@gem-sdk/core 1.13.42 → 1.14.0-dev.286
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/ComponentWrapper.js +1 -28
- package/dist/cjs/components/ComponentWrapperPreview.js +1 -72
- package/dist/cjs/components/Empty.js +1 -7
- package/dist/cjs/components/Render.js +1 -65
- package/dist/cjs/components/Render.liquid.js +15 -158
- package/dist/cjs/components/RenderBlock.js +1 -54
- package/dist/cjs/components/RenderCustomCode.js +5 -0
- package/dist/cjs/components/RenderPreview.js +1 -66
- package/dist/cjs/components/RenderSection.js +1 -23
- package/dist/cjs/components/constant.js +1 -39
- package/dist/cjs/components/src/product/helpers/variant-presets.js +1 -0
- 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 -370
- 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/ProductContext.js +1 -149
- package/dist/cjs/contexts/ProductListContext.js +1 -32
- package/dist/cjs/contexts/SectionContext.js +1 -53
- package/dist/cjs/contexts/ShopContext.js +1 -70
- 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/data-seo.generated.js +2 -6
- package/dist/cjs/graphql/fragments/media.generated.js +3 -6
- package/dist/cjs/graphql/fragments/product-little.generated.js +2 -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 +2 -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 +2 -6
- 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 +7 -0
- package/dist/cjs/graphql/queries/product-variants.generated.js +2 -10
- package/dist/cjs/graphql/queries/products.generated.js +3 -17
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +2 -14
- package/dist/cjs/graphql/queries/store-property.generated.js +2 -6
- package/dist/cjs/helpers/GlobalEvent.js +1 -19
- package/dist/cjs/helpers/background.js +1 -109
- package/dist/cjs/helpers/borders.js +4 -183
- package/dist/cjs/helpers/clone-deep.js +1 -5
- package/dist/cjs/helpers/cls.js +1 -16
- package/dist/cjs/helpers/colors.js +1 -183
- package/dist/cjs/helpers/compose-advance-style.js +1 -188
- package/dist/cjs/helpers/constant.js +1 -23
- package/dist/cjs/helpers/convert.js +1 -7
- package/dist/cjs/helpers/css-variable.js +1 -7
- package/dist/cjs/helpers/email.js +1 -11
- package/dist/cjs/helpers/flatten-connection.js +1 -9
- package/dist/cjs/helpers/get-resonsive-value.js +1 -31
- package/dist/cjs/helpers/get-shortname.js +1 -92
- 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 -12
- 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 -128
- 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 -45
- package/dist/cjs/helpers/queries/get-collection.js +1 -220
- 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 -161
- package/dist/cjs/helpers/query.js +1 -29
- package/dist/cjs/helpers/radius.js +6 -134
- package/dist/cjs/helpers/render.js +1 -71
- package/dist/cjs/helpers/shadow.js +1 -56
- package/dist/cjs/helpers/size.js +4 -35
- 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 -105
- package/dist/cjs/helpers/variant.js +1 -8
- 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 -22
- 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/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 -0
- 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 -124
- 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/index.js +1 -291
- package/dist/cjs/types/global-style.js +1 -14
- package/dist/cjs/types/shop.js +1 -2
- package/dist/esm/components/AddOn.js +1 -14
- package/dist/esm/components/ComponentWrapper.js +1 -24
- package/dist/esm/components/ComponentWrapperPreview.js +1 -68
- package/dist/esm/components/Empty.js +1 -3
- package/dist/esm/components/Render.js +1 -61
- package/dist/esm/components/Render.liquid.js +15 -153
- package/dist/esm/components/RenderBlock.js +1 -50
- package/dist/esm/components/RenderCustomCode.js +5 -0
- package/dist/esm/components/RenderPreview.js +1 -62
- package/dist/esm/components/RenderSection.js +1 -19
- package/dist/esm/components/constant.js +1 -37
- package/dist/esm/components/src/product/helpers/variant-presets.js +1 -0
- 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 -367
- 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/ProductContext.js +1 -146
- package/dist/esm/contexts/ProductListContext.js +1 -28
- package/dist/esm/contexts/SectionContext.js +1 -49
- package/dist/esm/contexts/ShopContext.js +1 -67
- 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/data-seo.generated.js +2 -4
- package/dist/esm/graphql/fragments/media.generated.js +3 -4
- package/dist/esm/graphql/fragments/product-little.generated.js +2 -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 +2 -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 +2 -4
- 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 +7 -0
- package/dist/esm/graphql/queries/product-variants.generated.js +4 -10
- package/dist/esm/graphql/queries/products.generated.js +9 -20
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +8 -18
- package/dist/esm/graphql/queries/store-property.generated.js +2 -4
- package/dist/esm/helpers/GlobalEvent.js +1 -15
- package/dist/esm/helpers/background.js +1 -106
- package/dist/esm/helpers/borders.js +4 -175
- package/dist/esm/helpers/clone-deep.js +1 -3
- package/dist/esm/helpers/cls.js +1 -14
- package/dist/esm/helpers/colors.js +1 -168
- package/dist/esm/helpers/compose-advance-style.js +1 -185
- package/dist/esm/helpers/constant.js +1 -19
- package/dist/esm/helpers/convert.js +1 -4
- package/dist/esm/helpers/css-variable.js +1 -5
- package/dist/esm/helpers/email.js +1 -6
- package/dist/esm/helpers/flatten-connection.js +1 -7
- package/dist/esm/helpers/get-resonsive-value.js +1 -27
- package/dist/esm/helpers/get-shortname.js +1 -90
- 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 -7
- 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 -117
- 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 -41
- package/dist/esm/helpers/queries/get-collection.js +1 -217
- 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 -159
- package/dist/esm/helpers/query.js +1 -25
- package/dist/esm/helpers/radius.js +6 -127
- package/dist/esm/helpers/render.js +1 -64
- package/dist/esm/helpers/shadow.js +1 -51
- package/dist/esm/helpers/size.js +4 -31
- 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 -96
- package/dist/esm/helpers/variant.js +1 -6
- 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 -20
- 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/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 -0
- 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 -111
- 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/index.js +1 -92
- package/dist/esm/types/global-style.js +1 -11
- package/dist/types/index.d.ts +1228 -1031
- package/package.json +3 -3
|
@@ -1,125 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var productLittleDetail_generated = require('../../graphql/queries/product-little-detail.generated.js');
|
|
4
|
-
var productMedias_generated = require('../../graphql/queries/product-medias.generated.js');
|
|
5
|
-
var productVariants_generated = require('../../graphql/queries/product-variants.generated.js');
|
|
6
|
-
|
|
7
|
-
const getProductBySlug = async (fetcher, slug)=>{
|
|
8
|
-
const [product, variants, medias] = await Promise.all([
|
|
9
|
-
fetchProduct(fetcher, slug),
|
|
10
|
-
fetchVariants(fetcher, slug),
|
|
11
|
-
fetchMedias(fetcher, slug)
|
|
12
|
-
]);
|
|
13
|
-
if (!product) {
|
|
14
|
-
throw new Error('Product not found');
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
...product,
|
|
18
|
-
variants: {
|
|
19
|
-
edges: variants
|
|
20
|
-
},
|
|
21
|
-
medias: {
|
|
22
|
-
edges: medias
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const orderBy = {
|
|
27
|
-
field: 'PLATFORM_UPDATED_AT',
|
|
28
|
-
direction: 'DESC'
|
|
29
|
-
};
|
|
30
|
-
const fetchProduct = async (fetcher, handle, isStorefront)=>{
|
|
31
|
-
const variables = {
|
|
32
|
-
orderBy,
|
|
33
|
-
where: {
|
|
34
|
-
status: 'ACTIVE',
|
|
35
|
-
handle,
|
|
36
|
-
...isStorefront && {
|
|
37
|
-
isStorefront
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const response = await fetcher([
|
|
42
|
-
productLittleDetail_generated.ProductLittleDetailDocument,
|
|
43
|
-
variables
|
|
44
|
-
]);
|
|
45
|
-
return response.product?.edges?.[0]?.node;
|
|
46
|
-
};
|
|
47
|
-
const fetchVariants = async (fetcher, handle, isStorefront)=>{
|
|
48
|
-
const initVariables = {
|
|
49
|
-
orderBy,
|
|
50
|
-
orderByVariant: {
|
|
51
|
-
field: 'POSITION',
|
|
52
|
-
direction: 'ASC'
|
|
53
|
-
},
|
|
54
|
-
where: {
|
|
55
|
-
status: 'ACTIVE',
|
|
56
|
-
handle,
|
|
57
|
-
...isStorefront && {
|
|
58
|
-
isStorefront
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const query = async (variables, olds)=>{
|
|
63
|
-
try {
|
|
64
|
-
const response = await fetcher([
|
|
65
|
-
productVariants_generated.ProductVariantsDocument,
|
|
66
|
-
variables
|
|
67
|
-
]);
|
|
68
|
-
const product = response.variants?.edges?.[0];
|
|
69
|
-
const items = olds?.concat(product?.node?.variants?.edges ?? []);
|
|
70
|
-
if (product?.node?.variants?.pageInfo?.hasNextPage) {
|
|
71
|
-
return query({
|
|
72
|
-
...variables,
|
|
73
|
-
afterVariant: product?.node?.variants?.pageInfo.endCursor
|
|
74
|
-
}, items);
|
|
75
|
-
}
|
|
76
|
-
return items ?? [];
|
|
77
|
-
} catch {
|
|
78
|
-
return olds ?? [];
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
return query(initVariables, []);
|
|
82
|
-
};
|
|
83
|
-
const fetchMedias = async (fetcher, handle, isStorefront)=>{
|
|
84
|
-
const initVariables = {
|
|
85
|
-
orderBy,
|
|
86
|
-
where: {
|
|
87
|
-
status: 'ACTIVE',
|
|
88
|
-
handle,
|
|
89
|
-
...isStorefront && {
|
|
90
|
-
isStorefront
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
orderByMedia: {
|
|
94
|
-
field: 'POSITION',
|
|
95
|
-
direction: 'ASC'
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const query = async (variables)=>{
|
|
99
|
-
try {
|
|
100
|
-
const response = await fetcher([
|
|
101
|
-
productMedias_generated.ProductMediasDocument,
|
|
102
|
-
variables
|
|
103
|
-
]);
|
|
104
|
-
const product = response.medias?.edges?.[0];
|
|
105
|
-
const items = product?.node?.medias?.edges ?? [];
|
|
106
|
-
if (product?.node?.medias?.pageInfo?.hasNextPage) {
|
|
107
|
-
try {
|
|
108
|
-
const newData = await query({
|
|
109
|
-
...variables,
|
|
110
|
-
afterMedia: product?.node?.medias?.pageInfo.endCursor
|
|
111
|
-
});
|
|
112
|
-
return items.concat(newData);
|
|
113
|
-
} catch {
|
|
114
|
-
return items;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return items;
|
|
118
|
-
} catch {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return query(initVariables);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
exports.getProductBySlug = getProductBySlug;
|
|
1
|
+
"use strict";var productLittleDetail_generated=require("../../graphql/queries/product-little-detail.generated.js"),productMedias_generated=require("../../graphql/queries/product-medias.generated.js"),productVariants_generated=require("../../graphql/queries/product-variants.generated.js");const getProductBySlug=async(e,t)=>{let[r,a,d]=await Promise.all([fetchProduct(e,t),fetchVariants(e,t),fetchMedias(e,t)]);if(!r)throw Error("Product not found");return{...r,variants:{edges:a},medias:{edges:d}}},orderBy={field:"PLATFORM_UPDATED_AT",direction:"DESC"},fetchProduct=async(e,t,r)=>{let a={orderBy,where:{status:"ACTIVE",handle:t,...r&&{isStorefront:r}}},d=await e([productLittleDetail_generated.ProductLittleDetailDocument,a]);return d.product?.edges?.[0]?.node},fetchVariants=async(e,t,r)=>{let a={orderBy,orderByVariant:{field:"POSITION",direction:"ASC"},where:{status:"ACTIVE",handle:t,...r&&{isStorefront:r}}},d=async(t,r)=>{try{let a=await e([productVariants_generated.ProductVariantsDocument,t]),n=a.variants?.edges?.[0],i=r?.concat(n?.node?.variants?.edges??[]);if(n?.node?.variants?.pageInfo?.hasNextPage)return d({...t,afterVariant:n?.node?.variants?.pageInfo.endCursor},i);return i??[]}catch{return r??[]}};return d(a,[])},fetchMedias=async(e,t,r)=>{let a={orderBy,where:{status:"ACTIVE",handle:t,...r&&{isStorefront:r}},orderByMedia:{field:"POSITION",direction:"ASC"}},d=async t=>{try{let r=await e([productMedias_generated.ProductMediasDocument,t]),a=r.medias?.edges?.[0],n=a?.node?.medias?.edges??[];if(a?.node?.medias?.pageInfo?.hasNextPage)try{let e=await d({...t,afterMedia:a?.node?.medias?.pageInfo.endCursor});return n.concat(e)}catch{}return n}catch{return[]}};return d(a)};exports.getProductBySlug=getProductBySlug;
|
|
@@ -1,154 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var productLittleDetail_generated = require('../../graphql/queries/product-little-detail.generated.js');
|
|
4
|
-
var productMedias_generated = require('../../graphql/queries/product-medias.generated.js');
|
|
5
|
-
var productVariants_generated = require('../../graphql/queries/product-variants.generated.js');
|
|
6
|
-
|
|
7
|
-
const getProduct = async (fetcher, { id, isSample, isStorefront })=>{
|
|
8
|
-
const [product, variants, medias] = await Promise.all([
|
|
9
|
-
fetchProduct(fetcher, {
|
|
10
|
-
id,
|
|
11
|
-
isSample,
|
|
12
|
-
isStorefront
|
|
13
|
-
}),
|
|
14
|
-
fetchVariants(fetcher, {
|
|
15
|
-
id,
|
|
16
|
-
isSample,
|
|
17
|
-
isStorefront
|
|
18
|
-
}),
|
|
19
|
-
fetchMedias(fetcher, {
|
|
20
|
-
id,
|
|
21
|
-
isSample,
|
|
22
|
-
isStorefront
|
|
23
|
-
})
|
|
24
|
-
]);
|
|
25
|
-
if (!product) {
|
|
26
|
-
throw new Error('Product not found');
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
...product,
|
|
30
|
-
variants: {
|
|
31
|
-
edges: variants
|
|
32
|
-
},
|
|
33
|
-
medias: {
|
|
34
|
-
edges: medias
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const orderBy = {
|
|
39
|
-
field: 'CREATED_AT',
|
|
40
|
-
direction: 'DESC'
|
|
41
|
-
};
|
|
42
|
-
const fetchProduct = async (fetcher, { id, isSample, isStorefront })=>{
|
|
43
|
-
const variables = {
|
|
44
|
-
orderBy,
|
|
45
|
-
where: {
|
|
46
|
-
isSample,
|
|
47
|
-
...isStorefront && {
|
|
48
|
-
isStorefront
|
|
49
|
-
},
|
|
50
|
-
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
51
|
-
status: 'ACTIVE'
|
|
52
|
-
},
|
|
53
|
-
...id && id.toLowerCase() !== 'latest' && {
|
|
54
|
-
baseID: id
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const response = await fetcher([
|
|
59
|
-
productLittleDetail_generated.ProductLittleDetailDocument,
|
|
60
|
-
variables
|
|
61
|
-
]);
|
|
62
|
-
return response.product?.edges?.[0]?.node;
|
|
63
|
-
};
|
|
64
|
-
const fetchVariants = async (fetcher, { id, isSample, isStorefront })=>{
|
|
65
|
-
const initVariables = {
|
|
66
|
-
orderBy,
|
|
67
|
-
where: {
|
|
68
|
-
isSample,
|
|
69
|
-
...isStorefront && {
|
|
70
|
-
isStorefront
|
|
71
|
-
},
|
|
72
|
-
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
73
|
-
status: 'ACTIVE'
|
|
74
|
-
},
|
|
75
|
-
...id && id.toLowerCase() !== 'latest' && {
|
|
76
|
-
baseID: id
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
orderByVariant: {
|
|
80
|
-
field: 'POSITION',
|
|
81
|
-
direction: 'ASC'
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const query = async (variables, olds)=>{
|
|
85
|
-
try {
|
|
86
|
-
const response = await fetcher([
|
|
87
|
-
productVariants_generated.ProductVariantsDocument,
|
|
88
|
-
variables
|
|
89
|
-
]);
|
|
90
|
-
const product = response.variants?.edges?.[0];
|
|
91
|
-
const items = olds?.concat(product?.node?.variants?.edges ?? []);
|
|
92
|
-
if (product?.node?.variants?.pageInfo?.hasNextPage) {
|
|
93
|
-
return query({
|
|
94
|
-
...variables,
|
|
95
|
-
afterVariant: product?.node?.variants?.pageInfo.endCursor
|
|
96
|
-
}, items);
|
|
97
|
-
}
|
|
98
|
-
return items ?? [];
|
|
99
|
-
} catch {
|
|
100
|
-
return olds ?? [];
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
return query(initVariables, []);
|
|
104
|
-
};
|
|
105
|
-
const fetchMedias = async (fetcher, { id, isSample, isStorefront })=>{
|
|
106
|
-
const initVariables = {
|
|
107
|
-
orderBy,
|
|
108
|
-
where: {
|
|
109
|
-
isSample,
|
|
110
|
-
...isStorefront && {
|
|
111
|
-
isStorefront
|
|
112
|
-
},
|
|
113
|
-
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
114
|
-
status: 'ACTIVE'
|
|
115
|
-
},
|
|
116
|
-
...id && id.toLowerCase() !== 'latest' && {
|
|
117
|
-
baseID: id
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
orderByMedia: {
|
|
121
|
-
field: 'POSITION',
|
|
122
|
-
direction: 'ASC'
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const query = async (variables)=>{
|
|
126
|
-
try {
|
|
127
|
-
const response = await fetcher([
|
|
128
|
-
productMedias_generated.ProductMediasDocument,
|
|
129
|
-
variables
|
|
130
|
-
]);
|
|
131
|
-
const product = response.medias?.edges?.[0];
|
|
132
|
-
const items = product?.node?.medias?.edges ?? [];
|
|
133
|
-
if (product?.node?.medias?.pageInfo?.hasNextPage) {
|
|
134
|
-
try {
|
|
135
|
-
const newData = await query({
|
|
136
|
-
...variables,
|
|
137
|
-
afterMedia: product?.node?.medias?.pageInfo.endCursor
|
|
138
|
-
});
|
|
139
|
-
return items.concat(newData);
|
|
140
|
-
} catch {
|
|
141
|
-
return items;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return items;
|
|
145
|
-
} catch {
|
|
146
|
-
return [];
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
return query(initVariables);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
exports.fetchMedias = fetchMedias;
|
|
153
|
-
exports.fetchVariants = fetchVariants;
|
|
154
|
-
exports.getProduct = getProduct;
|
|
1
|
+
"use strict";var productLittleDetail_generated=require("../../graphql/queries/product-little-detail.generated.js"),productMedias_generated=require("../../graphql/queries/product-medias.generated.js"),productVariants_generated=require("../../graphql/queries/product-variants.generated.js");const getProduct=async(e,{id:t,isSample:r,isStorefront:a})=>{let[s,d,o]=await Promise.all([fetchProduct(e,{id:t,isSample:r,isStorefront:a}),fetchVariants(e,{id:t,isSample:r,isStorefront:a}),fetchMedias(e,{id:t,isSample:r,isStorefront:a})]);if(!s)throw Error("Product not found");return{...s,variants:{edges:d},medias:{edges:o}}},orderBy={field:"CREATED_AT",direction:"DESC"},fetchProduct=async(e,{id:t,isSample:r,isStorefront:a})=>{let s={orderBy,where:{isSample:r,...a&&{isStorefront:a},...(!t||t&&"latest"==t.toLowerCase())&&{status:"ACTIVE"},...t&&"latest"!==t.toLowerCase()&&{baseID:t}}},d=await e([productLittleDetail_generated.ProductLittleDetailDocument,s]);return d.product?.edges?.[0]?.node},fetchVariants=async(e,{id:t,isSample:r,isStorefront:a})=>{let s={orderBy,where:{isSample:r,...a&&{isStorefront:a},...(!t||t&&"latest"==t.toLowerCase())&&{status:"ACTIVE"},...t&&"latest"!==t.toLowerCase()&&{baseID:t}},orderByVariant:{field:"POSITION",direction:"ASC"}},d=async(t,r)=>{try{let a=await e([productVariants_generated.ProductVariantsDocument,t]),s=a.variants?.edges?.[0],o=r?.concat(s?.node?.variants?.edges??[]);if(s?.node?.variants?.pageInfo?.hasNextPage)return d({...t,afterVariant:s?.node?.variants?.pageInfo.endCursor},o);return o??[]}catch{return r??[]}};return d(s,[])},fetchMedias=async(e,{id:t,isSample:r,isStorefront:a})=>{let s={orderBy,where:{isSample:r,...a&&{isStorefront:a},...(!t||t&&"latest"==t.toLowerCase())&&{status:"ACTIVE"},...t&&"latest"!==t.toLowerCase()&&{baseID:t}},orderByMedia:{field:"POSITION",direction:"ASC"}},d=async t=>{try{let r=await e([productMedias_generated.ProductMediasDocument,t]),a=r.medias?.edges?.[0],s=a?.node?.medias?.edges??[];if(a?.node?.medias?.pageInfo?.hasNextPage)try{let e=await d({...t,afterMedia:a?.node?.medias?.pageInfo.endCursor});return s.concat(e)}catch{}return s}catch{return[]}};return d(s)};exports.fetchMedias=fetchMedias,exports.fetchVariants=fetchVariants,exports.getProduct=getProduct;
|
|
@@ -1,161 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var products_generated = require('../../graphql/queries/products.generated.js');
|
|
4
|
-
var getCollection = require('./get-collection.js');
|
|
5
|
-
var getProduct = require('./get-product.js');
|
|
6
|
-
|
|
7
|
-
const getProducts = async (fetcher, { ids, isSample, isStorefront })=>{
|
|
8
|
-
const products = await loopFetchProducts(fetcher, {
|
|
9
|
-
ids,
|
|
10
|
-
isSample,
|
|
11
|
-
isStorefront
|
|
12
|
-
});
|
|
13
|
-
if (!products) {
|
|
14
|
-
throw new Error('Product not found');
|
|
15
|
-
}
|
|
16
|
-
const [mergedVariant, mergedMedias] = await Promise.all([
|
|
17
|
-
mergeVariantsToProducts({
|
|
18
|
-
fetcher,
|
|
19
|
-
products,
|
|
20
|
-
isSample,
|
|
21
|
-
isStorefront
|
|
22
|
-
}),
|
|
23
|
-
mergeMediasToProducts({
|
|
24
|
-
fetcher,
|
|
25
|
-
products,
|
|
26
|
-
isSample,
|
|
27
|
-
isStorefront
|
|
28
|
-
})
|
|
29
|
-
]);
|
|
30
|
-
return {
|
|
31
|
-
...products,
|
|
32
|
-
products: {
|
|
33
|
-
...products.products,
|
|
34
|
-
edges: products.products?.edges.map((edge)=>{
|
|
35
|
-
const medias = mergedMedias.find((item)=>item.productId === edge.node?.baseID);
|
|
36
|
-
const variants = mergedVariant.find((item)=>item.productId === edge.node?.baseID);
|
|
37
|
-
if (edge.node) {
|
|
38
|
-
return {
|
|
39
|
-
...edge,
|
|
40
|
-
node: {
|
|
41
|
-
...edge.node,
|
|
42
|
-
variants: {
|
|
43
|
-
...edge.node?.variants,
|
|
44
|
-
edges: variants?.items ?? []
|
|
45
|
-
},
|
|
46
|
-
medias: {
|
|
47
|
-
...edge.node?.medias,
|
|
48
|
-
edges: medias?.items ?? []
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return edge;
|
|
54
|
-
}) ?? []
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const fetchProducts = async (fetcher, variables)=>{
|
|
59
|
-
return fetcher([
|
|
60
|
-
products_generated.ProductsDocument,
|
|
61
|
-
variables
|
|
62
|
-
]);
|
|
63
|
-
};
|
|
64
|
-
const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront })=>{
|
|
65
|
-
const numberOfProducts = (ids?.length == 0 ? 4 : ids?.length) ?? 4;
|
|
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: getCollection.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 getProduct.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 getProduct.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
|
-
exports.getProducts = getProducts;
|
|
1
|
+
"use strict";var products_generated=require("../../graphql/queries/products.generated.js"),getCollection=require("./get-collection.js"),getProduct=require("./get-product.js");const getProducts=async(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:s})=>{let o=await loopFetchProducts(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:s});if(!o)throw Error("Product not found");let[a,c]=await Promise.all([mergeVariantsToProducts({fetcher:e,products:o,isSample:r,isStorefront:d}),mergeMediasToProducts({fetcher:e,products:o,isSample:r,isStorefront:d})]);return{...o,products:{...o.products,edges:o.products?.edges.map(e=>{let t=c.find(t=>t.productId===e.node?.baseID),r=a.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})??[]}}},fetchProducts=async(e,t)=>e([products_generated.ProductsDocument,t]),loopFetchProducts=async(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:s})=>{let o,a,c,n,u;let i=s||4,g=(t?.length==0?i:t?.length)??i,l=1,p=Math.ceil(g/8);for(;l<=p&&!1!==n;){o={first:getCollection.calculateFirstProduct(g,l,8),firstMedia:1,firstVariant:1,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},where:{status:"ACTIVE",isSample:r,...d&&{isStorefront:d},...t?.length?{baseIDIn:t}:{}},after:a};let s=await fetchProducts(e,o);if(a=s?.products?.pageInfo?.endCursor,1===l?(c=s,u=s):u?.products&&s?.products?.edges.length&&(u.products={edges:u.products.edges.concat(s?.products?.edges),pageInfo:s?.products?.pageInfo}),l++,!u){n=!1;break}}return c},mergeVariantsToProducts=async({fetcher:e,products:t,isSample:r,isStorefront:d})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await getProduct.fetchVariants(e,{id:t?.node?.baseID,isSample:r,isStorefront:d});return{productId:t?.node?.baseID,items:s}})??[]);return s},mergeMediasToProducts=async({fetcher:e,products:t,isSample:r,isStorefront:d})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await getProduct.fetchMedias(e,{id:t?.node?.baseID,isSample:r,isStorefront:d});return{productId:t?.node?.baseID,items:s}})??[]);return s};exports.getProducts=getProducts;
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const generateProductQueryKey = (args)=>{
|
|
4
|
-
return [
|
|
5
|
-
'query/product',
|
|
6
|
-
args
|
|
7
|
-
];
|
|
8
|
-
};
|
|
9
|
-
const generateCollectionQueryKey = (args)=>{
|
|
10
|
-
return [
|
|
11
|
-
'query/collection',
|
|
12
|
-
args
|
|
13
|
-
];
|
|
14
|
-
};
|
|
15
|
-
const generateProductsQueryKey = (args)=>{
|
|
16
|
-
return [
|
|
17
|
-
'query/products',
|
|
18
|
-
{
|
|
19
|
-
...args,
|
|
20
|
-
ids: [
|
|
21
|
-
...args.ids
|
|
22
|
-
].sort()
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
exports.generateCollectionQueryKey = generateCollectionQueryKey;
|
|
28
|
-
exports.generateProductQueryKey = generateProductQueryKey;
|
|
29
|
-
exports.generateProductsQueryKey = generateProductsQueryKey;
|
|
1
|
+
"use strict";const generateProductQueryKey=e=>["query/product",e],generateCollectionQueryKey=e=>["query/collection",e],generateProductsQueryKey=e=>["query/products",{...e,ids:[...e.ids].sort()}];exports.generateCollectionQueryKey=generateCollectionQueryKey,exports.generateProductQueryKey=generateProductQueryKey,exports.generateProductsQueryKey=generateProductsQueryKey;
|
|
@@ -1,134 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (!corner.radiusType) return {};
|
|
8
|
-
if ([
|
|
9
|
-
'custom',
|
|
10
|
-
'circle'
|
|
11
|
-
].includes(corner.radiusType)) return makeStyle.makeStyle({
|
|
12
|
-
bblr: corner.bblr,
|
|
13
|
-
bbrr: corner.bbrr,
|
|
14
|
-
btlr: corner.btlr,
|
|
15
|
-
btrr: corner.btrr
|
|
16
|
-
});
|
|
17
|
-
return makeStyle.makeStyle({
|
|
18
|
-
radius: `var(--g-radius-${corner.radiusType})`
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const getRadiusCSSFromGlobal = (state, key, device)=>{
|
|
22
|
-
if (!key || !state) return {};
|
|
23
|
-
const suffix = device && device !== 'desktop' ? constant.devicesMapping?.[device] : '';
|
|
24
|
-
const mState = constant.stateMapping?.[state];
|
|
25
|
-
return {
|
|
26
|
-
[`-${mState}-radius${suffix}`]: `var(--g-radius-${key})`
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
const getCustomRadius = (state, radius, device)=>{
|
|
30
|
-
if (!radius || !state || radius.radiusType !== 'custom') return {};
|
|
31
|
-
const suffix = device && device !== 'desktop' ? constant.devicesMapping?.[device] : '';
|
|
32
|
-
const mState = constant.stateMapping?.[state];
|
|
33
|
-
return {
|
|
34
|
-
[`-${mState}-bblr${suffix}`]: radius.bblr,
|
|
35
|
-
[`-${mState}-bbrr${suffix}`]: radius.bbrr,
|
|
36
|
-
[`-${mState}-btlr${suffix}`]: radius.btlr,
|
|
37
|
-
[`-${mState}-btrr${suffix}`]: radius.btrr
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const composeRadius = (value)=>{
|
|
41
|
-
if (!value) return {};
|
|
42
|
-
if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
|
|
43
|
-
return composeRadiusResponsiveState(value);
|
|
44
|
-
}
|
|
45
|
-
return composeRadiusState(value);
|
|
46
|
-
};
|
|
47
|
-
const composeRadiusState = (radiusValue, device)=>{
|
|
48
|
-
const style = {};
|
|
49
|
-
switch(radiusValue?.normal?.radiusType){
|
|
50
|
-
case 'medium':
|
|
51
|
-
case 'large':
|
|
52
|
-
case 'small':
|
|
53
|
-
Object.assign(style, getRadiusCSSFromGlobal('normal', radiusValue?.normal?.radiusType, device));
|
|
54
|
-
break;
|
|
55
|
-
case 'circle':
|
|
56
|
-
case 'none':
|
|
57
|
-
case 'custom':
|
|
58
|
-
Object.assign(style, getCustomRadius('normal', radiusValue.normal, device));
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
switch(radiusValue?.hover?.radiusType){
|
|
62
|
-
case 'medium':
|
|
63
|
-
case 'large':
|
|
64
|
-
case 'small':
|
|
65
|
-
Object.assign(style, getRadiusCSSFromGlobal('hover', radiusValue?.hover?.radiusType, device));
|
|
66
|
-
break;
|
|
67
|
-
case 'circle':
|
|
68
|
-
case 'none':
|
|
69
|
-
case 'custom':
|
|
70
|
-
Object.assign(style, getCustomRadius('hover', radiusValue.hover, device));
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
switch(radiusValue?.focus?.radiusType){
|
|
74
|
-
case 'medium':
|
|
75
|
-
case 'large':
|
|
76
|
-
case 'small':
|
|
77
|
-
Object.assign(style, getRadiusCSSFromGlobal('focus', radiusValue?.focus?.radiusType, device));
|
|
78
|
-
break;
|
|
79
|
-
case 'circle':
|
|
80
|
-
case 'none':
|
|
81
|
-
case 'custom':
|
|
82
|
-
Object.assign(style, getCustomRadius('focus', radiusValue.focus, device));
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
return style;
|
|
86
|
-
};
|
|
87
|
-
const composeRadiusResponsiveState = (radiusValue)=>{
|
|
88
|
-
const style = {};
|
|
89
|
-
Object.assign(style, composeRadiusState(radiusValue?.desktop, 'desktop'));
|
|
90
|
-
Object.assign(style, composeRadiusState(radiusValue?.tablet, 'tablet'));
|
|
91
|
-
Object.assign(style, composeRadiusState(radiusValue?.mobile, 'mobile'));
|
|
92
|
-
return style;
|
|
93
|
-
};
|
|
94
|
-
const getRadiusStyleActiveState = (radiusValue)=>{
|
|
95
|
-
if (radiusValue?.active?.radiusType === 'custom') {
|
|
96
|
-
return getCustomRadius('normal', radiusValue?.active);
|
|
97
|
-
}
|
|
98
|
-
return getRadiusCSSFromGlobal('normal', radiusValue?.active?.radiusType);
|
|
99
|
-
};
|
|
100
|
-
const composeCornerCss = (value)=>{
|
|
101
|
-
if (!value) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const { radiusType, bblr, bbrr, btlr, btrr } = value;
|
|
105
|
-
let radiusValue = undefined;
|
|
106
|
-
switch(radiusType){
|
|
107
|
-
case 'medium':
|
|
108
|
-
case 'large':
|
|
109
|
-
case 'small':
|
|
110
|
-
radiusValue = `border-radius: var(--g-radius-${radiusType});`;
|
|
111
|
-
break;
|
|
112
|
-
case 'circle':
|
|
113
|
-
case 'none':
|
|
114
|
-
case 'custom':
|
|
115
|
-
radiusValue = `
|
|
116
|
-
${bblr ? `border-bottom-left-radius: ${bblr};` : ''}
|
|
117
|
-
|
|
118
|
-
${bbrr ? `border-bottom-right-radius: ${bbrr};` : ''}
|
|
119
|
-
|
|
120
|
-
${btlr ? `border-top-left-radius: ${btlr};` : ''}
|
|
121
|
-
|
|
122
|
-
${btrr ? `border-top-right-radius: ${btrr};` : ''}
|
|
123
|
-
`;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
return radiusValue;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
exports.composeCornerCss = composeCornerCss;
|
|
130
|
-
exports.composeRadius = composeRadius;
|
|
131
|
-
exports.getCornerCSSFromGlobal = getCornerCSSFromGlobal;
|
|
132
|
-
exports.getCustomRadius = getCustomRadius;
|
|
133
|
-
exports.getRadiusCSSFromGlobal = getRadiusCSSFromGlobal;
|
|
134
|
-
exports.getRadiusStyleActiveState = getRadiusStyleActiveState;
|
|
1
|
+
"use strict";var constant=require("./constant.js"),makeStyle=require("./make-style.js");const getCornerCSSFromGlobal=e=>e?.radiusType?["custom","circle"].includes(e?.radiusType)?makeStyle.makeStyle({bblr:e.bblr,bbrr:e.bbrr,btlr:e.btlr,btrr:e.btrr}):makeStyle.makeStyle({radius:`var(--g-radius-${e?.radiusType})`}):{},getRadiusCSSFromGlobal=(e,s,t)=>{if(!s||!e)return{};let a=t&&"desktop"!==t?constant.devicesMapping?.[t]:"",r=constant.stateMapping?.[e];return{[`-${r}-radius${a}`]:`var(--g-radius-${s})`}},getCustomRadius=(e,s,t)=>{if(!s||!e||s?.radiusType!=="custom")return{};let a=t&&"desktop"!==t?constant.devicesMapping?.[t]:"",r=constant.stateMapping?.[e];return{[`-${r}-bblr${a}`]:s.bblr,[`-${r}-bbrr${a}`]:s.bbrr,[`-${r}-btlr${a}`]:s.btlr,[`-${r}-btrr${a}`]:s.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 t={};switch(e?.normal?.radiusType){case"medium":case"large":case"small":Object.assign(t,getRadiusCSSFromGlobal("normal",e?.normal?.radiusType,s));break;case"circle":case"none":case"custom":Object.assign(t,getCustomRadius("normal",e.normal,s))}switch(e?.hover?.radiusType){case"medium":case"large":case"small":Object.assign(t,getRadiusCSSFromGlobal("hover",e?.hover?.radiusType,s));break;case"circle":case"none":case"custom":Object.assign(t,getCustomRadius("hover",e.hover,s))}switch(e?.focus?.radiusType){case"medium":case"large":case"small":Object.assign(t,getRadiusCSSFromGlobal("focus",e?.focus?.radiusType,s));break;case"circle":case"none":case"custom":Object.assign(t,getCustomRadius("focus",e.focus,s))}return t},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 t;if(!e)return"";let{radiusType:a,bblr:r,bbrr:o,btlr:i,btrr:c}=e,u=s?" !important":"";switch(a){case"medium":case"large":case"small":t=`border-radius: var(--g-radius-${a});`;break;case"circle":case"none":case"custom":t=`
|
|
2
|
+
${r?`border-bottom-left-radius: ${r}${u};`:""}
|
|
3
|
+
${o?`border-bottom-right-radius: ${o}${u};`:""}
|
|
4
|
+
${i?`border-top-left-radius: ${i}${u};`:""}
|
|
5
|
+
${c?`border-top-right-radius: ${c}${u};`:""}
|
|
6
|
+
`}return t};exports.composeCornerCss=composeCornerCss,exports.composeRadius=composeRadius,exports.composeRadiusResponsive=composeRadiusResponsive,exports.getCornerCSSFromGlobal=getCornerCSSFromGlobal,exports.getCustomRadius=getCustomRadius,exports.getRadiusCSSFromGlobal=getRadiusCSSFromGlobal,exports.getRadiusStyleActiveState=getRadiusStyleActiveState;
|