@gem-sdk/core 1.5.17 → 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 +92 -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 +92 -69
- 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
|
@@ -5,75 +5,98 @@ import 'swr';
|
|
|
5
5
|
import { getSelectedVariant } from '../helpers/product.js';
|
|
6
6
|
import '../helpers/convert.js';
|
|
7
7
|
|
|
8
|
-
const useUniqProductID = ()
|
|
9
|
-
return useProductStore((s)
|
|
10
|
-
};
|
|
11
|
-
const useProduct = ()
|
|
12
|
-
return useProductStore((s)
|
|
13
|
-
};
|
|
14
|
-
const useFeaturedImageGlobal = ()
|
|
15
|
-
return useProductStore((s)
|
|
16
|
-
};
|
|
17
|
-
const useProductProperties = ()
|
|
18
|
-
return useProductStore((s)
|
|
19
|
-
};
|
|
20
|
-
const useQuantity = ()
|
|
21
|
-
const quantity = useProductStore((s)
|
|
22
|
-
const decrement = useProductStore((s)
|
|
23
|
-
const increment = useProductStore((s)
|
|
24
|
-
const updateQuantity = useProductStore((s)
|
|
25
|
-
const reset = useCallback(()
|
|
26
|
-
updateQuantity(1);
|
|
27
|
-
}, [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
8
|
+
const useUniqProductID = ()=>{
|
|
9
|
+
return useProductStore((s)=>s.uiqueId);
|
|
10
|
+
};
|
|
11
|
+
const useProduct = ()=>{
|
|
12
|
+
return useProductStore((s)=>s.product);
|
|
13
|
+
};
|
|
14
|
+
const useFeaturedImageGlobal = ()=>{
|
|
15
|
+
return useProductStore((s)=>s.featuredImageGlobal);
|
|
16
|
+
};
|
|
17
|
+
const useProductProperties = ()=>{
|
|
18
|
+
return useProductStore((s)=>s.properties);
|
|
19
|
+
};
|
|
20
|
+
const useQuantity = ()=>{
|
|
21
|
+
const quantity = useProductStore((s)=>s.quantity);
|
|
22
|
+
const decrement = useProductStore((s)=>s.decrementQuantity);
|
|
23
|
+
const increment = useProductStore((s)=>s.incrementQuantity);
|
|
24
|
+
const updateQuantity = useProductStore((s)=>s.setQuantity);
|
|
25
|
+
const reset = useCallback(()=>{
|
|
26
|
+
updateQuantity(1);
|
|
27
|
+
}, [
|
|
28
|
+
updateQuantity
|
|
29
|
+
]);
|
|
30
|
+
return useMemo(()=>({
|
|
31
|
+
quantity,
|
|
32
|
+
increment,
|
|
33
|
+
decrement,
|
|
34
|
+
reset,
|
|
35
|
+
setQuantity: updateQuantity
|
|
36
|
+
}), [
|
|
37
|
+
decrement,
|
|
38
|
+
increment,
|
|
39
|
+
quantity,
|
|
40
|
+
reset,
|
|
41
|
+
updateQuantity
|
|
42
|
+
]);
|
|
43
|
+
};
|
|
44
|
+
const useSelectedOption = ()=>{
|
|
45
|
+
const setSelectedOption = useProductStore((s)=>s.setSelectedOption);
|
|
46
|
+
const selectedOptions = useProductStore((s)=>s.selectedOptions);
|
|
47
|
+
const forceSelectedOption = useProductStore((s)=>s.forceSelectedOption);
|
|
48
|
+
const updateOption = useCallback((optionId, optionValue)=>{
|
|
49
|
+
setSelectedOption(optionId, optionValue);
|
|
50
|
+
}, [
|
|
51
|
+
setSelectedOption
|
|
52
|
+
]);
|
|
53
|
+
return useMemo(()=>({
|
|
54
|
+
selectedOptions,
|
|
55
|
+
setSelectedOption: updateOption,
|
|
56
|
+
forceSelectedOption
|
|
57
|
+
}), [
|
|
58
|
+
selectedOptions,
|
|
59
|
+
updateOption,
|
|
60
|
+
forceSelectedOption
|
|
61
|
+
]);
|
|
62
|
+
};
|
|
63
|
+
const useVariants = ()=>{
|
|
64
|
+
const variants = useProductStore((s)=>s.product?.variants);
|
|
65
|
+
return flattenConnection(variants);
|
|
66
|
+
};
|
|
67
|
+
const useVariant = (id)=>{
|
|
68
|
+
const variants = useVariants();
|
|
69
|
+
return useMemo(()=>variants?.find((v)=>v?.id === id), [
|
|
70
|
+
id,
|
|
71
|
+
variants
|
|
72
|
+
]);
|
|
73
|
+
};
|
|
74
|
+
const useCurrentVariant = ()=>{
|
|
75
|
+
const { selectedOptions } = useSelectedOption();
|
|
76
|
+
const variants = useVariants();
|
|
77
|
+
return useMemo(()=>getSelectedVariant(variants, selectedOptions), [
|
|
78
|
+
selectedOptions,
|
|
79
|
+
variants
|
|
80
|
+
]);
|
|
81
|
+
};
|
|
82
|
+
function checkInStock(variant) {
|
|
83
|
+
if (!variant) return false;
|
|
84
|
+
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 || !variant?.manageInventory || variant.inventoryPolicy === 'continue';
|
|
85
|
+
}
|
|
86
|
+
const useCurrentVariantInStock = ()=>{
|
|
87
|
+
const currentVariant = useCurrentVariant();
|
|
88
|
+
const isInStock = checkInStock(currentVariant);
|
|
89
|
+
return isInStock;
|
|
90
|
+
};
|
|
91
|
+
const useVariantOutStock = (optionId, optionValue)=>{
|
|
92
|
+
const { selectedOptions } = useSelectedOption();
|
|
93
|
+
const variants = useVariants();
|
|
94
|
+
const matchedVariant = getSelectedVariant(variants, {
|
|
95
|
+
...selectedOptions,
|
|
96
|
+
[optionId]: optionValue
|
|
97
|
+
});
|
|
98
|
+
const isInStock = checkInStock(matchedVariant);
|
|
99
|
+
return !isInStock;
|
|
77
100
|
};
|
|
78
101
|
|
|
79
102
|
export { checkInStock, useCurrentVariant, useCurrentVariantInStock, useFeaturedImageGlobal, useProduct, useProductProperties, useQuantity, useSelectedOption, useUniqProductID, useVariant, useVariantOutStock, useVariants };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useProductListStore } from '../contexts/ProductListContext.js';
|
|
2
2
|
|
|
3
|
-
const useProductList = ()
|
|
4
|
-
return useProductListStore((s)
|
|
5
|
-
};
|
|
6
|
-
const useProductListProducts = ()
|
|
7
|
-
return useProductListStore((s)
|
|
8
|
-
};
|
|
9
|
-
const useProductListSettings = ()
|
|
10
|
-
return useProductListStore((s)
|
|
11
|
-
};
|
|
12
|
-
const useProductListStyles = ()
|
|
13
|
-
return useProductListStore((s)
|
|
3
|
+
const useProductList = ()=>{
|
|
4
|
+
return useProductListStore((s)=>s.collection);
|
|
5
|
+
};
|
|
6
|
+
const useProductListProducts = ()=>{
|
|
7
|
+
return useProductListStore((s)=>s.products);
|
|
8
|
+
};
|
|
9
|
+
const useProductListSettings = ()=>{
|
|
10
|
+
return useProductListStore((s)=>s.settings);
|
|
11
|
+
};
|
|
12
|
+
const useProductListStyles = ()=>{
|
|
13
|
+
return useProductListStore((s)=>s.styles);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export { useProductList, useProductListProducts, useProductListSettings, useProductListStyles };
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
const cache = new Map();
|
|
2
|
-
const useSuspenseFetch = (key, promise)
|
|
3
|
-
const value = cache.get(key) || {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
value.
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
1
|
+
const cache = new Map();
|
|
2
|
+
const useSuspenseFetch = (key, promise)=>{
|
|
3
|
+
const value = cache.get(key) || {
|
|
4
|
+
status: 'new',
|
|
5
|
+
data: null
|
|
6
|
+
};
|
|
7
|
+
if (value.status === 'resolved') {
|
|
8
|
+
return {
|
|
9
|
+
data: value.data
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
promise().then((data)=>{
|
|
13
|
+
value.status = 'resolved';
|
|
14
|
+
value.data = data;
|
|
15
|
+
cache.set(key, value);
|
|
16
|
+
}).catch(()=>{
|
|
17
|
+
value.status = 'error';
|
|
18
|
+
value.data = null;
|
|
19
|
+
});
|
|
20
|
+
throw promise();
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
export { useSuspenseFetch as default };
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { useSwatches } from './shop.js';
|
|
2
2
|
|
|
3
|
-
const initialSwatchOptionValue = {
|
|
4
|
-
label: '',
|
|
5
|
-
colors: [],
|
|
6
|
-
imageUrl: ''
|
|
7
|
-
};
|
|
8
|
-
const initialGlobalSwatchesData = {
|
|
9
|
-
optionTitle: '',
|
|
10
|
-
optionType: '',
|
|
11
|
-
optionValues: []
|
|
12
|
-
};
|
|
13
|
-
const useSwatchesOptions = (options)
|
|
14
|
-
const { swatches
|
|
15
|
-
if (!options)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
3
|
+
const initialSwatchOptionValue = {
|
|
4
|
+
label: '',
|
|
5
|
+
colors: [],
|
|
6
|
+
imageUrl: ''
|
|
7
|
+
};
|
|
8
|
+
const initialGlobalSwatchesData = {
|
|
9
|
+
optionTitle: '',
|
|
10
|
+
optionType: '',
|
|
11
|
+
optionValues: []
|
|
12
|
+
};
|
|
13
|
+
const useSwatchesOptions = (options)=>{
|
|
14
|
+
const { swatches } = useSwatches();
|
|
15
|
+
if (!options) return [];
|
|
16
|
+
return options?.map((option)=>{
|
|
17
|
+
const swatchOption = swatches?.find((sw)=>sw?.optionTitle === option?.name) || {
|
|
18
|
+
...initialGlobalSwatchesData
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
...option,
|
|
22
|
+
optionType: swatchOption ? swatchOption.optionType : '',
|
|
23
|
+
values: option.values?.map((val)=>{
|
|
24
|
+
const swatchValue = swatchOption && swatchOption?.optionValues?.find((swatOp)=>swatOp?.label === val?.label) || {
|
|
25
|
+
...initialSwatchOptionValue
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
...val,
|
|
29
|
+
colors: swatchValue?.colors || [],
|
|
30
|
+
imageUrl: swatchValue?.imageUrl || ''
|
|
31
|
+
};
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
});
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
export { useSwatchesOptions as default };
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
const OptionNormalStyle = [
|
|
2
|
-
|
|
1
|
+
const OptionNormalStyle = [
|
|
2
|
+
'radio_buttons',
|
|
3
|
+
'dropdown'
|
|
4
|
+
];
|
|
5
|
+
const OptionSpecialStyle = [
|
|
6
|
+
'color',
|
|
7
|
+
'image',
|
|
8
|
+
'rectangle_list'
|
|
9
|
+
];
|
|
3
10
|
|
|
4
11
|
export { OptionNormalStyle, OptionSpecialStyle };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -158,6 +158,7 @@ type Mapped$3<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
|
|
|
158
158
|
id: K;
|
|
159
159
|
label: string;
|
|
160
160
|
info?: string;
|
|
161
|
+
hiddenWithGemPages?: boolean;
|
|
161
162
|
hyperlinkInfo?: HyperlinkInfo;
|
|
162
163
|
hideOnMode?: {
|
|
163
164
|
responsive?: boolean;
|
|
@@ -189,6 +190,7 @@ type Mapped$3<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
|
|
|
189
190
|
id: K;
|
|
190
191
|
label: string;
|
|
191
192
|
info?: string;
|
|
193
|
+
hiddenWithGemPages?: boolean;
|
|
192
194
|
hyperlinkInfo?: HyperlinkInfo;
|
|
193
195
|
hideOnMode?: {
|
|
194
196
|
responsive?: boolean;
|
|
@@ -318,6 +320,7 @@ type GroupControlType<T> = {
|
|
|
318
320
|
label?: string;
|
|
319
321
|
info?: string;
|
|
320
322
|
popup?: boolean;
|
|
323
|
+
hiddenWithGemPages?: boolean;
|
|
321
324
|
controls?: ControlProp<T>[];
|
|
322
325
|
hide?: boolean;
|
|
323
326
|
hideOnMode?: {
|
|
@@ -755,7 +758,26 @@ type ComponentSetting<P extends BaseProps> = {
|
|
|
755
758
|
};
|
|
756
759
|
};
|
|
757
760
|
};
|
|
758
|
-
|
|
761
|
+
ui?: ControlUI[];
|
|
762
|
+
};
|
|
763
|
+
type ControlUI = {
|
|
764
|
+
type: 'group' | 'tab' | 'advanced' | 'control';
|
|
765
|
+
label?: Record<string, string>;
|
|
766
|
+
info?: Record<string, string>;
|
|
767
|
+
condition?: string;
|
|
768
|
+
controls?: ControlUI[];
|
|
769
|
+
setting?: {
|
|
770
|
+
id: string;
|
|
771
|
+
state?: StateType;
|
|
772
|
+
};
|
|
773
|
+
options?: {
|
|
774
|
+
label?: 'medium' | 'large';
|
|
775
|
+
hideOnDevices?: {
|
|
776
|
+
desktop?: boolean;
|
|
777
|
+
tablet?: boolean;
|
|
778
|
+
mobile?: boolean;
|
|
779
|
+
};
|
|
780
|
+
};
|
|
759
781
|
};
|
|
760
782
|
|
|
761
783
|
type Maybe<T> = T | undefined;
|
|
@@ -7511,4 +7533,4 @@ declare const fetchMedias: (fetcher: FetchFunc, { id, isSample }: FetchParams) =
|
|
|
7511
7533
|
|
|
7512
7534
|
declare const getProductBySlug: (fetcher: FetchFunc, slug?: string) => Promise<ProductSelectFragment>;
|
|
7513
7535
|
|
|
7514
|
-
export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, Border, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentSetting, ContainerProp, ControlProp, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, ExtractState, FetchFunc, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, InitComponentType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LooxReviewsWidgetType, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, OptionNormalStyle, OptionSpecialStyle, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, RenderMemo as Render, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RoundedSize, SectionData, SectionEntity, SectionProvider, SectionProviderProps, ShadowProps, ShadowStyle, ShadowStyleApplied, ShadowType, ShopProvider, ShopProviderProps, shop as ShopType, SizeProps, SizeSetting, SizeType, SpacingType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TypographyProps, TypographySetting, TypographyType, VariantSelectFragment, calculateFirstProduct, cls, composeRadius, composeSize, composeSpacing, fetchMedias, fetchVariants, flattenConnection, fpixel, genTypoClass, genVariable, getCollection, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, globalEvent, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, isBrowser, isColor, isDefined, isEmptyChildren, isLocalEnv, loadScript, makeAspectRatio, makeHeight, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, prefetchQueries, props, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useIsSampleProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useMoney, usePageType, usePluginEnable, usePrevious, useProduct, useProductList, useProductListProducts, useProductListSettings, useProductListStore, useProductListStyles, useProductProperties, useProductQuery, useProductStore, useProductsQuery, useQuantity, useRemoveCartItem, useSection, useSectionStore, useSelectedOption, useShopStore, useStoreFront, useSuspenseFetch, useSwatches, useSwatchesOptions, useUniqProductID, useUpdateCartItem, useVariant, useVariantOutStock, useVariants, validateEmail };
|
|
7536
|
+
export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, Border, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentSetting, ContainerProp, ControlProp, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, ExtractState, FetchFunc, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, InitComponentType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LooxReviewsWidgetType, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, OptionNormalStyle, OptionSpecialStyle, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, RenderMemo as Render, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RoundedSize, SectionData, SectionEntity, SectionProvider, SectionProviderProps, ShadowProps, ShadowStyle, ShadowStyleApplied, ShadowType, ShopProvider, ShopProviderProps, shop as ShopType, SizeProps, SizeSetting, SizeType, SpacingType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TypographyProps, TypographySetting, TypographyType, VariantSelectFragment, calculateFirstProduct, cls, composeRadius, composeSize, composeSpacing, fetchMedias, fetchVariants, flattenConnection, fpixel, genTypoClass, genVariable, getCollection, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, globalEvent, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, isBrowser, isColor, isDefined, isEmptyChildren, isLocalEnv, loadScript, makeAspectRatio, makeHeight, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, prefetchQueries, props, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useIsSampleProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useMoney, usePageType, usePluginEnable, usePrevious, useProduct, useProductList, useProductListProducts, useProductListSettings, useProductListStore, useProductListStyles, useProductProperties, useProductQuery, useProductStore, useProductsQuery, useQuantity, useRemoveCartItem, useSection, useSectionStore, useSelectedOption, useShopStore, useStoreFront, useSuspenseFetch, useSwatches, useSwatchesOptions, useUniqProductID, useUpdateCartItem, useVariant, useVariantOutStock, useVariants, validateEmail };
|