timered-counter 1.2.0 → 1.3.0-beta.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.
Files changed (54) hide show
  1. package/custom-elements.json +264 -64
  2. package/dist/custom-elements.json +264 -64
  3. package/dist/src/index.d.ts +2 -0
  4. package/dist/src/index.js +9 -0
  5. package/dist/src/index.js.map +1 -1
  6. package/dist/src/timered-counter-adapter.d.ts +2 -1
  7. package/dist/src/timered-counter-adapter.js +4 -1
  8. package/dist/src/timered-counter-adapter.js.map +1 -1
  9. package/dist/src/timered-counter-datetime-duration.js +5 -7
  10. package/dist/src/timered-counter-datetime-duration.js.map +1 -1
  11. package/dist/src/timered-counter-number.js +5 -7
  12. package/dist/src/timered-counter-number.js.map +1 -1
  13. package/dist/src/timered-counter-string.js +4 -8
  14. package/dist/src/timered-counter-string.js.map +1 -1
  15. package/dist/src/timered-counter.js +5 -7
  16. package/dist/src/timered-counter.js.map +1 -1
  17. package/dist/src/transitions/roller/roller-digit.js +5 -7
  18. package/dist/src/transitions/roller/roller-digit.js.map +1 -1
  19. package/dist/src/transitions/roller/roller.js +5 -7
  20. package/dist/src/transitions/roller/roller.js.map +1 -1
  21. package/dist/src/utils/grace-define-custom-element.d.ts +1 -0
  22. package/dist/src/utils/grace-define-custom-element.js +10 -0
  23. package/dist/src/utils/grace-define-custom-element.js.map +1 -0
  24. package/dist/src/wrappers/vue/format-props.d.ts +1 -0
  25. package/dist/src/wrappers/vue/format-props.js +22 -0
  26. package/dist/src/wrappers/vue/format-props.js.map +1 -0
  27. package/dist/src/wrappers/vue/index.d.ts +14 -0
  28. package/dist/src/wrappers/vue/index.js +13 -0
  29. package/dist/src/wrappers/vue/index.js.map +1 -0
  30. package/dist/src/wrappers/vue/timered-counter-datetime-duration.d.ts +14 -0
  31. package/dist/src/wrappers/vue/timered-counter-datetime-duration.js +39 -0
  32. package/dist/src/wrappers/vue/timered-counter-datetime-duration.js.map +1 -0
  33. package/dist/src/wrappers/vue/timered-counter-number.d.ts +14 -0
  34. package/dist/src/wrappers/vue/timered-counter-number.js +39 -0
  35. package/dist/src/wrappers/vue/timered-counter-number.js.map +1 -0
  36. package/dist/src/wrappers/vue/timered-counter-string.d.ts +14 -0
  37. package/dist/src/wrappers/vue/timered-counter-string.js +38 -0
  38. package/dist/src/wrappers/vue/timered-counter-string.js.map +1 -0
  39. package/dist/stories/timered-counter/decimaljs.stories.js +1 -1
  40. package/dist/stories/timered-counter/decimaljs.stories.js.map +1 -1
  41. package/dist/stories/timered-counter-number/decimaljs.stories.js +1 -1
  42. package/dist/stories/timered-counter-number/decimaljs.stories.js.map +1 -1
  43. package/dist/stories/timered-counter-string/decimaljs.stories.js +1 -1
  44. package/dist/stories/timered-counter-string/decimaljs.stories.js.map +1 -1
  45. package/dist/stories/timered-counter-string/grapheme-splitter.stories.js +2 -2
  46. package/dist/stories/timered-counter-string/grapheme-splitter.stories.js.map +1 -1
  47. package/dist/stories/timered-counter-string/intl-segmenter.stories.js +1 -1
  48. package/dist/stories/timered-counter-string/intl-segmenter.stories.js.map +1 -1
  49. package/dist/timered-counter.esm-browser.js +53 -58
  50. package/dist/timered-counter.esm-browser.js.map +1 -1
  51. package/dist/timered-counter.global.js +47 -52
  52. package/dist/timered-counter.global.js.map +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +20 -2
@@ -5,7 +5,16 @@
5
5
  {
6
6
  "kind": "javascript-module",
7
7
  "path": "src/index.ts",
8
- "declarations": [],
8
+ "declarations": [
9
+ {
10
+ "kind": "function",
11
+ "name": "registerDecimalJsNumberAdapter"
12
+ },
13
+ {
14
+ "kind": "function",
15
+ "name": "registerGraphemeSplitterStringAdapter"
16
+ }
17
+ ],
9
18
  "exports": [
10
19
  {
11
20
  "kind": "js",
@@ -62,6 +71,22 @@
62
71
  "name": "*",
63
72
  "package": "./timered-counter-adapter.js"
64
73
  }
74
+ },
75
+ {
76
+ "kind": "js",
77
+ "name": "registerDecimalJsNumberAdapter",
78
+ "declaration": {
79
+ "name": "registerDecimalJsNumberAdapter",
80
+ "module": "src/index.ts"
81
+ }
82
+ },
83
+ {
84
+ "kind": "js",
85
+ "name": "registerGraphemeSplitterStringAdapter",
86
+ "declaration": {
87
+ "name": "registerGraphemeSplitterStringAdapter",
88
+ "module": "src/index.ts"
89
+ }
65
90
  }
66
91
  ]
67
92
  },
@@ -191,7 +216,7 @@
191
216
  },
192
217
  {
193
218
  "kind": "method",
194
- "name": "registryAdapter",
219
+ "name": "registerAdapter",
195
220
  "static": true,
196
221
  "parameters": [
197
222
  {
@@ -252,6 +277,18 @@
252
277
  }
253
278
  }
254
279
  ]
