@gem-sdk/core 2.2.0-staging.30 → 2.2.0-staging.48
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/Render.liquid.js +1 -2
- package/dist/cjs/components/RenderCustomCode.js +1 -2
- package/dist/cjs/contexts/ProductContext.js +5 -0
- package/dist/cjs/hooks/useProduct.js +6 -1
- package/dist/esm/components/Render.liquid.js +1 -2
- package/dist/esm/components/RenderCustomCode.js +1 -2
- package/dist/esm/contexts/ProductContext.js +5 -0
- package/dist/esm/hooks/useProduct.js +6 -1
- package/dist/types/index.d.ts +3 -0
- package/package.json +1 -1
- package/dist/cjs/helpers/custom-cdoe.js +0 -8
- package/dist/esm/helpers/custom-cdoe.js +0 -6
|
@@ -20,7 +20,6 @@ require('dayjs');
|
|
|
20
20
|
var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
|
|
21
21
|
var convert = require('../helpers/convert.js');
|
|
22
22
|
var render = require('../helpers/render.js');
|
|
23
|
-
var customCdoe = require('../helpers/custom-cdoe.js');
|
|
24
23
|
|
|
25
24
|
const componentsRenderWithParentId = [
|
|
26
25
|
'CarouselItem'
|
|
@@ -207,7 +206,7 @@ const RenderCustomCode = (item)=>{
|
|
|
207
206
|
const { css, javascript, rootClassName } = item.advanced?.editorData || {};
|
|
208
207
|
const replacedCSS = css?.replaceAll(rootClassName, item.uid);
|
|
209
208
|
const replacedJS = javascript?.replaceAll(rootClassName, item.uid);
|
|
210
|
-
const cssCode = render.RenderIf(!!css
|
|
209
|
+
const cssCode = render.RenderIf(!!css, render.template`
|
|
211
210
|
<style id="${`custom-css-${item?.uid}`}">
|
|
212
211
|
${replacedCSS}
|
|
213
212
|
</style>
|
|
@@ -19,7 +19,6 @@ require('@gem-sdk/adapter-shopify');
|
|
|
19
19
|
require('swr/mutation');
|
|
20
20
|
require('vanilla-lazyload');
|
|
21
21
|
require('../hooks/useCartUI.js');
|
|
22
|
-
var customCdoe = require('../helpers/custom-cdoe.js');
|
|
23
22
|
|
|
24
23
|
const RenderCustomCode = ({ uid, advanced })=>{
|
|
25
24
|
const mode = shop.useEditorMode();
|
|
@@ -42,7 +41,7 @@ const RenderCustomCode = ({ uid, advanced })=>{
|
|
|
42
41
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
43
42
|
children: [
|
|
44
43
|
/*#__PURE__*/ jsxRuntime.jsx(Head, {
|
|
45
|
-
children: !!css &&
|
|
44
|
+
children: !!css && /*#__PURE__*/ jsxRuntime.jsx("style", {
|
|
46
45
|
id: mapId['css'],
|
|
47
46
|
dangerouslySetInnerHTML: {
|
|
48
47
|
__html: replacedCSS
|
|
@@ -120,6 +120,11 @@ const createProductStoreProvider = (data)=>zustand.createStore((set, get)=>({
|
|
|
120
120
|
set({
|
|
121
121
|
hasPreSelected: value
|
|
122
122
|
});
|
|
123
|
+
},
|
|
124
|
+
setIsChangeSelectedOption: (value)=>{
|
|
125
|
+
set({
|
|
126
|
+
isChangeSelectedOption: value
|
|
127
|
+
});
|
|
123
128
|
}
|
|
124
129
|
}));
|
|
125
130
|
const ProductProvider = ({ children, product, initialVariantId, quantity = 1, isSyncProduct })=>{
|
|
@@ -110,6 +110,8 @@ const useSelectedOption = ()=>{
|
|
|
110
110
|
const selectedOptions = ProductContext.useProductStore((s)=>s.selectedOptions);
|
|
111
111
|
const forceSelectedOption = ProductContext.useProductStore((s)=>s.forceSelectedOption);
|
|
112
112
|
const isSyncProduct = ProductContext.useProductStore((s)=>s.isSyncProduct);
|
|
113
|
+
const isChangeSelectedOption = ProductContext.useProductStore((s)=>s.isChangeSelectedOption);
|
|
114
|
+
const setIsChangeSelectedOption = ProductContext.useProductStore((s)=>s.setIsChangeSelectedOption);
|
|
113
115
|
const updateOption = react.useCallback((optionId, optionValue, productId, noEmit)=>{
|
|
114
116
|
if (!noEmit && isSyncProduct) {
|
|
115
117
|
const setOption = new CustomEvent('set-selected-option', {
|
|
@@ -125,9 +127,11 @@ const useSelectedOption = ()=>{
|
|
|
125
127
|
window.dispatchEvent(setOption);
|
|
126
128
|
}
|
|
127
129
|
setSelectedOption(optionId, optionValue);
|
|
130
|
+
setIsChangeSelectedOption(true);
|
|
128
131
|
}, [
|
|
132
|
+
isSyncProduct,
|
|
129
133
|
setSelectedOption,
|
|
130
|
-
|
|
134
|
+
setIsChangeSelectedOption
|
|
131
135
|
]);
|
|
132
136
|
const forceOption = react.useCallback((selectedOption, productId, noEmit)=>{
|
|
133
137
|
if (!noEmit && isSyncProduct) {
|
|
@@ -148,6 +152,7 @@ const useSelectedOption = ()=>{
|
|
|
148
152
|
isSyncProduct
|
|
149
153
|
]);
|
|
150
154
|
return react.useMemo(()=>({
|
|
155
|
+
isChangeSelectedOption,
|
|
151
156
|
selectedOptions,
|
|
152
157
|
setSelectedOption: updateOption,
|
|
153
158
|
forceSelectedOption: forceOption
|
|
@@ -16,7 +16,6 @@ import 'dayjs';
|
|
|
16
16
|
import { composeAdvanceStyle } from '../helpers/compose-advance-style.js';
|
|
17
17
|
import { baseAssetURL, isLocalEnv } from '../helpers/convert.js';
|
|
18
18
|
import { RenderIf, template } from '../helpers/render.js';
|
|
19
|
-
import { hasNonEmptyCSSRules } from '../helpers/custom-cdoe.js';
|
|
20
19
|
|
|
21
20
|
const componentsRenderWithParentId = [
|
|
22
21
|
'CarouselItem'
|
|
@@ -203,7 +202,7 @@ const RenderCustomCode = (item)=>{
|
|
|
203
202
|
const { css, javascript, rootClassName } = item.advanced?.editorData || {};
|
|
204
203
|
const replacedCSS = css?.replaceAll(rootClassName, item.uid);
|
|
205
204
|
const replacedJS = javascript?.replaceAll(rootClassName, item.uid);
|
|
206
|
-
const cssCode = RenderIf(!!css
|
|
205
|
+
const cssCode = RenderIf(!!css, template`
|
|
207
206
|
<style id="${`custom-css-${item?.uid}`}">
|
|
208
207
|
${replacedCSS}
|
|
209
208
|
</style>
|
|
@@ -15,7 +15,6 @@ import '@gem-sdk/adapter-shopify';
|
|
|
15
15
|
import 'swr/mutation';
|
|
16
16
|
import 'vanilla-lazyload';
|
|
17
17
|
import '../hooks/useCartUI.js';
|
|
18
|
-
import { hasNonEmptyCSSRules } from '../helpers/custom-cdoe.js';
|
|
19
18
|
|
|
20
19
|
const RenderCustomCode = ({ uid, advanced })=>{
|
|
21
20
|
const mode = useEditorMode();
|
|
@@ -38,7 +37,7 @@ const RenderCustomCode = ({ uid, advanced })=>{
|
|
|
38
37
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
39
38
|
children: [
|
|
40
39
|
/*#__PURE__*/ jsx(Head, {
|
|
41
|
-
children: !!css &&
|
|
40
|
+
children: !!css && /*#__PURE__*/ jsx("style", {
|
|
42
41
|
id: mapId['css'],
|
|
43
42
|
dangerouslySetInnerHTML: {
|
|
44
43
|
__html: replacedCSS
|
|
@@ -118,6 +118,11 @@ const createProductStoreProvider = (data)=>createStore((set, get)=>({
|
|
|
118
118
|
set({
|
|
119
119
|
hasPreSelected: value
|
|
120
120
|
});
|
|
121
|
+
},
|
|
122
|
+
setIsChangeSelectedOption: (value)=>{
|
|
123
|
+
set({
|
|
124
|
+
isChangeSelectedOption: value
|
|
125
|
+
});
|
|
121
126
|
}
|
|
122
127
|
}));
|
|
123
128
|
const ProductProvider = ({ children, product, initialVariantId, quantity = 1, isSyncProduct })=>{
|
|
@@ -108,6 +108,8 @@ const useSelectedOption = ()=>{
|
|
|
108
108
|
const selectedOptions = useProductStore((s)=>s.selectedOptions);
|
|
109
109
|
const forceSelectedOption = useProductStore((s)=>s.forceSelectedOption);
|
|
110
110
|
const isSyncProduct = useProductStore((s)=>s.isSyncProduct);
|
|
111
|
+
const isChangeSelectedOption = useProductStore((s)=>s.isChangeSelectedOption);
|
|
112
|
+
const setIsChangeSelectedOption = useProductStore((s)=>s.setIsChangeSelectedOption);
|
|
111
113
|
const updateOption = useCallback((optionId, optionValue, productId, noEmit)=>{
|
|
112
114
|
if (!noEmit && isSyncProduct) {
|
|
113
115
|
const setOption = new CustomEvent('set-selected-option', {
|
|
@@ -123,9 +125,11 @@ const useSelectedOption = ()=>{
|
|
|
123
125
|
window.dispatchEvent(setOption);
|
|
124
126
|
}
|
|
125
127
|
setSelectedOption(optionId, optionValue);
|
|
128
|
+
setIsChangeSelectedOption(true);
|
|
126
129
|
}, [
|
|
130
|
+
isSyncProduct,
|
|
127
131
|
setSelectedOption,
|
|
128
|
-
|
|
132
|
+
setIsChangeSelectedOption
|
|
129
133
|
]);
|
|
130
134
|
const forceOption = useCallback((selectedOption, productId, noEmit)=>{
|
|
131
135
|
if (!noEmit && isSyncProduct) {
|
|
@@ -146,6 +150,7 @@ const useSelectedOption = ()=>{
|
|
|
146
150
|
isSyncProduct
|
|
147
151
|
]);
|
|
148
152
|
return useMemo(()=>({
|
|
153
|
+
isChangeSelectedOption,
|
|
149
154
|
selectedOptions,
|
|
150
155
|
setSelectedOption: updateOption,
|
|
151
156
|
forceSelectedOption: forceOption
|
package/dist/types/index.d.ts
CHANGED
|
@@ -36178,6 +36178,8 @@ type ProductContextProps = {
|
|
|
36178
36178
|
setHasPreSelected: (value: boolean) => void;
|
|
36179
36179
|
useProductCompareAtPrice?: boolean;
|
|
36180
36180
|
setUseProductCompareAtPrice: (value?: boolean) => void;
|
|
36181
|
+
isChangeSelectedOption?: boolean;
|
|
36182
|
+
setIsChangeSelectedOption: (value: boolean) => void;
|
|
36181
36183
|
};
|
|
36182
36184
|
type ProductProviderProps = Pick<ProductContextProps, 'product' | 'quantity' | 'selectedOptions' | 'isSyncProduct'> & {
|
|
36183
36185
|
initialVariantId?: string;
|
|
@@ -44918,6 +44920,7 @@ declare const useHasPreSelected: () => {
|
|
|
44918
44920
|
setHasPreSelected: (value: boolean) => void;
|
|
44919
44921
|
};
|
|
44920
44922
|
declare const useSelectedOption: () => {
|
|
44923
|
+
isChangeSelectedOption: boolean | undefined;
|
|
44921
44924
|
selectedOptions: Record<string, string> | undefined;
|
|
44922
44925
|
setSelectedOption: (optionId?: Maybe$1<string>, optionValue?: Maybe$1<string>, productId?: Maybe$1<string>, noEmit?: boolean) => void;
|
|
44923
44926
|
forceSelectedOption: (selectedOption?: Record<string, string>, productId?: Maybe$1<string>, noEmit?: boolean) => void;
|
package/package.json
CHANGED