@gem-sdk/components 2.0.0-dev.294 → 2.0.0-dev.303

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 (218) hide show
  1. package/dist/cjs/accordion/components/common/index.js +2 -2
  2. package/dist/cjs/article/components/ArticleAuthor.js +1 -1
  3. package/dist/cjs/article/components/ArticleTitle.js +3 -1
  4. package/dist/cjs/article/components/ArticleTitle.liquid.js +5 -2
  5. package/dist/cjs/article/setting/ArticleList.js +0 -30
  6. package/dist/cjs/article/setting/configs/ArticleAuthor/presets.js +0 -9
  7. package/dist/cjs/article/setting/configs/ArticleAuthor/settings.js +9 -5
  8. package/dist/cjs/article/setting/configs/ArticleAuthor/uiV2.js +16 -0
  9. package/dist/cjs/article/setting/configs/ArticleCategory/presets.js +0 -9
  10. package/dist/cjs/article/setting/configs/ArticleCategory/settings.js +9 -5
  11. package/dist/cjs/article/setting/configs/ArticleDate/presets.js +0 -9
  12. package/dist/cjs/article/setting/configs/ArticleDate/settings.js +9 -5
  13. package/dist/cjs/article/setting/configs/ArticleImage/settings.js +22 -1
  14. package/dist/cjs/article/setting/configs/ArticleTitle/settings.js +36 -7
  15. package/dist/cjs/article/setting/configs/ArticleTitle/uiV2.js +47 -2
  16. package/dist/cjs/builder.js +6 -2
  17. package/dist/cjs/button/components/Button.js +1 -1
  18. package/dist/cjs/button/components/Button.liquid.js +1 -1
  19. package/dist/cjs/button/components/ButtonIcon.liquid.js +3 -1
  20. package/dist/cjs/button/components/ButtonLabel.liquid.js +3 -1
  21. package/dist/cjs/button/components/common/attributes.js +2 -2
  22. package/dist/cjs/button/components/common/classes.js +2 -1
  23. package/dist/cjs/button/components/common/styles.js +9 -11
  24. package/dist/cjs/button/setting/configs/settings.js +7 -8
  25. package/dist/cjs/button/setting/configs/uiV2.js +4 -50
  26. package/dist/cjs/dialog/components/Dialog.js +109 -394
  27. package/dist/cjs/dialog/components/Dialog.liquid.js +129 -153
  28. package/dist/cjs/dialog/components/common/common.js +130 -0
  29. package/dist/cjs/dialog/components/common/getAttr.js +27 -0
  30. package/dist/cjs/dialog/components/common/getClasses.js +88 -0
  31. package/dist/cjs/dialog/components/common/getStyle.js +107 -0
  32. package/dist/cjs/dialog/components/hooks/useDialog.js +233 -0
  33. package/dist/cjs/dialog/setting/configs/settings.js +1 -1
  34. package/dist/cjs/dialog/setting/configs/uiV2.js +35 -25
  35. package/dist/cjs/form/components/form-checkbox/FormCheckbox.js +0 -4
  36. package/dist/cjs/form/components/textinput/TextInput.js +58 -0
  37. package/dist/cjs/form/components/textinput/TextInput.liquid.js +60 -0
  38. package/dist/cjs/form/components/textinput/common/composeClasses.js +33 -0
  39. package/dist/cjs/form/components/textinput/common/composeStyles.js +70 -0
  40. package/dist/cjs/form/next.js +5 -1
  41. package/dist/cjs/form/setting/index.js +3 -1
  42. package/dist/cjs/form/setting/newsletter/configs/settings.js +4 -2
  43. package/dist/cjs/form/setting/newsletter/configs/uiV2.js +2 -0
  44. package/dist/cjs/form/setting/text-input/TextInput.js +53 -0
  45. package/dist/cjs/form/setting/text-input/configs/settings.js +307 -0
  46. package/dist/cjs/form/setting/text-input/configs/uiV1.js +106 -0
  47. package/dist/cjs/form/setting/text-input/configs/uiV2.js +303 -0
  48. package/dist/cjs/grid/row/setting/configs/settings.js +6 -3
  49. package/dist/cjs/helpers.js +8 -0
  50. package/dist/cjs/icon-list/common/attrs.js +10 -0
  51. package/dist/cjs/icon-list/common/classes.js +9 -0
  52. package/dist/cjs/icon-list/common/styles.js +29 -0
  53. package/dist/cjs/icon-list/components/IconList.js +19 -30
  54. package/dist/cjs/icon-list/components/IconList.liquid.js +21 -24
  55. package/dist/cjs/icon-list/components/IconListItem.js +13 -7
  56. package/dist/cjs/icon-list/components/IconListItem.liquid.js +13 -7
  57. package/dist/cjs/icon-list-hoz/components/IconListHoz.js +37 -25
  58. package/dist/cjs/icon-list-hoz/components/IconListHoz.liquid.js +31 -25
  59. package/dist/cjs/icon-list-hoz/components/IconListHozItem.js +12 -6
  60. package/dist/cjs/icon-list-hoz/components/IconListIHozItem.liquid.js +26 -0
  61. package/dist/cjs/icon-list-hoz/components/common/getAttr.js +9 -0
  62. package/dist/cjs/icon-list-hoz/components/common/getClasses.js +24 -0
  63. package/dist/cjs/icon-list-hoz/components/common/getStyle.js +30 -0
  64. package/dist/cjs/index.js +6 -1
  65. package/dist/cjs/index.liquid.js +7 -3
  66. package/dist/cjs/line/common/classes.js +66 -0
  67. package/dist/cjs/line/common/index.js +16 -0
  68. package/dist/cjs/line/common/styles.js +120 -0
  69. package/dist/cjs/line/components/Divider.js +26 -0
  70. package/dist/cjs/line/components/Divider.liquid.js +22 -0
  71. package/dist/cjs/line/components/Line.js +98 -0
  72. package/dist/cjs/line/components/Line.liquid.js +86 -0
  73. package/dist/cjs/line/next.js +1 -1
  74. package/dist/cjs/post-purchase/line/setting/configs/uiV2.js +1 -1
  75. package/dist/cjs/post-purchase/link/setting/configs/settings.js +2 -1
  76. package/dist/cjs/post-purchase/link/setting/configs/uiV2.js +1 -1
  77. package/dist/cjs/post-purchase/product/settings/product-variants/configs/uiV2.js +1 -1
  78. package/dist/cjs/product/components/FileUpload/components/config/setting.js +24 -26
  79. package/dist/cjs/product/components/FileUpload/components/config/uiV2.js +12 -179
  80. package/dist/cjs/product/components/ProductList.js +1 -1
  81. package/dist/cjs/product/components/ProductVariants/index.js +2 -2
  82. package/dist/cjs/product/components/ProductVariants/index.liquid.js +2 -2
  83. package/dist/cjs/product/components/ProductVariants/variants/Dropdown.js +8 -3
  84. package/dist/cjs/product/components/ProductVariants/variants/Dropdown.liquid.js +7 -2
  85. package/dist/cjs/product/setting/ProductVariants.js +8 -1374
  86. package/dist/cjs/product/setting/product-list/configs/uiV2.js +0 -3
  87. package/dist/cjs/product/setting/product-variant/configs/presets.js +168 -0
  88. package/dist/cjs/product/setting/product-variant/configs/settings.js +732 -0
  89. package/dist/cjs/product/setting/product-variant/configs/uiV1.js +509 -0
  90. package/dist/cjs/product/setting/product-variant/configs/uiV2.js +347 -0
  91. package/dist/cjs/third-party/components/EcoboostifyShoppableReelUgc.js +33 -0
  92. package/dist/cjs/third-party/components/EcoboostifyShoppableReelUgc.liquid.js +12 -0
  93. package/dist/cjs/third-party/configs/EcoboostifyShoppableReelUgc.js +12 -0
  94. package/dist/cjs/third-party/next.js +5 -0
  95. package/dist/cjs/third-party/setting/EcoboostifyShoppableReelUgc.js +142 -0
  96. package/dist/cjs/third-party/setting/index.js +3 -1
  97. package/dist/esm/accordion/components/common/index.js +2 -2
  98. package/dist/esm/article/components/ArticleAuthor.js +1 -1
  99. package/dist/esm/article/components/ArticleTitle.js +3 -1
  100. package/dist/esm/article/components/ArticleTitle.liquid.js +5 -2
  101. package/dist/esm/article/setting/ArticleList.js +0 -30
  102. package/dist/esm/article/setting/configs/ArticleAuthor/presets.js +0 -9
  103. package/dist/esm/article/setting/configs/ArticleAuthor/settings.js +9 -5
  104. package/dist/esm/article/setting/configs/ArticleAuthor/uiV2.js +16 -0
  105. package/dist/esm/article/setting/configs/ArticleCategory/presets.js +0 -9
  106. package/dist/esm/article/setting/configs/ArticleCategory/settings.js +9 -5
  107. package/dist/esm/article/setting/configs/ArticleDate/presets.js +0 -9
  108. package/dist/esm/article/setting/configs/ArticleDate/settings.js +9 -5
  109. package/dist/esm/article/setting/configs/ArticleImage/settings.js +22 -1
  110. package/dist/esm/article/setting/configs/ArticleTitle/settings.js +36 -7
  111. package/dist/esm/article/setting/configs/ArticleTitle/uiV2.js +47 -2
  112. package/dist/esm/builder.js +6 -2
  113. package/dist/esm/button/components/Button.js +1 -1
  114. package/dist/esm/button/components/Button.liquid.js +1 -1
  115. package/dist/esm/button/components/ButtonIcon.liquid.js +3 -1
  116. package/dist/esm/button/components/ButtonLabel.liquid.js +3 -1
  117. package/dist/esm/button/components/common/attributes.js +2 -2
  118. package/dist/esm/button/components/common/classes.js +3 -2
  119. package/dist/esm/button/components/common/styles.js +10 -12
  120. package/dist/esm/button/setting/configs/settings.js +7 -8
  121. package/dist/esm/button/setting/configs/uiV2.js +4 -50
  122. package/dist/esm/dialog/components/Dialog.js +110 -395
  123. package/dist/esm/dialog/components/Dialog.liquid.js +130 -154
  124. package/dist/esm/dialog/components/common/common.js +117 -0
  125. package/dist/esm/dialog/components/common/getAttr.js +22 -0
  126. package/dist/esm/dialog/components/common/getClasses.js +79 -0
  127. package/dist/esm/dialog/components/common/getStyle.js +98 -0
  128. package/dist/esm/dialog/components/hooks/useDialog.js +231 -0
  129. package/dist/esm/dialog/setting/configs/settings.js +1 -1
  130. package/dist/esm/dialog/setting/configs/uiV2.js +35 -25
  131. package/dist/esm/form/components/form-checkbox/FormCheckbox.js +0 -4
  132. package/dist/esm/form/components/textinput/TextInput.js +54 -0
  133. package/dist/esm/form/components/textinput/TextInput.liquid.js +56 -0
  134. package/dist/esm/form/components/textinput/common/composeClasses.js +29 -0
  135. package/dist/esm/form/components/textinput/common/composeStyles.js +67 -0
  136. package/dist/esm/form/next.js +5 -1
  137. package/dist/esm/form/setting/index.js +3 -1
  138. package/dist/esm/form/setting/newsletter/configs/settings.js +4 -2
  139. package/dist/esm/form/setting/newsletter/configs/uiV2.js +2 -0
  140. package/dist/esm/form/setting/text-input/TextInput.js +49 -0
  141. package/dist/esm/form/setting/text-input/configs/settings.js +305 -0
  142. package/dist/esm/form/setting/text-input/configs/uiV1.js +104 -0
  143. package/dist/esm/form/setting/text-input/configs/uiV2.js +301 -0
  144. package/dist/esm/grid/row/setting/configs/settings.js +6 -3
  145. package/dist/esm/helpers.js +8 -1
  146. package/dist/esm/icon-list/common/attrs.js +8 -0
  147. package/dist/esm/icon-list/common/classes.js +6 -0
  148. package/dist/esm/icon-list/common/styles.js +25 -0
  149. package/dist/esm/icon-list/components/IconList.js +21 -32
  150. package/dist/esm/icon-list/components/IconList.liquid.js +21 -24
  151. package/dist/esm/icon-list/components/IconListItem.js +13 -7
  152. package/dist/esm/icon-list/components/IconListItem.liquid.js +14 -8
  153. package/dist/esm/icon-list-hoz/components/IconListHoz.js +38 -26
  154. package/dist/esm/icon-list-hoz/components/IconListHoz.liquid.js +32 -26
  155. package/dist/esm/icon-list-hoz/components/IconListHozItem.js +12 -6
  156. package/dist/esm/icon-list-hoz/components/IconListIHozItem.liquid.js +22 -0
  157. package/dist/esm/icon-list-hoz/components/common/getAttr.js +7 -0
  158. package/dist/esm/icon-list-hoz/components/common/getClasses.js +21 -0
  159. package/dist/esm/icon-list-hoz/components/common/getStyle.js +27 -0
  160. package/dist/esm/index.js +4 -2
  161. package/dist/esm/index.liquid.js +4 -2
  162. package/dist/esm/line/common/classes.js +59 -0
  163. package/dist/esm/line/common/index.js +14 -0
  164. package/dist/esm/line/common/styles.js +114 -0
  165. package/dist/esm/line/components/Divider.js +22 -0
  166. package/dist/esm/line/components/Divider.liquid.js +18 -0
  167. package/dist/esm/line/components/Line.js +94 -0
  168. package/dist/esm/line/components/Line.liquid.js +82 -0
  169. package/dist/esm/line/next.js +1 -1
  170. package/dist/esm/post-purchase/line/setting/configs/uiV2.js +1 -1
  171. package/dist/esm/post-purchase/link/setting/configs/settings.js +2 -1
  172. package/dist/esm/post-purchase/link/setting/configs/uiV2.js +1 -1
  173. package/dist/esm/post-purchase/product/settings/product-variants/configs/uiV2.js +1 -1
  174. package/dist/esm/product/components/FileUpload/components/config/setting.js +24 -26
  175. package/dist/esm/product/components/FileUpload/components/config/uiV2.js +12 -179
  176. package/dist/esm/product/components/ProductList.js +1 -1
  177. package/dist/esm/product/components/ProductVariants/index.js +2 -2
  178. package/dist/esm/product/components/ProductVariants/index.liquid.js +2 -2
  179. package/dist/esm/product/components/ProductVariants/variants/Dropdown.js +8 -3
  180. package/dist/esm/product/components/ProductVariants/variants/Dropdown.liquid.js +7 -2
  181. package/dist/esm/product/setting/ProductVariants.js +8 -1374
  182. package/dist/esm/product/setting/product-list/configs/uiV2.js +0 -3
  183. package/dist/esm/product/setting/product-variant/configs/presets.js +166 -0
  184. package/dist/esm/product/setting/product-variant/configs/settings.js +730 -0
  185. package/dist/esm/product/setting/product-variant/configs/uiV1.js +507 -0
  186. package/dist/esm/product/setting/product-variant/configs/uiV2.js +345 -0
  187. package/dist/esm/third-party/components/EcoboostifyShoppableReelUgc.js +29 -0
  188. package/dist/esm/third-party/components/EcoboostifyShoppableReelUgc.liquid.js +8 -0
  189. package/dist/esm/third-party/configs/EcoboostifyShoppableReelUgc.js +8 -0
  190. package/dist/esm/third-party/next.js +5 -0
  191. package/dist/esm/third-party/setting/EcoboostifyShoppableReelUgc.js +138 -0
  192. package/dist/esm/third-party/setting/index.js +3 -1
  193. package/dist/types/index.d.ts +184 -166
  194. package/package.json +2 -2
  195. package/dist/cjs/dialog/helpers/common.js +0 -55
  196. package/dist/cjs/icon-list-hoz/components/IconListItemHoz.liquid.js +0 -23
  197. package/dist/cjs/line/Divider.js +0 -35
  198. package/dist/cjs/line/Divider.liquid.js +0 -35
  199. package/dist/cjs/line/Line.js +0 -167
  200. package/dist/cjs/line/Line.liquid.js +0 -163
  201. package/dist/esm/dialog/helpers/common.js +0 -47
  202. package/dist/esm/icon-list-hoz/components/IconListItemHoz.liquid.js +0 -19
  203. package/dist/esm/line/Divider.js +0 -31
  204. package/dist/esm/line/Divider.liquid.js +0 -31
  205. package/dist/esm/line/Line.js +0 -163
  206. package/dist/esm/line/Line.liquid.js +0 -159
  207. /package/dist/cjs/dialog/{hooks/use-scroll-percentage.js → components/hooks/useScrollPercentage.js} +0 -0
  208. /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/color.js +0 -0
  209. /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/dropdown.js +0 -0
  210. /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image-shopify.js +0 -0
  211. /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image.js +0 -0
  212. /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/rectangle-list.js +0 -0
  213. /package/dist/esm/dialog/{hooks/use-scroll-percentage.js → components/hooks/useScrollPercentage.js} +0 -0
  214. /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/color.js +0 -0
  215. /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/dropdown.js +0 -0
  216. /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image-shopify.js +0 -0
  217. /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image.js +0 -0
  218. /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/rectangle-list.js +0 -0
