diff --git a/.gitignore b/.gitignore index 4660117e..531f322a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # library build build +temp # misc .DS_Store @@ -27,4 +28,4 @@ yarn-debug.log* yarn-error.log* # npm pack default output -sima-land-moleculas-0.0.0.tgz \ No newline at end of file +sima-land-moleculas-0.0.0.tgz diff --git a/package-lock.json b/package-lock.json index 1938cb4f..5ae32e9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "node": ">=16.15.1" }, "peerDependencies": { - "@sima-land/ui-nucleons": "^45.0.0-alpha.24", + "@sima-land/ui-nucleons": "^45.0.0-alpha.25", "@sima-land/ui-quarks": "^5.1.1", "react": "^17.0 || ^18.0" } @@ -3143,9 +3143,9 @@ } }, "node_modules/@sima-land/ui-nucleons": { - "version": "45.0.0-alpha.24", - "resolved": "https://registry.npmjs.org/@sima-land/ui-nucleons/-/ui-nucleons-45.0.0-alpha.24.tgz", - "integrity": "sha512-dd/kxjW2ioMyANiVS/rtHNQeLQTz/yb6P67U/zkqGLk4hVJ0+jL2sXjUqf7fu0jOKE83txZ6XtjyQvElc5Q0Ow==", + "version": "45.0.0-alpha.25", + "resolved": "https://registry.npmjs.org/@sima-land/ui-nucleons/-/ui-nucleons-45.0.0-alpha.25.tgz", + "integrity": "sha512-elyb9fyW3jx1JFUhB9zLAbsteJUu5cXionnWZdze2Wutq2mZcfYaY77TTfw8dc0gkJoPPddoZ5ZNxh/OBRRrlg==", "peer": true, "dependencies": { "@floating-ui/react": "^0.26.13", diff --git a/package.json b/package.json index 8f36b7d2..f18a516d 100644 --- a/package.json +++ b/package.json @@ -11,11 +11,12 @@ }, "scripts": { "prepare": "husky", - "build": "npm run build:clean && npm run build:scripts && npm run build:assets && npm run build:package", + "build": "npm run build:sync-exports && npm run build:clean && npm run build:scripts && npm run build:assets && npm run build:package", "build:clean": "rm -rf build", "build:scripts": "tsc --project tsconfig.build.json", - "build:assets": "node scripts/build-assets.mjs", + "build:assets": "node scripts/copy-assets.mjs", "build:package": "cd build && npm pkg delete scripts.prepare && cd ..", + "build:sync-exports": "node scripts/emit-exports.mjs && npm pkg set --json exports=\"$(cat ./temp/exports.json)\" && rm -rf temp/exports.json", "type-check": "tsc -p . --noEmit", "lint": "npm run lint:scripts && npm run lint:styles", "lint:scripts": "eslint src", @@ -57,8 +58,39 @@ "typescript": "^5.3.3" }, "peerDependencies": { - "@sima-land/ui-nucleons": "^45.0.0-alpha.24", + "@sima-land/ui-nucleons": "^45.0.0-alpha.25", "@sima-land/ui-quarks": "^5.1.1", "react": "^17.0 || ^18.0" + }, + "exports": { + "./common/components/badge-list": "./common/components/badge-list/index.js", + "./common/components/badge": "./common/components/badge/index.js", + "./common/components/breadcrumbs": "./common/components/breadcrumbs/index.js", + "./common/components/hover-slider": "./common/components/hover-slider/index.js", + "./common/components/img-stub": "./common/components/img-stub/index.js", + "./common/components/interactive-image": "./common/components/interactive-image/index.js", + "./common/components/interactive-image/interactive-image-util.scss": "./common/components/interactive-image/interactive-image-util.scss", + "./common/components/media-gallery": "./common/components/media-gallery/index.js", + "./common/components/media-modal": "./common/components/media-modal/index.js", + "./common/components/modifier": "./common/components/modifier/index.js", + "./common/components/pagination-controls": "./common/components/pagination-controls/index.js", + "./common/components/product-image": "./common/components/product-image/index.js", + "./common/components/product-info": "./common/components/product-info/index.js", + "./common/components/rating-counter": "./common/components/rating-counter/index.js", + "./common/components/rating-counter/rating-counter-util.scss": "./common/components/rating-counter/rating-counter-util.scss", + "./common/hooks": "./common/hooks/index.js", + "./desktop/components/breadcrumbs": "./desktop/components/breadcrumbs/index.js", + "./desktop/components/gallery-modal": "./desktop/components/gallery-modal/index.js", + "./desktop/components/person-info": "./desktop/components/person-info/index.js", + "./desktop/components/product-carousel": "./desktop/components/product-carousel/index.js", + "./desktop/components/promotion-card": "./desktop/components/promotion-card/index.js", + "./mobile/components/action-circles": "./mobile/components/action-circles/index.js", + "./mobile/components/action-list": "./mobile/components/action-list/index.js", + "./mobile/components/breadcrumbs": "./mobile/components/breadcrumbs/index.js", + "./mobile/components/person-info": "./mobile/components/person-info/index.js", + "./mobile/components/product-row": "./mobile/components/product-row/index.js", + "./mobile/components/product-slider": "./mobile/components/product-slider/index.js", + "./mobile/components/search-bar": "./mobile/components/search-bar/index.js", + "./mobile/components/select-screen": "./mobile/components/select-screen/index.js" } } diff --git a/scripts/build-assets.mjs b/scripts/copy-assets.mjs similarity index 92% rename from scripts/build-assets.mjs rename to scripts/copy-assets.mjs index 03353622..4e78b5bb 100644 --- a/scripts/build-assets.mjs +++ b/scripts/copy-assets.mjs @@ -1,4 +1,4 @@ -/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */ +/* eslint-disable jsdoc/require-jsdoc */ import copyfiles from 'copyfiles'; function copy(paths, options = {}) { diff --git a/scripts/emit-exports.mjs b/scripts/emit-exports.mjs new file mode 100644 index 00000000..6f5d4808 --- /dev/null +++ b/scripts/emit-exports.mjs @@ -0,0 +1,33 @@ +import fs from 'node:fs/promises'; +import path from 'node:path'; +import glob from 'fast-glob'; + +const paths = await glob( + [ + // + './src/{common,desktop,mobile}/components/*/index.{js,jsx,ts,tsx}', + './src/{common,desktop,mobile}/hooks/index.{js,jsx,ts,tsx}', + './src/**/*.scss', + ], + { + ignore: [ + // + './src/**/*.m.scss', + './src/**/_*.scss', + ], + }, +); + +const data = Object.fromEntries( + paths + .sort() + .map(p => [ + `./${path.relative('src', p).replace(/\/index\.(js|jsx|ts|tsx)$/g, '')}`, + `./${path.relative('src', p).replace(/\.(js|jsx|ts|tsx)$/g, '.js')}`, + ]), +); + +const outputPath = path.resolve(process.cwd(), 'temp/exports.json'); + +await fs.mkdir(path.dirname(outputPath), { recursive: true }); +await fs.writeFile(outputPath, JSON.stringify(data, null, 2), 'utf-8'); diff --git a/src/common/components/badge/badge.m.scss b/src/common/components/badge/badge.m.scss index c9b70a2c..2a5d4751 100644 --- a/src/common/components/badge/badge.m.scss +++ b/src/common/components/badge/badge.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; $badge-size: 20px; $icon-size: 16px; diff --git a/src/common/components/hover-slider/hover-slider.m.scss b/src/common/components/hover-slider/hover-slider.m.scss index 1254a26e..383fd2b6 100644 --- a/src/common/components/hover-slider/hover-slider.m.scss +++ b/src/common/components/hover-slider/hover-slider.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .root { position: relative; diff --git a/src/common/components/interactive-image/interactive-image-util.scss b/src/common/components/interactive-image/interactive-image-util.scss index 03570dec..61848a39 100644 --- a/src/common/components/interactive-image/interactive-image-util.scss +++ b/src/common/components/interactive-image/interactive-image-util.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; @mixin dot-size-default { --dot-size: 32px; diff --git a/src/common/components/interactive-image/interactive-image.m.scss b/src/common/components/interactive-image/interactive-image.m.scss index 3cc26977..57a8a95c 100644 --- a/src/common/components/interactive-image/interactive-image.m.scss +++ b/src/common/components/interactive-image/interactive-image.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; @use './interactive-image-util'; .root { diff --git a/src/common/components/media-modal/layout.m.scss b/src/common/components/media-modal/layout.m.scss index 62144fbe..423d9b34 100644 --- a/src/common/components/media-modal/layout.m.scss +++ b/src/common/components/media-modal/layout.m.scss @@ -1,5 +1,5 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .layout { display: flex; diff --git a/src/common/components/media-modal/parts/parts.m.scss b/src/common/components/media-modal/parts/parts.m.scss index 9fa9038a..e1db542b 100644 --- a/src/common/components/media-modal/parts/parts.m.scss +++ b/src/common/components/media-modal/parts/parts.m.scss @@ -1,5 +1,5 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .header-layout { min-height: 40px; // ВАЖНО: чтобы при отсутствии табов не уменьшалась высота diff --git a/src/common/components/media-modal/parts/review.m.scss b/src/common/components/media-modal/parts/review.m.scss index cfb190c8..58ba0ecd 100644 --- a/src/common/components/media-modal/parts/review.m.scss +++ b/src/common/components/media-modal/parts/review.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; @use 'pkg:@sima-land/ui-nucleons/colors.scss'; .root { diff --git a/src/common/components/media-modal/parts/scroll-section.m.scss b/src/common/components/media-modal/parts/scroll-section.m.scss index 82c356e2..a84af04f 100644 --- a/src/common/components/media-modal/parts/scroll-section.m.scss +++ b/src/common/components/media-modal/parts/scroll-section.m.scss @@ -1,5 +1,5 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .inner { display: flex; diff --git a/src/common/components/media-modal/parts/thumbnail.m.scss b/src/common/components/media-modal/parts/thumbnail.m.scss index 9d6edc66..8c39734b 100644 --- a/src/common/components/media-modal/parts/thumbnail.m.scss +++ b/src/common/components/media-modal/parts/thumbnail.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; .root { display: block; diff --git a/src/common/components/media-modal/parts/thumbnails.m.scss b/src/common/components/media-modal/parts/thumbnails.m.scss index 001c2247..e81cb8c3 100644 --- a/src/common/components/media-modal/parts/thumbnails.m.scss +++ b/src/common/components/media-modal/parts/thumbnails.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .list-desktop { display: flex; diff --git a/src/common/components/pagination-controls/pagination-controls.m.scss b/src/common/components/pagination-controls/pagination-controls.m.scss index f29fe8d8..c62c5b9c 100644 --- a/src/common/components/pagination-controls/pagination-controls.m.scss +++ b/src/common/components/pagination-controls/pagination-controls.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .layout { display: flex; diff --git a/src/common/components/product-info/parts/image-button.m.scss b/src/common/components/product-info/parts/image-button.m.scss index 5113f265..53e5bd51 100644 --- a/src/common/components/product-info/parts/image-button.m.scss +++ b/src/common/components/product-info/parts/image-button.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; .root { width: 24px; diff --git a/src/common/components/product-info/parts/parts.m.scss b/src/common/components/product-info/parts/parts.m.scss index 1ac30560..87fbe3b8 100644 --- a/src/common/components/product-info/parts/parts.m.scss +++ b/src/common/components/product-info/parts/parts.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; .text-button { font-size: 14px; diff --git a/src/common/components/product-info/parts/rating-counter.m.scss b/src/common/components/product-info/parts/rating-counter.m.scss index e7b68c7f..b587a085 100644 --- a/src/common/components/product-info/parts/rating-counter.m.scss +++ b/src/common/components/product-info/parts/rating-counter.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; @use '../../rating-counter/rating-counter-util'; .root { diff --git a/src/common/components/product-info/parts/wait-list-added-link.m.scss b/src/common/components/product-info/parts/wait-list-added-link.m.scss index 1a7fd42e..7d24bb90 100644 --- a/src/common/components/product-info/parts/wait-list-added-link.m.scss +++ b/src/common/components/product-info/parts/wait-list-added-link.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; .root { font-size: 14px; diff --git a/src/common/components/rating-counter/rating-counter.m.scss b/src/common/components/rating-counter/rating-counter.m.scss index 8748005d..baada169 100644 --- a/src/common/components/rating-counter/rating-counter.m.scss +++ b/src/common/components/rating-counter/rating-counter.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; @use './rating-counter-util'; .root { diff --git a/src/desktop/components/gallery-modal/components/gallery-modal.m.scss b/src/desktop/components/gallery-modal/components/gallery-modal.m.scss index c8dfa597..929dfb4e 100644 --- a/src/desktop/components/gallery-modal/components/gallery-modal.m.scss +++ b/src/desktop/components/gallery-modal/components/gallery-modal.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .root { position: absolute; diff --git a/src/desktop/components/product-carousel/product-carousel.m.scss b/src/desktop/components/product-carousel/product-carousel.m.scss index 4be211cd..432fab52 100644 --- a/src/desktop/components/product-carousel/product-carousel.m.scss +++ b/src/desktop/components/product-carousel/product-carousel.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; @use 'pkg:@sima-land/ui-nucleons/colors.scss'; $breakpoints: 'xs', 's', 'm', 'l', 'xl'; diff --git a/src/desktop/components/promotion-card/variables.scss b/src/desktop/components/promotion-card/_variables.scss similarity index 100% rename from src/desktop/components/promotion-card/variables.scss rename to src/desktop/components/promotion-card/_variables.scss diff --git a/src/desktop/components/promotion-card/placeholder.m.scss b/src/desktop/components/promotion-card/placeholder.m.scss index aaa60f37..3b659edc 100644 --- a/src/desktop/components/promotion-card/placeholder.m.scss +++ b/src/desktop/components/promotion-card/placeholder.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use './variables'; +@use './_variables'; .part { background: colors.$basic-gray4; diff --git a/src/desktop/components/promotion-card/promotion-card.m.scss b/src/desktop/components/promotion-card/promotion-card.m.scss index 226d668d..cb7ca45a 100644 --- a/src/desktop/components/promotion-card/promotion-card.m.scss +++ b/src/desktop/components/promotion-card/promotion-card.m.scss @@ -1,7 +1,7 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; -@use 'pkg:@sima-land/ui-nucleons/shadows'; -@use './variables'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; +@use 'pkg:@sima-land/ui-nucleons/shadows.scss'; +@use './_variables'; .root { background: #fff; diff --git a/src/mobile/components/action-circles/action-circles.m.scss b/src/mobile/components/action-circles/action-circles.m.scss index c0cb0ccd..3d2030d2 100644 --- a/src/mobile/components/action-circles/action-circles.m.scss +++ b/src/mobile/components/action-circles/action-circles.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .circles { display: flex; diff --git a/src/mobile/components/action-list/action-list.m.scss b/src/mobile/components/action-list/action-list.m.scss index c0cb0ccd..3d2030d2 100644 --- a/src/mobile/components/action-list/action-list.m.scss +++ b/src/mobile/components/action-list/action-list.m.scss @@ -1,5 +1,5 @@ @use 'pkg:@sima-land/ui-nucleons/colors.scss'; -@use 'pkg:@sima-land/ui-nucleons/utils'; +@use 'pkg:@sima-land/ui-nucleons/utils.scss'; .circles { display: flex; diff --git a/src/mobile/components/product-slider/product-slider.m.scss b/src/mobile/components/product-slider/product-slider.m.scss index 04c2c8db..221a9b61 100644 --- a/src/mobile/components/product-slider/product-slider.m.scss +++ b/src/mobile/components/product-slider/product-slider.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; .item { display: flex; diff --git a/src/mobile/components/select-screen/select-screen.m.scss b/src/mobile/components/select-screen/select-screen.m.scss index 578c594d..21489526 100644 --- a/src/mobile/components/select-screen/select-screen.m.scss +++ b/src/mobile/components/select-screen/select-screen.m.scss @@ -1,4 +1,4 @@ -@use 'pkg:@sima-land/ui-nucleons/breakpoints'; +@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss'; @use 'pkg:@sima-land/ui-nucleons/colors.scss'; .container {