@ptcwebops/ptcw-design 6.3.5 → 6.3.6
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/event-jumbotron-example.cjs.entry.js +36 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/ptc-close-icon_2.cjs.entry.js +6 -12
- package/dist/cjs/ptc-countdown.cjs.entry.js +100 -19
- package/dist/cjs/ptcw-design.cjs.js +1 -1
- package/dist/collection/components/organism-bundles/event-jumbotron-example/event-jumbotron-example.css +8 -4
- package/dist/collection/components/organism-bundles/event-jumbotron-example/event-jumbotron-example.js +35 -2
- package/dist/collection/components/ptc-countdown/ptc-countdown.css +2 -0
- package/dist/collection/components/ptc-countdown/ptc-countdown.js +193 -17
- package/dist/collection/components/ptc-modal/ptc-modal.css +4 -4
- package/dist/collection/components/ptc-modal/ptc-modal.js +5 -29
- package/dist/custom-elements/index.js +144 -36
- package/dist/esm/event-jumbotron-example.entry.js +36 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/ptc-close-icon_2.entry.js +6 -12
- package/dist/esm/ptc-countdown.entry.js +100 -19
- package/dist/esm/ptcw-design.js +1 -1
- package/dist/ptcw-design/p-9fa958b9.entry.js +1 -0
- package/dist/ptcw-design/p-ab3d2934.entry.js +1 -0
- package/dist/ptcw-design/p-c8f68292.entry.js +1 -0
- package/dist/ptcw-design/ptcw-design.esm.js +1 -1
- package/dist/types/components/organism-bundles/event-jumbotron-example/event-jumbotron-example.d.ts +2 -0
- package/dist/types/components/ptc-countdown/ptc-countdown.d.ts +9 -0
- package/dist/types/components/ptc-modal/ptc-modal.d.ts +0 -1
- package/dist/types/components.d.ts +10 -2
- package/package.json +1 -1
- package/readme.md +1 -1
- package/dist/ptcw-design/p-27a4ee73.entry.js +0 -1
- package/dist/ptcw-design/p-42992202.entry.js +0 -1
- package/dist/ptcw-design/p-54350a01.entry.js +0 -1
|
@@ -74,6 +74,7 @@ ptc-link, ptc-square-card,
|
|
|
74
74
|
padding: 16px 4px;
|
|
75
75
|
display: block;
|
|
76
76
|
max-width: 450px;
|
|
77
|
+
min-width: 280px;
|
|
77
78
|
border-radius: 4px;
|
|
78
79
|
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.32);
|
|
79
80
|
background-color: #20262a;
|
|
@@ -81,6 +82,7 @@ ptc-link, ptc-square-card,
|
|
|
81
82
|
@media only screen and (min-width: 480px) {
|
|
82
83
|
.countdown-outer {
|
|
83
84
|
padding: 16px 32px;
|
|
85
|
+
min-width: 380px;
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import utc from 'dayjs/plugin/utc';
|
|
4
|
-
import timezone from 'dayjs/plugin/timezone';
|
|
4
|
+
// import timezone from 'dayjs/plugin/timezone';
|
|
5
5
|
// Extend dayjs with timezone support
|
|
6
6
|
dayjs.extend(utc);
|
|
7
|
-
dayjs.extend(timezone);
|
|
7
|
+
// dayjs.extend(timezone);
|
|
8
8
|
export class PtcCountdown {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.countdownTitle = '';
|
|
11
11
|
this.eventTime = '';
|
|
12
|
-
this.eventTimeZone = '
|
|
12
|
+
this.eventTimeZone = 'EST';
|
|
13
13
|
this.expiredText = 'This event has started on';
|
|
14
|
+
this.daysText = 'days';
|
|
15
|
+
this.hoursText = 'hours';
|
|
16
|
+
this.minutesText = 'minutes';
|
|
17
|
+
this.secondsText = 'seconds';
|
|
18
|
+
this.useHourFormat = true;
|
|
14
19
|
this.timeLeft = {
|
|
15
20
|
days: 0,
|
|
16
21
|
hours: 0,
|
|
@@ -18,24 +23,70 @@ export class PtcCountdown {
|
|
|
18
23
|
seconds: 0,
|
|
19
24
|
};
|
|
20
25
|
this.isExpired = false;
|
|
26
|
+
this.displayLocale = 'en';
|
|
21
27
|
}
|
|
22
28
|
componentWillLoad() {
|
|
23
29
|
if (!this.eventTime || !this.eventTimeZone) {
|
|
24
30
|
console.error('Both eventTime and eventTimeZone are required.');
|
|
25
31
|
return;
|
|
26
32
|
}
|
|
33
|
+
this.detectLocaleFromURL();
|
|
27
34
|
this.startCountdown();
|
|
28
35
|
}
|
|
29
36
|
disconnectedCallback() {
|
|
30
37
|
clearInterval(this.timer);
|
|
31
38
|
}
|
|
39
|
+
// Map time zone abbreviations to their offset in minutes.
|
|
40
|
+
getOffsetFromAbbr(abbr) {
|
|
41
|
+
const tzMapping = {
|
|
42
|
+
'ACDT': 630,
|
|
43
|
+
'ACST': 570,
|
|
44
|
+
'ADT': -180,
|
|
45
|
+
'AEDT': 660,
|
|
46
|
+
'AEST': 600,
|
|
47
|
+
'AKDT': -480,
|
|
48
|
+
'AKST': -540,
|
|
49
|
+
'AST': -240,
|
|
50
|
+
'AWST': 480,
|
|
51
|
+
'BST': 60,
|
|
52
|
+
'CDT': -300,
|
|
53
|
+
'CEST': 120,
|
|
54
|
+
'CET': 60,
|
|
55
|
+
'CST': -360,
|
|
56
|
+
'CST_CN': 480,
|
|
57
|
+
'EDT': -240,
|
|
58
|
+
'EEST': 180,
|
|
59
|
+
'EET': 120,
|
|
60
|
+
'EST': -300,
|
|
61
|
+
'GMT': 0,
|
|
62
|
+
'HKT': 480,
|
|
63
|
+
'IST': 330,
|
|
64
|
+
'JST': 540,
|
|
65
|
+
'MDT': -360,
|
|
66
|
+
'MST': -420,
|
|
67
|
+
'PDT': -420,
|
|
68
|
+
'PST': -480,
|
|
69
|
+
'UTC': 0,
|
|
70
|
+
};
|
|
71
|
+
return tzMapping[abbr] !== undefined ? tzMapping[abbr] : 0;
|
|
72
|
+
}
|
|
73
|
+
// Convert the provided date to ISO 8601 if needed.
|
|
32
74
|
transformDate(contentDate) {
|
|
75
|
+
// If contentDate includes a 'T', assume it’s ISO 8601.
|
|
76
|
+
if (contentDate.includes('T')) {
|
|
77
|
+
return contentDate;
|
|
78
|
+
}
|
|
79
|
+
// Otherwise, assume the original format "M/D/YYYY h:mm:ss A"
|
|
33
80
|
return dayjs(contentDate, 'M/D/YYYY h:mm:ss A').format('YYYY-MM-DDTHH:mm:ss');
|
|
34
81
|
}
|
|
35
82
|
calculateTimeLeft() {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
83
|
+
const offset = this.getOffsetFromAbbr(this.eventTimeZone);
|
|
84
|
+
// Parse eventTime as if it is in the provided time zone.
|
|
85
|
+
// Using utcOffset(offset, true) tells dayjs to treat the parsed time as local in that offset.
|
|
86
|
+
const target = dayjs(this.transformDate(this.eventTime))
|
|
87
|
+
.utcOffset(offset, true)
|
|
88
|
+
.utc();
|
|
89
|
+
const now = dayjs.utc();
|
|
39
90
|
const diff = target.diff(now);
|
|
40
91
|
if (diff > 0) {
|
|
41
92
|
this.timeLeft = {
|
|
@@ -51,24 +102,58 @@ export class PtcCountdown {
|
|
|
51
102
|
}
|
|
52
103
|
}
|
|
53
104
|
startCountdown() {
|
|
105
|
+
this.calculateTimeLeft();
|
|
54
106
|
this.timer = window.setInterval(() => this.calculateTimeLeft(), 1000);
|
|
55
107
|
}
|
|
108
|
+
shouldUse12HourFormat() {
|
|
109
|
+
if (this.displayLocale === 'en') {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
else if (this.useHourFormat !== undefined) {
|
|
113
|
+
return this.useHourFormat;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
detectLocaleFromURL() {
|
|
117
|
+
const url = window.location.href;
|
|
118
|
+
if (url.includes('/cn/')) {
|
|
119
|
+
this.displayLocale = 'zh-CN';
|
|
120
|
+
}
|
|
121
|
+
else if (url.includes('/tw/')) {
|
|
122
|
+
this.displayLocale = 'zh-TW';
|
|
123
|
+
}
|
|
124
|
+
else if (url.includes('/fr/')) {
|
|
125
|
+
this.displayLocale = 'fr';
|
|
126
|
+
}
|
|
127
|
+
else if (url.includes('/de/')) {
|
|
128
|
+
this.displayLocale = 'de';
|
|
129
|
+
}
|
|
130
|
+
else if (url.includes('/it/')) {
|
|
131
|
+
this.displayLocale = 'it';
|
|
132
|
+
}
|
|
133
|
+
else if (url.includes('/ja/')) {
|
|
134
|
+
this.displayLocale = 'ja';
|
|
135
|
+
}
|
|
136
|
+
else if (url.includes('/ko/')) {
|
|
137
|
+
this.displayLocale = 'ko';
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.displayLocale = 'en';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
56
143
|
render() {
|
|
57
144
|
const { days, hours, minutes, seconds } = this.timeLeft;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
minute: '2-digit',
|
|
65
|
-
}))), h("div", { class: "cd-event-date" }, new Date(this.eventTime).toLocaleString('en-US', {
|
|
66
|
-
//timeZone: this.eventTimeZone,
|
|
145
|
+
// Format the event time in 24-hour ISO 8601 style, applying the eventTimeZone offset.
|
|
146
|
+
const formattedEventTime = dayjs(this.transformDate(this.eventTime))
|
|
147
|
+
.utcOffset(this.getOffsetFromAbbr(this.eventTimeZone), true)
|
|
148
|
+
.format('YYYY-MM-DD HH:mm');
|
|
149
|
+
const hour12 = this.shouldUse12HourFormat();
|
|
150
|
+
return (h("div", { class: "countdown-outer" }, this.countdownTitle && h("div", { class: "event-name" }, this.countdownTitle), !this.isExpired ? (h("div", { id: "CDOutput", class: "countdown" }, h("div", { class: "day" }, h("div", null, days), h("span", null, this.daysText)), h("div", { class: "hours" }, h("div", null, hours), h("span", null, this.hoursText)), h("div", { class: "minutes" }, h("div", null, minutes), h("span", null, this.minutesText)), h("div", { class: "seconds" }, h("div", null, seconds), h("span", null, this.secondsText)))) : (h("div", { class: "expired" }, `${this.expiredText} ${formattedEventTime} ${this.eventTimeZone}`)), h("div", { class: "cd-event-date" }, new Date(this.eventTime).toLocaleDateString(this.displayLocale, {
|
|
67
151
|
month: 'long',
|
|
68
152
|
day: 'numeric',
|
|
69
153
|
year: 'numeric',
|
|
70
154
|
hour: '2-digit',
|
|
71
155
|
minute: '2-digit',
|
|
156
|
+
hour12: hour12,
|
|
72
157
|
}), ' ', "(", this.eventTimeZone, ")")));
|
|
73
158
|
}
|
|
74
159
|
static get is() { return "ptc-countdown"; }
|
|
@@ -137,7 +222,7 @@ export class PtcCountdown {
|
|
|
137
222
|
},
|
|
138
223
|
"attribute": "event-time-zone",
|
|
139
224
|
"reflect": false,
|
|
140
|
-
"defaultValue": "'
|
|
225
|
+
"defaultValue": "'EST'"
|
|
141
226
|
},
|
|
142
227
|
"expiredText": {
|
|
143
228
|
"type": "string",
|
|
@@ -156,13 +241,104 @@ export class PtcCountdown {
|
|
|
156
241
|
"attribute": "expired-text",
|
|
157
242
|
"reflect": false,
|
|
158
243
|
"defaultValue": "'This event has started on'"
|
|
244
|
+
},
|
|
245
|
+
"daysText": {
|
|
246
|
+
"type": "string",
|
|
247
|
+
"mutable": false,
|
|
248
|
+
"complexType": {
|
|
249
|
+
"original": "string",
|
|
250
|
+
"resolved": "string",
|
|
251
|
+
"references": {}
|
|
252
|
+
},
|
|
253
|
+
"required": false,
|
|
254
|
+
"optional": false,
|
|
255
|
+
"docs": {
|
|
256
|
+
"tags": [],
|
|
257
|
+
"text": ""
|
|
258
|
+
},
|
|
259
|
+
"attribute": "days-text",
|
|
260
|
+
"reflect": false,
|
|
261
|
+
"defaultValue": "'days'"
|
|
262
|
+
},
|
|
263
|
+
"hoursText": {
|
|
264
|
+
"type": "string",
|
|
265
|
+
"mutable": false,
|
|
266
|
+
"complexType": {
|
|
267
|
+
"original": "string",
|
|
268
|
+
"resolved": "string",
|
|
269
|
+
"references": {}
|
|
270
|
+
},
|
|
271
|
+
"required": false,
|
|
272
|
+
"optional": false,
|
|
273
|
+
"docs": {
|
|
274
|
+
"tags": [],
|
|
275
|
+
"text": ""
|
|
276
|
+
},
|
|
277
|
+
"attribute": "hours-text",
|
|
278
|
+
"reflect": false,
|
|
279
|
+
"defaultValue": "'hours'"
|
|
280
|
+
},
|
|
281
|
+
"minutesText": {
|
|
282
|
+
"type": "string",
|
|
283
|
+
"mutable": false,
|
|
284
|
+
"complexType": {
|
|
285
|
+
"original": "string",
|
|
286
|
+
"resolved": "string",
|
|
287
|
+
"references": {}
|
|
288
|
+
},
|
|
289
|
+
"required": false,
|
|
290
|
+
"optional": false,
|
|
291
|
+
"docs": {
|
|
292
|
+
"tags": [],
|
|
293
|
+
"text": ""
|
|
294
|
+
},
|
|
295
|
+
"attribute": "minutes-text",
|
|
296
|
+
"reflect": false,
|
|
297
|
+
"defaultValue": "'minutes'"
|
|
298
|
+
},
|
|
299
|
+
"secondsText": {
|
|
300
|
+
"type": "string",
|
|
301
|
+
"mutable": false,
|
|
302
|
+
"complexType": {
|
|
303
|
+
"original": "string",
|
|
304
|
+
"resolved": "string",
|
|
305
|
+
"references": {}
|
|
306
|
+
},
|
|
307
|
+
"required": false,
|
|
308
|
+
"optional": false,
|
|
309
|
+
"docs": {
|
|
310
|
+
"tags": [],
|
|
311
|
+
"text": ""
|
|
312
|
+
},
|
|
313
|
+
"attribute": "seconds-text",
|
|
314
|
+
"reflect": false,
|
|
315
|
+
"defaultValue": "'seconds'"
|
|
316
|
+
},
|
|
317
|
+
"useHourFormat": {
|
|
318
|
+
"type": "boolean",
|
|
319
|
+
"mutable": false,
|
|
320
|
+
"complexType": {
|
|
321
|
+
"original": "boolean",
|
|
322
|
+
"resolved": "boolean",
|
|
323
|
+
"references": {}
|
|
324
|
+
},
|
|
325
|
+
"required": false,
|
|
326
|
+
"optional": true,
|
|
327
|
+
"docs": {
|
|
328
|
+
"tags": [],
|
|
329
|
+
"text": ""
|
|
330
|
+
},
|
|
331
|
+
"attribute": "use-hour-format",
|
|
332
|
+
"reflect": false,
|
|
333
|
+
"defaultValue": "true"
|
|
159
334
|
}
|
|
160
335
|
};
|
|
161
336
|
}
|
|
162
337
|
static get states() {
|
|
163
338
|
return {
|
|
164
339
|
"timeLeft": {},
|
|
165
|
-
"isExpired": {}
|
|
340
|
+
"isExpired": {},
|
|
341
|
+
"displayLocale": {}
|
|
166
342
|
};
|
|
167
343
|
}
|
|
168
344
|
}
|
|
@@ -481,10 +481,10 @@ ptc-link, ptc-square-card,
|
|
|
481
481
|
text-decoration-line: underline;
|
|
482
482
|
line-height: var(--ptc-line-height-densest);
|
|
483
483
|
}
|
|
484
|
-
:host .wrapper .bottom-close span:focus-visible {
|
|
485
|
-
border-radius: var(--ptc-border-radius-standard);
|
|
486
|
-
outline: 5px solid var(--keyboard-nav-outline);
|
|
487
|
-
}
|
|
488
484
|
:host .wrapper .bottom-close span:hover {
|
|
489
485
|
color: var(--color-blue-08);
|
|
486
|
+
}
|
|
487
|
+
:host .wrapper .bottom-close:focus-visible {
|
|
488
|
+
border-radius: var(--ptc-border-radius-standard);
|
|
489
|
+
outline: 5px solid var(--keyboard-nav-outline);
|
|
490
490
|
}
|
|
@@ -27,15 +27,6 @@ export class PtcModal {
|
|
|
27
27
|
fallbackElement.focus();
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
//change it with @Watch
|
|
31
|
-
// componentDidUpdate() {
|
|
32
|
-
// if (this.show) {
|
|
33
|
-
// this.lastFocusElement = document.activeElement as HTMLElement;
|
|
34
|
-
// this.fireOnOpened(this);
|
|
35
|
-
// } else {
|
|
36
|
-
// this.fireOnClosed(this);
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
30
|
this.handleKeyPress = (event) => {
|
|
40
31
|
if (event.key === 'Enter' || event.key === ' ' || event.key === 'Tab') {
|
|
41
32
|
this.openedByKeyboard = true;
|
|
@@ -65,7 +56,6 @@ export class PtcModal {
|
|
|
65
56
|
this.headerOnlyText1 = undefined;
|
|
66
57
|
this.headerOnlyText2 = undefined;
|
|
67
58
|
this.bottomCloseBtn = undefined;
|
|
68
|
-
this.initialFocus = true;
|
|
69
59
|
this.openedByKeyboard = false;
|
|
70
60
|
this.bodyOverflowSetting = undefined;
|
|
71
61
|
}
|
|
@@ -238,12 +228,16 @@ export class PtcModal {
|
|
|
238
228
|
this.trap.deactivate();
|
|
239
229
|
}
|
|
240
230
|
} })));
|
|
241
|
-
let bottomCloseBtnEle = (h("div", { class: "bottom-close", id: "modal-bottom-close", onClick: e => {
|
|
231
|
+
let bottomCloseBtnEle = (h("div", { tabindex: "0", class: "bottom-close", id: "modal-bottom-close", onClick: e => {
|
|
242
232
|
e.preventDefault();
|
|
243
233
|
this.close();
|
|
244
234
|
}, onKeyPress: e => {
|
|
245
235
|
e.preventDefault();
|
|
246
236
|
this.close();
|
|
237
|
+
this.setReturnFocus();
|
|
238
|
+
if (this.trap) {
|
|
239
|
+
this.trap.deactivate();
|
|
240
|
+
}
|
|
247
241
|
} }, h("span", null, this.bottomCloseBtn)));
|
|
248
242
|
if (this.iframeUrl) {
|
|
249
243
|
content = h("iframe", { src: this.iframeUrl, frameBorder: 0, allowFullScreen: false, height: '100%', width: '100%', scrolling: "no", onLoad: this.resizeIframe });
|
|
@@ -669,24 +663,6 @@ export class PtcModal {
|
|
|
669
663
|
},
|
|
670
664
|
"attribute": "bottom-close-btn",
|
|
671
665
|
"reflect": false
|
|
672
|
-
},
|
|
673
|
-
"initialFocus": {
|
|
674
|
-
"type": "boolean",
|
|
675
|
-
"mutable": false,
|
|
676
|
-
"complexType": {
|
|
677
|
-
"original": "boolean",
|
|
678
|
-
"resolved": "boolean",
|
|
679
|
-
"references": {}
|
|
680
|
-
},
|
|
681
|
-
"required": false,
|
|
682
|
-
"optional": true,
|
|
683
|
-
"docs": {
|
|
684
|
-
"tags": [],
|
|
685
|
-
"text": ""
|
|
686
|
-
},
|
|
687
|
-
"attribute": "initial-focus",
|
|
688
|
-
"reflect": false,
|
|
689
|
-
"defaultValue": "true"
|
|
690
666
|
}
|
|
691
667
|
};
|
|
692
668
|
}
|