@gem-sdk/core 1.22.1 → 1.22.4

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.
@@ -61,6 +61,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
61
61
  advanced: advanced
62
62
  }),
63
63
  /*#__PURE__*/ jsxRuntime.jsx(children.type, {
64
+ className: advanced?.cssClass,
64
65
  ...children.props,
65
66
  style,
66
67
  builderAttrs,
@@ -78,7 +79,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
78
79
  }),
79
80
  /*#__PURE__*/ jsxRuntime.jsx("div", {
80
81
  style: style,
81
- className: `${props.uid}`,
82
+ className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
82
83
  ...builderAttrs,
83
84
  children: children
84
85
  })
@@ -101,6 +101,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, ...passPr
101
101
  },
102
102
  styles: item.styles,
103
103
  setting: item.settings,
104
+ advanced: {
105
+ cssClass: item?.advanced?.cssClass
106
+ },
104
107
  ...passProps,
105
108
  rawChildren: item.childrens.map((id)=>{
106
109
  return {
@@ -130,6 +133,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, ...passPr
130
133
  },
131
134
  styles: item.styles,
132
135
  setting: item.settings,
136
+ advanced: {
137
+ cssClass: item?.advanced?.cssClass
138
+ },
133
139
  isText: componentTexts.includes(item.tag) ? true : null,
134
140
  ...passProps
135
141
  });
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ const colorPreset = {
4
+ black: '#000000',
5
+ white: '#FFFFFF',
6
+ gray: '#808080',
7
+ red: '#FF0000',
8
+ blue: '#0000FF',
9
+ green: '#008000',
10
+ yellow: '#FFFF00',
11
+ orange: '#FFA500',
12
+ pink: '#FFC0CB',
13
+ purple: '#800080',
14
+ brown: '#A52A2A',
15
+ cyan: '#00FFFF',
16
+ magenta: '#FF00FF',
17
+ teal: '#008080',
18
+ navy: '#000080',
19
+ maroon: '#800000',
20
+ gold: '#FFD700',
21
+ silver: '#C0C0C0',
22
+ beige: '#F5F5DC',
23
+ ivory: '#FFFFF0',
24
+ lavender: '#E6E6FA',
25
+ indigo: '#4B0082',
26
+ coral: '#FF7F50',
27
+ mint: '#98FF98',
28
+ 'sky blue': '#87CEEB',
29
+ salmon: '#FA8072',
30
+ olive: '#808000',
31
+ lilac: '#C8A2C8',
32
+ peach: '#FFDAB9',
33
+ turquoise: '#40E0D0',
34
+ ruby: '#E0115F',
35
+ bronze: '#CD7F32',
36
+ slate: '#708090',
37
+ charcoal: '#36454F',
38
+ sand: '#C2B280',
39
+ mauve: '#E0B0FF',
40
+ tangerine: '#FF4500',
41
+ 'mint green': '#00FF99',
42
+ 'forest green': '#228B22',
43
+ 'ruby red': '#9B111E',
44
+ marigold: '#FFB928',
45
+ eggplant: '#990066',
46
+ 'coral pink': '#F88379',
47
+ mustard: '#FFDB58',
48
+ 'sky gray': '#B0C4DE',
49
+ 'dusty rose': '#FF9BAE',
50
+ 'olive green': '#556B2F',
51
+ coffee: '#6F4E37',
52
+ 'lilac gray': '#C8A2C8',
53
+ 'steel blue': '#4682B4'
54
+ };
55
+
56
+ exports.colorPreset = colorPreset;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ const ProductOptionNameDocument = `
4
+ query productOptionName($limit: Int, $offset: Int) {
5
+ productOptionName(
6
+ limit: $limit,
7
+ offset: $offset
8
+ )
9
+ }`;
10
+
11
+ exports.ProductOptionNameDocument = ProductOptionNameDocument;
@@ -58,6 +58,7 @@ function composeAdvanceStyle(data, tag) {
58
58
  ];
