@gem-sdk/core 1.37.5 → 2.0.0-dev.832
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AddOn.js +1 -18
- package/dist/cjs/components/ComponentToolbarPreview.js +1 -465
- package/dist/cjs/components/ComponentWrapper.js +1 -46
- package/dist/cjs/components/ComponentWrapperPreview.js +1 -136
- package/dist/cjs/components/Empty.js +1 -7
- package/dist/cjs/components/Render.js +1 -65
- package/dist/cjs/components/Render.liquid.js +14 -288
- package/dist/cjs/components/RenderBlock.js +1 -54
- package/dist/cjs/components/RenderCustomCode.js +3 -56
- package/dist/cjs/components/RenderPreview.js +1 -66
- package/dist/cjs/components/RenderSection.js +1 -23
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +1 -0
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +1 -0
- package/dist/cjs/components/ai-generator/components/PickProduct.js +1 -0
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +1 -0
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -0
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +1 -0
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +1 -0
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +1 -0
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +1 -0
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +1 -0
- package/dist/cjs/components/animation/AnimationWrapper.js +1 -0
- package/dist/cjs/components/constant.js +1 -54
- package/dist/cjs/components/resize/Resize.js +1 -16
- package/dist/cjs/components/resize/Spacing.js +1 -248
- package/dist/cjs/components/src/product/helpers/variant-presets.js +1 -56
- package/dist/cjs/components/theme-section/CreateThemeSection.js +1 -117
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +1 -36
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +1 -102
- package/dist/cjs/components/toolbar/Tooltip.js +1 -22
- package/dist/cjs/contexts/AddonContext.js +1 -36
- package/dist/cjs/contexts/BuilderComponent.js +1 -34
- package/dist/cjs/contexts/BuilderContext.js +1 -35
- package/dist/cjs/contexts/BuilderPreviewContext.js +1 -479
- package/dist/cjs/contexts/CartLineContext.js +1 -29
- package/dist/cjs/contexts/CollectionContext.js +1 -38
- package/dist/cjs/contexts/ModalContext.js +1 -47
- package/dist/cjs/contexts/PageContext.js +1 -44
- package/dist/cjs/contexts/ProductContext.js +1 -156
- package/dist/cjs/contexts/ProductListContext.js +1 -32
- package/dist/cjs/contexts/SectionContext.js +1 -53
- package/dist/cjs/contexts/ShopContext.js +1 -80
- package/dist/cjs/graphql/fragments/analytic.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection-product.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection.generated.js +2 -6
- package/dist/cjs/graphql/fragments/custom-code.generated.js +2 -6
- package/dist/cjs/graphql/fragments/custom-font.generated.js +2 -6
- package/dist/cjs/graphql/fragments/data-seo.generated.js +2 -6
- package/dist/cjs/graphql/fragments/media.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product-little.generated.js +11 -6
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product-option.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product.generated.js +11 -6
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +3 -9
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +2 -6
- package/dist/cjs/graphql/fragments/selected-option.generated.js +2 -6
- package/dist/cjs/graphql/fragments/variant.generated.js +2 -6
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +3 -7
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +2 -16
- package/dist/cjs/graphql/queries/collection.generated.js +2 -14
- package/dist/cjs/graphql/queries/collections.generated.js +2 -9
- package/dist/cjs/graphql/queries/preview-page.generated.js +2 -14
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +2 -11
- package/dist/cjs/graphql/queries/product-medias.generated.js +2 -8
- package/dist/cjs/graphql/queries/product-value-label.generated.js +2 -6
- package/dist/cjs/graphql/queries/product-variants.generated.js +2 -10
- package/dist/cjs/graphql/queries/products.generated.js +12 -17
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +2 -15
- package/dist/cjs/graphql/queries/store-property.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +13 -0
- package/dist/cjs/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +34 -0
- package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +22 -0
- package/dist/cjs/helpers/GlobalEvent.js +1 -19
- package/dist/cjs/helpers/animations.js +1 -213
- package/dist/cjs/helpers/background.js +1 -230
- package/dist/cjs/helpers/borders.js +4 -183
- package/dist/cjs/helpers/carousel.js +1 -58
- package/dist/cjs/helpers/clone-deep.js +1 -5
- package/dist/cjs/helpers/cls.js +1 -16
- package/dist/cjs/helpers/colors.js +1 -184
- package/dist/cjs/helpers/compose-advance-style.js +1 -268
- package/dist/cjs/helpers/constant.js +1 -23
- package/dist/cjs/helpers/convert.js +1 -7
- package/dist/cjs/helpers/covert-entities-html.js +1 -19
- package/dist/cjs/helpers/css-variable.js +1 -7
- package/dist/cjs/helpers/email.js +1 -11
- package/dist/cjs/helpers/filter-toolbar-preview.js +1 -14
- package/dist/cjs/helpers/flatten-connection.js +1 -9
- package/dist/cjs/helpers/get-resonsive-value.js +1 -36
- package/dist/cjs/helpers/get-shortname.js +1 -92
- package/dist/cjs/helpers/icon-list.js +1 -61
- package/dist/cjs/helpers/is-browser.js +1 -9
- package/dist/cjs/helpers/is-defined.js +1 -7
- package/dist/cjs/helpers/is-empty-children.js +1 -15
- package/dist/cjs/helpers/is-safari.js +1 -9
- package/dist/cjs/helpers/layout.js +1 -59
- package/dist/cjs/helpers/load-script.js +1 -31
- package/dist/cjs/helpers/make-style.js +1 -163
- package/dist/cjs/helpers/normalize-builder-data.js +1 -23
- package/dist/cjs/helpers/prefetch-queries.js +1 -78
- package/dist/cjs/helpers/product.js +1 -48
- package/dist/cjs/helpers/queries/get-collection.js +1 -226
- package/dist/cjs/helpers/queries/get-collections.js +1 -21
- package/dist/cjs/helpers/queries/get-product-by-slug.js +1 -125
- package/dist/cjs/helpers/queries/get-product.js +1 -154
- package/dist/cjs/helpers/queries/get-products.js +1 -163
- package/dist/cjs/helpers/query.js +1 -29
- package/dist/cjs/helpers/radius.js +6 -140
- package/dist/cjs/helpers/render.js +1 -76
- package/dist/cjs/helpers/shadow.js +1 -57
- package/dist/cjs/helpers/size.js +4 -183
- package/dist/cjs/helpers/spacing.js +1 -43
- package/dist/cjs/helpers/tracking/fpixel.js +1 -28
- package/dist/cjs/helpers/tracking/gtag.js +1 -93
- package/dist/cjs/helpers/tracking/tiktokpixel.js +1 -17
- package/dist/cjs/helpers/typography.js +17 -126
- package/dist/cjs/helpers/variant.js +1 -11
- package/dist/cjs/hooks/animation/animations.js +1 -0
- package/dist/cjs/hooks/animation/useAnimationActions.js +1 -39
- package/dist/cjs/hooks/animation/useAnimationConfig.js +1 -29
- package/dist/cjs/hooks/animation/useAnimationPreview.js +1 -31
- package/dist/cjs/hooks/animation/useAnimationTarget.js +1 -120
- package/dist/cjs/hooks/animation/useApplyAnimation.js +1 -87
- package/dist/cjs/hooks/animation/useLivePageAnimation.js +1 -0
- package/dist/cjs/hooks/cart/use-add-to-cart.js +1 -20
- package/dist/cjs/hooks/cart/use-cart-data.js +1 -28
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +1 -20
- package/dist/cjs/hooks/cart/use-cart-note-update.js +1 -20
- package/dist/cjs/hooks/cart/use-create-cart.js +1 -22
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +1 -20
- package/dist/cjs/hooks/cart/use-update-cart-item.js +1 -20
- package/dist/cjs/hooks/shop/use-collection-query.js +1 -22
- package/dist/cjs/hooks/shop/use-collections-query.js +1 -17
- package/dist/cjs/hooks/shop/use-product-query.js +1 -22
- package/dist/cjs/hooks/shop/use-products-query.js +1 -23
- package/dist/cjs/hooks/shop.js +1 -126
- package/dist/cjs/hooks/use-current-device.js +1 -21
- package/dist/cjs/hooks/use-lazy-video.js +1 -15
- package/dist/cjs/hooks/useAnimations.js +1 -26
- package/dist/cjs/hooks/useCartId.js +1 -44
- package/dist/cjs/hooks/useCartLine.js +1 -11
- package/dist/cjs/hooks/useCartUI.js +1 -48
- package/dist/cjs/hooks/useCollection.js +1 -9
- package/dist/cjs/hooks/useFetchHandle.js +1 -13
- package/dist/cjs/hooks/useFormatMoney.js +1 -58
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +1 -113
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -10
- package/dist/cjs/hooks/useLoadScript.js +1 -32
- package/dist/cjs/hooks/useMoney.js +1 -84
- package/dist/cjs/hooks/usePrevious.js +1 -19
- package/dist/cjs/hooks/useProduct.js +1 -206
- package/dist/cjs/hooks/useProductList.js +1 -21
- package/dist/cjs/hooks/useSuspenseFetch.js +1 -27
- package/dist/cjs/hooks/useSwatchesOptions.js +1 -41
- package/dist/cjs/hooks/useToolbarPostPurchase.js +1 -0
- package/dist/cjs/index.js +1 -361
- package/dist/cjs/types/animations.js +1 -47
- package/dist/cjs/types/appAPI.js +1 -0
- package/dist/cjs/types/global-style.js +1 -15
- package/dist/cjs/types/shop.js +1 -2
- package/dist/cjs/web-components/src/helpers/styles/constant.js +1 -9
- package/dist/esm/components/AddOn.js +1 -14
- package/dist/esm/components/ComponentToolbarPreview.js +1 -463
- package/dist/esm/components/ComponentWrapper.js +1 -42
- package/dist/esm/components/ComponentWrapperPreview.js +1 -132
- package/dist/esm/components/Empty.js +1 -3
- package/dist/esm/components/Render.js +1 -61
- package/dist/esm/components/Render.liquid.js +14 -282
- package/dist/esm/components/RenderBlock.js +1 -50
- package/dist/esm/components/RenderCustomCode.js +3 -52
- package/dist/esm/components/RenderPreview.js +1 -62
- package/dist/esm/components/RenderSection.js +1 -19
- package/dist/esm/components/ai-generator/AIContentGenerator.js +1 -0
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +1 -0
- package/dist/esm/components/ai-generator/components/PickProduct.js +1 -0
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +1 -0
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -0
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +1 -0
- package/dist/esm/components/ai-generator/icons/AIIcon.js +1 -0
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +1 -0
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +1 -0
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +1 -0
- package/dist/esm/components/animation/AnimationWrapper.js +1 -0
- package/dist/esm/components/constant.js +1 -50
- package/dist/esm/components/resize/Resize.js +1 -12
- package/dist/esm/components/resize/Spacing.js +1 -244
- package/dist/esm/components/src/product/helpers/variant-presets.js +1 -54
- package/dist/esm/components/theme-section/CreateThemeSection.js +1 -115
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +1 -34
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +1 -100
- package/dist/esm/components/toolbar/Tooltip.js +1 -18
- package/dist/esm/contexts/AddonContext.js +1 -32
- package/dist/esm/contexts/BuilderComponent.js +1 -31
- package/dist/esm/contexts/BuilderContext.js +1 -32
- package/dist/esm/contexts/BuilderPreviewContext.js +1 -476
- package/dist/esm/contexts/CartLineContext.js +1 -26
- package/dist/esm/contexts/CollectionContext.js +1 -35
- package/dist/esm/contexts/ModalContext.js +1 -44
- package/dist/esm/contexts/PageContext.js +1 -41
- package/dist/esm/contexts/ProductContext.js +1 -153
- package/dist/esm/contexts/ProductListContext.js +1 -28
- package/dist/esm/contexts/SectionContext.js +1 -49
- package/dist/esm/contexts/ShopContext.js +1 -77
- package/dist/esm/graphql/fragments/analytic.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection-detail.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection-product.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection.generated.js +2 -4
- package/dist/esm/graphql/fragments/custom-code.generated.js +2 -4
- package/dist/esm/graphql/fragments/custom-font.generated.js +2 -4
- package/dist/esm/graphql/fragments/data-seo.generated.js +2 -4
- package/dist/esm/graphql/fragments/media.generated.js +2 -4
- package/dist/esm/graphql/fragments/product-little.generated.js +11 -4
- package/dist/esm/graphql/fragments/product-option-value.generated.js +2 -4
- package/dist/esm/graphql/fragments/product-option.generated.js +2 -4
- package/dist/esm/graphql/fragments/product.generated.js +11 -4
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-page-section.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +3 -6
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +2 -4
- package/dist/esm/graphql/fragments/selected-option.generated.js +2 -4
- package/dist/esm/graphql/fragments/variant.generated.js +2 -4
- package/dist/esm/graphql/mutations/page-view-up.generated.js +3 -5
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +10 -22
- package/dist/esm/graphql/queries/collection.generated.js +8 -18
- package/dist/esm/graphql/queries/collections.generated.js +3 -8
- package/dist/esm/graphql/queries/preview-page.generated.js +8 -18
- package/dist/esm/graphql/queries/product-little-detail.generated.js +5 -12
- package/dist/esm/graphql/queries/product-medias.generated.js +2 -6
- package/dist/esm/graphql/queries/product-value-label.generated.js +2 -4
- package/dist/esm/graphql/queries/product-variants.generated.js +4 -10
- package/dist/esm/graphql/queries/products.generated.js +18 -20
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +9 -20
- package/dist/esm/graphql/queries/store-property.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +13 -0
- package/dist/esm/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +34 -0
- package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +22 -0
- package/dist/esm/helpers/GlobalEvent.js +1 -15
- package/dist/esm/helpers/animations.js +1 -211
- package/dist/esm/helpers/background.js +1 -222
- package/dist/esm/helpers/borders.js +4 -175
- package/dist/esm/helpers/carousel.js +1 -54
- package/dist/esm/helpers/clone-deep.js +1 -3
- package/dist/esm/helpers/cls.js +1 -14
- package/dist/esm/helpers/colors.js +1 -169
- package/dist/esm/helpers/compose-advance-style.js +1 -261
- package/dist/esm/helpers/constant.js +1 -19
- package/dist/esm/helpers/convert.js +1 -4
- package/dist/esm/helpers/covert-entities-html.js +1 -17
- package/dist/esm/helpers/css-variable.js +1 -5
- package/dist/esm/helpers/email.js +1 -6
- package/dist/esm/helpers/filter-toolbar-preview.js +1 -9
- package/dist/esm/helpers/flatten-connection.js +1 -7
- package/dist/esm/helpers/get-resonsive-value.js +1 -31
- package/dist/esm/helpers/get-shortname.js +1 -90
- package/dist/esm/helpers/icon-list.js +1 -58
- package/dist/esm/helpers/is-browser.js +1 -5
- package/dist/esm/helpers/is-defined.js +1 -5
- package/dist/esm/helpers/is-empty-children.js +1 -10
- package/dist/esm/helpers/is-safari.js +1 -5
- package/dist/esm/helpers/layout.js +1 -54
- package/dist/esm/helpers/load-script.js +1 -29
- package/dist/esm/helpers/make-style.js +1 -149
- package/dist/esm/helpers/normalize-builder-data.js +1 -21
- package/dist/esm/helpers/prefetch-queries.js +1 -76
- package/dist/esm/helpers/product.js +1 -44
- package/dist/esm/helpers/queries/get-collection.js +1 -223
- package/dist/esm/helpers/queries/get-collections.js +1 -19
- package/dist/esm/helpers/queries/get-product-by-slug.js +1 -123
- package/dist/esm/helpers/queries/get-product.js +1 -150
- package/dist/esm/helpers/queries/get-products.js +1 -161
- package/dist/esm/helpers/query.js +1 -25
- package/dist/esm/helpers/radius.js +6 -132
- package/dist/esm/helpers/render.js +1 -68
- package/dist/esm/helpers/shadow.js +1 -52
- package/dist/esm/helpers/size.js +4 -171
- package/dist/esm/helpers/spacing.js +1 -40
- package/dist/esm/helpers/tracking/fpixel.js +1 -24
- package/dist/esm/helpers/tracking/gtag.js +1 -87
- package/dist/esm/helpers/tracking/tiktokpixel.js +1 -15
- package/dist/esm/helpers/typography.js +17 -116
- package/dist/esm/helpers/variant.js +1 -9
- package/dist/esm/hooks/animation/animations.js +1 -0
- package/dist/esm/hooks/animation/useAnimationActions.js +1 -37
- package/dist/esm/hooks/animation/useAnimationConfig.js +1 -27
- package/dist/esm/hooks/animation/useAnimationPreview.js +1 -29
- package/dist/esm/hooks/animation/useAnimationTarget.js +1 -118
- package/dist/esm/hooks/animation/useApplyAnimation.js +1 -83
- package/dist/esm/hooks/animation/useLivePageAnimation.js +1 -0
- package/dist/esm/hooks/cart/use-add-to-cart.js +1 -18
- package/dist/esm/hooks/cart/use-cart-data.js +1 -26
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +1 -18
- package/dist/esm/hooks/cart/use-cart-note-update.js +1 -18
- package/dist/esm/hooks/cart/use-create-cart.js +1 -20
- package/dist/esm/hooks/cart/use-remove-cart-item.js +1 -18
- package/dist/esm/hooks/cart/use-update-cart-item.js +1 -18
- package/dist/esm/hooks/shop/use-collection-query.js +1 -20
- package/dist/esm/hooks/shop/use-collections-query.js +1 -15
- package/dist/esm/hooks/shop/use-product-query.js +1 -20
- package/dist/esm/hooks/shop/use-products-query.js +1 -21
- package/dist/esm/hooks/shop.js +1 -111
- package/dist/esm/hooks/use-current-device.js +1 -19
- package/dist/esm/hooks/use-lazy-video.js +1 -13
- package/dist/esm/hooks/useAnimations.js +1 -24
- package/dist/esm/hooks/useCartId.js +1 -40
- package/dist/esm/hooks/useCartLine.js +1 -7
- package/dist/esm/hooks/useCartUI.js +1 -44
- package/dist/esm/hooks/useCollection.js +1 -7
- package/dist/esm/hooks/useFetchHandle.js +1 -11
- package/dist/esm/hooks/useFormatMoney.js +1 -56
- package/dist/esm/hooks/useInitialSwatchesOptions.js +1 -109
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -6
- package/dist/esm/hooks/useLoadScript.js +1 -28
- package/dist/esm/hooks/useMoney.js +1 -80
- package/dist/esm/hooks/usePrevious.js +1 -17
- package/dist/esm/hooks/useProduct.js +1 -192
- package/dist/esm/hooks/useProductList.js +1 -16
- package/dist/esm/hooks/useSuspenseFetch.js +1 -23
- package/dist/esm/hooks/useSwatchesOptions.js +1 -37
- package/dist/esm/hooks/useToolbarPostPurchase.js +1 -0
- package/dist/esm/index.js +1 -100
- package/dist/esm/types/animations.js +1 -47
- package/dist/esm/types/appAPI.js +1 -0
- package/dist/esm/types/global-style.js +1 -12
- package/dist/esm/web-components/src/helpers/styles/constant.js +1 -7
- package/dist/types/index.d.ts +24802 -6237
- package/package.json +8 -3
|
@@ -1,161 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { calculateFirstProduct } from './get-collection.js';
|
|
3
|
-
import { fetchVariants, fetchMedias } from './get-product.js';
|
|
4
|
-
|
|
5
|
-
const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
|
|
6
|
-
const products = await loopFetchProducts(fetcher, {
|
|
7
|
-
ids,
|
|
8
|
-
isSample,
|
|
9
|
-
isStorefront,
|
|
10
|
-
defaultSelectedProductCount
|
|
11
|
-
});
|
|
12
|
-
if (!products) {
|
|
13
|
-
throw new Error('Product not found');
|
|
14
|
-
}
|
|
15
|
-
const [mergedVariant, mergedMedias] = await Promise.all([
|
|
16
|
-
mergeVariantsToProducts({
|
|
17
|
-
fetcher,
|
|
18
|
-
products,
|
|
19
|
-
isSample,
|
|
20
|
-
isStorefront
|
|
21
|
-
}),
|
|
22
|
-
mergeMediasToProducts({
|
|
23
|
-
fetcher,
|
|
24
|
-
products,
|
|
25
|
-
isSample,
|
|
26
|
-
isStorefront
|
|
27
|
-
})
|
|
28
|
-
]);
|
|
29
|
-
return {
|
|
30
|
-
...products,
|
|
31
|
-
products: {
|
|
32
|
-
...products.products,
|
|
33
|
-
edges: products.products?.edges.map((edge)=>{
|
|
34
|
-
const medias = mergedMedias.find((item)=>item.productId === edge.node?.baseID);
|
|
35
|
-
const variants = mergedVariant.find((item)=>item.productId === edge.node?.baseID);
|
|
36
|
-
if (edge.node) {
|
|
37
|
-
return {
|
|
38
|
-
...edge,
|
|
39
|
-
node: {
|
|
40
|
-
...edge.node,
|
|
41
|
-
variants: {
|
|
42
|
-
...edge.node?.variants,
|
|
43
|
-
edges: variants?.items ?? []
|
|
44
|
-
},
|
|
45
|
-
medias: {
|
|
46
|
-
...edge.node?.medias,
|
|
47
|
-
edges: medias?.items ?? []
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return edge;
|
|
53
|
-
}) ?? []
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
const fetchProducts = async (fetcher, variables)=>{
|
|
58
|
-
return fetcher([
|
|
59
|
-
ProductsDocument,
|
|
60
|
-
variables
|
|
61
|
-
]);
|
|
62
|
-
};
|
|
63
|
-
const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
|
|
64
|
-
const defaultNumberOfProducts = defaultSelectedProductCount || 4;
|
|
65
|
-
const numberOfProducts = (ids?.length == 0 ? defaultNumberOfProducts : ids?.length) ?? defaultNumberOfProducts;
|
|
66
|
-
const productsPerPage = 8; // number of products per page
|
|
67
|
-
let variables; // variables of collection query
|
|
68
|
-
let productAfterFetcher; // product after of collection query
|
|
69
|
-
let dataProducts; // data of collection query
|
|
70
|
-
let hasNextPage; //
|
|
71
|
-
let firstProducts;
|
|
72
|
-
let currentPage = 1;
|
|
73
|
-
// counter number of queries
|
|
74
|
-
const pages = Math.ceil(numberOfProducts / productsPerPage);
|
|
75
|
-
while(currentPage <= pages && hasNextPage !== false){
|
|
76
|
-
variables = {
|
|
77
|
-
first: calculateFirstProduct(numberOfProducts, currentPage, productsPerPage),
|
|
78
|
-
firstMedia: 1,
|
|
79
|
-
firstVariant: 1,
|
|
80
|
-
orderBy: {
|
|
81
|
-
field: 'PLATFORM_CREATED_AT',
|
|
82
|
-
direction: 'DESC'
|
|
83
|
-
},
|
|
84
|
-
orderByMedia: {
|
|
85
|
-
field: 'POSITION',
|
|
86
|
-
direction: 'ASC'
|
|
87
|
-
},
|
|
88
|
-
where: {
|
|
89
|
-
status: 'ACTIVE',
|
|
90
|
-
isSample,
|
|
91
|
-
...isStorefront && {
|
|
92
|
-
isStorefront
|
|
93
|
-
},
|
|
94
|
-
...ids?.length ? {
|
|
95
|
-
baseIDIn: ids
|
|
96
|
-
} : {}
|
|
97
|
-
},
|
|
98
|
-
after: productAfterFetcher
|
|
99
|
-
};
|
|
100
|
-
const pageData = await fetchProducts(fetcher, variables);
|
|
101
|
-
productAfterFetcher = pageData?.products?.pageInfo?.endCursor;
|
|
102
|
-
if (currentPage === 1) {
|
|
103
|
-
dataProducts = pageData; // set data of first page
|
|
104
|
-
firstProducts = pageData;
|
|
105
|
-
} else if (firstProducts?.products && pageData?.products?.edges.length) {
|
|
106
|
-
// concat new values to the old ones
|
|
107
|
-
firstProducts.products = {
|
|
108
|
-
edges: firstProducts.products.edges.concat(pageData?.products?.edges),
|
|
109
|
-
pageInfo: pageData?.products?.pageInfo
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
currentPage++;
|
|
113
|
-
// hasNextPage = false if there is no more pages then break the loop
|
|
114
|
-
if (!firstProducts) {
|
|
115
|
-
hasNextPage = false;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return dataProducts;
|
|
120
|
-
};
|
|
121
|
-
const mergeVariantsToProducts = async ({ fetcher, products, isSample, isStorefront })=>{
|
|
122
|
-
const productsWithVariants = await Promise.all(products?.products?.edges?.map(async (product)=>{
|
|
123
|
-
const variants = await fetchVariants(fetcher, {
|
|
124
|
-
id: product?.node?.baseID,
|
|
125
|
-
isSample,
|
|
126
|
-
isStorefront
|
|
127
|
-
});
|
|
128
|
-
return {
|
|
129
|
-
productId: product?.node?.baseID,
|
|
130
|
-
items: variants
|
|
131
|
-
};
|
|
132
|
-
}) ?? []);
|
|
133
|
-
return productsWithVariants;
|
|
134
|
-
};
|
|
135
|
-
const mergeMediasToProducts = async ({ fetcher, products, isSample, isStorefront })=>{
|
|
136
|
-
const productsWithMedias = await Promise.all(products?.products?.edges?.map(async (product)=>{
|
|
137
|
-
const medias = await fetchMedias(fetcher, {
|
|
138
|
-
id: product?.node?.baseID,
|
|
139
|
-
isSample,
|
|
140
|
-
isStorefront
|
|
141
|
-
});
|
|
142
|
-
return {
|
|
143
|
-
productId: product?.node?.baseID,
|
|
144
|
-
items: medias
|
|
145
|
-
};
|
|
146
|
-
}) ?? []);
|
|
147
|
-
return productsWithMedias;
|
|
148
|
-
}; // future can be used for fetching products with paging ids
|
|
149
|
-
// const pagingQuery = (
|
|
150
|
-
// data: string[],
|
|
151
|
-
// currentPage: number,
|
|
152
|
-
// productsPerPage: number,
|
|
153
|
-
// first: number,
|
|
154
|
-
// ): string[] => {
|
|
155
|
-
// return data.slice(
|
|
156
|
-
// (currentPage - 1) * productsPerPage,
|
|
157
|
-
// (currentPage - 1) * productsPerPage + first,
|
|
158
|
-
// );
|
|
159
|
-
// };
|
|
160
|
-
|
|
161
|
-
export { getProducts };
|
|
1
|
+
import{ProductsDocument as e}from"../../graphql/queries/products.generated.js";import{calculateFirstProduct as t}from"./get-collection.js";import{fetchVariants as r,fetchMedias as d}from"./get-product.js";let getProducts=async(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:o,allStatus:s})=>{let a=await loopFetchProducts(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:o,allStatus:s});if(!a)throw Error("Product not found");let[i,c]=await Promise.all([mergeVariantsToProducts({fetcher:e,products:a,isSample:r,isStorefront:d}),mergeMediasToProducts({fetcher:e,products:a,isSample:r,isStorefront:d})]);return{...a,products:{...a.products,edges:a.products?.edges.map(e=>{let t=c.find(t=>t.productId===e.node?.baseID),r=i.find(t=>t.productId===e.node?.baseID);return e.node?{...e,node:{...e.node,variants:{...e.node?.variants,edges:r?.items??[]},medias:{...e.node?.medias,edges:t?.items??[]}}}:e})??[]}}},getProductQueryAll=async(e,t)=>{let r=t?.limit||4;delete t.limit;let d={first:r,firstMedia:1,firstVariant:1,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},where:{status:"ACTIVE",...t}},o=await fetchProducts(e,d);return o},fetchProducts=async(t,r)=>t([e,r]),loopFetchProducts=async(e,{ids:r,isSample:d,isStorefront:o,defaultSelectedProductCount:s,allStatus:a})=>{let i,c,n,u,l;let p=s||4,g=(r?.length==0?p:r?.length)??p,f=1,m=Math.ceil(g/8);for(;f<=m&&!1!==u;){let s=a?{}:{status:"ACTIVE"};i={first:t(g,f,8),firstMedia:1,firstVariant:1,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},where:{...s,isSample:d,...o&&{isStorefront:o},...r?.length?{baseIDIn:r}:{}},after:c};let p=await fetchProducts(e,i);if(c=p?.products?.pageInfo?.endCursor,1===f?(n=p,l=p):l?.products&&p?.products?.edges.length&&(l.products={edges:l.products.edges.concat(p?.products?.edges),pageInfo:p?.products?.pageInfo}),f++,!l){u=!1;break}}return n},mergeVariantsToProducts=async({fetcher:e,products:t,isSample:d,isStorefront:o})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await r(e,{id:t?.node?.baseID,isSample:d,isStorefront:o});return{productId:t?.node?.baseID,items:s}})??[]);return s},mergeMediasToProducts=async({fetcher:e,products:t,isSample:r,isStorefront:o})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await d(e,{id:t?.node?.baseID,isSample:r,isStorefront:o});return{productId:t?.node?.baseID,items:s}})??[]);return s};export{getProductQueryAll,getProducts};
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
return [
|
|
3
|
-
'query/product',
|
|
4
|
-
args
|
|
5
|
-
];
|
|
6
|
-
};
|
|
7
|
-
const generateCollectionQueryKey = (args)=>{
|
|
8
|
-
return [
|
|
9
|
-
'query/collection',
|
|
10
|
-
args
|
|
11
|
-
];
|
|
12
|
-
};
|
|
13
|
-
const generateProductsQueryKey = (args)=>{
|
|
14
|
-
return [
|
|
15
|
-
'query/products',
|
|
16
|
-
{
|
|
17
|
-
...args,
|
|
18
|
-
ids: [
|
|
19
|
-
...args.ids
|
|
20
|
-
].sort()
|
|
21
|
-
}
|
|
22
|
-
];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export { generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey };
|
|
1
|
+
let generateProductQueryKey=e=>["query/product",e],generateCollectionQueryKey=e=>["query/collection",e],generateProductsQueryKey=e=>["query/products",{...e,ids:[...e.ids].sort()}];export{generateCollectionQueryKey,generateProductQueryKey,generateProductsQueryKey};
|
|
@@ -1,132 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'custom',
|
|
8
|
-
'circle'
|
|
9
|
-
].includes(corner?.radiusType)) return makeStyle({
|
|
10
|
-
bblr: corner.bblr,
|
|
11
|
-
bbrr: corner.bbrr,
|
|
12
|
-
btlr: corner.btlr,
|
|
13
|
-
btrr: corner.btrr
|
|
14
|
-
});
|
|
15
|
-
return makeStyle({
|
|
16
|
-
radius: `var(--g-radius-${corner?.radiusType})`
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
const getRadiusCSSFromGlobal = (state, key, device)=>{
|
|
20
|
-
if (!key || !state) return {};
|
|
21
|
-
const suffix = device && device !== 'desktop' ? devicesMapping?.[device] : '';
|
|
22
|
-
const mState = stateMapping?.[state];
|
|
23
|
-
return {
|
|
24
|
-
[`-${mState}-radius${suffix}`]: `var(--g-radius-${key})`
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
const getCustomRadius = (state, radius, device)=>{
|
|
28
|
-
if (!radius || !state || radius?.radiusType !== 'custom') return {};
|
|
29
|
-
const suffix = device && device !== 'desktop' ? devicesMapping?.[device] : '';
|
|
30
|
-
const mState = stateMapping?.[state];
|
|
31
|
-
return {
|
|
32
|
-
[`-${mState}-bblr${suffix}`]: radius.bblr,
|
|
33
|
-
[`-${mState}-bbrr${suffix}`]: radius.bbrr,
|
|
34
|
-
[`-${mState}-btlr${suffix}`]: radius.btlr,
|
|
35
|
-
[`-${mState}-btrr${suffix}`]: radius.btrr
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const composeRadius = (value)=>{
|
|
39
|
-
if (!value) return {};
|
|
40
|
-
if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
|
|
41
|
-
return composeRadiusResponsiveState(value);
|
|
42
|
-
}
|
|
43
|
-
return composeRadiusState(value);
|
|
44
|
-
};
|
|
45
|
-
const composeRadiusResponsive = (radiusValue)=>{
|
|
46
|
-
const style = {};
|
|
47
|
-
Object.assign(style, getCustomRadius('normal', radiusValue?.desktop, 'desktop'));
|
|
48
|
-
Object.assign(style, getCustomRadius('normal', radiusValue?.tablet, 'tablet'));
|
|
49
|
-
Object.assign(style, getCustomRadius('normal', radiusValue?.mobile, 'mobile'));
|
|
50
|
-
return style;
|
|
51
|
-
};
|
|
52
|
-
const composeRadiusState = (radiusValue, device)=>{
|
|
53
|
-
const style = {};
|
|
54
|
-
switch(radiusValue?.normal?.radiusType){
|
|
55
|
-
case 'medium':
|
|
56
|
-
case 'large':
|
|
57
|
-
case 'small':
|
|
58
|
-
Object.assign(style, getRadiusCSSFromGlobal('normal', radiusValue?.normal?.radiusType, device));
|
|
59
|
-
break;
|
|
60
|
-
case 'circle':
|
|
61
|
-
case 'none':
|
|
62
|
-
case 'custom':
|
|
63
|
-
Object.assign(style, getCustomRadius('normal', radiusValue.normal, device));
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
switch(radiusValue?.hover?.radiusType){
|
|
67
|
-
case 'medium':
|
|
68
|
-
case 'large':
|
|
69
|
-
case 'small':
|
|
70
|
-
Object.assign(style, getRadiusCSSFromGlobal('hover', radiusValue?.hover?.radiusType, device));
|
|
71
|
-
break;
|
|
72
|
-
case 'circle':
|
|
73
|
-
case 'none':
|
|
74
|
-
case 'custom':
|
|
75
|
-
Object.assign(style, getCustomRadius('hover', radiusValue.hover, device));
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
switch(radiusValue?.focus?.radiusType){
|
|
79
|
-
case 'medium':
|
|
80
|
-
case 'large':
|
|
81
|
-
case 'small':
|
|
82
|
-
Object.assign(style, getRadiusCSSFromGlobal('focus', radiusValue?.focus?.radiusType, device));
|
|
83
|
-
break;
|
|
84
|
-
case 'circle':
|
|
85
|
-
case 'none':
|
|
86
|
-
case 'custom':
|
|
87
|
-
Object.assign(style, getCustomRadius('focus', radiusValue.focus, device));
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
return style;
|
|
91
|
-
};
|
|
92
|
-
const composeRadiusResponsiveState = (radiusValue)=>{
|
|
93
|
-
const style = {};
|
|
94
|
-
Object.assign(style, composeRadiusState(radiusValue?.desktop, 'desktop'));
|
|
95
|
-
Object.assign(style, composeRadiusState(radiusValue?.tablet, 'tablet'));
|
|
96
|
-
Object.assign(style, composeRadiusState(radiusValue?.mobile, 'mobile'));
|
|
97
|
-
return style;
|
|
98
|
-
};
|
|
99
|
-
const getRadiusStyleActiveState = (radiusValue)=>{
|
|
100
|
-
if (radiusValue?.active?.radiusType === 'custom') {
|
|
101
|
-
return getCustomRadius('normal', radiusValue?.active);
|
|
102
|
-
}
|
|
103
|
-
return getRadiusCSSFromGlobal('normal', radiusValue?.active?.radiusType);
|
|
104
|
-
};
|
|
105
|
-
const composeCornerCss = (value, important = false)=>{
|
|
106
|
-
if (!value) {
|
|
107
|
-
return '';
|
|
108
|
-
}
|
|
109
|
-
const { radiusType, bblr, bbrr, btlr, btrr } = value;
|
|
110
|
-
const sub = important ? ' !important' : '';
|
|
111
|
-
let radiusValue = undefined;
|
|
112
|
-
switch(radiusType){
|
|
113
|
-
case 'medium':
|
|
114
|
-
case 'large':
|
|
115
|
-
case 'small':
|
|
116
|
-
radiusValue = `border-radius: var(--g-radius-${radiusType});`;
|
|
117
|
-
break;
|
|
118
|
-
case 'circle':
|
|
119
|
-
case 'none':
|
|
120
|
-
case 'custom':
|
|
121
|
-
radiusValue = `
|
|
122
|
-
${bblr ? `border-bottom-left-radius: ${bblr}${sub};` : ''}
|
|
123
|
-
${bbrr ? `border-bottom-right-radius: ${bbrr}${sub};` : ''}
|
|
124
|
-
${btlr ? `border-top-left-radius: ${btlr}${sub};` : ''}
|
|
125
|
-
${btrr ? `border-top-right-radius: ${btrr}${sub};` : ''}
|
|
126
|
-
`;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
return radiusValue;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export { composeCornerCss, composeRadius, composeRadiusResponsive, getCornerCSSFromGlobal, getCustomRadius, getRadiusCSSFromGlobal, getRadiusStyleActiveState };
|
|
1
|
+
import{devicesMapping as e,stateMapping as s}from"./constant.js";import{makeStyle as a}from"./make-style.js";let getCornerCSSFromGlobal=e=>e?.radiusType?["custom","circle"].includes(e?.radiusType)?a({bblr:e.bblr,bbrr:e.bbrr,btlr:e.btlr,btrr:e.btrr}):a({radius:`var(--g-radius-${e?.radiusType})`}):{},getRadiusCSSFromGlobal=(a,t,r)=>{if(!t||!a)return{};let o=r&&"desktop"!==r?e?.[r]:"",i=s?.[a];return{[`-${i}-radius${o}`]:`var(--g-radius-${t})`}},getCustomRadius=(a,t,r)=>{if(!t||!a||t?.radiusType!=="custom")return{};let o=r&&"desktop"!==r?e?.[r]:"",i=s?.[a];return{[`-${i}-bblr${o}`]:t.bblr,[`-${i}-bbrr${o}`]:t.bbrr,[`-${i}-btlr${o}`]:t.btlr,[`-${i}-btrr${o}`]:t.btrr}},composeRadius=e=>e?"desktop"in e||"tablet"in e||"mobile"in e?composeRadiusResponsiveState(e):composeRadiusState(e):{},composeRadiusResponsive=e=>{let s={};return Object.assign(s,getCustomRadius("normal",e?.desktop,"desktop")),Object.assign(s,getCustomRadius("normal",e?.tablet,"tablet")),Object.assign(s,getCustomRadius("normal",e?.mobile,"mobile")),s},composeRadiusState=(e,s)=>{let a={};switch(e?.normal?.radiusType){case"medium":case"large":case"small":Object.assign(a,getRadiusCSSFromGlobal("normal",e?.normal?.radiusType,s));break;case"circle":case"none":case"custom":Object.assign(a,getCustomRadius("normal",e.normal,s))}switch(e?.hover?.radiusType){case"medium":case"large":case"small":Object.assign(a,getRadiusCSSFromGlobal("hover",e?.hover?.radiusType,s));break;case"circle":case"none":case"custom":Object.assign(a,getCustomRadius("hover",e.hover,s))}switch(e?.focus?.radiusType){case"medium":case"large":case"small":Object.assign(a,getRadiusCSSFromGlobal("focus",e?.focus?.radiusType,s));break;case"circle":case"none":case"custom":Object.assign(a,getCustomRadius("focus",e.focus,s))}return a},composeRadiusResponsiveState=e=>{let s={};return Object.assign(s,composeRadiusState(e?.desktop,"desktop")),Object.assign(s,composeRadiusState(e?.tablet,"tablet")),Object.assign(s,composeRadiusState(e?.mobile,"mobile")),s},getRadiusStyleActiveState=e=>e?.active?.radiusType==="custom"?getCustomRadius("normal",e?.active):getRadiusCSSFromGlobal("normal",e?.active?.radiusType),composeCornerCss=(e,s=!1)=>{let a;if(!e)return"";let{radiusType:t,bblr:r,bbrr:o,btlr:i,btrr:u}=e,c=s?" !important":"";switch(t){case"medium":case"large":case"small":a=`border-radius: var(--g-radius-${t});`;break;case"circle":case"none":case"custom":a=`
|
|
2
|
+
${r?`border-bottom-left-radius: ${r}${c};`:""}
|
|
3
|
+
${o?`border-bottom-right-radius: ${o}${c};`:""}
|
|
4
|
+
${i?`border-top-left-radius: ${i}${c};`:""}
|
|
5
|
+
${u?`border-top-right-radius: ${u}${c};`:""}
|
|
6
|
+
`}return a};export{composeCornerCss,composeRadius,composeRadiusResponsive,getCornerCSSFromGlobal,getCustomRadius,getRadiusCSSFromGlobal,getRadiusStyleActiveState};
|
|
@@ -1,68 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const isObject = (obj)=>{
|
|
3
|
-
if (typeof obj === 'object' && !Array.isArray(obj) && obj !== null) {
|
|
4
|
-
return true;
|
|
5
|
-
}
|
|
6
|
-
return false;
|
|
7
|
-
};
|
|
8
|
-
const props = (strings, ...keys)=>{
|
|
9
|
-
const props = keys[0];
|
|
10
|
-
const propsArr = [];
|
|
11
|
-
for(const attr in props){
|
|
12
|
-
if (Object.hasOwnProperty.call(props, attr)) {
|
|
13
|
-
const val = props[attr];
|
|
14
|
-
if (![
|
|
15
|
-
'symbol',
|
|
16
|
-
'object',
|
|
17
|
-
'function'
|
|
18
|
-
].includes(typeof val)) {
|
|
19
|
-
if (val) {
|
|
20
|
-
propsArr.push(`${attr}="${val}"`);
|
|
21
|
-
} else {
|
|
22
|
-
propsArr.push(`${attr}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return propsArr.join(' ');
|
|
28
|
-
};
|
|
29
|
-
const styles = (strings, ...keys)=>{
|
|
30
|
-
const styles = keys[0];
|
|
31
|
-
const styleArr = [];
|
|
32
|
-
for(const attr in styles){
|
|
33
|
-
if (Object.hasOwnProperty.call(styles, attr)) {
|
|
34
|
-
const val = styles[attr];
|
|
35
|
-
if (val !== undefined && val !== false) styleArr.push(`${attr}:${val}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return styleArr.join(';');
|
|
39
|
-
};
|
|
40
|
-
const dataStringify = (obj)=>{
|
|
41
|
-
return JSON.stringify(obj).replace(/\\"/g, '"');
|
|
42
|
-
};
|
|
43
|
-
const template = (strings, ...keys)=>{
|
|
44
|
-
let str = '';
|
|
45
|
-
strings.forEach((item, index)=>{
|
|
46
|
-
str += item;
|
|
47
|
-
if (keys[index] !== undefined) {
|
|
48
|
-
if (isObject(keys[index])) {
|
|
49
|
-
if (/style=["|']/.test(item)) {
|
|
50
|
-
str += styles`${keys[index]}`;
|
|
51
|
-
} else {
|
|
52
|
-
str += props`${keys[index]}`;
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
str += keys[index];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return str;
|
|
60
|
-
};
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
-
const composeMemo = (fn, _)=>fn();
|
|
63
|
-
const removeUndefinedValuesFromObject = (obj)=>{
|
|
64
|
-
Object.keys(obj).forEach((key)=>obj?.[key] === undefined && delete obj[key]);
|
|
65
|
-
return obj;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export { RenderIf, composeMemo, dataStringify, props, removeUndefinedValuesFromObject, styles, template };
|
|
1
|
+
let RenderIf=(e,t,r)=>e?"string"==typeof t?t:t():("string"==typeof r?r:r?.())??"",isObject=e=>!("object"!=typeof e||Array.isArray(e))&&null!==e,props=(e,...t)=>{let r=t[0],o=[];for(let e in r)if(Object.hasOwnProperty.call(r,e)){let t=r[e];["symbol","object","function"].includes(typeof t)||(t?o.push(`${e}="${t}"`):o.push(`${e}`))}return o.join(" ")},styles=(e,...t)=>{let r=t[0],o=[];for(let e in r)if(Object.hasOwnProperty.call(r,e)){let t=r[e];void 0!==t&&!1!==t&&o.push(`${e}:${t}`)}return o.join(";")},dataStringify=e=>JSON.stringify(e).replace(/\\"/g,'"'),template=(e,...t)=>{let r="";return e.forEach((e,o)=>{r+=e,void 0!==t[o]&&(isObject(t[o])?/style=["|']/.test(e)?r+=styles`${t[o]}`:r+=props`${t[o]}`:r+=t[o])}),r},composeMemo=(e,t)=>e(),removeUndefinedValuesFromObject=e=>(Object.keys(e).forEach(t=>e?.[t]===void 0&&delete e[t]),e);export{RenderIf,composeMemo,dataStringify,props,removeUndefinedValuesFromObject,styles,template};
|
|
@@ -1,52 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { stateMapping } from './constant.js';
|
|
3
|
-
import { getShortName } from './get-shortname.js';
|
|
4
|
-
|
|
5
|
-
const parseValueWithUnit = (valueWithUnit)=>{
|
|
6
|
-
const matches = valueWithUnit.match(/(\d+)(.+)/);
|
|
7
|
-
if (matches && matches.length === 3) {
|
|
8
|
-
const value = Number(matches[1] ?? 0);
|
|
9
|
-
const unit = matches[2];
|
|
10
|
-
return {
|
|
11
|
-
value,
|
|
12
|
-
unit: unit ?? 'px'
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
value: 0,
|
|
17
|
-
unit: 'px'
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
const getStyleShadow = (shadowStyle, isActiveState = false)=>{
|
|
21
|
-
const { styleAppliedFor, value, isEnableShadow } = shadowStyle || {};
|
|
22
|
-
let { state } = shadowStyle || {};
|
|
23
|
-
if (!state) state = 'normal';
|
|
24
|
-
if (!styleAppliedFor || !value) return {};
|
|
25
|
-
if (typeof value.distance == 'undefined') return {};
|
|
26
|
-
const { value: distance, unit: unitDistance } = parseValueWithUnit(`${value?.distance}`);
|
|
27
|
-
return {
|
|
28
|
-
[`-${!isActiveState ? stateMapping?.[state] : ''}-${getShortName(styleAppliedFor)}`]: isEnableShadow ? `${Math.cos(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${value?.blur} ${styleAppliedFor === 'box-shadow' ? value?.spread + ' ' : ''}${getSingleColorVariable(value?.color)}` : 'none'
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
|
|
32
|
-
if (!shadow || !styleAppliedFor) return {};
|
|
33
|
-
const style = {};
|
|
34
|
-
for (const [key, value] of Object.entries(shadow)){
|
|
35
|
-
Object.assign(style, getStyleShadow({
|
|
36
|
-
value: value,
|
|
37
|
-
state: key,
|
|
38
|
-
styleAppliedFor,
|
|
39
|
-
isEnableShadow: isEnableShadow?.[key]
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
return style;
|
|
43
|
-
};
|
|
44
|
-
const composeShadowCss = ({ hasBoxShadow, boxShadowValue, important })=>{
|
|
45
|
-
if (!hasBoxShadow) return undefined;
|
|
46
|
-
if (!boxShadowValue) return undefined;
|
|
47
|
-
const { value: distance, unit: unitDistance } = parseValueWithUnit(`${boxShadowValue?.distance}`);
|
|
48
|
-
const sub = important ? ' !important' : '';
|
|
49
|
-
return `box-shadow: ${Math.cos(parseFloat(`${boxShadowValue?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${boxShadowValue?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${boxShadowValue?.blur} ${boxShadowValue?.spread + ' '}${getSingleColorVariable(boxShadowValue?.color)}${sub};`;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export { composeShadowCss, getStyleShadow, getStyleShadowState, parseValueWithUnit };
|
|
1
|
+
import{getSingleColorVariable as t}from"./colors.js";import{stateMapping as e}from"./constant.js";import{getShortName as a}from"./get-shortname.js";let parseValueWithUnit=t=>{let e=t.match(/(\d+)(.+)/);if(e&&3===e.length){let t=Number(e[1]??0),a=e[2];return{value:t,unit:a??"px"}}return{value:0,unit:"px"}},getStyleShadow=(r,o=!1)=>{let{styleAppliedFor:l,value:s,isEnableShadow:n}=r||{},{state:i}=r||{};if(i||(i="normal"),!l||!s||void 0===s.distance)return{};let{value:$,unit:h}=parseValueWithUnit(`${s?.distance}`);return{[`-${o?"":e?.[i]}-${a(l)}`]:n?`${Math.cos(parseFloat(`${s?.angle}`)*Math.PI/180)*parseFloat(`${$}`)}${h} ${Math.sin(parseFloat(`${s?.angle}`)*Math.PI/180)*parseFloat(`${$}`)}${h} ${s?.blur} ${"box-shadow"===l?s?.spread+" ":""}${t(s?.color)}`:"none"}},getStyleShadowState=(t,e,a)=>{if(!t||!e)return{};let r={};for(let[o,l]of Object.entries(t))Object.assign(r,getStyleShadow({value:l,state:o,styleAppliedFor:e,isEnableShadow:a?.[o]}));return r},composeShadowCss=({hasBoxShadow:e,boxShadowValue:a,important:r})=>{if(!e||!a)return;let{value:o,unit:l}=parseValueWithUnit(`${a?.distance}`),s=r?" !important":"";return`box-shadow: ${Math.cos(parseFloat(`${a?.angle}`)*Math.PI/180)*parseFloat(`${o}`)}${l} ${Math.sin(parseFloat(`${a?.angle}`)*Math.PI/180)*parseFloat(`${o}`)}${l} ${a?.blur} ${a?.spread+" "}${t(a?.color)}${s};`};export{composeShadowCss,getStyleShadow,getStyleShadowState,parseValueWithUnit};
|
package/dist/esm/helpers/size.js
CHANGED
|
@@ -1,171 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function getCustomSizeCSSByDevice(size, device) {
|
|
6
|
-
if (!size || !device) return {};
|
|
7
|
-
const suffix = devicesMapping[device] ?? '';
|
|
8
|
-
return {
|
|
9
|
-
[`--pl${suffix}`]: size?.[device]?.horizontal,
|
|
10
|
-
[`--pr${suffix}`]: size?.[device]?.horizontal,
|
|
11
|
-
[`--pt${suffix}`]: size?.[device]?.vertical,
|
|
12
|
-
[`--pb${suffix}`]: size?.[device]?.vertical
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const composeSize = (size)=>{
|
|
16
|
-
return Object.assign({}, getCustomSizeCSSByDevice(size, 'desktop'), getCustomSizeCSSByDevice(size, 'tablet'), getCustomSizeCSSByDevice(size, 'mobile'));
|
|
17
|
-
};
|
|
18
|
-
function genSizeClass(name) {
|
|
19
|
-
return `gp-g-s-${name}`;
|
|
20
|
-
}
|
|
21
|
-
const composeSizeCss = (spacing)=>{
|
|
22
|
-
if (spacing === undefined) return '';
|
|
23
|
-
const size = spacing;
|
|
24
|
-
const sizeHozi = spacing?.custom?.desktop?.horizontal;
|
|
25
|
-
const sizeVerti = spacing?.custom?.desktop?.vertical;
|
|
26
|
-
if (!size?.custom) return undefined;
|
|
27
|
-
return `
|
|
28
|
-
${sizeHozi ? `padding-left: ${sizeHozi}; padding-right: ${sizeHozi};` : undefined}
|
|
29
|
-
${sizeVerti ? `padding-top: ${sizeVerti}; padding-bottom: ${sizeVerti};` : undefined}
|
|
30
|
-
`;
|
|
31
|
-
};
|
|
32
|
-
const makeGlobalSize = (globalSize)=>{
|
|
33
|
-
return {
|
|
34
|
-
width: makeStyleWithDefault('w', getWidthHeightGlobalSize('width', globalSize), {
|
|
35
|
-
desktop: '--g-ct-w',
|
|
36
|
-
tablet: '--g-ct-w',
|
|
37
|
-
mobile: '--g-ct-w'
|
|
38
|
-
}),
|
|
39
|
-
height: makeStyleResponsive('h', getWidthHeightGlobalSize('height', globalSize)),
|
|
40
|
-
padding: getPaddingGlobalSize(globalSize),
|
|
41
|
-
gap: getGlobalSizeGap(globalSize)
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
const getGlobalSizeGap = (globalSize)=>{
|
|
45
|
-
return {
|
|
46
|
-
'--gg': globalSize?.desktop?.gap,
|
|
47
|
-
'--gg-tablet': globalSize?.tablet?.gap,
|
|
48
|
-
'--gg-mobile': globalSize?.mobile?.gap
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
const makeStyleWithDefault = (name, value, defaultVal)=>{
|
|
52
|
-
return {
|
|
53
|
-
[`--${name}`]: value?.desktop === 'default' ? `var(${defaultVal?.desktop})` : value?.desktop,
|
|
54
|
-
[`--${name}-tablet`]: value?.tablet === 'default' ? `var(${defaultVal?.tablet})` : value?.tablet,
|
|
55
|
-
[`--${name}-mobile`]: value?.mobile === 'default' ? `var(${defaultVal?.mobile})` : value?.mobile
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const getWidthHeightGlobalSize = (type, globalSize)=>{
|
|
59
|
-
if (!globalSize) return {};
|
|
60
|
-
let result = {};
|
|
61
|
-
const DEVICES = [
|
|
62
|
-
'desktop',
|
|
63
|
-
'mobile',
|
|
64
|
-
'tablet'
|
|
65
|
-
];
|
|
66
|
-
DEVICES.forEach((device)=>{
|
|
67
|
-
result = {
|
|
68
|
-
...result,
|
|
69
|
-
[device]: getResponsiveValueByScreen(globalSize, device)?.[type]
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
return result;
|
|
73
|
-
};
|
|
74
|
-
const getHeightByShapeGlobalSize = (shapeByLayout)=>{
|
|
75
|
-
let result = {};
|
|
76
|
-
const DEVICES = [
|
|
77
|
-
'desktop',
|
|
78
|
-
'mobile',
|
|
79
|
-
'tablet'
|
|
80
|
-
];
|
|
81
|
-
DEVICES.forEach((device)=>{
|
|
82
|
-
const shapeByDevice = getResponsiveValueByScreen(shapeByLayout, device);
|
|
83
|
-
const shapeValue = shapeByDevice?.shapeValue;
|
|
84
|
-
const height = shapeByDevice?.height;
|
|
85
|
-
result = {
|
|
86
|
-
...result,
|
|
87
|
-
[device]: shapeValue ? 'auto' : height || 'auto'
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
return result;
|
|
91
|
-
};
|
|
92
|
-
const getWidthByShapeGlobalSize = (shapeByLayout, defaultAuto)=>{
|
|
93
|
-
let result = {};
|
|
94
|
-
const DEVICES = [
|
|
95
|
-
'desktop',
|
|
96
|
-
'mobile',
|
|
97
|
-
'tablet'
|
|
98
|
-
];
|
|
99
|
-
DEVICES.forEach((device)=>{
|
|
100
|
-
const shapeByDevice = getResponsiveValueByScreen(shapeByLayout, device);
|
|
101
|
-
const width = defaultAuto ? shapeByDevice?.width || 'auto' : shapeByDevice?.width;
|
|
102
|
-
if (width) {
|
|
103
|
-
result = {
|
|
104
|
-
...result,
|
|
105
|
-
[device]: width
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
return result;
|
|
110
|
-
};
|
|
111
|
-
const getAspectRatioGlobalSize = (shape)=>{
|
|
112
|
-
let result = {};
|
|
113
|
-
const DEVICES = [
|
|
114
|
-
'desktop',
|
|
115
|
-
'mobile',
|
|
116
|
-
'tablet'
|
|
117
|
-
];
|
|
118
|
-
DEVICES.forEach((device)=>{
|
|
119
|
-
const shapeValue = getResponsiveValueByScreen(shape, device)?.shapeValue;
|
|
120
|
-
if (shapeValue) {
|
|
121
|
-
result = {
|
|
122
|
-
...result,
|
|
123
|
-
[device]: shapeValue
|
|
124
|
-
};
|
|
125
|
-
} else {
|
|
126
|
-
const shapeConfig = getResponsiveValueByScreen(shape, device)?.shape;
|
|
127
|
-
switch(shapeConfig){
|
|
128
|
-
case 'square':
|
|
129
|
-
result = {
|
|
130
|
-
...result,
|
|
131
|
-
[device]: '1/1'
|
|
132
|
-
};
|
|
133
|
-
break;
|
|
134
|
-
case 'vertical':
|
|
135
|
-
result = {
|
|
136
|
-
...result,
|
|
137
|
-
[device]: '3/4'
|
|
138
|
-
};
|
|
139
|
-
break;
|
|
140
|
-
case 'horizontal':
|
|
141
|
-
result = {
|
|
142
|
-
...result,
|
|
143
|
-
[device]: '4/3'
|
|
144
|
-
};
|
|
145
|
-
break;
|
|
146
|
-
case 'original':
|
|
147
|
-
result = {
|
|
148
|
-
...result,
|
|
149
|
-
[device]: 'auto'
|
|
150
|
-
};
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return result;
|
|
156
|
-
};
|
|
157
|
-
function getCustomPaddingSizeCSSByDevice(globalSize, device) {
|
|
158
|
-
if (!globalSize || !device) return {};
|
|
159
|
-
const suffix = devicesMapping[device] ?? '';
|
|
160
|
-
return {
|
|
161
|
-
[`--pl${suffix}`]: globalSize?.[device]?.padding?.left,
|
|
162
|
-
[`--pr${suffix}`]: globalSize?.[device]?.padding?.right,
|
|
163
|
-
[`--pt${suffix}`]: globalSize?.[device]?.padding?.top,
|
|
164
|
-
[`--pb${suffix}`]: globalSize?.[device]?.padding?.bottom
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
const getPaddingGlobalSize = (globalSize)=>{
|
|
168
|
-
return Object.assign({}, getCustomPaddingSizeCSSByDevice(globalSize, 'desktop'), getCustomPaddingSizeCSSByDevice(globalSize, 'tablet'), getCustomPaddingSizeCSSByDevice(globalSize, 'mobile'));
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getGlobalSizeGap, getHeightByShapeGlobalSize, getPaddingGlobalSize, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeStyleWithDefault };
|
|
1
|
+
import{makeStyleResponsive as e}from"./make-style.js";import{devicesMapping as t}from"./constant.js";import{getResponsiveValueByScreen as i}from"./get-resonsive-value.js";function getCustomSizeCSSByDevice(e,i){if(!e||!i)return{};let a=t[i]??"";return{[`--pl${a}`]:e?.[i]?.horizontal,[`--pr${a}`]:e?.[i]?.horizontal,[`--pt${a}`]:e?.[i]?.vertical,[`--pb${a}`]:e?.[i]?.vertical}}let composeSize=e=>Object.assign({},getCustomSizeCSSByDevice(e,"desktop"),getCustomSizeCSSByDevice(e,"tablet"),getCustomSizeCSSByDevice(e,"mobile"));function genSizeClass(e){return`gp-g-s-${e}`}let composeSizeCss=e=>{if(void 0===e)return"";let t=e?.custom?.desktop?.horizontal,i=e?.custom?.desktop?.vertical;if(e?.custom)return`
|
|
2
|
+
${t?`padding-left: ${t}; padding-right: ${t};`:void 0}
|
|
3
|
+
${i?`padding-top: ${i}; padding-bottom: ${i};`:void 0}
|
|
4
|
+
`},makeGlobalSize=t=>({width:makeStyleWithDefault("w",getWidthHeightGlobalSize("width",t),{desktop:"--g-ct-w",tablet:"--g-ct-w",mobile:"--g-ct-w"}),height:e("h",getWidthHeightGlobalSize("height",t)),padding:getPaddingGlobalSize(t),gap:getGlobalSizeGap(t)}),getGlobalSizeGap=e=>({"--gg":e?.desktop?.gap,"--gg-tablet":e?.tablet?.gap,"--gg-mobile":e?.mobile?.gap}),makeStyleWithDefault=(e,t,i)=>({[`--${e}`]:t?.desktop==="default"?`var(${i?.desktop})`:t?.desktop,[`--${e}-tablet`]:t?.tablet==="default"?`var(${i?.tablet})`:t?.tablet,[`--${e}-mobile`]:t?.mobile==="default"?`var(${i?.mobile})`:t?.mobile}),getWidthHeightGlobalSize=(e,t)=>{if(!t)return{};let a={},l=["desktop","mobile","tablet"];return l.forEach(l=>{a={...a,[l]:i(t,l)?.[e]}}),a},getHeightByShapeGlobalSize=e=>{let t={},a=["desktop","mobile","tablet"];return a.forEach(a=>{let l=i(e,a),o=l?.shapeValue,g=l?.height;t={...t,[a]:o?"auto":g||"auto"}}),t},getWidthByShapeGlobalSize=(e,t)=>{let a={},l=["desktop","mobile","tablet"];return l.forEach(l=>{let o=i(e,l),g=t?o?.width||"auto":o?.width;g&&(a={...a,[l]:g})}),a},getAspectRatioGlobalSize=e=>{let t={},a=["desktop","mobile","tablet"];return a.forEach(a=>{let l=i(e,a)?.shapeValue;if(l)t={...t,[a]:l};else{let l=i(e,a)?.shape;switch(l){case"square":t={...t,[a]:"1/1"};break;case"vertical":t={...t,[a]:"3/4"};break;case"horizontal":t={...t,[a]:"4/3"};break;case"original":t={...t,[a]:"auto"}}}}),t};function getCustomPaddingSizeCSSByDevice(e,i){if(!e||!i)return{};let a=t[i]??"";return{[`--pl${a}`]:e?.[i]?.padding?.left,[`--pr${a}`]:e?.[i]?.padding?.right,[`--pt${a}`]:e?.[i]?.padding?.top,[`--pb${a}`]:e?.[i]?.padding?.bottom}}let getPaddingGlobalSize=e=>Object.assign({},getCustomPaddingSizeCSSByDevice(e,"desktop"),getCustomPaddingSizeCSSByDevice(e,"tablet"),getCustomPaddingSizeCSSByDevice(e,"mobile"));export{composeSize,composeSizeCss,genSizeClass,getAspectRatioGlobalSize,getGlobalSizeGap,getHeightByShapeGlobalSize,getPaddingGlobalSize,getWidthByShapeGlobalSize,getWidthHeightGlobalSize,makeGlobalSize,makeStyleWithDefault};
|