@uibit/countdown 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 UIBit Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Countdown
2
+
3
+ [Interactive Demonstration](https://rawlings.github.io/uibit/components/countdown)
4
+
5
+ Countdown provides a highly customizable visual timer designed to communicate time sensitivity and build anticipation. Whether highlighting a product launch, event deadline, or limited-time campaign, it offers clear, real-time feedback that drives user action.
6
+
7
+ ## Value Delivery
8
+
9
+ - **Clear Time Tracking** – Displays time remaining with absolute clarity, preventing user confusion about deadlines.
10
+ - **Conversion Optimization** – Provides transparent visual indications of time limits to encourage prompt user decisions.
11
+ - **Dynamic Events** – Dispatches lifecycle events upon completion, allowing applications to automatically adapt content when the timer expires.
12
+ - **Flexible Presentation** – Supports specific calendar targets or relative durations, with responsive layout options that match parent designs.
13
+
14
+ ## Ideal Applications
15
+
16
+ - **Event Launches** – Counting down to live streams, product releases, or grand openings.
17
+ - **Campaign Deadlines** – Communicating registration limits or limited-time offers.
18
+ - **Transactional Interfaces** – Showing remaining time for reservation holdings or checkout windows.
19
+
20
+ ## Further Information
21
+
22
+ Detailed design guidelines, customizable attributes, and integration examples are available on our documentation site.
23
+
24
+
25
+ ## Changelog
26
+
27
+ Please see the [Changelog](CHANGELOG.md) for version history.
@@ -0,0 +1,346 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/countdown.ts",
8
+ "declarations": [
9
+ {
10
+ "kind": "class",
11
+ "description": "Countdown timer to a target date/time or a fixed duration. Supports\nconfigurable display formats and fires events on each tick and on completion.",
12
+ "name": "Countdown",
13
+ "cssProperties": [
14
+ {
15
+ "description": "Font family for the entire countdown",
16
+ "name": "--uibit-countdown-font-family",
17
+ "default": "ui-monospace,'SF Mono',Menlo,monospace"
18
+ },
19
+ {
20
+ "description": "Base font size",
21
+ "name": "--uibit-countdown-font-size",
22
+ "default": "1rem"
23
+ },
24
+ {
25
+ "description": "Font weight",
26
+ "name": "--uibit-countdown-font-weight",
27
+ "default": "600"
28
+ },
29
+ {
30
+ "description": "Text color for values",
31
+ "name": "--uibit-countdown-color",
32
+ "default": "#111827"
33
+ },
34
+ {
35
+ "description": "Gap between time units",
36
+ "name": "--uibit-countdown-gap",
37
+ "default": "1.5rem"
38
+ },
39
+ {
40
+ "description": "Gap between the value and label within a unit",
41
+ "name": "--uibit-countdown-unit-gap",
42
+ "default": "0.375rem"
43
+ },
44
+ {
45
+ "description": "Font size for the numeric value",
46
+ "name": "--uibit-countdown-value-font-size",
47
+ "default": "2.25rem"
48
+ },
49
+ {
50
+ "description": "Min width of each value block",
51
+ "name": "--uibit-countdown-value-min-width",
52
+ "default": "4rem"
53
+ },
54
+ {
55
+ "description": "Font size for unit labels (Days, Hours…)",
56
+ "name": "--uibit-countdown-label-font-size",
57
+ "default": "0.6875rem"
58
+ },
59
+ {
60
+ "description": "Color for unit labels",
61
+ "name": "--uibit-countdown-label-color",
62
+ "default": "#6b7280"
63
+ },
64
+ {
65
+ "description": "Font size of the colon separator",
66
+ "name": "--uibit-countdown-separator-font-size",
67
+ "default": "2.25rem"
68
+ },
69
+ {
70
+ "description": "Color of the colon separator",
71
+ "name": "--uibit-countdown-separator-color",
72
+ "default": "#d1d5db"
73
+ }
74
+ ],
75
+ "members": [
76
+ {
77
+ "kind": "field",
78
+ "name": "target",
79
+ "type": {
80
+ "text": "string | undefined"
81
+ },
82
+ "description": "ISO 8601 date/time string for the countdown target (e.g. `\"2025-12-31T00:00:00\"`). Takes precedence over `duration`.",
83
+ "attribute": "target"
84
+ },
85
+ {
86
+ "kind": "field",
87
+ "name": "duration",
88
+ "type": {
89
+ "text": "number | undefined"
90
+ },
91
+ "description": "Fixed countdown duration in milliseconds. Used when `target` is not set.",
92
+ "attribute": "duration"
93
+ },
94
+ {
95
+ "kind": "field",
96
+ "name": "autoStart",
97
+ "type": {
98
+ "text": "boolean"
99
+ },
100
+ "default": "true",
101
+ "description": "Automatically start the countdown on connect.",
102
+ "attribute": "auto-start"
103
+ },
104
+ {
105
+ "kind": "field",
106
+ "name": "format",
107
+ "type": {
108
+ "text": "string"
109
+ },
110
+ "default": "'HH:MM:SS'",
111
+ "description": "Display format. Tokens: `DD` days, `HH` hours, `MM` minutes, `SS` seconds.",
112
+ "attribute": "format"
113
+ },
114
+ {
115
+ "kind": "field",
116
+ "name": "remaining",
117
+ "type": {
118
+ "text": "number"
119
+ },
120
+ "privacy": "private",
121
+ "default": "0"
122
+ },
123
+ {
124
+ "kind": "field",
125
+ "name": "days",
126
+ "type": {
127
+ "text": "number"
128
+ },
129
+ "privacy": "private",
130
+ "default": "0"
131
+ },
132
+ {
133
+ "kind": "field",
134
+ "name": "hours",
135
+ "type": {
136
+ "text": "number"
137
+ },
138
+ "privacy": "private",
139
+ "default": "0"
140
+ },
141
+ {
142
+ "kind": "field",
143
+ "name": "minutes",
144
+ "type": {
145
+ "text": "number"
146
+ },
147
+ "privacy": "private",
148
+ "default": "0"
149
+ },
150
+ {
151
+ "kind": "field",
152
+ "name": "seconds",
153
+ "type": {
154
+ "text": "number"
155
+ },
156
+ "privacy": "private",
157
+ "default": "0"
158
+ },
159
+ {
160
+ "kind": "field",
161
+ "name": "timer",
162
+ "type": {
163
+ "text": "number | undefined"
164
+ },
165
+ "privacy": "private"
166
+ },
167
+ {
168
+ "kind": "field",
169
+ "name": "resolvedTargetTime",
170
+ "type": {
171
+ "text": "number"
172
+ },
173
+ "privacy": "private",
174
+ "default": "0"
175
+ },
176
+ {
177
+ "kind": "method",
178
+ "name": "start"
179
+ },
180
+ {
181
+ "kind": "method",
182
+ "name": "stop"
183
+ },
184
+ {
185
+ "kind": "method",
186
+ "name": "tick",
187
+ "privacy": "private"
188
+ },
189
+ {
190
+ "kind": "method",
191
+ "name": "getFormattedUnits",
192
+ "privacy": "private"
193
+ }
194
+ ],
195
+ "events": [
196
+ {
197
+ "type": {
198
+ "text": "{ days: number, hours: number, minutes: number, seconds: number, remaining: number }"
199
+ },
200
+ "description": "Fired every second while the countdown is running",
201
+ "name": "countdown-tick"
202
+ },
203
+ {
204
+ "description": "countdown-complete - Fired when the countdown reaches zero",
205
+ "name": "void"
206
+ }
207
+ ],
208
+ "attributes": [
209
+ {
210
+ "name": "target",
211
+ "type": {
212
+ "text": "string | undefined"
213
+ },
214
+ "description": "ISO 8601 date/time string for the countdown target (e.g. `\"2025-12-31T00:00:00\"`). Takes precedence over `duration`.",
215
+ "fieldName": "target"
216
+ },
217
+ {
218
+ "name": "duration",
219
+ "type": {
220
+ "text": "number | undefined"
221
+ },
222
+ "description": "Fixed countdown duration in milliseconds. Used when `target` is not set.",
223
+ "fieldName": "duration"
224
+ },
225
+ {
226
+ "name": "auto-start",
227
+ "type": {
228
+ "text": "boolean"
229
+ },
230
+ "default": "true",
231
+ "description": "Automatically start the countdown on connect.",
232
+ "fieldName": "autoStart"
233
+ },
234
+ {
235
+ "name": "format",
236
+ "type": {
237
+ "text": "string"
238
+ },
239
+ "default": "'HH:MM:SS'",
240
+ "description": "Display format. Tokens: `DD` days, `HH` hours, `MM` minutes, `SS` seconds.",
241
+ "fieldName": "format"
242
+ }
243
+ ],
244
+ "superclass": {
245
+ "name": "UIBitElement",
246
+ "package": "@uibit/core"
247
+ },
248
+ "tagName": "uibit-countdown",
249
+ "customElement": true
250
+ }
251
+ ],
252
+ "exports": [
253
+ {
254
+ "kind": "js",
255
+ "name": "Countdown",
256
+ "declaration": {
257
+ "name": "Countdown",
258
+ "module": "src/countdown.ts"
259
+ }
260
+ },
261
+ {
262
+ "kind": "custom-element-definition",
263
+ "name": "uibit-countdown",
264
+ "declaration": {
265
+ "name": "Countdown",
266
+ "module": "src/countdown.ts"
267
+ }
268
+ },
269
+ {
270
+ "kind": "js",
271
+ "name": "default",
272
+ "declaration": {
273
+ "name": "Countdown",
274
+ "module": "src/countdown.ts"
275
+ }
276
+ }
277
+ ]
278
+ },
279
+ {
280
+ "kind": "javascript-module",
281
+ "path": "src/index.ts",
282
+ "declarations": [],
283
+ "exports": [
284
+ {
285
+ "kind": "js",
286
+ "name": "default",
287
+ "declaration": {
288
+ "name": "default",
289
+ "module": "./countdown"
290
+ }
291
+ },
292
+ {
293
+ "kind": "js",
294
+ "name": "Countdown",
295
+ "declaration": {
296
+ "name": "Countdown",
297
+ "module": "./countdown"
298
+ }
299
+ },
300
+ {
301
+ "kind": "js",
302
+ "name": "CountdownConfig",
303
+ "declaration": {
304
+ "name": "CountdownConfig",
305
+ "module": "./types"
306
+ }
307
+ },
308
+ {
309
+ "kind": "js",
310
+ "name": "CountdownTickEvent",
311
+ "declaration": {
312
+ "name": "CountdownTickEvent",
313
+ "module": "./types"
314
+ }
315
+ }
316
+ ]
317
+ },
318
+ {
319
+ "kind": "javascript-module",
320
+ "path": "src/styles.ts",
321
+ "declarations": [
322
+ {
323
+ "kind": "variable",
324
+ "name": "styles",
325
+ "default": "css` :host { display: block; font-family: var(--uibit-countdown-font-family, inherit); font-size: var(--uibit-countdown-font-size, var(--uibit-font-size-base, 1rem)); font-weight: var(--uibit-countdown-font-weight, var(--uibit-font-weight-semibold, 600)); color: var(--uibit-countdown-color, #111827); text-align: center; } .countdown { display: flex; gap: var(--uibit-countdown-gap, 1.5rem); justify-content: center; align-items: center; } .unit { display: flex; flex-direction: column; align-items: center; gap: var(--uibit-countdown-unit-gap, 0.375rem); } .value { font-size: var(--uibit-countdown-value-font-size, var(--uibit-font-size-3xl, 2.25rem)); min-width: var(--uibit-countdown-value-min-width, 4rem); line-height: 1; letter-spacing: var(--uibit-letter-spacing-tight, -0.025em); font-variant-numeric: tabular-nums; } .label { font-size: var(--uibit-countdown-label-font-size, var(--uibit-font-size-xs, 0.6875rem)); text-transform: uppercase; letter-spacing: var(--uibit-letter-spacing-widest, 0.1em); color: var(--uibit-countdown-label-color, #6b7280); font-weight: var(--uibit-font-weight-medium, 500); } .separator { font-size: var(--uibit-countdown-separator-font-size, var(--uibit-font-size-3xl, 2.25rem)); align-self: flex-start; color: var(--uibit-countdown-separator-color, #d1d5db); line-height: 1; } `"
326
+ }
327
+ ],
328
+ "exports": [
329
+ {
330
+ "kind": "js",
331
+ "name": "styles",
332
+ "declaration": {
333
+ "name": "styles",
334
+ "module": "src/styles.ts"
335
+ }
336
+ }
337
+ ]
338
+ },
339
+ {
340
+ "kind": "javascript-module",
341
+ "path": "src/types.ts",
342
+ "declarations": [],
343
+ "exports": []
344
+ }
345
+ ]
346
+ }
@@ -0,0 +1,49 @@
1
+ import { UIBitElement } from '@uibit/core';
2
+ /**
3
+ * Countdown timer to a target date/time or a fixed duration. Supports
4
+ * configurable display formats and fires events on each tick and on completion.
5
+ *
6
+ * @fires {{ days: number, hours: number, minutes: number, seconds: number, remaining: number }} countdown-tick - Fired every second while the countdown is running
7
+ * @fires void countdown-complete - Fired when the countdown reaches zero
8
+ *
9
+ * @cssprop [--uibit-countdown-font-family=ui-monospace,'SF Mono',Menlo,monospace] - Font family for the entire countdown
10
+ * @cssprop [--uibit-countdown-font-size=1rem] - Base font size
11
+ * @cssprop [--uibit-countdown-font-weight=600] - Font weight
12
+ * @cssprop [--uibit-countdown-color=#111827] - Text color for values
13
+ * @cssprop [--uibit-countdown-gap=1.5rem] - Gap between time units
14
+ * @cssprop [--uibit-countdown-unit-gap=0.375rem] - Gap between the value and label within a unit
15
+ * @cssprop [--uibit-countdown-value-font-size=2.25rem] - Font size for the numeric value
16
+ * @cssprop [--uibit-countdown-value-min-width=4rem] - Min width of each value block
17
+ * @cssprop [--uibit-countdown-label-font-size=0.6875rem] - Font size for unit labels (Days, Hours…)
18
+ * @cssprop [--uibit-countdown-label-color=#6b7280] - Color for unit labels
19
+ * @cssprop [--uibit-countdown-separator-font-size=2.25rem] - Font size of the colon separator
20
+ * @cssprop [--uibit-countdown-separator-color=#d1d5db] - Color of the colon separator
21
+ */
22
+ export declare class Countdown extends UIBitElement {
23
+ static styles: import("lit").CSSResult;
24
+ /** ISO 8601 date/time string for the countdown target (e.g. `"2025-12-31T00:00:00"`). Takes precedence over `duration`. */
25
+ target?: string;
26
+ /** Fixed countdown duration in milliseconds. Used when `target` is not set. */
27
+ duration?: number;
28
+ /** Automatically start the countdown on connect. */
29
+ autoStart: boolean;
30
+ /** Display format. Tokens: `DD` days, `HH` hours, `MM` minutes, `SS` seconds. */
31
+ format: string;
32
+ private remaining;
33
+ private days;
34
+ private hours;
35
+ private minutes;
36
+ private seconds;
37
+ private timer?;
38
+ private resolvedTargetTime;
39
+ connectedCallback(): void;
40
+ disconnectedCallback(): void;
41
+ updated(changedProperties: Map<string, unknown>): void;
42
+ start(): void;
43
+ stop(): void;
44
+ private tick;
45
+ private getFormattedUnits;
46
+ render(): import("lit").TemplateResult<1>;
47
+ }
48
+ export default Countdown;
49
+ //# sourceMappingURL=countdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countdown.d.ts","sourceRoot":"","sources":["../src/countdown.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,YAAY,EAAE,MAAM,aAAa,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,SAAU,SAAQ,YAAY;IACzC,MAAM,CAAC,MAAM,0BAAU;IAEvB,2HAA2H;IAC/F,MAAM,CAAC,EAAE,MAAM,CAAC;IAC5C,+EAA+E;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC9C,oDAAoD;IACE,SAAS,UAAQ;IACvE,iFAAiF;IACrD,MAAM,SAAc;IAEvC,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IAE7B,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,kBAAkB,CAAK;IAE/B,iBAAiB,SAKhB;IAED,oBAAoB,SAGnB;IAED,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,QAY9C;IAED,KAAK,SASJ;IAED,IAAI,SAKH;IAED,OAAO,CAAC,IAAI;IAuBZ,OAAO,CAAC,iBAAiB;IAoDzB,MAAM,oCAeL;CACF;eAEc,SAAS"}
@@ -0,0 +1,197 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html } from 'lit';
8
+ import { customElement, msg, UIBitElement } from '@uibit/core';
9
+ import { property, state } from 'lit/decorators.js';
10
+ import { styles } from './styles';
11
+ /**
12
+ * Countdown timer to a target date/time or a fixed duration. Supports
13
+ * configurable display formats and fires events on each tick and on completion.
14
+ *
15
+ * @fires {{ days: number, hours: number, minutes: number, seconds: number, remaining: number }} countdown-tick - Fired every second while the countdown is running
16
+ * @fires void countdown-complete - Fired when the countdown reaches zero
17
+ *
18
+ * @cssprop [--uibit-countdown-font-family=ui-monospace,'SF Mono',Menlo,monospace] - Font family for the entire countdown
19
+ * @cssprop [--uibit-countdown-font-size=1rem] - Base font size
20
+ * @cssprop [--uibit-countdown-font-weight=600] - Font weight
21
+ * @cssprop [--uibit-countdown-color=#111827] - Text color for values
22
+ * @cssprop [--uibit-countdown-gap=1.5rem] - Gap between time units
23
+ * @cssprop [--uibit-countdown-unit-gap=0.375rem] - Gap between the value and label within a unit
24
+ * @cssprop [--uibit-countdown-value-font-size=2.25rem] - Font size for the numeric value
25
+ * @cssprop [--uibit-countdown-value-min-width=4rem] - Min width of each value block
26
+ * @cssprop [--uibit-countdown-label-font-size=0.6875rem] - Font size for unit labels (Days, Hours…)
27
+ * @cssprop [--uibit-countdown-label-color=#6b7280] - Color for unit labels
28
+ * @cssprop [--uibit-countdown-separator-font-size=2.25rem] - Font size of the colon separator
29
+ * @cssprop [--uibit-countdown-separator-color=#d1d5db] - Color of the colon separator
30
+ */
31
+ let Countdown = class Countdown extends UIBitElement {
32
+ constructor() {
33
+ super(...arguments);
34
+ /** Automatically start the countdown on connect. */
35
+ this.autoStart = true;
36
+ /** Display format. Tokens: `DD` days, `HH` hours, `MM` minutes, `SS` seconds. */
37
+ this.format = 'HH:MM:SS';
38
+ this.remaining = 0;
39
+ this.days = 0;
40
+ this.hours = 0;
41
+ this.minutes = 0;
42
+ this.seconds = 0;
43
+ this.resolvedTargetTime = 0;
44
+ }
45
+ static { this.styles = styles; }
46
+ connectedCallback() {
47
+ super.connectedCallback();
48
+ if (this.autoStart) {
49
+ this.start();
50
+ }
51
+ }
52
+ disconnectedCallback() {
53
+ super.disconnectedCallback();
54
+ this.stop();
55
+ }
56
+ updated(changedProperties) {
57
+ if (changedProperties.has('target') ||
58
+ changedProperties.has('duration') ||
59
+ changedProperties.has('autoStart')) {
60
+ if (this.autoStart) {
61
+ this.start();
62
+ }
63
+ else {
64
+ this.stop();
65
+ }
66
+ }
67
+ }
68
+ start() {
69
+ this.stop();
70
+ const now = Date.now();
71
+ this.resolvedTargetTime = this.target
72
+ ? new Date(this.target).getTime()
73
+ : now + (this.duration || 0);
74
+ this.tick();
75
+ this.timer = window.setInterval(() => this.tick(), 1000);
76
+ }
77
+ stop() {
78
+ if (this.timer) {
79
+ clearInterval(this.timer);
80
+ this.timer = undefined;
81
+ }
82
+ }
83
+ tick() {
84
+ const now = Date.now();
85
+ this.remaining = Math.max(0, this.resolvedTargetTime - now);
86
+ this.days = Math.floor(this.remaining / (1000 * 60 * 60 * 24));
87
+ this.hours = Math.floor((this.remaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
88
+ this.minutes = Math.floor((this.remaining % (1000 * 60 * 60)) / (1000 * 60));
89
+ this.seconds = Math.floor((this.remaining % (1000 * 60)) / 1000);
90
+ this.dispatchCustomEvent('countdown-tick', {
91
+ remaining: this.remaining,
92
+ days: this.days,
93
+ hours: this.hours,
94
+ minutes: this.minutes,
95
+ seconds: this.seconds,
96
+ });
97
+ if (this.remaining <= 0) {
98
+ this.stop();
99
+ this.dispatchCustomEvent('countdown-complete');
100
+ }
101
+ }
102
+ getFormattedUnits() {
103
+ const fmt = (this.format || 'HH:MM:SS').toUpperCase();
104
+ let displayDays = 0;
105
+ let displayHours = 0;
106
+ let displayMinutes = 0;
107
+ let displaySeconds = 0;
108
+ const totalSeconds = Math.floor(this.remaining / 1000);
109
+ const totalMinutes = Math.floor(totalSeconds / 60);
110
+ const totalHours = Math.floor(totalMinutes / 60);
111
+ if (fmt.includes('DD') || fmt.includes('DAY')) {
112
+ displayDays = this.days;
113
+ displayHours = this.hours;
114
+ displayMinutes = this.minutes;
115
+ displaySeconds = this.seconds;
116
+ }
117
+ else if (fmt.includes('HH')) {
118
+ displayHours = totalHours;
119
+ displayMinutes = this.minutes;
120
+ displaySeconds = this.seconds;
121
+ }
122
+ else if (fmt.includes('MM')) {
123
+ displayMinutes = totalMinutes;
124
+ displaySeconds = this.seconds;
125
+ }
126
+ else {
127
+ displaySeconds = totalSeconds;
128
+ }
129
+ const units = [];
130
+ if (fmt.includes('DD') || fmt.includes('DAY')) {
131
+ units.push({ value: String(displayDays).padStart(2, '0'), label: msg('Days') });
132
+ }
133
+ if (fmt.includes('HH') || fmt.includes('HOUR')) {
134
+ units.push({ value: String(displayHours).padStart(2, '0'), label: msg('Hours') });
135
+ }
136
+ if (fmt.includes('MM') || fmt.includes('MIN')) {
137
+ units.push({ value: String(displayMinutes).padStart(2, '0'), label: msg('Minutes') });
138
+ }
139
+ if (fmt.includes('SS') || fmt.includes('SEC')) {
140
+ units.push({ value: String(displaySeconds).padStart(2, '0'), label: msg('Seconds') });
141
+ }
142
+ // If format matches nothing standard, default to HH:MM:SS
143
+ if (units.length === 0) {
144
+ units.push({ value: String(totalHours).padStart(2, '0'), label: msg('Hours') });
145
+ units.push({ value: String(this.minutes).padStart(2, '0'), label: msg('Minutes') });
146
+ units.push({ value: String(this.seconds).padStart(2, '0'), label: msg('Seconds') });
147
+ }
148
+ return units;
149
+ }
150
+ render() {
151
+ const units = this.getFormattedUnits();
152
+ return html `
153
+ <div part="countdown" class="countdown" role="timer" aria-live="polite" aria-label=${msg('Countdown timer')}>
154
+ ${units.map((unit, index) => html `
155
+ ${index > 0 ? html `<div part="separator" class="separator">:</div>` : ''}
156
+ <div part="unit" class="unit">
157
+ <div part="value" class="value">${unit.value}</div>
158
+ <div part="label" class="label"><slot name="${unit.label.toLowerCase()}-label">${unit.label}</slot></div>
159
+ </div>
160
+ `)}
161
+ </div>
162
+ `;
163
+ }
164
+ };
165
+ __decorate([
166
+ property({ type: String })
167
+ ], Countdown.prototype, "target", void 0);
168
+ __decorate([
169
+ property({ type: Number })
170
+ ], Countdown.prototype, "duration", void 0);
171
+ __decorate([
172
+ property({ type: Boolean, attribute: 'auto-start' })
173
+ ], Countdown.prototype, "autoStart", void 0);
174
+ __decorate([
175
+ property({ type: String })
176
+ ], Countdown.prototype, "format", void 0);
177
+ __decorate([
178
+ state()
179
+ ], Countdown.prototype, "remaining", void 0);
180
+ __decorate([
181
+ state()
182
+ ], Countdown.prototype, "days", void 0);
183
+ __decorate([
184
+ state()
185
+ ], Countdown.prototype, "hours", void 0);
186
+ __decorate([
187
+ state()
188
+ ], Countdown.prototype, "minutes", void 0);
189
+ __decorate([
190
+ state()
191
+ ], Countdown.prototype, "seconds", void 0);
192
+ Countdown = __decorate([
193
+ customElement('uibit-countdown')
194
+ ], Countdown);
195
+ export { Countdown };
196
+ export default Countdown;
197
+ //# sourceMappingURL=countdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countdown.js","sourceRoot":"","sources":["../src/countdown.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,YAAY;IAApC;;QAOL,oDAAoD;QACE,cAAS,GAAG,IAAI,CAAC;QACvE,iFAAiF;QACrD,WAAM,GAAG,UAAU,CAAC;QAE/B,cAAS,GAAG,CAAC,CAAC;QACd,SAAI,GAAG,CAAC,CAAC;QACT,UAAK,GAAG,CAAC,CAAC;QAC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A3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAiB;AAEhB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAmB;AAEQ;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;4CAAkB;AAE3C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAqB;AAE/B;IAAhB,KAAK,EAAE;4CAAuB;AACd;IAAhB,KAAK,EAAE;uCAAkB;AACT;IAAhB,KAAK,EAAE;wCAAmB;AACV;IAAhB,KAAK,EAAE;0CAAqB;AACZ;IAAhB,KAAK,EAAE;0CAAqB;AAhBlB,SAAS;IADrB,aAAa,CAAC,iBAAiB,CAAC;GACpB,SAAS,CA4JrB;;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Component, ChangeDetectionStrategy, ElementRef, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
2
+ import '@uibit/countdown';
3
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
4
+
5
+ @Component({
6
+ selector: 'uibit-countdown',
7
+ template: '<ng-content></ng-content>',
8
+ changeDetection: ChangeDetectionStrategy.OnPush,
9
+ standalone: true,
10
+ host: {
11
+ '(countdown-tick)': 'countdownTick.emit($event)',
12
+ '(void)': 'void.emit($event)'
13
+ }
14
+ })
15
+ export class NgxCountdown {
16
+ constructor(private el: ElementRef<HTMLElementClass>) {
17
+ effect(() => {
18
+ if (this.el.nativeElement) {
19
+ this.el.nativeElement.target = this.target();
20
+ }
21
+ });
22
+ effect(() => {
23
+ if (this.el.nativeElement) {
24
+ this.el.nativeElement.duration = this.duration();
25
+ }
26
+ });
27
+ effect(() => {
28
+ if (this.el.nativeElement) {
29
+ this.el.nativeElement.autoStart = this.autoStart();
30
+ }
31
+ });
32
+ effect(() => {
33
+ if (this.el.nativeElement) {
34
+ this.el.nativeElement.format = this.format();
35
+ }
36
+ });
37
+ }
38
+
39
+ readonly target = input<string | undefined, any>('');
40
+ readonly duration = input<number | undefined, any>(0, { transform: numberAttribute });
41
+ readonly autoStart = input<boolean, any>(true, { transform: booleanAttribute });
42
+ readonly format = input<string, any>('HH:MM:SS');
43
+
44
+ readonly countdownTick = output<CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>>();
45
+ readonly void = output<CustomEvent<any>>();
46
+ }
@@ -0,0 +1,10 @@
1
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
2
+ import '@uibit/countdown';
3
+
4
+ declare global {
5
+ namespace astroHTML.JSX {
6
+ interface IntrinsicElements {
7
+ 'uibit-countdown': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes;
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ import { defineNuxtPlugin } from '#app';
2
+
3
+ export default defineNuxtPlugin(() => {
4
+ if (process.client) {
5
+ import('@uibit/countdown');
6
+ }
7
+ });
@@ -0,0 +1,16 @@
1
+ import type { JSX } from 'preact';
2
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
3
+ import '@uibit/countdown';
4
+
5
+ declare module 'preact' {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ 'uibit-countdown': JSX.HTMLAttributes<HTMLElementClass> & {
9
+ target?: string | undefined;
10
+ duration?: number | undefined;
11
+ autoStart?: boolean;
12
+ format?: string;
13
+ };
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,10 @@
1
+ import { component$, Slot } from '@builder.io/qwik';
2
+ import '@uibit/countdown';
3
+
4
+ export const Countdown = component$<any>((props) => {
5
+ return (
6
+ <uibit-countdown {...props}>
7
+ <Slot />
8
+ </uibit-countdown>
9
+ );
10
+ });
@@ -0,0 +1,22 @@
1
+ import type { HTMLAttributes, ClassAttributes } from 'react';
2
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
3
+ import '@uibit/countdown';
4
+
5
+ declare global {
6
+ namespace React {
7
+ namespace JSX {
8
+ interface IntrinsicElements {
9
+ 'uibit-countdown': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
10
+ children?: React.ReactNode;
11
+ class?: string;
12
+ target?: string | undefined;
13
+ duration?: number | undefined;
14
+ autoStart?: boolean;
15
+ format?: string;
16
+ onCountdownTick?: (event: any) => void;
17
+ onVoid?: (event: any) => void;
18
+ };
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,18 @@
1
+ import type { JSX } from 'solid-js';
2
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
3
+ import '@uibit/countdown';
4
+
5
+ declare module 'solid-js' {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ 'uibit-countdown': Partial<HTMLElementClass> & JSX.HTMLAttributes<HTMLElementClass> & {
9
+ target?: string | undefined;
10
+ duration?: number | undefined;
11
+ autoStart?: boolean;
12
+ format?: string;
13
+ "on:countdown-tick"?: (event: CustomEvent) => void;
14
+ "on:void"?: (event: CustomEvent) => void;
15
+ };
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,15 @@
1
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
2
+ import '@uibit/countdown';
3
+
4
+ declare module '@stencil/core' {
5
+ export namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'uibit-countdown': HTMLElementClass & {
8
+ target?: string | undefined;
9
+ duration?: number | undefined;
10
+ autoStart?: boolean;
11
+ format?: string;
12
+ };
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,46 @@
1
+ <script lang="ts">
2
+ import '@uibit/countdown';
3
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
4
+
5
+ let {
6
+ target = undefined,
7
+ duration = undefined,
8
+ autoStart = undefined,
9
+ format = undefined,
10
+ children
11
+ } = $props<{
12
+ children?: any;
13
+ target?: string | undefined;
14
+ duration?: number | undefined;
15
+ autoStart?: boolean;
16
+ format?: string;
17
+
18
+ }>();
19
+
20
+ let elementRef: HTMLElementClass | null = $state(null);
21
+
22
+ $effect(() => {
23
+ if (elementRef && target !== undefined) {
24
+ elementRef.target = target;
25
+ }
26
+ if (elementRef && duration !== undefined) {
27
+ elementRef.duration = duration;
28
+ }
29
+ if (elementRef && autoStart !== undefined) {
30
+ elementRef.autoStart = autoStart;
31
+ }
32
+ if (elementRef && format !== undefined) {
33
+ elementRef.format = format;
34
+ }
35
+ });
36
+
37
+ </script>
38
+
39
+ <uibit-countdown bind:this={elementRef} {...$$restProps}>
40
+
41
+ {#if children}
42
+ {@render children()}
43
+ {:else}
44
+ <slot />
45
+ {/if}
46
+ </uibit-countdown>
@@ -0,0 +1,30 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import type { Countdown as HTMLElementClass } from '@uibit/countdown';
3
+ import '@uibit/countdown';
4
+
5
+ export const Countdown = defineComponent({
6
+ name: 'Countdown',
7
+ props: {
8
+ target: { type: [String, Number, Boolean, Array, Object] as any },
9
+ duration: { type: [String, Number, Boolean, Array, Object] as any },
10
+ autoStart: { type: [String, Number, Boolean, Array, Object] as any },
11
+ format: { type: [String, Number, Boolean, Array, Object] as any }
12
+ },
13
+ emits: ['countdown-tick', 'void'],
14
+ setup(props, { slots, emit }) {
15
+ return () => {
16
+ const eventListeners: Record<string, any> = {};
17
+ eventListeners['onCountdown-tick'] = (event: Event) => {
18
+ emit('countdown-tick', event);
19
+ };
20
+ eventListeners['onVoid'] = (event: Event) => {
21
+ emit('void', event);
22
+ };
23
+
24
+ return h('uibit-countdown', {
25
+ ...props,
26
+ ...eventListeners
27
+ }, slots.default?.());
28
+ };
29
+ }
30
+ });
@@ -0,0 +1,3 @@
1
+ export { default, Countdown } from './countdown';
2
+ export type { CountdownConfig, CountdownTickEvent } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default, Countdown } from './countdown';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const styles: import("lit").CSSResult;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBA8ClB,CAAC"}
package/dist/styles.js ADDED
@@ -0,0 +1,49 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: block;
5
+ font-family: var(--uibit-countdown-font-family, inherit);
6
+ font-size: var(--uibit-countdown-font-size, var(--uibit-font-size-base, 1rem));
7
+ font-weight: var(--uibit-countdown-font-weight, var(--uibit-font-weight-semibold, 600));
8
+ color: var(--uibit-countdown-color, #111827);
9
+ text-align: center;
10
+ }
11
+
12
+ .countdown {
13
+ display: flex;
14
+ gap: var(--uibit-countdown-gap, 1.5rem);
15
+ justify-content: center;
16
+ align-items: center;
17
+ }
18
+
19
+ .unit {
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center;
23
+ gap: var(--uibit-countdown-unit-gap, 0.375rem);
24
+ }
25
+
26
+ .value {
27
+ font-size: var(--uibit-countdown-value-font-size, var(--uibit-font-size-3xl, 2.25rem));
28
+ min-width: var(--uibit-countdown-value-min-width, 4rem);
29
+ line-height: 1;
30
+ letter-spacing: var(--uibit-letter-spacing-tight, -0.025em);
31
+ font-variant-numeric: tabular-nums;
32
+ }
33
+
34
+ .label {
35
+ font-size: var(--uibit-countdown-label-font-size, var(--uibit-font-size-xs, 0.6875rem));
36
+ text-transform: uppercase;
37
+ letter-spacing: var(--uibit-letter-spacing-widest, 0.1em);
38
+ color: var(--uibit-countdown-label-color, #6b7280);
39
+ font-weight: var(--uibit-font-weight-medium, 500);
40
+ }
41
+
42
+ .separator {
43
+ font-size: var(--uibit-countdown-separator-font-size, var(--uibit-font-size-3xl, 2.25rem));
44
+ align-self: flex-start;
45
+ color: var(--uibit-countdown-separator-color, #d1d5db);
46
+ line-height: 1;
47
+ }
48
+ `;
49
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CxB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type Countdown from './countdown';
2
+ export interface CountdownConfig {
3
+ target?: string | Date;
4
+ duration?: number;
5
+ autoStart?: boolean;
6
+ format?: string;
7
+ timezone?: string;
8
+ }
9
+ export interface CountdownTickEvent extends CustomEvent {
10
+ detail: {
11
+ remaining: number;
12
+ days: number;
13
+ hours: number;
14
+ minutes: number;
15
+ seconds: number;
16
+ };
17
+ }
18
+ declare global {
19
+ interface HTMLElementTagNameMap {
20
+ 'uibit-countdown': Countdown;
21
+ }
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACf,UAAU,qBAAqB;QAC3B,iBAAiB,EAAE,SAAS,CAAC;KAChC;CACA"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@uibit/countdown",
3
+ "version": "0.1.0",
4
+ "description": "Highly customizable countdown timer. Supports target date markers or set durations, reactive timers, and custom format templates.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./countdown.css": "./dist/countdown.css",
14
+ "./custom-elements.json": "./custom-elements.json",
15
+ "./react": "./dist/frameworks/react/index.d.ts",
16
+ "./vue": "./dist/frameworks/vue/index.ts",
17
+ "./svelte": "./dist/frameworks/svelte/index.svelte",
18
+ "./angular": "./dist/frameworks/angular/index.ts",
19
+ "./solid": "./dist/frameworks/solid/index.d.ts",
20
+ "./astro": "./dist/frameworks/astro/index.astro",
21
+ "./qwik": "./dist/frameworks/qwik/index.tsx",
22
+ "./nuxt": "./dist/frameworks/nuxt/index.ts",
23
+ "./preact": "./dist/frameworks/preact/index.d.ts",
24
+ "./stencil": "./dist/frameworks/stencil/index.d.ts"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "package.json",
29
+ "README.md",
30
+ "LICENSE",
31
+ "custom-elements.json"
32
+ ],
33
+ "keywords": [
34
+ "countdown",
35
+ "timer",
36
+ "web-component",
37
+ "lit",
38
+ "event"
39
+ ],
40
+ "author": "Jonathan Rawlings",
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/Rawlings/uibit",
45
+ "directory": "packages/components/countdown"
46
+ },
47
+ "dependencies": {
48
+ "@uibit/core": "0.1.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^20.19.43",
52
+ "lit": "^3.3.3",
53
+ "typescript": "7.0.2",
54
+ "@uibit/codegen": "0.1.0"
55
+ },
56
+ "peerDependencies": {
57
+ "lit": "^3.0.0",
58
+ "react": ">=18",
59
+ "vue": ">=3",
60
+ "svelte": ">=4 || ^5",
61
+ "@angular/core": ">=14"
62
+ },
63
+ "customElements": "custom-elements.json",
64
+ "peerDependenciesMeta": {
65
+ "react": {
66
+ "optional": true
67
+ },
68
+ "vue": {
69
+ "optional": true
70
+ },
71
+ "svelte": {
72
+ "optional": true
73
+ },
74
+ "@angular/core": {
75
+ "optional": true
76
+ }
77
+ },
78
+ "uibit": {
79
+ "id": "countdown",
80
+ "title": "Countdown",
81
+ "category": "Data",
82
+ "tagName": "uibit-countdown"
83
+ },
84
+ "scripts": {
85
+ "build": "cem analyze --globs 'src/**/*.ts' --litelement && uibit-codegen --package . && tsc",
86
+ "dev": "concurrently \"cem analyze --globs 'src/**/*.ts' --litelement --watch\" \"tsc --watch\"",
87
+ "analyze": "cem analyze --globs 'src/**/*.ts' --litelement",
88
+ "typecheck": "tsc --noEmit"
89
+ }
90
+ }