@uibit/number-increment 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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![NPM Version](https://img.shields.io/npm/v/@uibit/number-increment.svg?style=flat-square&color=black)](https://www.npmjs.com/package/@uibit/number-increment)
4
4
 
5
5
 
6
- [Interactive Demonstration](https://rawlings.github.io/uibit/number-ticker)
6
+ [Interactive Demonstration](https://rawlings.github.io/uibit/components/number-increment)
7
7
 
8
8
  ## Installation
9
9
 
@@ -1,80 +1,89 @@
1
- import { Component, ChangeDetectionStrategy, ElementRef, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
1
+ import { Component, ChangeDetectionStrategy, ElementRef, model, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
2
2
  import '@uibit/number-increment';
3
3
  import type { NumberIncrement as HTMLElementClass } from '@uibit/number-increment';
4
-
5
4
  @Component({
6
- selector: 'uibit-number-increment',
7
- template: '<ng-content></ng-content>',
8
- changeDetection: ChangeDetectionStrategy.OnPush,
9
- standalone: true,
10
- host: {
11
- '(void)': 'void.emit($event)'
12
- }
5
+ selector: 'uibit-number-increment',
6
+ template: '<ng-content></ng-content>',
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ standalone: true,
9
+ host: {
10
+ '(void)': 'void.emit($event)'
11
+ }
13
12
  })
14
13
  export class NgxNumberIncrement {
15
- constructor(private el: ElementRef<HTMLElementClass>) {
16
- effect(() => {
17
- if (this.el.nativeElement) {
18
- this.el.nativeElement.value = this.value();
19
- }
14
+ constructor(private el: ElementRef<HTMLElementClass>){
15
+ effect(()=>{
16
+ if (this.el.nativeElement) {
17
+ this.el.nativeElement.value = this.value();
18
+ }
19
+ });
20
+ effect(()=>{
21
+ if (this.el.nativeElement) {
22
+ this.el.nativeElement.from = this.from();
23
+ }
24
+ });
25
+ effect(()=>{
26
+ if (this.el.nativeElement) {
27
+ this.el.nativeElement.duration = this.duration();
28
+ }
29
+ });
30
+ effect(()=>{
31
+ if (this.el.nativeElement) {
32
+ this.el.nativeElement.decimals = this.decimals();
33
+ }
34
+ });
35
+ effect(()=>{
36
+ if (this.el.nativeElement) {
37
+ this.el.nativeElement.options = this.options();
38
+ }
39
+ });
40
+ effect(()=>{
41
+ if (this.el.nativeElement) {
42
+ this.el.nativeElement.formatter = this.formatter();
43
+ }
44
+ });
45
+ effect(()=>{
46
+ if (this.el.nativeElement) {
47
+ this.el.nativeElement.easing = this.easing();
48
+ }
49
+ });
50
+ effect(()=>{
51
+ if (this.el.nativeElement) {
52
+ this.el.nativeElement.threshold = this.threshold();
53
+ }
54
+ });
55
+ effect(()=>{
56
+ if (this.el.nativeElement) {
57
+ this.el.nativeElement.repeat = this.repeat();
58
+ }
59
+ });
60
+ effect(()=>{
61
+ if (this.el.nativeElement) {
62
+ this.el.nativeElement.locale = this.locale();
63
+ }
64
+ });
65
+ }
66
+ readonly value = model<number>(0);
67
+ readonly from = input<number, any>(0, {
68
+ transform: numberAttribute
20
69
  });
21
- effect(() => {
22
- if (this.el.nativeElement) {
23
- this.el.nativeElement.from = this.from();
24
- }
70
+ readonly duration = input<number, any>(1800, {
71
+ transform: numberAttribute
25
72
  });
26
- effect(() => {
27
- if (this.el.nativeElement) {
28
- this.el.nativeElement.duration = this.duration();
29
- }
73
+ readonly decimals = input<number, any>(0, {
74
+ transform: numberAttribute
30
75
  });
31
- effect(() => {
32
- if (this.el.nativeElement) {
33
- this.el.nativeElement.decimals = this.decimals();
34
- }
76
+ readonly options = input<Intl.NumberFormatOptions | undefined>(undefined);
77
+ readonly formatter = input<(value: number) => string | undefined, any>(undefined, {
78
+ transform: numberAttribute
35
79
  });
36
- effect(() => {
37
- if (this.el.nativeElement) {
38
- this.el.nativeElement.options = this.options();
39
- }
80
+ readonly easing = input<'ease-out' | 'ease-in-out' | 'linear'>('ease-out');
81
+ readonly threshold = input<number, any>(0.2, {
82
+ transform: numberAttribute
40
83
  });
41
- effect(() => {
42
- if (this.el.nativeElement) {
43
- this.el.nativeElement.formatter = this.formatter();
44
- }
84
+ readonly repeat = input<boolean, any>(false, {
85
+ transform: booleanAttribute
45
86
  });
46
- effect(() => {
47
- if (this.el.nativeElement) {
48
- this.el.nativeElement.easing = this.easing();
49
- }
50
- });
51
- effect(() => {
52
- if (this.el.nativeElement) {
53
- this.el.nativeElement.threshold = this.threshold();
54
- }
55
- });
56
- effect(() => {
57
- if (this.el.nativeElement) {
58
- this.el.nativeElement.repeat = this.repeat();
59
- }
60
- });
61
- effect(() => {
62
- if (this.el.nativeElement) {
63
- this.el.nativeElement.locale = this.locale();
64
- }
65
- });
66
- }
67
-
68
- readonly value = input<number, any>(0, { transform: numberAttribute });
69
- readonly from = input<number, any>(0, { transform: numberAttribute });
70
- readonly duration = input<number, any>(1800, { transform: numberAttribute });
71
- readonly decimals = input<number, any>(0, { transform: numberAttribute });
72
- readonly options = input<Intl.NumberFormatOptions | undefined, any>(undefined);
73
- readonly formatter = input<(value: number) => string | undefined, any>(0, { transform: numberAttribute });
74
- readonly easing = input<'ease-out' | 'ease-in-out' | 'linear', any>('ease-out');
75
- readonly threshold = input<number, any>(0.2, { transform: numberAttribute });
76
- readonly repeat = input<boolean, any>(false, { transform: booleanAttribute });
77
- readonly locale = input<string, any>('');
78
-
79
- readonly void = output<CustomEvent<any>>();
87
+ readonly locale = input<string>('');
88
+ readonly void = output<CustomEvent<any>>();
80
89
  }
@@ -4,7 +4,19 @@ import '@uibit/number-increment';
4
4
  declare global {
5
5
  namespace astroHTML.JSX {
6
6
  interface IntrinsicElements {
7
- 'uibit-number-increment': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes;
7
+ 'uibit-number-increment': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
8
+ value?: number;
9
+ from?: number;
10
+ duration?: number;
11
+ decimals?: number;
12
+ options?: Intl.NumberFormatOptions | undefined;
13
+ formatter?: (value: number) => string | undefined;
14
+ easing?: 'ease-out' | 'ease-in-out' | 'linear';
15
+ threshold?: number;
16
+ repeat?: boolean;
17
+ locale?: string;
18
+ "on:void"?: (event: Event) => void;
19
+ };
8
20
  }
9
21
  }
10
22
  }
@@ -16,6 +16,8 @@ declare module 'preact' {
16
16
  threshold?: number;
17
17
  repeat?: boolean;
18
18
  locale?: string;
19
+ onVoid?: (event: Event) => void;
20
+ "on:void"?: (event: Event) => void;
19
21
  };
20
22
  }
21
23
  }
@@ -0,0 +1,165 @@
1
+ import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
2
+ import type { NumberIncrement as HTMLElementClass } from '@uibit/number-increment';
3
+ import '@uibit/number-increment';
4
+ const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
5
+ export interface NumberIncrementProps extends Omit<React.HTMLAttributes<HTMLElementClass>, 'value' | 'from' | 'duration' | 'decimals' | 'options' | 'formatter' | 'easing' | 'threshold' | 'repeat' | 'locale' | 'onVoid'> {
6
+ children?: React.ReactNode;
7
+ value?: number;
8
+ from?: number;
9
+ duration?: number;
10
+ decimals?: number;
11
+ options?: Intl.NumberFormatOptions | undefined;
12
+ formatter?: (value: number) => string | undefined;
13
+ easing?: 'ease-out' | 'ease-in-out' | 'linear';
14
+ threshold?: number;
15
+ repeat?: boolean;
16
+ locale?: string;
17
+ onVoid?: (event: Event) => void;
18
+ }
19
+ export const NumberIncrement = ({ ref, children, ...props }: NumberIncrementProps & {
20
+ ref?: React.Ref<HTMLElementClass>;
21
+ })=>{
22
+ const innerRef = useRef<HTMLElementClass>(null);
23
+ const propsRef = useRef(props);
24
+ propsRef.current = props;
25
+ useImperativeHandle(ref, ()=>innerRef.current!);
26
+ useTypeOfLayoutEffect(()=>{
27
+ const element = innerRef.current;
28
+ if (element && props.value !== undefined) {
29
+ (element as any).value = props.value;
30
+ }
31
+ }, [
32
+ props.value
33
+ ]);
34
+ useTypeOfLayoutEffect(()=>{
35
+ const element = innerRef.current;
36
+ if (element && props.from !== undefined) {
37
+ (element as any).from = props.from;
38
+ }
39
+ }, [
40
+ props.from
41
+ ]);
42
+ useTypeOfLayoutEffect(()=>{
43
+ const element = innerRef.current;
44
+ if (element && props.duration !== undefined) {
45
+ (element as any).duration = props.duration;
46
+ }
47
+ }, [
48
+ props.duration
49
+ ]);
50
+ useTypeOfLayoutEffect(()=>{
51
+ const element = innerRef.current;
52
+ if (element && props.decimals !== undefined) {
53
+ (element as any).decimals = props.decimals;
54
+ }
55
+ }, [
56
+ props.decimals
57
+ ]);
58
+ useTypeOfLayoutEffect(()=>{
59
+ const element = innerRef.current;
60
+ if (element && props.options !== undefined) {
61
+ (element as any).options = props.options;
62
+ }
63
+ }, [
64
+ props.options
65
+ ]);
66
+ useTypeOfLayoutEffect(()=>{
67
+ const element = innerRef.current;
68
+ if (element && props.formatter !== undefined) {
69
+ (element as any).formatter = props.formatter;
70
+ }
71
+ }, [
72
+ props.formatter
73
+ ]);
74
+ useTypeOfLayoutEffect(()=>{
75
+ const element = innerRef.current;
76
+ if (element && props.easing !== undefined) {
77
+ (element as any).easing = props.easing;
78
+ }
79
+ }, [
80
+ props.easing
81
+ ]);
82
+ useTypeOfLayoutEffect(()=>{
83
+ const element = innerRef.current;
84
+ if (element && props.threshold !== undefined) {
85
+ (element as any).threshold = props.threshold;
86
+ }
87
+ }, [
88
+ props.threshold
89
+ ]);
90
+ useTypeOfLayoutEffect(()=>{
91
+ const element = innerRef.current;
92
+ if (element && props.repeat !== undefined) {
93
+ (element as any).repeat = props.repeat;
94
+ }
95
+ }, [
96
+ props.repeat
97
+ ]);
98
+ useTypeOfLayoutEffect(()=>{
99
+ const element = innerRef.current;
100
+ if (element && props.locale !== undefined) {
101
+ (element as any).locale = props.locale;
102
+ }
103
+ }, [
104
+ props.locale
105
+ ]);
106
+ useTypeOfLayoutEffect(()=>{
107
+ const element = innerRef.current;
108
+ if (!element) return;
109
+ const handleEvent = (event: Event)=>{
110
+ if (propsRef.current.onVoid) {
111
+ propsRef.current.onVoid(event as any);
112
+ }
113
+ };
114
+ element.addEventListener('void', handleEvent);
115
+ return ()=>{
116
+ element.removeEventListener('void', handleEvent);
117
+ };
118
+ }, []);
119
+ const domProps = {
120
+ ...props
121
+ };
122
+ const customPropNames = [
123
+ 'value',
124
+ 'from',
125
+ 'duration',
126
+ 'decimals',
127
+ 'options',
128
+ 'formatter',
129
+ 'easing',
130
+ 'threshold',
131
+ 'repeat',
132
+ 'locale',
133
+ 'onVoid'
134
+ ];
135
+ for (const key of customPropNames){
136
+ delete (domProps as any)[key];
137
+ }
138
+ return React.createElement('uibit-number-increment', {
139
+ ref: innerRef,
140
+ ...domProps
141
+ }, children);
142
+ };
143
+ declare global {
144
+ namespace React {
145
+ namespace JSX {
146
+ interface IntrinsicElements {
147
+ 'uibit-number-increment': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
148
+ children?: React.ReactNode;
149
+ class?: string;
150
+ value?: number;
151
+ from?: number;
152
+ duration?: number;
153
+ decimals?: number;
154
+ options?: Intl.NumberFormatOptions | undefined;
155
+ formatter?: (value: number) => string | undefined;
156
+ easing?: 'ease-out' | 'ease-in-out' | 'linear';
157
+ threshold?: number;
158
+ repeat?: boolean;
159
+ locale?: string;
160
+ onVoid?: (event: CustomEvent<any>) => void;
161
+ };
162
+ }
163
+ }
164
+ }
165
+ }
@@ -16,7 +16,7 @@ declare module 'solid-js' {
16
16
  threshold?: number;
17
17
  repeat?: boolean;
18
18
  locale?: string;
19
- "on:void"?: (event: CustomEvent) => void;
19
+ "on:void"?: (event: Event) => void;
20
20
  };
21
21
  }
22
22
  }
@@ -15,6 +15,8 @@ declare module '@stencil/core' {
15
15
  threshold?: number;
16
16
  repeat?: boolean;
17
17
  locale?: string;
18
+ onVoid?: (event: Event) => void;
19
+ "on:void"?: (event: Event) => void;
18
20
  };
19
21
  }
20
22
  }
@@ -1,21 +1,22 @@
1
1
  <script lang="ts">
2
2
  import '@uibit/number-increment';
3
3
  import type { NumberIncrement as HTMLElementClass } from '@uibit/number-increment';
4
-
5
- let {
6
- value = undefined,
7
- from = undefined,
8
- duration = undefined,
9
- decimals = undefined,
10
- options = undefined,
11
- formatter = undefined,
12
- easing = undefined,
13
- threshold = undefined,
14
- repeat = undefined,
15
- locale = undefined,
16
- children
4
+
5
+ let {
6
+ value = $bindable(),
7
+ from = $bindable(),
8
+ duration = $bindable(),
9
+ decimals = $bindable(),
10
+ options = $bindable(),
11
+ formatter = $bindable(),
12
+ easing = $bindable(),
13
+ threshold = $bindable(),
14
+ repeat = $bindable(),
15
+ locale = $bindable(),
16
+ children,
17
+ ...restProps
17
18
  } = $props<{
18
- children?: any;
19
+ children?: import('svelte').Snippet;
19
20
  value?: number;
20
21
  from?: number;
21
22
  duration?: number;
@@ -26,47 +27,96 @@
26
27
  threshold?: number;
27
28
  repeat?: boolean;
28
29
  locale?: string;
29
-
30
+
31
+ [key: string]: any;
30
32
  }>();
31
-
32
- let elementRef: HTMLElementClass | null = $state(null);
33
-
34
- $effect(() => {
35
- if (elementRef && value !== undefined) {
33
+
34
+ let elementRef: HTMLElementClass | null = $state(null);
35
+
36
+ $effect(() => {
37
+ if (elementRef && value !== undefined && elementRef.value !== value) {
36
38
  elementRef.value = value;
37
39
  }
38
- if (elementRef && from !== undefined) {
40
+ if (elementRef && from !== undefined && elementRef.from !== from) {
39
41
  elementRef.from = from;
40
42
  }
41
- if (elementRef && duration !== undefined) {
43
+ if (elementRef && duration !== undefined && elementRef.duration !== duration) {
42
44
  elementRef.duration = duration;
43
45
  }
44
- if (elementRef && decimals !== undefined) {
46
+ if (elementRef && decimals !== undefined && elementRef.decimals !== decimals) {
45
47
  elementRef.decimals = decimals;
46
48
  }
47
- if (elementRef && options !== undefined) {
49
+ if (elementRef && options !== undefined && elementRef.options !== options) {
48
50
  elementRef.options = options;
49
51
  }
50
- if (elementRef && formatter !== undefined) {
52
+ if (elementRef && formatter !== undefined && elementRef.formatter !== formatter) {
51
53
  elementRef.formatter = formatter;
52
54
  }
53
- if (elementRef && easing !== undefined) {
55
+ if (elementRef && easing !== undefined && elementRef.easing !== easing) {
54
56
  elementRef.easing = easing;
55
57
  }
56
- if (elementRef && threshold !== undefined) {
58
+ if (elementRef && threshold !== undefined && elementRef.threshold !== threshold) {
57
59
  elementRef.threshold = threshold;
58
60
  }
59
- if (elementRef && repeat !== undefined) {
61
+ if (elementRef && repeat !== undefined && elementRef.repeat !== repeat) {
60
62
  elementRef.repeat = repeat;
61
63
  }
62
- if (elementRef && locale !== undefined) {
64
+ if (elementRef && locale !== undefined && elementRef.locale !== locale) {
63
65
  elementRef.locale = locale;
64
66
  }
65
67
  });
66
-
68
+
69
+ $effect(() => {
70
+ const element = elementRef;
71
+ if (!element) return;
72
+
73
+ const handleEvent = () => {
74
+ if (value !== element.value) {
75
+ value = element.value as any;
76
+ }
77
+ if (from !== element.from) {
78
+ from = element.from as any;
79
+ }
80
+ if (duration !== element.duration) {
81
+ duration = element.duration as any;
82
+ }
83
+ if (decimals !== element.decimals) {
84
+ decimals = element.decimals as any;
85
+ }
86
+ if (options !== element.options) {
87
+ options = element.options as any;
88
+ }
89
+ if (formatter !== element.formatter) {
90
+ formatter = element.formatter as any;
91
+ }
92
+ if (easing !== element.easing) {
93
+ easing = element.easing as any;
94
+ }
95
+ if (threshold !== element.threshold) {
96
+ threshold = element.threshold as any;
97
+ }
98
+ if (repeat !== element.repeat) {
99
+ repeat = element.repeat as any;
100
+ }
101
+ if (locale !== element.locale) {
102
+ locale = element.locale as any;
103
+ }
104
+ };
105
+
106
+ const events = ['change', 'input', 'void'];
107
+ for (const event of events) {
108
+ element.addEventListener(event, handleEvent);
109
+ }
110
+ return () => {
111
+ for (const event of events) {
112
+ element.removeEventListener(event, handleEvent);
113
+ }
114
+ };
115
+ });
116
+
67
117
  </script>
68
118
 
69
- <uibit-number-increment bind:this={elementRef} {...$$restProps}>
119
+ <uibit-number-increment bind:this={elementRef} {...restProps}>
70
120
 
71
121
  {#if children}
72
122
  {@render children()}
@@ -1,33 +1,176 @@
1
- import { defineComponent, h } from 'vue';
1
+ import { defineComponent, h, ref, watch } from 'vue';
2
2
  import type { NumberIncrement as HTMLElementClass } from '@uibit/number-increment';
3
3
  import '@uibit/number-increment';
4
-
5
4
  export const NumberIncrement = defineComponent({
6
- name: 'NumberIncrement',
7
- props: {
8
- value: { type: [String, Number, Boolean, Array, Object] as any },
9
- from: { type: [String, Number, Boolean, Array, Object] as any },
10
- duration: { type: [String, Number, Boolean, Array, Object] as any },
11
- decimals: { type: [String, Number, Boolean, Array, Object] as any },
12
- options: { type: [String, Number, Boolean, Array, Object] as any },
13
- formatter: { type: [String, Number, Boolean, Array, Object] as any },
14
- easing: { type: [String, Number, Boolean, Array, Object] as any },
15
- threshold: { type: [String, Number, Boolean, Array, Object] as any },
16
- repeat: { type: [String, Number, Boolean, Array, Object] as any },
17
- locale: { type: [String, Number, Boolean, Array, Object] as any }
18
- },
19
- emits: ['void'],
20
- setup(props, { slots, emit }) {
21
- return () => {
22
- const eventListeners: Record<string, any> = {};
23
- eventListeners['onVoid'] = (event: Event) => {
24
- emit('void', event);
25
- };
26
-
27
- return h('uibit-number-increment', {
28
- ...props,
29
- ...eventListeners
30
- }, slots.default?.());
31
- };
32
- }
5
+ name: 'NumberIncrement',
6
+ props: {
7
+ value: {
8
+ type: [
9
+ String,
10
+ Number,
11
+ Boolean,
12
+ Array,
13
+ Object
14
+ ] as any
15
+ },
16
+ from: {
17
+ type: [
18
+ String,
19
+ Number,
20
+ Boolean,
21
+ Array,
22
+ Object
23
+ ] as any
24
+ },
25
+ duration: {
26
+ type: [
27
+ String,
28
+ Number,
29
+ Boolean,
30
+ Array,
31
+ Object
32
+ ] as any
33
+ },
34
+ decimals: {
35
+ type: [
36
+ String,
37
+ Number,
38
+ Boolean,
39
+ Array,
40
+ Object
41
+ ] as any
42
+ },
43
+ options: {
44
+ type: [
45
+ String,
46
+ Number,
47
+ Boolean,
48
+ Array,
49
+ Object
50
+ ] as any
51
+ },
52
+ formatter: {
53
+ type: [
54
+ String,
55
+ Number,
56
+ Boolean,
57
+ Array,
58
+ Object
59
+ ] as any
60
+ },
61
+ easing: {
62
+ type: [
63
+ String,
64
+ Number,
65
+ Boolean,
66
+ Array,
67
+ Object
68
+ ] as any
69
+ },
70
+ threshold: {
71
+ type: [
72
+ String,
73
+ Number,
74
+ Boolean,
75
+ Array,
76
+ Object
77
+ ] as any
78
+ },
79
+ repeat: {
80
+ type: [
81
+ String,
82
+ Number,
83
+ Boolean,
84
+ Array,
85
+ Object
86
+ ] as any
87
+ },
88
+ locale: {
89
+ type: [
90
+ String,
91
+ Number,
92
+ Boolean,
93
+ Array,
94
+ Object
95
+ ] as any
96
+ }
97
+ },
98
+ emits: [
99
+ 'void'
100
+ ],
101
+ setup (props, { slots, emit }) {
102
+ const elementRef = ref<HTMLElementClass | null>(null);
103
+ if (false) {
104
+ watch(()=>props.modelValue, (newVal)=>{
105
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
106
+ elementRef.value.value = newVal;
107
+ }
108
+ });
109
+ watch(()=>props.value, (newVal)=>{
110
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
111
+ elementRef.value.value = newVal;
112
+ }
113
+ });
114
+ }
115
+ watch(()=>props.from, (newVal)=>{
116
+ if (elementRef.value && newVal !== undefined) {
117
+ (elementRef.value as any).from = newVal;
118
+ }
119
+ });
120
+ watch(()=>props.duration, (newVal)=>{
121
+ if (elementRef.value && newVal !== undefined) {
122
+ (elementRef.value as any).duration = newVal;
123
+ }
124
+ });
125
+ watch(()=>props.decimals, (newVal)=>{
126
+ if (elementRef.value && newVal !== undefined) {
127
+ (elementRef.value as any).decimals = newVal;
128
+ }
129
+ });
130
+ watch(()=>props.options, (newVal)=>{
131
+ if (elementRef.value && newVal !== undefined) {
132
+ (elementRef.value as any).options = newVal;
133
+ }
134
+ });
135
+ watch(()=>props.formatter, (newVal)=>{
136
+ if (elementRef.value && newVal !== undefined) {
137
+ (elementRef.value as any).formatter = newVal;
138
+ }
139
+ });
140
+ watch(()=>props.easing, (newVal)=>{
141
+ if (elementRef.value && newVal !== undefined) {
142
+ (elementRef.value as any).easing = newVal;
143
+ }
144
+ });
145
+ watch(()=>props.threshold, (newVal)=>{
146
+ if (elementRef.value && newVal !== undefined) {
147
+ (elementRef.value as any).threshold = newVal;
148
+ }
149
+ });
150
+ watch(()=>props.repeat, (newVal)=>{
151
+ if (elementRef.value && newVal !== undefined) {
152
+ (elementRef.value as any).repeat = newVal;
153
+ }
154
+ });
155
+ watch(()=>props.locale, (newVal)=>{
156
+ if (elementRef.value && newVal !== undefined) {
157
+ (elementRef.value as any).locale = newVal;
158
+ }
159
+ });
160
+ return ()=>{
161
+ const eventListeners: Record<string, any> = {};
162
+ eventListeners['onVoid'] = (event: Event)=>{
163
+ emit('void', event);
164
+ };
165
+ const mergedProps = {
166
+ ...props,
167
+ ...eventListeners,
168
+ ref: elementRef
169
+ };
170
+ if (false && props.modelValue !== undefined) {
171
+ (mergedProps as any).value = props.modelValue;
172
+ }
173
+ return h('uibit-number-increment', mergedProps, slots.default?.());
174
+ };
175
+ }
33
176
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uibit/number-increment",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Intersection-aware numeric counter that animates to a target value with easing curves, locale-aware formatting, and custom formatter function overrides. Triggers once the element scrolls into the viewport.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,7 +11,7 @@
11
11
  "import": "./dist/index.js"
12
12
  },
13
13
  "./custom-elements.json": "./custom-elements.json",
14
- "./react": "./dist/frameworks/react/index.d.ts",
14
+ "./react": "./dist/frameworks/react/index.ts",
15
15
  "./vue": "./dist/frameworks/vue/index.ts",
16
16
  "./svelte": "./dist/frameworks/svelte/index.svelte",
17
17
  "./angular": "./dist/frameworks/angular/index.ts",
@@ -52,7 +52,7 @@
52
52
  "@types/node": "^20.19.43",
53
53
  "lit": "^3.3.3",
54
54
  "typescript": "7.0.2",
55
- "@uibit/codegen": "0.1.0"
55
+ "@uibit/codegen": "0.2.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "lit": "^3.0.0",
@@ -1,27 +0,0 @@
1
- import type { HTMLAttributes, ClassAttributes } from 'react';
2
- import type { NumberIncrement as HTMLElementClass } from '@uibit/number-increment';
3
- import '@uibit/number-increment';
4
-
5
- declare global {
6
- namespace React {
7
- namespace JSX {
8
- interface IntrinsicElements {
9
- 'uibit-number-increment': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
10
- children?: React.ReactNode;
11
- class?: string;
12
- value?: number;
13
- from?: number;
14
- duration?: number;
15
- decimals?: number;
16
- options?: Intl.NumberFormatOptions | undefined;
17
- formatter?: (value: number) => string | undefined;
18
- easing?: 'ease-out' | 'ease-in-out' | 'linear';
19
- threshold?: number;
20
- repeat?: boolean;
21
- locale?: string;
22
- onVoid?: (event: any) => void;
23
- };
24
- }
25
- }
26
- }
27
- }