@gem-sdk/core 1.23.0-staging.123 → 1.23.0-staging.126
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.
|
@@ -151,15 +151,25 @@ const useCurrentVariantInStock = ()=>{
|
|
|
151
151
|
const currentVariant = useCurrentVariant();
|
|
152
152
|
return variant.checkInStock(currentVariant);
|
|
153
153
|
};
|
|
154
|
-
const useVariantOutStock = (optionId, optionValue)=>{
|
|
154
|
+
const useVariantOutStock = (optionId, optionValue, options)=>{
|
|
155
155
|
const { selectedOptions } = useSelectedOption();
|
|
156
156
|
const variants = useVariants();
|
|
157
|
+
const lastPos = options.optionNumber - 1;
|
|
158
|
+
if (options.position < lastPos) {
|
|
159
|
+
return variants.some((variant$1)=>{
|
|
160
|
+
if (variant$1) {
|
|
161
|
+
const { selectedOptions } = variant$1;
|
|
162
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
163
|
+
const isInStock = variant.checkInStock(variant$1);
|
|
164
|
+
return opt && isInStock;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
157
168
|
const matchedVariant = product.getSelectedVariant(variants, {
|
|
158
169
|
...selectedOptions,
|
|
159
170
|
[optionId]: optionValue
|
|
160
171
|
});
|
|
161
|
-
|
|
162
|
-
return !isInStock;
|
|
172
|
+
return variant.checkInStock(matchedVariant);
|
|
163
173
|
};
|
|
164
174
|
const useCheckAvailableVariantInStock = (optionId, optionValue)=>{
|
|
165
175
|
const variants = useVariants();
|
|
@@ -149,15 +149,25 @@ const useCurrentVariantInStock = ()=>{
|
|
|
149
149
|
const currentVariant = useCurrentVariant();
|
|
150
150
|
return checkInStock(currentVariant);
|
|
151
151
|
};
|
|
152
|
-
const useVariantOutStock = (optionId, optionValue)=>{
|
|
152
|
+
const useVariantOutStock = (optionId, optionValue, options)=>{
|
|
153
153
|
const { selectedOptions } = useSelectedOption();
|
|
154
154
|
const variants = useVariants();
|
|
155
|
+
const lastPos = options.optionNumber - 1;
|
|
156
|
+
if (options.position < lastPos) {
|
|
157
|
+
return variants.some((variant)=>{
|
|
158
|
+
if (variant) {
|
|
159
|
+
const { selectedOptions } = variant;
|
|
160
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
161
|
+
const isInStock = checkInStock(variant);
|
|
162
|
+
return opt && isInStock;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
155
166
|
const matchedVariant = getSelectedVariant(variants, {
|
|
156
167
|
...selectedOptions,
|
|
157
168
|
[optionId]: optionValue
|
|
158
169
|
});
|
|
159
|
-
|
|
160
|
-
return !isInStock;
|
|
170
|
+
return checkInStock(matchedVariant);
|
|
161
171
|
};
|
|
162
172
|
const useCheckAvailableVariantInStock = (optionId, optionValue)=>{
|
|
163
173
|
const variants = useVariants();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -494,6 +494,7 @@ type Option$1<T> = {
|
|
|
494
494
|
hideOnPage?: string[];
|
|
495
495
|
flowTag?: string[];
|
|
496
496
|
condition?: 'and' | 'or';
|
|
497
|
+
icon?: string;
|
|
497
498
|
};
|
|
498
499
|
type Mapped$2<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
|
|
499
500
|
id: K;
|
|
@@ -968,7 +969,6 @@ type DropdownInput<T> = SharedControlType<T> & {
|
|
|
968
969
|
|
|
969
970
|
type Dropdown<T> = SharedControlType<T> & {
|
|
970
971
|
type: 'dropdown';
|
|
971
|
-
inputType?: 'text';
|
|
972
972
|
displayOptions?: {
|
|
973
973
|
label: string;
|
|
974
974
|
value: string;
|
|
@@ -9872,7 +9872,10 @@ declare const useVariant: (id: string) => Maybe<Pick<ProductVariant, "width" | "
|
|
|
9872
9872
|
}>;
|
|
9873
9873
|
declare const useCurrentVariant: () => Maybe<VariantSelectFragment>;
|
|
9874
9874
|
declare const useCurrentVariantInStock: () => boolean;
|
|
9875
|
-
declare const useVariantOutStock: (optionId: string, optionValue: string
|
|
9875
|
+
declare const useVariantOutStock: (optionId: string, optionValue: string, options: {
|
|
9876
|
+
position: number;
|
|
9877
|
+
optionNumber: number;
|
|
9878
|
+
}) => boolean;
|
|
9876
9879
|
declare const useCheckAvailableVariantInStock: (optionId: string, optionValue: string) => boolean;
|
|
9877
9880
|
|
|
9878
9881
|
declare const useProductList: () => CollectionProductSelectFragment | undefined;
|