@uibit/read-time 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 +1 -1
- package/dist/frameworks/angular/index.ts +26 -24
- package/dist/frameworks/astro/index.d.ts +6 -1
- package/dist/frameworks/preact/index.d.ts +1 -0
- package/dist/frameworks/react/index.ts +72 -0
- package/dist/frameworks/stencil/index.d.ts +1 -0
- package/dist/frameworks/svelte/index.svelte +46 -17
- package/dist/frameworks/vue/index.ts +74 -20
- package/dist/read-time.d.ts.map +1 -1
- package/dist/read-time.js +8 -4
- package/dist/read-time.js.map +1 -1
- package/package.json +3 -3
- package/dist/frameworks/react/index.d.ts +0 -19
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@uibit/read-time)
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
[Interactive Demonstration](https://rawlings.github.io/uibit/
|
|
6
|
+
[Interactive Demonstration](https://rawlings.github.io/uibit/components/read-time)
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import { Component, ChangeDetectionStrategy, ElementRef, input, effect, booleanAttribute, numberAttribute } from '@angular/core';
|
|
2
2
|
import '@uibit/read-time';
|
|
3
3
|
import type { ReadTime as HTMLElementClass } from '@uibit/read-time';
|
|
4
|
-
|
|
5
4
|
@Component({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
selector: 'uibit-read-time',
|
|
6
|
+
template: '<ng-content></ng-content>',
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
standalone: true
|
|
10
9
|
})
|
|
11
10
|
export class NgxReadTime {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
constructor(private el: ElementRef<HTMLElementClass>){
|
|
12
|
+
effect(()=>{
|
|
13
|
+
if (this.el.nativeElement) {
|
|
14
|
+
this.el.nativeElement.wpm = this.wpm();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
effect(()=>{
|
|
18
|
+
if (this.el.nativeElement) {
|
|
19
|
+
this.el.nativeElement.showIcon = this.showIcon();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
effect(()=>{
|
|
23
|
+
if (this.el.nativeElement) {
|
|
24
|
+
this.el.nativeElement.locale = this.locale();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
readonly wpm = input<number, any>(238, {
|
|
29
|
+
transform: numberAttribute
|
|
17
30
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.el.nativeElement.showIcon = this.showIcon();
|
|
21
|
-
}
|
|
31
|
+
readonly showIcon = input<boolean, any>(true, {
|
|
32
|
+
transform: booleanAttribute
|
|
22
33
|
});
|
|
23
|
-
|
|
24
|
-
if (this.el.nativeElement) {
|
|
25
|
-
this.el.nativeElement.locale = this.locale();
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
readonly wpm = input<number, any>(238, { transform: numberAttribute });
|
|
31
|
-
readonly showIcon = input<boolean, any>(true, { transform: booleanAttribute });
|
|
32
|
-
readonly locale = input<string, any>('');
|
|
34
|
+
readonly locale = input<string>('');
|
|
33
35
|
}
|
|
@@ -4,7 +4,12 @@ import '@uibit/read-time';
|
|
|
4
4
|
declare global {
|
|
5
5
|
namespace astroHTML.JSX {
|
|
6
6
|
interface IntrinsicElements {
|
|
7
|
-
'uibit-read-time': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes
|
|
7
|
+
'uibit-read-time': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
|
|
8
|
+
wpm?: number;
|
|
9
|
+
showIcon?: boolean;
|
|
10
|
+
locale?: string;
|
|
11
|
+
|
|
12
|
+
};
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
15
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
2
|
+
import type { ReadTime as HTMLElementClass } from '@uibit/read-time';
|
|
3
|
+
import '@uibit/read-time';
|
|
4
|
+
const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
5
|
+
export interface ReadTimeProps extends Omit<React.HTMLAttributes<HTMLElementClass>, 'wpm' | 'showIcon' | 'locale'> {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
wpm?: number;
|
|
8
|
+
showIcon?: boolean;
|
|
9
|
+
locale?: string;
|
|
10
|
+
}
|
|
11
|
+
export const ReadTime = ({ ref, children, ...props }: ReadTimeProps & {
|
|
12
|
+
ref?: React.Ref<HTMLElementClass>;
|
|
13
|
+
})=>{
|
|
14
|
+
const innerRef = useRef<HTMLElementClass>(null);
|
|
15
|
+
const propsRef = useRef(props);
|
|
16
|
+
propsRef.current = props;
|
|
17
|
+
useImperativeHandle(ref, ()=>innerRef.current!);
|
|
18
|
+
useTypeOfLayoutEffect(()=>{
|
|
19
|
+
const element = innerRef.current;
|
|
20
|
+
if (element && props.wpm !== undefined) {
|
|
21
|
+
(element as any).wpm = props.wpm;
|
|
22
|
+
}
|
|
23
|
+
}, [
|
|
24
|
+
props.wpm
|
|
25
|
+
]);
|
|
26
|
+
useTypeOfLayoutEffect(()=>{
|
|
27
|
+
const element = innerRef.current;
|
|
28
|
+
if (element && props.showIcon !== undefined) {
|
|
29
|
+
(element as any).showIcon = props.showIcon;
|
|
30
|
+
}
|
|
31
|
+
}, [
|
|
32
|
+
props.showIcon
|
|
33
|
+
]);
|
|
34
|
+
useTypeOfLayoutEffect(()=>{
|
|
35
|
+
const element = innerRef.current;
|
|
36
|
+
if (element && props.locale !== undefined) {
|
|
37
|
+
(element as any).locale = props.locale;
|
|
38
|
+
}
|
|
39
|
+
}, [
|
|
40
|
+
props.locale
|
|
41
|
+
]);
|
|
42
|
+
const domProps = {
|
|
43
|
+
...props
|
|
44
|
+
};
|
|
45
|
+
const customPropNames = [
|
|
46
|
+
'wpm',
|
|
47
|
+
'showIcon',
|
|
48
|
+
'locale'
|
|
49
|
+
];
|
|
50
|
+
for (const key of customPropNames){
|
|
51
|
+
delete (domProps as any)[key];
|
|
52
|
+
}
|
|
53
|
+
return React.createElement('uibit-read-time', {
|
|
54
|
+
ref: innerRef,
|
|
55
|
+
...domProps
|
|
56
|
+
}, children);
|
|
57
|
+
};
|
|
58
|
+
declare global {
|
|
59
|
+
namespace React {
|
|
60
|
+
namespace JSX {
|
|
61
|
+
interface IntrinsicElements {
|
|
62
|
+
'uibit-read-time': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
|
|
63
|
+
children?: React.ReactNode;
|
|
64
|
+
class?: string;
|
|
65
|
+
wpm?: number;
|
|
66
|
+
showIcon?: boolean;
|
|
67
|
+
locale?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,38 +1,67 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import '@uibit/read-time';
|
|
3
3
|
import type { ReadTime as HTMLElementClass } from '@uibit/read-time';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
wpm =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
wpm = $bindable(),
|
|
7
|
+
showIcon = $bindable(),
|
|
8
|
+
locale = $bindable(),
|
|
9
|
+
timer = undefined,
|
|
10
|
+
children,
|
|
11
|
+
...restProps
|
|
11
12
|
} = $props<{
|
|
12
|
-
children?:
|
|
13
|
+
children?: import('svelte').Snippet;
|
|
13
14
|
wpm?: number;
|
|
14
15
|
showIcon?: boolean;
|
|
15
16
|
locale?: string;
|
|
16
17
|
timer?: import('svelte').Snippet;
|
|
18
|
+
[key: string]: any;
|
|
17
19
|
}>();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (elementRef && wpm !== undefined) {
|
|
20
|
+
|
|
21
|
+
let elementRef: HTMLElementClass | null = $state(null);
|
|
22
|
+
|
|
23
|
+
$effect(() => {
|
|
24
|
+
if (elementRef && wpm !== undefined && elementRef.wpm !== wpm) {
|
|
23
25
|
elementRef.wpm = wpm;
|
|
24
26
|
}
|
|
25
|
-
if (elementRef && showIcon !== undefined) {
|
|
27
|
+
if (elementRef && showIcon !== undefined && elementRef.showIcon !== showIcon) {
|
|
26
28
|
elementRef.showIcon = showIcon;
|
|
27
29
|
}
|
|
28
|
-
if (elementRef && locale !== undefined) {
|
|
30
|
+
if (elementRef && locale !== undefined && elementRef.locale !== locale) {
|
|
29
31
|
elementRef.locale = locale;
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
|
-
|
|
34
|
+
|
|
35
|
+
$effect(() => {
|
|
36
|
+
const element = elementRef;
|
|
37
|
+
if (!element) return;
|
|
38
|
+
|
|
39
|
+
const handleEvent = () => {
|
|
40
|
+
if (wpm !== element.wpm) {
|
|
41
|
+
wpm = element.wpm as any;
|
|
42
|
+
}
|
|
43
|
+
if (showIcon !== element.showIcon) {
|
|
44
|
+
showIcon = element.showIcon as any;
|
|
45
|
+
}
|
|
46
|
+
if (locale !== element.locale) {
|
|
47
|
+
locale = element.locale as any;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const events = ['change', 'input'];
|
|
52
|
+
for (const event of events) {
|
|
53
|
+
element.addEventListener(event, handleEvent);
|
|
54
|
+
}
|
|
55
|
+
return () => {
|
|
56
|
+
for (const event of events) {
|
|
57
|
+
element.removeEventListener(event, handleEvent);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
33
62
|
</script>
|
|
34
63
|
|
|
35
|
-
<uibit-read-time bind:this={elementRef} {
|
|
64
|
+
<uibit-read-time bind:this={elementRef} {...restProps}>
|
|
36
65
|
{#if timer}
|
|
37
66
|
<div slot="timer">
|
|
38
67
|
{@render timer()}
|
|
@@ -1,24 +1,78 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue';
|
|
1
|
+
import { defineComponent, h, ref, watch } from 'vue';
|
|
2
2
|
import type { ReadTime as HTMLElementClass } from '@uibit/read-time';
|
|
3
3
|
import '@uibit/read-time';
|
|
4
|
-
|
|
5
4
|
export const ReadTime = defineComponent({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
name: 'ReadTime',
|
|
6
|
+
props: {
|
|
7
|
+
wpm: {
|
|
8
|
+
type: [
|
|
9
|
+
String,
|
|
10
|
+
Number,
|
|
11
|
+
Boolean,
|
|
12
|
+
Array,
|
|
13
|
+
Object
|
|
14
|
+
] as any
|
|
15
|
+
},
|
|
16
|
+
showIcon: {
|
|
17
|
+
type: [
|
|
18
|
+
String,
|
|
19
|
+
Number,
|
|
20
|
+
Boolean,
|
|
21
|
+
Array,
|
|
22
|
+
Object
|
|
23
|
+
] as any
|
|
24
|
+
},
|
|
25
|
+
locale: {
|
|
26
|
+
type: [
|
|
27
|
+
String,
|
|
28
|
+
Number,
|
|
29
|
+
Boolean,
|
|
30
|
+
Array,
|
|
31
|
+
Object
|
|
32
|
+
] as any
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
emits: [],
|
|
36
|
+
setup (props, { slots, emit }) {
|
|
37
|
+
const elementRef = ref<HTMLElementClass | null>(null);
|
|
38
|
+
if (false) {
|
|
39
|
+
watch(()=>props.modelValue, (newVal)=>{
|
|
40
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
41
|
+
elementRef.value.value = newVal;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
watch(()=>props.value, (newVal)=>{
|
|
45
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
46
|
+
elementRef.value.value = newVal;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
watch(()=>props.wpm, (newVal)=>{
|
|
51
|
+
if (elementRef.value && newVal !== undefined) {
|
|
52
|
+
(elementRef.value as any).wpm = newVal;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
watch(()=>props.showIcon, (newVal)=>{
|
|
56
|
+
if (elementRef.value && newVal !== undefined) {
|
|
57
|
+
(elementRef.value as any).showIcon = newVal;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
watch(()=>props.locale, (newVal)=>{
|
|
61
|
+
if (elementRef.value && newVal !== undefined) {
|
|
62
|
+
(elementRef.value as any).locale = newVal;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return ()=>{
|
|
66
|
+
const eventListeners: Record<string, any> = {};
|
|
67
|
+
const mergedProps = {
|
|
68
|
+
...props,
|
|
69
|
+
...eventListeners,
|
|
70
|
+
ref: elementRef
|
|
71
|
+
};
|
|
72
|
+
if (false && props.modelValue !== undefined) {
|
|
73
|
+
(mergedProps as any).value = props.modelValue;
|
|
74
|
+
}
|
|
75
|
+
return h('uibit-read-time', mergedProps, slots.default?.());
|
|
76
|
+
};
|
|
77
|
+
}
|
|
24
78
|
});
|
package/dist/read-time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-time.d.ts","sourceRoot":"","sources":["../src/read-time.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,YAAY,EAAY,MAAM,aAAa,CAAC;AAKzF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,QAAS,SAAQ,YAAY;IACxC,MAAM,CAAC,MAAM,0BAAU;IAEvB,iDAAiD;IACH,GAAG,SAAO;IACxD,4CAA4C;IACS,QAAQ,UAAQ;IAE5D,OAAO,CAAC,MAAM,CAAM;IAE7B,OAAO,CAAC,KAAK,CAAC,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,YAAY,
|
|
1
|
+
{"version":3,"file":"read-time.d.ts","sourceRoot":"","sources":["../src/read-time.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,YAAY,EAAY,MAAM,aAAa,CAAC;AAKzF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,QAAS,SAAQ,YAAY;IACxC,MAAM,CAAC,MAAM,0BAAU;IAEvB,iDAAiD;IACH,GAAG,SAAO;IACxD,4CAA4C;IACS,QAAQ,UAAQ;IAE5D,OAAO,CAAC,MAAM,CAAM;IAE7B,OAAO,CAAC,KAAK,CAAC,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,YAAY,SAOX;IAED,OAAO,CAAC,UAAU;IA+ClB,OAAO,CAAC,YAAY;IAkBpB,MAAM,oCAUL;CACF;eAEc,QAAQ"}
|
package/dist/read-time.js
CHANGED
|
@@ -44,7 +44,6 @@ let ReadTime = class ReadTime extends UIBitElement {
|
|
|
44
44
|
this._slot = this.shadowRoot?.querySelector('slot:not([name])');
|
|
45
45
|
this._slot?.addEventListener('slotchange', () => this._calculate());
|
|
46
46
|
this._timerSlot = this.shadowRoot?.querySelector('slot[name="timer"]');
|
|
47
|
-
this._timerSlot?.addEventListener('slotchange', () => this._calculate());
|
|
48
47
|
this._calculate();
|
|
49
48
|
}
|
|
50
49
|
_calculate() {
|
|
@@ -62,7 +61,7 @@ let ReadTime = class ReadTime extends UIBitElement {
|
|
|
62
61
|
this._label = defaultLabel;
|
|
63
62
|
// Update any slotted elements inside slot="timer"
|
|
64
63
|
if (this._timerSlot) {
|
|
65
|
-
const assignedTimer = this._timerSlot.assignedElements(
|
|
64
|
+
const assignedTimer = this._timerSlot.assignedElements();
|
|
66
65
|
for (const el of assignedTimer) {
|
|
67
66
|
let template = el.getAttribute('data-template');
|
|
68
67
|
if (template === null) {
|
|
@@ -77,10 +76,15 @@ let ReadTime = class ReadTime extends UIBitElement {
|
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
if (template) {
|
|
80
|
-
|
|
79
|
+
const newText = template.replace('{time}', timeStr);
|
|
80
|
+
if (el.textContent !== newText) {
|
|
81
|
+
el.textContent = newText;
|
|
82
|
+
}
|
|
81
83
|
}
|
|
82
84
|
else if (!el.textContent || el.textContent.trim() === '' || el.hasAttribute('data-auto-update')) {
|
|
83
|
-
el.textContent
|
|
85
|
+
if (el.textContent !== this._label) {
|
|
86
|
+
el.textContent = this._label;
|
|
87
|
+
}
|
|
84
88
|
el.setAttribute('data-auto-update', '');
|
|
85
89
|
}
|
|
86
90
|
}
|
package/dist/read-time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-time.js","sourceRoot":"","sources":["../src/read-time.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,YAAY;IAAnC;;QAGL,iDAAiD;QACH,QAAG,GAAG,GAAG,CAAC;QACxD,4CAA4C;QACS,aAAQ,GAAG,IAAI,CAAC;QAEpD,WAAM,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"read-time.js","sourceRoot":"","sources":["../src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KAAK,CAAC,UAAU,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;YACzE,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9C,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;YAGH,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA,kCAAkC,OAAO,CAAC,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;6CAC1E,IAAI,CAAC,MAAM;;;;KAInD,CAAC;IACJ,CAAC;CACF,CAAA;AA9F+C;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qCAAW;AAEH;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;0CAAiB;AAEpD;IAAhB,KAAK,EAAE;wCAAqB;AARlB,QAAQ;IADpB,aAAa,CAAC,iBAAiB,CAAC;GACpB,QAAQ,CAkGpB;;AAED,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibit/read-time",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Text-analyzer badge that scans the word count of its slotted content and outputs an estimated reading time string. No backend metadata required — works directly in any CMS template.",
|
|
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.
|
|
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.
|
|
55
|
+
"@uibit/codegen": "0.2.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"lit": "^3.0.0",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes, ClassAttributes } from 'react';
|
|
2
|
-
import type { ReadTime as HTMLElementClass } from '@uibit/read-time';
|
|
3
|
-
import '@uibit/read-time';
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
namespace React {
|
|
7
|
-
namespace JSX {
|
|
8
|
-
interface IntrinsicElements {
|
|
9
|
-
'uibit-read-time': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
class?: string;
|
|
12
|
-
wpm?: number;
|
|
13
|
-
showIcon?: boolean;
|
|
14
|
-
locale?: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|