@gem-sdk/components 2.0.0-dev.524 → 2.0.0-dev.525

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.
@@ -15,7 +15,7 @@ const ProductList = (props)=>{
15
15
  const { setting, styles, pageContext } = props;
16
16
  const isSalesPage = pageContext?.pageType === 'GP_FUNNEL_PAGE';
17
17
  if (isSalesPage) return '';
18
- const { hasRelatedExclude, relatedExcludeTrim, collectionID, isLatest, isGrid, numberOfProducts, productListId, productListHandles, sortedBy, isReverse, productSrc, productSetting, isSorted, relatedTag } = index.getDataLiquid(props);
18
+ const { hasRelatedExclude, relatedExcludeTrim, collectionID, isLatest, isGrid, numberOfProducts, productListId, productListHandles, sortedBy, isReverse, productSrc, productNumber, isSorted, relatedTag } = index.getDataLiquid(props);
19
19
  const getRelatedProduct = ()=>{
20
20
  return core.template /* liquid */ `
21
21
  ${core.RenderIf(productSrc === 'RelatedProduct', `
@@ -128,7 +128,7 @@ const ProductList = (props)=>{
128
128
  assign target_collection = null
129
129
  assign productSrc = '${productSrc}'
130
130
  assign c = 0
131
- assign limit = ${isGrid ? collectionID === 'latest' ? productSrc === 'RelatedProduct' ? numberOfProducts : productSetting?.numOfSelectedProducts || 4 : numberOfProducts : numberOfProducts}
131
+ assign limit = ${productNumber ?? 4}
132
132
  if request.page_type == 'collection' or preview_page_type == 'collection'
133
133
  assign target_collection = collection
134
134
  if target_collection == empty or target_collection == null
@@ -219,6 +219,7 @@ const ProductList = (props)=>{
219
219
 
220
220
  ${core.RenderIf(!!styles?.preloadBgImage, `${core.RenderIf(!!styles?.backgroundImage?.desktop?.image?.src, `<link rel="preload" href="${styles?.backgroundImage?.desktop?.image?.src}" as="image" />`)}${core.RenderIf(!!styles?.backgroundImage?.tablet?.image?.src, `<link rel="preload" href="${styles?.backgroundImage?.tablet?.image?.src}" as="image" />`)}${core.RenderIf(!!styles?.backgroundImage?.mobile?.image?.src, `<link rel="preload" href="${styles?.backgroundImage?.mobile?.image?.src}" as="image" />`)}`)}
221
221
 
222
+
222
223
  <div style="${productListStyle}">
223
224
  <div
224
225
  class="${productListWrapClass}"
@@ -7,21 +7,39 @@ var getClass = require('./common/getClass.js');
7
7
  var getStyle = require('./common/getStyle.js');
8
8
 
9
9
  const ProductListItem = (props)=>{
10
- const { pageContext, children } = props;
10
+ const { pageContext, rawChildren } = props;
11
11
  const { productItemStyle } = getStyle.getStyle(props);
12
12
  const { productItemClass, gpProductClass } = getClass.getClass(props);
13
+ const composeChildren = ()=>{
14
+ return core.template`
15
+ ${rawChildren?.map((child, index)=>{
16
+ if (child) {
17
+ return core.template`
18
+ ${core.RenderChildren({
19
+ ...child,
20
+ index: index,
21
+ style: {
22
+ ...child.style,
23
+ ...productItemStyle
24
+ }
25
+ })}
26
+ `;
27
+ }
28
+ })}
29
+ `;
30
+ };
13
31
  return core.template /* liquid */ `
14
32
  <gp-product
15
33
  gp-context='{"variantSelected": {{ variant | json | escape }}, "quantity": 1 , "formId": "{{ product_form_id }}"}'
16
34
  gp-data='{"variantSelected": {{ variant | json | escape }}, "quantity": 1, "productUrl":{{ product.url | json | escape }}, "productHandle":{{ product.handle | json | escape }}, "collectionUrl": {{ collection.url | json | escape }}, "collectionHandle": {{ collection.handle | json | escape }},"pageContext" : ${JSON.stringify(pageContext)}}'
17
35
  class="${gpProductClass}"
18
- style="${productItemStyle}"
36
+
19
37
  >
20
38
  {%- form 'product', product, id: product_form_id, class: 'form contents ${productItemClass}', data-type: 'add-to-cart-form', autocomplete: 'off' -%}
21
39
  <input type="hidden" name="id" value="{{ variant.id }}" />
22
40
  <input type="hidden" min="1" name="quantity" value="{{ quantity }}" />
23
41
  <button type="submit" onclick="return false;" style="display:none;"></button>
24
- ${children ?? ''}
42
+ ${composeChildren()}
25
43
  {%- endform -%}
26
44
  </gp-product>
27
45
  `;
@@ -63,6 +63,7 @@ const getDataLiquid = (props)=>{
63
63
  const sortedArray = (productSetting?.productSrc === 'Collection' || productSetting?.productSrc === 'DynamicCollection') && isSorted ? setting?.orderBy?.split('_') : 'none';
64
64
  const sortedBy = isSorted && sortedArray?.[0] === 'TITLE' ? "| sort: 'title'" : "| sort: 'updated_at'";
65
65
  const isReverse = sortedArray?.[sortedArray.length - 1] === 'DESC';
66
+ const productNumber = isGrid ? collectionID === 'latest' ? productSrc === 'RelatedProduct' ? numberOfProducts : productSetting?.numOfSelectedProducts || 4 : isLatest ? 4 : numberOfProducts : numberOfProducts;
66
67
  return {
67
68
  hasRelatedExclude,
68
69
  relatedExcludeTrim,
@@ -77,7 +78,8 @@ const getDataLiquid = (props)=>{
77
78
  productSrc,
78
79
  productSetting,
79
80
  isSorted,
80
- relatedTag
81
+ relatedTag,
82
+ productNumber
81
83
  };
82
84
  };
83
85
 
@@ -115,17 +115,6 @@ const SettingUIV2 = [
115
115
  linkWithSetting: {
116
116
  name: 'itemPadding',
117
117
  field: 'padding'
118
- },
119
- compoDefaultValue: {
120
- desktop: {
121
- default: {
122
- type: 'custom',
123
- top: '16px',
124
- bottom: '16px',
125
- left: '16px',
126
- right: '16px'
127
- }
128
- }
129
118
  }
130
119
  }
131
120
  },
@@ -328,11 +317,57 @@ const SettingUIV2 = [
328
317
  },
329
318
  {
330
319
  label: {
331
- en: 'Shadow'
320
+ en: 'Shadow',
321
+ cn: '阴影',
322
+ es: 'Sombra'
332
323
  },
333
324
  setting: {
334
325
  id: 'boxShadow',
335
326
  state: 'normal'
327
+ },
328
+ options: {
329
+ updateFields: [
330
+ {
331
+ field: 'normal.enable',
332
+ settingId: 'hasBoxShadow',
333
+ state: 'normal'
334
+ }
335
+ ]
336
+ },
337
+ controlChangeTrigger: {
338
+ settings: [
339
+ {
340
+ condition: `boxShadow.normal.enable === true`,
341
+ source: [
342
+ 'boxShadow',
343
+ 'hasBoxShadow'
344
+ ],
345
+ action: {
346
+ controlId: 'hasBoxShadow',
347
+ groupType: 'advanced',
348
+ controlType: 'advanced',
349
+ state: 'normal',
350
+ newValue: true
351
+ }
352
+ },
353
+ {
354
+ condition: `boxShadow.normal.enable === false`,
355
+ source: [
356
+ 'boxShadow',
357
+ 'hasBoxShadow'
358
+ ],
359
+ action: {
360
+ controlId: 'hasBoxShadow',
361
+ groupType: 'advanced',
362
+ controlType: 'advanced',
363
+ state: 'normal',
364
+ newValue: false
365
+ }
366
+ }
367
+ ],
368
+ options: {
369
+ noRecordHistory: true
370
+ }
336
371
  }
337
372
  }
338
373
  ]
@@ -11,7 +11,7 @@ const ProductList = (props)=>{
11
11
  const { setting, styles, pageContext } = props;
12
12
  const isSalesPage = pageContext?.pageType === 'GP_FUNNEL_PAGE';
13
13
  if (isSalesPage) return '';
14
- const { hasRelatedExclude, relatedExcludeTrim, collectionID, isLatest, isGrid, numberOfProducts, productListId, productListHandles, sortedBy, isReverse, productSrc, productSetting, isSorted, relatedTag } = getDataLiquid(props);
14
+ const { hasRelatedExclude, relatedExcludeTrim, collectionID, isLatest, isGrid, numberOfProducts, productListId, productListHandles, sortedBy, isReverse, productSrc, productNumber, isSorted, relatedTag } = getDataLiquid(props);
15
15
  const getRelatedProduct = ()=>{
16
16
  return template /* liquid */ `
17
17
  ${RenderIf(productSrc === 'RelatedProduct', `
@@ -124,7 +124,7 @@ const ProductList = (props)=>{
124
124
  assign target_collection = null
125
125
  assign productSrc = '${productSrc}'
126
126
  assign c = 0
127
- assign limit = ${isGrid ? collectionID === 'latest' ? productSrc === 'RelatedProduct' ? numberOfProducts : productSetting?.numOfSelectedProducts || 4 : numberOfProducts : numberOfProducts}
127
+ assign limit = ${productNumber ?? 4}
128
128
  if request.page_type == 'collection' or preview_page_type == 'collection'
129
129
  assign target_collection = collection
130
130
  if target_collection == empty or target_collection == null
@@ -215,6 +215,7 @@ const ProductList = (props)=>{
215
215
 
216
216
  ${RenderIf(!!styles?.preloadBgImage, `${RenderIf(!!styles?.backgroundImage?.desktop?.image?.src, `<link rel="preload" href="${styles?.backgroundImage?.desktop?.image?.src}" as="image" />`)}${RenderIf(!!styles?.backgroundImage?.tablet?.image?.src, `<link rel="preload" href="${styles?.backgroundImage?.tablet?.image?.src}" as="image" />`)}${RenderIf(!!styles?.backgroundImage?.mobile?.image?.src, `<link rel="preload" href="${styles?.backgroundImage?.mobile?.image?.src}" as="image" />`)}`)}
217
217
 
218
+
218
219
  <div style="${productListStyle}">
219
220
  <div
220
221
  class="${productListWrapClass}"
@@ -1,23 +1,41 @@
1
- import { template } from '@gem-sdk/core';
1
+ import { template, RenderChildren } from '@gem-sdk/core';
2
2
  import { getClass } from './common/getClass.js';
3
3
  import { getStyle } from './common/getStyle.js';
4
4
 
5
5
  const ProductListItem = (props)=>{
6
- const { pageContext, children } = props;
6
+ const { pageContext, rawChildren } = props;
7
7
  const { productItemStyle } = getStyle(props);
8
8
  const { productItemClass, gpProductClass } = getClass(props);
9
+ const composeChildren = ()=>{
10
+ return template`
11
+ ${rawChildren?.map((child, index)=>{
12
+ if (child) {
13
+ return template`
14
+ ${RenderChildren({
15
+ ...child,
16
+ index: index,
17
+ style: {
18
+ ...child.style,
19
+ ...productItemStyle
20
+ }
21
+ })}
22
+ `;
23
+ }
24
+ })}
25
+ `;
26
+ };
9
27
  return template /* liquid */ `
10
28
  <gp-product
11
29
  gp-context='{"variantSelected": {{ variant | json | escape }}, "quantity": 1 , "formId": "{{ product_form_id }}"}'
12
30
  gp-data='{"variantSelected": {{ variant | json | escape }}, "quantity": 1, "productUrl":{{ product.url | json | escape }}, "productHandle":{{ product.handle | json | escape }}, "collectionUrl": {{ collection.url | json | escape }}, "collectionHandle": {{ collection.handle | json | escape }},"pageContext" : ${JSON.stringify(pageContext)}}'
13
31
  class="${gpProductClass}"
14
- style="${productItemStyle}"
32
+
15
33
  >
16
34
  {%- form 'product', product, id: product_form_id, class: 'form contents ${productItemClass}', data-type: 'add-to-cart-form', autocomplete: 'off' -%}
17
35
  <input type="hidden" name="id" value="{{ variant.id }}" />
18
36
  <input type="hidden" min="1" name="quantity" value="{{ quantity }}" />
19
37
  <button type="submit" onclick="return false;" style="display:none;"></button>
20
- ${children ?? ''}
38
+ ${composeChildren()}
21
39
  {%- endform -%}
22
40
  </gp-product>
23
41
  `;
@@ -61,6 +61,7 @@ const getDataLiquid = (props)=>{
61
61
  const sortedArray = (productSetting?.productSrc === 'Collection' || productSetting?.productSrc === 'DynamicCollection') && isSorted ? setting?.orderBy?.split('_') : 'none';
62
62
  const sortedBy = isSorted && sortedArray?.[0] === 'TITLE' ? "| sort: 'title'" : "| sort: 'updated_at'";
63
63
  const isReverse = sortedArray?.[sortedArray.length - 1] === 'DESC';
64
+ const productNumber = isGrid ? collectionID === 'latest' ? productSrc === 'RelatedProduct' ? numberOfProducts : productSetting?.numOfSelectedProducts || 4 : isLatest ? 4 : numberOfProducts : numberOfProducts;
64
65
  return {
65
66
  hasRelatedExclude,
66
67
  relatedExcludeTrim,
@@ -75,7 +76,8 @@ const getDataLiquid = (props)=>{
75
76
  productSrc,
76
77
  productSetting,
77
78
  isSorted,
78
- relatedTag
79
+ relatedTag,
80
+ productNumber
79
81
  };
80
82
  };
81
83
 
@@ -113,17 +113,6 @@ const SettingUIV2 = [
113
113
  linkWithSetting: {
114
114
  name: 'itemPadding',
115
115
  field: 'padding'
116
- },
117
- compoDefaultValue: {
118
- desktop: {
119
- default: {
120
- type: 'custom',
121
- top: '16px',
122
- bottom: '16px',
123
- left: '16px',
124
- right: '16px'
125
- }
126
- }
127
116
  }
128
117
  }
129
118
  },
@@ -326,11 +315,57 @@ const SettingUIV2 = [
326
315
  },
327
316
  {
328
317
  label: {
329
- en: 'Shadow'
318
+ en: 'Shadow',
319
+ cn: '阴影',
320
+ es: 'Sombra'
330
321
  },
331
322
  setting: {
332
323
  id: 'boxShadow',
333
324
  state: 'normal'
325
+ },
326
+ options: {
327
+ updateFields: [
328
+ {
329
+ field: 'normal.enable',
330
+ settingId: 'hasBoxShadow',
331
+ state: 'normal'
332
+ }
333
+ ]
334
+ },
335
+ controlChangeTrigger: {
336
+ settings: [
337
+ {
338
+ condition: `boxShadow.normal.enable === true`,
339
+ source: [
340
+ 'boxShadow',
341
+ 'hasBoxShadow'
342
+ ],
343
+ action: {
344
+ controlId: 'hasBoxShadow',
345
+ groupType: 'advanced',
346
+ controlType: 'advanced',
347
+ state: 'normal',
348
+ newValue: true
349
+ }
350
+ },
351
+ {
352
+ condition: `boxShadow.normal.enable === false`,
353
+ source: [
354
+ 'boxShadow',
355
+ 'hasBoxShadow'
356
+ ],
357
+ action: {
358
+ controlId: 'hasBoxShadow',
359
+ groupType: 'advanced',
360
+ controlType: 'advanced',
361
+ state: 'normal',
362
+ newValue: false
363
+ }
364
+ }
365
+ ],
366
+ options: {
367
+ noRecordHistory: true
368
+ }
334
369
  }
335
370
  }
336
371
  ]
@@ -3736,6 +3736,7 @@ type ProductListProps = BasePropsWrap<ProductListSetting, ProductListSettingStyl
3736
3736
  className?: string;
3737
3737
  children: React.ReactNode;
3738
3738
  pageContext?: PageContext;
3739
+ rawChildren: any;
3739
3740
  };
3740
3741
 
3741
3742
  type DynamicCheckoutProps = BasePropsWrap<{} & Pick<NonNullable<ButtonProps['setting']>, 'iconAlign' | 'iconSvg' | 'iconVisible'>, ButtonProps['styles'] & {}> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.524",
3
+ "version": "2.0.0-dev.525",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",