@gem-sdk/core 1.9.0 → 1.9.2

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.
@@ -3,6 +3,8 @@
3
3
  var constant = require('./constant.js');
4
4
  var getResonsiveValue = require('./get-resonsive-value.js');
5
5
 
6
+ const gridToArrayRegex = // eslint-disable-next-line regexp/no-super-linear-backtracking
7
+ /[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g; // Regex convert css grid to array
6
8
  const optionLayoutStyle = (column)=>{
7
9
  if (!column) return {};
8
10
  const style = {};
@@ -24,6 +26,34 @@ const composeGridLayout = (layout)=>{
24
26
  [`--gtc-mobile`]: mobile
25
27
  };
26
28
  };
29
+ const gridToArray = (layout)=>{
30
+ return layout ? layout.match(gridToArrayRegex) ?? [] : [];
31
+ };
32
+ const convertOldLayout = (layout)=>{
33
+ const desktopCol = gridToArray(layout?.desktop).length;
34
+ const tabletCol = gridToArray(layout?.tablet).length;
35
+ const mobileCol = gridToArray(layout?.mobile).length;
36
+ return {
37
+ desktop: {
38
+ cols: desktopCol ? Array.from({
39
+ length: desktopCol
40
+ }, ()=>12 / desktopCol) : undefined,
41
+ display: 'fill'
42
+ },
43
+ tablet: {
44
+ cols: tabletCol ? Array.from({
45
+ length: tabletCol
46
+ }, ()=>12 / tabletCol) : undefined
47
+ },
48
+ mobile: {
49
+ cols: mobileCol ? Array.from({
50
+ length: mobileCol
51
+ }, ()=>12 / mobileCol) : undefined
52
+ }
53
+ };
54
+ };
27
55
 
28
56
  exports.composeGridLayout = composeGridLayout;
57
+ exports.convertOldLayout = convertOldLayout;
58
+ exports.gridToArrayRegex = gridToArrayRegex;
29
59
  exports.optionLayoutStyle = optionLayoutStyle;
package/dist/cjs/index.js CHANGED
@@ -159,6 +159,8 @@ exports.validateEmail = email.validateEmail;
159
159
  exports.getStyleBackgroundByDevice = background.getStyleBackgroundByDevice;
160
160
  exports.genVariable = cssVariable.genVariable;
161
161
  exports.composeGridLayout = layout.composeGridLayout;
162
+ exports.convertOldLayout = layout.convertOldLayout;
163
+ exports.gridToArrayRegex = layout.gridToArrayRegex;
162
164
  exports.optionLayoutStyle = layout.optionLayoutStyle;
163
165
  exports.isDefined = isDefined.isDefined;
164
166
  exports.getGlobalColorCSSProp = colors.getGlobalColorCSSProp;
@@ -1,6 +1,8 @@
1
1
  import { devicesMapping } from './constant.js';
2
2
  import { getResponsiveValueByScreen, getResponsiveValue } from './get-resonsive-value.js';
3
3
 
4
+ const gridToArrayRegex = // eslint-disable-next-line regexp/no-super-linear-backtracking
5
+ /[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g; // Regex convert css grid to array
4
6
  const optionLayoutStyle = (column)=>{
5
7
  if (!column) return {};
6
8
  const style = {};
@@ -22,5 +24,31 @@ const composeGridLayout = (layout)=>{
22
24
  [`--gtc-mobile`]: mobile
23
25
  };
24
26
  };
27
+ const gridToArray = (layout)=>{
28
+ return layout ? layout.match(gridToArrayRegex) ?? [] : [];
29
+ };
30
+ const convertOldLayout = (layout)=>{
31
+ const desktopCol = gridToArray(layout?.desktop).length;
32
+ const tabletCol = gridToArray(layout?.tablet).length;
33
+ const mobileCol = gridToArray(layout?.mobile).length;
34
+ return {
35
+ desktop: {
36
+ cols: desktopCol ? Array.from({
37
+ length: desktopCol
38
+ }, ()=>12 / desktopCol) : undefined,
39
+ display: 'fill'
40
+ },
41
+ tablet: {
42
+ cols: tabletCol ? Array.from({
43
+ length: tabletCol
44
+ }, ()=>12 / tabletCol) : undefined
45
+ },
46
+ mobile: {
47
+ cols: mobileCol ? Array.from({
48
+ length: mobileCol
49
+ }, ()=>12 / mobileCol) : undefined
50
+ }
51
+ };
52
+ };
25
53
 
26
- export { composeGridLayout, optionLayoutStyle };
54
+ export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle };
package/dist/esm/index.js CHANGED
@@ -40,7 +40,7 @@ export { loadScript } from './helpers/load-script.js';
40
40
  export { validateEmail } from './helpers/email.js';
41
41
  export { getStyleBackgroundByDevice } from './helpers/background.js';
42
42
  export { genVariable } from './helpers/css-variable.js';
43
- export { composeGridLayout, optionLayoutStyle } from './helpers/layout.js';
43
+ export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle } from './helpers/layout.js';
44
44
  export { isDefined } from './helpers/is-defined.js';
