timered-counter 1.0.0 → 1.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/custom-elements.json +253 -103
- package/dist/custom-elements.json +253 -103
- package/dist/decimal-js-number-adapter.esm-browser.js +9 -0
- package/dist/decimal-js-number-adapter.esm-browser.js.map +1 -0
- package/dist/decimal-js-number-adapter.global.js +10 -0
- package/dist/decimal-js-number-adapter.global.js.map +1 -0
- package/dist/grapheme-splitter-string-adapter.esm-browser.js +2 -0
- package/dist/grapheme-splitter-string-adapter.esm-browser.js.map +1 -0
- package/dist/grapheme-splitter-string-adapter.global.js +2 -0
- package/dist/grapheme-splitter-string-adapter.global.js.map +1 -0
- package/dist/src/index.d.ts +1 -5
- package/dist/src/index.js +1 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/mixins/counter-base.js +9 -9
- package/dist/src/mixins/counter-base.js.map +1 -1
- package/dist/src/number-adapter/decimal-js.d.ts +8 -1
- package/dist/src/number-adapter/decimal-js.js +7 -0
- package/dist/src/number-adapter/decimal-js.js.map +1 -1
- package/dist/src/number-adapter/index.d.ts +6 -4
- package/dist/src/number-adapter/index.js +7 -4
- package/dist/src/number-adapter/index.js.map +1 -1
- package/dist/src/string-adapter/grapheme-splitter.d.ts +7 -0
- package/dist/src/string-adapter/grapheme-splitter.js +7 -0
- package/dist/src/string-adapter/grapheme-splitter.js.map +1 -1
- package/dist/src/string-adapter/index.d.ts +6 -4
- package/dist/src/string-adapter/index.js +7 -4
- package/dist/src/string-adapter/index.js.map +1 -1
- package/dist/src/timered-counter-adapter.d.ts +65 -0
- package/dist/src/timered-counter-adapter.js +120 -0
- package/dist/src/timered-counter-adapter.js.map +1 -0
- package/dist/src/transitions/roller/roller-digit.js +3 -3
- package/dist/src/transitions/roller/roller-digit.js.map +1 -1
- package/dist/src/transitions/roller/roller.js +1 -1
- package/dist/src/transitions/roller/roller.js.map +1 -1
- package/dist/stories/timered-counter/decimaljs.stories.js +4 -2
- package/dist/stories/timered-counter/decimaljs.stories.js.map +1 -1
- package/dist/stories/timered-counter-number/decimaljs.stories.js +4 -2
- package/dist/stories/timered-counter-number/decimaljs.stories.js.map +1 -1
- package/dist/stories/timered-counter-string/decimaljs.stories.js +4 -2
- package/dist/stories/timered-counter-string/decimaljs.stories.js.map +1 -1
- package/dist/stories/timered-counter-string/grapheme-splitter.stories.js +7 -3
- package/dist/stories/timered-counter-string/grapheme-splitter.stories.js.map +1 -1
- package/dist/stories/timered-counter-string/intl-segmenter.stories.js +5 -3
- package/dist/stories/timered-counter-string/intl-segmenter.stories.js.map +1 -1
- package/dist/timered-counter.esm-browser.js +51 -58
- package/dist/timered-counter.esm-browser.js.map +1 -1
- package/dist/timered-counter.global.js +51 -58
- package/dist/timered-counter.global.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/counter-adapter.d.ts +0 -38
- package/dist/src/counter-adapter.js +0 -71
- package/dist/src/counter-adapter.js.map +0 -1
@@ -3,7 +3,8 @@ import { expect } from '@storybook/test';
|
|
3
3
|
import { range } from 'remeda';
|
4
4
|
import { faker } from '@faker-js/faker';
|
5
5
|
import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
|
6
|
-
import {
|
6
|
+
import { TimeredCounterAdapter, } from '../../src/index.js';
|
7
|
+
import DecimalJsNumberAdapter from '../../src/number-adapter/decimal-js.js';
|
7
8
|
import { bigNumber } from '../story-parts/big-number.js';
|
8
9
|
import { setByAttr, setByProp } from '../utils/index.js';
|
9
10
|
import { animationEvents } from '../story-parts/animation-events.js';
|
@@ -21,7 +22,8 @@ const meta = {
|
|
21
22
|
controls: { expanded: true },
|
22
23
|
},
|
23
24
|
beforeEach: () => {
|
24
|
-
|
25
|
+
TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter);
|
26
|
+
TimeredCounterAdapter.setNumberAdapter('decimal.js');
|
25
27
|
},
|
26
28
|
};
|
27
29
|
export default meta;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"decimaljs.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-string/decimaljs.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EACL,
|
1
|
+
{"version":3,"file":"decimaljs.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-string/decimaljs.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EACL,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE5E,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;AAElD,SAAS,KAAK,CAAC,OAAuB,EAAE,CAAM,EAAE,C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AE,KAAK,EAAE,CAAC,CACrE,CAAC;QAEF,MAAM,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CACvC,eAAe,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACrE,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,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,KAAK,EAAE,CAAC,CACzD,CAAC;QAEF,MAAM,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAC7C,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACzD,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport { expect } from '@storybook/test';\nimport { range } from 'remeda';\nimport { faker } from '@faker-js/faker';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n TimeredCounterAdapter,\n type TimeredCounter,\n TimeredCounterString,\n} from '../../src/index.js';\nimport DecimalJsNumberAdapter from '../../src/number-adapter/decimal-js.js';\n\nimport { bigNumber } from '../story-parts/big-number.js';\nimport { setByAttr, setByProp } from '../utils/index.js';\nimport { animationEvents } from '../story-parts/animation-events.js';\n\nexport { Basic, AnimationOptions, Styles, Emoji } from './index.stories.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nfunction equal(counter: TimeredCounter, a: any, b: any) {\n a = counter.getAttribute('aria-label')?.replaceAll(/\\s/g, ' ');\n return expect(a).toBe(b.toString());\n}\n\nconst meta: Meta = {\n title: 'TimeredCounterString/with decimal.js',\n component: 'timered-counter-string',\n tags: ['autodocs', 'timered-counter-string'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter);\n TimeredCounterAdapter.setNumberAdapter('decimal.js');\n },\n};\nexport default meta;\n\nexport const Events: StoryObj<TimeredCounterString> = {\n args: {\n className: 'test-target',\n animationOptions: { duration: 100 },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n const list = range(0, 5).map(() =>\n faker.lorem.sentence({ min: 1, max: 2 }),\n );\n\n await step('Testing with attribute', () =>\n animationEvents(context, { counter, list, setBy: setByAttr, equal }),\n );\n\n await step('Testing with property', () =>\n animationEvents(context, { counter, list, setBy: setByProp, equal }),\n );\n },\n};\n\nexport const BigNumber: StoryObj<TimeredCounterString> = {\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, equal }),\n );\n\n await step('Testing with property', async () =>\n bigNumber(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n"]}
|
@@ -3,7 +3,9 @@ import { expect } from '@storybook/test';
|
|
3
3
|
import { range } from 'remeda';
|
4
4
|
import { faker } from '@faker-js/faker';
|
5
5
|
import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
|
6
|
-
import {
|
6
|
+
import { TimeredCounterAdapter, } from '../../src/index.js';
|
7
|
+
import DecimalJsNumberAdapter from '../../src/number-adapter/decimal-js.js';
|
8
|
+
import GraphemeSplitterStringAdapter from '../../src/string-adapter/grapheme-splitter.js';
|
7
9
|
import { bigNumber } from '../story-parts/big-number.js';
|
8
10
|
import { setByAttr, setByProp } from '../utils/index.js';
|
9
11
|
import { animationEvents } from '../story-parts/animation-events.js';
|
@@ -21,8 +23,10 @@ const meta = {
|
|
21
23
|
controls: { expanded: true },
|
22
24
|
},
|
23
25
|
beforeEach: () => {
|
24
|
-
|
25
|
-
|
26
|
+
TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter);
|
27
|
+
TimeredCounterAdapter.registryAdapter(GraphemeSplitterStringAdapter);
|
28
|
+
TimeredCounterAdapter.setNumberAdapter('decimal.js');
|
29
|
+
TimeredCounterAdapter.setStringAdapter('grapheme-splitter');
|
26
30
|
},
|
27
31
|
};
|
28
32
|
export default meta;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"grapheme-splitter.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-string/grapheme-splitter.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EACL,
|
1
|
+
{"version":3,"file":"grapheme-splitter.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-string/grapheme-splitter.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,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AAM,IAAI,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE,CAC9C,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACzD,CAAC;QAEF,MAAM,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAC7C,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACzD,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport { expect } from '@storybook/test';\nimport { range } from 'remeda';\nimport { faker } from '@faker-js/faker';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n TimeredCounterAdapter,\n type TimeredCounter,\n TimeredCounterString,\n} from '../../src/index.js';\nimport DecimalJsNumberAdapter from '../../src/number-adapter/decimal-js.js';\nimport GraphemeSplitterStringAdapter from '../../src/string-adapter/grapheme-splitter.js';\nimport { bigNumber } from '../story-parts/big-number.js';\nimport { setByAttr, setByProp } from '../utils/index.js';\nimport { animationEvents } from '../story-parts/animation-events.js';\n\nexport { Basic, AnimationOptions, Styles, Emoji } from './index.stories.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nfunction equal(counter: TimeredCounter, a: any, b: any) {\n a = counter.getAttribute('aria-label')?.replaceAll(/\\s/g, ' ');\n return expect(a).toBe(b.toString());\n}\n\nconst meta: Meta = {\n title: 'TimeredCounterString/with grapheme-splitter',\n component: 'timered-counter-string',\n tags: ['autodocs', 'timered-counter-string'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter);\n TimeredCounterAdapter.registryAdapter(GraphemeSplitterStringAdapter);\n\n TimeredCounterAdapter.setNumberAdapter('decimal.js');\n TimeredCounterAdapter.setStringAdapter('grapheme-splitter');\n },\n};\nexport default meta;\n\nexport const Events: StoryObj<TimeredCounterString> = {\n args: {\n className: 'test-target',\n animationOptions: { duration: 100 },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n const list = range(0, 5).map(() =>\n faker.lorem.sentence({ min: 1, max: 2 }),\n );\n\n await step('Testing with attribute', () =>\n animationEvents(context, { counter, list, setBy: setByAttr, equal }),\n );\n\n await step('Testing with property', () =>\n animationEvents(context, { counter, list, setBy: setByProp, equal }),\n );\n },\n};\n\nexport const BigNumber: StoryObj<TimeredCounterString> = {\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, equal }),\n );\n\n await step('Testing with property', async () =>\n bigNumber(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n"]}
|
@@ -3,7 +3,8 @@ import { expect } from '@storybook/test';
|
|
3
3
|
import { range } from 'remeda';
|
4
4
|
import { faker } from '@faker-js/faker';
|
5
5
|
import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
|
6
|
-
import {
|
6
|
+
import { TimeredCounterAdapter, } from '../../src/index.js';
|
7
|
+
import DecimalJsNumberAdapter from '../../src/number-adapter/decimal-js.js';
|
7
8
|
import { bigNumber } from '../story-parts/big-number.js';
|
8
9
|
import { setByAttr, setByProp } from '../utils/index.js';
|
9
10
|
import { animationEvents } from '../story-parts/animation-events.js';
|
@@ -21,8 +22,9 @@ const meta = {
|
|
21
22
|
controls: { expanded: true },
|
22
23
|
},
|
23
24
|
beforeEach: () => {
|
24
|
-
|
25
|
-
|
25
|
+
TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter);
|
26
|
+
TimeredCounterAdapter.setNumberAdapter('decimal.js');
|
27
|
+
TimeredCounterAdapter.setStringAdapter('intl-segmenter');
|
26
28
|
},
|
27
29
|
};
|
28
30
|
export default meta;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"intl-segmenter.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-string/intl-segmenter.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EACL,
|
1
|
+
{"version":3,"file":"intl-segmenter.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-string/intl-segmenter.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,sBAAsB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtF,OAAO,EACL,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE5E,yBAAyB,CAAC,sBAAsB,CAAC,CAAC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wBAAwB,EAAE,GAAG,EAAE,CACxC,eAAe,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACrE,CAAC;QAEF,MAAM,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CACvC,eAAe,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACrE,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,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,KAAK,EAAE,CAAC,CACzD,CAAC;QAEF,MAAM,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAC7C,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACzD,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport { expect } from '@storybook/test';\nimport { range } from 'remeda';\nimport { faker } from '@faker-js/faker';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n TimeredCounterAdapter,\n type TimeredCounter,\n TimeredCounterString,\n} from '../../src/index.js';\nimport DecimalJsNumberAdapter from '../../src/number-adapter/decimal-js.js';\nimport { bigNumber } from '../story-parts/big-number.js';\nimport { setByAttr, setByProp } from '../utils/index.js';\nimport { animationEvents } from '../story-parts/animation-events.js';\n\nexport { Basic, AnimationOptions, Styles, Emoji } from './index.stories.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nfunction equal(counter: TimeredCounter, a: any, b: any) {\n a = counter.getAttribute('aria-label')?.replaceAll(/\\s/g, ' ');\n return expect(a).toBe(b.toString());\n}\n\nconst meta: Meta = {\n title: 'TimeredCounterString/with Intl Segmenter',\n component: 'timered-counter-string',\n tags: ['autodocs', 'timered-counter-string'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n TimeredCounterAdapter.registryAdapter(DecimalJsNumberAdapter);\n\n TimeredCounterAdapter.setNumberAdapter('decimal.js');\n TimeredCounterAdapter.setStringAdapter('intl-segmenter');\n },\n};\nexport default meta;\n\nexport const Events: StoryObj<TimeredCounterString> = {\n args: {\n className: 'test-target',\n animationOptions: { duration: 100 },\n },\n async play(context) {\n const { canvasElement, step } = context;\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounter;\n\n const list = range(0, 5).map(() =>\n faker.lorem.sentence({ min: 1, max: 2 }),\n );\n\n await step('Testing with attribute', () =>\n animationEvents(context, { counter, list, setBy: setByAttr, equal }),\n );\n\n await step('Testing with property', () =>\n animationEvents(context, { counter, list, setBy: setByProp, equal }),\n );\n },\n};\n\nexport const BigNumber: StoryObj<TimeredCounterString> = {\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, equal }),\n );\n\n await step('Testing with property', async () =>\n bigNumber(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n"]}
|