@uibit/countdown 0.1.1 → 0.2.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/dist/frameworks/angular/index.ts +50 -43
- package/dist/frameworks/astro/index.d.ts +9 -1
- package/dist/frameworks/preact/index.d.ts +4 -0
- package/dist/frameworks/react/index.ts +138 -0
- package/dist/frameworks/solid/index.d.ts +2 -2
- package/dist/frameworks/stencil/index.d.ts +4 -0
- package/dist/frameworks/svelte/index.svelte +56 -21
- package/dist/frameworks/vue/index.ts +111 -27
- package/package.json +3 -3
- package/dist/frameworks/react/index.d.ts +0 -23
|
@@ -1,52 +1,59 @@
|
|
|
1
1
|
import { Component, ChangeDetectionStrategy, ElementRef, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
|
|
2
2
|
import '@uibit/countdown';
|
|
3
3
|
import type { Countdown as HTMLElementClass } from '@uibit/countdown';
|
|
4
|
-
|
|
5
4
|
@Component({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
selector: 'uibit-countdown',
|
|
6
|
+
template: '<ng-content></ng-content>',
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
standalone: true,
|
|
9
|
+
host: {
|
|
10
|
+
'(countdown-tick)': 'countdownTick.emit($event)',
|
|
11
|
+
'(void)': 'void.emit($event)'
|
|
12
|
+
}
|
|
14
13
|
})
|
|
15
14
|
export class NgxCountdown {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
constructor(private el: ElementRef<HTMLElementClass>){
|
|
16
|
+
effect(()=>{
|
|
17
|
+
if (this.el.nativeElement) {
|
|
18
|
+
this.el.nativeElement.target = this.target();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
effect(()=>{
|
|
22
|
+
if (this.el.nativeElement) {
|
|
23
|
+
this.el.nativeElement.duration = this.duration();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
effect(()=>{
|
|
27
|
+
if (this.el.nativeElement) {
|
|
28
|
+
this.el.nativeElement.autoStart = this.autoStart();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
effect(()=>{
|
|
32
|
+
if (this.el.nativeElement) {
|
|
33
|
+
this.el.nativeElement.format = this.format();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
effect(()=>{
|
|
37
|
+
if (this.el.nativeElement) {
|
|
38
|
+
this.el.nativeElement.locale = this.locale();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
readonly target = input<string | undefined>(undefined);
|
|
43
|
+
readonly duration = input<number | undefined, any>(undefined, {
|
|
44
|
+
transform: numberAttribute
|
|
21
45
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.el.nativeElement.duration = this.duration();
|
|
25
|
-
}
|
|
46
|
+
readonly autoStart = input<boolean, any>(true, {
|
|
47
|
+
transform: booleanAttribute
|
|
26
48
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
effect(() => {
|
|
38
|
-
if (this.el.nativeElement) {
|
|
39
|
-
this.el.nativeElement.locale = this.locale();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
readonly target = input<string | undefined, any>('');
|
|
45
|
-
readonly duration = input<number | undefined, any>(0, { transform: numberAttribute });
|
|
46
|
-
readonly autoStart = input<boolean, any>(true, { transform: booleanAttribute });
|
|
47
|
-
readonly format = input<string, any>('HH:MM:SS');
|
|
48
|
-
readonly locale = input<string, any>('');
|
|
49
|
-
|
|
50
|
-
readonly countdownTick = output<CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>>();
|
|
51
|
-
readonly void = output<CustomEvent<any>>();
|
|
49
|
+
readonly format = input<string>('HH:MM:SS');
|
|
50
|
+
readonly locale = input<string>('');
|
|
51
|
+
readonly countdownTick = output<CustomEvent<{
|
|
52
|
+
days: number;
|
|
53
|
+
hours: number;
|
|
54
|
+
minutes: number;
|
|
55
|
+
seconds: number;
|
|
56
|
+
remaining: number;
|
|
57
|
+
}>>();
|
|
58
|
+
readonly void = output<CustomEvent<any>>();
|
|
52
59
|
}
|
|
@@ -4,7 +4,15 @@ import '@uibit/countdown';
|
|
|
4
4
|
declare global {
|
|
5
5
|
namespace astroHTML.JSX {
|
|
6
6
|
interface IntrinsicElements {
|
|
7
|
-
'uibit-countdown': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes
|
|
7
|
+
'uibit-countdown': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
|
|
8
|
+
target?: string | undefined;
|
|
9
|
+
duration?: number | undefined;
|
|
10
|
+
autoStart?: boolean;
|
|
11
|
+
format?: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
"on:countdown-tick"?: (event: CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>) => void;
|
|
14
|
+
"on:void"?: (event: Event) => void;
|
|
15
|
+
};
|
|
8
16
|
}
|
|
9
17
|
}
|
|
10
18
|
}
|
|
@@ -11,6 +11,10 @@ declare module 'preact' {
|
|
|
11
11
|
autoStart?: boolean;
|
|
12
12
|
format?: string;
|
|
13
13
|
locale?: string;
|
|
14
|
+
onCountdownTick?: (event: CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>) => void;
|
|
15
|
+
"on:countdown-tick"?: (event: CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>) => void;
|
|
16
|
+
onVoid?: (event: Event) => void;
|
|
17
|
+
"on:void"?: (event: Event) => void;
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
2
|
+
import type { Countdown as HTMLElementClass } from '@uibit/countdown';
|
|
3
|
+
import '@uibit/countdown';
|
|
4
|
+
const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
5
|
+
export interface CountdownProps extends Omit<React.HTMLAttributes<HTMLElementClass>, 'target' | 'duration' | 'autoStart' | 'format' | 'locale' | 'onCountdownTick' | 'onVoid'> {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
target?: string | undefined;
|
|
8
|
+
duration?: number | undefined;
|
|
9
|
+
autoStart?: boolean;
|
|
10
|
+
format?: string;
|
|
11
|
+
locale?: string;
|
|
12
|
+
onCountdownTick?: (event: CustomEvent<{
|
|
13
|
+
days: number;
|
|
14
|
+
hours: number;
|
|
15
|
+
minutes: number;
|
|
16
|
+
seconds: number;
|
|
17
|
+
remaining: number;
|
|
18
|
+
}>) => void;
|
|
19
|
+
onVoid?: (event: Event) => void;
|
|
20
|
+
}
|
|
21
|
+
export const Countdown = ({ ref, children, ...props }: CountdownProps & {
|
|
22
|
+
ref?: React.Ref<HTMLElementClass>;
|
|
23
|
+
})=>{
|
|
24
|
+
const innerRef = useRef<HTMLElementClass>(null);
|
|
25
|
+
const propsRef = useRef(props);
|
|
26
|
+
propsRef.current = props;
|
|
27
|
+
useImperativeHandle(ref, ()=>innerRef.current!);
|
|
28
|
+
useTypeOfLayoutEffect(()=>{
|
|
29
|
+
const element = innerRef.current;
|
|
30
|
+
if (element && props.target !== undefined) {
|
|
31
|
+
(element as any).target = props.target;
|
|
32
|
+
}
|
|
33
|
+
}, [
|
|
34
|
+
props.target
|
|
35
|
+
]);
|
|
36
|
+
useTypeOfLayoutEffect(()=>{
|
|
37
|
+
const element = innerRef.current;
|
|
38
|
+
if (element && props.duration !== undefined) {
|
|
39
|
+
(element as any).duration = props.duration;
|
|
40
|
+
}
|
|
41
|
+
}, [
|
|
42
|
+
props.duration
|
|
43
|
+
]);
|
|
44
|
+
useTypeOfLayoutEffect(()=>{
|
|
45
|
+
const element = innerRef.current;
|
|
46
|
+
if (element && props.autoStart !== undefined) {
|
|
47
|
+
(element as any).autoStart = props.autoStart;
|
|
48
|
+
}
|
|
49
|
+
}, [
|
|
50
|
+
props.autoStart
|
|
51
|
+
]);
|
|
52
|
+
useTypeOfLayoutEffect(()=>{
|
|
53
|
+
const element = innerRef.current;
|
|
54
|
+
if (element && props.format !== undefined) {
|
|
55
|
+
(element as any).format = props.format;
|
|
56
|
+
}
|
|
57
|
+
}, [
|
|
58
|
+
props.format
|
|
59
|
+
]);
|
|
60
|
+
useTypeOfLayoutEffect(()=>{
|
|
61
|
+
const element = innerRef.current;
|
|
62
|
+
if (element && props.locale !== undefined) {
|
|
63
|
+
(element as any).locale = props.locale;
|
|
64
|
+
}
|
|
65
|
+
}, [
|
|
66
|
+
props.locale
|
|
67
|
+
]);
|
|
68
|
+
useTypeOfLayoutEffect(()=>{
|
|
69
|
+
const element = innerRef.current;
|
|
70
|
+
if (!element) return;
|
|
71
|
+
const handleEvent = (event: Event)=>{
|
|
72
|
+
if (propsRef.current.onCountdownTick) {
|
|
73
|
+
propsRef.current.onCountdownTick(event as any);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
element.addEventListener('countdown-tick', handleEvent);
|
|
77
|
+
return ()=>{
|
|
78
|
+
element.removeEventListener('countdown-tick', handleEvent);
|
|
79
|
+
};
|
|
80
|
+
}, []);
|
|
81
|
+
useTypeOfLayoutEffect(()=>{
|
|
82
|
+
const element = innerRef.current;
|
|
83
|
+
if (!element) return;
|
|
84
|
+
const handleEvent = (event: Event)=>{
|
|
85
|
+
if (propsRef.current.onVoid) {
|
|
86
|
+
propsRef.current.onVoid(event as any);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
element.addEventListener('void', handleEvent);
|
|
90
|
+
return ()=>{
|
|
91
|
+
element.removeEventListener('void', handleEvent);
|
|
92
|
+
};
|
|
93
|
+
}, []);
|
|
94
|
+
const domProps = {
|
|
95
|
+
...props
|
|
96
|
+
};
|
|
97
|
+
const customPropNames = [
|
|
98
|
+
'target',
|
|
99
|
+
'duration',
|
|
100
|
+
'autoStart',
|
|
101
|
+
'format',
|
|
102
|
+
'locale',
|
|
103
|
+
'onCountdownTick',
|
|
104
|
+
'onVoid'
|
|
105
|
+
];
|
|
106
|
+
for (const key of customPropNames){
|
|
107
|
+
delete (domProps as any)[key];
|
|
108
|
+
}
|
|
109
|
+
return React.createElement('uibit-countdown', {
|
|
110
|
+
ref: innerRef,
|
|
111
|
+
...domProps
|
|
112
|
+
}, children);
|
|
113
|
+
};
|
|
114
|
+
declare global {
|
|
115
|
+
namespace React {
|
|
116
|
+
namespace JSX {
|
|
117
|
+
interface IntrinsicElements {
|
|
118
|
+
'uibit-countdown': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
|
|
119
|
+
children?: React.ReactNode;
|
|
120
|
+
class?: string;
|
|
121
|
+
target?: string | undefined;
|
|
122
|
+
duration?: number | undefined;
|
|
123
|
+
autoStart?: boolean;
|
|
124
|
+
format?: string;
|
|
125
|
+
locale?: string;
|
|
126
|
+
onCountdownTick?: (event: CustomEvent<{
|
|
127
|
+
days: number;
|
|
128
|
+
hours: number;
|
|
129
|
+
minutes: number;
|
|
130
|
+
seconds: number;
|
|
131
|
+
remaining: number;
|
|
132
|
+
}>) => void;
|
|
133
|
+
onVoid?: (event: CustomEvent<any>) => void;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -11,8 +11,8 @@ declare module 'solid-js' {
|
|
|
11
11
|
autoStart?: boolean;
|
|
12
12
|
format?: string;
|
|
13
13
|
locale?: string;
|
|
14
|
-
"on:countdown-tick"?: (event: CustomEvent) => void;
|
|
15
|
-
"on:void"?: (event:
|
|
14
|
+
"on:countdown-tick"?: (event: CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>) => void;
|
|
15
|
+
"on:void"?: (event: Event) => void;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -10,6 +10,10 @@ declare module '@stencil/core' {
|
|
|
10
10
|
autoStart?: boolean;
|
|
11
11
|
format?: string;
|
|
12
12
|
locale?: string;
|
|
13
|
+
onCountdownTick?: (event: CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>) => void;
|
|
14
|
+
"on:countdown-tick"?: (event: CustomEvent<{ days: number, hours: number, minutes: number, seconds: number, remaining: number }>) => void;
|
|
15
|
+
onVoid?: (event: Event) => void;
|
|
16
|
+
"on:void"?: (event: Event) => void;
|
|
13
17
|
};
|
|
14
18
|
}
|
|
15
19
|
}
|
|
@@ -1,47 +1,82 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import '@uibit/countdown';
|
|
3
3
|
import type { Countdown as HTMLElementClass } from '@uibit/countdown';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
target =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
target = $bindable(),
|
|
7
|
+
duration = $bindable(),
|
|
8
|
+
autoStart = $bindable(),
|
|
9
|
+
format = $bindable(),
|
|
10
|
+
locale = $bindable(),
|
|
11
|
+
children,
|
|
12
|
+
...restProps
|
|
12
13
|
} = $props<{
|
|
13
|
-
children?:
|
|
14
|
+
children?: import('svelte').Snippet;
|
|
14
15
|
target?: string | undefined;
|
|
15
16
|
duration?: number | undefined;
|
|
16
17
|
autoStart?: boolean;
|
|
17
18
|
format?: string;
|
|
18
19
|
locale?: string;
|
|
19
|
-
|
|
20
|
+
|
|
21
|
+
[key: string]: any;
|
|
20
22
|
}>();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (elementRef && target !== undefined) {
|
|
23
|
+
|
|
24
|
+
let elementRef: HTMLElementClass | null = $state(null);
|
|
25
|
+
|
|
26
|
+
$effect(() => {
|
|
27
|
+
if (elementRef && target !== undefined && elementRef.target !== target) {
|
|
26
28
|
elementRef.target = target;
|
|
27
29
|
}
|
|
28
|
-
if (elementRef && duration !== undefined) {
|
|
30
|
+
if (elementRef && duration !== undefined && elementRef.duration !== duration) {
|
|
29
31
|
elementRef.duration = duration;
|
|
30
32
|
}
|
|
31
|
-
if (elementRef && autoStart !== undefined) {
|
|
33
|
+
if (elementRef && autoStart !== undefined && elementRef.autoStart !== autoStart) {
|
|
32
34
|
elementRef.autoStart = autoStart;
|
|
33
35
|
}
|
|
34
|
-
if (elementRef && format !== undefined) {
|
|
36
|
+
if (elementRef && format !== undefined && elementRef.format !== format) {
|
|
35
37
|
elementRef.format = format;
|
|
36
38
|
}
|
|
37
|
-
if (elementRef && locale !== undefined) {
|
|
39
|
+
if (elementRef && locale !== undefined && elementRef.locale !== locale) {
|
|
38
40
|
elementRef.locale = locale;
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
|
-
|
|
43
|
+
|
|
44
|
+
$effect(() => {
|
|
45
|
+
const element = elementRef;
|
|
46
|
+
if (!element) return;
|
|
47
|
+
|
|
48
|
+
const handleEvent = () => {
|
|
49
|
+
if (target !== element.target) {
|
|
50
|
+
target = element.target as any;
|
|
51
|
+
}
|
|
52
|
+
if (duration !== element.duration) {
|
|
53
|
+
duration = element.duration as any;
|
|
54
|
+
}
|
|
55
|
+
if (autoStart !== element.autoStart) {
|
|
56
|
+
autoStart = element.autoStart as any;
|
|
57
|
+
}
|
|
58
|
+
if (format !== element.format) {
|
|
59
|
+
format = element.format as any;
|
|
60
|
+
}
|
|
61
|
+
if (locale !== element.locale) {
|
|
62
|
+
locale = element.locale as any;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const events = ['change', 'input', 'countdown-tick', 'void'];
|
|
67
|
+
for (const event of events) {
|
|
68
|
+
element.addEventListener(event, handleEvent);
|
|
69
|
+
}
|
|
70
|
+
return () => {
|
|
71
|
+
for (const event of events) {
|
|
72
|
+
element.removeEventListener(event, handleEvent);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
42
77
|
</script>
|
|
43
78
|
|
|
44
|
-
<uibit-countdown bind:this={elementRef} {
|
|
79
|
+
<uibit-countdown bind:this={elementRef} {...restProps}>
|
|
45
80
|
|
|
46
81
|
{#if children}
|
|
47
82
|
{@render children()}
|
|
@@ -1,31 +1,115 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue';
|
|
1
|
+
import { defineComponent, h, ref, watch } from 'vue';
|
|
2
2
|
import type { Countdown as HTMLElementClass } from '@uibit/countdown';
|
|
3
3
|
import '@uibit/countdown';
|
|
4
|
-
|
|
5
4
|
export const Countdown = defineComponent({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
name: 'Countdown',
|
|
6
|
+
props: {
|
|
7
|
+
target: {
|
|
8
|
+
type: [
|
|
9
|
+
String,
|
|
10
|
+
Number,
|
|
11
|
+
Boolean,
|
|
12
|
+
Array,
|
|
13
|
+
Object
|
|
14
|
+
] as any
|
|
15
|
+
},
|
|
16
|
+
duration: {
|
|
17
|
+
type: [
|
|
18
|
+
String,
|
|
19
|
+
Number,
|
|
20
|
+
Boolean,
|
|
21
|
+
Array,
|
|
22
|
+
Object
|
|
23
|
+
] as any
|
|
24
|
+
},
|
|
25
|
+
autoStart: {
|
|
26
|
+
type: [
|
|
27
|
+
String,
|
|
28
|
+
Number,
|
|
29
|
+
Boolean,
|
|
30
|
+
Array,
|
|
31
|
+
Object
|
|
32
|
+
] as any
|
|
33
|
+
},
|
|
34
|
+
format: {
|
|
35
|
+
type: [
|
|
36
|
+
String,
|
|
37
|
+
Number,
|
|
38
|
+
Boolean,
|
|
39
|
+
Array,
|
|
40
|
+
Object
|
|
41
|
+
] as any
|
|
42
|
+
},
|
|
43
|
+
locale: {
|
|
44
|
+
type: [
|
|
45
|
+
String,
|
|
46
|
+
Number,
|
|
47
|
+
Boolean,
|
|
48
|
+
Array,
|
|
49
|
+
Object
|
|
50
|
+
] as any
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
emits: [
|
|
54
|
+
'countdown-tick',
|
|
55
|
+
'void'
|
|
56
|
+
],
|
|
57
|
+
setup (props, { slots, emit }) {
|
|
58
|
+
const elementRef = ref<HTMLElementClass | null>(null);
|
|
59
|
+
if (false) {
|
|
60
|
+
watch(()=>props.modelValue, (newVal)=>{
|
|
61
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
62
|
+
elementRef.value.value = newVal;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
watch(()=>props.value, (newVal)=>{
|
|
66
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
67
|
+
elementRef.value.value = newVal;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
watch(()=>props.target, (newVal)=>{
|
|
72
|
+
if (elementRef.value && newVal !== undefined) {
|
|
73
|
+
(elementRef.value as any).target = newVal;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
watch(()=>props.duration, (newVal)=>{
|
|
77
|
+
if (elementRef.value && newVal !== undefined) {
|
|
78
|
+
(elementRef.value as any).duration = newVal;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
watch(()=>props.autoStart, (newVal)=>{
|
|
82
|
+
if (elementRef.value && newVal !== undefined) {
|
|
83
|
+
(elementRef.value as any).autoStart = newVal;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
watch(()=>props.format, (newVal)=>{
|
|
87
|
+
if (elementRef.value && newVal !== undefined) {
|
|
88
|
+
(elementRef.value as any).format = newVal;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
watch(()=>props.locale, (newVal)=>{
|
|
92
|
+
if (elementRef.value && newVal !== undefined) {
|
|
93
|
+
(elementRef.value as any).locale = newVal;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return ()=>{
|
|
97
|
+
const eventListeners: Record<string, any> = {};
|
|
98
|
+
eventListeners['onCountdown-tick'] = (event: Event)=>{
|
|
99
|
+
emit('countdown-tick', event);
|
|
100
|
+
};
|
|
101
|
+
eventListeners['onVoid'] = (event: Event)=>{
|
|
102
|
+
emit('void', event);
|
|
103
|
+
};
|
|
104
|
+
const mergedProps = {
|
|
105
|
+
...props,
|
|
106
|
+
...eventListeners,
|
|
107
|
+
ref: elementRef
|
|
108
|
+
};
|
|
109
|
+
if (false && props.modelValue !== undefined) {
|
|
110
|
+
(mergedProps as any).value = props.modelValue;
|
|
111
|
+
}
|
|
112
|
+
return h('uibit-countdown', mergedProps, slots.default?.());
|
|
113
|
+
};
|
|
114
|
+
}
|
|
31
115
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibit/countdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Highly customizable countdown timer. Supports target date markers or set durations, reactive timers, and custom format templates.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"./countdown.css": "./dist/countdown.css",
|
|
14
14
|
"./custom-elements.json": "./custom-elements.json",
|
|
15
|
-
"./react": "./dist/frameworks/react/index.
|
|
15
|
+
"./react": "./dist/frameworks/react/index.ts",
|
|
16
16
|
"./vue": "./dist/frameworks/vue/index.ts",
|
|
17
17
|
"./svelte": "./dist/frameworks/svelte/index.svelte",
|
|
18
18
|
"./angular": "./dist/frameworks/angular/index.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/node": "^20.19.43",
|
|
52
52
|
"lit": "^3.3.3",
|
|
53
53
|
"typescript": "7.0.2",
|
|
54
|
-
"@uibit/codegen": "0.
|
|
54
|
+
"@uibit/codegen": "0.2.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"lit": "^3.0.0",
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
locale?: string;
|
|
17
|
-
onCountdownTick?: (event: any) => void;
|
|
18
|
-
onVoid?: (event: any) => void;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|