@everymatrix/helper-count-down 0.0.1
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/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/helper-count-down-989b391c.js +558 -0
- package/dist/cjs/helper-count-down.cjs.entry.js +10 -0
- package/dist/cjs/helper-count-down.cjs.js +25 -0
- package/dist/cjs/index-7d78f0f2.js +1190 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/helper-count-down/helper-count-down.css +31 -0
- package/dist/collection/components/helper-count-down/helper-count-down.js +342 -0
- package/dist/collection/components/helper-count-down/helper-count-down.type.js +4 -0
- package/dist/collection/components/helper-count-down/index.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/helper-count-down-db059b77.js +556 -0
- package/dist/esm/helper-count-down.entry.js +2 -0
- package/dist/esm/helper-count-down.js +20 -0
- package/dist/esm/index-27ec5eeb.js +1163 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/helper-count-down/app-globals-0f993ce5.js +1 -0
- package/dist/helper-count-down/helper-count-down-db059b77.js +1 -0
- package/dist/helper-count-down/helper-count-down.entry.js +1 -0
- package/dist/helper-count-down/helper-count-down.esm.js +1 -0
- package/dist/helper-count-down/index-27ec5eeb.js +2 -0
- package/dist/helper-count-down/index.esm.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +19 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/packages/stencil/helper-count-down/stencil.config.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/packages/stencil/helper-count-down/stencil.config.dev.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/packages/stencil/helper-count-down/storybook/main.d.ts +3 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/packages/stencil/helper-count-down/storybook/preview.d.ts +70 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/tools/plugins/index.d.ts +4 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/helper-count-down/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/helper-count-down/helper-count-down.d.ts +51 -0
- package/dist/types/components/helper-count-down/helper-count-down.type.d.ts +3 -0
- package/dist/types/components/helper-count-down/index.d.ts +1 -0
- package/dist/types/components.d.ts +69 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +27 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-7d78f0f2.js');
|
|
4
|
+
|
|
5
|
+
const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @name setClientStyling
|
|
9
|
+
* @description Method used to create and append to the passed element of the widget a style element with the content received
|
|
10
|
+
* @param {HTMLElement} stylingContainer The reference element of the widget
|
|
11
|
+
* @param {string} clientStyling The style content
|
|
12
|
+
*/
|
|
13
|
+
function setClientStyling(stylingContainer, clientStyling) {
|
|
14
|
+
if (stylingContainer) {
|
|
15
|
+
const sheet = document.createElement('style');
|
|
16
|
+
sheet.innerHTML = clientStyling;
|
|
17
|
+
stylingContainer.appendChild(sheet);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @name setClientStylingURL
|
|
23
|
+
* @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
|
|
24
|
+
* @param {HTMLElement} stylingContainer The reference element of the widget
|
|
25
|
+
* @param {string} clientStylingUrl The URL of the style content
|
|
26
|
+
*/
|
|
27
|
+
function setClientStylingURL(stylingContainer, clientStylingUrl) {
|
|
28
|
+
if (!stylingContainer || !clientStylingUrl) return;
|
|
29
|
+
|
|
30
|
+
const url = new URL(clientStylingUrl);
|
|
31
|
+
|
|
32
|
+
fetch(url.href)
|
|
33
|
+
.then((res) => res.text())
|
|
34
|
+
.then((data) => {
|
|
35
|
+
const cssFile = document.createElement('style');
|
|
36
|
+
cssFile.innerHTML = data;
|
|
37
|
+
if (stylingContainer) {
|
|
38
|
+
stylingContainer.appendChild(cssFile);
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.catch((err) => {
|
|
42
|
+
console.error('There was an error while trying to load client styling from URL', err);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @name setStreamLibrary
|
|
48
|
+
* @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
|
|
49
|
+
* @param {HTMLElement} stylingContainer The highest element of the widget
|
|
50
|
+
* @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
|
|
51
|
+
* @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
|
|
52
|
+
* @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
|
|
53
|
+
*/
|
|
54
|
+
function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
|
|
55
|
+
if (!window.emMessageBus) return;
|
|
56
|
+
|
|
57
|
+
const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
|
|
58
|
+
|
|
59
|
+
if (!supportAdoptStyle || !useAdoptedStyleSheets) {
|
|
60
|
+
subscription = getStyleTagSubscription(stylingContainer, domain);
|
|
61
|
+
|
|
62
|
+
return subscription;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!window[StyleCacheKey]) {
|
|
66
|
+
window[StyleCacheKey] = {};
|
|
67
|
+
}
|
|
68
|
+
subscription = getAdoptStyleSubscription(stylingContainer, domain);
|
|
69
|
+
|
|
70
|
+
const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
|
|
71
|
+
const wrappedUnsubscribe = () => {
|
|
72
|
+
if (window[StyleCacheKey][domain]) {
|
|
73
|
+
const cachedObject = window[StyleCacheKey][domain];
|
|
74
|
+
cachedObject.refCount > 1
|
|
75
|
+
? (cachedObject.refCount = cachedObject.refCount - 1)
|
|
76
|
+
: delete window[StyleCacheKey][domain];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
originalUnsubscribe();
|
|
80
|
+
};
|
|
81
|
+
subscription.unsubscribe = wrappedUnsubscribe;
|
|
82
|
+
|
|
83
|
+
return subscription;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getStyleTagSubscription(stylingContainer, domain) {
|
|
87
|
+
const sheet = document.createElement('style');
|
|
88
|
+
|
|
89
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
90
|
+
if (stylingContainer) {
|
|
91
|
+
sheet.innerHTML = data;
|
|
92
|
+
stylingContainer.appendChild(sheet);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getAdoptStyleSubscription(stylingContainer, domain) {
|
|
98
|
+
return window.emMessageBus.subscribe(domain, (data) => {
|
|
99
|
+
if (!stylingContainer) return;
|
|
100
|
+
|
|
101
|
+
const shadowRoot = stylingContainer.getRootNode();
|
|
102
|
+
const cacheStyleObject = window[StyleCacheKey];
|
|
103
|
+
let cachedStyle = cacheStyleObject[domain] && cacheStyleObject[domain].sheet;
|
|
104
|
+
|
|
105
|
+
if (!cachedStyle) {
|
|
106
|
+
cachedStyle = new CSSStyleSheet();
|
|
107
|
+
cachedStyle.replaceSync(data);
|
|
108
|
+
cacheStyleObject[domain] = {
|
|
109
|
+
sheet: cachedStyle,
|
|
110
|
+
refCount: 1
|
|
111
|
+
};
|
|
112
|
+
} else {
|
|
113
|
+
cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const currentSheets = shadowRoot.adoptedStyleSheets || [];
|
|
117
|
+
if (!currentSheets.includes(cachedStyle)) {
|
|
118
|
+
shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function toInteger(dirtyNumber) {
|
|
124
|
+
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
125
|
+
return NaN;
|
|
126
|
+
}
|
|
127
|
+
var number = Number(dirtyNumber);
|
|
128
|
+
if (isNaN(number)) {
|
|
129
|
+
return number;
|
|
130
|
+
}
|
|
131
|
+
return number < 0 ? Math.ceil(number) : Math.floor(number);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function requiredArgs(required, args) {
|
|
135
|
+
if (args.length < required) {
|
|
136
|
+
throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Days in 1 week.
|
|
142
|
+
*
|
|
143
|
+
* @name daysInWeek
|
|
144
|
+
* @constant
|
|
145
|
+
* @type {number}
|
|
146
|
+
* @default
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Milliseconds in 1 minute
|
|
151
|
+
*
|
|
152
|
+
* @name millisecondsInMinute
|
|
153
|
+
* @constant
|
|
154
|
+
* @type {number}
|
|
155
|
+
* @default
|
|
156
|
+
*/
|
|
157
|
+
var millisecondsInMinute = 60000;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Milliseconds in 1 hour
|
|
161
|
+
*
|
|
162
|
+
* @name millisecondsInHour
|
|
163
|
+
* @constant
|
|
164
|
+
* @type {number}
|
|
165
|
+
* @default
|
|
166
|
+
*/
|
|
167
|
+
var millisecondsInHour = 3600000;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @name parseISO
|
|
171
|
+
* @category Common Helpers
|
|
172
|
+
* @summary Parse ISO string
|
|
173
|
+
*
|
|
174
|
+
* @description
|
|
175
|
+
* Parse the given string in ISO 8601 format and return an instance of Date.
|
|
176
|
+
*
|
|
177
|
+
* Function accepts complete ISO 8601 formats as well as partial implementations.
|
|
178
|
+
* ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
|
|
179
|
+
*
|
|
180
|
+
* If the argument isn't a string, the function cannot parse the string or
|
|
181
|
+
* the values are invalid, it returns Invalid Date.
|
|
182
|
+
*
|
|
183
|
+
* @param {String} argument - the value to convert
|
|
184
|
+
* @param {Object} [options] - an object with options.
|
|
185
|
+
* @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
|
|
186
|
+
* @returns {Date} the parsed date in the local time zone
|
|
187
|
+
* @throws {TypeError} 1 argument required
|
|
188
|
+
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* // Convert string '2014-02-11T11:30:30' to date:
|
|
192
|
+
* const result = parseISO('2014-02-11T11:30:30')
|
|
193
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* // Convert string '+02014101' to date,
|
|
197
|
+
* // if the additional number of digits in the extended year format is 1:
|
|
198
|
+
* const result = parseISO('+02014101', { additionalDigits: 1 })
|
|
199
|
+
* //=> Fri Apr 11 2014 00:00:00
|
|
200
|
+
*/
|
|
201
|
+
function parseISO(argument, options) {
|
|
202
|
+
var _options$additionalDi;
|
|
203
|
+
requiredArgs(1, arguments);
|
|
204
|
+
var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);
|
|
205
|
+
if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
|
|
206
|
+
throw new RangeError('additionalDigits must be 0, 1 or 2');
|
|
207
|
+
}
|
|
208
|
+
if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
|
|
209
|
+
return new Date(NaN);
|
|
210
|
+
}
|
|
211
|
+
var dateStrings = splitDateString(argument);
|
|
212
|
+
var date;
|
|
213
|
+
if (dateStrings.date) {
|
|
214
|
+
var parseYearResult = parseYear(dateStrings.date, additionalDigits);
|
|
215
|
+
date = parseDate(parseYearResult.restDateString, parseYearResult.year);
|
|
216
|
+
}
|
|
217
|
+
if (!date || isNaN(date.getTime())) {
|
|
218
|
+
return new Date(NaN);
|
|
219
|
+
}
|
|
220
|
+
var timestamp = date.getTime();
|
|
221
|
+
var time = 0;
|
|
222
|
+
var offset;
|
|
223
|
+
if (dateStrings.time) {
|
|
224
|
+
time = parseTime(dateStrings.time);
|
|
225
|
+
if (isNaN(time)) {
|
|
226
|
+
return new Date(NaN);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (dateStrings.timezone) {
|
|
230
|
+
offset = parseTimezone(dateStrings.timezone);
|
|
231
|
+
if (isNaN(offset)) {
|
|
232
|
+
return new Date(NaN);
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
var dirtyDate = new Date(timestamp + time);
|
|
236
|
+
// js parsed string assuming it's in UTC timezone
|
|
237
|
+
// but we need it to be parsed in our timezone
|
|
238
|
+
// so we use utc values to build date in our timezone.
|
|
239
|
+
// Year values from 0 to 99 map to the years 1900 to 1999
|
|
240
|
+
// so set year explicitly with setFullYear.
|
|
241
|
+
var result = new Date(0);
|
|
242
|
+
result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());
|
|
243
|
+
result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
return new Date(timestamp + time + offset);
|
|
247
|
+
}
|
|
248
|
+
var patterns = {
|
|
249
|
+
dateTimeDelimiter: /[T ]/,
|
|
250
|
+
timeZoneDelimiter: /[Z ]/i,
|
|
251
|
+
timezone: /([Z+-].*)$/
|
|
252
|
+
};
|
|
253
|
+
var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
|
|
254
|
+
var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
|
|
255
|
+
var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
256
|
+
function splitDateString(dateString) {
|
|
257
|
+
var dateStrings = {};
|
|
258
|
+
var array = dateString.split(patterns.dateTimeDelimiter);
|
|
259
|
+
var timeString;
|
|
260
|
+
|
|
261
|
+
// The regex match should only return at maximum two array elements.
|
|
262
|
+
// [date], [time], or [date, time].
|
|
263
|
+
if (array.length > 2) {
|
|
264
|
+
return dateStrings;
|
|
265
|
+
}
|
|
266
|
+
if (/:/.test(array[0])) {
|
|
267
|
+
timeString = array[0];
|
|
268
|
+
} else {
|
|
269
|
+
dateStrings.date = array[0];
|
|
270
|
+
timeString = array[1];
|
|
271
|
+
if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
|
|
272
|
+
dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
|
|
273
|
+
timeString = dateString.substr(dateStrings.date.length, dateString.length);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (timeString) {
|
|
277
|
+
var token = patterns.timezone.exec(timeString);
|
|
278
|
+
if (token) {
|
|
279
|
+
dateStrings.time = timeString.replace(token[1], '');
|
|
280
|
+
dateStrings.timezone = token[1];
|
|
281
|
+
} else {
|
|
282
|
+
dateStrings.time = timeString;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return dateStrings;
|
|
286
|
+
}
|
|
287
|
+
function parseYear(dateString, additionalDigits) {
|
|
288
|
+
var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)');
|
|
289
|
+
var captures = dateString.match(regex);
|
|
290
|
+
// Invalid ISO-formatted year
|
|
291
|
+
if (!captures) return {
|
|
292
|
+
year: NaN,
|
|
293
|
+
restDateString: ''
|
|
294
|
+
};
|
|
295
|
+
var year = captures[1] ? parseInt(captures[1]) : null;
|
|
296
|
+
var century = captures[2] ? parseInt(captures[2]) : null;
|
|
297
|
+
|
|
298
|
+
// either year or century is null, not both
|
|
299
|
+
return {
|
|
300
|
+
year: century === null ? year : century * 100,
|
|
301
|
+
restDateString: dateString.slice((captures[1] || captures[2]).length)
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function parseDate(dateString, year) {
|
|
305
|
+
// Invalid ISO-formatted year
|
|
306
|
+
if (year === null) return new Date(NaN);
|
|
307
|
+
var captures = dateString.match(dateRegex);
|
|
308
|
+
// Invalid ISO-formatted string
|
|
309
|
+
if (!captures) return new Date(NaN);
|
|
310
|
+
var isWeekDate = !!captures[4];
|
|
311
|
+
var dayOfYear = parseDateUnit(captures[1]);
|
|
312
|
+
var month = parseDateUnit(captures[2]) - 1;
|
|
313
|
+
var day = parseDateUnit(captures[3]);
|
|
314
|
+
var week = parseDateUnit(captures[4]);
|
|
315
|
+
var dayOfWeek = parseDateUnit(captures[5]) - 1;
|
|
316
|
+
if (isWeekDate) {
|
|
317
|
+
if (!validateWeekDate(year, week, dayOfWeek)) {
|
|
318
|
+
return new Date(NaN);
|
|
319
|
+
}
|
|
320
|
+
return dayOfISOWeekYear(year, week, dayOfWeek);
|
|
321
|
+
} else {
|
|
322
|
+
var date = new Date(0);
|
|
323
|
+
if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
|
|
324
|
+
return new Date(NaN);
|
|
325
|
+
}
|
|
326
|
+
date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
|
|
327
|
+
return date;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function parseDateUnit(value) {
|
|
331
|
+
return value ? parseInt(value) : 1;
|
|
332
|
+
}
|
|
333
|
+
function parseTime(timeString) {
|
|
334
|
+
var captures = timeString.match(timeRegex);
|
|
335
|
+
if (!captures) return NaN; // Invalid ISO-formatted time
|
|
336
|
+
|
|
337
|
+
var hours = parseTimeUnit(captures[1]);
|
|
338
|
+
var minutes = parseTimeUnit(captures[2]);
|
|
339
|
+
var seconds = parseTimeUnit(captures[3]);
|
|
340
|
+
if (!validateTime(hours, minutes, seconds)) {
|
|
341
|
+
return NaN;
|
|
342
|
+
}
|
|
343
|
+
return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000;
|
|
344
|
+
}
|
|
345
|
+
function parseTimeUnit(value) {
|
|
346
|
+
return value && parseFloat(value.replace(',', '.')) || 0;
|
|
347
|
+
}
|
|
348
|
+
function parseTimezone(timezoneString) {
|
|
349
|
+
if (timezoneString === 'Z') return 0;
|
|
350
|
+
var captures = timezoneString.match(timezoneRegex);
|
|
351
|
+
if (!captures) return 0;
|
|
352
|
+
var sign = captures[1] === '+' ? -1 : 1;
|
|
353
|
+
var hours = parseInt(captures[2]);
|
|
354
|
+
var minutes = captures[3] && parseInt(captures[3]) || 0;
|
|
355
|
+
if (!validateTimezone(hours, minutes)) {
|
|
356
|
+
return NaN;
|
|
357
|
+
}
|
|
358
|
+
return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
|
|
359
|
+
}
|
|
360
|
+
function dayOfISOWeekYear(isoWeekYear, week, day) {
|
|
361
|
+
var date = new Date(0);
|
|
362
|
+
date.setUTCFullYear(isoWeekYear, 0, 4);
|
|
363
|
+
var fourthOfJanuaryDay = date.getUTCDay() || 7;
|
|
364
|
+
var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
|
|
365
|
+
date.setUTCDate(date.getUTCDate() + diff);
|
|
366
|
+
return date;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Validation functions
|
|
370
|
+
|
|
371
|
+
// February is null to handle the leap year (using ||)
|
|
372
|
+
var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
373
|
+
function isLeapYearIndex(year) {
|
|
374
|
+
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
375
|
+
}
|
|
376
|
+
function validateDate(year, month, date) {
|
|
377
|
+
return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
|
|
378
|
+
}
|
|
379
|
+
function validateDayOfYearDate(year, dayOfYear) {
|
|
380
|
+
return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
|
|
381
|
+
}
|
|
382
|
+
function validateWeekDate(_year, week, day) {
|
|
383
|
+
return week >= 1 && week <= 53 && day >= 0 && day <= 6;
|
|
384
|
+
}
|
|
385
|
+
function validateTime(hours, minutes, seconds) {
|
|
386
|
+
if (hours === 24) {
|
|
387
|
+
return minutes === 0 && seconds === 0;
|
|
388
|
+
}
|
|
389
|
+
return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
|
|
390
|
+
}
|
|
391
|
+
function validateTimezone(_hours, minutes) {
|
|
392
|
+
return minutes >= 0 && minutes <= 59;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const helperCountDownCss = ":host{display:block}.helper-count-down-container{display:flex;align-items:center}.helper-count-down-prefix{margin-right:4px}.helper-count-down-suffix{margin-left:4px}.helper-count-down-values{display:flex;align-items:center}.helper-count-down-item{display:flex;align-items:center;justify-content:center}.helper-count-down-item-num{font-variant-numeric:tabular-nums}";
|
|
396
|
+
const HelperCountDownStyle0 = helperCountDownCss;
|
|
397
|
+
|
|
398
|
+
const HelperCountDown = class {
|
|
399
|
+
constructor(hostRef) {
|
|
400
|
+
index.registerInstance(this, hostRef);
|
|
401
|
+
this.countDownChange = index.createEvent(this, "countDownChange", 7);
|
|
402
|
+
this.countDownFinish = index.createEvent(this, "countDownFinish", 7);
|
|
403
|
+
this.value = undefined;
|
|
404
|
+
this.format = 'HH:mm:ss';
|
|
405
|
+
this.prefix = undefined;
|
|
406
|
+
this.suffix = undefined;
|
|
407
|
+
this.mbSource = undefined;
|
|
408
|
+
this.clientStyling = undefined;
|
|
409
|
+
this.clientStylingUrl = undefined;
|
|
410
|
+
this.endTime = undefined;
|
|
411
|
+
this.timeObj = {
|
|
412
|
+
day: { str: '00', unit: '' },
|
|
413
|
+
hour: { str: '00', unit: '' },
|
|
414
|
+
minute: { str: '00', unit: '' },
|
|
415
|
+
second: { str: '00', unit: '' }
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
handleClientStylingChange(newValue, oldValue) {
|
|
419
|
+
if (newValue != oldValue) {
|
|
420
|
+
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
handleClientStylingUrlChange(newValue, oldValue) {
|
|
424
|
+
if (newValue != oldValue) {
|
|
425
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
handleMbSourceChange(newValue, oldValue) {
|
|
429
|
+
if (newValue != oldValue) {
|
|
430
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
handleValueChange(newValue) {
|
|
434
|
+
this.setEndTime(newValue);
|
|
435
|
+
if (newValue) {
|
|
436
|
+
this.startCountDown();
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
this.clearCountDown();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
componentDidLoad() {
|
|
443
|
+
if (this.stylingContainer) {
|
|
444
|
+
if (this.mbSource)
|
|
445
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
446
|
+
if (this.clientStyling)
|
|
447
|
+
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
448
|
+
if (this.clientStylingUrl)
|
|
449
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
450
|
+
}
|
|
451
|
+
this.setEndTime(this.value);
|
|
452
|
+
if (this.value)
|
|
453
|
+
this.startCountDown();
|
|
454
|
+
}
|
|
455
|
+
setEndTime(value) {
|
|
456
|
+
if (typeof value === 'string') {
|
|
457
|
+
// If it's a string, parse it and get the milliseconds
|
|
458
|
+
const time = parseISO(value).getTime();
|
|
459
|
+
this.endTime = isNaN(time) ? null : time;
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
// If it's a number, use it directly
|
|
463
|
+
this.endTime = value;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
disconnectedCallback() {
|
|
467
|
+
this.stylingSubscription && this.stylingSubscription.unsubscribe();
|
|
468
|
+
this.clearCountDown();
|
|
469
|
+
}
|
|
470
|
+
startCountDown() {
|
|
471
|
+
this.clearCountDown();
|
|
472
|
+
this.tick();
|
|
473
|
+
this.timer = setInterval(() => {
|
|
474
|
+
this.tick();
|
|
475
|
+
}, 1000);
|
|
476
|
+
}
|
|
477
|
+
clearCountDown() {
|
|
478
|
+
if (this.timer) {
|
|
479
|
+
clearInterval(this.timer);
|
|
480
|
+
this.timer = null;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
tick() {
|
|
484
|
+
if (!this.endTime)
|
|
485
|
+
return;
|
|
486
|
+
let leftTime = this.endTime - Date.now();
|
|
487
|
+
if (leftTime <= 0) {
|
|
488
|
+
leftTime = 0;
|
|
489
|
+
this.clearCountDown();
|
|
490
|
+
this.countDownFinish.emit();
|
|
491
|
+
}
|
|
492
|
+
const d = Math.floor(leftTime / (1000 * 60 * 60 * 24));
|
|
493
|
+
const h = Math.floor((leftTime / (1000 * 60 * 60)) % 24);
|
|
494
|
+
const m = Math.floor((leftTime / 1000 / 60) % 60);
|
|
495
|
+
const s = Math.floor((leftTime / 1000) % 60);
|
|
496
|
+
const pad = (n) => (n < 10 ? `0${n}` : `${n}`);
|
|
497
|
+
this.timeObj = {
|
|
498
|
+
day: { str: pad(d), unit: 'd' },
|
|
499
|
+
hour: { str: pad(h), unit: 'h' },
|
|
500
|
+
minute: { str: pad(m), unit: 'm' },
|
|
501
|
+
second: { str: pad(s), unit: 's' }
|
|
502
|
+
};
|
|
503
|
+
const formatTime = this.getFormatTime();
|
|
504
|
+
this.countDownChange.emit({ leftTime, formatTime, legalTime: formatTime });
|
|
505
|
+
}
|
|
506
|
+
getFormatTime() {
|
|
507
|
+
return this.format
|
|
508
|
+
.replace('DD', this.timeObj.day.str)
|
|
509
|
+
.replace('HH', this.timeObj.hour.str)
|
|
510
|
+
.replace('mm', this.timeObj.minute.str)
|
|
511
|
+
.replace('ss', this.timeObj.second.str);
|
|
512
|
+
}
|
|
513
|
+
renderItems() {
|
|
514
|
+
const regex = /(DD|HH|mm|ss)|([\s\S]+?)(?=(DD|HH|mm|ss)|$)/g;
|
|
515
|
+
const items = [];
|
|
516
|
+
let match;
|
|
517
|
+
while ((match = regex.exec(this.format)) !== null) {
|
|
518
|
+
if (match[1]) {
|
|
519
|
+
let val = '';
|
|
520
|
+
switch (match[1]) {
|
|
521
|
+
case 'DD':
|
|
522
|
+
val = this.timeObj.day.str;
|
|
523
|
+
break;
|
|
524
|
+
case 'HH':
|
|
525
|
+
val = this.timeObj.hour.str;
|
|
526
|
+
break;
|
|
527
|
+
case 'mm':
|
|
528
|
+
val = this.timeObj.minute.str;
|
|
529
|
+
break;
|
|
530
|
+
case 'ss':
|
|
531
|
+
val = this.timeObj.second.str;
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
items.push({ val, unit: '' });
|
|
535
|
+
}
|
|
536
|
+
else if (match[2]) {
|
|
537
|
+
if (items.length > 0) {
|
|
538
|
+
items[items.length - 1].unit = match[2];
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return items.map((item, index$1) => {
|
|
543
|
+
return (index.h("div", { key: index$1 + item.unit, class: "helper-count-down-item", part: "item" }, index.h("div", { class: "helper-count-down-item-num" }, item.val), index.h("div", { class: "helper-count-down-item-unit" }, item.unit)));
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
render() {
|
|
547
|
+
return (index.h("div", { key: 'b360412e045020b5ac0263c6ca56458f31eedb2c', class: "helper-count-down-container", ref: (el) => (this.stylingContainer = el) }, index.h("slot", { key: 'c72bed87fba869c842407b04e0cbfe038e5b7ea8' }), this.prefix && index.h("div", { key: '8d3ba9d60577421f81bae7bc76f52a774b17e1fe', class: "helper-count-down-prefix" }, this.prefix), index.h("div", { key: '187edf3b8eb6de85efe1a748fd8ef47a68e19611', class: "helper-count-down-values", part: "values" }, this.renderItems()), this.suffix && index.h("div", { key: '3a8e5d9561ecd3f52eff423bd43c8b60a261a17c', class: "helper-count-down-suffix" }, this.suffix)));
|
|
548
|
+
}
|
|
549
|
+
static get watchers() { return {
|
|
550
|
+
"clientStyling": ["handleClientStylingChange"],
|
|
551
|
+
"clientStylingUrl": ["handleClientStylingUrlChange"],
|
|
552
|
+
"mbSource": ["handleMbSourceChange"],
|
|
553
|
+
"value": ["handleValueChange"]
|
|
554
|
+
}; }
|
|
555
|
+
};
|
|
556
|
+
HelperCountDown.style = HelperCountDownStyle0;
|
|
557
|
+
|
|
558
|
+
exports.HelperCountDown = HelperCountDown;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-7d78f0f2.js');
|
|
6
|
+
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
Stencil Client Patch Browser v4.19.2 | MIT Licensed | https://stenciljs.com
|
|
10
|
+
*/
|
|
11
|
+
var patchBrowser = () => {
|
|
12
|
+
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('helper-count-down.cjs.js', document.baseURI).href));
|
|
13
|
+
const opts = {};
|
|
14
|
+
if (importMeta !== "") {
|
|
15
|
+
opts.resourcesUrl = new URL(".", importMeta).href;
|
|
16
|
+
}
|
|
17
|
+
return index.promiseResolve(opts);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
patchBrowser().then(async (options) => {
|
|
21
|
+
await appGlobals.globalScripts();
|
|
22
|
+
return index.bootstrapLazy([["helper-count-down.cjs",[[1,"helper-count-down",{"value":[520],"format":[513],"prefix":[513],"suffix":[513],"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"endTime":[32],"timeObj":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"],"value":["handleValueChange"]}]]]], options);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
exports.setNonce = index.setNonce;
|