@gem-sdk/components 2.0.0-dev.346 → 2.0.0-dev.348
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/carousel/components/plugins/AutoPlayPlugin.js +58 -17
- package/dist/cjs/countdown-timer/components/Countdown.js +103 -307
- package/dist/cjs/countdown-timer/components/Countdown.liquid.js +92 -56
- package/dist/cjs/countdown-timer/components/common/getAttr.js +15 -0
- package/dist/cjs/countdown-timer/components/common/getClasses.js +69 -0
- package/dist/cjs/countdown-timer/components/common/getStyle.js +66 -0
- package/dist/cjs/countdown-timer/components/hooks/useCountDownTimer.js +67 -0
- package/dist/cjs/countdown-timer/{hooks → components/hooks}/useTimeLeft.js +1 -1
- package/dist/cjs/countdown-timer/index.js +1 -1
- package/dist/cjs/countdown-timer/setting/Countdown.js +1 -1
- package/dist/cjs/countdown-timer/setting/configs/settings.js +1 -1
- package/dist/cjs/product/components/ProductProperties/ProductPropertyInput/ProductPropertyInput.liquid.js +1 -1
- package/dist/cjs/product/setting/product-properties/configs/settingsV2.js +43 -14
- package/dist/cjs/product/setting/product-properties/configs/uiV2.js +5 -2
- package/dist/cjs/third-party/components/AliReviews.liquid.js +1 -1
- package/dist/cjs/third-party/components/FeraReviews/FeraReviewsSampleContent.js +3 -3
- package/dist/cjs/third-party/components/FeraReviews/LiquidTemplateByWidget.js +2 -2
- package/dist/cjs/third-party/components/FeraReviews.js +0 -5
- package/dist/cjs/third-party/components/GoogleReviewsByReputon.liquid.js +2 -2
- package/dist/cjs/third-party/components/JudgemeReviews.liquid.js +5 -5
- package/dist/cjs/third-party/components/KachingBundles.liquid.js +1 -1
- package/dist/cjs/third-party/components/KingProductOptions.liquid.js +1 -1
- package/dist/cjs/third-party/components/LaiProductReviews/LiquidTemplateByWiget.js +3 -3
- package/dist/cjs/third-party/components/LooxReviews.liquid.js +1 -1
- package/dist/cjs/third-party/components/Ryviu.liquid.js +1 -1
- package/dist/cjs/third-party/components/Vitals.liquid.js +2 -2
- package/dist/cjs/third-party/setting/TrustshopProductReviews.js +3 -3
- package/dist/cjs/third-party/setting/WhatmoreShoppableVideosreel.js +36 -36
- package/dist/cjs/third-party/types/index.js +5 -0
- package/dist/esm/carousel/components/plugins/AutoPlayPlugin.js +58 -17
- package/dist/esm/countdown-timer/components/Countdown.js +104 -308
- package/dist/esm/countdown-timer/components/Countdown.liquid.js +93 -57
- package/dist/esm/countdown-timer/components/common/getAttr.js +12 -0
- package/dist/esm/countdown-timer/components/common/getClasses.js +61 -0
- package/dist/esm/countdown-timer/components/common/getStyle.js +60 -0
- package/dist/esm/countdown-timer/components/hooks/useCountDownTimer.js +63 -0
- package/dist/esm/countdown-timer/{hooks → components/hooks}/useTimeLeft.js +1 -1
- package/dist/esm/countdown-timer/index.js +1 -1
- package/dist/esm/countdown-timer/setting/Countdown.js +1 -1
- package/dist/esm/countdown-timer/setting/configs/settings.js +1 -1
- package/dist/esm/product/components/ProductProperties/ProductPropertyInput/ProductPropertyInput.liquid.js +1 -1
- package/dist/esm/product/setting/product-properties/configs/settingsV2.js +43 -14
- package/dist/esm/product/setting/product-properties/configs/uiV2.js +5 -2
- package/dist/esm/third-party/components/AliReviews.liquid.js +1 -1
- package/dist/esm/third-party/components/FeraReviews/FeraReviewsSampleContent.js +1 -1
- package/dist/esm/third-party/components/FeraReviews/LiquidTemplateByWidget.js +1 -1
- package/dist/esm/third-party/components/FeraReviews.js +1 -5
- package/dist/esm/third-party/components/GoogleReviewsByReputon.liquid.js +2 -2
- package/dist/esm/third-party/components/JudgemeReviews.liquid.js +5 -5
- package/dist/esm/third-party/components/KachingBundles.liquid.js +1 -1
- package/dist/esm/third-party/components/KingProductOptions.liquid.js +1 -1
- package/dist/esm/third-party/components/LaiProductReviews/LiquidTemplateByWiget.js +3 -3
- package/dist/esm/third-party/components/LooxReviews.liquid.js +1 -1
- package/dist/esm/third-party/components/Ryviu.liquid.js +1 -1
- package/dist/esm/third-party/components/Vitals.liquid.js +2 -2
- package/dist/esm/third-party/setting/TrustshopProductReviews.js +3 -3
- package/dist/esm/third-party/setting/WhatmoreShoppableVideosreel.js +36 -36
- package/dist/esm/third-party/types/index.js +5 -1
- package/dist/types/index.d.ts +1541 -1531
- package/package.json +1 -1
|
@@ -1,335 +1,131 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { formatTime
|
|
4
|
-
import useTimeLeft from '../hooks/useTimeLeft.js';
|
|
5
|
-
import { useEditorMode, useInteraction, makeStyleResponsive, composeSize, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertBorderColor, composeRadius, makeStyle, getGlobalColorCSSProp, cls, getGlobalColorClass, genSizeClass } from '@gem-sdk/core';
|
|
6
|
-
import { useRef } from 'react';
|
|
3
|
+
import { formatTime } from '../helpers.js';
|
|
7
4
|
import Text from '../../text/components/Text.js';
|
|
8
|
-
import {
|
|
5
|
+
import { useEditorMode } from '@gem-sdk/core';
|
|
6
|
+
import useCountDownTimer from './hooks/useCountDownTimer.js';
|
|
7
|
+
import { createClass, createAttr, createStyle, If } from '@gem-sdk/system';
|
|
8
|
+
import { getAttr } from './common/getAttr.js';
|
|
9
|
+
import { getTextExpireClasses, getWrapperClasses, getContentClasses, getTextFrontClasses, getLinkClasses, getDateClasses, getTextBackClasses } from './common/getClasses.js';
|
|
10
|
+
import { getWrapperStyle, getContainStyle, getDateStyle, getTextFrontStyle, getTextBackStyle } from './common/getStyle.js';
|
|
9
11
|
|
|
10
|
-
const Countdown = (
|
|
11
|
-
const {
|
|
12
|
+
const Countdown = (props)=>{
|
|
13
|
+
const { setting, styles, builderProps, advanced } = props;
|
|
14
|
+
const { labelTypo, numTypo, labelTypography, numTypography } = styles ?? {};
|
|
15
|
+
const { weekLabel, dayLabel, hourLabel, minuteLabel, secondLabel, enableWeek, enableDay, enableHour, enableMinute, enableSecond, redirectUrl } = setting ?? {};
|
|
12
16
|
const mode = useEditorMode();
|
|
13
|
-
const ref =
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
timerEverygreen: setting?.timerEverygreen,
|
|
18
|
-
dateStandard: setting?.dateStandard,
|
|
19
|
-
behaviour: setting?.behaviour,
|
|
20
|
-
loopAfterFinish: setting?.loopAfterFinish,
|
|
21
|
-
redirectUrl: setting?.redirectUrl,
|
|
22
|
-
timeZone: setting?.timeZone
|
|
17
|
+
const { week, day, hour, minute, second, timeLeft, ref } = useCountDownTimer(setting, builderProps);
|
|
18
|
+
const hasLinkCover = !!redirectUrl?.link && mode !== 'edit';
|
|
19
|
+
const textExpireClasses = createClass({
|
|
20
|
+
...getTextExpireClasses()
|
|
23
21
|
});
|
|
24
|
-
const { week, day, hour, minute, second } = convertTime(timeLeft, {
|
|
25
|
-
enableWeek: setting?.enableWeek,
|
|
26
|
-
enableDay: setting?.enableDay,
|
|
27
|
-
enableHour: setting?.enableHour,
|
|
28
|
-
enableMinute: setting?.enableMinute,
|
|
29
|
-
enableSecond: setting?.enableSecond
|
|
30
|
-
});
|
|
31
|
-
useTransition((preTimeLeft)=>{
|
|
32
|
-
if (preTimeLeft !== timeLeft) {
|
|
33
|
-
dispatchInteractionCountdownTimer(timeLeft);
|
|
34
|
-
}
|
|
35
|
-
}, [
|
|
36
|
-
timeLeft
|
|
37
|
-
]);
|
|
38
|
-
const dispatchInteractionCountdownTimer = (timeLeft)=>{
|
|
39
|
-
const element = ref.current;
|
|
40
|
-
const gpInteractionCounter = new Map(Object.entries(JSON.parse(element?.getAttribute('gp-interaction-counter') ?? '{}')));
|
|
41
|
-
if (gpInteractionCounter.size <= 0) return;
|
|
42
|
-
gpInteractionCounter.forEach((_, key)=>{
|
|
43
|
-
if (timeLeft !== Number(key)) return;
|
|
44
|
-
trigger({
|
|
45
|
-
event: 'gp:countdown-timer',
|
|
46
|
-
selector: `[data-id="${builderProps?.uid}"]`,
|
|
47
|
-
element,
|
|
48
|
-
data: Number(key)
|
|
49
|
-
});
|
|
50
|
-
if (!setting?.loopAfterFinish) {
|
|
51
|
-
gpInteractionCounter.delete(key);
|
|
52
|
-
element.setAttribute('gp-interaction-counter', JSON.stringify(Object.fromEntries(gpInteractionCounter)));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
const renderClassWithCondition = (condition, className)=>condition ? className : '';
|
|
57
22
|
if (setting?.autoHideWhenTimeout && timeLeft <= 0) {
|
|
58
23
|
if (mode !== 'edit') {
|
|
59
24
|
return null;
|
|
60
25
|
}
|
|
61
26
|
return /*#__PURE__*/ jsx("div", {
|
|
62
|
-
className:
|
|
27
|
+
className: textExpireClasses,
|
|
63
28
|
children: /*#__PURE__*/ jsx("span", {
|
|
64
29
|
children: "Countdown is run out of time (this only visible in the editor)"
|
|
65
30
|
})
|
|
66
31
|
});
|
|
67
32
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
33
|
+
const attrs = createAttr({
|
|
34
|
+
...getAttr({
|
|
35
|
+
uid: builderProps?.uid || ''
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
const wrapperStyle = createStyle({
|
|
39
|
+
...getWrapperStyle(styles)
|
|
40
|
+
});
|
|
41
|
+
const wrapperClasses = createClass({
|
|
42
|
+
...getWrapperClasses(advanced?.cssClass)
|
|
43
|
+
});
|
|
44
|
+
const containClasses = createClass({
|
|
45
|
+
...getContentClasses()
|
|
46
|
+
});
|
|
47
|
+
const containStyle = createStyle({
|
|
48
|
+
...getContainStyle(styles)
|
|
49
|
+
});
|
|
50
|
+
const dateStyle = createStyle({
|
|
51
|
+
...getDateStyle(styles)
|
|
52
|
+
});
|
|
53
|
+
const dateClasses = (dateLabel)=>createClass({
|
|
54
|
+
...getDateClasses(styles, dateLabel)
|
|
55
|
+
});
|
|
56
|
+
const textFrontClasses = createClass({
|
|
57
|
+
...getTextFrontClasses(styles)
|
|
58
|
+
});
|
|
59
|
+
const textFrontStyle = createStyle({
|
|
60
|
+
...getTextFrontStyle(styles)
|
|
61
|
+
});
|
|
62
|
+
const textBackStyle = createStyle({
|
|
63
|
+
...getTextBackStyle(styles)
|
|
64
|
+
});
|
|
65
|
+
const textBackClasses = (textLabel)=>createClass({
|
|
66
|
+
...getTextBackClasses(styles, textLabel)
|
|
67
|
+
});
|
|
68
|
+
const linkClasses = createClass({
|
|
69
|
+
...getLinkClasses()
|
|
70
|
+
});
|
|
71
|
+
const timeTemplate = (time, textLabel)=>{
|
|
72
|
+
const textFrontLabel = formatTime(time);
|
|
73
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
74
|
+
style: dateStyle,
|
|
75
|
+
className: dateClasses(textLabel),
|
|
81
76
|
children: [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
...handleConvertBorderWidth(styles?.borderState),
|
|
87
|
-
...handleConvertBorderColor(styles?.borderState),
|
|
88
|
-
...composeRadius(styles?.roundedState),
|
|
89
|
-
...makeStyle({
|
|
90
|
-
bg: getGlobalColorCSSProp(styles?.backgroundItemColor)
|
|
91
|
-
})
|
|
77
|
+
/*#__PURE__*/ jsx(Text, {
|
|
78
|
+
styles: {
|
|
79
|
+
typography: numTypography,
|
|
80
|
+
typo: numTypo
|
|
92
81
|
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
styles: {
|
|
98
|
-
typography: styles?.numTypography,
|
|
99
|
-
typo: styles?.numTypo
|
|
100
|
-
},
|
|
101
|
-
style: {
|
|
102
|
-
...makeStyle({
|
|
103
|
-
mb: styles?.verticalGap,
|
|
104
|
-
c: getGlobalColorCSSProp(colorNumber)
|
|
105
|
-
})
|
|
106
|
-
},
|
|
107
|
-
setting: {
|
|
108
|
-
text: formatTime(week),
|
|
109
|
-
htmlTag: 'div',
|
|
110
|
-
excludeFlex: true
|
|
111
|
-
}
|
|
112
|
-
}),
|
|
113
|
-
/*#__PURE__*/ jsx(Text, {
|
|
114
|
-
className: cls(getGlobalColorClass('text', colorLabel), renderClassWithCondition(!setting?.weekLabel, 'gp-hidden')),
|
|
115
|
-
styles: {
|
|
116
|
-
typography: styles?.labelTypography,
|
|
117
|
-
typo: styles?.labelTypo
|
|
118
|
-
},
|
|
119
|
-
style: {
|
|
120
|
-
...makeStyle({
|
|
121
|
-
c: getGlobalColorCSSProp(colorLabel)
|
|
122
|
-
})
|
|
123
|
-
},
|
|
124
|
-
setting: {
|
|
125
|
-
text: setting?.weekLabel,
|
|
126
|
-
htmlTag: 'p',
|
|
127
|
-
excludeFlex: true
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
]
|
|
131
|
-
}),
|
|
132
|
-
setting?.enableDay && /*#__PURE__*/ jsxs("div", {
|
|
133
|
-
style: {
|
|
134
|
-
...!styles?.itemPadding?.type ? composeSize(styles?.itemPadding?.custom) : {},
|
|
135
|
-
...handleConvertBorderStyle(styles?.borderState),
|
|
136
|
-
...handleConvertBorderWidth(styles?.borderState),
|
|
137
|
-
...handleConvertBorderColor(styles?.borderState),
|
|
138
|
-
...composeRadius(styles?.roundedState),
|
|
139
|
-
...makeStyle({
|
|
140
|
-
bg: getGlobalColorCSSProp(styles?.backgroundItemColor)
|
|
141
|
-
})
|
|
142
|
-
},
|
|
143
|
-
className: cls(getGlobalColorClass('bg', styles?.backgroundItemColor), 'gp-min-w-max !gp-max-w-max gp-flex-1 gp-text-center', styles?.itemPadding?.type ? genSizeClass(styles?.itemPadding?.type) : '', renderClassWithCondition(!setting?.dayLabel, 'gp-content-center')),
|
|
144
|
-
children: [
|
|
145
|
-
/*#__PURE__*/ jsx(Text, {
|
|
146
|
-
className: cls(getGlobalColorClass('text', colorNumber)),
|
|
147
|
-
styles: {
|
|
148
|
-
typography: styles?.numTypography,
|
|
149
|
-
typo: styles?.numTypo
|
|
150
|
-
},
|
|
151
|
-
style: {
|
|
152
|
-
...makeStyle({
|
|
153
|
-
mb: styles?.verticalGap,
|
|
154
|
-
c: getGlobalColorCSSProp(colorNumber)
|
|
155
|
-
})
|
|
156
|
-
},
|
|
157
|
-
setting: {
|
|
158
|
-
text: formatTime(day),
|
|
159
|
-
htmlTag: 'div',
|
|
160
|
-
excludeFlex: true
|
|
161
|
-
}
|
|
162
|
-
}),
|
|
163
|
-
/*#__PURE__*/ jsx(Text, {
|
|
164
|
-
className: `${cls(getGlobalColorClass('text', colorLabel), renderClassWithCondition(!setting?.dayLabel, 'gp-hidden'))} , `,
|
|
165
|
-
styles: {
|
|
166
|
-
typography: styles?.labelTypography,
|
|
167
|
-
typo: styles?.labelTypo
|
|
168
|
-
},
|
|
169
|
-
style: {
|
|
170
|
-
...makeStyle({
|
|
171
|
-
c: getGlobalColorCSSProp(colorLabel)
|
|
172
|
-
})
|
|
173
|
-
},
|
|
174
|
-
setting: {
|
|
175
|
-
text: setting?.dayLabel,
|
|
176
|
-
htmlTag: 'p',
|
|
177
|
-
excludeFlex: true
|
|
178
|
-
}
|
|
179
|
-
})
|
|
180
|
-
]
|
|
181
|
-
}),
|
|
182
|
-
setting?.enableHour && /*#__PURE__*/ jsxs("div", {
|
|
183
|
-
className: cls(getGlobalColorClass('bg', styles?.backgroundItemColor), 'gp-min-w-max !gp-max-w-max gp-flex-1 gp-text-center', styles?.itemPadding?.type ? genSizeClass(styles?.itemPadding?.type) : '', renderClassWithCondition(!setting?.hourLabel, 'gp-content-center')),
|
|
184
|
-
style: {
|
|
185
|
-
...!styles?.itemPadding?.type ? composeSize(styles?.itemPadding?.custom) : {},
|
|
186
|
-
...handleConvertBorderStyle(styles?.borderState),
|
|
187
|
-
...handleConvertBorderWidth(styles?.borderState),
|
|
188
|
-
...handleConvertBorderColor(styles?.borderState),
|
|
189
|
-
...composeRadius(styles?.roundedState),
|
|
190
|
-
...makeStyle({
|
|
191
|
-
bg: getGlobalColorCSSProp(styles?.backgroundItemColor)
|
|
192
|
-
})
|
|
82
|
+
setting: {
|
|
83
|
+
htmlTag: 'div',
|
|
84
|
+
text: textFrontLabel,
|
|
85
|
+
excludeFlex: true
|
|
193
86
|
},
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
className: cls(getGlobalColorClass('text', colorNumber)),
|
|
197
|
-
styles: {
|
|
198
|
-
typography: styles?.numTypography,
|
|
199
|
-
typo: styles?.numTypo
|
|
200
|
-
},
|
|
201
|
-
style: {
|
|
202
|
-
...makeStyle({
|
|
203
|
-
mb: styles?.verticalGap,
|
|
204
|
-
c: getGlobalColorCSSProp(colorNumber)
|
|
205
|
-
})
|
|
206
|
-
},
|
|
207
|
-
setting: {
|
|
208
|
-
text: formatTime(hour),
|
|
209
|
-
htmlTag: 'div',
|
|
210
|
-
excludeFlex: true
|
|
211
|
-
}
|
|
212
|
-
}),
|
|
213
|
-
/*#__PURE__*/ jsx(Text, {
|
|
214
|
-
className: cls(getGlobalColorClass('text', colorLabel), renderClassWithCondition(!setting?.hourLabel, 'gp-hidden')),
|
|
215
|
-
styles: {
|
|
216
|
-
typography: styles?.labelTypography,
|
|
217
|
-
typo: styles?.labelTypo
|
|
218
|
-
},
|
|
219
|
-
style: {
|
|
220
|
-
...makeStyle({
|
|
221
|
-
c: getGlobalColorCSSProp(colorLabel)
|
|
222
|
-
})
|
|
223
|
-
},
|
|
224
|
-
setting: {
|
|
225
|
-
text: setting?.hourLabel,
|
|
226
|
-
htmlTag: 'p',
|
|
227
|
-
excludeFlex: true
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
]
|
|
87
|
+
className: textFrontClasses,
|
|
88
|
+
style: textFrontStyle
|
|
231
89
|
}),
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
...handleConvertBorderStyle(styles?.borderState),
|
|
237
|
-
...handleConvertBorderWidth(styles?.borderState),
|
|
238
|
-
...handleConvertBorderColor(styles?.borderState),
|
|
239
|
-
...composeRadius(styles?.roundedState),
|
|
240
|
-
...makeStyle({
|
|
241
|
-
bg: getGlobalColorCSSProp(styles?.backgroundItemColor)
|
|
242
|
-
})
|
|
90
|
+
/*#__PURE__*/ jsx(Text, {
|
|
91
|
+
styles: {
|
|
92
|
+
typography: labelTypography,
|
|
93
|
+
typo: labelTypo
|
|
243
94
|
},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
typography: styles?.numTypography,
|
|
249
|
-
typo: styles?.numTypo
|
|
250
|
-
},
|
|
251
|
-
style: {
|
|
252
|
-
...makeStyle({
|
|
253
|
-
mb: styles?.verticalGap,
|
|
254
|
-
c: getGlobalColorCSSProp(colorNumber)
|
|
255
|
-
})
|
|
256
|
-
},
|
|
257
|
-
setting: {
|
|
258
|
-
text: formatTime(minute),
|
|
259
|
-
htmlTag: 'div',
|
|
260
|
-
excludeFlex: true
|
|
261
|
-
}
|
|
262
|
-
}),
|
|
263
|
-
/*#__PURE__*/ jsx(Text, {
|
|
264
|
-
className: cls(getGlobalColorClass('text', colorLabel), renderClassWithCondition(!setting?.minuteLabel, 'gp-hidden')),
|
|
265
|
-
styles: {
|
|
266
|
-
typography: styles?.labelTypography,
|
|
267
|
-
typo: styles?.labelTypo
|
|
268
|
-
},
|
|
269
|
-
style: {
|
|
270
|
-
...makeStyle({
|
|
271
|
-
c: getGlobalColorCSSProp(colorLabel)
|
|
272
|
-
})
|
|
273
|
-
},
|
|
274
|
-
setting: {
|
|
275
|
-
text: setting?.minuteLabel,
|
|
276
|
-
htmlTag: 'p',
|
|
277
|
-
excludeFlex: true
|
|
278
|
-
}
|
|
279
|
-
})
|
|
280
|
-
]
|
|
281
|
-
}),
|
|
282
|
-
setting?.enableSecond && /*#__PURE__*/ jsxs("div", {
|
|
283
|
-
className: cls(getGlobalColorClass('bg', styles?.backgroundItemColor), 'gp-min-w-max !gp-max-w-max gp-flex-1 gp-text-center', styles?.itemPadding?.type ? genSizeClass(styles?.itemPadding?.type) : '', renderClassWithCondition(!setting?.secondLabel, 'gp-content-center')),
|
|
284
|
-
style: {
|
|
285
|
-
...!styles?.itemPadding?.type ? composeSize(styles?.itemPadding?.custom) : {},
|
|
286
|
-
...handleConvertBorderStyle(styles?.borderState),
|
|
287
|
-
...handleConvertBorderWidth(styles?.borderState),
|
|
288
|
-
...handleConvertBorderColor(styles?.borderState),
|
|
289
|
-
...composeRadius(styles?.roundedState),
|
|
290
|
-
...makeStyle({
|
|
291
|
-
bg: getGlobalColorCSSProp(styles?.backgroundItemColor)
|
|
292
|
-
})
|
|
95
|
+
setting: {
|
|
96
|
+
text: textLabel,
|
|
97
|
+
htmlTag: 'p',
|
|
98
|
+
excludeFlex: true
|
|
293
99
|
},
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
className: cls(getGlobalColorClass('text', colorNumber)),
|
|
297
|
-
styles: {
|
|
298
|
-
typography: styles?.numTypography,
|
|
299
|
-
typo: styles?.numTypo
|
|
300
|
-
},
|
|
301
|
-
style: {
|
|
302
|
-
...makeStyle({
|
|
303
|
-
mb: styles?.verticalGap,
|
|
304
|
-
c: getGlobalColorCSSProp(colorNumber)
|
|
305
|
-
})
|
|
306
|
-
},
|
|
307
|
-
setting: {
|
|
308
|
-
text: formatTime(second),
|
|
309
|
-
htmlTag: 'div',
|
|
310
|
-
excludeFlex: true
|
|
311
|
-
}
|
|
312
|
-
}),
|
|
313
|
-
/*#__PURE__*/ jsx(Text, {
|
|
314
|
-
className: cls(getGlobalColorClass('text', colorLabel), renderClassWithCondition(!setting?.secondLabel, 'gp-hidden')),
|
|
315
|
-
styles: {
|
|
316
|
-
typography: styles?.labelTypography,
|
|
317
|
-
typo: styles?.labelTypo
|
|
318
|
-
},
|
|
319
|
-
style: {
|
|
320
|
-
...makeStyle({
|
|
321
|
-
c: getGlobalColorCSSProp(colorLabel)
|
|
322
|
-
})
|
|
323
|
-
},
|
|
324
|
-
setting: {
|
|
325
|
-
text: setting?.secondLabel,
|
|
326
|
-
htmlTag: 'p',
|
|
327
|
-
excludeFlex: true
|
|
328
|
-
}
|
|
329
|
-
})
|
|
330
|
-
]
|
|
100
|
+
style: textBackStyle,
|
|
101
|
+
className: textBackClasses(textLabel)
|
|
331
102
|
})
|
|
332
103
|
]
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return /*#__PURE__*/ jsx("div", {
|
|
107
|
+
ref: ref,
|
|
108
|
+
...attrs,
|
|
109
|
+
className: wrapperClasses,
|
|
110
|
+
style: wrapperStyle,
|
|
111
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
112
|
+
className: containClasses,
|
|
113
|
+
style: containStyle,
|
|
114
|
+
children: [
|
|
115
|
+
If(hasLinkCover, /*#__PURE__*/ jsx("a", {
|
|
116
|
+
href: redirectUrl?.link,
|
|
117
|
+
target: redirectUrl?.target,
|
|
118
|
+
"aria-label": "Countdown link",
|
|
119
|
+
className: linkClasses,
|
|
120
|
+
children: ' '
|
|
121
|
+
})),
|
|
122
|
+
If(enableWeek, timeTemplate(week, weekLabel)),
|
|
123
|
+
If(enableWeek, timeTemplate(week, weekLabel)),
|
|
124
|
+
If(enableDay, timeTemplate(day, dayLabel)),
|
|
125
|
+
If(enableHour, timeTemplate(hour, hourLabel)),
|
|
126
|
+
If(enableMinute, timeTemplate(minute, minuteLabel)),
|
|
127
|
+
If(enableSecond, timeTemplate(second, secondLabel))
|
|
128
|
+
]
|
|
333
129
|
})
|
|
334
130
|
});
|
|
335
131
|
};
|
|
@@ -1,43 +1,81 @@
|
|
|
1
|
-
import { template,
|
|
1
|
+
import { template, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
2
|
import Text from '../../text/components/Text.liquid.js';
|
|
3
3
|
import { getInsertLinkData, getSettingPreloadData } from '../../helpers.js';
|
|
4
|
+
import { createStateOrContext, createStyle, createClass, createAttr, If } from '@gem-sdk/system';
|
|
5
|
+
import { getAttr, getAttrHref } from './common/getAttr.js';
|
|
6
|
+
import { getDateStyle, getTextFrontStyle, getTextBackStyle, getWrapperStyle, getContainStyle } from './common/getStyle.js';
|
|
7
|
+
import { getTextFrontClasses, getWrapperClasses, getContentClasses, getLinkClasses, getDateClasses, getTextBackClasses } from './common/getClasses.js';
|
|
4
8
|
|
|
5
|
-
const Countdown = (
|
|
9
|
+
const Countdown = (props)=>{
|
|
10
|
+
const { setting, styles, builderProps, advanced, pageContext } = props;
|
|
11
|
+
const { labelTypo, numTypo, numTypography, labelTypography } = styles ?? {};
|
|
12
|
+
const { weekLabel, dayLabel, hourLabel, minuteLabel, secondLabel, enableWeek, enableDay, enableHour, enableMinute, enableSecond, redirectUrl, translate } = setting ?? {};
|
|
13
|
+
const hasLinkCover = !!redirectUrl?.link;
|
|
14
|
+
const { urlData } = getInsertLinkData('', redirectUrl);
|
|
15
|
+
const stateData = createStateOrContext({
|
|
16
|
+
...setting,
|
|
17
|
+
...builderProps
|
|
18
|
+
});
|
|
19
|
+
const dateStyle = createStyle({
|
|
20
|
+
...getDateStyle(styles)
|
|
21
|
+
});
|
|
22
|
+
const dateClasses = (dateLabel)=>createClass({
|
|
23
|
+
...getDateClasses(styles, dateLabel)
|
|
24
|
+
});
|
|
25
|
+
const textFrontClasses = createClass({
|
|
26
|
+
...getTextFrontClasses(styles)
|
|
27
|
+
});
|
|
28
|
+
const textFrontStyle = createStyle({
|
|
29
|
+
...getTextFrontStyle(styles)
|
|
30
|
+
});
|
|
31
|
+
const textBackStyle = createStyle({
|
|
32
|
+
...getTextBackStyle(styles)
|
|
33
|
+
});
|
|
34
|
+
const textBackClasses = (textLabel)=>createClass({
|
|
35
|
+
...getTextBackClasses(styles, textLabel)
|
|
36
|
+
});
|
|
37
|
+
const attrs = createAttr({
|
|
38
|
+
...getAttr({
|
|
39
|
+
uid: builderProps?.uid || ''
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
const attrsHref = createAttr({
|
|
43
|
+
...getAttrHref({
|
|
44
|
+
uid: urlData.href || ''
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
const wrapperStyle = createStyle({
|
|
48
|
+
...getWrapperStyle(styles)
|
|
49
|
+
});
|
|
50
|
+
const wrapperClasses = createClass({
|
|
51
|
+
...getWrapperClasses(advanced?.cssClass)
|
|
52
|
+
});
|
|
53
|
+
const containClasses = createClass({
|
|
54
|
+
...getContentClasses()
|
|
55
|
+
});
|
|
56
|
+
const containStyle = createStyle({
|
|
57
|
+
...getContainStyle(styles)
|
|
58
|
+
});
|
|
6
59
|
const timeTemplate = (id, textLabel, translateLabel)=>{
|
|
60
|
+
const textFrontLabel = '00';
|
|
7
61
|
return template`
|
|
8
|
-
<div
|
|
9
|
-
style="${{
|
|
10
|
-
...!styles?.itemPadding?.type ? composeSize(styles?.itemPadding?.custom) : {},
|
|
11
|
-
...handleConvertBorderStyle(styles?.borderState),
|
|
12
|
-
...handleConvertBorderWidth(styles?.borderState),
|
|
13
|
-
...handleConvertBorderColor(styles?.borderState),
|
|
14
|
-
...composeRadius(styles?.roundedState),
|
|
15
|
-
...makeStyle({
|
|
16
|
-
bg: getGlobalColorCSSProp(styles?.backgroundItemColor)
|
|
17
|
-
})
|
|
18
|
-
}}"
|
|
19
|
-
class="${cls(getGlobalColorClass('bg', styles?.backgroundItemColor), 'gp-flex-1 gp-text-center gp-min-w-max !gp-max-w-max', styles?.itemPadding?.type ? genSizeClass(styles?.itemPadding?.type) : '', !textLabel ? 'gp-content-center' : '')}">
|
|
62
|
+
<div style="${dateStyle}" class="${dateClasses(textLabel)}">
|
|
20
63
|
${Text({
|
|
21
64
|
styles: {
|
|
22
|
-
typography:
|
|
23
|
-
typo:
|
|
65
|
+
typography: numTypography,
|
|
66
|
+
typo: numTypo
|
|
24
67
|
},
|
|
25
|
-
builderAttrs: {
|
|
26
|
-
id
|
|
27
|
-
},
|
|
28
|
-
style: {
|
|
29
|
-
...makeStyle({
|
|
30
|
-
mb: styles?.verticalGap,
|
|
31
|
-
c: getGlobalColorCSSProp(styles?.colorNumber)
|
|
32
|
-
})
|
|
33
|
-
},
|
|
34
|
-
className: 'gp-countdown-number',
|
|
35
68
|
setting: {
|
|
36
69
|
...setting,
|
|
37
|
-
text:
|
|
70
|
+
text: textFrontLabel,
|
|
38
71
|
excludeFlex: true,
|
|
39
72
|
translate: ''
|
|
40
73
|
},
|
|
74
|
+
style: textFrontStyle,
|
|
75
|
+
className: textFrontClasses,
|
|
76
|
+
builderAttrs: {
|
|
77
|
+
id
|
|
78
|
+
},
|
|
41
79
|
builderProps: {
|
|
42
80
|
...builderProps,
|
|
43
81
|
uid: builderProps?.uid,
|
|
@@ -46,13 +84,8 @@ const Countdown = ({ builderProps, setting, styles, advanced, pageContext })=>{
|
|
|
46
84
|
})}
|
|
47
85
|
${Text({
|
|
48
86
|
styles: {
|
|
49
|
-
typography:
|
|
50
|
-
typo:
|
|
51
|
-
},
|
|
52
|
-
style: {
|
|
53
|
-
...makeStyle({
|
|
54
|
-
c: getGlobalColorCSSProp(styles?.colorLabel)
|
|
55
|
-
})
|
|
87
|
+
typography: labelTypography,
|
|
88
|
+
typo: labelTypo
|
|
56
89
|
},
|
|
57
90
|
setting: {
|
|
58
91
|
...setting,
|
|
@@ -60,6 +93,8 @@ const Countdown = ({ builderProps, setting, styles, advanced, pageContext })=>{
|
|
|
60
93
|
excludeFlex: true,
|
|
61
94
|
translate: translateLabel
|
|
62
95
|
},
|
|
96
|
+
style: textBackStyle,
|
|
97
|
+
className: textBackClasses(textLabel),
|
|
63
98
|
builderProps: {
|
|
64
99
|
...builderProps,
|
|
65
100
|
uid: builderProps?.uid,
|
|
@@ -70,38 +105,39 @@ const Countdown = ({ builderProps, setting, styles, advanced, pageContext })=>{
|
|
|
70
105
|
</div>
|
|
71
106
|
`;
|
|
72
107
|
};
|
|
73
|
-
const
|
|
108
|
+
const linkClasses = createClass({
|
|
109
|
+
...getLinkClasses()
|
|
110
|
+
});
|
|
111
|
+
const renderScript = ()=>{
|
|
112
|
+
return RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-countdown.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-countdown.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);
|
|
113
|
+
};
|
|
74
114
|
return template /* liquid */ `
|
|
75
115
|
<gp-countdown-timer
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
...
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
style="${
|
|
84
|
-
|
|
85
|
-
}}"
|
|
116
|
+
${{
|
|
117
|
+
...attrs
|
|
118
|
+
}}
|
|
119
|
+
${{
|
|
120
|
+
...attrsHref
|
|
121
|
+
}}
|
|
122
|
+
class="${wrapperClasses}"
|
|
123
|
+
style="${wrapperStyle}"
|
|
124
|
+
gp-data='${JSON.stringify(stateData).replaceAll("'", ''')}'
|
|
86
125
|
>
|
|
87
|
-
<div id="section-countdown" class="
|
|
88
|
-
|
|
89
|
-
...makeStyleResponsive('jc', styles?.textAlign)
|
|
90
|
-
}}">
|
|
91
|
-
${RenderIf(!!setting?.redirectUrl?.link, `<a
|
|
126
|
+
<div id="section-countdown" class="${containClasses}" style="${containStyle}">
|
|
127
|
+
${If(hasLinkCover, `<a
|
|
92
128
|
href="${urlData.href}"
|
|
93
129
|
target="${urlData?.target}"
|
|
94
130
|
aria-label="Countdown link"
|
|
95
|
-
class="
|
|
131
|
+
class="${linkClasses}"
|
|
96
132
|
> </a>`)}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
133
|
+
${If(enableWeek, timeTemplate('week', weekLabel, translate ? 'weekLabel' : ''))}
|
|
134
|
+
${If(enableDay, timeTemplate('day', dayLabel, translate ? 'dayLabel' : ''))}
|
|
135
|
+
${If(enableHour, timeTemplate('hour', hourLabel, translate ? 'hourLabel' : ''))}
|
|
136
|
+
${If(enableMinute, timeTemplate('minute', minuteLabel, translate ? 'minuteLabel' : ''))}
|
|
137
|
+
${If(enableSecond, timeTemplate('second', secondLabel, translate ? 'secondLabel' : ''))}
|
|
102
138
|
</div>
|
|
103
139
|
</gp-countdown-timer>
|
|
104
|
-
${
|
|
140
|
+
${renderScript()}
|
|
105
141
|
`;
|
|
106
142
|
};
|
|
107
143
|
|