timered-counter 0.0.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.
Files changed (206) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -0
  3. package/dist/custom-elements.json +8484 -0
  4. package/dist/src/counter-adapter.d.ts +38 -0
  5. package/dist/src/counter-adapter.js +69 -0
  6. package/dist/src/counter-adapter.js.map +1 -0
  7. package/dist/src/easing/cubic-bezier.d.ts +5 -0
  8. package/dist/src/easing/cubic-bezier.js +35 -0
  9. package/dist/src/easing/cubic-bezier.js.map +1 -0
  10. package/dist/src/easing/easing-functions.d.ts +1 -0
  11. package/dist/src/easing/easing-functions.js +10 -0
  12. package/dist/src/easing/easing-functions.js.map +1 -0
  13. package/dist/src/easing/index.d.ts +2 -0
  14. package/dist/src/easing/index.js +3 -0
  15. package/dist/src/easing/index.js.map +1 -0
  16. package/dist/src/easing/penner-easing-functions.d.ts +33 -0
  17. package/dist/src/easing/penner-easing-functions.js +82 -0
  18. package/dist/src/easing/penner-easing-functions.js.map +1 -0
  19. package/dist/src/index.d.ts +18 -0
  20. package/dist/src/index.js +13 -0
  21. package/dist/src/index.js.map +1 -0
  22. package/dist/src/mixins/counter-aira.d.ts +9 -0
  23. package/dist/src/mixins/counter-aira.js +41 -0
  24. package/dist/src/mixins/counter-aira.js.map +1 -0
  25. package/dist/src/mixins/counter-animation.d.ts +13 -0
  26. package/dist/src/mixins/counter-animation.js +55 -0
  27. package/dist/src/mixins/counter-animation.js.map +1 -0
  28. package/dist/src/mixins/counter-base.d.ts +21 -0
  29. package/dist/src/mixins/counter-base.js +152 -0
  30. package/dist/src/mixins/counter-base.js.map +1 -0
  31. package/dist/src/mixins/counter-parts.d.ts +42 -0
  32. package/dist/src/mixins/counter-parts.js +180 -0
  33. package/dist/src/mixins/counter-parts.js.map +1 -0
  34. package/dist/src/mixins/counter-styles.d.ts +17 -0
  35. package/dist/src/mixins/counter-styles.js +93 -0
  36. package/dist/src/mixins/counter-styles.js.map +1 -0
  37. package/dist/src/number-adapter/build-in-bigint.d.ts +6 -0
  38. package/dist/src/number-adapter/build-in-bigint.js +92 -0
  39. package/dist/src/number-adapter/build-in-bigint.js.map +1 -0
  40. package/dist/src/number-adapter/build-in-number.d.ts +3 -0
  41. package/dist/src/number-adapter/build-in-number.js +84 -0
  42. package/dist/src/number-adapter/build-in-number.js.map +1 -0
  43. package/dist/src/number-adapter/decimal-js.d.ts +4 -0
  44. package/dist/src/number-adapter/decimal-js.js +87 -0
  45. package/dist/src/number-adapter/decimal-js.js.map +1 -0
  46. package/dist/src/number-adapter/index.d.ts +4 -0
  47. package/dist/src/number-adapter/index.js +5 -0
  48. package/dist/src/number-adapter/index.js.map +1 -0
  49. package/dist/src/number-adapter/types.d.ts +34 -0
  50. package/dist/src/number-adapter/types.js +2 -0
  51. package/dist/src/number-adapter/types.js.map +1 -0
  52. package/dist/src/string-adapter/build-in-intl-segmenter.d.ts +10 -0
  53. package/dist/src/string-adapter/build-in-intl-segmenter.js +18 -0
  54. package/dist/src/string-adapter/build-in-intl-segmenter.js.map +1 -0
  55. package/dist/src/string-adapter/build-in-string.d.ts +12 -0
  56. package/dist/src/string-adapter/build-in-string.js +16 -0
  57. package/dist/src/string-adapter/build-in-string.js.map +1 -0
  58. package/dist/src/string-adapter/grapheme-splitter.d.ts +8 -0
  59. package/dist/src/string-adapter/grapheme-splitter.js +16 -0
  60. package/dist/src/string-adapter/grapheme-splitter.js.map +1 -0
  61. package/dist/src/string-adapter/index.d.ts +4 -0
  62. package/dist/src/string-adapter/index.js +5 -0
  63. package/dist/src/string-adapter/index.js.map +1 -0
  64. package/dist/src/string-adapter/types.d.ts +19 -0
  65. package/dist/src/string-adapter/types.js +2 -0
  66. package/dist/src/string-adapter/types.js.map +1 -0
  67. package/dist/src/styles/timered-counter-datetime-styles.d.ts +1 -0
  68. package/dist/src/styles/timered-counter-datetime-styles.js +8 -0
  69. package/dist/src/styles/timered-counter-datetime-styles.js.map +1 -0
  70. package/dist/src/styles/timered-counter-number-styles.d.ts +1 -0
  71. package/dist/src/styles/timered-counter-number-styles.js +3 -0
  72. package/dist/src/styles/timered-counter-number-styles.js.map +1 -0
  73. package/dist/src/styles/timered-counter-string-styles.d.ts +1 -0
  74. package/dist/src/styles/timered-counter-string-styles.js +3 -0
  75. package/dist/src/styles/timered-counter-string-styles.js.map +1 -0
  76. package/dist/src/styles/timered-counter-styles.d.ts +1 -0
  77. package/dist/src/styles/timered-counter-styles.js +25 -0
  78. package/dist/src/styles/timered-counter-styles.js.map +1 -0
  79. package/dist/src/timered-counter-datetime-duration.d.ts +37 -0
  80. package/dist/src/timered-counter-datetime-duration.js +186 -0
  81. package/dist/src/timered-counter-datetime-duration.js.map +1 -0
  82. package/dist/src/timered-counter-number.d.ts +23 -0
  83. package/dist/src/timered-counter-number.js +114 -0
  84. package/dist/src/timered-counter-number.js.map +1 -0
  85. package/dist/src/timered-counter-string.d.ts +30 -0
  86. package/dist/src/timered-counter-string.js +138 -0
  87. package/dist/src/timered-counter-string.js.map +1 -0
  88. package/dist/src/timered-counter.d.ts +15 -0
  89. package/dist/src/timered-counter.js +80 -0
  90. package/dist/src/timered-counter.js.map +1 -0
  91. package/dist/src/transitions/roller/index.d.ts +1 -0
  92. package/dist/src/transitions/roller/index.js +2 -0
  93. package/dist/src/transitions/roller/index.js.map +1 -0
  94. package/dist/src/transitions/roller/roller-digit.d.ts +28 -0
  95. package/dist/src/transitions/roller/roller-digit.js +259 -0
  96. package/dist/src/transitions/roller/roller-digit.js.map +1 -0
  97. package/dist/src/transitions/roller/roller.d.ts +42 -0
  98. package/dist/src/transitions/roller/roller.js +235 -0
  99. package/dist/src/transitions/roller/roller.js.map +1 -0
  100. package/dist/src/transitions/roller/styles.d.ts +2 -0
  101. package/dist/src/transitions/roller/styles.js +77 -0
  102. package/dist/src/transitions/roller/styles.js.map +1 -0
  103. package/dist/src/types/duration.d.ts +33 -0
  104. package/dist/src/types/duration.js +35 -0
  105. package/dist/src/types/duration.js.map +1 -0
  106. package/dist/src/types/group.d.ts +67 -0
  107. package/dist/src/types/group.js +2 -0
  108. package/dist/src/types/group.js.map +1 -0
  109. package/dist/src/utils/any-base.d.ts +6 -0
  110. package/dist/src/utils/any-base.js +56 -0
  111. package/dist/src/utils/any-base.js.map +1 -0
  112. package/dist/src/utils/duration.d.ts +15 -0
  113. package/dist/src/utils/duration.js +66 -0
  114. package/dist/src/utils/duration.js.map +1 -0
  115. package/dist/src/utils/extract-group-option.d.ts +9 -0
  116. package/dist/src/utils/extract-group-option.js +81 -0
  117. package/dist/src/utils/extract-group-option.js.map +1 -0
  118. package/dist/src/utils/iso8601-duration.d.ts +4 -0
  119. package/dist/src/utils/iso8601-duration.js +32 -0
  120. package/dist/src/utils/iso8601-duration.js.map +1 -0
  121. package/dist/src/utils/localized-date-time-fields.d.ts +2 -0
  122. package/dist/src/utils/localized-date-time-fields.js +24 -0
  123. package/dist/src/utils/localized-date-time-fields.js.map +1 -0
  124. package/dist/src/utils/parse-json-string.d.ts +1 -0
  125. package/dist/src/utils/parse-json-string.js +9 -0
  126. package/dist/src/utils/parse-json-string.js.map +1 -0
  127. package/dist/src/utils/polyfill-keyframes.d.ts +1 -0
  128. package/dist/src/utils/polyfill-keyframes.js +19 -0
  129. package/dist/src/utils/polyfill-keyframes.js.map +1 -0
  130. package/dist/src/utils/preprocess-part-data.d.ts +25 -0
  131. package/dist/src/utils/preprocess-part-data.js +59 -0
  132. package/dist/src/utils/preprocess-part-data.js.map +1 -0
  133. package/dist/src/utils/transition-digit.d.ts +2 -0
  134. package/dist/src/utils/transition-digit.js +51 -0
  135. package/dist/src/utils/transition-digit.js.map +1 -0
  136. package/dist/src/utils/uuid.d.ts +1 -0
  137. package/dist/src/utils/uuid.js +7 -0
  138. package/dist/src/utils/uuid.js.map +1 -0
  139. package/dist/stories/story-parts/animation-events.d.ts +9 -0
  140. package/dist/stories/story-parts/animation-events.js +35 -0
  141. package/dist/stories/story-parts/animation-events.js.map +1 -0
  142. package/dist/stories/story-parts/animation-options.d.ts +8 -0
  143. package/dist/stories/story-parts/animation-options.js +25 -0
  144. package/dist/stories/story-parts/animation-options.js.map +1 -0
  145. package/dist/stories/story-parts/big-number.d.ts +8 -0
  146. package/dist/stories/story-parts/big-number.js +25 -0
  147. package/dist/stories/story-parts/big-number.js.map +1 -0
  148. package/dist/stories/story-parts/datetime-locale.d.ts +8 -0
  149. package/dist/stories/story-parts/datetime-locale.js +30 -0
  150. package/dist/stories/story-parts/datetime-locale.js.map +1 -0
  151. package/dist/stories/story-parts/datetime-precision.d.ts +8 -0
  152. package/dist/stories/story-parts/datetime-precision.js +82 -0
  153. package/dist/stories/story-parts/datetime-precision.js.map +1 -0
  154. package/dist/stories/story-parts/edge-case.d.ts +8 -0
  155. package/dist/stories/story-parts/edge-case.js +12 -0
  156. package/dist/stories/story-parts/edge-case.js.map +1 -0
  157. package/dist/stories/story-parts/emoji.d.ts +9 -0
  158. package/dist/stories/story-parts/emoji.js +20 -0
  159. package/dist/stories/story-parts/emoji.js.map +1 -0
  160. package/dist/stories/story-parts/locale-number.d.ts +7 -0
  161. package/dist/stories/story-parts/locale-number.js +23 -0
  162. package/dist/stories/story-parts/locale-number.js.map +1 -0
  163. package/dist/stories/story-parts/slots.d.ts +10 -0
  164. package/dist/stories/story-parts/slots.js +29 -0
  165. package/dist/stories/story-parts/slots.js.map +1 -0
  166. package/dist/stories/story-parts/styles.d.ts +7 -0
  167. package/dist/stories/story-parts/styles.js +34 -0
  168. package/dist/stories/story-parts/styles.js.map +1 -0
  169. package/dist/stories/story-parts/value-change.d.ts +9 -0
  170. package/dist/stories/story-parts/value-change.js +20 -0
  171. package/dist/stories/story-parts/value-change.js.map +1 -0
  172. package/dist/stories/timered-counter/decimaljs.stories.d.ts +6 -0
  173. package/dist/stories/timered-counter/decimaljs.stories.js +34 -0
  174. package/dist/stories/timered-counter/decimaljs.stories.js.map +1 -0
  175. package/dist/stories/timered-counter/index.stories.d.ts +9 -0
  176. package/dist/stories/timered-counter/index.stories.js +180 -0
  177. package/dist/stories/timered-counter/index.stories.js.map +1 -0
  178. package/dist/stories/timered-counter-datetime-duration/index.stories.d.ts +7 -0
  179. package/dist/stories/timered-counter-datetime-duration/index.stories.js +95 -0
  180. package/dist/stories/timered-counter-datetime-duration/index.stories.js.map +1 -0
  181. package/dist/stories/timered-counter-number/decimaljs.stories.d.ts +6 -0
  182. package/dist/stories/timered-counter-number/decimaljs.stories.js +34 -0
  183. package/dist/stories/timered-counter-number/decimaljs.stories.js.map +1 -0
  184. package/dist/stories/timered-counter-number/index.stories.d.ts +9 -0
  185. package/dist/stories/timered-counter-number/index.stories.js +188 -0
  186. package/dist/stories/timered-counter-number/index.stories.js.map +1 -0
  187. package/dist/stories/timered-counter-string/decimaljs.stories.d.ts +7 -0
  188. package/dist/stories/timered-counter-string/decimaljs.stories.js +55 -0
  189. package/dist/stories/timered-counter-string/decimaljs.stories.js.map +1 -0
  190. package/dist/stories/timered-counter-string/grapheme-splitter.stories.d.ts +7 -0
  191. package/dist/stories/timered-counter-string/grapheme-splitter.stories.js +56 -0
  192. package/dist/stories/timered-counter-string/grapheme-splitter.stories.js.map +1 -0
  193. package/dist/stories/timered-counter-string/index.stories.d.ts +9 -0
  194. package/dist/stories/timered-counter-string/index.stories.js +126 -0
  195. package/dist/stories/timered-counter-string/index.stories.js.map +1 -0
  196. package/dist/stories/timered-counter-string/intl-segmenter.stories.d.ts +7 -0
  197. package/dist/stories/timered-counter-string/intl-segmenter.stories.js +56 -0
  198. package/dist/stories/timered-counter-string/intl-segmenter.stories.js.map +1 -0
  199. package/dist/stories/utils/index.d.ts +8 -0
  200. package/dist/stories/utils/index.js +20 -0
  201. package/dist/stories/utils/index.js.map +1 -0
  202. package/dist/test/td-counter.test.d.ts +1 -0
  203. package/dist/test/td-counter.test.js +25 -0
  204. package/dist/test/td-counter.test.js.map +1 -0
  205. package/dist/tsconfig.tsbuildinfo +1 -0
  206. package/package.json +128 -0
