@gem-sdk/components 2.0.0-dev.275 → 2.0.0-dev.277

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 (94) hide show
  1. package/dist/cjs/article/components/ArticleReadMore.js +2 -4
  2. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +4 -4
  3. package/dist/cjs/builder.js +4 -8
  4. package/dist/cjs/button/components/Button.js +111 -184
  5. package/dist/cjs/button/components/Button.liquid.js +108 -171
  6. package/dist/cjs/button/components/ButtonIcon.js +17 -0
  7. package/dist/cjs/button/components/ButtonIcon.liquid.js +16 -0
  8. package/dist/cjs/button/components/ButtonLabel.js +18 -0
  9. package/dist/cjs/button/components/ButtonLabel.liquid.js +15 -0
  10. package/dist/cjs/button/components/ButtonLoadingIndicator.liquid.js +12 -0
  11. package/dist/cjs/button/components/common/attributes.js +15 -0
  12. package/dist/cjs/button/components/common/classes.js +55 -0
  13. package/dist/cjs/button/components/common/constants.js +26 -0
  14. package/dist/cjs/button/components/common/data.js +76 -0
  15. package/dist/cjs/button/components/common/helpers.js +131 -0
  16. package/dist/cjs/button/components/common/styles.js +157 -0
  17. package/dist/cjs/button/next.js +2 -6
  18. package/dist/cjs/button/setting/configs/settings.js +5 -1
  19. package/dist/cjs/cart/components/CheckoutNow.js +0 -2
  20. package/dist/cjs/coupon/components/Coupon.js +1 -3
  21. package/dist/cjs/dialog/setting/Dialog.js +7 -580
  22. package/dist/cjs/dialog/setting/configs/settings.js +325 -0
  23. package/dist/cjs/dialog/setting/configs/uiV1.js +288 -0
  24. package/dist/cjs/dialog/setting/configs/uiV2.js +258 -0
  25. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +3 -3
  26. package/dist/cjs/form/components/submit-button/SubmitButton.js +0 -4
  27. package/dist/cjs/index.js +2 -4
  28. package/dist/cjs/index.liquid.js +1 -3
  29. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +2 -5
  30. package/dist/cjs/product/components/DynamicCheckout.js +2 -5
  31. package/dist/cjs/product/components/FileUpload/components/common/index.js +1 -1
  32. package/dist/cjs/product/components/ProductButton.js +2 -3
  33. package/dist/cjs/product/components/ProductButton.liquid.js +3 -3
  34. package/dist/cjs/product/components/ProductDescription/index.liquid.js +1 -2
  35. package/dist/cjs/product/components/ProductViewMore.js +2 -5
  36. package/dist/cjs/product/components/ProductViewMore.liquid.js +2 -2
  37. package/dist/cjs/setting.js +2 -2
  38. package/dist/cjs/text/components/common/getClasses.js +1 -1
  39. package/dist/cjs/third-party/components/PushOwl.js +0 -5
  40. package/dist/esm/article/components/ArticleReadMore.js +1 -3
  41. package/dist/esm/banner/components/HeroBannerItem.liquid.js +4 -4
  42. package/dist/esm/builder.js +1 -5
  43. package/dist/esm/button/components/Button.js +113 -186
  44. package/dist/esm/button/components/Button.liquid.js +109 -172
  45. package/dist/esm/button/components/ButtonIcon.js +13 -0
  46. package/dist/esm/button/components/ButtonIcon.liquid.js +12 -0
  47. package/dist/esm/button/components/ButtonLabel.js +14 -0
  48. package/dist/esm/button/components/ButtonLabel.liquid.js +11 -0
  49. package/dist/esm/button/components/ButtonLoadingIndicator.liquid.js +8 -0
  50. package/dist/esm/button/components/common/attributes.js +13 -0
  51. package/dist/esm/button/components/common/classes.js +49 -0
  52. package/dist/esm/button/components/common/constants.js +24 -0
  53. package/dist/esm/button/components/common/data.js +74 -0
  54. package/dist/esm/button/components/common/helpers.js +118 -0
  55. package/dist/esm/button/components/common/styles.js +148 -0
  56. package/dist/esm/button/next.js +2 -6
  57. package/dist/esm/button/setting/configs/settings.js +5 -1
  58. package/dist/esm/cart/components/CheckoutNow.js +0 -2
  59. package/dist/esm/coupon/components/Coupon.js +1 -3
  60. package/dist/esm/dialog/setting/Dialog.js +7 -580
  61. package/dist/esm/dialog/setting/configs/settings.js +323 -0
  62. package/dist/esm/dialog/setting/configs/uiV1.js +286 -0
  63. package/dist/esm/dialog/setting/configs/uiV2.js +256 -0
  64. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +3 -3
  65. package/dist/esm/form/components/submit-button/SubmitButton.js +0 -4
  66. package/dist/esm/index.js +1 -2
  67. package/dist/esm/index.liquid.js +1 -2
  68. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +1 -4
  69. package/dist/esm/product/components/DynamicCheckout.js +1 -4
  70. package/dist/esm/product/components/FileUpload/components/common/index.js +1 -1
  71. package/dist/esm/product/components/ProductButton.js +1 -2
  72. package/dist/esm/product/components/ProductButton.liquid.js +1 -1
  73. package/dist/esm/product/components/ProductDescription/index.liquid.js +3 -4
  74. package/dist/esm/product/components/ProductViewMore.js +1 -4
  75. package/dist/esm/product/components/ProductViewMore.liquid.js +1 -1
  76. package/dist/esm/setting.js +2 -2
  77. package/dist/esm/text/components/common/getClasses.js +1 -1
  78. package/dist/esm/third-party/components/PushOwl.js +0 -5
  79. package/dist/types/index.d.ts +174 -266
  80. package/package.json +2 -2
  81. package/dist/cjs/button/components/v2/ButtonIcon.js +0 -18
  82. package/dist/cjs/button/components/v2/ButtonLabel.js +0 -25
  83. package/dist/cjs/button/components/v2/ButtonV2.js +0 -140
  84. package/dist/cjs/button/components/v2/ButtonV2.liquid.js +0 -181
  85. package/dist/cjs/button/hooks/useButtonCustomCss.js +0 -88
  86. package/dist/cjs/button/hooks/useButtonStyles.js +0 -93
  87. package/dist/esm/button/components/v2/ButtonIcon.js +0 -14
  88. package/dist/esm/button/components/v2/ButtonLabel.js +0 -21
  89. package/dist/esm/button/components/v2/ButtonV2.js +0 -136
  90. package/dist/esm/button/components/v2/ButtonV2.liquid.js +0 -177
  91. package/dist/esm/button/hooks/useButtonCustomCss.js +0 -84
  92. package/dist/esm/button/hooks/useButtonStyles.js +0 -91
  93. /package/dist/cjs/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  94. /package/dist/esm/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
