@gem-sdk/core 1.23.0-staging.122 → 1.23.0-staging.125
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
|
@@ -492,6 +492,9 @@ type Option$1<T> = {
|
|
|
492
492
|
value: T extends ObjectDevices<infer U> ? U extends StateProp<infer A> ? A : U : T extends StateProp<infer B> ? B : T;
|
|
493
493
|
label: string | number;
|
|
494
494
|
hideOnPage?: string[];
|
|
495
|
+
flowTag?: string[];
|
|
496
|
+
condition?: 'and' | 'or';
|
|
497
|
+
icon?: string;
|
|
495
498
|
};
|
|
496
499
|
type Mapped$2<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
|
|
497
500
|
id: K;
|
|
@@ -966,7 +969,6 @@ type DropdownInput<T> = SharedControlType<T> & {
|
|
|
966
969
|
|
|
967
970
|
type Dropdown<T> = SharedControlType<T> & {
|
|
968
971
|
type: 'dropdown';
|
|
969
|
-
inputType?: 'text';
|
|
970
972
|
displayOptions?: {
|
|
971
973
|
label: string;
|
|
972
974
|
value: string;
|
|
@@ -9870,7 +9872,10 @@ declare const useVariant: (id: string) => Maybe<Pick<ProductVariant, "width" | "
|
|
|
9870
9872
|
}>;
|
|
9871
9873
|
declare const useCurrentVariant: () => Maybe<VariantSelectFragment>;
|
|
9872
9874
|
declare const useCurrentVariantInStock: () => boolean;
|
|
9873
|
-
declare const useVariantOutStock: (optionId: string, optionValue: string
|
|
9875
|
+
declare const useVariantOutStock: (optionId: string, optionValue: string, options: {
|
|
9876
|
+
position: number;
|
|
9877
|
+
optionNumber: number;
|
|
9878
|
+
}) => boolean;
|
|
9874
9879
|
declare const useCheckAvailableVariantInStock: (optionId: string, optionValue: string) => boolean;
|
|
9875
9880
|
|
|
9876
9881
|
declare const useProductList: () => CollectionProductSelectFragment | undefined;
|