@gem-sdk/core 1.14.0-next.63 → 1.14.0-next.76
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var variant = require('./variant.js');
|
|
4
|
+
|
|
3
5
|
function getSelectedVariant(variants, choices) {
|
|
4
6
|
/**
|
|
5
7
|
* Ensure the user has selected all the required options, not just some.
|
|
@@ -26,6 +28,18 @@ function parseSelectedOption(options) {
|
|
|
26
28
|
return acc;
|
|
27
29
|
}, {});
|
|
28
30
|
}
|
|
31
|
+
function checkAvailableVariantInStock(variants, optionId, optionValue) {
|
|
32
|
+
return variants ? variants.some((item)=>{
|
|
33
|
+
if (item) {
|
|
34
|
+
const { selectedOptions } = item;
|
|
35
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
36
|
+
const isInStock = variant.checkInStock(item);
|
|
37
|
+
return opt && isInStock;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}) : false;
|
|
41
|
+
}
|
|
29
42
|
|
|
43
|
+
exports.checkAvailableVariantInStock = checkAvailableVariantInStock;
|
|
30
44
|
exports.getSelectedVariant = getSelectedVariant;
|
|
31
45
|
exports.parseSelectedOption = parseSelectedOption;
|
|
@@ -99,18 +99,15 @@ const useVariantOutStock = (optionId, optionValue)=>{
|
|
|
99
99
|
};
|
|
100
100
|
const useCheckAvailableVariantInStock = (optionId, optionValue)=>{
|
|
101
101
|
const variants = useVariants();
|
|
102
|
-
|
|
103
|
-
variants.forEach((item)=>{
|
|
102
|
+
return variants ? variants.some((item)=>{
|
|
104
103
|
if (item) {
|
|
105
104
|
const { selectedOptions } = item;
|
|
106
|
-
const opt = selectedOptions?.
|
|
105
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
107
106
|
const isInStock = variant.checkInStock(item);
|
|
108
|
-
|
|
109
|
-
available = true;
|
|
110
|
-
}
|
|
107
|
+
return opt && isInStock;
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
return false;
|
|
110
|
+
}) : false;
|
|
114
111
|
};
|
|
115
112
|
|
|
116
113
|
exports.useCheckAvailableVariantInStock = useCheckAvailableVariantInStock;
|
package/dist/cjs/index.js
CHANGED
|
@@ -194,6 +194,7 @@ exports.getCornerCSSFromGlobal = radius.getCornerCSSFromGlobal;
|
|
|
194
194
|
exports.getCustomRadius = radius.getCustomRadius;
|
|
195
195
|
exports.getRadiusCSSFromGlobal = radius.getRadiusCSSFromGlobal;
|
|
196
196
|
exports.getRadiusStyleActiveState = radius.getRadiusStyleActiveState;
|
|
197
|
+
exports.checkAvailableVariantInStock = product.checkAvailableVariantInStock;
|
|
197
198
|
exports.getSelectedVariant = product.getSelectedVariant;
|
|
198
199
|
exports.parseSelectedOption = product.parseSelectedOption;
|
|
199
200
|
exports.fpixel = fpixel;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { checkInStock } from './variant.js';
|
|
2
|
+
|
|
1
3
|
function getSelectedVariant(variants, choices) {
|
|
2
4
|
/**
|
|
3
5
|
* Ensure the user has selected all the required options, not just some.
|
|
@@ -24,5 +26,16 @@ function parseSelectedOption(options) {
|
|
|
24
26
|
return acc;
|
|
25
27
|
}, {});
|
|
26
28
|
}
|
|
29
|
+
function checkAvailableVariantInStock(variants, optionId, optionValue) {
|
|
30
|
+
return variants ? variants.some((item)=>{
|
|
31
|
+
if (item) {
|
|
32
|
+
const { selectedOptions } = item;
|
|
33
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
34
|
+
const isInStock = checkInStock(item);
|
|
35
|
+
return opt && isInStock;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}) : false;
|
|
39
|
+
}
|
|
27
40
|
|
|
28
|
-
export { getSelectedVariant, parseSelectedOption };
|
|
41
|
+
export { checkAvailableVariantInStock, getSelectedVariant, parseSelectedOption };
|
|
@@ -97,18 +97,15 @@ const useVariantOutStock = (optionId, optionValue)=>{
|
|
|
97
97
|
};
|
|
98
98
|
const useCheckAvailableVariantInStock = (optionId, optionValue)=>{
|
|
99
99
|
const variants = useVariants();
|
|
100
|
-
|
|
101
|
-
variants.forEach((item)=>{
|
|
100
|
+
return variants ? variants.some((item)=>{
|
|
102
101
|
if (item) {
|
|
103
102
|
const { selectedOptions } = item;
|
|
104
|
-
const opt = selectedOptions?.
|
|
103
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
105
104
|
const isInStock = checkInStock(item);
|
|
106
|
-
|
|
107
|
-
available = true;
|
|
108
|
-
}
|
|
105
|
+
return opt && isInStock;
|
|
109
106
|
}
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
return false;
|
|
108
|
+
}) : false;
|
|
112
109
|
};
|
|
113
110
|
|
|
114
111
|
export { useCheckAvailableVariantInStock, useCurrentVariant, useCurrentVariantInStock, useFeaturedImageGlobal, useProduct, useProductProperties, useQuantity, useSelectedOption, useUniqProductID, useVariant, useVariantOutStock, useVariants };
|
package/dist/esm/index.js
CHANGED
|
@@ -42,7 +42,7 @@ export { isDefined } from './helpers/is-defined.js';
|
|
|
42
42
|
export { composeTextColorCss, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateClassDynamicBtn, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveClassDynamicBtn, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getSingleColorVariable, isColor } from './helpers/colors.js';
|
|
43
43
|
export { composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, genTypoClass } from './helpers/typography.js';
|
|
44
44
|
export { composeCornerCss, composeRadius, getCornerCSSFromGlobal, getCustomRadius, getRadiusCSSFromGlobal, getRadiusStyleActiveState } from './helpers/radius.js';
|
|
45
|
-
export { getSelectedVariant, parseSelectedOption } from './helpers/product.js';
|
|
45
|
+
export { checkAvailableVariantInStock, getSelectedVariant, parseSelectedOption } from './helpers/product.js';
|
|
46
46
|
import * as fpixel from './helpers/tracking/fpixel.js';
|
|
47
47
|
export { fpixel };
|
|
48
48
|
import * as gtag from './helpers/tracking/gtag.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -753,6 +753,8 @@ type Mapped<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
|
|
|
753
753
|
type: 'layout-segment';
|
|
754
754
|
options: Option<T>[];
|
|
755
755
|
devices?: ResponsiveConfig<U>;
|
|
756
|
+
iconViewBox?: string;
|
|
757
|
+
enableItemBackground?: boolean;
|
|
756
758
|
} : {
|
|
757
759
|
id: K;
|
|
758
760
|
label: string;
|
|
@@ -9311,6 +9313,7 @@ declare function getSelectedVariant(variants?: Maybe<VariantSelectFragment>[], c
|
|
|
9311
9313
|
[key: string]: string;
|
|
9312
9314
|
}): Maybe<VariantSelectFragment>;
|
|
9313
9315
|
declare function parseSelectedOption(options: Array<SelectedOption>): SelectedOption | undefined;
|
|
9316
|
+
declare function checkAvailableVariantInStock(variants: Maybe<VariantSelectFragment>[] | undefined, optionId: string, optionValue: string): boolean;
|
|
9314
9317
|
|
|
9315
9318
|
declare const pageview$1: () => void;
|
|
9316
9319
|
declare const event: (name: string, options?: {}) => void;
|
|
@@ -9671,4 +9674,4 @@ type PublishedThemePageSelectFragment = Pick<PublishedThemePage, 'id' | 'name' |
|
|
|
9671
9674
|
|
|
9672
9675
|
declare const getProductBySlug: (fetcher: FetchFunc, slug?: string) => Promise<ProductSelectFragment>;
|
|
9673
9676
|
|
|
9674
|
-
export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, BoldSubscriptionsWidgetType, Border, BorderStyle, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, CollectionSelectFragment, CollectionsDocument, CollectionsQueryResponse, CollectionsQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentPreset, ComponentSetting, ContainerProp, ControlProp, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, ExtractState, FetchCollectionArgs, FetchFunc, FetchProductParams, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, InitComponentType, InstantJudgeMeReviewsWidgetType, InstantKlaviyoWidgetType, InstantLooxReviewsWidgetType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LooxReviewsWidgetType, ModalProvider, ModalProviderProps, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, ObjectLayoutValue, OptionNormalStyle, OptionSpecialStyle, PageType, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PickyStoryWidgetType, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductReviewsWidgetType, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, Ratio$1 as Ratio, RenderMemo as Render, RenderChildren, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RivyoWidgetType, RoundedSize, RyviuWidgetType, SectionData, SectionEntity, SectionProvider, SectionProviderProps, ShadowProps, ShadowStyle, ShadowStyleApplied, ShadowType, ShopProvider, ShopProviderProps, shop as ShopType, SizeProps, SizeSetting, SizeType, SpacingType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TypographyProps, TypographySetting, TypographySettingV2, TypographyType, TypographyV2Attrs, TypographyV2Props, VariantSelectFragment, WiserWidgetType, baseAssetURL, calculateFirstProduct, cls, composeAdvanceStyle, composeBackgroundCss, composeBorderCss, composeCornerCss, composeGridLayout, composeMemo, composeRadius, composeShadowCss, composeSize, composeSizeCss, composeSpacing, composeTextColorCss, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, convertOldLayout, dataStringify, fetchMedias, fetchVariants, flattenConnection, fpixel, genSizeClass, genTypoClass, genVariable, generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey, getBorderStyle, getCollection, getCornerCSSFromGlobal, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateClassDynamicBtn, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveClassDynamicBtn, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, globalEvent, gridToArrayRegex, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, handleConvertClassColorDynamicBtn, isBrowser, isColor, isDefined, isEmptyChildren, isLocalEnv, isSafari, loadScript, makeAspectRatio, makeHeight, makeLineClamp, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, parseValueWithUnit, prefetchQueries, props, removeNullUndefined, splitStyle, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckAvailableVariantInStock, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useCollectionsQuery, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useIsSampleProduct, useIsStorefrontProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useModalStore, useMoney, useMoneyFormat, usePageType, usePluginEnable, usePrevious, useProduct, useProductList, useProductListProducts, useProductListSettings, useProductListStore, useProductListStyles, useProductProperties, useProductQuery, useProductStore, useProductsQuery, useQuantity, useRemoveCartItem, useSection, useSectionStore, useSelectedOption, useShopStore, useStoreFront, useSuspenseFetch, useSwatches, useSwatchesOptions, useUniqProductID, useUpdateCartItem, useVariant, useVariantOutStock, useVariants, validateEmail };
|
|
9677
|
+
export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, BoldSubscriptionsWidgetType, Border, BorderStyle, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, CollectionSelectFragment, CollectionsDocument, CollectionsQueryResponse, CollectionsQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentPreset, ComponentSetting, ContainerProp, ControlProp, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, ExtractState, FetchCollectionArgs, FetchFunc, FetchProductParams, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, InitComponentType, InstantJudgeMeReviewsWidgetType, InstantKlaviyoWidgetType, InstantLooxReviewsWidgetType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LooxReviewsWidgetType, ModalProvider, ModalProviderProps, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, ObjectLayoutValue, OptionNormalStyle, OptionSpecialStyle, PageType, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PickyStoryWidgetType, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductReviewsWidgetType, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, Ratio$1 as Ratio, RenderMemo as Render, RenderChildren, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RivyoWidgetType, RoundedSize, RyviuWidgetType, SectionData, SectionEntity, SectionProvider, SectionProviderProps, ShadowProps, ShadowStyle, ShadowStyleApplied, ShadowType, ShopProvider, ShopProviderProps, shop as ShopType, SizeProps, SizeSetting, SizeType, SpacingType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TypographyProps, TypographySetting, TypographySettingV2, TypographyType, TypographyV2Attrs, TypographyV2Props, VariantSelectFragment, WiserWidgetType, baseAssetURL, calculateFirstProduct, checkAvailableVariantInStock, cls, composeAdvanceStyle, composeBackgroundCss, composeBorderCss, composeCornerCss, composeGridLayout, composeMemo, composeRadius, composeShadowCss, composeSize, composeSizeCss, composeSpacing, composeTextColorCss, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, convertOldLayout, dataStringify, fetchMedias, fetchVariants, flattenConnection, fpixel, genSizeClass, genTypoClass, genVariable, generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey, getBorderStyle, getCollection, getCornerCSSFromGlobal, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateClassDynamicBtn, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveClassDynamicBtn, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, globalEvent, gridToArrayRegex, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, handleConvertClassColorDynamicBtn, isBrowser, isColor, isDefined, isEmptyChildren, isLocalEnv, isSafari, loadScript, makeAspectRatio, makeHeight, makeLineClamp, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, parseValueWithUnit, prefetchQueries, props, removeNullUndefined, splitStyle, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckAvailableVariantInStock, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useCollectionsQuery, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useIsSampleProduct, useIsStorefrontProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useModalStore, useMoney, useMoneyFormat, usePageType, usePluginEnable, usePrevious, useProduct, useProductList, useProductListProducts, useProductListSettings, useProductListStore, useProductListStyles, useProductProperties, useProductQuery, useProductStore, useProductsQuery, useQuantity, useRemoveCartItem, useSection, useSectionStore, useSelectedOption, useShopStore, useStoreFront, useSuspenseFetch, useSwatches, useSwatchesOptions, useUniqProductID, useUpdateCartItem, useVariant, useVariantOutStock, useVariants, validateEmail };
|