@gem-sdk/core 1.21.4 → 1.21.7
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.
|
@@ -48,19 +48,49 @@ const useSelectedOption = ()=>{
|
|
|
48
48
|
const setSelectedOption = ProductContext.useProductStore((s)=>s.setSelectedOption);
|
|
49
49
|
const selectedOptions = ProductContext.useProductStore((s)=>s.selectedOptions);
|
|
50
50
|
const forceSelectedOption = ProductContext.useProductStore((s)=>s.forceSelectedOption);
|
|
51
|
-
const updateOption = react.useCallback((optionId, optionValue)=>{
|
|
51
|
+
const updateOption = react.useCallback((optionId, optionValue, productId, noEmit)=>{
|
|
52
|
+
if (!noEmit) {
|
|
53
|
+
const setOption = new CustomEvent('set-selected-option', {
|
|
54
|
+
bubbles: true,
|
|
55
|
+
cancelable: true,
|
|
56
|
+
composed: true,
|
|
57
|
+
detail: {
|
|
58
|
+
optionId,
|
|
59
|
+
optionValue,
|
|
60
|
+
productId
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
window.dispatchEvent(setOption);
|
|
64
|
+
}
|
|
52
65
|
setSelectedOption(optionId, optionValue);
|
|
53
66
|
}, [
|
|
54
67
|
setSelectedOption
|
|
55
68
|
]);
|
|
69
|
+
const forceOption = react.useCallback((selectedOption, productId, noEmit)=>{
|
|
70
|
+
if (!noEmit) {
|
|
71
|
+
const forceOption = new CustomEvent('force-selected-option', {
|
|
72
|
+
bubbles: true,
|
|
73
|
+
cancelable: true,
|
|
74
|
+
composed: true,
|
|
75
|
+
detail: {
|
|
76
|
+
selectedOption,
|
|
77
|
+
productId
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
window.dispatchEvent(forceOption);
|
|
81
|
+
}
|
|
82
|
+
forceSelectedOption(selectedOption);
|
|
83
|
+
}, [
|
|
84
|
+
forceSelectedOption
|
|
85
|
+
]);
|
|
56
86
|
return react.useMemo(()=>({
|
|
57
87
|
selectedOptions,
|
|
58
88
|
setSelectedOption: updateOption,
|
|
59
|
-
forceSelectedOption
|
|
89
|
+
forceSelectedOption: forceOption
|
|
60
90
|
}), [
|
|
61
91
|
selectedOptions,
|
|
62
92
|
updateOption,
|
|
63
|
-
|
|
93
|
+
forceOption
|
|
64
94
|
]);
|
|
65
95
|
};
|
|
66
96
|
const useVariants = ()=>{
|
|
@@ -46,19 +46,49 @@ const useSelectedOption = ()=>{
|
|
|
46
46
|
const setSelectedOption = useProductStore((s)=>s.setSelectedOption);
|
|
47
47
|
const selectedOptions = useProductStore((s)=>s.selectedOptions);
|
|
48
48
|
const forceSelectedOption = useProductStore((s)=>s.forceSelectedOption);
|
|
49
|
-
const updateOption = useCallback((optionId, optionValue)=>{
|
|
49
|
+
const updateOption = useCallback((optionId, optionValue, productId, noEmit)=>{
|
|
50
|
+
if (!noEmit) {
|
|
51
|
+
const setOption = new CustomEvent('set-selected-option', {
|
|
52
|
+
bubbles: true,
|
|
53
|
+
cancelable: true,
|
|
54
|
+
composed: true,
|
|
55
|
+
detail: {
|
|
56
|
+
optionId,
|
|
57
|
+
optionValue,
|
|
58
|
+
productId
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
window.dispatchEvent(setOption);
|
|
62
|
+
}
|
|
50
63
|
setSelectedOption(optionId, optionValue);
|
|
51
64
|
}, [
|
|
52
65
|
setSelectedOption
|
|
53
66
|
]);
|
|
67
|
+
const forceOption = useCallback((selectedOption, productId, noEmit)=>{
|
|
68
|
+
if (!noEmit) {
|
|
69
|
+
const forceOption = new CustomEvent('force-selected-option', {
|
|
70
|
+
bubbles: true,
|
|
71
|
+
cancelable: true,
|
|
72
|
+
composed: true,
|
|
73
|
+
detail: {
|
|
74
|
+
selectedOption,
|
|
75
|
+
productId
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
window.dispatchEvent(forceOption);
|
|
79
|
+
}
|
|
80
|
+
forceSelectedOption(selectedOption);
|
|
81
|
+
}, [
|
|
82
|
+
forceSelectedOption
|
|
83
|
+
]);
|
|
54
84
|
return useMemo(()=>({
|
|
55
85
|
selectedOptions,
|
|
56
86
|
setSelectedOption: updateOption,
|
|
57
|
-
forceSelectedOption
|
|
87
|
+
forceSelectedOption: forceOption
|
|
58
88
|
}), [
|
|
59
89
|
selectedOptions,
|
|
60
90
|
updateOption,
|
|
61
|
-
|
|
91
|
+
forceOption
|
|
62
92
|
]);
|
|
63
93
|
};
|
|
64
94
|
const useVariants = ()=>{
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9610,8 +9610,8 @@ declare const useQuantity: () => {
|
|
|
9610
9610
|
};
|
|
9611
9611
|
declare const useSelectedOption: () => {
|
|
9612
9612
|
selectedOptions: Record<string, string> | undefined;
|
|
9613
|
-
setSelectedOption: (optionId?: Maybe<string>, optionValue?: Maybe<string
|
|
9614
|
-
forceSelectedOption: (
|
|
9613
|
+
setSelectedOption: (optionId?: Maybe<string>, optionValue?: Maybe<string>, productId?: Maybe<string>, noEmit?: boolean) => void;
|
|
9614
|
+
forceSelectedOption: (selectedOption?: Record<string, string>, productId?: Maybe<string>, noEmit?: boolean) => void;
|
|
9615
9615
|
};
|
|
9616
9616
|
declare const useVariants: () => Maybe<Pick<ProductVariant, "title" | "width" | "length" | "weight" | "height" | "id" | "barcode" | "baseID" | "costPrice" | "inventoryPolicy" | "inventoryQuantity" | "inventoryStatus" | "isDigital" | "lowInventoryAmount" | "manageInventory" | "mediaId" | "platform" | "price" | "salePrice" | "sku" | "soldIndividually"> & {
|
|
9617
9617
|
selectedOptions: Pick<SelectedOption, "value" | "name" | "optionType">[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@gem-sdk/adapter-shopify": "1.12.0",
|
|
28
|
-
"@gem-sdk/styles": "1.21.
|
|
28
|
+
"@gem-sdk/styles": "1.21.5"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"react-error-boundary": "4.0.10",
|