@@ -1,73 +1,16 @@
1
- import { makeWidth, template, cls, RenderIf, makeStyle, getGlobalColorResponsiveStyle, makeStyleResponsive, composeRadius, getStyleBackgroundByDevice, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import { isTransparentColor } from '../../helpers.js';
3
- import { heightStyle, removeHeightPercentForContent, inheritStyleBody, bodyDialogClass } from '../helpers/common.js';
4
- import 'react/jsx-runtime';
5
- import 'react';
6
- import { ELEMENT_Z_INDEX } from '../../common/const.js';
1
+ import { template, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { createStateOrContext, createAttr, createStyle, createClass, If } from '@gem-sdk/system';
3
+ import { getAttr, getAttrContainer, getAttrOverlay, getAttrClose } from './common/getAttr.js';
4
+ import { getWrapperStyle, getContainStyle, getBackdropStyle, getOverlayStyle, getDialogContentStyle, getButtonContentStyle, getSvgContentStyle, getBodyContentStyle } from './common/getStyle.js';
5
+ import { getWrapperClasses, getContainClasses, getBackdropClasses, getOverlayClasses, getDialogContentClasses, getHeadContentClasses, getButtonContentClasses, getBodyContentClasses } from './common/getClasses.js';
7
6
 
8
- const Dialog = ({ setting, children, builderProps, style, advanced })=>{
7
+ const Dialog = (props)=>{
8
+ const { setting, children, builderProps, style, advanced, builderAttrs } = props;
9
9
  const display = advanced?.d;
10
- const dStyle = {
11
- '--d': display?.desktop ? 'contents' : 'none',
12
- '--d-tablet': display?.tablet ? 'contents' : 'none',
13
- '--d-mobile': display?.mobile ? 'contents' : 'none'
14
- };
15
- const { name, frequency = 3, triggerPercentage = 0, trigger, triggerTime, frequencyMode = 'once' } = setting ?? {};
16
- const { fullScreen, width, height, position, effectType, closeOnClickOutside, background } = setting ?? {};
17
- const { btnBg, btnColor, btnSize, iconSize, closeButtonPosition, btnRounded } = setting ?? {};
18
- const { isOverlay, overlayColor, overlayOpacity, mobileTrigger, mobileTriggerTime } = setting ?? {};
19
- const w = makeWidth(width, fullScreen);
20
- const displayStyle = Object.keys(style ?? {}).filter((key)=>[
21
- '--d',
22
- '--d-mobile',
23
- '--d-tablet'
24
- ].includes(key)).reduce((curr, key)=>({
25
- ...curr,
26
- [key]: style?.[key]
27
- }), {});
28
- const borderStyle = Object.keys(style ?? {}).filter((key)=>[
29
- '--bw',
30
- '--bw-mobile',
31
- '--bw-tablet',
32
- '--bc',
33
- '--bc-tablet',
34
- '--bc-mobile',
35
- '--b',
36
- '--b-tablet',
37
- '--b-mobile',
38
- '--bs',
39
- '--bs-tablet',
40
- '--bs-mobile',
41
- '--radius',
42
- '--radius-tablet',
43
- '--radius-mobile',
44
- '--bblr',
45
- '--bbrr',
46
- '--btlr',
47
- '--btrr',
48
- '--bblr-tablet',
49
- '--bbrr-tablet',
50
- '--btlr-tablet',
51
- '--btrr-tablet',
52
- '--bblr-mobile',
53
- '--bbrr-mobile',
54
- '--btlr-mobile',
55
- '--btrr-mobile'
56
- ].includes(key)).reduce((curr, key)=>({
57
- ...curr,
58
- [key]: style?.[key]
59
- }), {});
60
- const wrapperStyle = Object.keys(style ?? {}).filter((key)=>key.startsWith('--mt') || key.startsWith('--mb') || key.startsWith('--ml') || key.startsWith('--mr')).reduce((curr, key)=>({
61
- ...curr,
62
- [key]: style?.[key]
63
- }), {});
64
- const innerStyle = Object.keys(style ?? {}).filter((key)=>!Object.keys(wrapperStyle).includes(key) && !Object.keys(displayStyle).includes(key) && !Object.keys(borderStyle).includes(key)).reduce((curr, key)=>({
65
- ...curr,
66
- [key]: style?.[key]
67
- }), {});
10
+ const { frequency = 3, triggerPercentage = 0, trigger, triggerTime, frequencyMode = 'once', mobileTrigger, mobileTriggerTime, closeOnClickOutside } = setting ?? {};
11
+ const { name, fullScreen, width, height, position, overlayColor, overlayOpacity, iconSize, closeButtonPosition } = setting ?? {};
68
12
  const dialogId = setting?.dialogId ?? builderProps?.uid;
69
- return template /* liquid */ `
70
- <gp-dialog class="gps-lazy" data-id="${builderProps?.uid}" style="${dStyle}" data-gp-setting='${JSON.stringify({
13
+ const stateData = createStateOrContext({
71
14
  dialogId,
72
15
  trigger,
73
16
  triggerTime,
@@ -78,110 +21,143 @@ const Dialog = ({ setting, children, builderProps, style, advanced })=>{
78
21
  closeOnClickOutside,
79
22
  frequencyMode,
80
23
  display
81
- })}'>
82
- <dialog class="${advanced?.cssClass} gp-dialog gp-bg-transparent" aria-label="${name}" data-gp-dialog-id="${dialogId}"
83
- style="${{
84
- 'z-index': ELEMENT_Z_INDEX.DIALOG
85
- }}"
86
- >
87
- <div
88
- aria-label="Backdrop"
89
- class="${cls('gp-fixed gp-inset-0 gp-z-50 gp-flex gp-overflow-y-auto gp-overflow-x-hidden', {
90
- 'gp-items-center gp-justify-center': position === 'center',
91
- 'gp-justify-center gp-items-start': position === 'top',
92
- 'gp-justify-end gp-items-start': position === 'top-right',
93
- 'gp-justify-start gp-items-start': position === 'top-left',
94
- 'gp-items-end gp-justify-center': position === 'bottom',
95
- 'gp-items-center gp-justify-start': position === 'left',
96
- 'gp-items-center gp-justify-end': position === 'right',
97
- 'gp-items-end gp-justify-start': position === 'bottom-left',
98
- 'gp-items-end gp-justify-end': position === 'bottom-right'
99
- })}"
100
- >
101
- ${RenderIf(isOverlay, template /* liquid */ `
102
- <div
103
- class="gp-fixed gp-inset-0 gp-block gp-transition-all gp-duration-100"
104
- data-gp-dialog-overlay
105
- style="${{
106
- ...makeStyle({
107
- op: (overlayOpacity ?? 0) / 100
108
- }),
109
- ...getGlobalColorResponsiveStyle('bgc', {
110
- desktop: overlayColor
24
+ });
25
+ const enableEffect = true;
26
+ const isILP = false;
27
+ const attrs = createAttr({
28
+ ...getAttr({
29
+ uid: builderProps?.uid || ''
30
+ })
31
+ });
32
+ const wrapperDialogStyle = createStyle({
33
+ ...getWrapperStyle(display)
34
+ });
35
+ const wrapperClasses = createClass({
36
+ ...getWrapperClasses()
37
+ });
38
+ const containClasses = createClass({
39
+ ...getContainClasses(advanced?.cssClass)
40
+ });
41
+ const containAttrs = createAttr({
42
+ ...getAttrContainer({
43
+ uid: dialogId || ''
44
+ })
45
+ });
46
+ const containStyle = createStyle({
47
+ ...getContainStyle()
48
+ });
49
+ const backdropClasses = createClass({
50
+ ...getBackdropClasses(position)
51
+ });
52
+ const backdropStyle = createStyle({
53
+ ...getBackdropStyle(style)
54
+ });
55
+ const overlayAttrs = createAttr({
56
+ ...getAttrOverlay()
57
+ });
58
+ const overlayClasses = createClass({
59
+ ...getOverlayClasses()
60
+ });
61
+ const overlayStyle = createStyle({
62
+ ...getOverlayStyle(overlayOpacity, overlayColor, style)
63
+ });
64
+ const dialogContentStyle = createStyle({
65
+ ...getDialogContentStyle({
66
+ style,
67
+ width,
68
+ height,
69
+ fullScreen
70
+ })
71
+ });
72
+ const dialogContentClasses = createClass({
73
+ ...getDialogContentClasses({
74
+ setting,
75
+ enableEffect,
76
+ isILP
111
77
  })
112
- }}"
113
- ></div>
114
- `)}
115
- <span class="gp-inline-block gp-h-screen gp-align-middle"></span>
78
+ });
79
+ const closeAttrs = createAttr({
80
+ ...getAttrClose()
81
+ });
82
+ const headContentClasses = createClass({
83
+ ...getHeadContentClasses()
84
+ });
85
+ const buttonContentStyle = createStyle({
86
+ ...getButtonContentStyle(setting)
87
+ });
88
+ const buttonContentClasses = createClass({
89
+ ...getButtonContentClasses(closeButtonPosition)
90
+ });
91
+ const svgContentStyle = createStyle({
92
+ ...getSvgContentStyle(iconSize)
93
+ });
94
+ const bodyContentStyle = createStyle({
95
+ ...getBodyContentStyle(setting, style)
96
+ });
97
+ const bodyContentClasses = createClass({
98
+ ...getBodyContentClasses()
99
+ });
100
+ const renderScript = ()=>{
101
+ return RenderIf(isLocalEnv, `<script src="{{ 'gp-dialog.js' | asset_url }}" defer="defer"></script>`, `<script src="${baseAssetURL}/assets-v2/gp-dialog.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);
102
+ };
103
+ return template /* liquid */ `
104
+ <gp-dialog
105
+ ${{
106
+ ...attrs
107
+ }}
108
+ class="${wrapperClasses}"
109
+ style="${wrapperDialogStyle}"
110
+ data-gp-setting='${JSON.stringify(stateData)}'>
111
+ <dialog
112
+ aria-label="${name}"
113
+ ${{
114
+ ...containAttrs
115
+ }}
116
+ class="${containClasses}"
117
+ style="${containStyle}"
118
+ >
119
+ <div aria-label="Backdrop" class="${backdropClasses}" style="${backdropStyle}">
120
+ ${If(!!overlayColor, template`
121
+ <div
122
+ ${{
123
+ ...overlayAttrs
124
+ }}
125
+ class="${overlayClasses}"
126
+ style="${overlayStyle}"
127
+ aria-hidden=true
128
+ ></div>
129
+ `)}
130
+ <span class="${headContentClasses}"></span>
116
131
  <div
117
132
  role="dialog"
118
133
  aria-label="Dialog content"
119
- class="${cls('gp-relative gp-max-h-full gp-max-w-full ', {
120
- 'gp-animate-[fadeIn_0.4s_ease-in]': effectType === 'fade',
121
- 'gp-animate-[zoomIn_0.3s_ease-in]': effectType === 'zoom',
122
- 'gp-animate-[zoomOut_0.3s_ease-in]': effectType === 'zoom-out',
123
- 'gp-animate-[slideInLeft_0.3s_ease-in]': effectType === 'horizontal',
124
- 'gp-animate-[slideInUp_0.3s_ease-in]': effectType === 'vertical',
125
- 'gp-animate-[unfold_0.3s_ease-in-out]': effectType === 'unfold',
126
- 'gp-shadow-xl': !isTransparentColor(background?.desktop?.color),
127
- 'gp-overflow-hidden': closeButtonPosition !== 'outside'
128
- })}"
129
- style="${{
130
- ...wrapperStyle,
131
- ...borderStyle,
132
- ...makeStyleResponsive('w', w),
133
- ...heightStyle(fullScreen, height)
134
- }}"
134
+ ${{
135
+ ...builderAttrs
136
+ }}
137
+ class="${dialogContentClasses}"
138
+ style="${dialogContentStyle}"
135
139
  >
136
140
  <button
141
+ ${{
142
+ ...closeAttrs
143
+ }}
137
144
  type="button"
138
- data-gp-dialog-close
139
145
  tabindex="-1"
140
- class="${cls('gp-absolute gp-top-0 gp-right-0 gp-z-[999999] gp-inline-flex gp-items-center gp-justify-center gp-outline-none focus-visible:gp-shadow-none focus-visible:gp-outline-none', {
141
- 'gp-translate-x-1/2 -gp-translate-y-1/2 gp-shadow-md': closeButtonPosition === 'outside'
142
- })}"
143
- style="${{
144
- ...makeStyle({
145
- w: `${parseInt(btnSize.toString())}px`,
146
- h: `${parseInt(btnSize.toString())}px`
147
- }),
148
- ...getGlobalColorResponsiveStyle('c', {
149
- desktop: btnColor
150
- }),
151
- ...getGlobalColorResponsiveStyle('bgc', {
152
- desktop: btnBg
153
- }),
154
- ...composeRadius({
155
- normal: btnRounded
156
- })
157
- }}"
146
+ class="${buttonContentClasses}"
147
+ style="${buttonContentStyle}"
158
148
  >
159
149
  <svg
160
150
  viewBox="0 0 12 12"
161
151
  fill="currentColor"
162
- style="${{
163
- ...makeStyle({
164
- w: iconSize,
165
- h: iconSize
166
- })
167
- }}"
152
+ style="${svgContentStyle}"
168
153
  >
169
154
  <path d="M7.1,6l4.5,4.5l-1.1,1.1L6,7.1l-4.5,4.5l-1.1-1.1L4.9,6L0.5,1.5l1.1-1.1L6,4.9l4.5-4.5l1.1,1.1L7.1,6z"></path>
170
155
  </svg>
171
156
  </button>
172
157
  <div
173
- style="${{
174
- ...innerStyle,
175
- ...removeHeightPercentForContent(heightStyle(fullScreen, height)),
176
- ...inheritStyleBody,
177
- ...getStyleBackgroundByDevice(background, {
178
- ignoreBackgroundImage: true,
179
- ignoreBackgroundImageProperties: true,
180
- ignoreBgAttachment: true
181
- })
182
- }}"
183
158
  aria-label="Dialog body"
184
- class="${bodyDialogClass}">
159
+ style="${bodyContentStyle}"
160
+ class="${bodyContentClasses}">
185
161
  <div>
186
162
  ${children ?? ''}
187
163
  </div>
@@ -190,7 +166,7 @@ const Dialog = ({ setting, children, builderProps, style, advanced })=>{
190
166
  </div>
191
167
  </dialog>
192
168
  </gp-dialog>
193
- ${RenderIf(isLocalEnv, `<script src="{{ 'gp-dialog.js' | asset_url }}" defer="defer"></script>`, `<script src="${baseAssetURL}/assets-v2/gp-dialog.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
169
+ ${renderScript()}
194
170
  `;
195
171
  };
196
172
 
@@ -0,0 +1,117 @@
1
+ import { makeStyle } from '@gem-sdk/core';
2
+
3
+ const getDisplayStyle = (style)=>{
4
+ return Object.keys(style ?? {}).filter((key)=>[
5
+ '--d',
6
+ '--d-mobile',
7
+ '--d-tablet'
8
+ ].includes(key)).reduce((curr, key)=>({
9
+ ...curr,
10
+ [key]: style?.[key]
11
+ }), {});
12
+ };
13
+ const pointerEventStyle = (style)=>{
14
+ return Object.keys(style ?? {}).filter((key)=>[
15
+ '--d',
16
+ '--d-mobile',
17
+ '--d-tablet'
18
+ ].includes(key)).reduce((curr, key)=>({
19
+ ...curr,
20
+ [key.replace('--d', '--pe')]: style?.[key] === 'none' ? 'none' : 'auto'
21
+ }), {});
22
+ };
23
+ const getBorderStyle = (style)=>{
24
+ return Object.keys(style ?? {}).filter((key)=>[
25
+ '--bw',
26
+ '--bw-mobile',
27
+ '--bw-tablet',
28
+ '--bc',
29
+ '--bc-tablet',
30
+ '--bc-mobile',
31
+ '--b',
32
+ '--b-tablet',
33
+ '--b-mobile',
34
+ '--bs',
35
+ '--bs-tablet',
36
+ '--bs-mobile',
37
+ '--radius',
38
+ '--radius-tablet',
39
+ '--radius-mobile',
40
+ '--bblr',
41
+ '--bbrr',
42
+ '--btlr',
43
+ '--btrr',
44
+ '--bblr-tablet',
45
+ '--bbrr-tablet',
46
+ '--btlr-tablet',
47
+ '--btrr-tablet',
48
+ '--bblr-mobile',
49
+ '--bbrr-mobile',
50
+ '--btlr-mobile',
51
+ '--btrr-mobile'
52
+ ].includes(key)).reduce((curr, key)=>({
53
+ ...curr,
54
+ [key]: style?.[key]
55
+ }), {});
56
+ };
57
+ const getWrapperDialogStyle = (style)=>{
58
+ return Object.keys(style ?? {}).filter((key)=>key.startsWith('--mt') || key.startsWith('--mb') || key.startsWith('--ml') || key.startsWith('--mr')).reduce((curr, key)=>({
59
+ ...curr,
60
+ [key]: style?.[key]
61
+ }), {});
62
+ };
63
+ const getInnerStyle = (style)=>{
64
+ return Object.keys(style ?? {}).filter((key)=>!Object.keys(getWrapperDialogStyle(style)).includes(key) && !Object.keys(getDisplayStyle(style)).includes(key) && !Object.keys(getBorderStyle(style)).includes(key)).reduce((curr, key)=>({
65
+ ...curr,
66
+ [key]: style?.[key]
67
+ }), {});
68
+ };
69
+ const createDialogKey = (uid = '', type = '')=>({
70
+ id: `dialog:${uid}:${type}`,
71
+ time: `dialog:${uid}:${type}:time`
72
+ });
73
+ const isShowModal = (startDate, numberOfDay = 0)=>{
74
+ const start = startDate ? new Date(Number(startDate)) : new Date();
75
+ const c = Date.now() - start.getTime();
76
+ const diff = Math.abs(c / 24 / 60 / 60 / 1000);
77
+ return diff >= numberOfDay;
78
+ };
79
+ const isMobile = (userAgent)=>{
80
+ if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)) {
81
+ return true;
82
+ } else {
83
+ return false;
84
+ }
85
+ };
86
+ const getPropertyByDevice = (property, device)=>{
87
+ if (device === 'tablet') return property?.tablet ?? property?.desktop;
88
+ if (device === 'mobile') return property?.mobile ?? property?.tablet ?? property?.desktop;
89
+ return property?.desktop;
90
+ };
91
+ const heightStyle = (fullScreen, height)=>({
92
+ ...fullScreen?.desktop ? makeStyle({
93
+ h: '100%'
94
+ }) : !height?.desktop ? makeStyle({
95
+ minh: '300px'
96
+ }) : makeStyle({
97
+ h: height.desktop
98
+ }),
99
+ '--h-tablet': getPropertyByDevice(fullScreen, 'tablet') ? '100%' : getPropertyByDevice(height, 'tablet') ?? '300px',
100
+ '--h-mobile': getPropertyByDevice(fullScreen, 'mobile') ? '100%' : getPropertyByDevice(height, 'mobile') ?? '300px',
101
+ '--maxh': getPropertyByDevice(fullScreen, 'desktop') ? '100%' : '',
102
+ '--maxh-tablet': getPropertyByDevice(fullScreen, 'tablet') ? '100%' : '',
103
+ '--maxh-mobile': getPropertyByDevice(fullScreen, 'mobile') ? '100%' : ''
104
+ });
105
+ const removeHeightPercentForContent = (heightStyle)=>({
106
+ ...heightStyle,
107
+ '--h': heightStyle['--h']?.includes('%') ? '100%' : heightStyle['--h'],
108
+ '--h-tablet': heightStyle['--h-tablet']?.includes('%') ? '100%' : heightStyle['--h-tablet'],
109
+ '--h-mobile': heightStyle['--h-mobile']?.includes('%') ? '100%' : heightStyle['--h-mobile']
110
+ });
111
+ const parseNumber = (value)=>{
112
+ const numb = parseFloat(value?.toString() ?? '0');
113
+ if (isNaN(numb)) return 0;
114
+ return numb;
115
+ };
116
+
117
+ export { createDialogKey, getBorderStyle, getDisplayStyle, getInnerStyle, getPropertyByDevice, getWrapperDialogStyle, heightStyle, isMobile, isShowModal, parseNumber, pointerEventStyle, removeHeightPercentForContent };
@@ -0,0 +1,22 @@
1
+ const getAttr = ({ uid })=>{
2
+ return {
3
+ 'data-id': uid
4
+ };
5
+ };
6
+ const getAttrContainer = ({ uid })=>{
7
+ return {
8
+ 'data-gp-dialog-id': uid
9
+ };
10
+ };
11
+ const getAttrOverlay = ()=>{
12
+ return {
13
+ 'data-gp-dialog-overlay': ''
14
+ };
15
+ };
16
+ const getAttrClose = ()=>{
17
+ return {
18
+ 'data-gp-dialog-close': ''
19
+ };
20
+ };
21
+
22
+ export { getAttr, getAttrClose, getAttrContainer, getAttrOverlay };
@@ -0,0 +1,79 @@
1
+ import { isTransparentColor } from '../../../helpers.js';
2
+
3
+ function composeClasses(classList) {
4
+ return classList.split(' ').reduce((acc, item)=>{
5
+ acc[item] = true;
6
+ return acc;
7
+ }, {});
8
+ }
9
+ const getWrapperClasses = ()=>{
10
+ const classList = 'gps-lazy';
11
+ return {
12
+ ...composeClasses(classList)
13
+ };
14
+ };
15
+ const getContainClasses = (advancedCssClass)=>{
16
+ let classList = 'gp-dialog gp-bg-transparent';
17
+ if (advancedCssClass) classList += ` ${advancedCssClass}`;
18
+ return {
19
+ ...composeClasses(classList)
20
+ };
21
+ };
22
+ const getBackdropClasses = (position)=>{
23
+ let classList = 'gp-fixed gp-inset-0 gp-z-50 gp-flex gp-overflow-y-auto gp-overflow-x-hidden gp-shadow-xl';
24
+ if (position === 'center') classList += ` gp-items-center gp-justify-center`;
25
+ if (position === 'top') classList += ` gp-justify-center gp-items-start`;
26
+ if (position === 'top-right') classList += ` gp-justify-end gp-items-start`;
27
+ if (position === 'top-left') classList += ` gp-justify-start gp-items-start`;
28
+ if (position === 'bottom') classList += ` gp-items-end gp-justify-center`;
29
+ if (position === 'left') classList += ` gp-items-center gp-justify-start`;
30
+ if (position === 'right') classList += ` gp-items-center gp-justify-end`;
31
+ if (position === 'bottom-left') classList += ` gp-items-end gp-justify-start`;
32
+ if (position === 'bottom-right') classList += ` gp-items-end gp-justify-end`;
33
+ return {
34
+ ...composeClasses(classList)
35
+ };
36
+ };
37
+ const getOverlayClasses = ()=>{
38
+ const classList = 'gp-fixed gp-inset-0 gp-block gp-transition-all gp-duration-100';
39
+ return {
40
+ ...composeClasses(classList)
41
+ };
42
+ };
43
+ const getDialogContentClasses = ({ setting, enableEffect, isILP })=>{
44
+ const { effectType, background, closeButtonPosition } = setting ?? {};
45
+ let classList = 'gp-relative gp-max-h-full gp-max-w-full';
46
+ if (effectType === 'fade' && enableEffect) classList += ` gp-animate-[fadeIn_0.4s_ease-in]`;
47
+ if (effectType === 'zoom' && enableEffect) classList += ` gp-animate-[zoomIn_0.3s_ease-in]`;
48
+ if (effectType === 'zoom-out' && enableEffect) classList += ` gp-animate-[zoomOut_0.3s_ease-in]`;
49
+ if (effectType === 'horizontal' && enableEffect) classList += ` gp-animate-[slideInLeft_0.3s_ease-in]`;
50
+ if (effectType === 'vertical' && enableEffect) classList += ` gp-animate-[slideInUp_0.3s_ease-in]`;
51
+ if (effectType === 'unfold' && enableEffect) classList += ` gp-animate-[unfold_0.3s_ease-in-out]`;
52
+ if (closeButtonPosition !== 'outside') classList += ` gp-overflow-hidden`;
53
+ if (!isTransparentColor(background?.desktop?.color)) classList += ` gp-shadow-xl`;
54
+ if (!enableEffect && isILP) classList += ` gp-animate-[fadeOut_0.2s_ease-out]`;
55
+ return {
56
+ ...composeClasses(classList)
57
+ };
58
+ };
59
+ const getHeadContentClasses = ()=>{
60
+ const classList = 'gp-inline-block gp-h-screen gp-align-middle';
61
+ return {
62
+ ...composeClasses(classList)
63
+ };
64
+ };
65
+ const getButtonContentClasses = (closeButtonPosition)=>{
66
+ let classList = 'gp-absolute gp-top-0 gp-right-0 gp-z-[999999] gp-inline-flex gp-items-center gp-justify-center gp-outline-none focus-visible:gp-shadow-none focus-visible:gp-outline-none';
67
+ if (closeButtonPosition === 'outside') classList += ` gp-translate-x-1/2 -gp-translate-y-1/2 gp-shadow-md`;
68
+ return {
69
+ ...composeClasses(classList)
70
+ };
71
+ };
72
+ const getBodyContentClasses = ()=>{
73
+ const classList = 'gp-h-full gp-w-full gp-overflow-y-auto gp-overflow-x-hidden !gp-max-h-screen';
74
+ return {
75
+ ...composeClasses(classList)
76
+ };
77
+ };
78
+
79
+ export { getBackdropClasses, getBodyContentClasses, getButtonContentClasses, getContainClasses, getDialogContentClasses, getHeadContentClasses, getOverlayClasses, getWrapperClasses };
@@ -0,0 +1,98 @@
1
+ import { makeStyle, getGlobalColorResponsiveStyle, makeStyleResponsive, makeWidth, composeRadius, getStyleBackgroundByDevice } from '@gem-sdk/core';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
4
+ import { ELEMENT_Z_INDEX } from '../../../common/const.js';
5
+ import { pointerEventStyle, getDisplayStyle, getWrapperDialogStyle, getBorderStyle, heightStyle, getInnerStyle, removeHeightPercentForContent } from './common.js';
6
+
7
+ function filterTruthyStyles(styles) {
8
+ return Object.fromEntries(Object.entries(styles || {}).filter(([, value])=>!!value));
9
+ }
10
+ const getWrapperStyle = (display)=>{
11
+ const composeStyles = {
12
+ '--d': display?.desktop ? 'contents' : 'none',
13
+ '--d-tablet': display?.tablet ? 'contents' : 'none',
14
+ '--d-mobile': display?.mobile ? 'contents' : 'none'
15
+ };
16
+ return filterTruthyStyles(composeStyles);
17
+ };
18
+ const getContainStyle = ()=>{
19
+ const composeStyles = {
20
+ 'z-index': ELEMENT_Z_INDEX.DIALOG
21
+ };
22
+ return filterTruthyStyles(composeStyles);
23
+ };
24
+ const getBackdropStyle = (style)=>{
25
+ const composeStyles = {
26
+ ...pointerEventStyle(style)
27
+ };
28
+ return filterTruthyStyles(composeStyles);
29
+ };
30
+ const getOverlayStyle = (overlayOpacity, overlayColor, style)=>{
31
+ const composeStyles = {
32
+ ...makeStyle({
33
+ op: (overlayOpacity ?? 0) / 100
34
+ }),
35
+ ...getGlobalColorResponsiveStyle('bgc', {
36
+ desktop: overlayColor
37
+ }),
38
+ ...getDisplayStyle(style)
39
+ };
40
+ return filterTruthyStyles(composeStyles);
41
+ };
42
+ const getDialogContentStyle = ({ style, width, height, fullScreen })=>{
43
+ const composeStyles = {
44
+ ...getWrapperDialogStyle(style),
45
+ ...getBorderStyle(style),
46
+ ...getDisplayStyle(style),
47
+ ...makeStyleResponsive('w', makeWidth(width, fullScreen)),
48
+ ...heightStyle(fullScreen, height)
49
+ };
50
+ return filterTruthyStyles(composeStyles);
51
+ };
52
+ const getButtonContentStyle = (setting)=>{
53
+ const { btnSize, btnBg, btnRounded, btnColor } = setting ?? {};
54
+ const composeStyles = {
55
+ ...makeStyle({
56
+ w: `${parseInt(btnSize.toString())}px`,
57
+ h: `${parseInt(btnSize.toString())}px`
58
+ }),
59
+ ...getGlobalColorResponsiveStyle('c', {
60
+ desktop: btnColor
61
+ }),
62
+ ...getGlobalColorResponsiveStyle('bgc', {
63
+ desktop: btnBg
64
+ }),
65
+ ...composeRadius({
66
+ normal: btnRounded
67
+ })
68
+ };
69
+ return filterTruthyStyles(composeStyles);
70
+ };
71
+ const getSvgContentStyle = (iconSize)=>{
72
+ let composeStyles = {};
73
+ if (iconSize) {
74
+ composeStyles = {
75
+ ...makeStyle({
76
+ w: iconSize,
77
+ h: iconSize
78
+ })
79
+ };
80
+ }
81
+ return filterTruthyStyles(composeStyles);
82
+ };
83
+ const getBodyContentStyle = (setting, style)=>{
84
+ const { fullScreen, height, background } = setting ?? {};
85
+ const composeStyles = {
86
+ ...getInnerStyle(style),
87
+ ...removeHeightPercentForContent(heightStyle(fullScreen, height)),
88
+ 'border-radius': 'inherit',
89
+ ...getStyleBackgroundByDevice(background, {
90
+ ignoreBackgroundImage: true,
91
+ ignoreBackgroundImageProperties: true,
92
+ ignoreBgAttachment: true
93
+ })
94
+ };
95
+ return filterTruthyStyles(composeStyles);
96
+ };
97
+
98
+ export { getBackdropStyle, getBodyContentStyle, getButtonContentStyle, getContainStyle, getDialogContentStyle, getOverlayStyle, getSvgContentStyle, getWrapperStyle };