@gem-sdk/components 2.0.0-dev.351 → 2.0.0-dev.353

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 (49) hide show
  1. package/dist/cjs/article/setting/configs/ArticleAuthor/uiV2.js +9 -2
  2. package/dist/cjs/article/setting/configs/ArticleDate/uiV2.js +13 -6
  3. package/dist/cjs/article/setting/configs/ArticleExcerpt/settings.js +1 -1
  4. package/dist/cjs/article/setting/configs/ArticleExcerpt/uiV2.js +11 -1
  5. package/dist/cjs/article/setting/configs/ArticleImage/presets.js +3 -3
  6. package/dist/cjs/article/setting/configs/ArticleReadMore/presets.js +9 -9
  7. package/dist/cjs/article/setting/configs/ArticleReadMore/settings.js +4 -4
  8. package/dist/cjs/article/setting/configs/ArticleReadMore/uiV2.js +16 -12
  9. package/dist/cjs/stock-counter/components/StockCounter.js +104 -112
  10. package/dist/cjs/stock-counter/components/StockCounter.liquid.js +116 -141
  11. package/dist/cjs/stock-counter/components/common/getAttrs.js +44 -0
  12. package/dist/cjs/stock-counter/components/common/getClasses.js +68 -0
  13. package/dist/cjs/stock-counter/components/common/getContent.js +71 -0
  14. package/dist/cjs/stock-counter/components/common/getInlineCss.js +39 -0
  15. package/dist/cjs/stock-counter/components/common/getStyles.js +73 -0
  16. package/dist/cjs/stock-counter/components/hook/useStockCounter.js +37 -0
  17. package/dist/cjs/stock-counter/const.js +0 -6
  18. package/dist/cjs/stock-counter/helpers.js +0 -14
  19. package/dist/cjs/stock-counter/index.js +3 -1
  20. package/dist/cjs/stock-counter/setting/StockCounter.js +2 -2
  21. package/dist/cjs/stock-counter/setting/configs/presets.js +3 -0
  22. package/dist/cjs/stock-counter/setting/configs/{settings.js → settingsV2.js} +211 -42
  23. package/dist/cjs/stock-counter/setting/configs/uiV2.js +228 -41
  24. package/dist/esm/article/setting/configs/ArticleAuthor/uiV2.js +9 -2
  25. package/dist/esm/article/setting/configs/ArticleDate/uiV2.js +13 -6
  26. package/dist/esm/article/setting/configs/ArticleExcerpt/settings.js +1 -1
  27. package/dist/esm/article/setting/configs/ArticleExcerpt/uiV2.js +11 -1
  28. package/dist/esm/article/setting/configs/ArticleImage/presets.js +3 -3
  29. package/dist/esm/article/setting/configs/ArticleReadMore/presets.js +9 -9
  30. package/dist/esm/article/setting/configs/ArticleReadMore/settings.js +4 -4
  31. package/dist/esm/article/setting/configs/ArticleReadMore/uiV2.js +16 -12
  32. package/dist/esm/stock-counter/components/StockCounter.js +106 -114
  33. package/dist/esm/stock-counter/components/StockCounter.liquid.js +116 -141
  34. package/dist/esm/stock-counter/components/common/getAttrs.js +39 -0
  35. package/dist/esm/stock-counter/components/common/getClasses.js +60 -0
  36. package/dist/esm/stock-counter/components/common/getContent.js +68 -0
  37. package/dist/esm/stock-counter/components/common/getInlineCss.js +37 -0
  38. package/dist/esm/stock-counter/components/common/getStyles.js +67 -0
  39. package/dist/esm/stock-counter/components/hook/useStockCounter.js +35 -0
  40. package/dist/esm/stock-counter/const.js +1 -4
  41. package/dist/esm/stock-counter/helpers.js +1 -14
  42. package/dist/esm/stock-counter/index.js +3 -1
  43. package/dist/esm/stock-counter/setting/StockCounter.js +2 -2
  44. package/dist/esm/stock-counter/setting/configs/presets.js +3 -0
  45. package/dist/esm/stock-counter/setting/configs/settingsV2.js +438 -0
  46. package/dist/esm/stock-counter/setting/configs/uiV2.js +228 -41
  47. package/dist/types/index.d.ts +13 -5
  48. package/package.json +1 -1
  49. package/dist/esm/stock-counter/setting/configs/settings.js +0 -269