@@ -3,184 +3,121 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@gem-sdk/core');
6
- var helpers = require('../../helpers.js');
6
+ var system = require('@gem-sdk/system');
7
+ var attributes = require('./common/attributes.js');
8
+ var styles = require('./common/styles.js');
9
+ var classes = require('./common/classes.js');
10
+ var helpers$1 = require('../../helpers.js');
11
+ var ButtonIcon_liquid = require('./ButtonIcon.liquid.js');
12
+ var ButtonLabel_liquid = require('./ButtonLabel.liquid.js');
13
+ var ButtonLoadingIndicator_liquid = require('./ButtonLoadingIndicator.liquid.js');
14
+ var data = require('./common/data.js');
15
+ var helpers = require('./common/helpers.js');
7
16
 
8
- const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isForceValue = false })=>{
9
- const { align, size, backgroundColor, textColor, roundedBtn, iconSpacing, globalSize } = styles;
10
- const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
11
- const [wrapStyle, restStyle] = core.splitStyle([
12
- 'pos',
13
- 'top',
14
- 'left',
15
- 'bottom',
16
- 'right',
17
- 'z'
18
- ], style);
19
- const { Wrap, urlData, shouldRenderLink } = helpers.getInsertLinkData('button', btnLink, htmlType);
20
- const spacingDefault = {
21
- desktop: '8px'
22
- };
23
- const iconSpacingStyle = iconAlign === 'left' ? core.makeStyleResponsive('mr', iconSpacing || spacingDefault) : core.makeStyleResponsive('ml', iconSpacing || spacingDefault);
24
- // fix disabled still display hover color
25
- if (disabled) {
26
- delete backgroundColor?.hover;
27
- delete backgroundColor?.focus;
28
- }
29
- const composeGlobalSize = core.makeGlobalSize(globalSize);
30
- const appendTypoClass = core.composeTypographyClassName(styles?.typo, styles?.typography);
31
- const appendTypoStyle = core.composeTypographyStyle(styles?.typo, styles?.typography);
32
- delete appendTypoStyle['--c'];
33
- const innerBorderCss = `
34
- .${builderProps?.uid}.gp-button-base::before {
35
- content: "";
36
- height: 100%;
37
- width: 100%;
38
- position: absolute;
39
- pointer-events: none;
40
- ${core.composeBorderCss(styles?.borderBtn?.normal)}
41
- ${core.composeCornerCss(styles?.roundedBtn?.normal)}
42
- }
43
-
44
- .${builderProps?.uid}:hover::before {
45
- ${core.composeBorderCss(styles?.borderBtn?.hover)}
46
- ${core.composeCornerCss(styles?.roundedBtn?.hover)}
47
- }
48
-
49
- .${builderProps?.uid}:hover .gp-button-icon {
50
- color: ${core.getSingleColorVariable(styles?.textColor?.hover)};
51
- }
52
-
53
- .${builderProps?.uid} .gp-button-icon {
54
- color: ${core.getSingleColorVariable(styles?.textColor?.normal)};
55
- }
56
-
57
- .${builderProps?.uid}:hover .gp-button-price {
58
- color: ${core.getSingleColorVariable(styles?.textColor?.hover)};
59
- }
60
-
61
- .${builderProps?.uid} .gp-button-price {
62
- color: ${core.getSingleColorVariable(styles?.textColor?.normal)};
63
- }
64
-
65
- .${builderProps?.uid} .gp-product-dot-price {
66
- color: ${core.getSingleColorVariable(styles?.textColor?.normal)};
67
- }
68
-
69
- .${builderProps?.uid}:hover .gp-product-dot-price {
70
- color: ${core.getSingleColorVariable(styles?.textColor?.hover)};
71
- }
72
- `;
73
- const labelValDisplay = isForceValue ? label : helpers.getDynamicSourceLocales({
74
- val: label,
75
- uid: builderProps?.uidTranslate ?? builderProps?.uid,
76
- settingId: translate ?? 'label',
77
- pageContext,
78
- isCapitalize: styles?.typo?.attrs?.transform === 'capitalize',
79
- translate
17
+ const Button = (props)=>{
18
+ const { advanced, className, nodePrice, customAttrs, styles: styles$1 = {}, setting = {}, builderProps, wrapClassName = '' } = props;
19
+ const { iconSvg, loading, btnLink, htmlType, disabled, shouldClearSpace } = setting;
20
+ const { customCss, wrapStyle, restStyle, dataState, dataIdAttr, isShowIcon, isScrollToElement, getArialLabel, getLabelToDisplay, checkIsShowLabel, checkIsEditableLabel } = data.getData(props);
21
+ const { HTMLTag, urlData, shouldRenderLink } = helpers.getInsertLinkData({
22
+ htmlType,
23
+ setting: btnLink,
24
+ defaultTag: 'button',
25
+ isLiquid: true
26
+ });
27
+ const ButtonWrapper = helpers.getButtonWrapper(HTMLTag, isScrollToElement);
28
+ const buttonStyles = system.createStyle({
29
+ ...styles.getButtonStyles(styles$1, nodePrice)
30
+ });
31
+ const buttonIconStyles = system.createStyle({
32
+ ...styles.getButtonIconStyles(styles$1, setting)
33
+ });
34
+ const buttonWrapperStyles = system.createStyle({
35
+ ...styles.getButtonWrapperStyles(restStyle, styles$1)
36
+ });
37
+ const buttonClasses = system.createClass({
38
+ ...classes.getButtonClasses({
39
+ styles: styles$1,
40
+ className,
41
+ shouldRenderLink,
42
+ uid: builderProps?.uid
43
+ })
44
+ });
45
+ const buttonIconClasses = system.createClass({
46
+ ...classes.getButtonIconClasses(getLabelToDisplay({
47
+ isLiquid: true
48
+ }), shouldClearSpace)
80
49
  });
81
- return core.template`
82
- <gp-button style="${{
83
- ...wrapStyle
84
- }}">
85
- <div
86
- style="${{
87
- ...restStyle,
88
- ...core.makeStyleResponsive('ta', align)
89
- }}"
90
- class="${core.cls(wrapClassName, className?.includes('gp-button-atc') ? '' : advanced?.cssClass)}"
91
- >
92
- <style>${innerBorderCss}</style>
93
- <${Wrap}
94
- ${{
95
- ...urlData,
96
- 'data-id': builderProps?.uidInteraction ?? (dataId || builderProps?.uid),
97
- 'aria-label': setting?.label?.toString().replaceAll("'", '&#039;').replaceAll('"', "'"),
98
- ...disabled && typeof disabled === 'boolean' || disabled ? {
99
- disabled: 'disabled'
100
- } : {}
50
+ const buttonLabelClasses = system.createClass({
51
+ ...classes.getButtonLabelClasses(styles$1, checkIsEditableLabel({
52
+ isLiquid: true
53
+ }))
54
+ });
55
+ const buttonWrapperClasses = system.createClass({
56
+ ...classes.getButtonWrapperClasses(wrapClassName, className, advanced?.cssClass)
57
+ });
58
+ const buttonContentWrapperClasses = system.createClass({
59
+ ...classes.getButtonContentWrapperClasses(setting)
60
+ });
61
+ const buttonWrapperAttrs = system.createAttr({
62
+ ...attributes.getButtonAttributes({
63
+ urlData,
64
+ disabled,
65
+ dataState,
66
+ dataId: dataIdAttr,
67
+ arialLabel: getArialLabel({
68
+ isLiquid: true
69
+ })
70
+ })
71
+ });
72
+ const buttonState = system.createStateOrContext({
73
+ btnLink: setting?.btnLink
74
+ });
75
+ return system.Liquid(core.template`
76
+ <gp-button
77
+ gp-data='${core.dataStringify(buttonState)}'
78
+ style="${{
79
+ wrapStyle
80
+ }}"
81
+ >
82
+ <div style="${buttonWrapperStyles}" class="${buttonWrapperClasses}">
83
+ <style>${customCss}</style>
84
+ ${system.If(isScrollToElement, `<a
85
+ class="gp-trigger-button-link gp-hidden"
86
+ href=${urlData.href}
87
+ target=${urlData.target}
88
+ ></a>`)}
89
+ <${ButtonWrapper}
90
+ ${{
91
+ ...buttonWrapperAttrs
101
92
  }}
102
- ${{
93
+ ${{
103
94
  ...customAttrs
104
95
  }}
105
- data-state="${loading ? 'loading' : 'idle'}"
106
- class="${core.cls(builderProps?.uid, 'gp-button-base gp-rounded-none gp-max-w-full gp-relative gp-group gp-inline-flex gp-items-center gp-justify-center gp-no-underline gp-transition-colors gp-duration-300 disabled:gp-btn-disabled disabled:gp-opacity-30 disabled:gp-pointer-events-none', core.getGlobalColorStateClass('bg', backgroundColor), core.getGlobalColorStateClass('text', textColor), {
107
- 'gp-animate-bounce': styles?.animation?.normal === 'bounce',
108
- 'hover:gp-animate-bounce': styles?.animation?.hover === 'bounce',
109
- 'gp-scale-[1.1]': styles?.animation?.normal === 'grow',
110
- 'hover:gp-scale-[1.1]': styles?.animation?.hover === 'grow',
111
- 'gp-text-center': shouldRenderLink
112
- }, className, className?.includes('gp-button-atc') && advanced ? advanced?.cssClass : '', !nodePrice ? appendTypoClass : {})}"
113
- style="${{
114
- ...core.getGlobalColorStateStyle('bg', backgroundColor),
115
- ...core.composeRadius(roundedBtn),
116
- ...core.getStyleShadowState(styles?.boxShadowBtn, 'box-shadow', {
117
- normal: styles?.boxShadowBtn?.normal?.type !== 'none',
118
- hover: styles?.boxShadowBtn?.hover?.type !== 'none'
119
- }),
120
- ...!styles?.btnSpacing?.type ? core.composeSize(styles?.btnSpacing?.custom) : {},
121
- ...composeGlobalSize.width,
122
- ...composeGlobalSize.height,
123
- ...composeGlobalSize.padding,
124
- ...core.getGradientBgrStyleForButton(backgroundColor),
125
- ...core.getGlobalColorStateStyle('c', textColor),
126
- '--size': appendTypoStyle['--size'],
127
- '--size-tablet': appendTypoStyle['--size-tablet'],
128
- '--size-mobile': appendTypoStyle['--size-mobile'],
129
- ...!nodePrice ? appendTypoStyle : {}
130
- }}"
131
- >
132
- ${!disabledLoading ? ` <svg
133
- class="gp-invisible gp-absolute gp-h-5 gp-w-5 group-data-[state=loading]:gp-animate-spin group-data-[state=loading]:gp-visible"
134
- xmlns="http://www.w3.org/2000/svg"
135
- fill="none"
136
- viewBox="0 0 24 24"
96
+ style="${buttonStyles}"
97
+ class="${buttonClasses}"
137
98
  >
138
- <circle
139
- class="gp-opacity-25"
140
- cx="12"
141
- cy="12"
142
- r="10"
143
- stroke="currentColor"
144
- stroke-width="4"
145
- ></circle>
146
- <path
147
- class="gp-opacity-75"
148
- fill="currentColor"
149
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
150
- ></path>
151
- </svg>` : ''}
152
- <div
153
- class="${core.cls('gp-inline-flex', {
154
- 'gp-flex-row-reverse': iconAlign === 'right'
155
- })}">
156
- ${core.RenderIf(!!iconSvg && iconVisible, core.template`<span
157
- class="${`gp-inline-flex gp-button-icon gp-transition-colors gp-duration-300 gp-shrink-0 gp-items-center gp-justify-center group-data-[state=loading]:gp-invisible gp-z-1 [&>svg]:!gp-h-[var(--height-desktop)] [&>svg]:!gp-w-auto tablet:[&>svg]:!gp-h-[var(--height-tablet)] mobile:[&>svg]:!gp-h-[var(--height-mobile)]`}"
158
- style="${{
159
- ...label ? iconSpacingStyle : {},
160
- '--height-desktop': `${size?.desktop}`,
161
- '--height-tablet': `${size?.desktop ?? size?.tablet}`,
162
- '--height-mobile': `${size?.mobile ?? size?.tablet ?? size?.desktop}`
163
- }}"
164
- >${iconSvg}</span>`)}
165
- <span
166
- data-gp-text
167
- class="${`gp-content-product-button gp-button-text-only gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
168
- ${styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : ''}`}"
169
- style="${{
170
- ...nodePrice && appendTypoStyle,
171
- '--size': appendTypoStyle['--size'],
172
- '--size-tablet': appendTypoStyle['--size-tablet'],
173
- '--size-mobile': appendTypoStyle['--size-mobile']
174
- }}"
175
- >
176
- ${labelValDisplay}
177
- </span>
99
+ ${system.If(loading, ButtonLoadingIndicator_liquid.default, '')}
100
+ <div class="${buttonContentWrapperClasses}">
101
+ ${system.If(isShowIcon, ButtonIcon_liquid.default({
102
+ iconSvg: iconSvg ?? '',
103
+ styles: buttonIconStyles,
104
+ classes: buttonIconClasses
105
+ }))}
106
+ ${system.If(checkIsShowLabel({
107
+ isLiquid: true
108
+ }), ButtonLabel_liquid.default({
109
+ label: getLabelToDisplay({
110
+ isLiquid: true
111
+ }),
112
+ classes: buttonLabelClasses
113
+ }))}
114
+ </div>
115
+ ${system.If(!!nodePrice, nodePrice?.toString() ?? '', '')}
116
+ </${ButtonWrapper}>
178
117
  </div>
179
- ${nodePrice ? nodePrice : ''}
180
- </${Wrap}>
181
- </div>
182
- </gp-button>
183
- `;
118
+ ${system.If(core.isLocalEnv, `<script ${helpers$1.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-button.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers$1.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
119
+ </gp-button>
120
+ `);
184
121
  };
