@gem-sdk/core 2.0.0-dev.569 → 2.0.0-dev.575
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.
|
@@ -132,6 +132,11 @@ const createProductStoreProvider = (data)=>zustand.createStore((set, get)=>({
|
|
|
132
132
|
set({
|
|
133
133
|
hasPreSelected: value
|
|
134
134
|
});
|
|
135
|
+
},
|
|
136
|
+
setIsChangeSelectedOption: (value)=>{
|
|
137
|
+
set({
|
|
138
|
+
isChangeSelectedOption: value
|
|
139
|
+
});
|
|
135
140
|
}
|
|
136
141
|
}));
|
|
137
142
|
const ProductProvider = ({ children, product, initialVariantId, quantity = 1, isSyncProduct })=>{
|
|
@@ -128,6 +128,8 @@ const useSelectedOption = ()=>{
|
|
|
128
128
|
const selectedOptions = ProductContext.useProductStore((s)=>s.selectedOptions);
|
|
129
129
|
const forceSelectedOption = ProductContext.useProductStore((s)=>s.forceSelectedOption);
|
|
130
130
|
const isSyncProduct = ProductContext.useProductStore((s)=>s.isSyncProduct);
|
|
131
|
+
const isChangeSelectedOption = ProductContext.useProductStore((s)=>s.isChangeSelectedOption);
|
|
132
|
+
const setIsChangeSelectedOption = ProductContext.useProductStore((s)=>s.setIsChangeSelectedOption);
|
|
131
133
|
const updateOption = react.useCallback((optionId, optionValue, productId, noEmit)=>{
|
|
132
134
|
if (!noEmit && isSyncProduct) {
|
|
133
135
|
const setOption = new CustomEvent('set-selected-option', {
|
|
@@ -143,9 +145,11 @@ const useSelectedOption = ()=>{
|
|
|
143
145
|
window.dispatchEvent(setOption);
|
|
144
146
|
}
|
|
145
147
|
setSelectedOption(optionId, optionValue);
|
|
148
|
+
setIsChangeSelectedOption(true);
|
|
146
149
|
}, [
|
|
150
|
+
isSyncProduct,
|
|
147
151
|
setSelectedOption,
|
|
148
|
-
|
|
152
|
+
setIsChangeSelectedOption
|
|
149
153
|
]);
|
|
150
154
|
const forceOption = react.useCallback((selectedOption, productId, noEmit)=>{
|
|
151
155
|
if (!noEmit && isSyncProduct) {
|
|
@@ -166,6 +170,7 @@ const useSelectedOption = ()=>{
|
|
|
166
170
|
isSyncProduct
|
|
167
171
|
]);
|
|
168
172
|
return react.useMemo(()=>({
|
|
173
|
+
isChangeSelectedOption,
|
|
169
174
|
selectedOptions,
|
|
170
175
|
setSelectedOption: updateOption,
|
|
171
176
|
forceSelectedOption: forceOption
|
|
@@ -130,6 +130,11 @@ const createProductStoreProvider = (data)=>createStore((set, get)=>({
|
|
|
130
130
|
set({
|
|
131
131
|
hasPreSelected: value
|
|
132
132
|
});
|
|
133
|
+
},
|
|
134
|
+
setIsChangeSelectedOption: (value)=>{
|
|
135
|
+
set({
|
|
136
|
+
isChangeSelectedOption: value
|
|
137
|
+
});
|
|
133
138
|
}
|
|
134
139
|
}));
|
|
135
140
|
const ProductProvider = ({ children, product, initialVariantId, quantity = 1, isSyncProduct })=>{
|
|
@@ -126,6 +126,8 @@ const useSelectedOption = ()=>{
|
|
|
126
126
|
const selectedOptions = useProductStore((s)=>s.selectedOptions);
|
|
127
127
|
const forceSelectedOption = useProductStore((s)=>s.forceSelectedOption);
|
|
128
128
|
const isSyncProduct = useProductStore((s)=>s.isSyncProduct);
|
|
129
|
+
const isChangeSelectedOption = useProductStore((s)=>s.isChangeSelectedOption);
|
|
130
|
+
const setIsChangeSelectedOption = useProductStore((s)=>s.setIsChangeSelectedOption);
|
|
129
131
|
const updateOption = useCallback((optionId, optionValue, productId, noEmit)=>{
|
|
130
132
|
if (!noEmit && isSyncProduct) {
|
|
131
133
|
const setOption = new CustomEvent('set-selected-option', {
|
|
@@ -141,9 +143,11 @@ const useSelectedOption = ()=>{
|
|
|
141
143
|
window.dispatchEvent(setOption);
|
|
142
144
|
}
|
|
143
145
|
setSelectedOption(optionId, optionValue);
|
|
146
|
+
setIsChangeSelectedOption(true);
|
|
144
147
|
}, [
|
|
148
|
+
isSyncProduct,
|
|
145
149
|
setSelectedOption,
|
|
146
|
-
|
|
150
|
+
setIsChangeSelectedOption
|
|
147
151
|
]);
|
|
148
152
|
const forceOption = useCallback((selectedOption, productId, noEmit)=>{
|
|
149
153
|
if (!noEmit && isSyncProduct) {
|
|
@@ -164,6 +168,7 @@ const useSelectedOption = ()=>{
|
|
|
164
168
|
isSyncProduct
|
|
165
169
|
]);
|
|
166
170
|
return useMemo(()=>({
|
|
171
|
+
isChangeSelectedOption,
|
|
167
172
|
selectedOptions,
|
|
168
173
|
setSelectedOption: updateOption,
|
|
169
174
|
forceSelectedOption: forceOption
|
package/dist/types/index.d.ts
CHANGED
|
@@ -34812,6 +34812,8 @@ type ProductContextProps = {
|
|
|
34812
34812
|
setShouldRequireUploadMessage: (value: boolean) => void;
|
|
34813
34813
|
useProductCompareAtPrice?: boolean;
|
|
34814
34814
|
setUseProductCompareAtPrice: (value?: boolean) => void;
|
|
34815
|
+
isChangeSelectedOption?: boolean;
|
|
34816
|
+
setIsChangeSelectedOption: (value: boolean) => void;
|
|
34815
34817
|
};
|
|
34816
34818
|
type ProductProviderProps = Pick<ProductContextProps, 'product' | 'quantity' | 'selectedOptions' | 'isSyncProduct'> & {
|
|
34817
34819
|
initialVariantId?: string;
|
|
@@ -47820,6 +47822,7 @@ declare const useHasPreSelected: () => {
|
|
|
47820
47822
|
setHasPreSelected: (value: boolean) => void;
|
|
47821
47823
|
};
|
|
47822
47824
|
declare const useSelectedOption: () => {
|
|
47825
|
+
isChangeSelectedOption: boolean | undefined;
|
|
47823
47826
|
selectedOptions: Record<string, string> | undefined;
|
|
47824
47827
|
setSelectedOption: (optionId?: Maybe$1<string>, optionValue?: Maybe$1<string>, productId?: Maybe$1<string>, noEmit?: boolean) => void;
|
|
47825
47828
|
forceSelectedOption: (selectedOption?: Record<string, string>, productId?: Maybe$1<string>, noEmit?: boolean) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.575",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@gem-sdk/adapter-shopify": "2.0.0-dev.324",
|
|
31
|
-
"@gem-sdk/styles": "2.0.0-dev.
|
|
31
|
+
"@gem-sdk/styles": "2.0.0-dev.571",
|
|
32
32
|
"@types/classnames": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|