59
59
  Object.keys(data).forEach((attr)=>{
60
60
  const value = data[attr];
61
+ if (attr === 'cssClass') return;
61
62
  if (value === undefined || value === null) return;
62
63
  const hasBoxShadow = data.hasBoxShadow ? data.hasBoxShadow : {};
63
64
  if (typeof value === 'object') {
@@ -4,11 +4,12 @@ var products_generated = require('../../graphql/queries/products.generated.js');
4
4
  var getCollection = require('./get-collection.js');
5
5
  var getProduct = require('./get-product.js');
6
6
 
7
- const getProducts = async (fetcher, { ids, isSample, isStorefront })=>{
7
+ const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
8
8
  const products = await loopFetchProducts(fetcher, {
9
9
  ids,
10
10
  isSample,
11
- isStorefront
11
+ isStorefront,
12
+ defaultSelectedProductCount
12
13
  });
13
14
  if (!products) {
14
15
  throw new Error('Product not found');
@@ -61,8 +62,9 @@ const fetchProducts = async (fetcher, variables)=>{
61
62
  variables
62
63
  ]);
63
64
  };
64
- const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront })=>{
65
- const numberOfProducts = (ids?.length == 0 ? 4 : ids?.length) ?? 4;
65
+ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
66
+ const defaultNumberOfProducts = defaultSelectedProductCount || 4;
67
+ const numberOfProducts = (ids?.length == 0 ? defaultNumberOfProducts : ids?.length) ?? defaultNumberOfProducts;
66
68
  const productsPerPage = 8; // number of products per page
67
69
  let variables; // variables of collection query
68
70
  let productAfterFetcher; // product after of collection query
@@ -6,14 +6,15 @@ var query = require('../../helpers/query.js');
6
6
  var shop = require('../shop.js');
7
7
  var useFetchHandle = require('../useFetchHandle.js');
8
8
 
9
- const useProductsQuery = (ids, options)=>{
9
+ const useProductsQuery = (ids, options, defaultSelectedProductCount)=>{
10
10
  const fetcher = useFetchHandle.useFetchHandle();
11
11
  const isSample = shop.useIsSampleProduct();
12
12
  const isStorefront = shop.useIsStorefrontProduct();
13
13
  return useSWR(ids ? query.generateProductsQueryKey({
14
14
  ids,
15
15
  isSample,
16
- isStorefront
16
+ isStorefront,
17
+ defaultSelectedProductCount
17
18
  }) : null, async ([, arg])=>{
18
19
  return getProducts.getProducts(fetcher, arg);
19
20
  }, options);
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var useSWR = require('swr');
6
+ var productValueLabel_generated = require('../graphql/queries/product-value-label.generated.js');
7
+ var variantPresets = require('../components/src/product/helpers/variant-presets.js');
8
+ var shop = require('./shop.js');
9
+ var useFetchHandle = require('./useFetchHandle.js');
10
+ var ShopContext = require('../contexts/ShopContext.js');
11
+
12
+ let swatchChange = false;
13
+ let colorChange = false;
14
+ const useInitialSwatchesOptions = (options)=>{
15
+ const fetcher = useFetchHandle.useFetchHandle();
16
+ const changeSwatches = ShopContext.useShopStore((s)=>s.changeSwatches);
17
+ const { swatches } = shop.useSwatches();
18
+ const { data: productOptionName } = useSWR([
19
+ '/query/productOptionName',
20
+ {}
21
+ ], async ()=>fetchProductValueLabel(fetcher), {
22
+ revalidateOnMount: true
23
+ });
24
+ const swatchesTitleList = [];
25
+ swatches?.forEach((el)=>{
26
+ swatchesTitleList.push(el.optionTitle);
27
+ });
28
+ productOptionName?.productOptionName?.forEach((el)=>{
29
+ if (!swatchesTitleList.includes(el)) {
30
+ swatchChange = true;
31
+ swatches?.push({
32
+ optionTitle: el,
33
+ optionType: 'rectangle_list',
34
+ optionValues: []
35
+ });
36
+ }
37
+ });
38
+ if (!options) return [];
39
+ setDefaultSwatches(swatches, options);
40
+ if (swatches?.length && (swatchChange || colorChange)) {
41
+ window?.parent?.postMessage?.(JSON.stringify({
42
+ type: 'update-swatches',
43
+ swatches
44
+ }), '*');
45
+ changeSwatches(swatches);
46
+ }
47
+ };
48
+ const getColorDefault = (label, color)=>{
49
+ const colorByLabel = label ? variantPresets.colorPreset[label.toLocaleLowerCase()] : undefined;
50
+ const colorArray = colorByLabel ? [
51
+ colorByLabel
52
+ ] : [];
53
+ const firstColor = color?.[0];
54
+ if (!firstColor && colorArray.length) colorChange = true;
55
+ return firstColor ? [
56
+ firstColor
57
+ ] : colorArray;
58
+ };
59
+ const getProductOptionsLabelByName = (options, name)=>{
60
+ const labels = [];
61
+ const optionByName = options.find((op)=>op.name === name);
62
+ optionByName?.values.forEach((val)=>{
63
+ labels.push(val.label ?? '');
64
+ });
65
+ return labels;
66
+ };
67
+ const getSwatchesOptionsLabel = (options)=>{
68
+ const labels = [];
69
+ options.forEach((op)=>{
70
+ labels.push(op.label ?? '');
71
+ return;
72
+ });
73
+ return labels;
74
+ };
75
+ const setDefaultSwatches = (swatches, options)=>{
76
+ if (swatches) {
77
+ swatches?.map((sw)=>{
78
+ const productLabels = getProductOptionsLabelByName(options, sw.optionTitle);
79
+ const swLabels = getSwatchesOptionsLabel(sw.optionValues);
80
+ productLabels.forEach((label)=>{
81
+ if (!swLabels.includes(label)) {
82
+ sw.optionValues.push({
83
+ label,
84
+ colors: getColorDefault(label),
85
+ imageUrl: ''
86
+ });
87
+ }
88
+ });
89
+ sw.optionValues.map((op)=>{
90
+ return {
91
+ ...op,
92
+ colors: getColorDefault(op.label, op.colors)
93
+ };
94
+ });
95
+ });
96
+ }
97
+ return swatches;
98
+ };
99
+ const fetchProductValueLabel = async (fetcher)=>{
100
+ const initVariables = {};
101
+ const query = async (variables)=>{
102
+ const response = await fetcher([
103
+ productValueLabel_generated.ProductOptionNameDocument,
104
+ variables
105
+ ]);
106
+ return response;
107
+ };
108
+ return query(initVariables);
109
+ };
110
+
111
+ exports.default = useInitialSwatchesOptions;
package/dist/cjs/index.js CHANGED
@@ -83,6 +83,7 @@ var useProduct = require('./hooks/useProduct.js');
83
83
  var useProductList = require('./hooks/useProductList.js');
84
84
  var useSuspenseFetch = require('./hooks/useSuspenseFetch.js');
85
85
  var useSwatchesOptions = require('./hooks/useSwatchesOptions.js');
86
+ var useInitialSwatchesOptions = require('./hooks/useInitialSwatchesOptions.js');
86
87
  var shop$1 = require('./types/shop.js');
87
88
  var globalStyle = require('./types/global-style.js');
88
89
  var getCollection = require('./helpers/queries/get-collection.js');
@@ -283,6 +284,7 @@ exports.useProductListSettings = useProductList.useProductListSettings;
283
284
  exports.useProductListStyles = useProductList.useProductListStyles;
284
285
  exports.useSuspenseFetch = useSuspenseFetch.default;
285
286
  exports.useSwatchesOptions = useSwatchesOptions.default;
287
+ exports.useInitialSwatchesOptions = useInitialSwatchesOptions.default;
286
288
  exports.ShopType = shop$1;
287
289
  exports.OptionNormalStyle = globalStyle.OptionNormalStyle;
288
290
  exports.OptionSpecialStyle = globalStyle.OptionSpecialStyle;
@@ -57,6 +57,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
57
57
  advanced: advanced
58
58
  }),
59
59
  /*#__PURE__*/ jsx(children.type, {
60
+ className: advanced?.cssClass,
60
61
  ...children.props,
61
62
  style,
62
63
  builderAttrs,
@@ -74,7 +75,7 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
74
75
  }),
75
76
  /*#__PURE__*/ jsx("div", {
76
77
  style: style,
77
- className: `${props.uid}`,
78
+ className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
78
79
  ...builderAttrs,
79
80
  children: children
80
81
  })
@@ -97,6 +97,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, ...passPr
97
97
  },
98
98
  styles: item.styles,
99
99
  setting: item.settings,
100
+ advanced: {
101
+ cssClass: item?.advanced?.cssClass
102
+ },
100
103
  ...passProps,
101
104
  rawChildren: item.childrens.map((id)=>{
102
105
  return {
@@ -126,6 +129,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, ...passPr
126
129
  },
127
130
  styles: item.styles,
128
131
  setting: item.settings,
132
+ advanced: {
133
+ cssClass: item?.advanced?.cssClass
134
+ },
129
135
  isText: componentTexts.includes(item.tag) ? true : null,
130
136
  ...passProps
131
137
  });
@@ -0,0 +1,54 @@
1
+ const colorPreset = {
2
+ black: '#000000',
3
+ white: '#FFFFFF',
4
+ gray: '#808080',
5
+ red: '#FF0000',
6
+ blue: '#0000FF',
7
+ green: '#008000',
8
+ yellow: '#FFFF00',
9
+ orange: '#FFA500',
10
+ pink: '#FFC0CB',
11
+ purple: '#800080',
12
+ brown: '#A52A2A',
13
+ cyan: '#00FFFF',
14
+ magenta: '#FF00FF',
15
+ teal: '#008080',
16
+ navy: '#000080',
17
+ maroon: '#800000',
18
+ gold: '#FFD700',
19
+ silver: '#C0C0C0',
20
+ beige: '#F5F5DC',
21
+ ivory: '#FFFFF0',
22
+ lavender: '#E6E6FA',
23
+ indigo: '#4B0082',
24
+ coral: '#FF7F50',
25
+ mint: '#98FF98',
26
+ 'sky blue': '#87CEEB',
27
+ salmon: '#FA8072',
28
+ olive: '#808000',
29
+ lilac: '#C8A2C8',
30
+ peach: '#FFDAB9',
31
+ turquoise: '#40E0D0',
32
+ ruby: '#E0115F',
33
+ bronze: '#CD7F32',
34
+ slate: '#708090',
35
+ charcoal: '#36454F',
36
+ sand: '#C2B280',
37
+ mauve: '#E0B0FF',
38
+ tangerine: '#FF4500',
39
+ 'mint green': '#00FF99',
40
+ 'forest green': '#228B22',
41
+ 'ruby red': '#9B111E',
42
+ marigold: '#FFB928',
43
+ eggplant: '#990066',
44
+ 'coral pink': '#F88379',
45
+ mustard: '#FFDB58',
46
+ 'sky gray': '#B0C4DE',
47
+ 'dusty rose': '#FF9BAE',
48
+ 'olive green': '#556B2F',
49
+ coffee: '#6F4E37',
50
+ 'lilac gray': '#C8A2C8',
51
+ 'steel blue': '#4682B4'
52
+ };
53
+
54
+ export { colorPreset };
@@ -0,0 +1,9 @@
1
+ const ProductOptionNameDocument = `
2
+ query productOptionName($limit: Int, $offset: Int) {
3
+ productOptionName(
4
+ limit: $limit,
5
+ offset: $offset
6
+ )
7
+ }`;
8
+
9
+ export { ProductOptionNameDocument };
@@ -56,6 +56,7 @@ function composeAdvanceStyle(data, tag) {
56
56
  ];
57
57
  Object.keys(data).forEach((attr)=>{
58
58
  const value = data[attr];
59
+ if (attr === 'cssClass') return;
59
60
  if (value === undefined || value === null) return;
60
61
  const hasBoxShadow = data.hasBoxShadow ? data.hasBoxShadow : {};
61
62
  if (typeof value === 'object') {
@@ -2,11 +2,12 @@ import { ProductsDocument } from '../../graphql/queries/products.generated.js';
2
2
  import { calculateFirstProduct } from './get-collection.js';
3
3
  import { fetchVariants, fetchMedias } from './get-product.js';
4
4
 
5
- const getProducts = async (fetcher, { ids, isSample, isStorefront })=>{
5
+ const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
6
6
  const products = await loopFetchProducts(fetcher, {
7
7
  ids,
8
8
  isSample,
9
- isStorefront
9
+ isStorefront,
10
+ defaultSelectedProductCount
10
11
  });
11
12
  if (!products) {
12
13
  throw new Error('Product not found');
@@ -59,8 +60,9 @@ const fetchProducts = async (fetcher, variables)=>{
59
60
  variables
60
61
  ]);
61
62
  };
62
- const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront })=>{
63
- const numberOfProducts = (ids?.length == 0 ? 4 : ids?.length) ?? 4;
63
+ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
64
+ const defaultNumberOfProducts = defaultSelectedProductCount || 4;
65
+ const numberOfProducts = (ids?.length == 0 ? defaultNumberOfProducts : ids?.length) ?? defaultNumberOfProducts;
64
66
  const productsPerPage = 8; // number of products per page
65
67
  let variables; // variables of collection query
66
68
  let productAfterFetcher; // product after of collection query
@@ -4,14 +4,15 @@ import { generateProductsQueryKey } from '../../helpers/query.js';
4
4
  import { useIsSampleProduct, useIsStorefrontProduct } from '../shop.js';
5
5
  import { useFetchHandle } from '../useFetchHandle.js';
6
6
 
7
- const useProductsQuery = (ids, options)=>{
7
+ const useProductsQuery = (ids, options, defaultSelectedProductCount)=>{
8
8
  const fetcher = useFetchHandle();
9
9
  const isSample = useIsSampleProduct();
10
10
  const isStorefront = useIsStorefrontProduct();
11
11
  return useSWR(ids ? generateProductsQueryKey({
12
12
  ids,
13
13
  isSample,
14
- isStorefront
14
+ isStorefront,
15
+ defaultSelectedProductCount
15
16
  }) : null, async ([, arg])=>{
16
17
  return getProducts(fetcher, arg);
17
18
  }, options);
@@ -0,0 +1,107 @@
1
+ import useSWR from 'swr';
2
+ import { ProductOptionNameDocument } from '../graphql/queries/product-value-label.generated.js';
3
+ import { colorPreset } from '../components/src/product/helpers/variant-presets.js';
4
+ import { useSwatches } from './shop.js';
5
+ import { useFetchHandle } from './useFetchHandle.js';
6
+ import { useShopStore } from '../contexts/ShopContext.js';
7
+
8
+ let swatchChange = false;
9
+ let colorChange = false;
10
+ const useInitialSwatchesOptions = (options)=>{
11
+ const fetcher = useFetchHandle();
12
+ const changeSwatches = useShopStore((s)=>s.changeSwatches);
13
+ const { swatches } = useSwatches();
14
+ const { data: productOptionName } = useSWR([
15
+ '/query/productOptionName',
16
+ {}
17
+ ], async ()=>fetchProductValueLabel(fetcher), {
18
+ revalidateOnMount: true
19
+ });
20
+ const swatchesTitleList = [];
21
+ swatches?.forEach((el)=>{
22
+ swatchesTitleList.push(el.optionTitle);
23
+ });
24
+ productOptionName?.productOptionName?.forEach((el)=>{
25
+ if (!swatchesTitleList.includes(el)) {
26
+ swatchChange = true;
27
+ swatches?.push({
28
+ optionTitle: el,
29
+ optionType: 'rectangle_list',
30
+ optionValues: []
31
+ });
32
+ }
33
+ });
34
+ if (!options) return [];
35
+ setDefaultSwatches(swatches, options);
36
+ if (swatches?.length && (swatchChange || colorChange)) {
37
+ window?.parent?.postMessage?.(JSON.stringify({
38
+ type: 'update-swatches',
39
+ swatches
40
+ }), '*');
41
+ changeSwatches(swatches);
42
+ }
43
+ };
44
+ const getColorDefault = (label, color)=>{
45
+ const colorByLabel = label ? colorPreset[label.toLocaleLowerCase()] : undefined;
46
+ const colorArray = colorByLabel ? [
47
+ colorByLabel
48
+ ] : [];
49
+ const firstColor = color?.[0];
50
+ if (!firstColor && colorArray.length) colorChange = true;
51
+ return firstColor ? [
52
+ firstColor
53
+ ] : colorArray;
54
+ };
55
+ const getProductOptionsLabelByName = (options, name)=>{
56
+ const labels = [];
57
+ const optionByName = options.find((op)=>op.name === name);
58
+ optionByName?.values.forEach((val)=>{
59
+ labels.push(val.label ?? '');
60
+ });
61
+ return labels;
62
+ };
63
+ const getSwatchesOptionsLabel = (options)=>{
64
+ const labels = [];
65
+ options.forEach((op)=>{
66
+ labels.push(op.label ?? '');
67
+ return;
68
+ });
69
+ return labels;
70
+ };
71
+ const setDefaultSwatches = (swatches, options)=>{
72
+ if (swatches) {
73
+ swatches?.map((sw)=>{
74
+ const productLabels = getProductOptionsLabelByName(options, sw.optionTitle);
75
+ const swLabels = getSwatchesOptionsLabel(sw.optionValues);
76
+ productLabels.forEach((label)=>{
77
+ if (!swLabels.includes(label)) {
78
+ sw.optionValues.push({
79
+ label,
80
+ colors: getColorDefault(label),
81
+ imageUrl: ''
82
+ });
83
+ }
84
+ });
85
+ sw.optionValues.map((op)=>{
86
+ return {
87
+ ...op,
88
+ colors: getColorDefault(op.label, op.colors)
89
+ };
90
+ });
91
+ });
92
+ }
93
+ return swatches;
94
+ };
95
+ const fetchProductValueLabel = async (fetcher)=>{
96
+ const initVariables = {};
97
+ const query = async (variables)=>{
98
+ const response = await fetcher([
99
+ ProductOptionNameDocument,
100
+ variables
101
+ ]);
102
+ return response;
103
+ };
104
+ return query(initVariables);
105
+ };
106
+
107
+ export { useInitialSwatchesOptions as default };
package/dist/esm/index.js CHANGED
@@ -84,6 +84,7 @@ export { useCheckAvailableVariantInStock, useCurrentVariant, useCurrentVariantIn
84
84
  export { useProductList, useProductListProducts, useProductListSettings, useProductListStyles } from './hooks/useProductList.js';
85
85
  export { default as useSuspenseFetch } from './hooks/useSuspenseFetch.js';
86
86
  export { default as useSwatchesOptions } from './hooks/useSwatchesOptions.js';
87
+ export { default as useInitialSwatchesOptions } from './hooks/useInitialSwatchesOptions.js';
87
88
  import * as shop from './types/shop.js';
88
89
  export { shop as ShopType };
89
90
  export { OptionNormalStyle, OptionSpecialStyle } from './types/global-style.js';
@@ -107,7 +107,7 @@ type Ratio$1 = {
107
107
  };
108
108
  type FlexDirectionProp = 'row' | 'column' | 'row-reverse' | 'column-reverse';
109
109
  type TransformProp = 'default' | 'capitalize' | 'uppercase' | 'lowercase' | 'none';
110
- type BaseProps<Setting = unknown, Style = unknown, Advanced = unknown> = {
110
+ type BaseProps<Setting = unknown, Style = unknown, Advanced = Record<string, any>> = {
111
111
  builderProps?: {
112
112
  /** Unique id of component */
113
113
  uid?: string;
@@ -117,7 +117,7 @@ type BaseProps<Setting = unknown, Style = unknown, Advanced = unknown> = {
117
117
  setting?: Setting;
118
118
  advanced?: Advanced;
119
119
  };
120
- type BasePropsWrap<S = unknown, Style = unknown, A = unknown> = BaseProps<S, Style, A> & {
120
+ type BasePropsWrap<S = unknown, Style = unknown, A = Record<string, any>> = BaseProps<S, Style, A> & {
121
121
  builderAttrs?: Record<string, any>;
122
122
  style?: React.CSSProperties;
123
123
  };
@@ -203,6 +203,7 @@ type Mapped$5<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
203
203
  };
204
204
  devices?: ResponsiveConfig<U>;
205
205
  emptyOnClear?: boolean;
206
+ showVideo?: boolean;
206
207
  } : {
207
208
  id: K;
208
209
  label?: string;
@@ -234,6 +235,7 @@ type Mapped$5<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
234
235
  active?: boolean;
235
236
  };
236
237
  emptyOnClear?: boolean;
238
+ showVideo?: boolean;
237
239
  default?: T;
238
240
  };
239
241
  type SharedControlType<T> = {
@@ -641,7 +643,7 @@ type BackgroundControlType<T> = SharedControlType<T> & {
641
643
  value?: Background;
642
644
  };
643
645
  type Background = {
644
- type: 'color' | 'image';
646
+ type: 'color' | 'image' | 'video';
645
647
  color?: string;
646
648
  image?: {
647
649
  src?: string;
@@ -653,6 +655,9 @@ type Background = {
653
655
  position?: BgPosition;
654
656
  repeat?: BgRepeat;
655
657
  attachment?: BgAttachment;
658
+ video?: string;
659
+ loop?: boolean;
660
+ lazyLoad?: boolean;
656
661
  };
657
662
  type BgSize = 'cover' | 'contain';
658
663
  type BgRepeat = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
@@ -793,6 +798,10 @@ type SwatchesLinkControlType<T> = SharedControlType<T> & {
793
798
  id?: string;
794
799
  type: 'swatchesLink';
795
800
  };
801
+ type VariantSwatchesPresetControlType<T> = SharedControlType<T> & {
802
+ id?: string;
803
+ type: 'variant:presets';
804
+ };
796
805
 
797
806
  type LayoutControlType<T> = SharedControlType<T> & {
798
807
  type: 'layout';
@@ -887,7 +896,7 @@ type StepsGuide<T> = {
887
896
  [K in keyof T]-?: Mapped<K, T[K]>;
888
897
  }[keyof T];
889
898
 
890
- 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> | StepsGuide<T>;
899
+ 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> | VariantSwatchesPresetControlType<T> | ProductListControlType<T> | CollectionBannerControlType<T> | Ratio<T> | StickyDisplayControlType<T> | SyncProductPropertiesControlType<T> | StepsGuide<T>;
891
900
  type Setting<P extends BaseProps> = {
892
901
  id: 'setting';
893
902
  note?: string;
@@ -9465,6 +9474,7 @@ type FetchProductsParams = {
9465
9474
  ids: string[];
9466
9475
  isSample?: boolean;
9467
9476
  isStorefront?: boolean;
9477
+ defaultSelectedProductCount?: number;
9468
9478
  };
9469
9479
 
9470
9480
  declare const generateProductQueryKey: (args: FetchProductParams) => ['query/product', FetchProductParams];
@@ -9553,7 +9563,7 @@ declare const useCollectionsQuery: (variable: CollectionsQueryVariables, options
9553
9563
 
9554
9564
  declare const useProductQuery: (productId?: string, options?: SWRConfiguration<ProductSelectFragment>) => swr__internal.SWRResponse<ProductSelectFragment, any, Partial<swr__internal.PublicConfiguration<ProductSelectFragment, any, (arg: ["query/product", FetchProductParams]) => swr__internal.FetcherResponse<ProductSelectFragment>>> | undefined>;
9555
9565
 
9556
- declare const useProductsQuery: (ids?: string[], options?: SWRConfiguration<ProductsQueryResponse>) => swr__internal.SWRResponse<ProductsQueryResponse, any, Partial<swr__internal.PublicConfiguration<ProductsQueryResponse, any, (arg: ["query/products", FetchProductsParams]) => swr__internal.FetcherResponse<ProductsQueryResponse>>> | undefined>;
9566
+ declare const useProductsQuery: (ids?: string[], options?: SWRConfiguration<ProductsQueryResponse>, defaultSelectedProductCount?: number) => swr__internal.SWRResponse<ProductsQueryResponse, any, Partial<swr__internal.PublicConfiguration<ProductsQueryResponse, any, (arg: ["query/products", FetchProductsParams]) => swr__internal.FetcherResponse<ProductsQueryResponse>>> | undefined>;
9557
9567
 
9558
9568
  declare const useCurrentDevice: () => NameDevices;
9559
9569
 
@@ -9695,6 +9705,8 @@ declare const useSuspenseFetch: <T>(key: string | any[], promise: () => Promise<
9695
9705
 
9696
9706
  declare const useSwatchesOptions: (options?: ProductOption[]) => ProductOption[];
9697
9707
 
9708
+ declare const useInitialSwatchesOptions: (options?: ProductOption[]) => never[] | undefined;
9709
+
9698
9710
  type PublishedThemePageSelectFragment = Pick<PublishedThemePage, 'id' | 'name' | 'handle' | 'isMobile' | 'sectionPosition'> & {
9699
9711
  pageSections?: Maybe<Array<Maybe<Pick<PublishedPageSection, 'cid' | 'component' | 'id'>>>>;
9700
9712
  themePageCustomSections?: Maybe<Array<Maybe<Pick<PublishedCustomSection, 'cid' | 'component' | 'id' | 'type'>>>>;
@@ -9706,4 +9718,4 @@ type PublishedThemePageSelectFragment = Pick<PublishedThemePage, 'id' | 'name' |
9706
9718
 
9707
9719
  declare const getProductBySlug: (fetcher: FetchFunc, slug?: string) => Promise<ProductSelectFragment>;
9708
9720
 
9709
- 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, LaiProductReviewsWidgetType, 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, StampedWidgetType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TypographyProps, TypographySetting, TypographySettingV2, TypographyType, TypographyV2Attrs, TypographyV2Props, VariantSelectFragment, VitalsWidgetType, WiserWidgetType, WrapRenderChildren, 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, isColumnDirectionExist, 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, useIsSyncProduct, 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 };
9721
+ 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, LaiProductReviewsWidgetType, 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, StampedWidgetType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TypographyProps, TypographySetting, TypographySettingV2, TypographyType, TypographyV2Attrs, TypographyV2Props, VariantSelectFragment, VitalsWidgetType, WiserWidgetType, WrapRenderChildren, 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, isColumnDirectionExist, 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, useInitialSwatchesOptions, useIsSampleProduct, useIsStorefrontProduct, useIsSyncProduct, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.22.1",
3
+ "version": "1.22.4",
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.21.8"
28
+ "@gem-sdk/styles": "1.22.4"
29
29
  },
30
30
  "dependencies": {
31
31
  "react-error-boundary": "4.0.10",