185
122
 
186
123
  exports.default = Button;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ const ButtonIcon = ({ iconSvg, classes, styles })=>{
8
+ return /*#__PURE__*/ jsxRuntime.jsx("span", {
9
+ className: classes,
10
+ style: styles,
11
+ dangerouslySetInnerHTML: {
12
+ __html: iconSvg
13
+ }
14
+ });
15
+ };
16
+
17
+ exports.default = ButtonIcon;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const ButtonIcon = ({ iconSvg, classes, styles })=>{
6
+ return `
7
+ <span
8
+ style="${styles}"
9
+ class="${classes}"
10
+ >
11
+ ${iconSvg}
12
+ </span>
13
+ `;
14
+ };
15
+
16
+ exports.default = ButtonIcon;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ require('react');
7
+
8
+ const ButtonLabel = ({ label, classes })=>{
9
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
10
+ "data-gp-text": true,
11
+ className: classes,
12
+ dangerouslySetInnerHTML: {
13
+ __html: label
14
+ }
15
+ });
16
+ };
17
+
18
+ exports.default = ButtonLabel;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const ButtonLabel = ({ label, classes })=>{
6
+ return `
7
+ <span
8
+ data-gp-text
9
+ class="${classes}"
10
+ >
11
+ ${label}
12
+ </span>`;
13
+ };
14
+
15
+ exports.default = ButtonLabel;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@gem-sdk/core');
6
+ var constants = require('./common/constants.js');
7
+
8
+ const ButtonLoadingIndicator = ()=>{
9
+ return core.template`${constants.LOADING_INDICATOR}`;
10
+ };
11
+
12
+ exports.default = ButtonLoadingIndicator;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ const getButtonAttributes = ({ dataId, disabled, urlData, dataState, arialLabel })=>{
4
+ return {
5
+ ...urlData,
6
+ ...disabled !== undefined && {
7
+ disabled: disabled
8
+ },
9
+ 'data-id': dataId,
10
+ 'data-state': dataState,
11
+ 'aria-label': arialLabel
12
+ };
13
+ };
14
+
15
+ exports.getButtonAttributes = getButtonAttributes;
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const getButtonClasses = ({ uid, styles, className, shouldRenderLink })=>{
6
+ return {
7
+ ...className && {
8
+ [className]: true
9
+ },
10
+ ...uid && {
11
+ [uid]: true
12
+ },
13
+ 'gp-text-center': shouldRenderLink,
14
+ 'gp-max-w-full': styles?.textOverFlow || false,
15
+ 'gp-scale-[1.1]': styles?.animation?.normal === 'grow',
16
+ 'gp-animate-bounce': styles?.animation?.normal === 'bounce',
17
+ 'hover:gp-scale-[1.1]': styles?.animation?.hover === 'grow',
18
+ 'hover:gp-animate-bounce': styles?.animation?.hover === 'bounce',
19
+ 'gp-button-base gp-group gp-relative gp-inline-flex gp-max-w-full gp-items-center gp-justify-center gp-no-underline gp-transition-colors gp-duration-300 disabled:gp-btn-disabled disabled:gp-opacity-30': true,
20
+ [core.getGlobalColorStateClass('text', styles?.textColor)]: true
21
+ };
22
+ };
23
+ const getButtonWrapperClasses = (wrapClassName, className, advancedCssClass)=>{
24
+ return {
25
+ [wrapClassName]: true,
26
+ ...className?.includes('gp-button-atc') && advancedCssClass && {
27
+ [advancedCssClass]: true
28
+ }
29
+ };
30
+ };
31
+ const getButtonContentWrapperClasses = (setting)=>{
32
+ return {
33
+ 'gp-inline-flex': true,
34
+ 'gp-flex-row-reverse': setting?.iconAlign === 'right'
35
+ };
36
+ };
37
+ const getButtonLabelClasses = (styles, isEditable)=>{
38
+ return {
39
+ 'gp-relative gp-flex gp-h-full gp-items-center gp-overflow-hidden gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line': true,
40
+ '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]': styles?.typo?.attrs?.italic,
41
+ 'gp-text button-text': isEditable
42
+ };
43
+ };
44
+ const getButtonIconClasses = (label, shouldClearSpace)=>{
45
+ return {
46
+ '!gp-m-0': shouldClearSpace && !label,
47
+ 'gp-button-icon gp-transition-colors gp-duration-300 gp-z-1 gp-inline-flex gp-shrink-0 gp-items-center gp-justify-center group-data-[state=loading]:gp-invisible [&>svg]:!gp-h-[var(--height-desktop)] [&>svg]:!gp-w-auto tablet:[&>svg]:!gp-h-[var(--height-tablet)] mobile:[&>svg]:!gp-h-[var(--height-mobile)]': true
48
+ };
49
+ };
50
+
51
+ exports.getButtonClasses = getButtonClasses;
52
+ exports.getButtonContentWrapperClasses = getButtonContentWrapperClasses;
53
+ exports.getButtonIconClasses = getButtonIconClasses;
54
+ exports.getButtonLabelClasses = getButtonLabelClasses;
55
+ exports.getButtonWrapperClasses = getButtonWrapperClasses;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ const LOADING_INDICATOR = `
4
+ <svg
5
+ class="gp-invisible gp-absolute gp-h-5 gp-w-5 group-data-[state=loading]:gp-animate-spin group-data-[state=loading]:gp-visible"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ fill="none"
8
+ viewBox="0 0 24 24"
9
+ >
10
+ <circle
11
+ class="gp-opacity-25"
12
+ cx="12"
13
+ cy="12"
14
+ r="10"
15
+ stroke="currentColor"
16
+ stroke-width="4"
17
+ ></circle>
18
+ <path
19
+ class="gp-opacity-75"
20
+ fill="currentColor"
21
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
22
+ ></path>
23
+ </svg>
24
+ `;
25
+
26
+ exports.LOADING_INDICATOR = LOADING_INDICATOR;
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var helpers = require('./helpers.js');
4
+ var styles = require('./styles.js');
5
+
6
+ const getData = (props)=>{
7
+ const { style, dataId, pageContext, styles: styles$1 = {}, setting = {}, builderProps, isForceValue = false } = props;
8
+ const { label, iconSvg, btnLink, loading, options, disabled, translate, iconVisible, shouldClearSpace } = setting;
9
+ const [wrapStyle, restStyle] = helpers.getSplitStyles(style);
10
+ const cleanedStyles = helpers.getCleanedStyles(styles$1, disabled);
11
+ const customCss = styles.getCustomCssStyles({
12
+ styles: styles$1,
13
+ uid: builderProps?.uid
14
+ });
15
+ const dataState = helpers.getDataState(loading);
16
+ const dataIdAttr = helpers.getDataId(builderProps?.uidInteraction, dataId, builderProps?.uid);
17
+ const getArialLabel = (props)=>{
18
+ const { isLiquid } = props ?? {};
19
+ return helpers.handleGetArialLabel({
20
+ label,
21
+ isLiquid
22
+ });
23
+ };
24
+ const getLabelToDisplay = (props)=>{
25
+ const { isLiquid } = props ?? {};
26
+ return helpers.handleGetLabelToDisplay({
27
+ label,
28
+ builderProps,
29
+ styles: cleanedStyles,
30
+ isLiquid,
31
+ ...isLiquid && {
32
+ translate
33
+ },
34
+ ...isLiquid && {
35
+ pageContext
36
+ },
37
+ ...isLiquid && {
38
+ isForceValue
39
+ }
40
+ });
41
+ };
42
+ const checkIsShowLabel = (props)=>{
43
+ const { isLiquid } = props ?? {};
44
+ const labelToDisplay = getLabelToDisplay({
45
+ isLiquid
46
+ });
47
+ return helpers.handleCheckIsShowLabel(labelToDisplay, shouldClearSpace);
48
+ };
49
+ const checkIsEditableLabel = (props)=>{
50
+ const { isLiquid, mode } = props ?? {};
51
+ return helpers.handleCheckIsEditableLabel({
52
+ options,
53
+ isLiquid,
54
+ ...!isLiquid && mode && {
55
+ mode
56
+ }
57
+ });
58
+ };
59
+ const isShowIcon = helpers.checkIsShowIcon(iconSvg, iconVisible);
60
+ const isScrollToElement = helpers.checkIsScrollToElement(btnLink);
61
+ return {
62
+ customCss,
63
+ wrapStyle,
64
+ restStyle,
65
+ dataState,
66
+ dataIdAttr,
67
+ isShowIcon,
68
+ isScrollToElement,
69
+ getArialLabel,
70
+ getLabelToDisplay,
71
+ checkIsShowLabel,
72
+ checkIsEditableLabel
73
+ };
74
+ };
75
+
76
+ exports.getData = getData;