45
45
  export { getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getSingleColorVariable, isColor } from './helpers/colors.js';
46
46
  export { genTypoClass } from './helpers/typography.js';
@@ -130,6 +130,7 @@ type ObjectLayoutValue = {
130
130
  display?: 'fill' | 'fit';
131
131
  cols?: number[];
132
132
  };
133
+ type ProductReviewsWidgetType = 'reviews' | 'badge';
133
134
 
134
135
  type ResponsiveConfig<T> = {
135
136
  desktop: {
@@ -7365,8 +7366,10 @@ declare const getStyleBackgroundByDevice: (background?: ObjectDevices<Background
7365
7366
 
7366
7367
  declare const genVariable: (variableName: string) => string;
7367
7368
 
7369
+ declare const gridToArrayRegex: RegExp;
7368
7370
  declare const optionLayoutStyle: (column?: ObjectDevices<string | number>) => React.CSSProperties;
7369
7371
  declare const composeGridLayout: (layout?: ObjectDevices<ObjectLayoutValue>) => React.CSSProperties;
7372
+ declare const convertOldLayout: (layout?: ObjectDevices<string>) => ObjectDevices<ObjectLayoutValue>;
7370
7373
 
7371
7374
  declare function isDefined<T>(argument: T | undefined): argument is T;
7372
7375
 
@@ -7695,4 +7698,4 @@ declare const fetchMedias: (fetcher: FetchFunc, { id, isSample, isStorefront }:
7695
7698
 
7696
7699
  declare const getProductBySlug: (fetcher: FetchFunc, slug?: string) => Promise<ProductSelectFragment>;
7697
7700
 
7698
- export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, Border, BorderStyle, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, CollectionsDocument, CollectionsQueryResponse, CollectionsQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentSetting, ContainerProp, ControlProp, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, ExtractState, FetchFunc, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, InitComponentType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LooxReviewsWidgetType, ModalProvider, ModalProviderProps, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, ObjectLayoutValue, OptionNormalStyle, OptionSpecialStyle, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, RenderMemo as Render, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RoundedSize, 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, TypographyType, VariantSelectFragment, calculateFirstProduct, cls, composeAdvanceStyle, composeGridLayout, composeRadius, composeSize, composeSpacing, fetchMedias, fetchVariants, flattenConnection, fpixel, genTypoClass, genVariable, getBorderStyle, getCollection, getCornerCSSFromGlobal, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, globalEvent, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, isBrowser, isColor, isDefined, isEmptyChildren, isLocalEnv, loadScript, makeAspectRatio, makeHeight, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, prefetchQueries, props, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useCollectionsQuery, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useIsSampleProduct, useIsStorefrontProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useModalStore, useMoney, 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 };
7701
+ export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, Border, BorderStyle, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, CollectionsDocument, CollectionsQueryResponse, CollectionsQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentSetting, ContainerProp, ControlProp, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, ExtractState, FetchFunc, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, InitComponentType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LooxReviewsWidgetType, ModalProvider, ModalProviderProps, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, ObjectLayoutValue, OptionNormalStyle, OptionSpecialStyle, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductReviewsWidgetType, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, RenderMemo as Render, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RoundedSize, 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, TypographyType, VariantSelectFragment, calculateFirstProduct, cls, composeAdvanceStyle, composeGridLayout, composeRadius, composeSize, composeSpacing, convertOldLayout, fetchMedias, fetchVariants, flattenConnection, fpixel, genTypoClass, genVariable, getBorderStyle, getCollection, getCornerCSSFromGlobal, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, globalEvent, gridToArrayRegex, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, isBrowser, isColor, isDefined, isEmptyChildren, isLocalEnv, loadScript, makeAspectRatio, makeHeight, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, prefetchQueries, props, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useCollectionsQuery, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useIsSampleProduct, useIsStorefrontProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useModalStore, useMoney, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",