280
+ },
281
+ {
282
+ "kind": "function",
283
+ "name": "registerAdapter",
284
+ "parameters": [
285
+ {
286
+ "name": "args",
287
+ "type": {
288
+ "text": "Parameters<(typeof TimeredCounterAdapter)['registerAdapter']>"
289
+ }
290
+ }
291
+ ]
255
292
  }
256
293
  ],
257
294
  "exports": [
@@ -294,6 +331,14 @@
294
331
  "name": "registerStringAdapter",
295
332
  "module": "src/timered-counter-adapter.ts"
296
333
  }
334
+ },
335
+ {
336
+ "kind": "js",
337
+ "name": "registerAdapter",
338
+ "declaration": {
339
+ "name": "registerAdapter",
340
+ "module": "src/timered-counter-adapter.ts"
341
+ }
297
342
  }
298
343
  ]
299
344
  },
@@ -1211,8 +1256,6 @@
1211
1256
  "name": "TimeredCounter",
1212
1257
  "module": "/src/timered-counter.js"
1213
1258
  },
1214
- "tagName": "timered-counter-datetime-duration",
1215
- "customElement": true,
1216
1259
  "events": [
1217
1260
  {
1218
1261
  "name": "timered-counter-animation-start",
@@ -1245,14 +1288,6 @@
1245
1288
  "name": "TimeredCounterDatetimeDuration",
1246
1289
  "module": "src/timered-counter-datetime-duration.ts"
1247
1290
  }
1248
- },
1249
- {
1250
- "kind": "custom-element-definition",
1251
- "name": "timered-counter-datetime-duration",
1252
- "declaration": {
1253
- "name": "TimeredCounterDatetimeDuration",
1254
- "module": "src/timered-counter-datetime-duration.ts"
1255
- }
1256
1291
  }
1257
1292
  ]
1258
1293
  },
@@ -2128,8 +2163,6 @@
2128
2163
  "name": "TimeredCounter",
2129
2164
  "module": "/src/timered-counter.js"
2130
2165
  },
2131
- "tagName": "timered-counter-number",
2132
- "customElement": true,
2133
2166
  "events": [
2134
2167
  {
2135
2168
  "name": "timered-counter-animation-start",
@@ -2162,14 +2195,6 @@
2162
2195
  "name": "TimeredCounterNumber",
2163
2196
  "module": "src/timered-counter-number.ts"
2164
2197
  }
2165
- },
2166
- {
2167
- "kind": "custom-element-definition",
2168
- "name": "timered-counter-number",
2169
- "declaration": {
2170
- "name": "TimeredCounterNumber",
2171
- "module": "src/timered-counter-number.ts"
2172
- }
2173
2198
  }
2174
2199
  ]
2175
2200
  },
@@ -2923,8 +2948,6 @@
2923
2948
  "name": "TimeredCounter",
2924
2949
  "module": "/src/timered-counter.js"
2925
2950
  },
2926
- "tagName": "timered-counter-string",
2927
- "customElement": true,
2928
2951
  "attributes": [
2929
2952
  {
2930
2953
  "name": "aria-label",
@@ -3109,14 +3132,6 @@
3109
3132
  "name": "TimeredCounterString",
3110
3133
  "module": "src/timered-counter-string.ts"
3111
3134
  }
3112
- },
3113
- {
3114
- "kind": "custom-element-definition",
3115
- "name": "timered-counter-string",
3116
- "declaration": {
3117
- "name": "TimeredCounterString",
3118
- "module": "src/timered-counter-string.ts"
3119
- }
3120
3135
  }
3121
3136
  ]
3122
3137
  },
@@ -3805,7 +3820,6 @@
3805
3820
  "name": "LitElement",
3806
3821
  "package": "lit"
3807
3822
  },
3808
- "tagName": "timered-counter",
3809
3823
  "customElement": true,
3810
3824
  "attributes": [
3811
3825
  {
@@ -3969,14 +3983,6 @@
3969
3983
  "name": "TimeredCounter",
3970
3984
  "module": "src/timered-counter.ts"
3971
3985
  }
3972
- },
3973
- {
3974
- "kind": "custom-element-definition",
3975
- "name": "timered-counter",
3976
- "declaration": {
3977
- "name": "TimeredCounter",
3978
- "module": "src/timered-counter.ts"
3979
- }
3980
3986
  }
3981
3987
  ]
3982
3988
  },
@@ -6486,6 +6492,53 @@
6486
6492
  }
6487
6493
  ]
6488
6494
  },
