@gem-sdk/components 2.0.0-dev.702 → 2.0.0-dev.704

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.
Files changed (72) hide show
  1. package/dist/cjs/article/setting/configs/ArticleReadMore/settings.js +86 -134
  2. package/dist/cjs/button/components/common/helpers.js +2 -9
  3. package/dist/cjs/button/components/common/styles.js +14 -81
  4. package/dist/cjs/button/setting/configs/settings.js +85 -133
  5. package/dist/cjs/coupon/common/classes.js +3 -12
  6. package/dist/cjs/coupon/common/styles.js +7 -17
  7. package/dist/cjs/coupon/setting/config/settings.js +60 -100
  8. package/dist/cjs/form/setting/submit-button/configs/settings.js +103 -250
  9. package/dist/cjs/helpers.js +4 -1
  10. package/dist/cjs/image/components/NextImage.liquid.js +2 -2
  11. package/dist/cjs/index.js +4 -0
  12. package/dist/cjs/post-purchase/product/settings/product-image/setting-v2.js +2 -2
  13. package/dist/cjs/post-purchase/product/settings/product-image/uiV2.js +72 -2
  14. package/dist/cjs/product/components/DynamicCheckout/common/styles.js +12 -12
  15. package/dist/cjs/product/components/ProductBadge/index.liquid.js +12 -3
  16. package/dist/cjs/product/components/ProductBadge/utils/generateLiquidContent.js +2 -2
  17. package/dist/cjs/product/components/ProductButton/common/styles.js +4 -14
  18. package/dist/cjs/product/components/ProductDescription/index.liquid.js +21 -4
  19. package/dist/cjs/product/components/ProductImagesV2/common/common.js +1 -1
  20. package/dist/cjs/product/setting/constant/bundle-layout/horizontalThree.js +1 -0
  21. package/dist/cjs/product/setting/constant/bundle-layout/horizontalTwo.js +1 -0
  22. package/dist/cjs/product/setting/constant/bundle-layout/verticalThree.js +1 -0
  23. package/dist/cjs/product/setting/constant/bundle-layout/verticalTwo.js +1 -0
  24. package/dist/cjs/product/setting/dynamic-checkout/configs/settings.js +86 -134
  25. package/dist/cjs/product/setting/product-badge/configs/settings.js +5 -0
  26. package/dist/cjs/product/setting/product-button/configs/settings.js +142 -222
  27. package/dist/cjs/product/setting/product-description/configs/settings.js +5 -0
  28. package/dist/cjs/product/setting/product-view-more/configs/settings.js +100 -148
  29. package/dist/cjs/stock-counter/components/StockCounter.js +0 -2
  30. package/dist/cjs/stock-counter/components/StockCounter.liquid.js +44 -3
  31. package/dist/cjs/stock-counter/components/common/getContent.js +19 -10
  32. package/dist/cjs/stock-counter/helpers.js +20 -3
  33. package/dist/cjs/stock-counter/index.js +0 -1
  34. package/dist/cjs/stock-counter/setting/configs/settingsV2.js +5 -0
  35. package/dist/cjs/third-party/setting/Selleasy/index.js +5 -5
  36. package/dist/esm/article/setting/configs/ArticleReadMore/settings.js +86 -134
  37. package/dist/esm/button/components/common/helpers.js +2 -9
  38. package/dist/esm/button/components/common/styles.js +16 -81
  39. package/dist/esm/button/setting/configs/settings.js +85 -133
  40. package/dist/esm/coupon/common/classes.js +3 -12
  41. package/dist/esm/coupon/common/styles.js +7 -17
  42. package/dist/esm/coupon/setting/config/settings.js +60 -100
  43. package/dist/esm/form/setting/submit-button/configs/settings.js +103 -250
  44. package/dist/esm/helpers.js +4 -1
  45. package/dist/esm/image/components/NextImage.liquid.js +2 -2
  46. package/dist/esm/index.js +1 -0
  47. package/dist/esm/post-purchase/product/settings/product-image/setting-v2.js +2 -2
  48. package/dist/esm/post-purchase/product/settings/product-image/uiV2.js +72 -2
  49. package/dist/esm/product/components/DynamicCheckout/common/styles.js +12 -12
  50. package/dist/esm/product/components/ProductBadge/index.liquid.js +13 -4
  51. package/dist/esm/product/components/ProductBadge/utils/generateLiquidContent.js +2 -2
  52. package/dist/esm/product/components/ProductButton/common/styles.js +4 -14
  53. package/dist/esm/product/components/ProductDescription/index.liquid.js +22 -5
  54. package/dist/esm/product/components/ProductImagesV2/common/common.js +1 -1
  55. package/dist/esm/product/setting/constant/bundle-layout/horizontalThree.js +1 -0
  56. package/dist/esm/product/setting/constant/bundle-layout/horizontalTwo.js +1 -0
  57. package/dist/esm/product/setting/constant/bundle-layout/verticalThree.js +1 -0
  58. package/dist/esm/product/setting/constant/bundle-layout/verticalTwo.js +1 -0
  59. package/dist/esm/product/setting/dynamic-checkout/configs/settings.js +86 -134
  60. package/dist/esm/product/setting/product-badge/configs/settings.js +5 -0
  61. package/dist/esm/product/setting/product-button/configs/settings.js +142 -222
  62. package/dist/esm/product/setting/product-description/configs/settings.js +5 -0
  63. package/dist/esm/product/setting/product-view-more/configs/settings.js +100 -148
  64. package/dist/esm/stock-counter/components/StockCounter.js +0 -2
  65. package/dist/esm/stock-counter/components/StockCounter.liquid.js +46 -5
  66. package/dist/esm/stock-counter/components/common/getContent.js +19 -11
  67. package/dist/esm/stock-counter/helpers.js +20 -4
  68. package/dist/esm/stock-counter/index.js +0 -1
  69. package/dist/esm/stock-counter/setting/configs/settingsV2.js +5 -0
  70. package/dist/esm/third-party/setting/Selleasy/index.js +5 -5
  71. package/dist/types/index.d.ts +40 -28
  72. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  import { template, dataStringify, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import { getSettingPreloadData } from '../../../helpers.js';
2
+ import { getDynamicSourceLocales, getSettingPreloadData } from '../../../helpers.js';
3
3
  import { checkDiscountContentProductBadge } from './utils/common.js';
4
4
  import { generateBadgeContent } from './utils/generateLiquidContent.js';
5
5
  import { renderBadgeInFirstTime } from './utils/renderBadgeLiquid.js';
@@ -10,7 +10,7 @@ import { getSubWrapperAttrs, getContainerAttrs, getTextContentAttrs, getImageAtt
10
10
  import { IS_LIQUID } from './constants.js';
11
11
 
12
12
  const ProductBadge = (props)=>{
13
- const { styles, setting } = props;
13
+ const { styles, setting, builderProps, pageContext } = props;
14
14
  const isTextBadge = setting?.shape !== 'image';
15
15
  const isDiscountContent = checkDiscountContentProductBadge(setting?.displayContent);
16
16
  const containerStyle = createStyle({
@@ -74,7 +74,6 @@ const ProductBadge = (props)=>{
74
74
  })
75
75
  });
76
76
  const createDataState = createStateOrContext({
77
- displayContent: setting?.displayContent,
78
77
  minPrice: `{{ minPriceValue | replace: '"', '\\"' | escape }}`,
79
78
  variantIDs: '{{ product.variants | map: "id" | json | escape }}',
80
79
  variantInventoryQuantities: '{{ product.variants | map: "inventory_quantity" | json | escape }}',
@@ -87,9 +86,18 @@ const ProductBadge = (props)=>{
87
86
  productTags: '{{ product.tags | join: "," }}',
88
87
  isTextBadge
89
88
  });
89
+ const { displayContent, translate } = setting ?? {};
90
+ const displayContentVal = getDynamicSourceLocales({
91
+ val: displayContent?.trim(),
92
+ uid: builderProps?.uid,
93
+ settingId: 'displayContent',
94
+ isLiquid: true,
95
+ pageContext,
96
+ translate
97
+ });
90
98
  return template`
91
99
  {% if product %}
92
- ${generateBadgeContent(setting?.displayContent)}
100
+ ${generateBadgeContent(displayContentVal, pageContext?.isPreviewing)}
93
101
  ${renderBadgeInFirstTime(setting?.displayTrigger, isDiscountContent, isTextBadge)}
94
102
  <gp-product-badge
95
103
  ${{
@@ -98,6 +106,7 @@ const ProductBadge = (props)=>{
98
106
  gp-data='${dataStringify(createDataState)}'
99
107
  class="containerClass"
100
108
  style="${containerStyle}"
109
+ data-display-content="${pageContext?.isPreviewing ? displayContentVal : `{{${displayContentVal}}}`}"
101
110
  >
102
111
  <div class="${wrapperClass}">
103
112
  <div
@@ -1,6 +1,6 @@
1
- const generateBadgeContent = (content)=>{
1
+ const generateBadgeContent = (content, isPreviewing)=>{
2
2
  return `
3
- {% assign content = "${content?.trim()}" %}
3
+ {% assign content = ${isPreviewing ? JSON.stringify(content) : content} %}
4
4
 
5
5
  {%if content.size > 0 %}
6
6
  {% if variant.compare_at_price and variant.compare_at_price > 0 %}
@@ -49,18 +49,8 @@ const getSoldOutButtonStyles = (styles)=>{
49
49
  const mapStylesByDevice = (target, key, value)=>{
50
50
  if (value) {
51
51
  target[key] = {
52
- desktop: {
53
- normal: value.desktop?.normal,
54
- hover: target[key]?.desktop?.hover
55
- },
56
- tablet: {
57
- normal: value.tablet?.normal,
58
- hover: target[key]?.tablet?.hover
59
- },
60
- mobile: {
61
- normal: value.mobile?.normal,
62
- hover: target[key]?.mobile?.hover
63
- }
52
+ normal: value?.normal,
53
+ hover: target[key]?.hover
64
54
  };
65
55
  }
66
56
  };
@@ -68,10 +58,10 @@ const getSoldOutButtonStyles = (styles)=>{
68
58
  mapStylesByDevice(buttonSoldOutStyles, 'boxShadowBtnV2', oosShadowV2);
69
59
  mapStylesByDevice(buttonSoldOutStyles, 'roundedBtnV2', oosRoundedV2);
70
60
  mapStylesByDevice(buttonSoldOutStyles, 'borderBtnV2', oosBorderV2);
71
- if (oosTextColorV2?.desktop?.normal) {
61
+ if (oosTextColorV2?.normal) {
72
62
  buttonSoldOutStyles.typo = buttonSoldOutStyles.typo ?? {};
73
63
  buttonSoldOutStyles.typo.attrs = buttonSoldOutStyles.typo.attrs ?? {};
74
- buttonSoldOutStyles.typo.attrs.color = oosTextColorV2.desktop.normal;
64
+ buttonSoldOutStyles.typo.attrs.color = oosTextColorV2.normal;
75
65
  }
76
66
  return {
77
67
  ...getButtonBaseStyles(),
@@ -1,13 +1,13 @@
1
1
  import { makeStyleResponsive, makeLineClamp, template, dataStringify, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import { getSettingPreloadData } from '../../../helpers.js';
2
+ import { getDynamicSourceLocales, getSettingPreloadData } from '../../../helpers.js';
3
3
  import { createClass, createStyle, createAttr, createStateOrContext, LiquidIf, Liquid, LiquidUnless, If } from '@gem-sdk/system';
4
4
  import { getClasses, getButtonClasses, getClassPreBuilt } from './common/getClasses.js';
5
5
  import { getTextStyle, getButtonStyle, getStaticCss } from './common/getStyle.js';
6
6
  import { ICON_SVG } from './common/const.js';
7
7
 
8
8
  const ProductDescription = (props)=>{
9
- const { setting, advanced, builderProps } = props;
10
- const { htmlTag } = setting ?? {};
9
+ const { setting, advanced, builderProps, pageContext } = props;
10
+ const { htmlTag, translate, viewMoreText, viewLessText } = setting ?? {};
11
11
  const Tag = htmlTag === 'html' ? 'div' : 'p';
12
12
  const gpDescriptionClasses = createClass({
13
13
  'gp-product-description': true,
@@ -58,11 +58,28 @@ const ProductDescription = (props)=>{
58
58
  },
59
59
  textStyle
60
60
  });
61
+ const viewMoreTextDisplay = getDynamicSourceLocales({
62
+ val: viewMoreText,
63
+ uid: builderProps?.uid,
64
+ settingId: 'viewMoreText',
65
+ pageContext,
66
+ translate
67
+ });
68
+ const viewLessTextDisplay = getDynamicSourceLocales({
69
+ val: viewLessText,
70
+ uid: builderProps?.uid,
71
+ settingId: 'viewLessText',
72
+ pageContext,
73
+ translate
74
+ });
61
75
  return LiquidIf(noDescriptionHtml, '', Liquid(template`
62
76
  <gp-product-description-v2
63
77
  ${attr}
64
78
  class="${gpDescriptionClasses}"
65
- gp-data='${dataStringify(stateData).replaceAll("'", '&#039;')}'>
79
+ gp-data='${dataStringify(stateData).replaceAll("'", '&#039;')}'
80
+ data-view-more-text="${viewMoreTextDisplay}"
81
+ data-view-less-text="${viewLessTextDisplay}"
82
+ >
66
83
  <style>${textDescriptionCss}</style>
67
84
  <div class="${classPreBuilt}" ></div>
68
85
  ${LiquidUnless('product', `<p>Product not found</p>`, template`<${Tag} ${textAttr} class="${textClasses}" style="${textStyle}">
@@ -70,7 +87,7 @@ const ProductDescription = (props)=>{
70
87
  </${Tag}>
71
88
  ${LiquidUnless(noDescriptionHtml, template`<button type="button" class="${buttonClasses}" style="${buttonStyle}">
72
89
  <span class="${showMoreTextClasses}">
73
- ${If(false, setting?.viewLessText || '', setting?.viewMoreText)}
90
+ ${If(false, viewLessTextDisplay?.toString(), viewMoreTextDisplay?.toString())}
74
91
  </span>
75
92
  ${If(setting?.enableViewMoreIcon, template`<span class="${showMoreIconClasses}">${ICON_SVG}</span>`, ' ')}
76
93
  </button>`)}`)}
@@ -333,7 +333,7 @@ const getPaddingBottomByShapeSetting = (shapeSetting)=>{
333
333
  };
334
334
  return;
335
335
  }
336
- const value = aspectRatio?.[device] !== 'auto' && !!aspectRatio?.[device] ? aspectRatio?.[device]?.split('/').reverse().join('') : '{%if media.height%} {{media.height}} / {{media.width}} {%else%} 100 / 100 {%endif%}';
336
+ const value = aspectRatio?.[device] !== 'auto' && !!aspectRatio?.[device] ? aspectRatio?.[device]?.split('/').reverse().join('/') : '{%if media.height%} {{media.height}} / {{media.width}} {%else%} 100 / 100 {%endif%}';
337
337
  result = {
338
338
  ...result,
339
339
  [device]: `calc((${value})*100%)`
@@ -58,6 +58,7 @@ const horizontalThree = [
58
58
  settings: {
59
59
  contentType: 'text',
60
60
  displayContent: 'SALE {percent_discount}',
61
+ translate: 'displayContent',
61
62
  displayTrigger: [
62
63
  {
63
64
  conditionType: 'exact_or_above',
@@ -57,6 +57,7 @@ const horizontalTwo = [
57
57
  settings: {
58
58
  contentType: 'text',
59
59
  displayContent: 'SALE {percent_discount}',
60
+ translate: 'displayContent',
60
61
  displayTrigger: [
61
62
  {
62
63
  conditionType: 'exact_or_above',
@@ -198,6 +198,7 @@ const verticalThree = [
198
198
  settings: {
199
199
  contentType: 'text',
200
200
  displayContent: 'SALE {percent_discount}',
201
+ translate: 'displayContent',
201
202
  displayTrigger: [
202
203
  {
203
204
  conditionType: 'exact_or_above',
@@ -198,6 +198,7 @@ const verticalTwo = [
198
198
  settings: {
199
199
  contentType: 'text',
200
200
  displayContent: 'SALE {percent_discount}',
201
+ translate: 'displayContent',
201
202
  displayTrigger: [
202
203
  {
203
204
  conditionType: 'exact_or_above',
@@ -57,52 +57,36 @@ const DynamicCheckoutSettings = [
57
57
  {
58
58
  id: 'backgroundColorV2',
59
59
  type: 'color-picker-v2',
60
- devices: {
61
- desktop: {
62
- default: {
63
- normal: 'brand',
64
- hover: 'highlight'
65
- }
66
- }
60
+ default: {
61
+ normal: 'brand',
62
+ hover: 'highlight'
67
63
  },
68
64
  compoDefaultValue: {
69
- desktop: {
70
- default: {
71
- normal: 'brand',
72
- hover: 'highlight'
73
- }
74
- }
65
+ normal: 'brand',
66
+ hover: 'highlight'
75
67
  },
76
68
  enableGradient: true
77
69
  },
78
70
  {
79
71
  id: 'backgroundImage',
80
72
  type: 'background-image',
81
- devices: {
82
- desktop: {
83
- default: {
84
- normal: {},
85
- hover: {}
86
- }
87
- }
73
+ default: {
74
+ normal: {},
75
+ hover: {}
88
76
  },
89
77
  compoDefaultValue: {
90
- desktop: {
91
- default: {
92
- normal: {
93
- image: {
94
- src: 'https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/',
95
- width: 1200,
96
- height: 480
97
- }
98
- },
99
- hover: {
100
- image: {
101
- src: 'https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/',
102
- width: 1200,
103
- height: 480
104
- }
105
- }
78
+ normal: {
79
+ image: {
80
+ src: 'https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/',
81
+ width: 1200,
82
+ height: 480
83
+ }
84
+ },
85
+ hover: {
86
+ image: {
87
+ src: 'https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/',
88
+ width: 1200,
89
+ height: 480
106
90
  }
107
91
  }
108
92
  }
@@ -139,44 +123,36 @@ const DynamicCheckoutSettings = [
139
123
  {
140
124
  id: 'borderBtnV2',
141
125
  type: 'border-v2',
142
- devices: {
143
- desktop: {
144
- default: {
145
- normal: {
146
- borderType: 'none',
147
- border: 'none',
148
- borderWidth: '1px',
149
- width: '1px 1px 1px 1px',
150
- color: '#121212',
151
- isCustom: true
152
- },
153
- hover: {
154
- borderType: 'none',
155
- border: 'none',
156
- borderWidth: '1px',
157
- width: '1px 1px 1px 1px',
158
- color: '#121212',
159
- isCustom: true
160
- }
161
- }
126
+ default: {
127
+ normal: {
128
+ borderType: 'none',
129
+ border: 'none',
130
+ borderWidth: '1px',
131
+ width: '1px 1px 1px 1px',
132
+ color: '#121212',
133
+ isCustom: true
134
+ },
135
+ hover: {
136
+ borderType: 'none',
137
+ border: 'none',
138
+ borderWidth: '1px',
139
+ width: '1px 1px 1px 1px',
140
+ color: '#121212',
141
+ isCustom: true
162
142
  }
163
143
  },
164
144
  compoDefaultValue: {
165
- desktop: {
166
- default: {
167
- normal: {
168
- border: 'solid',
169
- color: '#212121',
170
- width: '1px',
171
- borderWidth: '1px'
172
- },
173
- hover: {
174
- border: 'solid',
175
- color: '#212121',
176
- width: '1px',
177
- borderWidth: '1px'
178
- }
179
- }
145
+ normal: {
146
+ border: 'solid',
147
+ color: '#212121',
148
+ width: '1px',
149
+ borderWidth: '1px'
150
+ },
151
+ hover: {
152
+ border: 'solid',
153
+ color: '#212121',
154
+ width: '1px',
155
+ borderWidth: '1px'
180
156
  }
181
157
  }
182
158
  },
@@ -245,69 +221,53 @@ const DynamicCheckoutSettings = [
245
221
  {
246
222
  id: 'boxShadowBtnV2',
247
223
  type: 'shadow-v2',
248
- devices: {
249
- desktop: {
250
- default: {
251
- normal: {}
252
- }
253
- }
224
+ default: {
225
+ normal: {}
254
226
  },
255
227
  compoDefaultValue: {
256
- desktop: {
257
- default: {
258
- normal: {
259
- type: 'shadow-1',
260
- distance: '4px',
261
- blur: '4px',
262
- spread: '0px',
263
- color: '#121212',
264
- angle: 45
265
- }
266
- }
228
+ normal: {
229
+ type: 'shadow-1',
230
+ distance: '4px',
231
+ blur: '4px',
232
+ spread: '0px',
233
+ color: '#121212',
234
+ angle: 45
267
235
  }
268
236
  }
269
237
  },
270
238
  {
271
239
  id: 'roundedBtnV2',
272
240
  type: 'corner-v2',
273
- devices: {
274
- desktop: {
275
- default: {
276
- normal: {
277
- btrr: '0px',
278
- bblr: '0px',
279
- bbrr: '0px',
280
- btlr: '0px',
281
- radiusType: 'none'
282
- },
283
- hover: {
284
- btrr: '0px',
285
- bblr: '0px',
286
- bbrr: '0px',
287
- btlr: '0px',
288
- radiusType: 'none'
289
- }
290
- }
241
+ default: {
242
+ normal: {
243
+ btrr: '0px',
244
+ bblr: '0px',
245
+ bbrr: '0px',
246
+ btlr: '0px',
247
+ radiusType: 'none'
248
+ },
249
+ hover: {
250
+ btrr: '0px',
251
+ bblr: '0px',
252
+ bbrr: '0px',
253
+ btlr: '0px',
254
+ radiusType: 'none'
291
255
  }
292
256
  },
293
257
  compoDefaultValue: {
294
- desktop: {
295
- default: {
296
- normal: {
297
- btrr: '8px',
298
- bblr: '8px',
299
- bbrr: '8px',
300
- btlr: '8px',
301
- radiusType: 'rounded'
302
- },
303
- hover: {
304
- btrr: '8px',
305
- bblr: '8px',
306
- bbrr: '8px',
307
- btlr: '8px',
308
- radiusType: 'rounded'
309
- }
310
- }
258
+ normal: {
259
+ btrr: '8px',
260
+ bblr: '8px',
261
+ bbrr: '8px',
262
+ btlr: '8px',
263
+ radiusType: 'rounded'
264
+ },
265
+ hover: {
266
+ btrr: '8px',
267
+ bblr: '8px',
268
+ bbrr: '8px',
269
+ btlr: '8px',
270
+ radiusType: 'rounded'
311
271
  }
312
272
  }
313
273
  },
@@ -406,19 +366,11 @@ const DynamicCheckoutSettings = [
406
366
  {
407
367
  id: 'textColorHover',
408
368
  type: 'color-picker-v2',
409
- devices: {
410
- desktop: {
411
- default: {
412
- hover: 'text-3'
413
- }
414
- }
369
+ default: {
370
+ hover: 'text-3'
415
371
  },
416
372
  compoDefaultValue: {
417
- desktop: {
418
- default: {
419
- hover: 'text-3'
420
- }
421
- }
373
+ hover: 'text-3'
422
374
  }
423
375
  },
424
376
  {
@@ -132,6 +132,11 @@ const ProductBadgeSettings = [
132
132
  message: `{inventory_quantity} Only work with product enable “Track inventory”`,
133
133
  closable: true
134
134
  },
135
+ {
136
+ id: 'translate',
137
+ type: 'input',
138
+ default: 'displayContent'
139
+ },
135
140
  {
136
141
  id: 'contentType',
137
142
  label: 'Shape',