@gem-sdk/core 1.14.0-next.96 → 1.14.1
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 +18 -1
- package/dist/cjs/components/ComponentWrapper.js +28 -1
- package/dist/cjs/components/ComponentWrapperPreview.js +72 -1
- package/dist/cjs/components/Empty.js +7 -1
- package/dist/cjs/components/Render.js +65 -1
- package/dist/cjs/components/Render.liquid.js +158 -3
- package/dist/cjs/components/RenderBlock.js +54 -1
- package/dist/cjs/components/RenderPreview.js +66 -1
- package/dist/cjs/components/RenderSection.js +23 -1
- package/dist/cjs/components/constant.js +39 -1
- package/dist/cjs/contexts/AddonContext.js +36 -1
- package/dist/cjs/contexts/BuilderComponent.js +34 -1
- package/dist/cjs/contexts/BuilderContext.js +35 -1
- package/dist/cjs/contexts/BuilderPreviewContext.js +370 -1
- package/dist/cjs/contexts/CartLineContext.js +29 -1
- package/dist/cjs/contexts/CollectionContext.js +38 -1
- package/dist/cjs/contexts/ModalContext.js +47 -1
- package/dist/cjs/contexts/ProductContext.js +149 -1
- package/dist/cjs/contexts/ProductListContext.js +32 -1
- package/dist/cjs/contexts/SectionContext.js +53 -1
- package/dist/cjs/contexts/ShopContext.js +70 -1
- package/dist/cjs/graphql/fragments/analytic.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection.generated.js +6 -2
- package/dist/cjs/graphql/fragments/custom-code.generated.js +6 -2
- package/dist/cjs/graphql/fragments/data-seo.generated.js +6 -2
- package/dist/cjs/graphql/fragments/media.generated.js +6 -3
- package/dist/cjs/graphql/fragments/product-little.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +6 -2
- package/dist/cjs/graphql/fragments/selected-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/variant.generated.js +6 -2
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +7 -3
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +16 -2
- package/dist/cjs/graphql/queries/collection.generated.js +14 -2
- package/dist/cjs/graphql/queries/collections.generated.js +9 -2
- package/dist/cjs/graphql/queries/preview-page.generated.js +14 -2
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +11 -2
- package/dist/cjs/graphql/queries/product-medias.generated.js +8 -2
- package/dist/cjs/graphql/queries/product-variants.generated.js +10 -2
- package/dist/cjs/graphql/queries/products.generated.js +17 -3
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +14 -2
- package/dist/cjs/graphql/queries/store-property.generated.js +6 -2
- package/dist/cjs/helpers/GlobalEvent.js +19 -1
- package/dist/cjs/helpers/background.js +109 -1
- package/dist/cjs/helpers/borders.js +183 -4
- package/dist/cjs/helpers/clone-deep.js +5 -1
- package/dist/cjs/helpers/cls.js +16 -1
- package/dist/cjs/helpers/colors.js +183 -1
- package/dist/cjs/helpers/compose-advance-style.js +188 -1
- package/dist/cjs/helpers/constant.js +23 -1
- package/dist/cjs/helpers/convert.js +7 -1
- package/dist/cjs/helpers/css-variable.js +7 -1
- package/dist/cjs/helpers/email.js +11 -1
- package/dist/cjs/helpers/flatten-connection.js +9 -1
- package/dist/cjs/helpers/get-resonsive-value.js +31 -1
- package/dist/cjs/helpers/get-shortname.js +92 -1
- package/dist/cjs/helpers/is-browser.js +9 -1
- package/dist/cjs/helpers/is-defined.js +7 -1
- package/dist/cjs/helpers/is-empty-children.js +12 -1
- package/dist/cjs/helpers/is-safari.js +9 -1
- package/dist/cjs/helpers/layout.js +59 -1
- package/dist/cjs/helpers/load-script.js +31 -1
- package/dist/cjs/helpers/make-style.js +128 -1
- package/dist/cjs/helpers/normalize-builder-data.js +23 -1
- package/dist/cjs/helpers/prefetch-queries.js +78 -1
- package/dist/cjs/helpers/product.js +45 -1
- package/dist/cjs/helpers/queries/get-collection.js +220 -1
- package/dist/cjs/helpers/queries/get-collections.js +21 -1
- package/dist/cjs/helpers/queries/get-product-by-slug.js +125 -1
- package/dist/cjs/helpers/queries/get-product.js +154 -1
- package/dist/cjs/helpers/queries/get-products.js +161 -1
- package/dist/cjs/helpers/query.js +29 -1
- package/dist/cjs/helpers/radius.js +131 -6
- package/dist/cjs/helpers/render.js +71 -1
- package/dist/cjs/helpers/shadow.js +56 -1
- package/dist/cjs/helpers/size.js +35 -4
- package/dist/cjs/helpers/spacing.js +43 -1
- package/dist/cjs/helpers/tracking/fpixel.js +28 -1
- package/dist/cjs/helpers/tracking/gtag.js +93 -1
- package/dist/cjs/helpers/tracking/tiktokpixel.js +17 -1
- package/dist/cjs/helpers/typography.js +105 -17
- package/dist/cjs/helpers/variant.js +8 -1
- package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-data.js +28 -1
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -1
- package/dist/cjs/hooks/cart/use-create-cart.js +22 -1
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -1
- package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -1
- package/dist/cjs/hooks/shop/use-collection-query.js +22 -1
- package/dist/cjs/hooks/shop/use-collections-query.js +17 -1
- package/dist/cjs/hooks/shop/use-product-query.js +22 -1
- package/dist/cjs/hooks/shop/use-products-query.js +22 -1
- package/dist/cjs/hooks/shop.js +126 -1
- package/dist/cjs/hooks/use-current-device.js +21 -1
- package/dist/cjs/hooks/use-lazy-video.js +15 -1
- package/dist/cjs/hooks/useCartId.js +44 -1
- package/dist/cjs/hooks/useCartLine.js +11 -1
- package/dist/cjs/hooks/useCartUI.js +48 -1
- package/dist/cjs/hooks/useCollection.js +9 -1
- package/dist/cjs/hooks/useFetchHandle.js +13 -1
- package/dist/cjs/hooks/useFormatMoney.js +58 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -1
- package/dist/cjs/hooks/useLoadScript.js +32 -1
- package/dist/cjs/hooks/useMoney.js +84 -1
- package/dist/cjs/hooks/usePrevious.js +19 -1
- package/dist/cjs/hooks/useProduct.js +124 -1
- package/dist/cjs/hooks/useProductList.js +21 -1
- package/dist/cjs/hooks/useSuspenseFetch.js +27 -1
- package/dist/cjs/hooks/useSwatchesOptions.js +41 -1
- package/dist/cjs/index.js +291 -1
- package/dist/cjs/types/global-style.js +14 -1
- package/dist/cjs/types/shop.js +2 -1
- package/dist/esm/components/AddOn.js +14 -1
- package/dist/esm/components/ComponentWrapper.js +24 -1
- package/dist/esm/components/ComponentWrapperPreview.js +68 -1
- package/dist/esm/components/Empty.js +3 -1
- package/dist/esm/components/Render.js +61 -1
- package/dist/esm/components/Render.liquid.js +153 -3
- package/dist/esm/components/RenderBlock.js +50 -1
- package/dist/esm/components/RenderPreview.js +62 -1
- package/dist/esm/components/RenderSection.js +19 -1
- package/dist/esm/components/constant.js +37 -1
- package/dist/esm/contexts/AddonContext.js +32 -1
- package/dist/esm/contexts/BuilderComponent.js +31 -1
- package/dist/esm/contexts/BuilderContext.js +32 -1
- package/dist/esm/contexts/BuilderPreviewContext.js +367 -1
- package/dist/esm/contexts/CartLineContext.js +26 -1
- package/dist/esm/contexts/CollectionContext.js +35 -1
- package/dist/esm/contexts/ModalContext.js +44 -1
- package/dist/esm/contexts/ProductContext.js +146 -1
- package/dist/esm/contexts/ProductListContext.js +28 -1
- package/dist/esm/contexts/SectionContext.js +49 -1
- package/dist/esm/contexts/ShopContext.js +67 -1
- package/dist/esm/graphql/fragments/analytic.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-detail.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-product.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection.generated.js +4 -2
- package/dist/esm/graphql/fragments/custom-code.generated.js +4 -2
- package/dist/esm/graphql/fragments/data-seo.generated.js +4 -2
- package/dist/esm/graphql/fragments/media.generated.js +4 -3
- package/dist/esm/graphql/fragments/product-little.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option-value.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/product.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-page-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +4 -2
- package/dist/esm/graphql/fragments/selected-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/variant.generated.js +4 -2
- package/dist/esm/graphql/mutations/page-view-up.generated.js +5 -3
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +22 -10
- package/dist/esm/graphql/queries/collection.generated.js +18 -8
- package/dist/esm/graphql/queries/collections.generated.js +8 -3
- package/dist/esm/graphql/queries/preview-page.generated.js +18 -8
- package/dist/esm/graphql/queries/product-little-detail.generated.js +12 -5
- package/dist/esm/graphql/queries/product-medias.generated.js +6 -2
- package/dist/esm/graphql/queries/product-variants.generated.js +10 -4
- package/dist/esm/graphql/queries/products.generated.js +20 -9
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +18 -8
- package/dist/esm/graphql/queries/store-property.generated.js +4 -2
- package/dist/esm/helpers/GlobalEvent.js +15 -1
- package/dist/esm/helpers/background.js +106 -1
- package/dist/esm/helpers/borders.js +175 -4
- package/dist/esm/helpers/clone-deep.js +3 -1
- package/dist/esm/helpers/cls.js +14 -1
- package/dist/esm/helpers/colors.js +168 -1
- package/dist/esm/helpers/compose-advance-style.js +185 -1
- package/dist/esm/helpers/constant.js +19 -1
- package/dist/esm/helpers/convert.js +4 -1
- package/dist/esm/helpers/css-variable.js +5 -1
- package/dist/esm/helpers/email.js +6 -1
- package/dist/esm/helpers/flatten-connection.js +7 -1
- package/dist/esm/helpers/get-resonsive-value.js +27 -1
- package/dist/esm/helpers/get-shortname.js +90 -1
- package/dist/esm/helpers/is-browser.js +5 -1
- package/dist/esm/helpers/is-defined.js +5 -1
- package/dist/esm/helpers/is-empty-children.js +7 -1
- package/dist/esm/helpers/is-safari.js +5 -1
- package/dist/esm/helpers/layout.js +54 -1
- package/dist/esm/helpers/load-script.js +29 -1
- package/dist/esm/helpers/make-style.js +117 -1
- package/dist/esm/helpers/normalize-builder-data.js +21 -1
- package/dist/esm/helpers/prefetch-queries.js +76 -1
- package/dist/esm/helpers/product.js +41 -1
- package/dist/esm/helpers/queries/get-collection.js +217 -1
- package/dist/esm/helpers/queries/get-collections.js +19 -1
- package/dist/esm/helpers/queries/get-product-by-slug.js +123 -1
- package/dist/esm/helpers/queries/get-product.js +150 -1
- package/dist/esm/helpers/queries/get-products.js +159 -1
- package/dist/esm/helpers/query.js +25 -1
- package/dist/esm/helpers/radius.js +124 -6
- package/dist/esm/helpers/render.js +64 -1
- package/dist/esm/helpers/shadow.js +51 -1
- package/dist/esm/helpers/size.js +31 -4
- package/dist/esm/helpers/spacing.js +40 -1
- package/dist/esm/helpers/tracking/fpixel.js +24 -1
- package/dist/esm/helpers/tracking/gtag.js +87 -1
- package/dist/esm/helpers/tracking/tiktokpixel.js +15 -1
- package/dist/esm/helpers/typography.js +96 -17
- package/dist/esm/helpers/variant.js +6 -1
- package/dist/esm/hooks/cart/use-add-to-cart.js +18 -1
- package/dist/esm/hooks/cart/use-cart-data.js +26 -1
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -1
- package/dist/esm/hooks/cart/use-cart-note-update.js +18 -1
- package/dist/esm/hooks/cart/use-create-cart.js +20 -1
- package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -1
- package/dist/esm/hooks/cart/use-update-cart-item.js +18 -1
- package/dist/esm/hooks/shop/use-collection-query.js +20 -1
- package/dist/esm/hooks/shop/use-collections-query.js +15 -1
- package/dist/esm/hooks/shop/use-product-query.js +20 -1
- package/dist/esm/hooks/shop/use-products-query.js +20 -1
- package/dist/esm/hooks/shop.js +111 -1
- package/dist/esm/hooks/use-current-device.js +19 -1
- package/dist/esm/hooks/use-lazy-video.js +13 -1
- package/dist/esm/hooks/useCartId.js +40 -1
- package/dist/esm/hooks/useCartLine.js +7 -1
- package/dist/esm/hooks/useCartUI.js +44 -1
- package/dist/esm/hooks/useCollection.js +7 -1
- package/dist/esm/hooks/useFetchHandle.js +11 -1
- package/dist/esm/hooks/useFormatMoney.js +56 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -1
- package/dist/esm/hooks/useLoadScript.js +28 -1
- package/dist/esm/hooks/useMoney.js +80 -1
- package/dist/esm/hooks/usePrevious.js +17 -1
- package/dist/esm/hooks/useProduct.js +111 -1
- package/dist/esm/hooks/useProductList.js +16 -1
- package/dist/esm/hooks/useSuspenseFetch.js +23 -1
- package/dist/esm/hooks/useSwatchesOptions.js +37 -1
- package/dist/esm/index.js +92 -1
- package/dist/esm/types/global-style.js +11 -1
- package/dist/types/index.d.ts +26 -26
- package/package.json +2 -2
|
@@ -1 +1,149 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var zustand = require('zustand');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var flattenConnection = require('../helpers/flatten-connection.js');
|
|
7
|
+
var variant = require('../helpers/variant.js');
|
|
8
|
+
|
|
9
|
+
// const { Provider, useStore } = createContext<StoreApi<ProductContextProps>>();
|
|
10
|
+
const ProductContext = /*#__PURE__*/ react.createContext(null);
|
|
11
|
+
const createProductStoreProvider = (data)=>zustand.createStore((set, get)=>({
|
|
12
|
+
...data,
|
|
13
|
+
updateProperty: (name, data)=>{
|
|
14
|
+
set((state)=>{
|
|
15
|
+
return {
|
|
16
|
+
properties: state.properties?.map((v)=>{
|
|
17
|
+
if (v.key === name) {
|
|
18
|
+
return {
|
|
19
|
+
...v,
|
|
20
|
+
...data
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return v;
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
addProperty: (data)=>{
|
|
29
|
+
const properties = get().properties;
|
|
30
|
+
if (!properties?.some((v)=>v.key === data.key)) {
|
|
31
|
+
set((state)=>({
|
|
32
|
+
properties: [
|
|
33
|
+
...state.properties ?? [],
|
|
34
|
+
data
|
|
35
|
+
]
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
removeProperty: (name)=>{
|
|
40
|
+
set((state)=>({
|
|
41
|
+
properties: state.properties?.filter((v)=>v.key !== name)
|
|
42
|
+
}));
|
|
43
|
+
},
|
|
44
|
+
setQuantity: (num)=>{
|
|
45
|
+
set({
|
|
46
|
+
quantity: num > 0 ? num : 1
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
setProductFeaturedImage: (image)=>{
|
|
50
|
+
set({
|
|
51
|
+
featuredImageGlobal: image
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
incrementQuantity: ()=>{
|
|
55
|
+
set((state)=>{
|
|
56
|
+
const quantity = state.quantity ?? 1;
|
|
57
|
+
return {
|
|
58
|
+
quantity: quantity + 1
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
decrementQuantity: ()=>{
|
|
63
|
+
set((state)=>{
|
|
64
|
+
const quantity = state.quantity ?? 1;
|
|
65
|
+
return {
|
|
66
|
+
quantity: quantity > 2 ? quantity - 1 : 1
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
setSelectedOption: (optionId, optionValue)=>{
|
|
71
|
+
set((state)=>{
|
|
72
|
+
if (optionId && optionValue) {
|
|
73
|
+
return {
|
|
74
|
+
selectedOptions: {
|
|
75
|
+
...state?.selectedOptions,
|
|
76
|
+
[optionId]: optionValue
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return state;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
forceSelectedOption: (value)=>{
|
|
84
|
+
set((state)=>{
|
|
85
|
+
return {
|
|
86
|
+
selectedOptions: {
|
|
87
|
+
...state?.selectedOptions,
|
|
88
|
+
...value
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
updateIsSubmit: (value)=>{
|
|
94
|
+
set({
|
|
95
|
+
isSubmit: value
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
const ProductProvider = ({ children, product, initialVariantId, quantity = 1 })=>{
|
|
100
|
+
const uiqueId = react.useId();
|
|
101
|
+
const store = react.useMemo(()=>{
|
|
102
|
+
let selectedOptions = {};
|
|
103
|
+
let featuredImageGlobal = undefined;
|
|
104
|
+
if (product) {
|
|
105
|
+
const variants = flattenConnection.flattenConnection(product.variants);
|
|
106
|
+
const firstVariant = variants[0];
|
|
107
|
+
const firstVariantInStock = variants.find((item)=>variant.checkInStock(item));
|
|
108
|
+
const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariantInStock ?? firstVariant;
|
|
109
|
+
selectedOptions = initialVariant?.selectedOptions.reduce((acc, option)=>{
|
|
110
|
+
if (option.name) {
|
|
111
|
+
return {
|
|
112
|
+
...acc,
|
|
113
|
+
[option.name]: option.value
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return acc;
|
|
117
|
+
}, {});
|
|
118
|
+
featuredImageGlobal = product.medias?.edges.find((v)=>v.node?.id === initialVariant?.mediaId)?.node ?? product.featuredImage;
|
|
119
|
+
}
|
|
120
|
+
return createProductStoreProvider({
|
|
121
|
+
product,
|
|
122
|
+
quantity,
|
|
123
|
+
selectedOptions,
|
|
124
|
+
uiqueId,
|
|
125
|
+
featuredImageGlobal
|
|
126
|
+
});
|
|
127
|
+
}, [
|
|
128
|
+
initialVariantId,
|
|
129
|
+
product,
|
|
130
|
+
quantity,
|
|
131
|
+
uiqueId
|
|
132
|
+
]);
|
|
133
|
+
return /*#__PURE__*/ jsxRuntime.jsx(ProductContext.Provider, {
|
|
134
|
+
value: store,
|
|
135
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
136
|
+
children: children
|
|
137
|
+
})
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const useProductStore = (selector, equalityFn)=>{
|
|
141
|
+
const store = react.useContext(ProductContext);
|
|
142
|
+
if (!store) {
|
|
143
|
+
throw new Error('Element of product must be used inside a Product');
|
|
144
|
+
}
|
|
145
|
+
return zustand.useStore(store, selector, equalityFn);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
exports.ProductProvider = ProductProvider;
|
|
149
|
+
exports.useProductStore = useProductStore;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var zustand = require('zustand');
|
|
6
|
+
|
|
7
|
+
const ProductListContext = /*#__PURE__*/ react.createContext(null);
|
|
8
|
+
const createProductListProvider = (data)=>zustand.createStore(()=>({
|
|
9
|
+
...data
|
|
10
|
+
}));
|
|
11
|
+
const ProductListProvider = ({ children, collection, products, settings, styles })=>{
|
|
12
|
+
return /*#__PURE__*/ jsxRuntime.jsx(ProductListContext.Provider, {
|
|
13
|
+
value: createProductListProvider({
|
|
14
|
+
products,
|
|
15
|
+
collection,
|
|
16
|
+
settings,
|
|
17
|
+
styles
|
|
18
|
+
}),
|
|
19
|
+
children: children
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const useProductListStore = (selector, equalityFn)=>{
|
|
23
|
+
const store = react.useContext(ProductListContext);
|
|
24
|
+
if (!store) {
|
|
25
|
+
throw new Error('useProductListStore must be used within a useProductListStore');
|
|
26
|
+
}
|
|
27
|
+
return zustand.useStore(store, selector, equalityFn);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.ProductListContext = ProductListContext;
|
|
31
|
+
exports.ProductListProvider = ProductListProvider;
|
|
32
|
+
exports.useProductListStore = useProductListStore;
|
|
@@ -1 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var zustand = require('zustand');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var cloneDeep = require('../helpers/clone-deep.js');
|
|
7
|
+
var normalizeBuilderData = require('../helpers/normalize-builder-data.js');
|
|
8
|
+
|
|
9
|
+
const SectionContext = /*#__PURE__*/ react.createContext(null);
|
|
10
|
+
const createSectionProvider = (data)=>zustand.createStore((set, get)=>({
|
|
11
|
+
data: data ?? {},
|
|
12
|
+
getSection: (id)=>{
|
|
13
|
+
const section = get().data[id];
|
|
14
|
+
return section ?? undefined;
|
|
15
|
+
},
|
|
16
|
+
addSection: (id, data)=>{
|
|
17
|
+
const item = normalizeBuilderData.normalizeBuilderData(data);
|
|
18
|
+
set((prev)=>({
|
|
19
|
+
data: {
|
|
20
|
+
...prev.data,
|
|
21
|
+
[id]: cloneDeep.cloneDeep(item)
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
},
|
|
25
|
+
removeSection: (id)=>{
|
|
26
|
+
set((prev)=>{
|
|
27
|
+
const { [id]: _, ...rest } = prev.data;
|
|
28
|
+
return {
|
|
29
|
+
data: rest
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
const SectionProvider = ({ children, data, ...passProps })=>{
|
|
35
|
+
return /*#__PURE__*/ jsxRuntime.jsx(SectionContext.Provider, {
|
|
36
|
+
...passProps,
|
|
37
|
+
value: createSectionProvider(data),
|
|
38
|
+
children: children
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
// export const useSectionStore = useStore;
|
|
42
|
+
const useSectionStore = (selector, equalityFn)=>{
|
|
43
|
+
const store = react.useContext(SectionContext);
|
|
44
|
+
if (!store) {
|
|
45
|
+
throw new Error('useSectionStore must be used within a SectionProvider');
|
|
46
|
+
}
|
|
47
|
+
return zustand.useStore(store, selector, equalityFn);
|
|
48
|
+
};
|
|
49
|
+
const useSection = (id)=>useSectionStore((s)=>s.getSection(id));
|
|
50
|
+
|
|
51
|
+
exports.SectionProvider = SectionProvider;
|
|
52
|
+
exports.useSection = useSection;
|
|
53
|
+
exports.useSectionStore = useSectionStore;
|
|
@@ -1 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var zustand = require('zustand');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var AddonContext = require('./AddonContext.js');
|
|
8
|
+
var ModalContext = require('./ModalContext.js');
|
|
9
|
+
|
|
10
|
+
const ShopContext = /*#__PURE__*/ react.createContext(null);
|
|
11
|
+
const createShopStoreProvider = (data)=>zustand.createStore((set)=>({
|
|
12
|
+
mobileOnly: false,
|
|
13
|
+
isStorefront: true,
|
|
14
|
+
...data,
|
|
15
|
+
changeLocale: (locale)=>{
|
|
16
|
+
set({
|
|
17
|
+
locale
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
changeCurrency: (currency)=>{
|
|
21
|
+
set({
|
|
22
|
+
currency
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
changeSwatches: (swatches)=>{
|
|
26
|
+
set({
|
|
27
|
+
swatches
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
changeLayoutSettings: (layoutSettings)=>{
|
|
31
|
+
set({
|
|
32
|
+
layoutSettings
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
changeStorefrontInfo: ({ url, token })=>{
|
|
36
|
+
set({
|
|
37
|
+
storefrontUrl: url,
|
|
38
|
+
storefrontToken: token
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
const ShopProvider = ({ children, addons, storeOption, queryOption, ...passProps })=>{
|
|
43
|
+
const store = react.useMemo(()=>createShopStoreProvider(storeOption), [
|
|
44
|
+
storeOption
|
|
45
|
+
]);
|
|
46
|
+
return /*#__PURE__*/ jsxRuntime.jsx(AddonContext.AddonProvider, {
|
|
47
|
+
components: addons,
|
|
48
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(useSWR.SWRConfig, {
|
|
49
|
+
value: queryOption,
|
|
50
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(ShopContext.Provider, {
|
|
51
|
+
...passProps,
|
|
52
|
+
value: store,
|
|
53
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(ModalContext.ModalProvider, {
|
|
54
|
+
children: children
|
|
55
|
+
})
|
|
56
|
+
}, JSON.stringify(storeOption))
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
// export const useShopStore = useStore;
|
|
61
|
+
const useShopStore = (selector, equalityFn)=>{
|
|
62
|
+
const store = react.useContext(ShopContext);
|
|
63
|
+
if (!store) {
|
|
64
|
+
throw new Error('useShopStore must be used within a ShopProvider');
|
|
65
|
+
}
|
|
66
|
+
return zustand.useStore(store, selector, equalityFn);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.ShopProvider = ShopProvider;
|
|
70
|
+
exports.useShopStore = useShopStore;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const AnalyticSelect = `
|
|
2
4
|
fragment AnalyticSelect on Analytic {
|
|
3
5
|
fbPixelID
|
|
4
6
|
gaTrackingID
|
|
5
7
|
tiktokPixelID
|
|
6
8
|
}
|
|
7
|
-
`;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports.AnalyticSelect = AnalyticSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const CollectionDetailSelect = `
|
|
2
4
|
fragment CollectionDetailSelect on Collection {
|
|
3
5
|
id
|
|
4
6
|
createdAt
|
|
@@ -20,4 +22,6 @@
|
|
|
20
22
|
isStorefront
|
|
21
23
|
isSample
|
|
22
24
|
}
|
|
23
|
-
`;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports.CollectionDetailSelect = CollectionDetailSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const CollectionProductSelect = `
|
|
2
4
|
fragment CollectionProductSelect on Collection {
|
|
3
5
|
...CollectionDetailSelect
|
|
4
6
|
products(
|
|
@@ -19,4 +21,6 @@
|
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
`;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
exports.CollectionProductSelect = CollectionProductSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const CollectionSelect = `
|
|
2
4
|
fragment CollectionSelect on Collection {
|
|
3
5
|
...CollectionDetailSelect
|
|
4
6
|
products {
|
|
@@ -17,4 +19,6 @@
|
|
|
17
19
|
totalCount
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
|
-
`;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
exports.CollectionSelect = CollectionSelect;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const CustomCodeSelect = `
|
|
2
4
|
fragment CustomCodeSelect on CustomCode {
|
|
3
5
|
body
|
|
4
6
|
header
|
|
5
7
|
}
|
|
6
|
-
`;
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
exports.CustomCodeSelect = CustomCodeSelect;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const MediaSelect = `
|
|
2
4
|
fragment MediaSelect on Media {
|
|
3
5
|
id
|
|
4
6
|
contentType
|
|
5
|
-
previewImage
|
|
6
7
|
src
|
|
7
8
|
width
|
|
8
9
|
height
|
|
9
10
|
alt
|
|
10
11
|
}
|
|
11
|
-
`;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
exports.MediaSelect = MediaSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const ProductLittleSelect = `
|
|
2
4
|
fragment ProductLittleSelect on Product {
|
|
3
5
|
id
|
|
4
6
|
title
|
|
@@ -18,4 +20,6 @@
|
|
|
18
20
|
...MediaSelect
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
|
-
`;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
exports.ProductLittleSelect = ProductLittleSelect;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const ProductOptionValueSelect = `
|
|
2
4
|
fragment ProductOptionValueSelect on ProductOptionValue {
|
|
3
5
|
id
|
|
4
6
|
label
|
|
5
7
|
isDefault
|
|
6
8
|
baseID
|
|
7
9
|
}
|
|
8
|
-
`;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports.ProductOptionValueSelect = ProductOptionValueSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const ProductOptionSelect = `
|
|
2
4
|
fragment ProductOptionSelect on ProductOption {
|
|
3
5
|
id
|
|
4
6
|
name
|
|
@@ -7,4 +9,6 @@
|
|
|
7
9
|
...ProductOptionValueSelect
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
|
-
`;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
exports.ProductOptionSelect = ProductOptionSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const ProductSelect = `
|
|
2
4
|
fragment ProductSelect on Product {
|
|
3
5
|
...ProductLittleSelect
|
|
4
6
|
medias(first: $firstMedia, after: $afterMedia, orderBy: $orderByMedia) {
|
|
@@ -26,4 +28,6 @@
|
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
`;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports.ProductSelect = ProductSelect;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const PublishedCustomSectionSelect = `
|
|
2
4
|
fragment PublishedCustomSectionSelect on PublishedCustomSection {
|
|
3
5
|
cid
|
|
4
6
|
component
|
|
5
7
|
id
|
|
6
8
|
type
|
|
7
9
|
}
|
|
8
|
-
`;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports.PublishedCustomSectionSelect = PublishedCustomSectionSelect;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const PublishedPageSectionSelect = `
|
|
2
4
|
fragment PublishedPageSectionSelect on PublishedPageSection {
|
|
3
5
|
cid
|
|
4
6
|
component
|
|
5
7
|
id
|
|
6
8
|
}
|
|
7
|
-
`;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports.PublishedPageSectionSelect = PublishedPageSectionSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const PublishedThemePageSelect = `
|
|
2
4
|
fragment PublishedThemePageSelect on PublishedThemePage {
|
|
3
5
|
id
|
|
4
6
|
name
|
|
@@ -24,4 +26,6 @@
|
|
|
24
26
|
...CustomCodeSelect
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
|
-
`;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
exports.PublishedThemePageSelect = PublishedThemePageSelect;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const PublishedThemeStyleSelect = `
|
|
2
4
|
fragment PublishedThemeStyleSelect on PublishedThemeStyle {
|
|
3
5
|
id
|
|
4
6
|
data
|
|
5
7
|
name
|
|
6
8
|
}
|
|
7
|
-
`;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports.PublishedThemeStyleSelect = PublishedThemeStyleSelect;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const SelectedOptionSelect = `
|
|
2
4
|
fragment SelectedOptionSelect on SelectedOption {
|
|
3
5
|
name
|
|
4
6
|
value
|
|
5
7
|
optionType
|
|
6
8
|
}
|
|
7
|
-
`;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports.SelectedOptionSelect = SelectedOptionSelect;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const VariantSelect = `
|
|
2
4
|
fragment VariantSelect on ProductVariant {
|
|
3
5
|
id
|
|
4
6
|
title
|
|
@@ -28,4 +30,6 @@
|
|
|
28
30
|
...MediaSelect
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
`;
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports.VariantSelect = VariantSelect;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */ const PageViewUpDocument = `
|
|
4
|
+
mutation pageViewUp($pageHandle: String!, $userAgent: String!) {
|
|
3
5
|
pageViewUp(pageHandle: $pageHandle, userAgent: $userAgent)
|
|
4
6
|
}
|
|
5
|
-
`;
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports.PageViewUpDocument = PageViewUpDocument;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var collectionProduct_generated = require('../fragments/collection-product.generated.js');
|
|
4
|
+
var collectionDetail_generated = require('../fragments/collection-detail.generated.js');
|
|
5
|
+
var product_generated = require('../fragments/product.generated.js');
|
|
6
|
+
var productLittle_generated = require('../fragments/product-little.generated.js');
|
|
7
|
+
var productOption_generated = require('../fragments/product-option.generated.js');
|
|
8
|
+
var productOptionValue_generated = require('../fragments/product-option-value.generated.js');
|
|
9
|
+
var media_generated = require('../fragments/media.generated.js');
|
|
10
|
+
var variant_generated = require('../fragments/variant.generated.js');
|
|
11
|
+
var selectedOption_generated = require('../fragments/selected-option.generated.js');
|
|
12
|
+
|
|
13
|
+
const CollectionDetailFilterDocument = `
|
|
2
14
|
query collectionDetailFilter($firstProduct: Int = 10, $orderBy: CollectionOrder, $where: CollectionWhereInput, $orderByProduct: ProductOrder, $productsAfter: Cursor, $firstVariant: Int, $afterVariant: Cursor, $afterMedia: Cursor, $firstMedia: Int, $orderByMedia: MediaOrder, $whereProduct: ProductWhereInput) {
|
|
3
15
|
collections(first: 1, orderBy: $orderBy, where: $where) {
|
|
4
16
|
edges {
|
|
@@ -17,4 +29,6 @@ ${productOption_generated.ProductOptionSelect}
|
|
|
17
29
|
${productOptionValue_generated.ProductOptionValueSelect}
|
|
18
30
|
${media_generated.MediaSelect}
|
|
19
31
|
${variant_generated.VariantSelect}
|
|
20
|
-
${selectedOption_generated.SelectedOptionSelect}`;
|
|
32
|
+
${selectedOption_generated.SelectedOptionSelect}`;
|
|
33
|
+
|
|
34
|
+
exports.CollectionDetailFilterDocument = CollectionDetailFilterDocument;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var product_generated = require('../fragments/product.generated.js');
|
|
4
|
+
var productLittle_generated = require('../fragments/product-little.generated.js');
|
|
5
|
+
var productOption_generated = require('../fragments/product-option.generated.js');
|
|
6
|
+
var productOptionValue_generated = require('../fragments/product-option-value.generated.js');
|
|
7
|
+
var media_generated = require('../fragments/media.generated.js');
|
|
8
|
+
var variant_generated = require('../fragments/variant.generated.js');
|
|
9
|
+
var selectedOption_generated = require('../fragments/selected-option.generated.js');
|
|
10
|
+
|
|
11
|
+
const CollectionDocument = `
|
|
2
12
|
query collection($first: Int = 5, $firstMedia: Int = 20, $orderByMedia: MediaOrder, $afterMedia: Cursor, $firstVariant: Int = 20, $afterVariant: Cursor, $handle: String, $id: ID) {
|
|
3
13
|
collection(handle: $handle, id: $id) {
|
|
4
14
|
baseID
|
|
@@ -37,4 +47,6 @@ ${productOption_generated.ProductOptionSelect}
|
|
|
37
47
|
${productOptionValue_generated.ProductOptionValueSelect}
|
|
38
48
|
${media_generated.MediaSelect}
|
|
39
49
|
${variant_generated.VariantSelect}
|
|
40
|
-
${selectedOption_generated.SelectedOptionSelect}`;
|
|
50
|
+
${selectedOption_generated.SelectedOptionSelect}`;
|
|
51
|
+
|
|
52
|
+
exports.CollectionDocument = CollectionDocument;
|