@gem-sdk/components 2.0.0-dev.293 → 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.
- package/dist/cjs/accordion/components/common/index.js +2 -2
- package/dist/cjs/article/components/ArticleAuthor.js +1 -1
- package/dist/cjs/article/components/ArticleTitle.js +3 -1
- package/dist/cjs/article/components/ArticleTitle.liquid.js +5 -2
- package/dist/cjs/article/setting/ArticleList.js +0 -30
- package/dist/cjs/article/setting/configs/ArticleAuthor/presets.js +0 -9
- package/dist/cjs/article/setting/configs/ArticleAuthor/settings.js +9 -5
- package/dist/cjs/article/setting/configs/ArticleAuthor/uiV2.js +16 -0
- package/dist/cjs/article/setting/configs/ArticleCategory/presets.js +0 -9
- package/dist/cjs/article/setting/configs/ArticleCategory/settings.js +9 -5
- package/dist/cjs/article/setting/configs/ArticleDate/presets.js +0 -9
- package/dist/cjs/article/setting/configs/ArticleDate/settings.js +9 -5
- package/dist/cjs/article/setting/configs/ArticleImage/settings.js +22 -1
- package/dist/cjs/article/setting/configs/ArticleTitle/settings.js +36 -7
- package/dist/cjs/article/setting/configs/ArticleTitle/uiV2.js +47 -2
- package/dist/cjs/builder.js +6 -2
- package/dist/cjs/button/components/Button.js +1 -1
- package/dist/cjs/button/components/Button.liquid.js +1 -1
- package/dist/cjs/button/components/ButtonIcon.liquid.js +3 -1
- package/dist/cjs/button/components/ButtonLabel.liquid.js +3 -1
- package/dist/cjs/button/components/common/attributes.js +2 -2
- package/dist/cjs/button/components/common/classes.js +2 -1
- package/dist/cjs/button/components/common/styles.js +9 -11
- package/dist/cjs/button/setting/configs/settings.js +7 -8
- package/dist/cjs/button/setting/configs/uiV2.js +4 -50
- package/dist/cjs/dialog/components/Dialog.js +109 -394
- package/dist/cjs/dialog/components/Dialog.liquid.js +129 -153
- package/dist/cjs/dialog/components/common/common.js +130 -0
- package/dist/cjs/dialog/components/common/getAttr.js +27 -0
- package/dist/cjs/dialog/components/common/getClasses.js +88 -0
- package/dist/cjs/dialog/components/common/getStyle.js +107 -0
- package/dist/cjs/dialog/components/hooks/useDialog.js +233 -0
- package/dist/cjs/dialog/setting/configs/settings.js +1 -1
- package/dist/cjs/dialog/setting/configs/uiV2.js +35 -25
- package/dist/cjs/form/components/form-checkbox/FormCheckbox.js +0 -4
- package/dist/cjs/form/components/textinput/TextInput.js +58 -0
- package/dist/cjs/form/components/textinput/TextInput.liquid.js +60 -0
- package/dist/cjs/form/components/textinput/common/composeClasses.js +33 -0
- package/dist/cjs/form/components/textinput/common/composeStyles.js +70 -0
- package/dist/cjs/form/next.js +5 -1
- package/dist/cjs/form/setting/index.js +3 -1
- package/dist/cjs/form/setting/newsletter/configs/settings.js +4 -2
- package/dist/cjs/form/setting/newsletter/configs/uiV2.js +2 -0
- package/dist/cjs/form/setting/text-input/TextInput.js +53 -0
- package/dist/cjs/form/setting/text-input/configs/settings.js +307 -0
- package/dist/cjs/form/setting/text-input/configs/uiV1.js +106 -0
- package/dist/cjs/form/setting/text-input/configs/uiV2.js +303 -0
- package/dist/cjs/grid/row/setting/configs/settings.js +6 -3
- package/dist/cjs/helpers.js +8 -0
- package/dist/cjs/icon-list/common/attrs.js +10 -0
- package/dist/cjs/icon-list/common/classes.js +9 -0
- package/dist/cjs/icon-list/common/styles.js +29 -0
- package/dist/cjs/icon-list/components/IconList.js +19 -30
- package/dist/cjs/icon-list/components/IconList.liquid.js +21 -24
- package/dist/cjs/icon-list/components/IconListItem.js +13 -7
- package/dist/cjs/icon-list/components/IconListItem.liquid.js +13 -7
- package/dist/cjs/icon-list-hoz/components/IconListHoz.js +37 -25
- package/dist/cjs/icon-list-hoz/components/IconListHoz.liquid.js +31 -25
- package/dist/cjs/icon-list-hoz/components/IconListHozItem.js +12 -6
- package/dist/cjs/icon-list-hoz/components/IconListIHozItem.liquid.js +26 -0
- package/dist/cjs/icon-list-hoz/components/common/getAttr.js +9 -0
- package/dist/cjs/icon-list-hoz/components/common/getClasses.js +24 -0
- package/dist/cjs/icon-list-hoz/components/common/getStyle.js +30 -0
- package/dist/cjs/image/components/AdaptiveImage.js +1 -1
- package/dist/cjs/image/components/AdaptiveImage.liquid.js +4 -4
- package/dist/cjs/image/components/Image.js +1 -5
- package/dist/cjs/image/components/common/styles.js +2 -2
- package/dist/cjs/image/components/helpers/getNextImageLiquidAttrs.js +6 -24
- package/dist/cjs/image/components/helpers/getNextImageReactAttrs.js +3 -3
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/index.liquid.js +7 -3
- package/dist/cjs/line/common/classes.js +66 -0
- package/dist/cjs/line/common/index.js +16 -0
- package/dist/cjs/line/common/styles.js +120 -0
- package/dist/cjs/line/components/Divider.js +26 -0
- package/dist/cjs/line/components/Divider.liquid.js +22 -0
- package/dist/cjs/line/components/Line.js +98 -0
- package/dist/cjs/line/components/Line.liquid.js +86 -0
- package/dist/cjs/line/next.js +1 -1
- package/dist/cjs/post-purchase/line/setting/configs/uiV2.js +1 -1
- package/dist/cjs/post-purchase/link/setting/configs/settings.js +2 -1
- package/dist/cjs/post-purchase/link/setting/configs/uiV2.js +1 -1
- package/dist/cjs/post-purchase/product/settings/product-variants/configs/uiV2.js +1 -1
- package/dist/cjs/product/components/FileUpload/components/config/setting.js +24 -26
- package/dist/cjs/product/components/FileUpload/components/config/uiV2.js +12 -179
- package/dist/cjs/product/components/ProductList.js +1 -1
- package/dist/cjs/product/components/ProductVariants/index.js +2 -2
- package/dist/cjs/product/components/ProductVariants/index.liquid.js +2 -2
- package/dist/cjs/product/components/ProductVariants/variants/Dropdown.js +8 -3
- package/dist/cjs/product/components/ProductVariants/variants/Dropdown.liquid.js +7 -2
- package/dist/cjs/product/setting/ProductVariants.js +8 -1374
- package/dist/cjs/product/setting/product/configs/uiV2.js +2 -2
- package/dist/cjs/product/setting/product-list/configs/uiV2.js +0 -3
- package/dist/cjs/product/setting/product-variant/configs/presets.js +168 -0
- package/dist/cjs/product/setting/product-variant/configs/settings.js +732 -0
- package/dist/cjs/product/setting/product-variant/configs/uiV1.js +509 -0
- package/dist/cjs/product/setting/product-variant/configs/uiV2.js +347 -0
- package/dist/cjs/third-party/components/EcoboostifyShoppableReelUgc.js +33 -0
- package/dist/cjs/third-party/components/EcoboostifyShoppableReelUgc.liquid.js +12 -0
- package/dist/cjs/third-party/components/RechargeSubscriptions.liquid.js +1 -1
- package/dist/cjs/third-party/configs/EcoboostifyShoppableReelUgc.js +12 -0
- package/dist/cjs/third-party/next.js +5 -0
- package/dist/cjs/third-party/setting/EcoboostifyShoppableReelUgc.js +142 -0
- package/dist/cjs/third-party/setting/RechargeSubscriptions.js +5 -2
- package/dist/cjs/third-party/setting/index.js +3 -1
- package/dist/esm/accordion/components/common/index.js +2 -2
- package/dist/esm/article/components/ArticleAuthor.js +1 -1
- package/dist/esm/article/components/ArticleTitle.js +3 -1
- package/dist/esm/article/components/ArticleTitle.liquid.js +5 -2
- package/dist/esm/article/setting/ArticleList.js +0 -30
- package/dist/esm/article/setting/configs/ArticleAuthor/presets.js +0 -9
- package/dist/esm/article/setting/configs/ArticleAuthor/settings.js +9 -5
- package/dist/esm/article/setting/configs/ArticleAuthor/uiV2.js +16 -0
- package/dist/esm/article/setting/configs/ArticleCategory/presets.js +0 -9
- package/dist/esm/article/setting/configs/ArticleCategory/settings.js +9 -5
- package/dist/esm/article/setting/configs/ArticleDate/presets.js +0 -9
- package/dist/esm/article/setting/configs/ArticleDate/settings.js +9 -5
- package/dist/esm/article/setting/configs/ArticleImage/settings.js +22 -1
- package/dist/esm/article/setting/configs/ArticleTitle/settings.js +36 -7
- package/dist/esm/article/setting/configs/ArticleTitle/uiV2.js +47 -2
- package/dist/esm/builder.js +6 -2
- package/dist/esm/button/components/Button.js +1 -1
- package/dist/esm/button/components/Button.liquid.js +1 -1
- package/dist/esm/button/components/ButtonIcon.liquid.js +3 -1
- package/dist/esm/button/components/ButtonLabel.liquid.js +3 -1
- package/dist/esm/button/components/common/attributes.js +2 -2
- package/dist/esm/button/components/common/classes.js +3 -2
- package/dist/esm/button/components/common/styles.js +10 -12
- package/dist/esm/button/setting/configs/settings.js +7 -8
- package/dist/esm/button/setting/configs/uiV2.js +4 -50
- package/dist/esm/dialog/components/Dialog.js +110 -395
- package/dist/esm/dialog/components/Dialog.liquid.js +130 -154
- package/dist/esm/dialog/components/common/common.js +117 -0
- package/dist/esm/dialog/components/common/getAttr.js +22 -0
- package/dist/esm/dialog/components/common/getClasses.js +79 -0
- package/dist/esm/dialog/components/common/getStyle.js +98 -0
- package/dist/esm/dialog/components/hooks/useDialog.js +231 -0
- package/dist/esm/dialog/setting/configs/settings.js +1 -1
- package/dist/esm/dialog/setting/configs/uiV2.js +35 -25
- package/dist/esm/form/components/form-checkbox/FormCheckbox.js +0 -4
- package/dist/esm/form/components/textinput/TextInput.js +54 -0
- package/dist/esm/form/components/textinput/TextInput.liquid.js +56 -0
- package/dist/esm/form/components/textinput/common/composeClasses.js +29 -0
- package/dist/esm/form/components/textinput/common/composeStyles.js +67 -0
- package/dist/esm/form/next.js +5 -1
- package/dist/esm/form/setting/index.js +3 -1
- package/dist/esm/form/setting/newsletter/configs/settings.js +4 -2
- package/dist/esm/form/setting/newsletter/configs/uiV2.js +2 -0
- package/dist/esm/form/setting/text-input/TextInput.js +49 -0
- package/dist/esm/form/setting/text-input/configs/settings.js +305 -0
- package/dist/esm/form/setting/text-input/configs/uiV1.js +104 -0
- package/dist/esm/form/setting/text-input/configs/uiV2.js +301 -0
- package/dist/esm/grid/row/setting/configs/settings.js +6 -3
- package/dist/esm/helpers.js +8 -1
- package/dist/esm/icon-list/common/attrs.js +8 -0
- package/dist/esm/icon-list/common/classes.js +6 -0
- package/dist/esm/icon-list/common/styles.js +25 -0
- package/dist/esm/icon-list/components/IconList.js +21 -32
- package/dist/esm/icon-list/components/IconList.liquid.js +21 -24
- package/dist/esm/icon-list/components/IconListItem.js +13 -7
- package/dist/esm/icon-list/components/IconListItem.liquid.js +14 -8
- package/dist/esm/icon-list-hoz/components/IconListHoz.js +38 -26
- package/dist/esm/icon-list-hoz/components/IconListHoz.liquid.js +32 -26
- package/dist/esm/icon-list-hoz/components/IconListHozItem.js +12 -6
- package/dist/esm/icon-list-hoz/components/IconListIHozItem.liquid.js +22 -0
- package/dist/esm/icon-list-hoz/components/common/getAttr.js +7 -0
- package/dist/esm/icon-list-hoz/components/common/getClasses.js +21 -0
- package/dist/esm/icon-list-hoz/components/common/getStyle.js +27 -0
- package/dist/esm/image/components/AdaptiveImage.js +2 -2
- package/dist/esm/image/components/AdaptiveImage.liquid.js +4 -4
- package/dist/esm/image/components/Image.js +2 -6
- package/dist/esm/image/components/common/styles.js +2 -2
- package/dist/esm/image/components/helpers/getNextImageLiquidAttrs.js +6 -24
- package/dist/esm/image/components/helpers/getNextImageReactAttrs.js +3 -3
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.liquid.js +4 -2
- package/dist/esm/line/common/classes.js +59 -0
- package/dist/esm/line/common/index.js +14 -0
- package/dist/esm/line/common/styles.js +114 -0
- package/dist/esm/line/components/Divider.js +22 -0
- package/dist/esm/line/components/Divider.liquid.js +18 -0
- package/dist/esm/line/components/Line.js +94 -0
- package/dist/esm/line/components/Line.liquid.js +82 -0
- package/dist/esm/line/next.js +1 -1
- package/dist/esm/post-purchase/line/setting/configs/uiV2.js +1 -1
- package/dist/esm/post-purchase/link/setting/configs/settings.js +2 -1
- package/dist/esm/post-purchase/link/setting/configs/uiV2.js +1 -1
- package/dist/esm/post-purchase/product/settings/product-variants/configs/uiV2.js +1 -1
- package/dist/esm/product/components/FileUpload/components/config/setting.js +24 -26
- package/dist/esm/product/components/FileUpload/components/config/uiV2.js +12 -179
- package/dist/esm/product/components/ProductList.js +1 -1
- package/dist/esm/product/components/ProductVariants/index.js +2 -2
- package/dist/esm/product/components/ProductVariants/index.liquid.js +2 -2
- package/dist/esm/product/components/ProductVariants/variants/Dropdown.js +8 -3
- package/dist/esm/product/components/ProductVariants/variants/Dropdown.liquid.js +7 -2
- package/dist/esm/product/setting/ProductVariants.js +8 -1374
- package/dist/esm/product/setting/product/configs/uiV2.js +2 -2
- package/dist/esm/product/setting/product-list/configs/uiV2.js +0 -3
- package/dist/esm/product/setting/product-variant/configs/presets.js +166 -0
- package/dist/esm/product/setting/product-variant/configs/settings.js +730 -0
- package/dist/esm/product/setting/product-variant/configs/uiV1.js +507 -0
- package/dist/esm/product/setting/product-variant/configs/uiV2.js +345 -0
- package/dist/esm/third-party/components/EcoboostifyShoppableReelUgc.js +29 -0
- package/dist/esm/third-party/components/EcoboostifyShoppableReelUgc.liquid.js +8 -0
- package/dist/esm/third-party/components/RechargeSubscriptions.liquid.js +1 -1
- package/dist/esm/third-party/configs/EcoboostifyShoppableReelUgc.js +8 -0
- package/dist/esm/third-party/next.js +5 -0
- package/dist/esm/third-party/setting/EcoboostifyShoppableReelUgc.js +138 -0
- package/dist/esm/third-party/setting/RechargeSubscriptions.js +5 -2
- package/dist/esm/third-party/setting/index.js +3 -1
- package/dist/types/index.d.ts +184 -166
- package/package.json +2 -2
- package/dist/cjs/dialog/helpers/common.js +0 -55
- package/dist/cjs/icon-list-hoz/components/IconListItemHoz.liquid.js +0 -23
- package/dist/cjs/line/Divider.js +0 -35
- package/dist/cjs/line/Divider.liquid.js +0 -35
- package/dist/cjs/line/Line.js +0 -167
- package/dist/cjs/line/Line.liquid.js +0 -163
- package/dist/esm/dialog/helpers/common.js +0 -47
- package/dist/esm/icon-list-hoz/components/IconListItemHoz.liquid.js +0 -19
- package/dist/esm/line/Divider.js +0 -31
- package/dist/esm/line/Divider.liquid.js +0 -31
- package/dist/esm/line/Line.js +0 -163
- package/dist/esm/line/Line.liquid.js +0 -159
- /package/dist/cjs/dialog/{hooks/use-scroll-percentage.js → components/hooks/useScrollPercentage.js} +0 -0
- /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/color.js +0 -0
- /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/dropdown.js +0 -0
- /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image-shopify.js +0 -0
- /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image.js +0 -0
- /package/dist/cjs/product/setting/{swatches-style-config → product-variant/swatches-style-config}/rectangle-list.js +0 -0
- /package/dist/esm/dialog/{hooks/use-scroll-percentage.js → components/hooks/useScrollPercentage.js} +0 -0
- /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/color.js +0 -0
- /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/dropdown.js +0 -0
- /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image-shopify.js +0 -0
- /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/image.js +0 -0
- /package/dist/esm/product/setting/{swatches-style-config → product-variant/swatches-style-config}/rectangle-list.js +0 -0
|
@@ -1,73 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
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 = (
|
|
7
|
+
const Dialog = (props)=>{
|
|
8
|
+
const { setting, children, builderProps, style, advanced, builderAttrs } = props;
|
|
9
9
|
const display = advanced?.d;
|
|
10
|
-
const
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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="${
|
|
141
|
-
|
|
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
|
-
|
|
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
|
-
${
|
|
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 };
|