6495
+ {
6496
+ "kind": "javascript-module",
6497
+ "path": "src/utils/grace-define-custom-element.ts",
6498
+ "declarations": [
6499
+ {
6500
+ "kind": "function",
6501
+ "name": "graceDefineCustomElement",
6502
+ "return": {
6503
+ "type": {
6504
+ "text": "void"
6505
+ }
6506
+ },
6507
+ "parameters": [
6508
+ {
6509
+ "name": "tagName",
6510
+ "type": {
6511
+ "text": "string"
6512
+ }
6513
+ },
6514
+ {
6515
+ "name": "constructor",
6516
+ "type": {
6517
+ "text": "CustomElementConstructor"
6518
+ }
6519
+ }
6520
+ ]
6521
+ }
6522
+ ],
6523
+ "exports": [
6524
+ {
6525
+ "kind": "js",
6526
+ "name": "graceDefineCustomElement",
6527
+ "declaration": {
6528
+ "name": "graceDefineCustomElement",
6529
+ "module": "src/utils/grace-define-custom-element.ts"
6530
+ }
6531
+ },
6532
+ {
6533
+ "kind": "custom-element-definition",
6534
+ "name": "tagName",
6535
+ "declaration": {
6536
+ "name": "constructor",
6537
+ "module": "src/utils/grace-define-custom-element.ts"
6538
+ }
6539
+ }
6540
+ ]
6541
+ },
6489
6542
  {
6490
6543
  "kind": "javascript-module",
6491
6544
  "path": "src/utils/iso8601-duration.ts",
@@ -7140,7 +7193,7 @@
7140
7193
  "type": {
7141
7194
  "text": "Meta"
7142
7195
  },
7143
- "default": "{ title: 'TimeredCounter/with decimal.js', component: 'timered-counter', tags: ['autodocs', 'timered-counter'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); }, }"
7196
+ "default": "{ title: 'TimeredCounter/with decimal.js', component: 'timered-counter', tags: ['autodocs', 'timered-counter'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registerAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); }, }"
7144
7197
  },
7145
7198
  {
7146
7199
  "kind": "variable",
@@ -7396,7 +7449,7 @@
7396
7449
  "type": {
7397
7450
  "text": "Meta"
7398
7451
  },
7399
- "default": "{ title: 'TimeredCounterNumber/with decimal.js', component: 'timered-counter-number', tags: ['autodocs', 'timered-counter-number'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); }, }"
7452
+ "default": "{ title: 'TimeredCounterNumber/with decimal.js', component: 'timered-counter-number', tags: ['autodocs', 'timered-counter-number'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registerAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); }, }"
7400
7453
  },
7401
7454
  {
7402
7455
  "kind": "variable",
@@ -7580,7 +7633,7 @@
7580
7633
  "type": {
7581
7634
  "text": "Meta"
7582
7635
  },
7583
- "default": "{ title: 'TimeredCounterString/with decimal.js', component: 'timered-counter-string', tags: ['autodocs', 'timered-counter-string'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); }, }"
7636
+ "default": "{ title: 'TimeredCounterString/with decimal.js', component: 'timered-counter-string', tags: ['autodocs', 'timered-counter-string'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registerAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); }, }"
7584
7637
  },
7585
7638
  {
7586
7639
  "kind": "variable",
@@ -7668,7 +7721,7 @@
7668
7721
  "type": {
7669
7722
  "text": "Meta"
7670
7723
  },
7671
- "default": "{ title: 'TimeredCounterString/with grapheme-splitter', component: 'timered-counter-string', tags: ['autodocs', 'timered-counter-string'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.registryAdapter(GraphemeSplitterStringAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); TimeredCounterAdapter.setStringAdapter('grapheme-splitter'); }, }"
7724
+ "default": "{ title: 'TimeredCounterString/with grapheme-splitter', component: 'timered-counter-string', tags: ['autodocs', 'timered-counter-string'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registerAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.registerAdapter(GraphemeSplitterStringAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); TimeredCounterAdapter.setStringAdapter('grapheme-splitter'); }, }"
7672
7725
  },
7673
7726
  {
7674
7727
  "kind": "variable",
@@ -7860,7 +7913,7 @@
7860
7913
  "type": {
7861
7914
  "text": "Meta"
7862
7915
  },
7863
- "default": "{ title: 'TimeredCounterString/with Intl Segmenter', component: 'timered-counter-string', tags: ['autodocs', 'timered-counter-string'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); TimeredCounterAdapter.setStringAdapter('intl-segmenter'); }, }"
7916
+ "default": "{ title: 'TimeredCounterString/with Intl Segmenter', component: 'timered-counter-string', tags: ['autodocs', 'timered-counter-string'], parameters: { controls: { expanded: true }, }, beforeEach: () => { TimeredCounterAdapter.registerAdapter(DecimalJsNumberAdapter); TimeredCounterAdapter.setNumberAdapter('decimal.js'); TimeredCounterAdapter.setStringAdapter('intl-segmenter'); }, }"
7864
7917
  },
7865
7918
  {
7866
7919
  "kind": "variable",
@@ -8285,7 +8338,6 @@
8285
8338
  "name": "LitElement",
8286
8339
  "package": "lit"
8287
8340
  },
8288
- "tagName": "timered-counter-roller-digit",
8289
8341
  "customElement": true
8290
8342
  }
8291
8343
  ],
@@ -8297,14 +8349,6 @@
8297
8349
  "name": "TimeredCounterRollerDigit",
8298
8350
  "module": "src/transitions/roller/roller-digit.ts"
8299
8351
  }
8300
- },
8301
- {
8302
- "kind": "custom-element-definition",
8303
- "name": "timered-counter-roller-digit",
8304
- "declaration": {
8305
- "name": "TimeredCounterRollerDigit",
8306
- "module": "src/transitions/roller/roller-digit.ts"
8307
- }
8308
8352
  }
8309
8353
  ]
8310
8354
  },
@@ -8571,7 +8615,6 @@
8571
8615
  "name": "LitElement",
8572
8616
  "package": "lit"
8573
8617
  },
8574
- "tagName": "timered-counter-roller",
8575
8618
  "customElement": true
8576
8619
  }
8577
8620
  ],
@@ -8583,14 +8626,6 @@
8583
8626
  "name": "TimeredCounterRoller",
8584
8627
  "module": "src/transitions/roller/roller.ts"
8585
8628
  }
8586
- },
8587
- {
8588
- "kind": "custom-element-definition",
8589
- "name": "timered-counter-roller",
8590
- "declaration": {
8591
- "name": "TimeredCounterRoller",
8592
- "module": "src/transitions/roller/roller.ts"
8593
- }
8594
8629
  }