@@ -58,10 +58,17 @@ const uiV2 = [
58
58
  noRecordHistory: true
59
59
  }
60
60
  }
61
- },
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ label: {
66
+ en: 'SEO'
67
+ },
68
+ controls: [
62
69
  {
63
70
  label: {
64
- en: 'SEO'
71
+ en: 'SEO tag'
65
72
  },
66
73
  setting: {
67
74
  id: 'htmlTag'
@@ -40,28 +40,35 @@ const uiV2 = [
40
40
  noRecordHistory: true
41
41
  }
42
42
  }
43
- },
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ label: {
48
+ en: 'Display option'
49
+ },
50
+ controls: [
44
51
  {
45
52
  label: {
46
- en: 'SEO'
53
+ en: 'Date format'
47
54
  },
48
55
  setting: {
49
- id: 'htmlTag'
56
+ id: 'dateFormat'
50
57
  }
51
58
  }
52
59
  ]
53
60
  },
54
61
  {
55
62
  label: {
56
- en: 'Display option'
63
+ en: 'SEO'
57
64
  },
58
65
  controls: [
59
66
  {
60
67
  label: {
61
- en: 'Date format'
68
+ en: 'SEO tag'
62
69
  },
63
70
  setting: {
64
- id: 'dateFormat'
71
+ id: 'htmlTag'
65
72
  }
66
73
  }
67
74
  ]
@@ -95,8 +95,8 @@ const ArticleExcerptSettings = [
95
95
  },
96
96
  {
97
97
  id: 'hasLineClamp',
98
+ label: 'Max lines',
98
99
  type: 'toggle',
99
- label: 'Has Line Clamp',
100
100
  devices: {
101
101
  desktop: {
102
102
  default: true
@@ -51,7 +51,17 @@ const uiV2 = [
51
51
  {
52
52
  id: 'hasLineClamp',
53
53
  label: {
54
- en: 'Max line'
54
+ en: 'Max lines'
55
+ },
56
+ setting: {
57
+ id: 'hasLineClamp'
58
+ }
59
+ },
60
+ {
61
+ id: 'lineClamp',
62
+ conditionDisplay: 'hasLineClamp === true',
63
+ label: {
64
+ en: 'Number of lines'
55
65
  },
56
66
  setting: {
57
67
  id: 'lineClamp'
@@ -2,9 +2,9 @@
2
2
 
3
3
  const ArticleImagePresets = [
4
4
  {
5
- id: 'article-title',
5
+ id: 'article-image',
6
6
  name: {
7
- en: 'Article Title'
7
+ en: 'Article Image'
8
8
  },
9
9
  icon: {
10
10
  desktop: `<svg width="84" height="13" viewBox="0 0 84 13" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -15,7 +15,7 @@ const ArticleImagePresets = [
15
15
  },
16
16
  components: [
17
17
  {
18
- tag: 'ArticleTitle',
18
+ tag: 'ArticleImage',
19
19
  settings: {
20
20
  htmlTag: 'h1',
21
21
  linkArticle: true
@@ -39,10 +39,10 @@ const ArticleReadMorePresets = [
39
39
  height: 'Auto',
40
40
  padding: {
41
41
  type: 'custom',
42
- top: 'var(--g-s-xs)',
43
- bottom: 'var(--g-s-xs)',
44
- left: 'var(--g-s-l)',
45
- right: 'var(--g-s-l)'
42
+ top: 'var(--g-s-m)',
43
+ bottom: 'var(--g-s-m)',
44
+ left: 'var(--g-s-xl)',
45
+ right: 'var(--g-s-xl)'
46
46
  },
47
47
  gap: ''
48
48
  }
@@ -73,11 +73,11 @@ const ArticleReadMorePresets = [
73
73
  width: 'Auto',
74
74
  height: 'Auto',
75
75
  padding: {
76
- top: 'auto',
77
- bottom: 'auto',
78
- left: 'auto',
79
- right: 'auto',
80
- type: 'custom'
76
+ type: 'custom',
77
+ top: 'var(--g-s-m)',
78
+ bottom: 'var(--g-s-m)',
79
+ left: 'var(--g-s-xl)',
80
+ right: 'var(--g-s-xl)'
81
81
  },
82
82
  gap: ''
83
83
  }
@@ -394,7 +394,7 @@ const ArticleReadMoreSettings = [
394
394
  },
395
395
  {
396
396
  id: 'alignBtn',
397
- label: 'Alignment',
397
+ label: 'Align',
398
398
  type: 'option:value',
399
399
  options: [
400
400
  {
@@ -421,7 +421,7 @@ const ArticleReadMoreSettings = [
421
421
  ],
422
422
  devices: {
423
423
  desktop: {
424
- default: 'left'
424
+ default: 'center'
425
425
  }
426
426
  }
427
427
  },
@@ -671,7 +671,7 @@ const ArticleReadMoreSettings = [
671
671
  },
672
672
  {
673
673
  id: 'alignText',
674
- label: 'Alignment',
674
+ label: 'Align',
675
675
  type: 'option:value',
676
676
  options: [
677
677
  {
@@ -698,7 +698,7 @@ const ArticleReadMoreSettings = [
698
698
  ],
699
699
  devices: {
700
700
  desktop: {
701
- default: 'left'
701
+ default: 'center'
702
702
  }
703
703
  }
704
704
  },
@@ -95,10 +95,10 @@ const uiV2 = [
95
95
  },
96
96
  compoDefaultValue: {
97
97
  default: {
98
- top: '16px',
99
- right: '16px',
100
- bottom: '16px',
101
- left: '16px',
98
+ top: '12px',
99
+ right: '24px',
100
+ bottom: '12px',
101
+ left: '24px',
102
102
  linked: false
103
103
  }
104
104
  }
@@ -276,10 +276,10 @@ const uiV2 = [
276
276
  },
277
277
  compoDefaultValue: {
278
278
  default: {
279
- top: '16px',
280
- right: '16px',
281
- bottom: '16px',
282
- left: '16px',
279
+ top: '12px',
280
+ right: '24px',
281
+ bottom: '12px',
282
+ left: '24px',
283
283
  linked: false
284
284
  }
285
285
  }
@@ -423,7 +423,6 @@ const uiV2 = [
423
423
  ]
424
424
  },
425
425
  {
426
- conditionDisplay: `readMoreType == 'button'`,
427
426
  controls: [
428
427
  {
429
428
  label: {
@@ -432,15 +431,17 @@ const uiV2 = [
432
431
  setting: {
433
432
  id: 'alignBtn'
434
433
  },
434
+ conditionDisplay: `readMoreType == 'button'`,
435
+ conditionEnable: "globalSizeBtn.width !== '100%'",
435
436
  options: {
436
437
  labelVariant: 'primary',
437
- fullWidth: true
438
+ fullWidth: true,
439
+ disableMessage: `This option is disabled because the width is set to 100%`
438
440
  }
439
441
  }
440
442
  ]
441
443
  },
442
444
  {
443
- conditionDisplay: `readMoreType == 'text'`,
444
445
  controls: [
445
446
  {
446
447
  label: {
@@ -449,9 +450,12 @@ const uiV2 = [
449
450
  setting: {
450
451
  id: 'alignText'
451
452
  },
453
+ conditionDisplay: `readMoreType == 'text'`,
454
+ conditionEnable: "globalSizeText.width !== '100%'",
452
455
  options: {
453
456
  labelVariant: 'primary',
454
- fullWidth: true
457
+ fullWidth: true,
458
+ disableMessage: `This option is disabled because the width is set to 100%`
455
459
  }
456
460
  }
457
461
  ]
@@ -4,136 +4,128 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
- var core = require('@gem-sdk/core');
8
7
  var React = require('react');
9
- var _const = require('../const.js');
10
- var helpers = require('../helpers.js');
11
8
  var useStockCounterInteraction = require('../hooks/useStockCounterInteraction.js');
9
+ var getInlineCss = require('./common/getInlineCss.js');
10
+ var getClasses = require('./common/getClasses.js');
11
+ var getStyles = require('./common/getStyles.js');
12
+ require('next/link');
13
+ require('@gem-sdk/core');
14
+ var getAttrs = require('./common/getAttrs.js');
15
+ var system = require('@gem-sdk/system');
16
+ var useStockCounter = require('./hook/useStockCounter.js');
12
17
 
13
18
  const StockCounter = ({ setting, styles, builderProps })=>{
14
- const { width, alignment, typography, color, iconColor, textColor, displayProgressBar, progressBarHeight, roundedBorder, effect, typo } = styles ?? {};
15
- const { remainingPercentage, showIcon, icon, template, outOfStockMessage, continueSelling, unlimitedQuantityMessage, hiddenCounterWhenOutOfStock } = setting ?? {};
16
- const variant = core.useCurrentVariant();
19
+ const { displayProgressBar, borderRadius } = styles ?? {};
20
+ const { showIcon, icon, layout = 'full', oosIcon } = setting ?? {};
21
+ const { getMessage, isOutOfStock, inventoryQuantity } = useStockCounter.useStockCounter(setting, styles);
17
22
  const elementRef = React.useRef(null);
18
- const inventoryQuantity = React.useMemo(()=>{
19
- return Number(variant ? variant.inventoryQuantity : 0);
20
- }, [
21
- variant
22
- ]);
23
- const manageInventory = variant ? variant.manageInventory : true;
24
- const inventoryPolicy = variant ? variant.inventoryPolicy : 'deny';
25
- const mainColor = textColor || 'brand';
26
23
  const { dispatchStockCounterInteraction } = useStockCounterInteraction.useStockCounterInteraction({
27
24
  element: elementRef,
28
25
  uid: builderProps?.uid
29
26
  });
30
- const genVariable = (variableName)=>{
31
- return `var(--g-${variableName})`;
32
- };
33
- const isOutOfStock = manageInventory && inventoryQuantity <= _const.NO_PRODUCT_LEFT && inventoryPolicy !== _const.CONTINUE_SELLING_WHEN_OUT_OF_STOCK;
34
- const isContinueShopping = inventoryPolicy === _const.CONTINUE_SELLING_WHEN_OUT_OF_STOCK && inventoryQuantity <= _const.NO_PRODUCT_LEFT;
35
- const isUnlimitedQuantity = !manageInventory && unlimitedQuantityMessage;
27
+ const inlineCss = getInlineCss.getInlineCss(builderProps?.uid, borderRadius);
36
28
  const showProgressBar = displayProgressBar !== false && !isOutOfStock;
37
- function getMessage() {
38
- if (isUnlimitedQuantity) return helpers.transformHighlighTag(unlimitedQuantityMessage, mainColor);
39
- if (isOutOfStock) return helpers.transformHighlighTag(outOfStockMessage || '', mainColor);
40
- if (isContinueShopping) return helpers.transformHighlighTag(continueSelling || '', mainColor);
41
- return helpers.transformHighlighTag(helpers.transformNumberTag(template || '', mainColor, inventoryQuantity), mainColor);
42
- }
43
- const getVariableStyle = React.useMemo(()=>{
44
- if (typo) {
45
- return typo && typo.custom ? helpers.convertSizeToWidth(core.composeTypographyV2(typo.custom)) : {};
46
- }
47
- return typography && typography.custom ? helpers.convertSizeToWidth(core.composeTypography(typography.custom)) : {};
48
- }, [
49
- typo,
50
- typography
51
- ]);
52
- const typoWidth = React.useMemo(()=>{
53
- if (typo) {
54
- return typo && !typo.custom ? genVariable(core.getShortName(`typography-${typo.type}-fontSize`)) : undefined;
55
- }
56
- return typography && !typography.custom ? genVariable(core.getShortName(`typography-${typography.type}-fontSize`)) : undefined;
57
- }, [
58
- typo,
59
- typography
60
- ]);
61
- const appendTypoClass = core.composeTypographyClassName(styles?.typo, styles?.typography);
62
- const appendTypoStyle = core.composeTypographyStyle(styles?.typo, styles?.typography);
29
+ const showText = layout !== 'progress-bar';
30
+ const progressBarClasses = system.createClass({
31
+ ...getClasses.getProgressBarClasses(styles)
32
+ });
33
+ const progressBarStyles = system.createStyle({
34
+ ...getStyles.getProgressBarStyles(styles, setting)
35
+ });
36
+ const containerStyles = system.createStyle({
37
+ ...getStyles.getContainerStyles(styles)
38
+ });
39
+ const containerClasses = system.createClass({
40
+ ...getClasses.getContainerClasses(setting)
41
+ });
42
+ const wrapperStyles = system.createStyle({
43
+ ...getStyles.getWrapperStyles(styles)
44
+ });
45
+ const wrapperIconClasses = system.createClass({
46
+ ...getClasses.getWrapperIconClasses(setting)
47
+ });
48
+ const iconClasses = system.createClass({
49
+ ...getClasses.getIconClasses()
50
+ });
51
+ const iconStyles = (isOutOfStock)=>{
52
+ return system.createStyle({
53
+ ...getStyles.getIconStyles(styles, setting, isOutOfStock)
54
+ });
55
+ };
56
+ const textClasses = (isOutOfStock)=>{
57
+ return system.createClass({
58
+ ...getClasses.getTextClasses(styles, isOutOfStock)
59
+ });
60
+ };
61
+ const textStyles = (isOutOfStock)=>{
62
+ return system.createStyle({
63
+ ...getStyles.getTextStyles(styles, isOutOfStock)
64
+ });
65
+ };
66
+ const wrapperClasses = system.createClass({
67
+ ...getClasses.getWrapperClasses(setting, isOutOfStock)
68
+ });
69
+ const wrapperAttrs = system.createAttr({
70
+ ...getAttrs.getWrapperAttrs(builderProps)
71
+ });
63
72
  React.useEffect(()=>{
64
73
  dispatchStockCounterInteraction(inventoryQuantity);
65
74
  // eslint-disable-next-line react-hooks/exhaustive-deps
66
75
  }, [
67
76
  inventoryQuantity
68
77
  ]);
69
- return /*#__PURE__*/ jsxRuntime.jsx("div", {
70
- style: {
71
- ...core.makeStyleResponsive('ta', alignment)
72
- },
78
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
79
+ ...wrapperAttrs,
80
+ style: wrapperStyles,
73
81
  ref: elementRef,
74
- className: core.cls({
75
- 'gp-opacity-50': isOutOfStock && hiddenCounterWhenOutOfStock
76
- }),
77
- "data-id": builderProps?.uid,
78
- children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
79
- className: "gp-inline-block",
80
- style: {
81
- ...core.makeStyleResponsive('w', core.makeWidth(width)),
82
- ...core.makeStyle({
83
- c: core.getSingleColorVariable(textColor)
84
- })
85
- },
86
- children: [
87
- /*#__PURE__*/ jsxRuntime.jsxs("div", {
88
- className: "gp-flex gp-items-baseline",
89
- children: [
90
- showIcon && /*#__PURE__*/ jsxRuntime.jsx("div", {
91
- dangerouslySetInnerHTML: {
92
- __html: icon || ''
93
- },
94
- className: "gp-mr-1 gp-shrink-0 gp-bg-[length:60px_100%]",
95
- style: {
96
- ...core.makeStyle({
97
- c: core.getSingleColorVariable(iconColor),
98
- w: typoWidth
99
- }),
100
- ...getVariableStyle
101
- }
102
- }),
103
- /*#__PURE__*/ jsxRuntime.jsx("p", {
104
- dangerouslySetInnerHTML: {
105
- __html: getMessage()
106
- },
107
- className: appendTypoClass,
108
- style: {
109
- ...appendTypoStyle,
110
- ...core.getStyleShadow({
111
- value: typo?.custom?.textShadow,
112
- styleAppliedFor: 'text-shadow',
113
- isEnableShadow: typo?.custom?.textShadow?.type !== 'none'
114
- })
115
- }
116
- })
117
- ]
118
- }),
119
- showProgressBar && /*#__PURE__*/ jsxRuntime.jsx("div", {
120
- style: {
121
- ...core.makeStyleResponsive('h', progressBarHeight),
122
- ...core.makeStyle({
123
- bg: 'linear-gradient(90deg, #eee 50%, transparent 50%)',
124
- bgc: core.getSingleColorVariable(color),
125
- bgp: `${remainingPercentage}% center`
126
- })
127
- },
128
- className: core.cls('gp-relative gp-mt-2 gp-w-full -gp-scale-100 !gp-bg-[length:200%]', {
129
- 'gp-rounded-md': roundedBorder,
130
- "before:gp-absolute before:gp-eft-0 before:gp-h-full before:gp-w-full before:gp-animate-shift before:gp-content-['']": effect,
131
- 'before:gp-bg-stock-counter-animate before:gp-bg-[length:60px_100%] before:gp-shadow-stock-counter': effect,
132
- 'before:gp-rounded-md': effect && roundedBorder
82
+ className: wrapperClasses,
83
+ children: [
84
+ /*#__PURE__*/ jsxRuntime.jsx("style", {
85
+ children: inlineCss
86
+ }),
87
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
88
+ className: containerClasses,
89
+ style: containerStyles,
90
+ children: [
91
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
92
+ className: wrapperIconClasses,
93
+ children: [
94
+ showIcon && (isOutOfStock ? /*#__PURE__*/ jsxRuntime.jsx("div", {
95
+ dangerouslySetInnerHTML: {
96
+ __html: oosIcon || ''
97
+ },
98
+ className: iconClasses,
99
+ style: iconStyles(true)
100
+ }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
101
+ dangerouslySetInnerHTML: {
102
+ __html: icon || ''
103
+ },
104
+ className: iconClasses,
105
+ style: iconStyles(false)
106
+ })),
107
+ showText && (isOutOfStock ? /*#__PURE__*/ jsxRuntime.jsx("p", {
108
+ dangerouslySetInnerHTML: {
109
+ __html: getMessage()
110
+ },
111
+ className: textClasses(true),
112
+ style: textStyles(true)
113
+ }) : /*#__PURE__*/ jsxRuntime.jsx("p", {
114
+ dangerouslySetInnerHTML: {
115
+ __html: getMessage()
116
+ },
117
+ className: textClasses(false),
118
+ style: textStyles(false)
119
+ }))
120
+ ]
121
+ }),
122
+ showProgressBar && /*#__PURE__*/ jsxRuntime.jsx("div", {
123
+ style: progressBarStyles,
124
+ className: progressBarClasses
133
125
  })
134
- })
135
- ]
136
- })
126
+ ]
127
+ })
128
+ ]
137
129
  });
138
130
  };
139
131