@uibit/read-time 0.1.0 → 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
@@ -1,6 +1,16 @@
1
1
  # Text Read Timer
2
2
 
3
- [Interactive Demonstration](https://rawlings.github.io/uibit/text-read-timer)
3
+ [![NPM Version](https://img.shields.io/npm/v/@uibit/read-time.svg?style=flat-square&color=black)](https://www.npmjs.com/package/@uibit/read-time)
4
+
5
+
6
+ [Interactive Demonstration](https://rawlings.github.io/uibit/components/read-time)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @uibit/read-time
12
+ ```
13
+
4
14
 
5
15
  Text Read Timer automatically analyzes document length and displays a reading time estimate to users. By calculating read times directly on the client, it helps readers set expectations before committing to long-form articles, improving retention rates and page loyalty.
6
16
 
@@ -39,7 +39,7 @@
39
39
  "declarations": [
40
40
  {
41
41
  "kind": "class",
42
- "description": "Analyzes the word count of its slotted content and renders a reading-time\nbadge. The calculation happens inside the shadow DOM via a slot\nchange observer — no backend metadata required.\n\nPlace your HTML content in the default slot. The component counts only text\nnodes, ignoring markup and hidden elements.",
42
+ "description": "Analyzes the word count of its slotted content and renders a reading-time",
43
43
  "name": "ReadTime",
44
44
  "cssProperties": [
45
45
  {
@@ -156,6 +156,211 @@
156
156
  }
157
157
  }
158
158
  ]
159
+ },
160
+ {
161
+ "kind": "field",
162
+ "name": "locale",
163
+ "type": {
164
+ "text": "string"
165
+ },
166
+ "default": "''",
167
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
168
+ "attribute": "locale",
169
+ "inheritedFrom": {
170
+ "name": "UIBitElement",
171
+ "module": "../../platform/core/src/element.ts"
172
+ }
173
+ },
174
+ {
175
+ "kind": "field",
176
+ "name": "resolvedLocale",
177
+ "type": {
178
+ "text": "string | undefined"
179
+ },
180
+ "description": "Resolves the active locale for formatting and localization.\nChecks the `locale` property first, then traverses up the DOM to find\nthe nearest ancestor with a `lang` attribute, and finally falls back\nto undefined (which defaults to browser locale).",
181
+ "readonly": true,
182
+ "inheritedFrom": {
183
+ "name": "UIBitElement",
184
+ "module": "../../platform/core/src/element.ts"
185
+ }
186
+ },
187
+ {
188
+ "kind": "field",
189
+ "name": "_disposables",
190
+ "type": {
191
+ "text": "Set<() => void>"
192
+ },
193
+ "privacy": "private",
194
+ "default": "new Set()",
195
+ "inheritedFrom": {
196
+ "name": "UIBitElement",
197
+ "module": "../../platform/core/src/element.ts"
198
+ }
199
+ },
200
+ {
201
+ "kind": "method",
202
+ "name": "createProperty",
203
+ "static": true,
204
+ "parameters": [
205
+ {
206
+ "name": "name",
207
+ "type": {
208
+ "text": "PropertyKey"
209
+ }
210
+ },
211
+ {
212
+ "name": "options",
213
+ "optional": true,
214
+ "type": {
215
+ "text": "PropertyDeclaration"
216
+ }
217
+ }
218
+ ],
219
+ "description": "Overrides createProperty to automatically map camelCase property names\nto kebab-case attribute names by default.",
220
+ "inheritedFrom": {
221
+ "name": "UIBitElement",
222
+ "module": "../../platform/core/src/element.ts"
223
+ }
224
+ },
225
+ {
226
+ "kind": "method",
227
+ "name": "finalizeStyles",
228
+ "static": true,
229
+ "return": {
230
+ "type": {
231
+ "text": "Array<any>"
232
+ }
233
+ },
234
+ "parameters": [
235
+ {
236
+ "name": "styles",
237
+ "optional": true,
238
+ "type": {
239
+ "text": "CSSResultGroup"
240
+ }
241
+ }
242
+ ],
243
+ "description": "Automatically prepends basic layout resets (border-box) to the\ncomponent's final styles.",
244
+ "inheritedFrom": {
245
+ "name": "UIBitElement",
246
+ "module": "../../platform/core/src/element.ts"
247
+ }
248
+ },
249
+ {
250
+ "kind": "method",
251
+ "name": "dispatchCustomEvent",
252
+ "return": {
253
+ "type": {
254
+ "text": "boolean"
255
+ }
256
+ },
257
+ "parameters": [
258
+ {
259
+ "name": "name",
260
+ "type": {
261
+ "text": "string"
262
+ }
263
+ },
264
+ {
265
+ "name": "detail",
266
+ "optional": true,
267
+ "type": {
268
+ "text": "T"
269
+ }
270
+ },
271
+ {
272
+ "name": "options",
273
+ "optional": true,
274
+ "type": {
275
+ "text": "Omit<CustomEventInit<T>, 'detail'>"
276
+ }
277
+ }
278
+ ],
279
+ "description": "Helper to dispatch a custom event with standard bubbles and composed options.",
280
+ "inheritedFrom": {
281
+ "name": "UIBitElement",
282
+ "module": "../../platform/core/src/element.ts"
283
+ }
284
+ },
285
+ {
286
+ "kind": "method",
287
+ "name": "getCssPropertyValue",
288
+ "return": {
289
+ "type": {
290
+ "text": "string"
291
+ }
292
+ },
293
+ "parameters": [
294
+ {
295
+ "name": "propertyName",
296
+ "type": {
297
+ "text": "string"
298
+ }
299
+ }
300
+ ],
301
+ "description": "Helper to retrieve a computed CSS custom property value from the element.",
302
+ "inheritedFrom": {
303
+ "name": "UIBitElement",
304
+ "module": "../../platform/core/src/element.ts"
305
+ }
306
+ },
307
+ {
308
+ "kind": "method",
309
+ "name": "registerDisposable",
310
+ "parameters": [
311
+ {
312
+ "name": "cleanup",
313
+ "type": {
314
+ "text": "() => void"
315
+ }
316
+ }
317
+ ],
318
+ "description": "Register a cleanup function to be executed when the element is disconnected from the DOM.",
319
+ "inheritedFrom": {
320
+ "name": "UIBitElement",
321
+ "module": "../../platform/core/src/element.ts"
322
+ }
323
+ },
324
+ {
325
+ "kind": "method",
326
+ "name": "listen",
327
+ "return": {
328
+ "type": {
329
+ "text": "() => void"
330
+ }
331
+ },
332
+ "parameters": [
333
+ {
334
+ "name": "target",
335
+ "type": {
336
+ "text": "EventTarget"
337
+ }
338
+ },
339
+ {
340
+ "name": "type",
341
+ "type": {
342
+ "text": "K"
343
+ }
344
+ },
345
+ {
346
+ "name": "listener",
347
+ "type": {
348
+ "text": "(this: EventTarget, ev: HTMLElementEventMap[K]) => any"
349
+ }
350
+ },
351
+ {
352
+ "name": "options",
353
+ "optional": true,
354
+ "type": {
355
+ "text": "boolean | AddEventListenerOptions"
356
+ }
357
+ }
358
+ ],
359
+ "description": "Utility to add an event listener that is automatically cleaned up when the element is disconnected.",
360
+ "inheritedFrom": {
361
+ "name": "UIBitElement",
362
+ "module": "../../platform/core/src/element.ts"
363
+ }
159
364
  }
160
365
  ],
161
366
  "attributes": [
@@ -176,12 +381,26 @@
176
381
  "default": "true",
177
382
  "description": "Show the clock icon before the label.",
178
383
  "fieldName": "showIcon"
384
+ },
385
+ {
386
+ "name": "locale",
387
+ "type": {
388
+ "text": "string"
389
+ },
390
+ "default": "''",
391
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
392
+ "fieldName": "locale",
393
+ "inheritedFrom": {
394
+ "name": "UIBitElement",
395
+ "module": "../../platform/core/src/element.ts"
396
+ }
179
397
  }
180
398
  ],
181
399
  "superclass": {
182
400
  "name": "UIBitElement",
183
401
  "package": "@uibit/core"
184
402
  },
403
+ "summary": "A shadow DOM slotted text length reading time estimation indicator.\nbadge. The calculation happens inside the shadow DOM via a slot\nchange observer — no backend metadata required.\n\nPlace your HTML content in the default slot. The component counts only text\nnodes, ignoring markup and hidden elements.",
185
404
  "tagName": "uibit-read-time",
186
405
  "customElement": true
187
406
  }
@@ -239,6 +458,250 @@
239
458
  "path": "src/types.ts",
240
459
  "declarations": [],
241
460
  "exports": []
461
+ },
462
+ {
463
+ "kind": "javascript-module",
464
+ "path": "../../platform/core/src/element.ts",
465
+ "declarations": [
466
+ {
467
+ "kind": "class",
468
+ "description": "A foundational base class for all UIBit web components.\nProvides custom event helpers, default kebab-case attribute mapping,\nautomatic cleanup/disposable tracking, and auto-injected reset styles.",
469
+ "name": "UIBitElement",
470
+ "members": [
471
+ {
472
+ "kind": "field",
473
+ "name": "locale",
474
+ "type": {
475
+ "text": "string"
476
+ },
477
+ "default": "''",
478
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
479
+ "attribute": "locale"
480
+ },
481
+ {
482
+ "kind": "field",
483
+ "name": "resolvedLocale",
484
+ "type": {
485
+ "text": "string | undefined"
486
+ },
487
+ "description": "Resolves the active locale for formatting and localization.\nChecks the `locale` property first, then traverses up the DOM to find\nthe nearest ancestor with a `lang` attribute, and finally falls back\nto undefined (which defaults to browser locale).",
488
+ "readonly": true
489
+ },
490
+ {
491
+ "kind": "field",
492
+ "name": "_disposables",
493
+ "type": {
494
+ "text": "Set<() => void>"
495
+ },
496
+ "privacy": "private",
497
+ "default": "new Set()"
498
+ },
499
+ {
500
+ "kind": "method",
501
+ "name": "createProperty",
502
+ "static": true,
503
+ "parameters": [
504
+ {
505
+ "name": "name",
506
+ "type": {
507
+ "text": "PropertyKey"
508
+ }
509
+ },
510
+ {
511
+ "name": "options",
512
+ "optional": true,
513
+ "type": {
514
+ "text": "PropertyDeclaration"
515
+ }
516
+ }
517
+ ],
518
+ "description": "Overrides createProperty to automatically map camelCase property names\nto kebab-case attribute names by default."
519
+ },
520
+ {
521
+ "kind": "method",
522
+ "name": "finalizeStyles",
523
+ "static": true,
524
+ "return": {
525
+ "type": {
526
+ "text": "Array<any>"
527
+ }
528
+ },
529
+ "parameters": [
530
+ {
531
+ "name": "styles",
532
+ "optional": true,
533
+ "type": {
534
+ "text": "CSSResultGroup"
535
+ }
536
+ }
537
+ ],
538
+ "description": "Automatically prepends basic layout resets (border-box) to the\ncomponent's final styles."
539
+ },
540
+ {
541
+ "kind": "method",
542
+ "name": "dispatchCustomEvent",
543
+ "return": {
544
+ "type": {
545
+ "text": "boolean"
546
+ }
547
+ },
548
+ "parameters": [
549
+ {
550
+ "name": "name",
551
+ "type": {
552
+ "text": "string"
553
+ }
554
+ },
555
+ {
556
+ "name": "detail",
557
+ "optional": true,
558
+ "type": {
559
+ "text": "T"
560
+ }
561
+ },
562
+ {
563
+ "name": "options",
564
+ "optional": true,
565
+ "type": {
566
+ "text": "Omit<CustomEventInit<T>, 'detail'>"
567
+ }
568
+ }
569
+ ],
570
+ "description": "Helper to dispatch a custom event with standard bubbles and composed options."
571
+ },
572
+ {
573
+ "kind": "method",
574
+ "name": "getCssPropertyValue",
575
+ "return": {
576
+ "type": {
577
+ "text": "string"
578
+ }
579
+ },
580
+ "parameters": [
581
+ {
582
+ "name": "propertyName",
583
+ "type": {
584
+ "text": "string"
585
+ }
586
+ }
587
+ ],
588
+ "description": "Helper to retrieve a computed CSS custom property value from the element."
589
+ },
590
+ {
591
+ "kind": "method",
592
+ "name": "registerDisposable",
593
+ "parameters": [
594
+ {
595
+ "name": "cleanup",
596
+ "type": {
597
+ "text": "() => void"
598
+ }
599
+ }
600
+ ],
601
+ "description": "Register a cleanup function to be executed when the element is disconnected from the DOM."
602
+ },
603
+ {
604
+ "kind": "method",
605
+ "name": "listen",
606
+ "return": {
607
+ "type": {
608
+ "text": "() => void"
609
+ }
610
+ },
611
+ "parameters": [
612
+ {
613
+ "name": "target",
614
+ "type": {
615
+ "text": "EventTarget"
616
+ }
617
+ },
618
+ {
619
+ "name": "type",
620
+ "type": {
621
+ "text": "K"
622
+ }
623
+ },
624
+ {
625
+ "name": "listener",
626
+ "type": {
627
+ "text": "(this: EventTarget, ev: HTMLElementEventMap[K]) => any"
628
+ }
629
+ },
630
+ {
631
+ "name": "options",
632
+ "optional": true,
633
+ "type": {
634
+ "text": "boolean | AddEventListenerOptions"
635
+ }
636
+ }
637
+ ],
638
+ "description": "Utility to add an event listener that is automatically cleaned up when the element is disconnected."
639
+ },
640
+ {
641
+ "kind": "method",
642
+ "name": "listen",
643
+ "return": {
644
+ "type": {
645
+ "text": "() => void"
646
+ }
647
+ },
648
+ "parameters": [
649
+ {
650
+ "name": "target",
651
+ "type": {
652
+ "text": "EventTarget"
653
+ }
654
+ },
655
+ {
656
+ "name": "type",
657
+ "type": {
658
+ "text": "string"
659
+ }
660
+ },
661
+ {
662
+ "name": "listener",
663
+ "type": {
664
+ "text": "EventListenerOrEventListenerObject"
665
+ }
666
+ },
667
+ {
668
+ "name": "options",
669
+ "optional": true,
670
+ "type": {
671
+ "text": "boolean | AddEventListenerOptions"
672
+ }
673
+ }
674
+ ]
675
+ }
676
+ ],
677
+ "attributes": [
678
+ {
679
+ "name": "locale",
680
+ "type": {
681
+ "text": "string"
682
+ },
683
+ "default": "''",
684
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
685
+ "fieldName": "locale"
686
+ }
687
+ ],
688
+ "superclass": {
689
+ "name": "LitElement",
690
+ "package": "lit"
691
+ },
692
+ "customElement": true
693
+ }
694
+ ],
695
+ "exports": [
696
+ {
697
+ "kind": "js",
698
+ "name": "UIBitElement",
699
+ "declaration": {
700
+ "name": "UIBitElement",
701
+ "module": "../../platform/core/src/element.ts"
702
+ }
703
+ }
704
+ ]
242
705
  }
243
706
  ]
244
707
  }
@@ -1,27 +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
- selector: 'uibit-read-time',
7
- template: '<ng-content></ng-content>',
8
- changeDetection: ChangeDetectionStrategy.OnPush,
9
- standalone: true
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
- constructor(private el: ElementRef<HTMLElementClass>) {
13
- effect(() => {
14
- if (this.el.nativeElement) {
15
- this.el.nativeElement.wpm = this.wpm();
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
- effect(() => {
19
- if (this.el.nativeElement) {
20
- this.el.nativeElement.showIcon = this.showIcon();
21
- }
31
+ readonly showIcon = input<boolean, any>(true, {
32
+ transform: booleanAttribute
22
33
  });
23
- }
24
-
25
- readonly wpm = input<number, any>(238, { transform: numberAttribute });
26
- readonly showIcon = input<boolean, any>(true, { transform: booleanAttribute });
34
+ readonly locale = input<string>('');
27
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
  }
@@ -8,6 +8,8 @@ declare module 'preact' {
8
8
  'uibit-read-time': JSX.HTMLAttributes<HTMLElementClass> & {
9
9
  wpm?: number;
10
10
  showIcon?: boolean;
11
+ locale?: string;
12
+
11
13
  };
12
14
  }
13
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
+ }
@@ -8,6 +8,7 @@ declare module 'solid-js' {
8
8
  'uibit-read-time': Partial<HTMLElementClass> & JSX.HTMLAttributes<HTMLElementClass> & {
9
9
  wpm?: number;
10
10
  showIcon?: boolean;
11
+ locale?: string;
11
12
 
12
13
  };
13
14
  }
@@ -7,6 +7,8 @@ declare module '@stencil/core' {
7
7
  'uibit-read-time': HTMLElementClass & {
8
8
  wpm?: number;
9
9
  showIcon?: boolean;
10
+ locale?: string;
11
+
10
12
  };
11
13
  }
12
14
  }
@@ -1,33 +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
- let {
6
- wpm = undefined,
7
- showIcon = undefined,
8
- timer = undefined,
9
- children
4
+
5
+ let {
6
+ wpm = $bindable(),
7
+ showIcon = $bindable(),
8
+ locale = $bindable(),
9
+ timer = undefined,
10
+ children,
11
+ ...restProps
10
12
  } = $props<{
11
- children?: any;
13
+ children?: import('svelte').Snippet;
12
14
  wpm?: number;
13
15
  showIcon?: boolean;
16
+ locale?: string;
14
17
  timer?: import('svelte').Snippet;
18
+ [key: string]: any;
15
19
  }>();
16
-
17
- let elementRef: HTMLElementClass | null = $state(null);
18
-
19
- $effect(() => {
20
- if (elementRef && wpm !== undefined) {
20
+
21
+ let elementRef: HTMLElementClass | null = $state(null);
22
+
23
+ $effect(() => {
24
+ if (elementRef && wpm !== undefined && elementRef.wpm !== wpm) {
21
25
  elementRef.wpm = wpm;
22
26
  }
23
- if (elementRef && showIcon !== undefined) {
27
+ if (elementRef && showIcon !== undefined && elementRef.showIcon !== showIcon) {
24
28
  elementRef.showIcon = showIcon;
25
29
  }
30
+ if (elementRef && locale !== undefined && elementRef.locale !== locale) {
31
+ elementRef.locale = locale;
32
+ }
33
+ });
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
+ };
26
60
  });
27
-
61
+
28
62
  </script>
29
63
 
30
- <uibit-read-time bind:this={elementRef} {...$$restProps}>
64
+ <uibit-read-time bind:this={elementRef} {...restProps}>
31
65
  {#if timer}
32
66
  <div slot="timer">
33
67
  {@render timer()}
@@ -1,23 +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
- name: 'ReadTime',
7
- props: {
8
- wpm: { type: [String, Number, Boolean, Array, Object] as any },
9
- showIcon: { type: [String, Number, Boolean, Array, Object] as any }
10
- },
11
- emits: [],
12
- setup(props, { slots, emit }) {
13
- return () => {
14
- const eventListeners: Record<string, any> = {};
15
-
16
-
17
- return h('uibit-read-time', {
18
- ...props,
19
- ...eventListeners
20
- }, slots.default?.());
21
- };
22
- }
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
+ }
23
78
  });
@@ -1,6 +1,8 @@
1
1
  import { UIBitElement } from '@uibit/core';
2
2
  /**
3
3
  * Analyzes the word count of its slotted content and renders a reading-time
4
+
5
+ * @summary A shadow DOM slotted text length reading time estimation indicator.
4
6
  * badge. The calculation happens inside the shadow DOM via a slot
5
7
  * change observer — no backend metadata required.
6
8
  *
@@ -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;;;;;;;;;;;;;;;;;;GAkBG;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,SAQX;IAED,OAAO,CAAC,UAAU;IA0ClB,OAAO,CAAC,YAAY;IAkBpB,MAAM,oCAUL;CACF;eAEc,QAAQ"}
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
@@ -11,6 +11,8 @@ import { property, state } from 'lit/decorators.js';
11
11
  import { styles } from './styles';
12
12
  /**
13
13
  * Analyzes the word count of its slotted content and renders a reading-time
14
+
15
+ * @summary A shadow DOM slotted text length reading time estimation indicator.
14
16
  * badge. The calculation happens inside the shadow DOM via a slot
15
17
  * change observer — no backend metadata required.
16
18
  *
@@ -42,7 +44,6 @@ let ReadTime = class ReadTime extends UIBitElement {
42
44
  this._slot = this.shadowRoot?.querySelector('slot:not([name])');
43
45
  this._slot?.addEventListener('slotchange', () => this._calculate());
44
46
  this._timerSlot = this.shadowRoot?.querySelector('slot[name="timer"]');
45
- this._timerSlot?.addEventListener('slotchange', () => this._calculate());
46
47
  this._calculate();
47
48
  }
48
49
  _calculate() {
@@ -60,7 +61,7 @@ let ReadTime = class ReadTime extends UIBitElement {
60
61
  this._label = defaultLabel;
61
62
  // Update any slotted elements inside slot="timer"
62
63
  if (this._timerSlot) {
63
- const assignedTimer = this._timerSlot.assignedElements({ flatten: true });
64
+ const assignedTimer = this._timerSlot.assignedElements();
64
65
  for (const el of assignedTimer) {
65
66
  let template = el.getAttribute('data-template');
66
67
  if (template === null) {
@@ -75,10 +76,15 @@ let ReadTime = class ReadTime extends UIBitElement {
75
76
  }
76
77
  }
77
78
  if (template) {
78
- el.textContent = template.replace('{time}', timeStr);
79
+ const newText = template.replace('{time}', timeStr);
80
+ if (el.textContent !== newText) {
81
+ el.textContent = newText;
82
+ }
79
83
  }
80
84
  else if (!el.textContent || el.textContent.trim() === '' || el.hasAttribute('data-auto-update')) {
81
- el.textContent = this._label;
85
+ if (el.textContent !== this._label) {
86
+ el.textContent = this._label;
87
+ }
82
88
  el.setAttribute('data-auto-update', '');
83
89
  }
84
90
  }
@@ -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;;;;;;;;;;;;;;;;;;GAkBG;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;IAsF/B,CAAC;aA7FQ,WAAM,GAAG,MAAM,AAAT,CAAU;IAYvB,YAAY;QACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,kBAAkB,CAAoB,CAAC;QACnF,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAEpE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,oBAAoB,CAAoB,CAAC;QAC1F,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,UAAU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AAC,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.1.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.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",
@@ -46,13 +46,13 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "lucide": "^1.24.0",
49
- "@uibit/core": "0.1.0"
49
+ "@uibit/core": "0.2.0"
50
50
  },
51
51
  "devDependencies": {
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",
@@ -83,9 +83,9 @@
83
83
  "tagName": "uibit-read-time"
84
84
  },
85
85
  "scripts": {
86
- "build": "cem analyze --globs 'src/**/*.ts' --litelement && uibit-codegen --package . && tsc",
87
- "dev": "concurrently \"cem analyze --globs 'src/**/*.ts' --litelement --watch\" \"tsc --watch\"",
88
- "analyze": "cem analyze --globs 'src/**/*.ts' --litelement",
86
+ "build": "cem analyze --config ../custom-elements-manifest.config.js && uibit-codegen --package . && tsc",
87
+ "dev": "concurrently \"cem analyze --config ../custom-elements-manifest.config.js --watch\" \"tsc --watch\"",
88
+ "analyze": "cem analyze --config ../custom-elements-manifest.config.js",
89
89
  "typecheck": "tsc --noEmit"
90
90
  }
91
91
  }
@@ -1,18 +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
- };
15
- }
16
- }
17
- }
18
- }