8595
8630
  ]
8596
8631
  },
@@ -8627,6 +8662,171 @@
8627
8662
  }
8628
8663
  }
8629
8664
  ]
8665
+ },
8666
+ {
8667
+ "kind": "javascript-module",
8668
+ "path": "src/wrappers/vue/format-props.ts",
8669
+ "declarations": [
8670
+ {
8671
+ "kind": "function",
8672
+ "name": "formatProps",
8673
+ "return": {
8674
+ "type": {
8675
+ "text": "P"
8676
+ }
8677
+ },
8678
+ "parameters": [
8679
+ {
8680
+ "name": "props",
8681
+ "type": {
8682
+ "text": "P"
8683
+ }
8684
+ }
8685
+ ]
8686
+ }
8687
+ ],
8688
+ "exports": [
8689
+ {
8690
+ "kind": "js",
8691
+ "name": "formatProps",
8692
+ "declaration": {
8693
+ "name": "formatProps",
8694
+ "module": "src/wrappers/vue/format-props.ts"
8695
+ }
8696
+ }
8697
+ ]
8698
+ },
8699
+ {
8700
+ "kind": "javascript-module",
8701
+ "path": "src/wrappers/vue/index.ts",
8702
+ "declarations": [
8703
+ {
8704
+ "kind": "variable",
8705
+ "name": "TimeredCounterPlugin",
8706
+ "type": {
8707
+ "text": "Plugin"
8708
+ },
8709
+ "default": "{ install: (app: App) => { app.component('TimeredCounterNumber', TimeredCounterNumber); app.component( 'TimeredCounterDatetimeDuration', TimeredCounterDatetimeDuration, ); app.component('TimeredCounterString', TimeredCounterString); }, }"
8710
+ }
8711
+ ],
8712
+ "exports": [
8713
+ {
8714
+ "kind": "js",
8715
+ "name": "TimeredCounterNumber",
8716
+ "declaration": {
8717
+ "name": "TimeredCounterNumber",
8718
+ "module": "src/wrappers/vue/index.ts"
8719
+ }
8720
+ },
8721
+ {
8722
+ "kind": "js",
8723
+ "name": "TimeredCounterString",
8724
+ "declaration": {
8725
+ "name": "TimeredCounterString",
8726
+ "module": "src/wrappers/vue/index.ts"
8727
+ }
8728
+ },
8729
+ {
8730
+ "kind": "js",
8731
+ "name": "TimeredCounterDatetimeDuration",
8732
+ "declaration": {
8733
+ "name": "TimeredCounterDatetimeDuration",
8734
+ "module": "src/wrappers/vue/index.ts"
8735
+ }
8736
+ },
8737
+ {
8738
+ "kind": "js",
8739
+ "name": "default",
8740
+ "declaration": {
8741
+ "name": "TimeredCounterPlugin",
8742
+ "module": "src/wrappers/vue/index.ts"
8743
+ }
8744
+ }
8745
+ ]
8746
+ },
8747
+ {
8748
+ "kind": "javascript-module",
8749
+ "path": "src/wrappers/vue/timered-counter-datetime-duration.ts",
8750
+ "declarations": [
8751
+ {
8752
+ "kind": "function",
8753
+ "name": "TimeredCounterDatetimeDuration",
8754
+ "parameters": [
8755
+ {
8756
+ "name": "props"
8757
+ },
8758
+ {
8759
+ "name": "{ attrs, slots, emit }"
8760
+ }
8761
+ ]
8762
+ }
8763
+ ],
8764
+ "exports": [
8765
+ {
8766
+ "kind": "js",
8767
+ "name": "TimeredCounterDatetimeDuration",
8768
+ "declaration": {
8769
+ "name": "TimeredCounterDatetimeDuration",
8770
+ "module": "src/wrappers/vue/timered-counter-datetime-duration.ts"
8771
+ }
8772
+ }
8773
+ ]
8774
+ },
8775
+ {
8776
+ "kind": "javascript-module",
8777
+ "path": "src/wrappers/vue/timered-counter-number.ts",
8778
+ "declarations": [
8779
+ {
8780
+ "kind": "function",
8781
+ "name": "TimeredCounterNumber",
8782
+ "parameters": [
8783
+ {
8784
+ "name": "props"
8785
+ },
8786
+ {
8787
+ "name": "{ attrs, slots, emit }"
8788
+ }
8789
+ ]
8790
+ }
8791
+ ],
8792
+ "exports": [
8793
+ {
8794
+ "kind": "js",
8795
+ "name": "TimeredCounterNumber",
8796
+ "declaration": {
8797
+ "name": "TimeredCounterNumber",
8798
+ "module": "src/wrappers/vue/timered-counter-number.ts"
8799
+ }
8800
+ }
8801
+ ]
8802
+ },
8803
+ {
8804
+ "kind": "javascript-module",
8805
+ "path": "src/wrappers/vue/timered-counter-string.ts",
8806
+ "declarations": [
8807
+ {
8808
+ "kind": "function",
8809
+ "name": "TimeredCounterString",
8810
+ "parameters": [
8811
+ {
8812
+ "name": "props"
8813
+ },
8814
+ {
8815
+ "name": "{ attrs, slots, emit }"
8816
+ }
8817
+ ]
8818
+ }
8819
+ ],
8820
+ "exports": [
8821
+ {
8822
+ "kind": "js",
8823
+ "name": "TimeredCounterString",
8824
+ "declaration": {
8825
+ "name": "TimeredCounterString",
8826
+ "module": "src/wrappers/vue/timered-counter-string.ts"
8827
+ }
8828
+ }
8829
+ ]
8630
8830
  }
