@gem-sdk/core 1.5.15 → 1.5.22
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 +7 -7
- package/dist/cjs/components/ComponentWrapper.js +14 -8
- package/dist/cjs/components/ComponentWrapperPreview.js +55 -46
- package/dist/cjs/components/Empty.js +1 -1
- package/dist/cjs/components/Render.js +50 -13
- package/dist/cjs/components/Render.liquid.js +81 -57
- package/dist/cjs/components/RenderBlock.js +41 -8
- package/dist/cjs/components/RenderPreview.js +51 -13
- package/dist/cjs/components/RenderSection.js +11 -7
- package/dist/cjs/components/constant.js +24 -24
- package/dist/cjs/contexts/AddonContext.js +25 -14
- package/dist/cjs/contexts/BuilderComponent.js +23 -19
- package/dist/cjs/contexts/BuilderContext.js +25 -19
- package/dist/cjs/contexts/BuilderPreviewContext.js +349 -341
- package/dist/cjs/contexts/CartLineContext.js +19 -14
- package/dist/cjs/contexts/CollectionContext.js +21 -13
- package/dist/cjs/contexts/ProductContext.js +136 -115
- package/dist/cjs/contexts/ProductListContext.js +21 -13
- package/dist/cjs/contexts/SectionContext.js +41 -37
- package/dist/cjs/contexts/ShopContext.js +49 -31
- package/dist/cjs/graphql/fragments/analytic.generated.js +1 -1
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +1 -1
- package/dist/cjs/graphql/fragments/collection-product.generated.js +1 -1
- package/dist/cjs/graphql/fragments/custom-code.generated.js +1 -1
- package/dist/cjs/graphql/fragments/data-seo.generated.js +1 -1
- package/dist/cjs/graphql/fragments/media.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product-little.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product-option.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +1 -1
- package/dist/cjs/graphql/fragments/selected-option.generated.js +1 -1
- package/dist/cjs/graphql/fragments/variant.generated.js +1 -1
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +1 -1
- package/dist/cjs/graphql/queries/products.generated.js +1 -1
- package/dist/cjs/graphql/queries/store-property.generated.js +1 -1
- package/dist/cjs/helpers/GlobalEvent.js +12 -10
- package/dist/cjs/helpers/background.js +96 -96
- package/dist/cjs/helpers/borders.js +123 -127
- package/dist/cjs/helpers/clone-deep.js +1 -1
- package/dist/cjs/helpers/cls.js +11 -15
- package/dist/cjs/helpers/colors.js +121 -156
- package/dist/cjs/helpers/compose-advance-style.js +115 -121
- package/dist/cjs/helpers/constant.js +16 -11
- package/dist/cjs/helpers/css-variable.js +2 -2
- package/dist/cjs/helpers/email.js +3 -3
- package/dist/cjs/helpers/flatten-connection.js +4 -5
- package/dist/cjs/helpers/get-resonsive-value.js +24 -25
- package/dist/cjs/helpers/get-shortname.js +87 -87
- package/dist/cjs/helpers/is-browser.js +2 -2
- package/dist/cjs/helpers/is-defined.js +2 -2
- package/dist/cjs/helpers/is-empty-children.js +2 -2
- package/dist/cjs/helpers/layout.js +9 -10
- package/dist/cjs/helpers/load-script.js +26 -27
- package/dist/cjs/helpers/make-style.js +77 -86
- package/dist/cjs/helpers/normalize-builder-data.js +18 -12
- package/dist/cjs/helpers/prefetch-queries.js +72 -52
- package/dist/cjs/helpers/product.js +25 -29
- package/dist/cjs/helpers/queries/get-collection.js +179 -167
- package/dist/cjs/helpers/queries/get-product-by-slug.js +103 -94
- package/dist/cjs/helpers/queries/get-product.js +121 -106
- package/dist/cjs/helpers/queries/get-products.js +137 -125
- package/dist/cjs/helpers/radius.js +78 -81
- package/dist/cjs/helpers/render.js +56 -56
- package/dist/cjs/helpers/shadow.js +38 -38
- package/dist/cjs/helpers/size.js +12 -13
- package/dist/cjs/helpers/spacing.js +35 -37
- package/dist/cjs/helpers/tracking/fpixel.js +21 -22
- package/dist/cjs/helpers/tracking/gtag.js +84 -90
- package/dist/cjs/helpers/tracking/tiktokpixel.js +12 -12
- package/dist/cjs/helpers/typography.js +2 -2
- package/dist/cjs/hooks/cart/use-add-to-cart.js +10 -10
- package/dist/cjs/hooks/cart/use-cart-data.js +18 -16
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +10 -10
- package/dist/cjs/hooks/cart/use-cart-note-update.js +10 -10
- package/dist/cjs/hooks/cart/use-create-cart.js +12 -12
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +10 -10
- package/dist/cjs/hooks/cart/use-update-cart-item.js +10 -10
- package/dist/cjs/hooks/shop/use-collection-query.js +12 -6
- package/dist/cjs/hooks/shop/use-product-query.js +12 -6
- package/dist/cjs/hooks/shop/use-products-query.js +14 -6
- package/dist/cjs/hooks/shop.js +86 -67
- package/dist/cjs/hooks/use-current-device.js +14 -16
- package/dist/cjs/hooks/use-lazy-video.js +7 -7
- package/dist/cjs/hooks/useCartId.js +35 -27
- package/dist/cjs/hooks/useCartLine.js +2 -2
- package/dist/cjs/hooks/useCartUI.js +37 -31
- package/dist/cjs/hooks/useCollection.js +2 -2
- package/dist/cjs/hooks/useFetchHandle.js +6 -6
- package/dist/cjs/hooks/useFormatMoney.js +11 -7
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/dist/cjs/hooks/useLoadScript.js +22 -20
- package/dist/cjs/hooks/useMoney.js +59 -42
- package/dist/cjs/hooks/usePrevious.js +12 -10
- package/dist/cjs/hooks/useProduct.js +93 -69
- package/dist/cjs/hooks/useProductList.js +11 -11
- package/dist/cjs/hooks/useSuspenseFetch.js +20 -17
- package/dist/cjs/hooks/useSwatchesOptions.js +32 -30
- package/dist/cjs/types/global-style.js +9 -2
- package/dist/esm/components/AddOn.js +7 -7
- package/dist/esm/components/ComponentWrapper.js +14 -8
- package/dist/esm/components/ComponentWrapperPreview.js +55 -46
- package/dist/esm/components/Empty.js +1 -1
- package/dist/esm/components/Render.js +50 -13
- package/dist/esm/components/Render.liquid.js +81 -57
- package/dist/esm/components/RenderBlock.js +41 -8
- package/dist/esm/components/RenderPreview.js +51 -13
- package/dist/esm/components/RenderSection.js +11 -7
- package/dist/esm/components/constant.js +24 -24
- package/dist/esm/contexts/AddonContext.js +26 -15
- package/dist/esm/contexts/BuilderComponent.js +24 -20
- package/dist/esm/contexts/BuilderContext.js +26 -20
- package/dist/esm/contexts/BuilderPreviewContext.js +350 -342
- package/dist/esm/contexts/CartLineContext.js +20 -15
- package/dist/esm/contexts/CollectionContext.js +22 -14
- package/dist/esm/contexts/ProductContext.js +137 -116
- package/dist/esm/contexts/ProductListContext.js +22 -14
- package/dist/esm/contexts/SectionContext.js +42 -38
- package/dist/esm/contexts/ShopContext.js +50 -32
- package/dist/esm/graphql/fragments/analytic.generated.js +1 -1
- package/dist/esm/graphql/fragments/collection-detail.generated.js +1 -1
- package/dist/esm/graphql/fragments/collection-product.generated.js +1 -1
- package/dist/esm/graphql/fragments/custom-code.generated.js +1 -1
- package/dist/esm/graphql/fragments/data-seo.generated.js +1 -1
- package/dist/esm/graphql/fragments/media.generated.js +1 -1
- package/dist/esm/graphql/fragments/product-little.generated.js +1 -1
- package/dist/esm/graphql/fragments/product-option-value.generated.js +1 -1
- package/dist/esm/graphql/fragments/product-option.generated.js +1 -1
- package/dist/esm/graphql/fragments/product.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-page-section.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +1 -1
- package/dist/esm/graphql/fragments/selected-option.generated.js +1 -1
- package/dist/esm/graphql/fragments/variant.generated.js +1 -1
- package/dist/esm/graphql/mutations/page-view-up.generated.js +1 -1
- package/dist/esm/graphql/queries/products.generated.js +1 -1
- package/dist/esm/graphql/queries/store-property.generated.js +1 -1
- package/dist/esm/helpers/GlobalEvent.js +12 -10
- package/dist/esm/helpers/background.js +96 -96
- package/dist/esm/helpers/borders.js +123 -127
- package/dist/esm/helpers/clone-deep.js +1 -1
- package/dist/esm/helpers/cls.js +11 -15
- package/dist/esm/helpers/colors.js +121 -156
- package/dist/esm/helpers/compose-advance-style.js +115 -121
- package/dist/esm/helpers/constant.js +16 -11
- package/dist/esm/helpers/css-variable.js +2 -2
- package/dist/esm/helpers/email.js +3 -3
- package/dist/esm/helpers/flatten-connection.js +4 -5
- package/dist/esm/helpers/get-resonsive-value.js +24 -25
- package/dist/esm/helpers/get-shortname.js +87 -87
- package/dist/esm/helpers/is-browser.js +2 -2
- package/dist/esm/helpers/is-defined.js +2 -2
- package/dist/esm/helpers/is-empty-children.js +2 -2
- package/dist/esm/helpers/layout.js +9 -10
- package/dist/esm/helpers/load-script.js +26 -27
- package/dist/esm/helpers/make-style.js +77 -86
- package/dist/esm/helpers/normalize-builder-data.js +18 -12
- package/dist/esm/helpers/prefetch-queries.js +72 -52
- package/dist/esm/helpers/product.js +25 -29
- package/dist/esm/helpers/queries/get-collection.js +179 -167
- package/dist/esm/helpers/queries/get-product-by-slug.js +103 -94
- package/dist/esm/helpers/queries/get-product.js +121 -106
- package/dist/esm/helpers/queries/get-products.js +137 -125
- package/dist/esm/helpers/radius.js +78 -81
- package/dist/esm/helpers/render.js +56 -56
- package/dist/esm/helpers/shadow.js +38 -38
- package/dist/esm/helpers/size.js +12 -13
- package/dist/esm/helpers/spacing.js +35 -37
- package/dist/esm/helpers/tracking/fpixel.js +21 -22
- package/dist/esm/helpers/tracking/gtag.js +84 -90
- package/dist/esm/helpers/tracking/tiktokpixel.js +12 -12
- package/dist/esm/helpers/typography.js +2 -2
- package/dist/esm/hooks/cart/use-add-to-cart.js +10 -10
- package/dist/esm/hooks/cart/use-cart-data.js +18 -16
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +10 -10
- package/dist/esm/hooks/cart/use-cart-note-update.js +10 -10
- package/dist/esm/hooks/cart/use-create-cart.js +12 -12
- package/dist/esm/hooks/cart/use-remove-cart-item.js +10 -10
- package/dist/esm/hooks/cart/use-update-cart-item.js +10 -10
- package/dist/esm/hooks/shop/use-collection-query.js +12 -6
- package/dist/esm/hooks/shop/use-product-query.js +12 -6
- package/dist/esm/hooks/shop/use-products-query.js +14 -6
- package/dist/esm/hooks/shop.js +86 -67
- package/dist/esm/hooks/use-current-device.js +14 -16
- package/dist/esm/hooks/use-lazy-video.js +7 -7
- package/dist/esm/hooks/useCartId.js +35 -27
- package/dist/esm/hooks/useCartLine.js +2 -2
- package/dist/esm/hooks/useCartUI.js +37 -31
- package/dist/esm/hooks/useCollection.js +2 -2
- package/dist/esm/hooks/useFetchHandle.js +6 -6
- package/dist/esm/hooks/useFormatMoney.js +11 -7
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/dist/esm/hooks/useLoadScript.js +22 -20
- package/dist/esm/hooks/useMoney.js +59 -42
- package/dist/esm/hooks/usePrevious.js +12 -10
- package/dist/esm/hooks/useProduct.js +93 -70
- package/dist/esm/hooks/useProductList.js +11 -11
- package/dist/esm/hooks/useSuspenseFetch.js +20 -17
- package/dist/esm/hooks/useSwatchesOptions.js +32 -30
- package/dist/esm/types/global-style.js +9 -2
- package/dist/types/index.d.ts +24 -2
- package/package.json +1 -1
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
|
|
5
|
-
const usePrevious = (value)
|
|
6
|
-
// The ref object is a generic container whose current property is mutable ...
|
|
7
|
-
// ... and can hold any value, similar to an instance property on a class
|
|
8
|
-
const ref = react.useRef();
|
|
9
|
-
// Store current value in ref
|
|
10
|
-
react.useEffect(()
|
|
11
|
-
ref.current = value;
|
|
12
|
-
}, [
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const usePrevious = (value)=>{
|
|
6
|
+
// The ref object is a generic container whose current property is mutable ...
|
|
7
|
+
// ... and can hold any value, similar to an instance property on a class
|
|
8
|
+
const ref = react.useRef();
|
|
9
|
+
// Store current value in ref
|
|
10
|
+
react.useEffect(()=>{
|
|
11
|
+
ref.current = value;
|
|
12
|
+
}, [
|
|
13
|
+
value
|
|
14
|
+
]); // Only re-run if value changes
|
|
15
|
+
// Return previous value (happens before update in useEffect above)
|
|
16
|
+
return ref.current;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
exports.usePrevious = usePrevious;
|
|
@@ -7,77 +7,101 @@ require('swr');
|
|
|
7
7
|
var product = require('../helpers/product.js');
|
|
8
8
|
require('../helpers/convert.js');
|
|
9
9
|
|
|
10
|
-
const useUniqProductID = ()
|
|
11
|
-
return ProductContext.useProductStore((s)
|
|
12
|
-
};
|
|
13
|
-
const useProduct = ()
|
|
14
|
-
return ProductContext.useProductStore((s)
|
|
15
|
-
};
|
|
16
|
-
const useFeaturedImageGlobal = ()
|
|
17
|
-
return ProductContext.useProductStore((s)
|
|
18
|
-
};
|
|
19
|
-
const useProductProperties = ()
|
|
20
|
-
return ProductContext.useProductStore((s)
|
|
21
|
-
};
|
|
22
|
-
const useQuantity = ()
|
|
23
|
-
const quantity = ProductContext.useProductStore((s)
|
|
24
|
-
const decrement = ProductContext.useProductStore((s)
|
|
25
|
-
const increment = ProductContext.useProductStore((s)
|
|
26
|
-
const updateQuantity = ProductContext.useProductStore((s)
|
|
27
|
-
const reset = react.useCallback(()
|
|
28
|
-
updateQuantity(1);
|
|
29
|
-
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
10
|
+
const useUniqProductID = ()=>{
|
|
11
|
+
return ProductContext.useProductStore((s)=>s.uiqueId);
|
|
12
|
+
};
|
|
13
|
+
const useProduct = ()=>{
|
|
14
|
+
return ProductContext.useProductStore((s)=>s.product);
|
|
15
|
+
};
|
|
16
|
+
const useFeaturedImageGlobal = ()=>{
|
|
17
|
+
return ProductContext.useProductStore((s)=>s.featuredImageGlobal);
|
|
18
|
+
};
|
|
19
|
+
const useProductProperties = ()=>{
|
|
20
|
+
return ProductContext.useProductStore((s)=>s.properties);
|
|
21
|
+
};
|
|
22
|
+
const useQuantity = ()=>{
|
|
23
|
+
const quantity = ProductContext.useProductStore((s)=>s.quantity);
|
|
24
|
+
const decrement = ProductContext.useProductStore((s)=>s.decrementQuantity);
|
|
25
|
+
const increment = ProductContext.useProductStore((s)=>s.incrementQuantity);
|
|
26
|
+
const updateQuantity = ProductContext.useProductStore((s)=>s.setQuantity);
|
|
27
|
+
const reset = react.useCallback(()=>{
|
|
28
|
+
updateQuantity(1);
|
|
29
|
+
}, [
|
|
30
|
+
updateQuantity
|
|
31
|
+
]);
|
|
32
|
+
return react.useMemo(()=>({
|
|
33
|
+
quantity,
|
|
34
|
+
increment,
|
|
35
|
+
decrement,
|
|
36
|
+
reset,
|
|
37
|
+
setQuantity: updateQuantity
|
|
38
|
+
}), [
|
|
39
|
+
decrement,
|
|
40
|
+
increment,
|
|
41
|
+
quantity,
|
|
42
|
+
reset,
|
|
43
|
+
updateQuantity
|
|
44
|
+
]);
|
|
45
|
+
};
|
|
46
|
+
const useSelectedOption = ()=>{
|
|
47
|
+
const setSelectedOption = ProductContext.useProductStore((s)=>s.setSelectedOption);
|
|
48
|
+
const selectedOptions = ProductContext.useProductStore((s)=>s.selectedOptions);
|
|
49
|
+
const forceSelectedOption = ProductContext.useProductStore((s)=>s.forceSelectedOption);
|
|
50
|
+
const updateOption = react.useCallback((optionId, optionValue)=>{
|
|
51
|
+
setSelectedOption(optionId, optionValue);
|
|
52
|
+
}, [
|
|
53
|
+
setSelectedOption
|
|
54
|
+
]);
|
|
55
|
+
return react.useMemo(()=>({
|
|
56
|
+
selectedOptions,
|
|
57
|
+
setSelectedOption: updateOption,
|
|
58
|
+
forceSelectedOption
|
|
59
|
+
}), [
|
|
60
|
+
selectedOptions,
|
|
61
|
+
updateOption,
|
|
62
|
+
forceSelectedOption
|
|
63
|
+
]);
|
|
64
|
+
};
|
|
65
|
+
const useVariants = ()=>{
|
|
66
|
+
const variants = ProductContext.useProductStore((s)=>s.product?.variants);
|
|
67
|
+
return flattenConnection.flattenConnection(variants);
|
|
68
|
+
};
|
|
69
|
+
const useVariant = (id)=>{
|
|
70
|
+
const variants = useVariants();
|
|
71
|
+
return react.useMemo(()=>variants?.find((v)=>v?.id === id), [
|
|
72
|
+
id,
|
|
73
|
+
variants
|
|
74
|
+
]);
|
|
75
|
+
};
|
|
76
|
+
const useCurrentVariant = ()=>{
|
|
77
|
+
const { selectedOptions } = useSelectedOption();
|
|
78
|
+
const variants = useVariants();
|
|
79
|
+
return react.useMemo(()=>product.getSelectedVariant(variants, selectedOptions), [
|
|
80
|
+
selectedOptions,
|
|
81
|
+
variants
|
|
82
|
+
]);
|
|
83
|
+
};
|
|
84
|
+
function checkInStock(variant) {
|
|
85
|
+
if (!variant) return false;
|
|
86
|
+
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 || !variant?.manageInventory || variant.inventoryPolicy === 'continue';
|
|
87
|
+
}
|
|
88
|
+
const useCurrentVariantInStock = ()=>{
|
|
89
|
+
const currentVariant = useCurrentVariant();
|
|
90
|
+
const isInStock = checkInStock(currentVariant);
|
|
91
|
+
return isInStock;
|
|
92
|
+
};
|
|
93
|
+
const useVariantOutStock = (optionId, optionValue)=>{
|
|
94
|
+
const { selectedOptions } = useSelectedOption();
|
|
95
|
+
const variants = useVariants();
|
|
96
|
+
const matchedVariant = product.getSelectedVariant(variants, {
|
|
97
|
+
...selectedOptions,
|
|
98
|
+
[optionId]: optionValue
|
|
99
|
+
});
|
|
100
|
+
const isInStock = checkInStock(matchedVariant);
|
|
101
|
+
return !isInStock;
|
|
79
102
|
};
|
|
80
103
|
|
|
104
|
+
exports.checkInStock = checkInStock;
|
|
81
105
|
exports.useCurrentVariant = useCurrentVariant;
|
|
82
106
|
exports.useCurrentVariantInStock = useCurrentVariantInStock;
|
|
83
107
|
exports.useFeaturedImageGlobal = useFeaturedImageGlobal;
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var ProductListContext = require('../contexts/ProductListContext.js');
|
|
4
4
|
|
|
5
|
-
const useProductList = ()
|
|
6
|
-
return ProductListContext.useProductListStore((s)
|
|
7
|
-
};
|
|
8
|
-
const useProductListProducts = ()
|
|
9
|
-
return ProductListContext.useProductListStore((s)
|
|
10
|
-
};
|
|
11
|
-
const useProductListSettings = ()
|
|
12
|
-
return ProductListContext.useProductListStore((s)
|
|
13
|
-
};
|
|
14
|
-
const useProductListStyles = ()
|
|
15
|
-
return ProductListContext.useProductListStore((s)
|
|
5
|
+
const useProductList = ()=>{
|
|
6
|
+
return ProductListContext.useProductListStore((s)=>s.collection);
|
|
7
|
+
};
|
|
8
|
+
const useProductListProducts = ()=>{
|
|
9
|
+
return ProductListContext.useProductListStore((s)=>s.products);
|
|
10
|
+
};
|
|
11
|
+
const useProductListSettings = ()=>{
|
|
12
|
+
return ProductListContext.useProductListStore((s)=>s.settings);
|
|
13
|
+
};
|
|
14
|
+
const useProductListStyles = ()=>{
|
|
15
|
+
return ProductListContext.useProductListStore((s)=>s.styles);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
exports.useProductList = useProductList;
|
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const cache = new Map();
|
|
6
|
-
const useSuspenseFetch = (key, promise)
|
|
7
|
-
const value = cache.get(key) || {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
value.
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
|
|
5
|
+
const cache = new Map();
|
|
6
|
+
const useSuspenseFetch = (key, promise)=>{
|
|
7
|
+
const value = cache.get(key) || {
|
|
8
|
+
status: 'new',
|
|
9
|
+
data: null
|
|
10
|
+
};
|
|
11
|
+
if (value.status === 'resolved') {
|
|
12
|
+
return {
|
|
13
|
+
data: value.data
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
promise().then((data)=>{
|
|
17
|
+
value.status = 'resolved';
|
|
18
|
+
value.data = data;
|
|
19
|
+
cache.set(key, value);
|
|
20
|
+
}).catch(()=>{
|
|
21
|
+
value.status = 'error';
|
|
22
|
+
value.data = null;
|
|
23
|
+
});
|
|
24
|
+
throw promise();
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
exports.default = useSuspenseFetch;
|
|
@@ -4,36 +4,38 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var shop = require('./shop.js');
|
|
6
6
|
|
|
7
|
-
const initialSwatchOptionValue = {
|
|
8
|
-
label: '',
|
|
9
|
-
colors: [],
|
|
10
|
-
imageUrl: ''
|
|
11
|
-
};
|
|
12
|
-
const initialGlobalSwatchesData = {
|
|
13
|
-
optionTitle: '',
|
|
14
|
-
optionType: '',
|
|
15
|
-
optionValues: []
|
|
16
|
-
};
|
|
17
|
-
const useSwatchesOptions = (options)
|
|
18
|
-
const { swatches
|
|
19
|
-
if (!options)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
7
|
+
const initialSwatchOptionValue = {
|
|
8
|
+
label: '',
|
|
9
|
+
colors: [],
|
|
10
|
+
imageUrl: ''
|
|
11
|
+
};
|
|
12
|
+
const initialGlobalSwatchesData = {
|
|
13
|
+
optionTitle: '',
|
|
14
|
+
optionType: '',
|
|
15
|
+
optionValues: []
|
|
16
|
+
};
|
|
17
|
+
const useSwatchesOptions = (options)=>{
|
|
18
|
+
const { swatches } = shop.useSwatches();
|
|
19
|
+
if (!options) return [];
|
|
20
|
+
return options?.map((option)=>{
|
|
21
|
+
const swatchOption = swatches?.find((sw)=>sw?.optionTitle === option?.name) || {
|
|
22
|
+
...initialGlobalSwatchesData
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
...option,
|
|
26
|
+
optionType: swatchOption ? swatchOption.optionType : '',
|
|
27
|
+
values: option.values?.map((val)=>{
|
|
28
|
+
const swatchValue = swatchOption && swatchOption?.optionValues?.find((swatOp)=>swatOp?.label === val?.label) || {
|
|
29
|
+
...initialSwatchOptionValue
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
...val,
|
|
33
|
+
colors: swatchValue?.colors || [],
|
|
34
|
+
imageUrl: swatchValue?.imageUrl || ''
|
|
35
|
+
};
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
});
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
exports.default = useSwatchesOptions;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const OptionNormalStyle = [
|
|
4
|
-
|
|
3
|
+
const OptionNormalStyle = [
|
|
4
|
+
'radio_buttons',
|
|
5
|
+
'dropdown'
|
|
6
|
+
];
|
|
7
|
+
const OptionSpecialStyle = [
|
|
8
|
+
'color',
|
|
9
|
+
'image',
|
|
10
|
+
'rectangle_list'
|
|
11
|
+
];
|
|
5
12
|
|
|
6
13
|
exports.OptionNormalStyle = OptionNormalStyle;
|
|
7
14
|
exports.OptionSpecialStyle = OptionSpecialStyle;
|
|
@@ -2,13 +2,13 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useAddon } from '../contexts/AddonContext.js';
|
|
3
3
|
import { usePluginEnable } from '../hooks/shop.js';
|
|
4
4
|
|
|
5
|
-
const AddOn = ({ name
|
|
6
|
-
const Comp = useAddon(name);
|
|
7
|
-
const plugins = usePluginEnable();
|
|
8
|
-
if (!plugins?.includes(name)) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return jsx(Comp, {});
|
|
5
|
+
const AddOn = ({ name })=>{
|
|
6
|
+
const Comp = useAddon(name);
|
|
7
|
+
const plugins = usePluginEnable();
|
|
8
|
+
if (!plugins?.includes(name)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return /*#__PURE__*/ jsx(Comp, {});
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export { AddOn as default };
|
|
@@ -3,14 +3,20 @@ import { isValidElement } from 'react';
|
|
|
3
3
|
import { composeAdvanceStyle } from '../helpers/compose-advance-style.js';
|
|
4
4
|
import { disableWrap } from './constant.js';
|
|
5
5
|
|
|
6
|
-
const ComponentWrapper = ({ children, ...props })
|
|
7
|
-
if (props.type === 'section')
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const ComponentWrapper = ({ children , ...props })=>{
|
|
7
|
+
if (props.type === 'section') return null;
|
|
8
|
+
const style = composeAdvanceStyle(props.advanced, props.tag);
|
|
9
|
+
if (disableWrap.includes(props.tag) && /*#__PURE__*/ isValidElement(children)) {
|
|
10
|
+
return /*#__PURE__*/ jsx(children.type, {
|
|
11
|
+
...children.props,
|
|
12
|
+
style
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return /*#__PURE__*/ jsx("div", {
|
|
16
|
+
style: style,
|
|
17
|
+
className: `${props.uid}`,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
14
20
|
};
|
|
15
21
|
|
|
16
22
|
export { ComponentWrapper as default };
|
|
@@ -3,52 +3,61 @@ import { isValidElement } from 'react';
|
|
|
3
3
|
import { composeAdvanceStyle } from '../helpers/compose-advance-style.js';
|
|
4
4
|
import { disableWrap } from './constant.js';
|
|
5
5
|
|
|
6
|
-
const ComponentWrapperPreview = ({ children, ...props })
|
|
7
|
-
if (props.type === 'section') {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const customProps = {};
|
|
11
|
-
// Build editor configs
|
|
12
|
-
if (props.editorConfigs) {
|
|
13
|
-
const editorConfigs = props.editorConfigs;
|
|
14
|
-
if (editorConfigs.placeholder?.notAppendBeforeAfter) {
|
|
15
|
-
customProps['data-placeholder-not-append-before-after'] = true;
|
|
16
|
-
}
|
|
17
|
-
if (editorConfigs.toolbar?.parent) {
|
|
18
|
-
customProps['data-toolbar-parent'] = true;
|
|
19
|
-
}
|
|
20
|
-
if (editorConfigs.component?.noDelete) {
|
|
21
|
-
customProps['data-component-no-delete'] = true;
|
|
22
|
-
}
|
|
23
|
-
if (editorConfigs.component?.noDuplicate) {
|
|
24
|
-
customProps['data-component-no-duplicate'] = true;
|
|
25
|
-
}
|
|
26
|
-
if (editorConfigs.component?.noDragDrop) {
|
|
27
|
-
customProps['data-component-no-drag-drop'] = true;
|
|
28
|
-
}
|
|
29
|
-
if (editorConfigs.component?.noSetting) {
|
|
30
|
-
customProps['data-component-no-setting'] = true;
|
|
31
|
-
}
|
|
32
|
-
if (editorConfigs.toolbar?.hide) {
|
|
33
|
-
customProps['data-toolbar-hide'] = true;
|
|
34
|
-
}
|
|
35
|
-
if (editorConfigs.slots?.children) {
|
|
36
|
-
customProps['data-slots-children'] = true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const style = composeAdvanceStyle(props.advanced, props.tag);
|
|
40
|
-
const builderAttrs = {
|
|
41
|
-
...customProps,
|
|
42
|
-
'data-uid': props.uid,
|
|
43
|
-
'data-component-type': 'component',
|
|
44
|
-
'data-component-tag': props.tag,
|
|
45
|
-
'data-component-label': props.label
|
|
46
|
-
};
|
|
47
|
-
if (disableWrap.includes(props.tag) && isValidElement(children)) {
|
|
48
|
-
return jsx(children.type, {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
6
|
+
const ComponentWrapperPreview = ({ children , ...props })=>{
|
|
7
|
+
if (props.type === 'section') {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const customProps = {};
|
|
11
|
+
// Build editor configs
|
|
12
|
+
if (props.editorConfigs) {
|
|
13
|
+
const editorConfigs = props.editorConfigs;
|
|
14
|
+
if (editorConfigs.placeholder?.notAppendBeforeAfter) {
|
|
15
|
+
customProps['data-placeholder-not-append-before-after'] = true;
|
|
16
|
+
}
|
|
17
|
+
if (editorConfigs.toolbar?.parent) {
|
|
18
|
+
customProps['data-toolbar-parent'] = true;
|
|
19
|
+
}
|
|
20
|
+
if (editorConfigs.component?.noDelete) {
|
|
21
|
+
customProps['data-component-no-delete'] = true;
|
|
22
|
+
}
|
|
23
|
+
if (editorConfigs.component?.noDuplicate) {
|
|
24
|
+
customProps['data-component-no-duplicate'] = true;
|
|
25
|
+
}
|
|
26
|
+
if (editorConfigs.component?.noDragDrop) {
|
|
27
|
+
customProps['data-component-no-drag-drop'] = true;
|
|
28
|
+
}
|
|
29
|
+
if (editorConfigs.component?.noSetting) {
|
|
30
|
+
customProps['data-component-no-setting'] = true;
|
|
31
|
+
}
|
|
32
|
+
if (editorConfigs.toolbar?.hide) {
|
|
33
|
+
customProps['data-toolbar-hide'] = true;
|
|
34
|
+
}
|
|
35
|
+
if (editorConfigs.slots?.children) {
|
|
36
|
+
customProps['data-slots-children'] = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const style = composeAdvanceStyle(props.advanced, props.tag);
|
|
40
|
+
const builderAttrs = {
|
|
41
|
+
...customProps,
|
|
42
|
+
'data-uid': props.uid,
|
|
43
|
+
'data-component-type': 'component',
|
|
44
|
+
'data-component-tag': props.tag,
|
|
45
|
+
'data-component-label': props.label
|
|
46
|
+
};
|
|
47
|
+
if (disableWrap.includes(props.tag) && /*#__PURE__*/ isValidElement(children)) {
|
|
48
|
+
return /*#__PURE__*/ jsx(children.type, {
|
|
49
|
+
...children.props,
|
|
50
|
+
style,
|
|
51
|
+
builderAttrs
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// Render
|
|
55
|
+
return /*#__PURE__*/ jsx("div", {
|
|
56
|
+
style: style,
|
|
57
|
+
className: `${props.uid}`,
|
|
58
|
+
...builderAttrs,
|
|
59
|
+
children: children
|
|
60
|
+
});
|
|
52
61
|
};
|
|
53
62
|
|
|
54
63
|
export { ComponentWrapperPreview as default };
|
|
@@ -6,19 +6,56 @@ import { useBuilderStore } from '../contexts/BuilderContext.js';
|
|
|
6
6
|
import ComponentWrapper from './ComponentWrapper.js';
|
|
7
7
|
import RenderSectionMemo from './RenderSection.js';
|
|
8
8
|
|
|
9
|
-
const Render = ({ uid, ...passProps })
|
|
10
|
-
const item = useBuilderStore((s)
|
|
11
|
-
const Component = useBuilderComponent(item?.tag);
|
|
12
|
-
if (!item)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
else {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
const Render = ({ uid , ...passProps })=>{
|
|
10
|
+
const item = useBuilderStore((s)=>s.getItem(uid));
|
|
11
|
+
const Component = useBuilderComponent(item?.tag);
|
|
12
|
+
if (!item) return null;
|
|
13
|
+
if (item?.type === 'section') {
|
|
14
|
+
return /*#__PURE__*/ jsx(RenderSectionMemo, {
|
|
15
|
+
sectionId: item.uid
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
return /*#__PURE__*/ jsx(ErrorBoundary, {
|
|
19
|
+
fallbackRender: ({ error , resetErrorBoundary })=>/*#__PURE__*/ jsxs(Fragment, {
|
|
20
|
+
children: [
|
|
21
|
+
/*#__PURE__*/ jsx("span", {
|
|
22
|
+
"aria-label": "Error message",
|
|
23
|
+
children: error.message
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx("button", {
|
|
26
|
+
type: "button",
|
|
27
|
+
onClick: resetErrorBoundary,
|
|
28
|
+
children: "Try again"
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
children: /*#__PURE__*/ jsx(ComponentWrapper, {
|
|
33
|
+
...item,
|
|
34
|
+
children: item?.childrens?.length ? /*#__PURE__*/ jsx(Component, {
|
|
35
|
+
builderProps: {
|
|
36
|
+
uid,
|
|
37
|
+
builderData: item
|
|
38
|
+
},
|
|
39
|
+
styles: item.styles,
|
|
40
|
+
setting: item.settings,
|
|
41
|
+
...passProps,
|
|
42
|
+
children: item.childrens.map((id)=>/*#__PURE__*/ jsx(RenderMemo, {
|
|
43
|
+
uid: id
|
|
44
|
+
}, id))
|
|
45
|
+
}) : /*#__PURE__*/ jsx(Component, {
|
|
46
|
+
builderProps: {
|
|
47
|
+
uid,
|
|
48
|
+
builderData: item
|
|
49
|
+
},
|
|
50
|
+
styles: item.styles,
|
|
51
|
+
setting: item.settings,
|
|
52
|
+
...passProps
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
}, item.uid);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const RenderMemo = /*#__PURE__*/ memo(Render);
|
|
22
59
|
RenderMemo.displayName = 'RenderMemo';
|
|
23
60
|
|
|
24
61
|
export { RenderMemo as default };
|