@gem-sdk/core 1.0.0
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 -0
- package/dist/cjs/components/ComponentWrapper.js +45 -0
- package/dist/cjs/components/ComponentWrapperPreview.js +58 -0
- package/dist/cjs/components/Empty.js +7 -0
- package/dist/cjs/components/Render.js +28 -0
- package/dist/cjs/components/RenderBlock.js +21 -0
- package/dist/cjs/components/RenderPreview.js +28 -0
- package/dist/cjs/components/RenderSection.js +19 -0
- package/dist/cjs/contexts/AddonContext.js +25 -0
- package/dist/cjs/contexts/BuilderComponent.js +30 -0
- package/dist/cjs/contexts/BuilderContext.js +29 -0
- package/dist/cjs/contexts/BuilderPreviewContext.js +353 -0
- package/dist/cjs/contexts/CartLineContext.js +24 -0
- package/dist/cjs/contexts/CollectionContext.js +24 -0
- package/dist/cjs/contexts/ProductContext.js +126 -0
- package/dist/cjs/contexts/ProductListContext.js +24 -0
- package/dist/cjs/contexts/SectionContext.js +49 -0
- package/dist/cjs/contexts/ShopContext.js +43 -0
- package/dist/cjs/graphql/fragments/analytic.generated.js +11 -0
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +13 -0
- package/dist/cjs/graphql/fragments/collection-product.generated.js +26 -0
- package/dist/cjs/graphql/fragments/data-seo.generated.js +11 -0
- package/dist/cjs/graphql/fragments/media.generated.js +14 -0
- package/dist/cjs/graphql/fragments/product-little.generated.js +25 -0
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +13 -0
- package/dist/cjs/graphql/fragments/product-option.generated.js +14 -0
- package/dist/cjs/graphql/fragments/product.generated.js +33 -0
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +12 -0
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +11 -0
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +27 -0
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +11 -0
- package/dist/cjs/graphql/fragments/selected-option.generated.js +11 -0
- package/dist/cjs/graphql/fragments/variant.generated.js +35 -0
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +34 -0
- package/dist/cjs/graphql/queries/collection.generated.js +52 -0
- package/dist/cjs/graphql/queries/preview-page.generated.js +23 -0
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +24 -0
- package/dist/cjs/graphql/queries/product-medias.generated.js +29 -0
- package/dist/cjs/graphql/queries/product-variants.generated.js +33 -0
- package/dist/cjs/graphql/queries/products.generated.js +41 -0
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +23 -0
- package/dist/cjs/graphql/queries/storeProperty.generated.js +12 -0
- package/dist/cjs/helpers/GlobalEvent.js +17 -0
- package/dist/cjs/helpers/background.js +104 -0
- package/dist/cjs/helpers/borders.js +138 -0
- package/dist/cjs/helpers/clone-deep.js +5 -0
- package/dist/cjs/helpers/cls.js +20 -0
- package/dist/cjs/helpers/colors.js +157 -0
- package/dist/cjs/helpers/compose-advance-style.js +132 -0
- package/dist/cjs/helpers/constant.js +17 -0
- package/dist/cjs/helpers/css-variable.js +7 -0
- package/dist/cjs/helpers/email.js +11 -0
- package/dist/cjs/helpers/flatten-connection.js +10 -0
- package/dist/cjs/helpers/fpixel.js +29 -0
- package/dist/cjs/helpers/get-resonsive-value.js +32 -0
- package/dist/cjs/helpers/get-shortname.js +92 -0
- package/dist/cjs/helpers/gtag.js +48 -0
- package/dist/cjs/helpers/is-browser.js +9 -0
- package/dist/cjs/helpers/is-defined.js +7 -0
- package/dist/cjs/helpers/is-empty-children.js +12 -0
- package/dist/cjs/helpers/layout.js +17 -0
- package/dist/cjs/helpers/load-script.js +32 -0
- package/dist/cjs/helpers/make-style.js +99 -0
- package/dist/cjs/helpers/normalize-builder-data.js +17 -0
- package/dist/cjs/helpers/prefetch-queries.js +68 -0
- package/dist/cjs/helpers/product.js +35 -0
- package/dist/cjs/helpers/queries/get-collection.js +173 -0
- package/dist/cjs/helpers/queries/get-product-by-slug.js +99 -0
- package/dist/cjs/helpers/queries/get-product.js +113 -0
- package/dist/cjs/helpers/queries/get-products.js +135 -0
- package/dist/cjs/helpers/radius.js +91 -0
- package/dist/cjs/helpers/shadow.js +48 -0
- package/dist/cjs/helpers/size.js +20 -0
- package/dist/cjs/helpers/spacing.js +45 -0
- package/dist/cjs/helpers/tiktokpixel.js +17 -0
- package/dist/cjs/helpers/typography.js +7 -0
- package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -0
- package/dist/cjs/hooks/cart/use-cart-data.js +26 -0
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -0
- package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -0
- package/dist/cjs/hooks/cart/use-create-cart.js +22 -0
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -0
- package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -0
- package/dist/cjs/hooks/shop/use-collection-query.js +16 -0
- package/dist/cjs/hooks/shop/use-product-query.js +16 -0
- package/dist/cjs/hooks/shop/use-products-query.js +16 -0
- package/dist/cjs/hooks/shop.js +80 -0
- package/dist/cjs/hooks/use-current-device.js +23 -0
- package/dist/cjs/hooks/use-lazy-video.js +15 -0
- package/dist/cjs/hooks/useCartId.js +36 -0
- package/dist/cjs/hooks/useCartLine.js +11 -0
- package/dist/cjs/hooks/useCartUI.js +42 -0
- package/dist/cjs/hooks/useCollection.js +9 -0
- package/dist/cjs/hooks/useFetchHandle.js +13 -0
- package/dist/cjs/hooks/useFormatMoney.js +17 -0
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -0
- package/dist/cjs/hooks/useLoadScript.js +30 -0
- package/dist/cjs/hooks/useMoney.js +52 -0
- package/dist/cjs/hooks/usePrevious.js +17 -0
- package/dist/cjs/hooks/useProduct.js +90 -0
- package/dist/cjs/hooks/useProductList.js +21 -0
- package/dist/cjs/hooks/useSuspenseFetch.js +24 -0
- package/dist/cjs/hooks/useSwatchesOptions.js +39 -0
- package/dist/cjs/index.js +229 -0
- package/dist/cjs/types/global-style.js +7 -0
- package/dist/cjs/types/shop.js +2 -0
- package/dist/esm/components/AddOn.js +14 -0
- package/dist/esm/components/ComponentWrapper.js +40 -0
- package/dist/esm/components/ComponentWrapperPreview.js +54 -0
- package/dist/esm/components/Empty.js +3 -0
- package/dist/esm/components/Render.js +24 -0
- package/dist/esm/components/RenderBlock.js +17 -0
- package/dist/esm/components/RenderPreview.js +24 -0
- package/dist/esm/components/RenderSection.js +15 -0
- package/dist/esm/contexts/AddonContext.js +21 -0
- package/dist/esm/contexts/BuilderComponent.js +27 -0
- package/dist/esm/contexts/BuilderContext.js +26 -0
- package/dist/esm/contexts/BuilderPreviewContext.js +350 -0
- package/dist/esm/contexts/CartLineContext.js +21 -0
- package/dist/esm/contexts/CollectionContext.js +20 -0
- package/dist/esm/contexts/ProductContext.js +123 -0
- package/dist/esm/contexts/ProductListContext.js +20 -0
- package/dist/esm/contexts/SectionContext.js +45 -0
- package/dist/esm/contexts/ShopContext.js +40 -0
- package/dist/esm/graphql/fragments/analytic.generated.js +9 -0
- package/dist/esm/graphql/fragments/collection-detail.generated.js +11 -0
- package/dist/esm/graphql/fragments/collection-product.generated.js +24 -0
- package/dist/esm/graphql/fragments/data-seo.generated.js +9 -0
- package/dist/esm/graphql/fragments/media.generated.js +12 -0
- package/dist/esm/graphql/fragments/product-little.generated.js +23 -0
- package/dist/esm/graphql/fragments/product-option-value.generated.js +11 -0
- package/dist/esm/graphql/fragments/product-option.generated.js +12 -0
- package/dist/esm/graphql/fragments/product.generated.js +31 -0
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +10 -0
- package/dist/esm/graphql/fragments/published-page-section.generated.js +9 -0
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +25 -0
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +9 -0
- package/dist/esm/graphql/fragments/selected-option.generated.js +9 -0
- package/dist/esm/graphql/fragments/variant.generated.js +33 -0
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +32 -0
- package/dist/esm/graphql/queries/collection.generated.js +50 -0
- package/dist/esm/graphql/queries/preview-page.generated.js +21 -0
- package/dist/esm/graphql/queries/product-little-detail.generated.js +22 -0
- package/dist/esm/graphql/queries/product-medias.generated.js +27 -0
- package/dist/esm/graphql/queries/product-variants.generated.js +31 -0
- package/dist/esm/graphql/queries/products.generated.js +38 -0
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +21 -0
- package/dist/esm/graphql/queries/storeProperty.generated.js +10 -0
- package/dist/esm/helpers/GlobalEvent.js +13 -0
- package/dist/esm/helpers/background.js +102 -0
- package/dist/esm/helpers/borders.js +133 -0
- package/dist/esm/helpers/clone-deep.js +3 -0
- package/dist/esm/helpers/cls.js +18 -0
- package/dist/esm/helpers/colors.js +145 -0
- package/dist/esm/helpers/compose-advance-style.js +130 -0
- package/dist/esm/helpers/constant.js +13 -0
- package/dist/esm/helpers/css-variable.js +5 -0
- package/dist/esm/helpers/email.js +6 -0
- package/dist/esm/helpers/flatten-connection.js +8 -0
- package/dist/esm/helpers/fpixel.js +25 -0
- package/dist/esm/helpers/get-resonsive-value.js +28 -0
- package/dist/esm/helpers/get-shortname.js +90 -0
- package/dist/esm/helpers/gtag.js +45 -0
- package/dist/esm/helpers/is-browser.js +5 -0
- package/dist/esm/helpers/is-defined.js +5 -0
- package/dist/esm/helpers/is-empty-children.js +7 -0
- package/dist/esm/helpers/layout.js +15 -0
- package/dist/esm/helpers/load-script.js +30 -0
- package/dist/esm/helpers/make-style.js +91 -0
- package/dist/esm/helpers/normalize-builder-data.js +15 -0
- package/dist/esm/helpers/prefetch-queries.js +66 -0
- package/dist/esm/helpers/product.js +32 -0
- package/dist/esm/helpers/queries/get-collection.js +170 -0
- package/dist/esm/helpers/queries/get-product-by-slug.js +97 -0
- package/dist/esm/helpers/queries/get-product.js +109 -0
- package/dist/esm/helpers/queries/get-products.js +133 -0
- package/dist/esm/helpers/radius.js +86 -0
- package/dist/esm/helpers/shadow.js +45 -0
- package/dist/esm/helpers/size.js +18 -0
- package/dist/esm/helpers/spacing.js +42 -0
- package/dist/esm/helpers/tiktokpixel.js +15 -0
- package/dist/esm/helpers/typography.js +5 -0
- package/dist/esm/hooks/cart/use-add-to-cart.js +18 -0
- package/dist/esm/hooks/cart/use-cart-data.js +24 -0
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -0
- package/dist/esm/hooks/cart/use-cart-note-update.js +18 -0
- package/dist/esm/hooks/cart/use-create-cart.js +20 -0
- package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -0
- package/dist/esm/hooks/cart/use-update-cart-item.js +18 -0
- package/dist/esm/hooks/shop/use-collection-query.js +14 -0
- package/dist/esm/hooks/shop/use-product-query.js +14 -0
- package/dist/esm/hooks/shop/use-products-query.js +14 -0
- package/dist/esm/hooks/shop.js +68 -0
- package/dist/esm/hooks/use-current-device.js +21 -0
- package/dist/esm/hooks/use-lazy-video.js +13 -0
- package/dist/esm/hooks/useCartId.js +32 -0
- package/dist/esm/hooks/useCartLine.js +7 -0
- package/dist/esm/hooks/useCartUI.js +38 -0
- package/dist/esm/hooks/useCollection.js +7 -0
- package/dist/esm/hooks/useFetchHandle.js +11 -0
- package/dist/esm/hooks/useFormatMoney.js +13 -0
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -0
- package/dist/esm/hooks/useLoadScript.js +26 -0
- package/dist/esm/hooks/useMoney.js +48 -0
- package/dist/esm/hooks/usePrevious.js +15 -0
- package/dist/esm/hooks/useProduct.js +78 -0
- package/dist/esm/hooks/useProductList.js +16 -0
- package/dist/esm/hooks/useSuspenseFetch.js +20 -0
- package/dist/esm/hooks/useSwatchesOptions.js +35 -0
- package/dist/esm/index.js +82 -0
- package/dist/esm/types/global-style.js +4 -0
- package/dist/esm/types/shop.js +1 -0
- package/dist/types/index.d.ts +7393 -0
- package/package.json +50 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var create = require('zustand');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const CartLineContext = react.createContext(null);
|
|
8
|
+
const createCartLineStore = (data) => create.createStore(() => ({
|
|
9
|
+
...data,
|
|
10
|
+
}));
|
|
11
|
+
const CartLineProvider = ({ children, line }) => {
|
|
12
|
+
return (jsxRuntime.jsx(CartLineContext.Provider, { value: createCartLineStore({ line }), children: children }, `${line.id}-${line.quantity}`));
|
|
13
|
+
};
|
|
14
|
+
// export const useCartLineStore = useStore;
|
|
15
|
+
const useCartLineStore = (selector, equalityFn) => {
|
|
16
|
+
const store = react.useContext(CartLineContext);
|
|
17
|
+
if (!store) {
|
|
18
|
+
throw new Error('useCartLineStore must be used within a CartLineProvider');
|
|
19
|
+
}
|
|
20
|
+
return create.useStore(store, selector, equalityFn);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.CartLineProvider = CartLineProvider;
|
|
24
|
+
exports.useCartLineStore = useCartLineStore;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var create = require('zustand');
|
|
6
|
+
|
|
7
|
+
const CollectionListContext = react.createContext(null);
|
|
8
|
+
const createCollectionProvider = (data) => create.createStore(() => ({
|
|
9
|
+
...data,
|
|
10
|
+
}));
|
|
11
|
+
const CollectionProvider = ({ children, collection, products, settings, styles, }) => {
|
|
12
|
+
return (jsxRuntime.jsx(CollectionListContext.Provider, { value: createCollectionProvider({ products, collection, settings, styles }), children: children }, collection?.id));
|
|
13
|
+
};
|
|
14
|
+
const useCollectionStore = (selector, equalityFn) => {
|
|
15
|
+
const store = react.useContext(CollectionListContext);
|
|
16
|
+
if (!store) {
|
|
17
|
+
throw new Error('useCollectionStore must be used within a useCollectionStore');
|
|
18
|
+
}
|
|
19
|
+
return create.useStore(store, selector, equalityFn);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.CollectionListContext = CollectionListContext;
|
|
23
|
+
exports.CollectionProvider = CollectionProvider;
|
|
24
|
+
exports.useCollectionStore = useCollectionStore;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var create = require('zustand');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var flattenConnection = require('../helpers/flatten-connection.js');
|
|
7
|
+
|
|
8
|
+
// const { Provider, useStore } = createContext<StoreApi<ProductContextProps>>();
|
|
9
|
+
const ProductContext = react.createContext(null);
|
|
10
|
+
const createProductStoreProvider = (data) => create.createStore((set, get) => ({
|
|
11
|
+
...data,
|
|
12
|
+
updateProperty: (name, data) => {
|
|
13
|
+
set((state) => {
|
|
14
|
+
return {
|
|
15
|
+
properties: state.properties?.map((v) => {
|
|
16
|
+
if (v.key === name) {
|
|
17
|
+
return { ...v, ...data };
|
|
18
|
+
}
|
|
19
|
+
return v;
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
addProperty: (data) => {
|
|
25
|
+
const properties = get().properties;
|
|
26
|
+
if (!properties?.some((v) => v.key === data.key)) {
|
|
27
|
+
set((state) => ({ properties: [...(state.properties ?? []), data] }));
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
removeProperty: (name) => {
|
|
31
|
+
set((state) => ({ properties: state.properties?.filter((v) => v.key !== name) }));
|
|
32
|
+
},
|
|
33
|
+
setQuantity: (num) => {
|
|
34
|
+
set({
|
|
35
|
+
quantity: num > 0 ? num : 1,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
setProductFeaturedImage: (image) => {
|
|
39
|
+
set({
|
|
40
|
+
featuredImageGlobal: image,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
incrementQuantity: () => {
|
|
44
|
+
set((state) => {
|
|
45
|
+
const quantity = state.quantity ?? 1;
|
|
46
|
+
return {
|
|
47
|
+
quantity: quantity + 1,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
decrementQuantity: () => {
|
|
52
|
+
set((state) => {
|
|
53
|
+
const quantity = state.quantity ?? 1;
|
|
54
|
+
return {
|
|
55
|
+
quantity: quantity > 2 ? quantity - 1 : 1,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
setSelectedOption: (optionId, optionValue) => {
|
|
60
|
+
set((state) => {
|
|
61
|
+
if (optionId && optionValue) {
|
|
62
|
+
return {
|
|
63
|
+
selectedOptions: {
|
|
64
|
+
...state?.selectedOptions,
|
|
65
|
+
[optionId]: optionValue,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return state;
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
forceSelectedOption: (value) => {
|
|
73
|
+
set((state) => {
|
|
74
|
+
return {
|
|
75
|
+
selectedOptions: {
|
|
76
|
+
...state?.selectedOptions,
|
|
77
|
+
...value,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
updateIsSubmit: (value) => {
|
|
83
|
+
set({
|
|
84
|
+
isSubmit: value,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
}));
|
|
88
|
+
const ProductProvider = ({ children, product, initialVariantId, quantity = 1, }) => {
|
|
89
|
+
const uiqueId = react.useId();
|
|
90
|
+
const store = react.useMemo(() => {
|
|
91
|
+
let selectedOptions = {};
|
|
92
|
+
let featuredImageGlobal = undefined;
|
|
93
|
+
if (product) {
|
|
94
|
+
const variants = flattenConnection.flattenConnection(product.variants);
|
|
95
|
+
const firstVariant = flattenConnection.flattenConnection(product.variants)[0];
|
|
96
|
+
const initialVariant = variants.find((v) => v?.id === initialVariantId) ?? firstVariant;
|
|
97
|
+
selectedOptions = initialVariant?.selectedOptions.reduce((acc, option) => {
|
|
98
|
+
if (option.name) {
|
|
99
|
+
return { ...acc, [option.name]: option.value };
|
|
100
|
+
}
|
|
101
|
+
return acc;
|
|
102
|
+
}, {});
|
|
103
|
+
featuredImageGlobal =
|
|
104
|
+
product.medias?.edges.find((v) => v.node?.id === initialVariant?.mediaId)?.node ??
|
|
105
|
+
product.featuredImage;
|
|
106
|
+
}
|
|
107
|
+
return createProductStoreProvider({
|
|
108
|
+
product,
|
|
109
|
+
quantity,
|
|
110
|
+
selectedOptions,
|
|
111
|
+
uiqueId,
|
|
112
|
+
featuredImageGlobal,
|
|
113
|
+
});
|
|
114
|
+
}, [initialVariantId, product, quantity, uiqueId]);
|
|
115
|
+
return (jsxRuntime.jsx(ProductContext.Provider, { value: store, children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: children }) }));
|
|
116
|
+
};
|
|
117
|
+
const useProductStore = (selector, equalityFn) => {
|
|
118
|
+
const store = react.useContext(ProductContext);
|
|
119
|
+
if (!store) {
|
|
120
|
+
throw new Error('Element of product must be used inside a Product');
|
|
121
|
+
}
|
|
122
|
+
return create.useStore(store, selector, equalityFn);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
exports.ProductProvider = ProductProvider;
|
|
126
|
+
exports.useProductStore = useProductStore;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var create = require('zustand');
|
|
6
|
+
|
|
7
|
+
const ProductListContext = react.createContext(null);
|
|
8
|
+
const createProductListProvider = (data) => create.createStore(() => ({
|
|
9
|
+
...data,
|
|
10
|
+
}));
|
|
11
|
+
const ProductListProvider = ({ children, collection, products, settings, styles, }) => {
|
|
12
|
+
return (jsxRuntime.jsx(ProductListContext.Provider, { value: createProductListProvider({ products, collection, settings, styles }), children: children }));
|
|
13
|
+
};
|
|
14
|
+
const useProductListStore = (selector, equalityFn) => {
|
|
15
|
+
const store = react.useContext(ProductListContext);
|
|
16
|
+
if (!store) {
|
|
17
|
+
throw new Error('useProductListStore must be used within a useProductListStore');
|
|
18
|
+
}
|
|
19
|
+
return create.useStore(store, selector, equalityFn);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.ProductListContext = ProductListContext;
|
|
23
|
+
exports.ProductListProvider = ProductListProvider;
|
|
24
|
+
exports.useProductListStore = useProductListStore;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var create = 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 = react.createContext(null);
|
|
10
|
+
const createSectionProvider = (data) => create.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 (jsxRuntime.jsx(SectionContext.Provider, { ...passProps, value: createSectionProvider(data), children: children }));
|
|
36
|
+
};
|
|
37
|
+
// export const useSectionStore = useStore;
|
|
38
|
+
const useSectionStore = (selector, equalityFn) => {
|
|
39
|
+
const store = react.useContext(SectionContext);
|
|
40
|
+
if (!store) {
|
|
41
|
+
throw new Error('useSectionStore must be used within a SectionProvider');
|
|
42
|
+
}
|
|
43
|
+
return create.useStore(store, selector, equalityFn);
|
|
44
|
+
};
|
|
45
|
+
const useSection = (id) => useSectionStore((s) => s.getSection(id));
|
|
46
|
+
|
|
47
|
+
exports.SectionProvider = SectionProvider;
|
|
48
|
+
exports.useSection = useSection;
|
|
49
|
+
exports.useSectionStore = useSectionStore;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var create = require('zustand');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var AddonContext = require('./AddonContext.js');
|
|
8
|
+
|
|
9
|
+
const ShopContext = react.createContext(null);
|
|
10
|
+
const createShopStoreProvider = (data) => create.createStore((set) => ({
|
|
11
|
+
mobileOnly: false,
|
|
12
|
+
...data,
|
|
13
|
+
changeLocale: (locale) => {
|
|
14
|
+
set({ locale });
|
|
15
|
+
},
|
|
16
|
+
changeCurrency: (currency) => {
|
|
17
|
+
set({ currency });
|
|
18
|
+
},
|
|
19
|
+
changeSwatches: (swatches) => {
|
|
20
|
+
set({ swatches });
|
|
21
|
+
},
|
|
22
|
+
changeStorefrontInfo: ({ url, token }) => {
|
|
23
|
+
set((prev) => ({
|
|
24
|
+
storefrontUrl: url ?? prev.storefrontUrl,
|
|
25
|
+
storefrontToken: token ?? prev.storefrontToken,
|
|
26
|
+
}));
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
const ShopProvider = ({ children, addons, storeOption, queryOption, ...passProps }) => {
|
|
30
|
+
const store = react.useMemo(() => createShopStoreProvider(storeOption), [storeOption]);
|
|
31
|
+
return (jsxRuntime.jsx(AddonContext.AddonProvider, { components: addons, children: jsxRuntime.jsx(useSWR.SWRConfig, { value: queryOption, children: jsxRuntime.jsx(ShopContext.Provider, { ...passProps, value: store, children: children }, JSON.stringify(storeOption)) }) }));
|
|
32
|
+
};
|
|
33
|
+
// export const useShopStore = useStore;
|
|
34
|
+
const useShopStore = (selector, equalityFn) => {
|
|
35
|
+
const store = react.useContext(ShopContext);
|
|
36
|
+
if (!store) {
|
|
37
|
+
throw new Error('useShopStore must be used within a ShopProvider');
|
|
38
|
+
}
|
|
39
|
+
return create.useStore(store, selector, equalityFn);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.ShopProvider = ShopProvider;
|
|
43
|
+
exports.useShopStore = useShopStore;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CollectionProductSelect = `
|
|
4
|
+
fragment CollectionProductSelect on Collection {
|
|
5
|
+
...CollectionDetailSelect
|
|
6
|
+
products(
|
|
7
|
+
first: $firstProduct
|
|
8
|
+
orderBy: $orderByProduct
|
|
9
|
+
after: $productsAfter
|
|
10
|
+
where: $whereProduct
|
|
11
|
+
) {
|
|
12
|
+
edges {
|
|
13
|
+
cursor
|
|
14
|
+
node {
|
|
15
|
+
...ProductSelect
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
pageInfo {
|
|
19
|
+
endCursor
|
|
20
|
+
hasNextPage
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
exports.CollectionProductSelect = CollectionProductSelect;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ProductLittleSelect = `
|
|
4
|
+
fragment ProductLittleSelect on Product {
|
|
5
|
+
id
|
|
6
|
+
title
|
|
7
|
+
description
|
|
8
|
+
descriptionHtml
|
|
9
|
+
handle
|
|
10
|
+
averageRating
|
|
11
|
+
isStorefront
|
|
12
|
+
isSample
|
|
13
|
+
baseID
|
|
14
|
+
sku
|
|
15
|
+
options {
|
|
16
|
+
...ProductOptionSelect
|
|
17
|
+
}
|
|
18
|
+
vendor
|
|
19
|
+
featuredImage {
|
|
20
|
+
...MediaSelect
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
exports.ProductLittleSelect = ProductLittleSelect;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ProductSelect = `
|
|
4
|
+
fragment ProductSelect on Product {
|
|
5
|
+
...ProductLittleSelect
|
|
6
|
+
medias(first: $firstMedia, after: $afterMedia) {
|
|
7
|
+
edges {
|
|
8
|
+
cursor
|
|
9
|
+
node {
|
|
10
|
+
...MediaSelect
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
pageInfo {
|
|
14
|
+
endCursor
|
|
15
|
+
hasNextPage
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
variants(first: $firstVariant, after: $afterVariant) {
|
|
19
|
+
edges {
|
|
20
|
+
cursor
|
|
21
|
+
node {
|
|
22
|
+
...VariantSelect
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
pageInfo {
|
|
26
|
+
hasNextPage
|
|
27
|
+
endCursor
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports.ProductSelect = ProductSelect;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const PublishedThemePageSelect = `
|
|
4
|
+
fragment PublishedThemePageSelect on PublishedThemePage {
|
|
5
|
+
id
|
|
6
|
+
name
|
|
7
|
+
isMobile
|
|
8
|
+
pageSections {
|
|
9
|
+
...PublishedPageSectionSelect
|
|
10
|
+
}
|
|
11
|
+
themePageCustomSections {
|
|
12
|
+
...PublishedCustomSectionSelect
|
|
13
|
+
}
|
|
14
|
+
themePageDataSEO {
|
|
15
|
+
...DataSEOSelect
|
|
16
|
+
}
|
|
17
|
+
pageStyle {
|
|
18
|
+
...PublishedThemeStyleSelect
|
|
19
|
+
}
|
|
20
|
+
sectionPosition
|
|
21
|
+
themePageAnalytic {
|
|
22
|
+
...AnalyticSelect
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports.PublishedThemePageSelect = PublishedThemePageSelect;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const VariantSelect = `
|
|
4
|
+
fragment VariantSelect on ProductVariant {
|
|
5
|
+
id
|
|
6
|
+
title
|
|
7
|
+
barcode
|
|
8
|
+
baseID
|
|
9
|
+
costPrice
|
|
10
|
+
height
|
|
11
|
+
inventoryPolicy
|
|
12
|
+
inventoryQuantity
|
|
13
|
+
inventoryStatus
|
|
14
|
+
isDigital
|
|
15
|
+
length
|
|
16
|
+
lowInventoryAmount
|
|
17
|
+
manageInventory
|
|
18
|
+
mediaId
|
|
19
|
+
platform
|
|
20
|
+
price
|
|
21
|
+
salePrice
|
|
22
|
+
sku
|
|
23
|
+
soldIndividually
|
|
24
|
+
weight
|
|
25
|
+
width
|
|
26
|
+
selectedOptions {
|
|
27
|
+
...SelectedOptionSelect
|
|
28
|
+
}
|
|
29
|
+
media {
|
|
30
|
+
...MediaSelect
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports.VariantSelect = VariantSelect;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 = `
|
|
14
|
+
query collectionDetailFilter($firstProduct: Int = 10, $orderBy: CollectionOrder, $where: CollectionWhereInput, $orderByProduct: ProductOrder, $productsAfter: Cursor, $firstVariant: Int, $afterVariant: Cursor, $afterMedia: Cursor, $firstMedia: Int, $whereProduct: ProductWhereInput) {
|
|
15
|
+
collections(first: 1, orderBy: $orderBy, where: $where) {
|
|
16
|
+
edges {
|
|
17
|
+
cursor
|
|
18
|
+
node {
|
|
19
|
+
...CollectionProductSelect
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
${collectionProduct_generated.CollectionProductSelect}
|
|
25
|
+
${collectionDetail_generated.CollectionDetailSelect}
|
|
26
|
+
${product_generated.ProductSelect}
|
|
27
|
+
${productLittle_generated.ProductLittleSelect}
|
|
28
|
+
${productOption_generated.ProductOptionSelect}
|
|
29
|
+
${productOptionValue_generated.ProductOptionValueSelect}
|
|
30
|
+
${media_generated.MediaSelect}
|
|
31
|
+
${variant_generated.VariantSelect}
|
|
32
|
+
${selectedOption_generated.SelectedOptionSelect}`;
|
|
33
|
+
|
|
34
|
+
exports.CollectionDetailFilterDocument = CollectionDetailFilterDocument;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 = `
|
|
12
|
+
query collection($first: Int = 5, $firstMedia: Int = 20, $afterMedia: Cursor, $firstVariant: Int = 20, $afterVariant: Cursor, $handle: String, $id: ID) {
|
|
13
|
+
collection(handle: $handle, id: $id) {
|
|
14
|
+
baseID
|
|
15
|
+
createdAt
|
|
16
|
+
deletedAt
|
|
17
|
+
description
|
|
18
|
+
descriptionMeta
|
|
19
|
+
handle
|
|
20
|
+
id
|
|
21
|
+
platform
|
|
22
|
+
products(first: $first) {
|
|
23
|
+
edges {
|
|
24
|
+
cursor
|
|
25
|
+
node {
|
|
26
|
+
...ProductSelect
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
pageInfo {
|
|
30
|
+
endCursor
|
|
31
|
+
hasNextPage
|
|
32
|
+
hasPreviousPage
|
|
33
|
+
startCursor
|
|
34
|
+
}
|
|
35
|
+
totalCount
|
|
36
|
+
}
|
|
37
|
+
tags
|
|
38
|
+
templateSuffix
|
|
39
|
+
title
|
|
40
|
+
titleMeta
|
|
41
|
+
updatedAt
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
${product_generated.ProductSelect}
|
|
45
|
+
${productLittle_generated.ProductLittleSelect}
|
|
46
|
+
${productOption_generated.ProductOptionSelect}
|
|
47
|
+
${productOptionValue_generated.ProductOptionValueSelect}
|
|
48
|
+
${media_generated.MediaSelect}
|
|
49
|
+
${variant_generated.VariantSelect}
|
|
50
|
+
${selectedOption_generated.SelectedOptionSelect}`;
|
|
51
|
+
|
|
52
|
+
exports.CollectionDocument = CollectionDocument;
|