8631
8831
  ]
8632
8832
  }
@@ -6,6 +6,8 @@ export { TimeredCounter, TimeredCounterDatetimeDuration, TimeredCounterNumber, T
6
6
  export * from './easing/index.js';
7
7
  export * from './types/index.js';
8
8
  export * from './timered-counter-adapter.js';
9
+ export declare function registerDecimalJsNumberAdapter(): void;
10
+ export declare function registerGraphemeSplitterStringAdapter(): void;
9
11
  declare global {
10
12
  interface HTMLElementTagNameMap {
11
13
  'timered-counter': TimeredCounter;
package/dist/src/index.js CHANGED
@@ -2,8 +2,17 @@ import { TimeredCounter } from './timered-counter.js';
2
2
  import { TimeredCounterNumber } from './timered-counter-number.js';
3
3
  import { TimeredCounterString } from './timered-counter-string.js';
4
4
  import { TimeredCounterDatetimeDuration } from './timered-counter-datetime-duration.js';
5
+ import { TimeredCounterAdapter } from './timered-counter-adapter.js';
6
+ import decimalJsAdapter from './number-adapter/decimal-js.js';
7
+ import graphemeSplitterAdapter from './string-adapter/grapheme-splitter.js';
5
8
  export { TimeredCounter, TimeredCounterDatetimeDuration, TimeredCounterNumber, TimeredCounterString, };
6
9
  export * from './easing/index.js';
7
10
  export * from './types/index.js';
8
11
  export * from './timered-counter-adapter.js';
12
+ export function registerDecimalJsNumberAdapter() {
13
+ decimalJsAdapter.register(TimeredCounterAdapter);
14
+ }
15
+ export function registerGraphemeSplitterStringAdapter() {
16
+ graphemeSplitterAdapter.register(TimeredCounterAdapter);
17
+ }
9
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAExF,OAAO,EACL,cAAc,EACd,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,GACrB,CAAC;AAEF,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,8BAA8B,CAAC","sourcesContent":["import { TimeredCounter } from './timered-counter.js';\nimport { TimeredCounterNumber } from './timered-counter-number.js';\nimport { TimeredCounterString } from './timered-counter-string.js';\nimport { TimeredCounterDatetimeDuration } from './timered-counter-datetime-duration.js';\n\nexport {\n TimeredCounter,\n TimeredCounterDatetimeDuration,\n TimeredCounterNumber,\n TimeredCounterString,\n};\n\nexport * from './easing/index.js';\nexport * from './types/index.js';\n\nexport * from './timered-counter-adapter.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'timered-counter': TimeredCounter;\n 'timered-counter-datetime-duration': TimeredCounterDatetimeDuration;\n 'timered-counter-number': TimeredCounterNumber;\n 'timered-counter-string': TimeredCounterString;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAExF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAC9D,OAAO,uBAAuB,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EACL,cAAc,EACd,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,GACrB,CAAC;AAEF,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,8BAA8B,CAAC;AAE7C,MAAM,UAAU,8BAA8B;IAC5C,gBAAgB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,qCAAqC;IACnD,uBAAuB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { TimeredCounter } from './timered-counter.js';\nimport { TimeredCounterNumber } from './timered-counter-number.js';\nimport { TimeredCounterString } from './timered-counter-string.js';\nimport { TimeredCounterDatetimeDuration } from './timered-counter-datetime-duration.js';\n\nimport { TimeredCounterAdapter } from './timered-counter-adapter.js';\nimport decimalJsAdapter from './number-adapter/decimal-js.js';\nimport graphemeSplitterAdapter from './string-adapter/grapheme-splitter.js';\n\nexport {\n TimeredCounter,\n TimeredCounterDatetimeDuration,\n TimeredCounterNumber,\n TimeredCounterString,\n};\n\nexport * from './easing/index.js';\nexport * from './types/index.js';\n\nexport * from './timered-counter-adapter.js';\n\nexport function registerDecimalJsNumberAdapter() {\n decimalJsAdapter.register(TimeredCounterAdapter);\n}\n\nexport function registerGraphemeSplitterStringAdapter() {\n graphemeSplitterAdapter.register(TimeredCounterAdapter);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'timered-counter': TimeredCounter;\n 'timered-counter-datetime-duration': TimeredCounterDatetimeDuration;\n 'timered-counter-number': TimeredCounterNumber;\n 'timered-counter-string': TimeredCounterString;\n }\n}\n"]}
@@ -55,7 +55,7 @@ export declare class TimeredCounterAdapter {
55
55
  *
56
56
  * 具体示例请查看 {@link GraphemeSplitterAdapter} or {@link DecimalJsAdapter}.
57
57
  */
58
- static registryAdapter(adapter: {
58
+ static registerAdapter(adapter: {
59
59
  register: (counterAdapter: typeof TimeredCounterAdapter) => void;
60
60
  }): void;
61
61
  }
@@ -63,3 +63,4 @@ export declare function setNumberAdapter(...args: Parameters<(typeof TimeredCoun
63
63
  export declare function setStringAdapter(...args: Parameters<(typeof TimeredCounterAdapter)['setStringAdapter']>): void;
64
64
  export declare function registerNumberAdapter(...args: Parameters<(typeof TimeredCounterAdapter)['registerNumberAdapter']>): void;
65
65
  export declare function registerStringAdapter(...args: Parameters<(typeof TimeredCounterAdapter)['registerStringAdapter']>): void;
66
+ export declare function registerAdapter(...args: Parameters<(typeof TimeredCounterAdapter)['registerAdapter']>): void;
@@ -55,7 +55,7 @@ export class TimeredCounterAdapter {
55
55
  *
56
56
  * 具体示例请查看 {@link GraphemeSplitterAdapter} or {@link DecimalJsAdapter}.
57
57
  */
58
- static registryAdapter(adapter) {
58
+ static registerAdapter(adapter) {
59
59
  adapter.register(this);
60
60
  }
61
61
  }
@@ -117,4 +117,7 @@ export function registerNumberAdapter(...args) {
117
117
  export function registerStringAdapter(...args) {
118
118
  TimeredCounterAdapter.registerStringAdapter(...args);
119
119
  }
120
+ export function registerAdapter(...args) {
121
+ TimeredCounterAdapter.registerAdapter(...args);
122
+ }
120
123
  //# sourceMappingURL=timered-counter-adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"timered-counter-adapter.js","sourceRoot":"","sources":["../../src/timered-counter-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAiB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAErB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,OAAO,qBAAqB;IAsDhC;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,aAAgD;QACtE,IAAI,OAAO,GAAkB,oBAAoB,EAAE,CAAC;QAEpD,IAAI,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC5B,KAAK,MAAM,CACT,QAAQ,EACR,cAAc,EACf,IAAI,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBACrD,IAAI,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;oBACrC,OAAO,GAAG,cAAc,EAAE,CAAC;oBAC3B,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,aAAa,CAAC;QAC1B,CAAC;QAED,qBAAqB,CAAC,cAAc,GAAG,OAAO,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CACrB,aAAmE;QAEnE,IAAI,OAAO,GAAkB,oBAAoB,EAAE,CAAC;QAEpD,IAAI,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC5B,KAAK,MAAM,CACT,QAAQ,EACR,cAAc,EACf,IAAI,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBACrD,IAAI,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;oBACrC,OAAO,GAAG,cAAc,EAAE,CAAC;oBAC3B,MAAM;gBACR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CAAC;AAkFJ,MAAM,UAAU,gBAAgB,CAC9B,GAAG,IAAoE;IAEvE,qBAAqB,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,GAAG,IAAoE;IAEvE,qBAAqB,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,GAAG,IAAyE;IAE5E,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,GAAG,IAAyE;IAE5E,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { isNullish, isString } from 'remeda';\nimport { BuildInNumberAdapter, NumberAdapter } from './number-adapter/index.js';\nimport {\n BuildInIntlSegmenterAdapter,\n BuildInStringAdapter,\n StringAdapter,\n} from './string-adapter/index.js';\n\nexport class TimeredCounterAdapter {\n static AVAILABLE_NUMBER_ADAPTERS: Map<string[], () => NumberAdapter> =\n new Map([\n [['number'], BuildInNumberAdapter],\n // [['decimal.js', 'decimaljs'], DecimalJsAdapter()],\n ]);\n\n static AVAILABLE_STRING_ADAPTERS: Map<string[], () => StringAdapter> =\n new Map([\n [['string'], BuildInStringAdapter],\n [['intl-segmenter'], BuildInIntlSegmenterAdapter],\n // [['grapheme-splitter'], GraphemeSplitterAdapter()],\n ]);\n\n /**\n * 数字适配器, 有以下两种:\n * 1. BuildInNumberAdapter(默认): 使用内置 number 进行计算.\n * 2. DecimalJsAdapter: 使用 Decimal.js 进行计算.\n *\n * 详细信息请查看[字符长度限制](/guide/optional-dependencies#字符长度限制)章节.\n *\n * @default BuildInNumberAdapter\n */\n static NUMBER_ADAPTER: NumberAdapter = BuildInNumberAdapter();\n\n /**\n * 字符串适配器, 有以下两种:\n * 1. BuildInStringAdapter(默认): 使用内置 string 进行字符串处理.\n * 2. BuildInIntlSegmenterAdapter: 使用 Intl.Segmenter 进行字符串处理. 能够支持 emoji, 字符集.\n * 3. GraphemeSplitterAdapter: 使用 grapheme-splitter 进行字符串处理. 能够支持 emoji, 字符集.\n *\n * 详细信息请查看[支持 emoji 分词](/guide/optional-dependencies#支持-emoji-分词)章节.\n *\n * @default BuildInStringAdapter\n */\n static STRING_ADAPTER: StringAdapter = BuildInStringAdapter();\n\n /**\n * 将 value 及其相关的属性, 在 attribute 和 property 上的互相转换.\n *\n * @see https://lit.dev/docs/components/properties/#attributes\n * @protected\n */\n static VALUE_CONVERTER = {\n fromAttribute(value: string | null) {\n return value;\n },\n toAttribute(value: unknown) {\n return isNullish(value)\n ? value\n : TimeredCounterAdapter.NUMBER_ADAPTER.toString(value);\n },\n };\n\n /**\n * 设置要使用的数字适配器. 仅对设置完之后的 TimeredCounter 实例生效.\n *\n * 接受的关键字除了内置的 `number` 以外, 还可以通过 {@link registerNumberAdapter} 注册的 `keyword`.\n *\n * @param adapterOrType\n */\n static setNumberAdapter(adapterOrType: NumberAdapter | 'number' | string) {\n let adapter: NumberAdapter = BuildInNumberAdapter();\n\n if (isString(adapterOrType)) {\n for (const [\n keywords,\n adapterFactory,\n ] of TimeredCounterAdapter.AVAILABLE_NUMBER_ADAPTERS) {\n if (keywords.includes(adapterOrType)) {\n adapter = adapterFactory();\n break;\n }\n }\n } else {\n adapter = adapterOrType;\n }\n\n TimeredCounterAdapter.NUMBER_ADAPTER = adapter;\n }\n\n /**\n * 与 {@link setNumberAdapter} 类似, 用于设置字符串适配器.\n */\n static setStringAdapter(\n adapterOrType: StringAdapter | 'string' | 'intl-segmenter' | string,\n ) {\n let adapter: StringAdapter = BuildInStringAdapter();\n\n if (isString(adapterOrType)) {\n for (const [\n keywords,\n adapterFactory,\n ] of TimeredCounterAdapter.AVAILABLE_STRING_ADAPTERS) {\n if (keywords.includes(adapterOrType)) {\n adapter = adapterFactory();\n break;\n }\n }\n } else {\n adapter = adapterOrType;\n }\n\n TimeredCounterAdapter.STRING_ADAPTER = adapter;\n }\n\n static registerNumberAdapter(\n keyword: string[],\n adapter: () => NumberAdapter,\n ) {\n TimeredCounterAdapter.AVAILABLE_NUMBER_ADAPTERS.set(keyword, adapter);\n }\n\n static registerStringAdapter(\n keyword: string[],\n adapter: () => StringAdapter,\n ) {\n TimeredCounterAdapter.AVAILABLE_STRING_ADAPTERS.set(keyword, adapter);\n }\n\n /**\n * 可以直接使用 adapter 文件的导出进行注册.\n *\n * adapter 文件需要导出一个名为 register 的函数, 该函数接受一个 TimeredCounterAdapter 类型的参数.\n *\n * 具体示例请查看 {@link GraphemeSplitterAdapter} or {@link DecimalJsAdapter}.\n */\n static registryAdapter(adapter: {\n register: (counterAdapter: typeof TimeredCounterAdapter) => void;\n }) {\n adapter.register(this);\n }\n}\n\nexport function setNumberAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['setNumberAdapter']>\n) {\n TimeredCounterAdapter.setNumberAdapter(...args);\n}\n\nexport function setStringAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['setStringAdapter']>\n) {\n TimeredCounterAdapter.setStringAdapter(...args);\n}\n\nexport function registerNumberAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['registerNumberAdapter']>\n) {\n TimeredCounterAdapter.registerNumberAdapter(...args);\n}\n\nexport function registerStringAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['registerStringAdapter']>\n) {\n TimeredCounterAdapter.registerStringAdapter(...args);\n}\n"]}
1
+ {"version":3,"file":"timered-counter-adapter.js","sourceRoot":"","sources":["../../src/timered-counter-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAiB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAErB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,OAAO,qBAAqB;IA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U,qBAAqB,CACnC,GAAG,IAAyE;IAE5E,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,GAAG,IAAmE;IAEtE,qBAAqB,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { isNullish, isString } from 'remeda';\nimport { BuildInNumberAdapter, NumberAdapter } from './number-adapter/index.js';\nimport {\n BuildInIntlSegmenterAdapter,\n BuildInStringAdapter,\n StringAdapter,\n} from './string-adapter/index.js';\n\nexport class TimeredCounterAdapter {\n static AVAILABLE_NUMBER_ADAPTERS: Map<string[], () => NumberAdapter> =\n new Map([\n [['number'], BuildInNumberAdapter],\n // [['decimal.js', 'decimaljs'], DecimalJsAdapter()],\n ]);\n\n static AVAILABLE_STRING_ADAPTERS: Map<string[], () => StringAdapter> =\n new Map([\n [['string'], BuildInStringAdapter],\n [['intl-segmenter'], BuildInIntlSegmenterAdapter],\n // [['grapheme-splitter'], GraphemeSplitterAdapter()],\n ]);\n\n /**\n * 数字适配器, 有以下两种:\n * 1. BuildInNumberAdapter(默认): 使用内置 number 进行计算.\n * 2. DecimalJsAdapter: 使用 Decimal.js 进行计算.\n *\n * 详细信息请查看[字符长度限制](/guide/optional-dependencies#字符长度限制)章节.\n *\n * @default BuildInNumberAdapter\n */\n static NUMBER_ADAPTER: NumberAdapter = BuildInNumberAdapter();\n\n /**\n * 字符串适配器, 有以下两种:\n * 1. BuildInStringAdapter(默认): 使用内置 string 进行字符串处理.\n * 2. BuildInIntlSegmenterAdapter: 使用 Intl.Segmenter 进行字符串处理. 能够支持 emoji, 字符集.\n * 3. GraphemeSplitterAdapter: 使用 grapheme-splitter 进行字符串处理. 能够支持 emoji, 字符集.\n *\n * 详细信息请查看[支持 emoji 分词](/guide/optional-dependencies#支持-emoji-分词)章节.\n *\n * @default BuildInStringAdapter\n */\n static STRING_ADAPTER: StringAdapter = BuildInStringAdapter();\n\n /**\n * 将 value 及其相关的属性, 在 attribute 和 property 上的互相转换.\n *\n * @see https://lit.dev/docs/components/properties/#attributes\n * @protected\n */\n static VALUE_CONVERTER = {\n fromAttribute(value: string | null) {\n return value;\n },\n toAttribute(value: unknown) {\n return isNullish(value)\n ? value\n : TimeredCounterAdapter.NUMBER_ADAPTER.toString(value);\n },\n };\n\n /**\n * 设置要使用的数字适配器. 仅对设置完之后的 TimeredCounter 实例生效.\n *\n * 接受的关键字除了内置的 `number` 以外, 还可以通过 {@link registerNumberAdapter} 注册的 `keyword`.\n *\n * @param adapterOrType\n */\n static setNumberAdapter(adapterOrType: NumberAdapter | 'number' | string) {\n let adapter: NumberAdapter = BuildInNumberAdapter();\n\n if (isString(adapterOrType)) {\n for (const [\n keywords,\n adapterFactory,\n ] of TimeredCounterAdapter.AVAILABLE_NUMBER_ADAPTERS) {\n if (keywords.includes(adapterOrType)) {\n adapter = adapterFactory();\n break;\n }\n }\n } else {\n adapter = adapterOrType;\n }\n\n TimeredCounterAdapter.NUMBER_ADAPTER = adapter;\n }\n\n /**\n * 与 {@link setNumberAdapter} 类似, 用于设置字符串适配器.\n */\n static setStringAdapter(\n adapterOrType: StringAdapter | 'string' | 'intl-segmenter' | string,\n ) {\n let adapter: StringAdapter = BuildInStringAdapter();\n\n if (isString(adapterOrType)) {\n for (const [\n keywords,\n adapterFactory,\n ] of TimeredCounterAdapter.AVAILABLE_STRING_ADAPTERS) {\n if (keywords.includes(adapterOrType)) {\n adapter = adapterFactory();\n break;\n }\n }\n } else {\n adapter = adapterOrType;\n }\n\n TimeredCounterAdapter.STRING_ADAPTER = adapter;\n }\n\n static registerNumberAdapter(\n keyword: string[],\n adapter: () => NumberAdapter,\n ) {\n TimeredCounterAdapter.AVAILABLE_NUMBER_ADAPTERS.set(keyword, adapter);\n }\n\n static registerStringAdapter(\n keyword: string[],\n adapter: () => StringAdapter,\n ) {\n TimeredCounterAdapter.AVAILABLE_STRING_ADAPTERS.set(keyword, adapter);\n }\n\n /**\n * 可以直接使用 adapter 文件的导出进行注册.\n *\n * adapter 文件需要导出一个名为 register 的函数, 该函数接受一个 TimeredCounterAdapter 类型的参数.\n *\n * 具体示例请查看 {@link GraphemeSplitterAdapter} or {@link DecimalJsAdapter}.\n */\n static registerAdapter(adapter: {\n register: (counterAdapter: typeof TimeredCounterAdapter) => void;\n }) {\n adapter.register(this);\n }\n}\n\nexport function setNumberAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['setNumberAdapter']>\n) {\n TimeredCounterAdapter.setNumberAdapter(...args);\n}\n\nexport function setStringAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['setStringAdapter']>\n) {\n TimeredCounterAdapter.setStringAdapter(...args);\n}\n\nexport function registerNumberAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['registerNumberAdapter']>\n) {\n TimeredCounterAdapter.registerNumberAdapter(...args);\n}\n\nexport function registerStringAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['registerStringAdapter']>\n) {\n TimeredCounterAdapter.registerStringAdapter(...args);\n}\n\nexport function registerAdapter(\n ...args: Parameters<(typeof TimeredCounterAdapter)['registerAdapter']>\n) {\n TimeredCounterAdapter.registerAdapter(...args);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { customElement, property } from 'lit/decorators.js';
2
+ import { property } from 'lit/decorators.js';
3
3
  import { html } from 'lit';
4
4
  import { repeat } from 'lit/directives/repeat.js';
5
5
  import { isArray, isDate, isNullish, isString, map } from 'remeda';
@@ -11,6 +11,7 @@ import { duration, durationObject } from './utils/duration.js';
11
11
  import { iso8601Duration } from './utils/iso8601-duration.js';
12
12
  import { timeredCounterDatetimeStyles } from './styles/timered-counter-datetime-styles.js';
13
13
  import { parseJsonString } from './utils/parse-json-string.js';
14
+ import { graceDefineCustomElement } from './utils/grace-define-custom-element.js';
14
15
  /**
15
16
  * 根据最小精度对 from 进行优化. 避免频繁更新.
16
17
  *
@@ -43,7 +44,7 @@ function toDurationInMilliseconds(value, minPrecision) {
43
44
  to: result[1],
44
45
  };
45
46
  }
46
- let TimeredCounterDatetimeDuration = class TimeredCounterDatetimeDuration extends TimeredCounter {
47
+ export class TimeredCounterDatetimeDuration extends TimeredCounter {
47
48
  constructor() {
48
49
  super(...arguments);
49
50
  this.__precision = [DurationPartType.Second, DurationPartType.Day];
@@ -201,7 +202,7 @@ let TimeredCounterDatetimeDuration = class TimeredCounterDatetimeDuration extend
201
202
  </timered-counter-roller>
202
203
  `;
203
204
  }
204
- };
205
+ }
205
206
  TimeredCounterDatetimeDuration.styles = [...TimeredCounter.styles, timeredCounterDatetimeStyles];
206
207
  __decorate([
207
208
  property({
@@ -213,8 +214,5 @@ __decorate([
213
214
  },
214
215
  })
215
216
  ], TimeredCounterDatetimeDuration.prototype, "precision", null);
216
- TimeredCounterDatetimeDuration = __decorate([
217
- customElement('timered-counter-datetime-duration')
218
- ], TimeredCounterDatetimeDuration);
219
- export { TimeredCounterDatetimeDuration };
217
+ graceDefineCustomElement('timered-counter-datetime-duration', TimeredCounterDatetimeDuration);
220
218
  //# sourceMappingURL=timered-counter-datetime-duration.js.map