@uibit/read-time 0.1.0 → 0.1.1
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 +10 -0
- package/custom-elements.json +464 -1
- package/dist/frameworks/angular/index.ts +6 -0
- package/dist/frameworks/preact/index.d.ts +1 -0
- package/dist/frameworks/react/index.d.ts +1 -0
- package/dist/frameworks/solid/index.d.ts +1 -0
- package/dist/frameworks/stencil/index.d.ts +1 -0
- package/dist/frameworks/svelte/index.svelte +5 -0
- package/dist/frameworks/vue/index.ts +2 -1
- package/dist/read-time.d.ts +2 -0
- package/dist/read-time.d.ts.map +1 -1
- package/dist/read-time.js +2 -0
- package/dist/read-time.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
# Text Read Timer
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@uibit/read-time)
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
[Interactive Demonstration](https://rawlings.github.io/uibit/text-read-timer)
|
|
4
7
|
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @uibit/read-time
|
|
12
|
+
```
|
|
13
|
+
|
|
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
|
|
|
7
17
|
## Value Delivery
|
package/custom-elements.json
CHANGED
|
@@ -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
|
|
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
|
}
|
|
@@ -20,8 +20,14 @@ export class NgxReadTime {
|
|
|
20
20
|
this.el.nativeElement.showIcon = this.showIcon();
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
effect(() => {
|
|
24
|
+
if (this.el.nativeElement) {
|
|
25
|
+
this.el.nativeElement.locale = this.locale();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
readonly wpm = input<number, any>(238, { transform: numberAttribute });
|
|
26
31
|
readonly showIcon = input<boolean, any>(true, { transform: booleanAttribute });
|
|
32
|
+
readonly locale = input<string, any>('');
|
|
27
33
|
}
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
let {
|
|
6
6
|
wpm = undefined,
|
|
7
7
|
showIcon = undefined,
|
|
8
|
+
locale = undefined,
|
|
8
9
|
timer = undefined,
|
|
9
10
|
children
|
|
10
11
|
} = $props<{
|
|
11
12
|
children?: any;
|
|
12
13
|
wpm?: number;
|
|
13
14
|
showIcon?: boolean;
|
|
15
|
+
locale?: string;
|
|
14
16
|
timer?: import('svelte').Snippet;
|
|
15
17
|
}>();
|
|
16
18
|
|
|
@@ -23,6 +25,9 @@
|
|
|
23
25
|
if (elementRef && showIcon !== undefined) {
|
|
24
26
|
elementRef.showIcon = showIcon;
|
|
25
27
|
}
|
|
28
|
+
if (elementRef && locale !== undefined) {
|
|
29
|
+
elementRef.locale = locale;
|
|
30
|
+
}
|
|
26
31
|
});
|
|
27
32
|
|
|
28
33
|
</script>
|
|
@@ -6,7 +6,8 @@ export const ReadTime = defineComponent({
|
|
|
6
6
|
name: 'ReadTime',
|
|
7
7
|
props: {
|
|
8
8
|
wpm: { type: [String, Number, Boolean, Array, Object] as any },
|
|
9
|
-
showIcon: { type: [String, Number, Boolean, Array, Object] as any }
|
|
9
|
+
showIcon: { type: [String, Number, Boolean, Array, Object] as any },
|
|
10
|
+
locale: { type: [String, Number, Boolean, Array, Object] as any }
|
|
10
11
|
},
|
|
11
12
|
emits: [],
|
|
12
13
|
setup(props, { slots, emit }) {
|
package/dist/read-time.d.ts
CHANGED
|
@@ -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
|
*
|
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
|
|
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,SAQX;IAED,OAAO,CAAC,UAAU;IA0ClB,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
|
*
|
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
|
|
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,EA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C;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;AA1F+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,CA8FpB;;AAED,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibit/read-time",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"lucide": "^1.24.0",
|
|
49
|
-
"@uibit/core": "0.
|
|
49
|
+
"@uibit/core": "0.2.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^20.19.43",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"tagName": "uibit-read-time"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
|
-
"build": "cem analyze --
|
|
87
|
-
"dev": "concurrently \"cem analyze --
|
|
88
|
-
"analyze": "cem analyze --
|
|
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
|
}
|