@gem-sdk/core 1.21.2 → 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
|
@@ -850,7 +850,15 @@ type TypographyV2ControlType<T> = SharedControlType<T> & {
|
|
|
850
850
|
};
|
|
851
851
|
};
|
|
852
852
|
|
|
853
|
-
type
|
|
853
|
+
type StickyDisplayControlType<T> = SharedControlType<T> & {
|
|
854
|
+
type: 'sticky-display';
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
type SyncProductPropertiesControlType<T> = SharedControlType<T> & {
|
|
858
|
+
type: 'sync-product-properties';
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
type ControlProp<T> = AngleControlType<T> | CheckboxControlType<T> | ColorPickerControlType<T> | GroupControlType<T> | IconControlType<T> | InputFixContentControlType<T> | InputNumberControlType<T> | InputUnitControlType<T> | InputUnitSpacingControlType<T> | InputUnitWidthControlType<T> | InputControlType<T> | MarginControlType<T> | PaddingControlType<T> | PositionControlType<T> | RadioGroupControlType | RangeControlType<T> | SegmentControlType<T> | SelectControlType<T> | TextareaControlType<T> | ToggleControlType<T> | ImageControlType<T> | ChildrensControlType | GridControlType<T> | FlexControlType<T> | TextEditorControlType<T> | ProductControlType<T> | TypographyControlType<T> | TypographyV2ControlType<T> | MenuControlType<T> | BehaviorStateControlType<T> | PickLinkControlType<T> | BoxShadowControlType<T> | TextShadowControlType<T> | BorderControlType<T> | BorderRadiusControlType<T> | RadiusPresetControlType<T> | SizeControlType<T> | ChildItemType<T> | PickMultiProductControlType<T> | CollectionControlType<T> | BackgroundControlType<T> | VisibilityControlType<T> | SelectVariantControlType | CountdownEvergreenType | Timezone<T> | CustomContentControlType<T> | DateTimePickerControlType | CountdownDailyType | KlaviyoCodes | YotpoLoyaltyCodes | InputWidthControlType<T> | LayoutSegmentControlType<T> | InputSpacing<T> | UniqueIdControlType<T> | PositionSquareControlType<T> | CustomCodeEditor | LayoutControlType<T> | SwatchesLinkControlType<T> | ProductListControlType<T> | CollectionBannerControlType<T> | Ratio<T> | StickyDisplayControlType<T> | SyncProductPropertiesControlType<T>;
|
|
854
862
|
type Setting<P extends BaseProps> = {
|
|
855
863
|
id: 'setting';
|
|
856
864
|
note?: string;
|
|
@@ -9602,8 +9610,8 @@ declare const useQuantity: () => {
|
|
|
9602
9610
|
};
|
|
9603
9611
|
declare const useSelectedOption: () => {
|
|
9604
9612
|
selectedOptions: Record<string, string> | undefined;
|
|
9605
|
-
setSelectedOption: (optionId?: Maybe<string>, optionValue?: Maybe<string
|
|
9606
|
-
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;
|
|
9607
9615
|
};
|
|
9608
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"> & {
|
|
9609
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.
|
|
28
|
+
"@gem-sdk/styles": "1.21.5"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"react-error-boundary": "4.0.10",
|