@gem-sdk/core 1.14.0-next.91 → 1.14.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 -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 +27 -28
- package/package.json +2 -2
|
@@ -1 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const RenderIf = (c, t, f)=>c ? typeof t === 'string' ? t : t() : (typeof f === 'string' ? f : f?.()) ?? '';
|
|
4
|
+
const isObject = (obj)=>{
|
|
5
|
+
if (typeof obj === 'object' && !Array.isArray(obj) && obj !== null) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
};
|
|
10
|
+
const props = (strings, ...keys)=>{
|
|
11
|
+
const props = keys[0];
|
|
12
|
+
const propsArr = [];
|
|
13
|
+
for(const attr in props){
|
|
14
|
+
if (Object.hasOwnProperty.call(props, attr)) {
|
|
15
|
+
const val = props[attr];
|
|
16
|
+
if (![
|
|
17
|
+
'symbol',
|
|
18
|
+
'object',
|
|
19
|
+
'function'
|
|
20
|
+
].includes(typeof val)) {
|
|
21
|
+
if (val) {
|
|
22
|
+
propsArr.push(`${attr}="${val}"`);
|
|
23
|
+
} else {
|
|
24
|
+
propsArr.push(`${attr}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return propsArr.join(' ');
|
|
30
|
+
};
|
|
31
|
+
const styles = (strings, ...keys)=>{
|
|
32
|
+
const styles = keys[0];
|
|
33
|
+
const styleArr = [];
|
|
34
|
+
for(const attr in styles){
|
|
35
|
+
if (Object.hasOwnProperty.call(styles, attr)) {
|
|
36
|
+
const val = styles[attr];
|
|
37
|
+
if (val !== undefined && val !== false) styleArr.push(`${attr}:${val}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return styleArr.join(';');
|
|
41
|
+
};
|
|
42
|
+
const dataStringify = (obj)=>{
|
|
43
|
+
return JSON.stringify(obj).replace(/\\"/g, '"');
|
|
44
|
+
};
|
|
45
|
+
const template = (strings, ...keys)=>{
|
|
46
|
+
let str = '';
|
|
47
|
+
strings.forEach((item, index)=>{
|
|
48
|
+
str += item;
|
|
49
|
+
if (keys[index] !== undefined) {
|
|
50
|
+
if (isObject(keys[index])) {
|
|
51
|
+
if (/style=["|']/.test(item)) {
|
|
52
|
+
str += styles`${keys[index]}`;
|
|
53
|
+
} else {
|
|
54
|
+
str += props`${keys[index]}`;
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
str += keys[index];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return str;
|
|
62
|
+
};
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
64
|
+
const composeMemo = (fn, _)=>fn();
|
|
65
|
+
|
|
66
|
+
exports.RenderIf = RenderIf;
|
|
67
|
+
exports.composeMemo = composeMemo;
|
|
68
|
+
exports.dataStringify = dataStringify;
|
|
69
|
+
exports.props = props;
|
|
70
|
+
exports.styles = styles;
|
|
71
|
+
exports.template = template;
|
|
@@ -1 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var colors = require('./colors.js');
|
|
4
|
+
var constant = require('./constant.js');
|
|
5
|
+
var getShortname = require('./get-shortname.js');
|
|
6
|
+
|
|
7
|
+
const parseValueWithUnit = (valueWithUnit)=>{
|
|
8
|
+
const matches = valueWithUnit.match(/(\d+)(.+)/);
|
|
9
|
+
if (matches && matches.length === 3) {
|
|
10
|
+
const value = Number(matches[1] ?? 0);
|
|
11
|
+
const unit = matches[2];
|
|
12
|
+
return {
|
|
13
|
+
value,
|
|
14
|
+
unit: unit ?? 'px'
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
value: 0,
|
|
19
|
+
unit: 'px'
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const getStyleShadow = (shadowStyle, isActiveState = false)=>{
|
|
23
|
+
const { styleAppliedFor, value, isEnableShadow } = shadowStyle || {};
|
|
24
|
+
let { state } = shadowStyle || {};
|
|
25
|
+
if (!state) state = 'normal';
|
|
26
|
+
if (!styleAppliedFor || !value) return {};
|
|
27
|
+
if (typeof value.distance == 'undefined') return {};
|
|
28
|
+
const { value: distance, unit: unitDistance } = parseValueWithUnit(`${value?.distance}`);
|
|
29
|
+
return {
|
|
30
|
+
[`-${!isActiveState ? constant.stateMapping?.[state] : ''}-${getShortname.getShortName(styleAppliedFor)}`]: isEnableShadow ? `${Math.cos(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${value?.blur} ${styleAppliedFor === 'box-shadow' ? value?.spread + ' ' : ''}${colors.getSingleColorVariable(value?.color)}` : 'none'
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
|
|
34
|
+
if (!shadow || !styleAppliedFor) return {};
|
|
35
|
+
const style = {};
|
|
36
|
+
for (const [key, value] of Object.entries(shadow)){
|
|
37
|
+
Object.assign(style, getStyleShadow({
|
|
38
|
+
value: value,
|
|
39
|
+
state: key,
|
|
40
|
+
styleAppliedFor,
|
|
41
|
+
isEnableShadow: isEnableShadow?.[key]
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
return style;
|
|
45
|
+
};
|
|
46
|
+
const composeShadowCss = ({ hasBoxShadow, boxShadowValue })=>{
|
|
47
|
+
if (!hasBoxShadow) return undefined;
|
|
48
|
+
if (!boxShadowValue) return undefined;
|
|
49
|
+
const { value: distance, unit: unitDistance } = parseValueWithUnit(`${boxShadowValue?.distance}`);
|
|
50
|
+
return `box-shadow: ${Math.cos(parseFloat(`${boxShadowValue?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${boxShadowValue?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${boxShadowValue?.blur} ${boxShadowValue?.spread + ' '}${colors.getSingleColorVariable(boxShadowValue?.color)};`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.composeShadowCss = composeShadowCss;
|
|
54
|
+
exports.getStyleShadow = getStyleShadow;
|
|
55
|
+
exports.getStyleShadowState = getStyleShadowState;
|
|
56
|
+
exports.parseValueWithUnit = parseValueWithUnit;
|
package/dist/cjs/helpers/size.js
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constant = require('./constant.js');
|
|
4
|
+
|
|
5
|
+
function getCustomSizeCSSByDevice(size, device) {
|
|
6
|
+
if (!size || !device) return {};
|
|
7
|
+
const suffix = constant.devicesMapping[device] ?? '';
|
|
8
|
+
return {
|
|
9
|
+
[`--pl${suffix}`]: size?.[device]?.horizontal,
|
|
10
|
+
[`--pr${suffix}`]: size?.[device]?.horizontal,
|
|
11
|
+
[`--pt${suffix}`]: size?.[device]?.vertical,
|
|
12
|
+
[`--pb${suffix}`]: size?.[device]?.vertical
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const composeSize = (size)=>{
|
|
16
|
+
return Object.assign({}, getCustomSizeCSSByDevice(size, 'desktop'), getCustomSizeCSSByDevice(size, 'tablet'), getCustomSizeCSSByDevice(size, 'mobile'));
|
|
17
|
+
};
|
|
18
|
+
function genSizeClass(name) {
|
|
19
|
+
return `g-s-${name}`;
|
|
20
|
+
}
|
|
21
|
+
const composeSizeCss = (spacing)=>{
|
|
22
|
+
if (spacing === undefined) return '';
|
|
23
|
+
const size = spacing;
|
|
24
|
+
const sizeHozi = spacing?.custom?.desktop?.horizontal;
|
|
25
|
+
const sizeVerti = spacing?.custom?.desktop?.vertical;
|
|
26
|
+
if (!size?.custom) return undefined;
|
|
27
|
+
return `
|
|
28
|
+
${sizeHozi ? `padding-left: ${sizeHozi}; padding-right: ${sizeHozi};` : undefined}
|
|
29
|
+
${sizeVerti ? `padding-top: ${sizeVerti}; padding-bottom: ${sizeVerti};` : undefined}
|
|
30
|
+
`;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.composeSize = composeSize;
|
|
34
|
+
exports.composeSizeCss = composeSizeCss;
|
|
35
|
+
exports.genSizeClass = genSizeClass;
|
|
@@ -1 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constant = require('./constant.js');
|
|
4
|
+
|
|
5
|
+
function getSpacingCSSByType(key, device) {
|
|
6
|
+
if (!key) return {};
|
|
7
|
+
const suffix = device ? constant.devicesMapping?.[device] ?? '' : '';
|
|
8
|
+
return {
|
|
9
|
+
[`--p${suffix}`]: `var(--g-s-${key})`
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function getSpacingVariable(key) {
|
|
13
|
+
if (!key) return '';
|
|
14
|
+
return `var(--g-s-${key})`;
|
|
15
|
+
}
|
|
16
|
+
const composeSpacing = (spacingValue)=>{
|
|
17
|
+
const style = {};
|
|
18
|
+
switch(spacingValue?.desktop){
|
|
19
|
+
case 'm':
|
|
20
|
+
case 'l':
|
|
21
|
+
case 's':
|
|
22
|
+
Object.assign(style, getSpacingCSSByType(spacingValue.desktop));
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
switch(spacingValue?.tablet){
|
|
26
|
+
case 'm':
|
|
27
|
+
case 'l':
|
|
28
|
+
case 's':
|
|
29
|
+
Object.assign(style, getSpacingCSSByType(spacingValue.tablet, 'tablet'));
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
switch(spacingValue?.mobile){
|
|
33
|
+
case 'm':
|
|
34
|
+
case 'l':
|
|
35
|
+
case 's':
|
|
36
|
+
Object.assign(style, getSpacingCSSByType(spacingValue.mobile, 'mobile'));
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
return style;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.composeSpacing = composeSpacing;
|
|
43
|
+
exports.getSpacingVariable = getSpacingVariable;
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const pageview = ()=>{
|
|
4
|
+
if (!window.fbq) return;
|
|
5
|
+
window.fbq('track', 'PageView');
|
|
6
|
+
};
|
|
7
|
+
// https://developers.facebook.com/docs/facebook-pixel/advanced/
|
|
8
|
+
const event = (name, options = {})=>{
|
|
9
|
+
if (!window.fbq) return;
|
|
10
|
+
window.fbq('track', name, options);
|
|
11
|
+
};
|
|
12
|
+
const addToCart = (product)=>{
|
|
13
|
+
if (!window.fbq) return;
|
|
14
|
+
window.fbq('track', 'AddToCart', {
|
|
15
|
+
content_ids: [
|
|
16
|
+
product.id
|
|
17
|
+
],
|
|
18
|
+
content_name: product.name,
|
|
19
|
+
content_category: product.category,
|
|
20
|
+
content_type: 'product',
|
|
21
|
+
value: product.price,
|
|
22
|
+
currency: product.currency
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.addToCart = addToCart;
|
|
27
|
+
exports.event = event;
|
|
28
|
+
exports.pageview = pageview;
|
|
@@ -1 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
|
|
4
|
+
const pageview = (url, trackingId)=>{
|
|
5
|
+
// GA 4
|
|
6
|
+
if (window.gtag && trackingId) {
|
|
7
|
+
window.gtag('config', trackingId, {
|
|
8
|
+
page_path: url
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
// GA 3
|
|
12
|
+
if (window.ga) {
|
|
13
|
+
window.ga('send', 'pageview', url);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** Addition to cart events
|
|
17
|
+
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
|
|
18
|
+
*/ const addToCart = (product)=>{
|
|
19
|
+
// GA 3
|
|
20
|
+
if (!window.ga || !product) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
window.ga('ec:addProduct', {
|
|
24
|
+
...product,
|
|
25
|
+
id: product.sku,
|
|
26
|
+
name: product.variant === 'Default Title' ? product.name : `${product.name} - ${product.variant}`,
|
|
27
|
+
variant: product.variant === 'Default Title' ? product.name : product.variant
|
|
28
|
+
});
|
|
29
|
+
window.ga('ec:setAction', 'add');
|
|
30
|
+
window.ga('send', 'event', {
|
|
31
|
+
eventCategory: 'EnhancedEcommerce',
|
|
32
|
+
eventAction: 'Added Product',
|
|
33
|
+
nonInteraction: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/** Product clicked event
|
|
37
|
+
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#product-click
|
|
38
|
+
*/ const productClick = (product)=>{
|
|
39
|
+
if (!window.ga) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
ga('ec:addProduct', {
|
|
43
|
+
id: product.id,
|
|
44
|
+
name: product.name,
|
|
45
|
+
category: product.category,
|
|
46
|
+
brand: product.brand,
|
|
47
|
+
variant: product.variant
|
|
48
|
+
});
|
|
49
|
+
ga('ec:setAction', 'click');
|
|
50
|
+
ga('send', 'event', {
|
|
51
|
+
eventAction: 'Click',
|
|
52
|
+
eventCategory: 'Product'
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
/** Product viewed event
|
|
56
|
+
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-actvities
|
|
57
|
+
*/ const productDetail = (product)=>{
|
|
58
|
+
if (!product || !window.ga) return;
|
|
59
|
+
ga('ec:addProduct', {
|
|
60
|
+
brand: product.brand,
|
|
61
|
+
category: product.category,
|
|
62
|
+
id: product.id,
|
|
63
|
+
name: product.name,
|
|
64
|
+
variant: product.variant
|
|
65
|
+
});
|
|
66
|
+
ga('ec:setAction', 'detail');
|
|
67
|
+
ga('send', 'event', {
|
|
68
|
+
eventAction: 'Detail',
|
|
69
|
+
eventCategory: 'Ecommerce',
|
|
70
|
+
nonInteraction: 1
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
/** Removal from cart events
|
|
74
|
+
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
|
|
75
|
+
*/ const removeFromCart = (product, price)=>{
|
|
76
|
+
if (!product || !window.ga) return;
|
|
77
|
+
ga('ec:addProduct', {
|
|
78
|
+
id: product.id,
|
|
79
|
+
name: product.name,
|
|
80
|
+
price
|
|
81
|
+
});
|
|
82
|
+
ga('ec:setAction', 'remove');
|
|
83
|
+
ga('send', 'event', {
|
|
84
|
+
eventAction: 'Click',
|
|
85
|
+
eventCategory: 'Remove from cart'
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
exports.addToCart = addToCart;
|
|
90
|
+
exports.pageview = pageview;
|
|
91
|
+
exports.productClick = productClick;
|
|
92
|
+
exports.productDetail = productDetail;
|
|
93
|
+
exports.removeFromCart = removeFromCart;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const addToCart = (product)=>{
|
|
5
|
+
if (!window?.ttq?.track) return;
|
|
6
|
+
window.ttq.track('AddToCart', {
|
|
7
|
+
content_id: product.id,
|
|
8
|
+
content_type: 'product',
|
|
9
|
+
content_name: product.name,
|
|
10
|
+
quantity: product.quantity,
|
|
11
|
+
price: product.price,
|
|
12
|
+
value: (product.price ?? 0) * (product.quantity ?? 0),
|
|
13
|
+
currency: product.currency
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.addToCart = addToCart;
|
|
@@ -1,17 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var colors = require('./colors.js');
|
|
4
|
+
var makeStyle = require('./make-style.js');
|
|
5
|
+
|
|
6
|
+
const genTypoClass = (name)=>{
|
|
7
|
+
return `g-${name}`;
|
|
8
|
+
};
|
|
9
|
+
const composeTypographyCss = (typography)=>{
|
|
10
|
+
const typographyCustom = typography?.custom;
|
|
11
|
+
const { fontFamily, fontSize, fontStyle, fontWeight, lineHeight, letterSpacing } = typographyCustom?.desktop ?? {};
|
|
12
|
+
return `
|
|
13
|
+
${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily});` : ''}
|
|
14
|
+
${fontSize ? `font-size: ${fontSize};` : ''}
|
|
15
|
+
${fontStyle ? `font-style: ${fontStyle};` : ''}
|
|
16
|
+
${fontWeight ? `font-weight: ${fontWeight};` : ''}
|
|
17
|
+
${letterSpacing ? `letter-spacing: ${letterSpacing};` : ''}
|
|
18
|
+
${lineHeight ? `line-height: ${lineHeight};` : ''}
|
|
19
|
+
`;
|
|
20
|
+
};
|
|
21
|
+
const composeTypographyV2Css = (typography)=>{
|
|
22
|
+
const typographyCustom = typography?.custom;
|
|
23
|
+
const { fontFamily, fontSize, fontWeight, lineHeight, letterSpacing } = typographyCustom ?? {};
|
|
24
|
+
const typographyAttrs = typography?.attrs;
|
|
25
|
+
const { bold, italic, underline, transform } = typographyAttrs ?? {};
|
|
26
|
+
return `
|
|
27
|
+
${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily});` : ''}
|
|
28
|
+
${fontSize?.desktop ? `font-size: ${fontSize?.desktop};` : ''}
|
|
29
|
+
${bold ? `font-weight: bold;` : fontWeight ? `font-weight: ${fontWeight};` : ''}
|
|
30
|
+
${letterSpacing ? `letter-spacing: ${letterSpacing};` : ''}
|
|
31
|
+
${lineHeight ? `line-height: ${lineHeight};` : ''}
|
|
32
|
+
${italic ? `font-style: italic;` : ''}
|
|
33
|
+
${underline ? `text-decoration-line: underline;` : ''}
|
|
34
|
+
${transform ? `text-transform: ${transform};` : ''}
|
|
35
|
+
`;
|
|
36
|
+
};
|
|
37
|
+
function getCustomCSSByDevice(typography, device) {
|
|
38
|
+
if (!typography || !device) return {};
|
|
39
|
+
const suffix = device === 'desktop' || !device ? '' : `-${device}`;
|
|
40
|
+
const { fontFamily } = typography?.[device] ?? {};
|
|
41
|
+
return {
|
|
42
|
+
[`--size${suffix}`]: typography?.[device]?.fontSize,
|
|
43
|
+
[`--lh${suffix}`]: typography?.[device]?.lineHeight,
|
|
44
|
+
[`--fs${suffix}`]: typography?.[device]?.fontStyle,
|
|
45
|
+
[`--ff${suffix}`]: fontFamily ? `var(--g-font-${fontFamily}, ${fontFamily})` : undefined,
|
|
46
|
+
[`--weight${suffix}`]: typography?.[device]?.fontWeight,
|
|
47
|
+
[`--ls${suffix}`]: typography?.[device]?.letterSpacing
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const composeTypography = (typography)=>{
|
|
51
|
+
if (!typography) return {};
|
|
52
|
+
return makeStyle.removeNullUndefined({
|
|
53
|
+
...getCustomCSSByDevice(typography, 'desktop'),
|
|
54
|
+
...getCustomCSSByDevice(typography, 'tablet'),
|
|
55
|
+
...getCustomCSSByDevice(typography, 'mobile')
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const composeTypographyV2 = (value, attrs)=>{
|
|
59
|
+
if (!value) return {};
|
|
60
|
+
return makeStyle.removeNullUndefined({
|
|
61
|
+
...makeStyle.makeStyle({
|
|
62
|
+
fs: !attrs?.italic ? value?.fontStyle : undefined,
|
|
63
|
+
ff: value?.fontFamily ? `var(--g-font-${value.fontFamily.replace(/ /g, '-')}, ${value.fontFamily})` : undefined,
|
|
64
|
+
weight: !attrs?.bold ? value?.fontWeight : undefined,
|
|
65
|
+
ls: value?.letterSpacing,
|
|
66
|
+
lh: value?.lineHeight
|
|
67
|
+
}),
|
|
68
|
+
...makeStyle.makeStyleResponsive('size', value?.fontSize)
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const composeTypographyAttr = (attrs)=>{
|
|
72
|
+
if (!attrs) return {};
|
|
73
|
+
return makeStyle.removeNullUndefined({
|
|
74
|
+
...makeStyle.makeStyle({
|
|
75
|
+
fs: attrs?.italic ? 'italic' : undefined,
|
|
76
|
+
weight: attrs?.bold ? 'bold' : undefined,
|
|
77
|
+
c: colors.getSingleColorVariable(attrs?.color),
|
|
78
|
+
tt: attrs?.transform,
|
|
79
|
+
tdl: attrs?.underline ? 'underline' : undefined
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const composeTypographyClassName = (typo, typography)=>{
|
|
84
|
+
return typo ? typo?.type && !typo.custom ? genTypoClass(typo.type) : '' : typography?.type && genTypoClass(typography?.type);
|
|
85
|
+
};
|
|
86
|
+
const composeTypographyStyle = (typo, typography, disableAttr)=>{
|
|
87
|
+
if (typo) {
|
|
88
|
+
return {
|
|
89
|
+
...composeTypographyV2(typo.custom, typo.attrs),
|
|
90
|
+
...!disableAttr && composeTypographyAttr(typo.attrs)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
...!typography?.type ? composeTypography(typography?.custom) : {}
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.composeTypography = composeTypography;
|
|
99
|
+
exports.composeTypographyAttr = composeTypographyAttr;
|
|
100
|
+
exports.composeTypographyClassName = composeTypographyClassName;
|
|
101
|
+
exports.composeTypographyCss = composeTypographyCss;
|
|
102
|
+
exports.composeTypographyStyle = composeTypographyStyle;
|
|
103
|
+
exports.composeTypographyV2 = composeTypographyV2;
|
|
104
|
+
exports.composeTypographyV2Css = composeTypographyV2Css;
|
|
105
|
+
exports.genTypoClass = genTypoClass;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function checkInStock(variant) {
|
|
4
|
+
if (!variant) return false;
|
|
5
|
+
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
exports.checkInStock = checkInStock;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var adapterShopify = require('@gem-sdk/adapter-shopify');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var useSWRMutation = require('swr/mutation');
|
|
6
|
+
var shop = require('../shop.js');
|
|
7
|
+
|
|
8
|
+
const useAddToCart = (options)=>{
|
|
9
|
+
const shop$1 = shop.useStoreFront();
|
|
10
|
+
const { mutate } = useSWR.useSWRConfig();
|
|
11
|
+
return useSWRMutation('add-to-cart', (_, { arg })=>adapterShopify.addToCartOperation(shop$1)(arg), {
|
|
12
|
+
...options,
|
|
13
|
+
onSuccess: (result, key, config)=>{
|
|
14
|
+
mutate('cart', result, false);
|
|
15
|
+
options?.onSuccess?.(result, key, config);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.useAddToCart = useAddToCart;
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var adapterShopify = require('@gem-sdk/adapter-shopify');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var shop = require('../shop.js');
|
|
6
|
+
var useCartId = require('../useCartId.js');
|
|
7
|
+
|
|
8
|
+
const useCartData = (options)=>{
|
|
9
|
+
const { cartId, clearCartId } = useCartId.default();
|
|
10
|
+
const shop$1 = shop.useStoreFront();
|
|
11
|
+
return useSWR(cartId ? 'cart' : null, ()=>adapterShopify.getCartOperation(shop$1)({
|
|
12
|
+
cartId: cartId
|
|
13
|
+
}), {
|
|
14
|
+
revalidateOnMount: true,
|
|
15
|
+
revalidateOnFocus: true,
|
|
16
|
+
keepPreviousData: false,
|
|
17
|
+
dedupingInterval: 2000,
|
|
18
|
+
...options,
|
|
19
|
+
onSuccess (data, key, config) {
|
|
20
|
+
if (!data) {
|
|
21
|
+
clearCartId();
|
|
22
|
+
}
|
|
23
|
+
options?.onSuccess?.(data, key, config);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.useCartData = useCartData;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var adapterShopify = require('@gem-sdk/adapter-shopify');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var useSWRMutation = require('swr/mutation');
|
|
6
|
+
var shop = require('../shop.js');
|
|
7
|
+
|
|
8
|
+
const useCartDiscountCodesUpdate = (options)=>{
|
|
9
|
+
const shop$1 = shop.useStoreFront();
|
|
10
|
+
const { mutate } = useSWR.useSWRConfig();
|
|
11
|
+
return useSWRMutation('cart-discount-codes-update', (_, { arg })=>adapterShopify.cartDiscountCodesUpdateOperation(shop$1)(arg), {
|
|
12
|
+
...options,
|
|
13
|
+
onSuccess: (result, key, config)=>{
|
|
14
|
+
mutate('cart', result, false);
|
|
15
|
+
options?.onSuccess?.(result, key, config);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.useCartDiscountCodesUpdate = useCartDiscountCodesUpdate;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var adapterShopify = require('@gem-sdk/adapter-shopify');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var useSWRMutation = require('swr/mutation');
|
|
6
|
+
var shop = require('../shop.js');
|
|
7
|
+
|
|
8
|
+
const useCartNoteUpdate = (options)=>{
|
|
9
|
+
const shop$1 = shop.useStoreFront();
|
|
10
|
+
const { mutate } = useSWR.useSWRConfig();
|
|
11
|
+
return useSWRMutation('cart-note-update', (_, { arg })=>adapterShopify.cartNoteUpdateOperation(shop$1)(arg), {
|
|
12
|
+
...options,
|
|
13
|
+
onSuccess: (result, key, config)=>{
|
|
14
|
+
mutate('cart', result, false);
|
|
15
|
+
options?.onSuccess?.(result, key, config);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.useCartNoteUpdate = useCartNoteUpdate;
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var adapterShopify = require('@gem-sdk/adapter-shopify');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var useSWRMutation = require('swr/mutation');
|
|
6
|
+
var shop = require('../shop.js');
|
|
7
|
+
|
|
8
|
+
const useCreateCart = (options)=>{
|
|
9
|
+
const shop$1 = shop.useStoreFront();
|
|
10
|
+
const { mutate } = useSWR.useSWRConfig();
|
|
11
|
+
return useSWRMutation('create-cart', (_, { arg })=>{
|
|
12
|
+
return adapterShopify.createCartOperation(shop$1)(arg);
|
|
13
|
+
}, {
|
|
14
|
+
...options,
|
|
15
|
+
onSuccess: (result, key, config)=>{
|
|
16
|
+
mutate('cart', result, false);
|
|
17
|
+
options?.onSuccess?.(result, key, config);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.useCreateCart = useCreateCart;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var adapterShopify = require('@gem-sdk/adapter-shopify');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var useSWRMutation = require('swr/mutation');
|
|
6
|
+
var shop = require('../shop.js');
|
|
7
|
+
|
|
8
|
+
const useRemoveCartItem = (options)=>{
|
|
9
|
+
const shop$1 = shop.useStoreFront();
|
|
10
|
+
const { mutate } = useSWR.useSWRConfig();
|
|
11
|
+
return useSWRMutation('remove-cart-item', (_, { arg })=>adapterShopify.removeCartItemOperation(shop$1)(arg), {
|
|
12
|
+
...options,
|
|
13
|
+
onSuccess: (result, key, config)=>{
|
|
14
|
+
mutate('cart', result, false);
|
|
15
|
+
options?.onSuccess?.(result, key, config);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.useRemoveCartItem = useRemoveCartItem;
|