@@ -0,0 +1,180 @@
1
+ import { setCustomElementsManifest, } from '@storybook/web-components';
2
+ import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
3
+ import { setNumberAdapter } from '../../src/index.js';
4
+ import { setByAttr, setByProp } from '../utils/index.js';
5
+ import { valueChange } from '../story-parts/value-change.js';
6
+ import { edgeCase } from '../story-parts/edge-case.js';
7
+ import { animationEvents } from '../story-parts/animation-events.js';
8
+ import { animationOptions } from '../story-parts/animation-options.js';
9
+ import { styles } from '../story-parts/styles.js';
10
+ import { slots, render as slotsRender } from '../story-parts/slots.js';
11
+ setCustomElementsManifest(customElementsManifest);
12
+ const meta = {
13
+ title: 'TimeredCounter',
14
+ component: 'timered-counter',
15
+ tags: ['autodocs', 'timered-counter'],
16
+ parameters: {
17
+ controls: { expanded: true },
18
+ },
19
+ beforeEach: () => {
20
+ setNumberAdapter('number');
21
+ },
22
+ globals: {
23
+ setByAttr,
24
+ setByProp,
25
+ },
26
+ };
27
+ export default meta;
28
+ export const Basic = {
29
+ args: {
30
+ className: 'test-target',
31
+ // @ts-ignore
32
+ value: '0',
33
+ animationOptions: {
34
+ duration: 100,
35
+ },
36
+ },
37
+ async play(context) {
38
+ const { canvasElement, step } = context;
39
+ const counter = canvasElement.querySelector('.test-target');
40
+ await step('Testing with attribute', async () => {
41
+ await valueChange(context, {
42
+ counter,
43
+ setBy: setByAttr,
44
+ });
45
+ await step('Edge case', async () => edgeCase(context, {
46
+ counter,
47
+ list: [
48
+ ['Setting an empty string', '', '0'],
49
+ ['Setting a non-number', 'a', '0'],
50
+ ['Setting a decimal number', '1.1', '1.1'],
51
+ ['Setting a negative number', '-1', '-1'],
52
+ ['Setting Infinity', 'Infinity', '0'],
53
+ ['Setting NaN', 'NaN', '0'],
54
+ ['Setting null', 'null', '0'],
55
+ ['Setting undefined', 'undefined', '0'],
56
+ ['Setting true', 'true', '0'],
57
+ ['Setting false', 'false', '0'],
58
+ ['Setting an object', '{}', '0'],
59
+ ['Setting an array', '[]', '0'],
60
+ ['Setting a function', '() => {}', '0'],
61
+ ['Setting a Symbol', 'Symbol()', '0'],
62
+ ['Setting a BigInt', 'BigInt(1)', '0'],
63
+ ],
64
+ setBy: setByAttr,
65
+ }));
66
+ });
67
+ await step('Testing with property', async () => {
68
+ await valueChange(context, { counter, setBy: setByProp });
69
+ await step('Edge case', async () => edgeCase(context, {
70
+ counter,
71
+ list: [
72
+ ['Setting an empty string', '', 0],
73
+ ['Setting a non-number', 'a', 0],
74
+ ['Setting a decimal number', '1.1', 1.1],
75
+ ['Setting a negative number', '-1', -1],
76
+ ['Setting Infinity', 'Infinity', 0],
77
+ ['Setting NaN', 'NaN', 0],
78
+ ['Setting null', 'null', 0],
79
+ ['Setting undefined', 'undefined', 0],
80
+ ['Setting true', 'true', 0],
81
+ ['Setting false', 'false', 0],
82
+ ['Setting an object', '{}', 0],
83
+ ['Setting an array', '[]', 0],
84
+ ['Setting a function', '() => {}', 0],
85
+ ['Setting a Symbol', 'Symbol()', 0],
86
+ ['Setting a BigInt', 'BigInt(1)', 0],
87
+ ],
88
+ setBy: setByProp,
89
+ }));
90
+ });
91
+ },
92
+ };
93
+ export const Events = {
94
+ args: {
95
+ className: 'test-target',
96
+ animationOptions: {
97
+ duration: 100,
98
+ },
99
+ },
100
+ async play(context) {
101
+ const { canvasElement, step } = context;
102
+ const counter = canvasElement.querySelector('.test-target');
103
+ await step('Testing with attribute', async () => {
104
+ await step('Animation events', async () => animationEvents(context, {
105
+ counter,
106
+ setBy: setByAttr,
107
+ }));
108
+ });
109
+ await step('Testing with property', async () => {
110
+ await step('Animation events', async () => animationEvents(context, {
111
+ counter,
112
+ setBy: setByProp,
113
+ }));
114
+ });
115
+ },
116
+ };
117
+ export const AnimationOptions = {
118
+ args: {
119
+ className: 'test-target',
120
+ animationOptions: {
121
+ duration: 100,
122
+ },
123
+ },
124
+ async play(context) {
125
+ const { canvasElement, step } = context;
126
+ const counter = canvasElement.querySelector('.test-target');
127
+ await step('Testing with attribute', async () => {
128
+ await step('Animation options', async () => animationOptions(context, {
129
+ counter,
130
+ setBy: setByAttr,
131
+ }));
132
+ });
133
+ // await step('Testing with property', async () => {
134
+ // await step('Animation options', async () =>
135
+ // animationOptions(context, {
136
+ // counter,
137
+ // list,
138
+ // setBy: setByProp,
139
+ // }),
140
+ // );
141
+ // });
142
+ },
143
+ };
144
+ export const Styles = {
145
+ args: {
146
+ className: 'test-target',
147
+ animationOptions: {
148
+ duration: 100,
149
+ },
150
+ },
151
+ async play(context) {
152
+ const { canvasElement, step } = context;
153
+ const counter = canvasElement.querySelector('.test-target');
154
+ await step('Testing with attribute', async () => {
155
+ await step('Styles', async () => styles(context, {
156
+ counter,
157
+ setBy: setByAttr,
158
+ }));
159
+ });
160
+ await step('Testing with property', async () => {
161
+ await step('Styles', async () => styles(context, {
162
+ counter,
163
+ setBy: setByProp,
164
+ }));
165
+ });
166
+ },
167
+ };
168
+ export const Slots = {
169
+ args: {
170
+ className: 'test-target',
171
+ value: 0,
172
+ },
173
+ render: slotsRender,
174
+ async play(context) {
175
+ const { canvasElement } = context;
176
+ const counter = canvasElement.querySelector('.test-target');
177
+ await slots(context, { counter });
178
+ },
179
+ };
180
+ //# sourceMappingURL=index.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter/index.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAkB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,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C;QAEpB,MAAM,IAAI,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;YAC9C,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAC9B,MAAM,CAAC,OAAO,EAAE;gBACd,OAAO;gBACP,KAAK,EAAE,SAAS;aACjB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;YAC7C,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAC9B,MAAM,CAAC,OAAO,EAAE;gBACd,OAAO;gBACP,KAAK,EAAE,SAAS;aACjB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAA6B;IAC7C,IAAI,EAAE;QACJ,SAAS,EAAE,aAAa;QACxB,KAAK,EAAE,CAAC;KACT;IACD,MAAM,EAAE,WAAW;IACnB,KAAK,CAAC,IAAI,CAAC,OAAO;QAChB,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;QAElC,MAAM,OAAO,GAAG,aAAa,CAAC,aAAa,CACzC,cAAc,CACG,CAAC;QAEpB,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport { setNumberAdapter, TimeredCounter } from '../../src/index.js';\nimport { setByAttr, setByProp } from '../utils/index.js';\nimport { valueChange } from '../story-parts/value-change.js';\nimport { edgeCase } from '../story-parts/edge-case.js';\nimport { animationEvents } from '../story-parts/animation-events.js';\nimport { animationOptions } from '../story-parts/animation-options.js';\nimport { styles } from '../story-parts/styles.js';\nimport { slots, render as slotsRender } from '../story-parts/slots.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nconst meta: Meta = {\n title: 'TimeredCounter',\n component: 'timered-counter',\n tags: ['autodocs', 'timered-counter'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n setNumberAdapter('number');\n },\n globals: {\n setByAttr,\n setByProp,\n },\n};\nexport default meta;\n\nexport const Basic: StoryObj<TimeredCounter> = {\n args: {\n className: 'test-target',\n // @ts-ignore\n value: '0',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await valueChange(context, {\n counter,\n setBy: setByAttr,\n });\n\n await step('Edge case', async () =>\n edgeCase(context, {\n counter,\n list: [\n ['Setting an empty string', '', '0'],\n ['Setting a non-number', 'a', '0'],\n ['Setting a decimal number', '1.1', '1.1'],\n ['Setting a negative number', '-1', '-1'],\n ['Setting Infinity', 'Infinity', '0'],\n ['Setting NaN', 'NaN', '0'],\n ['Setting null', 'null', '0'],\n ['Setting undefined', 'undefined', '0'],\n ['Setting true', 'true', '0'],\n ['Setting false', 'false', '0'],\n ['Setting an object', '{}', '0'],\n ['Setting an array', '[]', '0'],\n ['Setting a function', '() => {}', '0'],\n ['Setting a Symbol', 'Symbol()', '0'],\n ['Setting a BigInt', 'BigInt(1)', '0'],\n ],\n setBy: setByAttr,\n }),\n );\n });\n\n await step('Testing with property', async () => {\n await valueChange(context, { counter, setBy: setByProp });\n\n await step('Edge case', async () =>\n edgeCase(context, {\n counter,\n list: [\n ['Setting an empty string', '', 0],\n ['Setting a non-number', 'a', 0],\n ['Setting a decimal number', '1.1', 1.1],\n ['Setting a negative number', '-1', -1],\n ['Setting Infinity', 'Infinity', 0],\n ['Setting NaN', 'NaN', 0],\n ['Setting null', 'null', 0],\n ['Setting undefined', 'undefined', 0],\n ['Setting true', 'true', 0],\n ['Setting false', 'false', 0],\n ['Setting an object', '{}', 0],\n ['Setting an array', '[]', 0],\n ['Setting a function', '() => {}', 0],\n ['Setting a Symbol', 'Symbol()', 0],\n ['Setting a BigInt', 'BigInt(1)', 0],\n ],\n setBy: setByProp,\n }),\n );\n });\n },\n};\n\nexport const Events: StoryObj<TimeredCounter> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await step('Animation events', async () =>\n animationEvents(context, {\n counter,\n setBy: setByAttr,\n }),\n );\n });\n\n await step('Testing with property', async () => {\n await step('Animation events', async () =>\n animationEvents(context, {\n counter,\n setBy: setByProp,\n }),\n );\n });\n },\n};\n\nexport const AnimationOptions: StoryObj<TimeredCounter> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await step('Animation options', async () =>\n animationOptions(context, {\n counter,\n setBy: setByAttr,\n }),\n );\n });\n\n // await step('Testing with property', async () => {\n // await step('Animation options', async () =>\n // animationOptions(context, {\n // counter,\n // list,\n // setBy: setByProp,\n // }),\n // );\n // });\n },\n};\n\nexport const Styles: StoryObj<TimeredCounter> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await step('Styles', async () =>\n styles(context, {\n counter,\n setBy: setByAttr,\n }),\n );\n });\n\n await step('Testing with property', async () => {\n await step('Styles', async () =>\n styles(context, {\n counter,\n setBy: setByProp,\n }),\n );\n });\n },\n};\n\nexport const Slots: StoryObj<TimeredCounter> = {\n args: {\n className: 'test-target',\n value: 0,\n },\n render: slotsRender,\n async play(context) {\n const { canvasElement } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await slots(context, { counter });\n },\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import { Meta, StoryObj } from '@storybook/web-components';
2
+ import { TimeredCounterDatetimeDuration } from '../../src/index.js';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Basic: StoryObj<TimeredCounterDatetimeDuration>;
6
+ export declare const Precision: StoryObj<TimeredCounterDatetimeDuration>;
7
+ export declare const Locale: StoryObj<TimeredCounterDatetimeDuration>;
@@ -0,0 +1,95 @@
1
+ import { setCustomElementsManifest, } from '@storybook/web-components';
2
+ import { isArray, isDate, range } from 'remeda';
3
+ import { addDays, addHours, addMinutes, addMonths, addSeconds, addYears, differenceInMilliseconds, } from 'date-fns';
4
+ import { expect } from '@storybook/test';
5
+ import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
6
+ import { setNumberAdapter, } from '../../src/index.js';
7
+ import { valueChange } from '../story-parts/value-change.js';
8
+ import { datetimePrecision } from '../story-parts/datetime-precision.js';
9
+ import { datetimeLocale } from '../story-parts/datetime-locale.js';
10
+ setCustomElementsManifest(customElementsManifest);
11
+ function setByAttr(element, attr, value) {
12
+ if (isArray(value)) {
13
+ if (isDate(value[0]) && isDate(value[1])) {
14
+ element.setAttribute(attr, JSON.stringify(value.map(date => date.getTime())));
15
+ }
16
+ }
17
+ else {
18
+ element.setAttribute(attr, value);
19
+ }
20
+ }
21
+ function setByProp(element, prop, value) {
22
+ // @ts-ignore
23
+ element[prop] = value;
24
+ }
25
+ function equal(counter, a, b) {
26
+ const na = counter.numberAdapter;
27
+ return expect(na.toString(a)).toBe(na.toString(na.create(differenceInMilliseconds(b[1], b[0]))));
28
+ }
29
+ const meta = {
30
+ title: 'TimeredCounterDatetimeDuration',
31
+ component: 'timered-counter-datetime-duration',
32
+ tags: ['autodocs', 'timered-counter-datetime-duration'],
33
+ parameters: {
34
+ controls: { expanded: true },
35
+ },
36
+ beforeEach: () => {
37
+ setNumberAdapter('number');
38
+ },
39
+ };
40
+ export default meta;
41
+ export const Basic = {
42
+ args: {
43
+ className: 'test-target',
44
+ animationOptions: {
45
+ duration: 100,
46
+ },
47
+ },
48
+ async play(context) {
49
+ const { canvasElement, step } = context;
50
+ const counter = canvasElement.querySelector('.test-target');
51
+ const list = [
52
+ ...range(0, 2).map(v => [new Date(), addSeconds(new Date(), v)]),
53
+ ...range(0, 2).map(v => [new Date(), addMinutes(new Date(), v)]),
54
+ ...range(0, 2).map(v => [new Date(), addHours(new Date(), v)]),
55
+ ...range(0, 2).map(v => [new Date(), addDays(new Date(), v)]),
56
+ ...range(0, 2).map(v => [new Date(), addMonths(new Date(), v)]),
57
+ ...range(0, 2).map(v => [new Date(), addYears(new Date(), v)]),
58
+ ];
59
+ await step('Testing with attribute', async () => {
60
+ await valueChange(context, { counter, list, setBy: setByAttr, equal });
61
+ });
62
+ await step('Testing with property', async () => {
63
+ await valueChange(context, { counter, list, setBy: setByProp, equal });
64
+ });
65
+ },
66
+ };
67
+ export const Precision = {
68
+ args: {
69
+ className: 'test-target',
70
+ animationOptions: {
71
+ duration: 100,
72
+ },
73
+ },
74
+ async play(context) {
75
+ const { canvasElement, step } = context;
76
+ const counter = canvasElement.querySelector('.test-target');
77
+ await step('Testing with attribute', async () => datetimePrecision(context, { counter, setBy: setByAttr, equal }));
78
+ await step('Testing with property', async () => datetimePrecision(context, { counter, setBy: setByProp, equal }));
79
+ },
80
+ };
81
+ export const Locale = {
82
+ args: {
83
+ className: 'test-target',
84
+ animationOptions: {
85
+ duration: 100,
86
+ },
87
+ },
88
+ async play(context) {
89
+ const { canvasElement, step } = context;
90
+ const counter = canvasElement.querySelector('.test-target');
91
+ await step('Testing with attribute', () => datetimeLocale(context, { counter, setBy: setByAttr, equal }));
92
+ await step('Testing with property', () => datetimeLocale(context, { counter, setBy: setByProp, equal }));
93
+ },
94
+ };
95
+ //# sourceMappingURL=index.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-datetime-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ACvC,cAAc,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAC9D,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport { isArray, isDate, range } from 'remeda';\nimport {\n addDays,\n addHours,\n addMinutes,\n addMonths,\n addSeconds,\n addYears,\n differenceInMilliseconds,\n} from 'date-fns';\nimport { expect } from '@storybook/test';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n setNumberAdapter,\n type TimeredCounter,\n TimeredCounterDatetimeDuration,\n} from '../../src/index.js';\nimport { valueChange } from '../story-parts/value-change.js';\nimport { datetimePrecision } from '../story-parts/datetime-precision.js';\nimport { datetimeLocale } from '../story-parts/datetime-locale.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nfunction setByAttr(\n element: TimeredCounter,\n attr: string,\n value: Date[] | string,\n) {\n if (isArray(value)) {\n if (isDate(value[0]) && isDate(value[1])) {\n element.setAttribute(\n attr,\n JSON.stringify((value as Date[]).map(date => date.getTime())),\n );\n }\n } else {\n element.setAttribute(attr, value);\n }\n}\n\nfunction setByProp(element: TimeredCounter, prop: string, value: any) {\n // @ts-ignore\n element[prop] = value;\n}\n\nfunction equal(counter: TimeredCounter, a: any, b: Date[]) {\n const na = counter.numberAdapter;\n return expect(na.toString(a)).toBe(\n na.toString(na.create(differenceInMilliseconds(b[1], b[0]))),\n );\n}\n\nconst meta: Meta = {\n title: 'TimeredCounterDatetimeDuration',\n component: 'timered-counter-datetime-duration',\n tags: ['autodocs', 'timered-counter-datetime-duration'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n setNumberAdapter('number');\n },\n};\nexport default meta;\n\nexport const Basic: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n const list = [\n ...range(0, 2).map(v => [new Date(), addSeconds(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addMinutes(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addHours(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addDays(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addMonths(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addYears(new Date(), v)]),\n ];\n\n await step('Testing with attribute', async () => {\n await valueChange(context, { counter, list, setBy: setByAttr, equal });\n });\n\n await step('Testing with property', async () => {\n await valueChange(context, { counter, list, setBy: setByProp, equal });\n });\n },\n};\n\nexport const Precision: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n await step('Testing with attribute', async () =>\n datetimePrecision(context, { counter, setBy: setByAttr, equal }),\n );\n await step('Testing with property', async () =>\n datetimePrecision(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n\nexport const Locale: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n await step('Testing with attribute', () =>\n datetimeLocale(context, { counter, setBy: setByAttr, equal }),\n );\n await step('Testing with property', () =>\n datetimeLocale(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from '@storybook/web-components';
2
+ import { TimeredCounterNumber } from '../../src/index.js';
3
+ export { Basic, Events, Styles, LocaleNumber, AnimationOptions, } from './index.stories.js';
4
+ declare const meta: Meta;
5
+ export default meta;
6
+ export declare const BigNumber: StoryObj<TimeredCounterNumber>;
@@ -0,0 +1,34 @@
1
+ import { setCustomElementsManifest, } from '@storybook/web-components';
2
+ import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
3
+ import { setNumberAdapter, } from '../../src/index.js';
4
+ import { setByAttr, setByProp } from '../utils/index.js';
5
+ import { bigNumber } from '../story-parts/big-number.js';
6
+ export { Basic, Events, Styles, LocaleNumber, AnimationOptions, } from './index.stories.js';
7
+ setCustomElementsManifest(customElementsManifest);
8
+ const meta = {
9
+ title: 'TimeredCounterNumber/with decimal.js',
10
+ component: 'timered-counter-number',
11
+ tags: ['autodocs', 'timered-counter-number'],
12
+ parameters: {
13
+ controls: { expanded: true },
14
+ },
15
+ beforeEach: () => {
16
+ setNumberAdapter('decimal.js');
17
+ },
18
+ };
19
+ export default meta;
20
+ export const BigNumber = {
21
+ args: {
22
+ className: 'test-target',
23
+ animationOptions: {
24
+ duration: 100,
25
+ },
26
+ },
27
+ async play(context) {
28
+ const { canvasElement, step } = context;
29
+ const counter = canvasElement.querySelector('.test-target');
30
+ await step('Testing with attribute', async () => bigNumber(context, { counter, setBy: setByAttr }));
31
+ await step('Testing with property', async () => bigNumber(context, { counter, setBy: setByProp }));
32
+ },
33
+ };
34
+ //# sourceMappingURL=decimaljs.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimaljs.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-number/decimaljs.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EACL,gBAAgB,GAGjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,YAAY,EACZ,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;AAElD,MAAM,IAAI,GAAS;IACjB,KAAK,EAAE,sCAAsC;IAC7C,SAAS,EAAE,wBAAwB;IACnC,IAAI,EAAE,CAAC,UAAU,EAAE,wBAAwB,CAAC;IAC5C,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC7B;IACD,UAAU,EAAE,GAAG,EAAE;QACf,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;CACF,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAmC;IACvD,IAAI,EAAE;QACJ,SAAS,EAAE,aAAa;QACxB,gBAAgB,EAAE;YAChB,QAAQ,EAAE,GAAG;SACd;KACF;IACD,KAAK,CAAC,IAAI,CAAC,OAAO;QAChB,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACxC,MAAM,OAAO,GAAG,aAAa,CAAC,aAAa,CACzC,cAAc,CACG,CAAC;QAEpB,MAAM,IAAI,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE,CAC9C,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAClD,CAAC;QAEF,MAAM,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAC7C,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAClD,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n setNumberAdapter,\n type TimeredCounter,\n TimeredCounterNumber,\n} from '../../src/index.js';\nimport { setByAttr, setByProp } from '../utils/index.js';\nimport { bigNumber } from '../story-parts/big-number.js';\n\nexport {\n Basic,\n Events,\n Styles,\n LocaleNumber,\n AnimationOptions,\n} from './index.stories.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nconst meta: Meta = {\n title: 'TimeredCounterNumber/with decimal.js',\n component: 'timered-counter-number',\n tags: ['autodocs', 'timered-counter-number'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n setNumberAdapter('decimal.js');\n },\n};\nexport default meta;\n\nexport const BigNumber: StoryObj<TimeredCounterNumber> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () =>\n bigNumber(context, { counter, setBy: setByAttr }),\n );\n\n await step('Testing with property', async () =>\n bigNumber(context, { counter, setBy: setByProp }),\n );\n },\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from '@storybook/web-components';
2
+ import { TimeredCounterNumber } from '../../src/index.js';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Basic: StoryObj<TimeredCounterNumber>;
6
+ export declare const Events: StoryObj<TimeredCounterNumber>;
7
+ export declare const AnimationOptions: StoryObj<TimeredCounterNumber>;
8
+ export declare const Styles: StoryObj<TimeredCounterNumber>;
9
+ export declare const LocaleNumber: StoryObj<TimeredCounterNumber>;
@@ -0,0 +1,188 @@
1
+ import { setCustomElementsManifest, } from '@storybook/web-components';
2
+ import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
3
+ import { setNumberAdapter, } from '../../src/index.js';
4
+ import { valueChange } from '../story-parts/value-change.js';
5
+ import { setByAttr, setByProp } from '../utils/index.js';
6
+ import { edgeCase } from '../story-parts/edge-case.js';
7
+ import { animationEvents } from '../story-parts/animation-events.js';
8
+ import { animationOptions } from '../story-parts/animation-options.js';
9
+ import { styles } from '../story-parts/styles.js';
10
+ import { localeNumber } from '../story-parts/locale-number.js';
11
+ setCustomElementsManifest(customElementsManifest);
12
+ const meta = {
13
+ title: 'TimeredCounterNumber',
14
+ component: 'timered-counter-number',
15
+ tags: ['autodocs', 'timered-counter-number'],
16
+ parameters: {
17
+ controls: { expanded: true },
18
+ },
19
+ beforeEach: () => {
20
+ setNumberAdapter('number');
21
+ },
22
+ };
23
+ export default meta;
24
+ export const Basic = {
25
+ args: {
26
+ className: 'test-target',
27
+ // @ts-ignore
28
+ value: '0',
29
+ animationOptions: {
30
+ duration: 100,
31
+ },
32
+ },
33
+ async play(context) {
34
+ const { canvasElement, step } = context;
35
+ const counter = canvasElement.querySelector('.test-target');
36
+ await step('Testing with attribute', async () => {
37
+ await valueChange(context, {
38
+ counter,
39
+ setBy: setByAttr,
40
+ });
41
+ await step('Edge case', async () => edgeCase(context, {
42
+ counter,
43
+ list: [
44
+ ['Setting an empty string', '', '0'],
45
+ ['Setting a non-number', 'a', '0'],
46
+ ['Setting a decimal number', '1.1', '1.1'],
47
+ ['Setting a negative number', '-1', '-1'],
48
+ ['Setting Infinity', 'Infinity', '0'],
49
+ ['Setting NaN', 'NaN', '0'],
50
+ ['Setting null', 'null', '0'],
51
+ ['Setting undefined', 'undefined', '0'],
52
+ ['Setting true', 'true', '0'],
53
+ ['Setting false', 'false', '0'],
54
+ ['Setting an object', '{}', '0'],
55
+ ['Setting an array', '[]', '0'],
56
+ ['Setting a function', '() => {}', '0'],
57
+ ['Setting a Symbol', 'Symbol()', '0'],
58
+ ['Setting a BigInt', 'BigInt(1)', '0'],
59
+ ],
60
+ setBy: setByAttr,
61
+ }));
62
+ });
63
+ await step('Testing with property', async () => {
64
+ await valueChange(context, { counter, setBy: setByProp });
65
+ await step('Edge case', async () => edgeCase(context, {
66
+ counter,
67
+ list: [
68
+ ['Setting an empty string', '', 0],
69
+ ['Setting a non-number', 'a', 0],
70
+ ['Setting a decimal number', '1.1', 1.1],
71
+ ['Setting a negative number', '-1', -1],
72
+ ['Setting Infinity', 'Infinity', 0],
73
+ ['Setting NaN', 'NaN', 0],
74
+ ['Setting null', 'null', 0],
75
+ ['Setting undefined', 'undefined', 0],
76
+ ['Setting true', 'true', 0],
77
+ ['Setting false', 'false', 0],
78
+ ['Setting an object', '{}', 0],
79
+ ['Setting an array', '[]', 0],
80
+ ['Setting a function', '() => {}', 0],
81
+ ['Setting a Symbol', 'Symbol()', 0],
82
+ ['Setting a BigInt', 'BigInt(1)', 0],
83
+ ],
84
+ setBy: setByProp,
85
+ }));
86
+ });
87
+ },
88
+ };
89
+ export const Events = {
90
+ args: {
91
+ className: 'test-target',
92
+ animationOptions: {
93
+ duration: 100,
94
+ },
95
+ },
96
+ async play(context) {
97
+ const { canvasElement, step } = context;
98
+ const counter = canvasElement.querySelector('.test-target');
99
+ await step('Testing with attribute', async () => {
100
+ await step('Animation events', async () => animationEvents(context, {
101
+ counter,
102
+ setBy: setByAttr,
103
+ }));
104
+ });
105
+ await step('Testing with property', async () => {
106
+ await step('Animation events', async () => animationEvents(context, {
107
+ counter,
108
+ setBy: setByProp,
109
+ }));
110
+ });
111
+ },
112
+ };
113
+ export const AnimationOptions = {
114
+ args: {
115
+ className: 'test-target',
116
+ animationOptions: {
117
+ duration: 100,
118
+ },
119
+ },
120
+ async play(context) {
121
+ const { canvasElement, step } = context;
122
+ const counter = canvasElement.querySelector('.test-target');
123
+ await step('Testing with attribute', async () => {
124
+ await step('Animation options', async () => animationOptions(context, {
125
+ counter,
126
+ setBy: setByAttr,
127
+ }));
128
+ });
129
+ // await step('Testing with property', async () => {
130
+ // await step('Animation options', async () =>
131
+ // animationOptions(context, {
132
+ // counter,
133
+ // list,
134
+ // setBy: setByProp,
135
+ // }),
136
+ // );
137
+ // });
138
+ },
139
+ };
140
+ export const Styles = {
141
+ args: {
142
+ className: 'test-target',
143
+ animationOptions: {
144
+ duration: 100,
145
+ },
146
+ },
147
+ async play(context) {
148
+ const { canvasElement, step } = context;
149
+ const counter = canvasElement.querySelector('.test-target');
150
+ await step('Testing with attribute', async () => {
151
+ await step('Styles', async () => styles(context, {
152
+ counter,
153
+ setBy: setByAttr,
154
+ }));
155
+ });
156
+ await step('Testing with property', async () => {
157
+ await step('Styles', async () => styles(context, {
158
+ counter,
159
+ setBy: setByProp,
160
+ }));
161
+ });
162
+ },
163
+ };
164
+ export const LocaleNumber = {
165
+ args: {
166
+ className: 'test-target',
167
+ animationOptions: {
168
+ duration: 100,
169
+ },
170
+ },
171
+ async play(context) {
172
+ const { canvasElement, step } = context;
173
+ const counter = canvasElement.querySelector('.test-target');
174
+ await step('Testing with attribute', async () => {
175
+ await step('Locale number', async () => localeNumber(context, {
176
+ counter,
177
+ setBy: setByAttr,
178
+ }));
179
+ });
180
+ await step('Testing with property', async () => {
181
+ await step('Locale number', async () => localeNumber(context, {
182
+ counter,
183
+ setBy: setByProp,
184
+ }));
185
+ });
186
+ },
187
+ };
188
+ //# sourceMappingURL=index.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-number/index.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EACL,gBAAgB,GAGjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,yB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I,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;YAC7C,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAC9B,MAAM,CAAC,OAAO,EAAE;gBACd,OAAO;gBACP,KAAK,EAAE,SAAS;aACjB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAmC;IAC1D,IAAI,EAAE;QACJ,SAAS,EAAE,aAAa;QACxB,gBAAgB,EAAE;YAChB,QAAQ,EAAE,GAAG;SACd;KACF;IACD,KAAK,CAAC,IAAI,CAAC,OAAO;QAChB,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACxC,MAAM,OAAO,GAAG,aAAa,CAAC,aAAa,CACzC,cAAc,CACG,CAAC;QAEpB,MAAM,IAAI,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;YAC9C,MAAM,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CACrC,YAAY,CAAC,OAAO,EAAE;gBACpB,OAAO;gBACP,KAAK,EAAE,SAAS;aACjB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;YAC7C,MAAM,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CACrC,YAAY,CAAC,OAAO,EAAE;gBACpB,OAAO;gBACP,KAAK,EAAE,SAAS;aACjB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n setNumberAdapter,\n type TimeredCounter,\n TimeredCounterNumber,\n} from '../../src/index.js';\nimport { valueChange } from '../story-parts/value-change.js';\nimport { setByAttr, setByProp } from '../utils/index.js';\nimport { edgeCase } from '../story-parts/edge-case.js';\nimport { animationEvents } from '../story-parts/animation-events.js';\nimport { animationOptions } from '../story-parts/animation-options.js';\nimport { styles } from '../story-parts/styles.js';\nimport { localeNumber } from '../story-parts/locale-number.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nconst meta: Meta = {\n title: 'TimeredCounterNumber',\n component: 'timered-counter-number',\n tags: ['autodocs', 'timered-counter-number'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n setNumberAdapter('number');\n },\n};\nexport default meta;\n\nexport const Basic: StoryObj<TimeredCounterNumber> = {\n args: {\n className: 'test-target',\n // @ts-ignore\n value: '0',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await valueChange(context, {\n counter,\n setBy: setByAttr,\n });\n\n await step('Edge case', async () =>\n edgeCase(context, {\n counter,\n list: [\n ['Setting an empty string', '', '0'],\n ['Setting a non-number', 'a', '0'],\n ['Setting a decimal number', '1.1', '1.1'],\n ['Setting a negative number', '-1', '-1'],\n ['Setting Infinity', 'Infinity', '0'],\n ['Setting NaN', 'NaN', '0'],\n ['Setting null', 'null', '0'],\n ['Setting undefined', 'undefined', '0'],\n ['Setting true', 'true', '0'],\n ['Setting false', 'false', '0'],\n ['Setting an object', '{}', '0'],\n ['Setting an array', '[]', '0'],\n ['Setting a function', '() => {}', '0'],\n ['Setting a Symbol', 'Symbol()', '0'],\n ['Setting a BigInt', 'BigInt(1)', '0'],\n ],\n setBy: setByAttr,\n }),\n );\n });\n\n await step('Testing with property', async () => {\n await valueChange(context, { counter, setBy: setByProp });\n\n await step('Edge case', async () =>\n edgeCase(context, {\n counter,\n list: [\n ['Setting an empty string', '', 0],\n ['Setting a non-number', 'a', 0],\n ['Setting a decimal number', '1.1', 1.1],\n ['Setting a negative number', '-1', -1],\n ['Setting Infinity', 'Infinity', 0],\n ['Setting NaN', 'NaN', 0],\n ['Setting null', 'null', 0],\n ['Setting undefined', 'undefined', 0],\n ['Setting true', 'true', 0],\n ['Setting false', 'false', 0],\n ['Setting an object', '{}', 0],\n ['Setting an array', '[]', 0],\n ['Setting a function', '() => {}', 0],\n ['Setting a Symbol', 'Symbol()', 0],\n ['Setting a BigInt', 'BigInt(1)', 0],\n ],\n setBy: setByProp,\n }),\n );\n });\n },\n};\n\nexport const Events: StoryObj<TimeredCounterNumber> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await step('Animation events', async () =>\n animationEvents(context, {\n counter,\n setBy: setByAttr,\n }),\n );\n });\n\n await step('Testing with property', async () => {\n await step('Animation events', async () =>\n animationEvents(context, {\n counter,\n setBy: setByProp,\n }),\n );\n });\n },\n};\n\nexport const AnimationOptions: StoryObj<TimeredCounterNumber> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await step('Animation options', async () =>\n animationOptions(context, {\n counter,\n setBy: setByAttr,\n }),\n );\n });\n\n // await step('Testing with property', async () => {\n // await step('Animation options', async () =>\n // animationOptions(context, {\n // counter,\n // list,\n // setBy: setByProp,\n // }),\n // );\n // });\n },\n};\n\nexport const Styles: StoryObj<TimeredCounterNumber> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await step('Styles', async () =>\n styles(context, {\n counter,\n setBy: setByAttr,\n }),\n );\n });\n\n await step('Testing with property', async () => {\n await step('Styles', async () =>\n styles(context, {\n counter,\n setBy: setByProp,\n }),\n );\n });\n },\n};\n\nexport const LocaleNumber: StoryObj<TimeredCounterNumber> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n await step('Testing with attribute', async () => {\n await step('Locale number', async () =>\n localeNumber(context, {\n counter,\n setBy: setByAttr,\n }),\n );\n });\n\n await step('Testing with property', async () => {\n await step('Locale number', async () =>\n localeNumber(context, {\n counter,\n setBy: setByProp,\n }),\n );\n });\n },\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import { Meta, StoryObj } from '@storybook/web-components';
2
+ import { TimeredCounterString } from '../../src/index.js';
3
+ export { Basic, AnimationOptions, Styles, Emoji } from './index.stories.js';
4
+ declare const meta: Meta;
5
+ export default meta;
6
+ export declare const Events: StoryObj<TimeredCounterString>;
7
+ export declare const BigNumber: StoryObj<TimeredCounterString>;