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.
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/dist/custom-elements.json +8484 -0
- package/dist/src/counter-adapter.d.ts +38 -0
- package/dist/src/counter-adapter.js +69 -0
- package/dist/src/counter-adapter.js.map +1 -0
- package/dist/src/easing/cubic-bezier.d.ts +5 -0
- package/dist/src/easing/cubic-bezier.js +35 -0
- package/dist/src/easing/cubic-bezier.js.map +1 -0
- package/dist/src/easing/easing-functions.d.ts +1 -0
- package/dist/src/easing/easing-functions.js +10 -0
- package/dist/src/easing/easing-functions.js.map +1 -0
- package/dist/src/easing/index.d.ts +2 -0
- package/dist/src/easing/index.js +3 -0
- package/dist/src/easing/index.js.map +1 -0
- package/dist/src/easing/penner-easing-functions.d.ts +33 -0
- package/dist/src/easing/penner-easing-functions.js +82 -0
- package/dist/src/easing/penner-easing-functions.js.map +1 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.js +13 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mixins/counter-aira.d.ts +9 -0
- package/dist/src/mixins/counter-aira.js +41 -0
- package/dist/src/mixins/counter-aira.js.map +1 -0
- package/dist/src/mixins/counter-animation.d.ts +13 -0
- package/dist/src/mixins/counter-animation.js +55 -0
- package/dist/src/mixins/counter-animation.js.map +1 -0
- package/dist/src/mixins/counter-base.d.ts +21 -0
- package/dist/src/mixins/counter-base.js +152 -0
- package/dist/src/mixins/counter-base.js.map +1 -0
- package/dist/src/mixins/counter-parts.d.ts +42 -0
- package/dist/src/mixins/counter-parts.js +180 -0
- package/dist/src/mixins/counter-parts.js.map +1 -0
- package/dist/src/mixins/counter-styles.d.ts +17 -0
- package/dist/src/mixins/counter-styles.js +93 -0
- package/dist/src/mixins/counter-styles.js.map +1 -0
- package/dist/src/number-adapter/build-in-bigint.d.ts +6 -0
- package/dist/src/number-adapter/build-in-bigint.js +92 -0
- package/dist/src/number-adapter/build-in-bigint.js.map +1 -0
- package/dist/src/number-adapter/build-in-number.d.ts +3 -0
- package/dist/src/number-adapter/build-in-number.js +84 -0
- package/dist/src/number-adapter/build-in-number.js.map +1 -0
- package/dist/src/number-adapter/decimal-js.d.ts +4 -0
- package/dist/src/number-adapter/decimal-js.js +87 -0
- package/dist/src/number-adapter/decimal-js.js.map +1 -0
- package/dist/src/number-adapter/index.d.ts +4 -0
- package/dist/src/number-adapter/index.js +5 -0
- package/dist/src/number-adapter/index.js.map +1 -0
- package/dist/src/number-adapter/types.d.ts +34 -0
- package/dist/src/number-adapter/types.js +2 -0
- package/dist/src/number-adapter/types.js.map +1 -0
- package/dist/src/string-adapter/build-in-intl-segmenter.d.ts +10 -0
- package/dist/src/string-adapter/build-in-intl-segmenter.js +18 -0
- package/dist/src/string-adapter/build-in-intl-segmenter.js.map +1 -0
- package/dist/src/string-adapter/build-in-string.d.ts +12 -0
- package/dist/src/string-adapter/build-in-string.js +16 -0
- package/dist/src/string-adapter/build-in-string.js.map +1 -0
- package/dist/src/string-adapter/grapheme-splitter.d.ts +8 -0
- package/dist/src/string-adapter/grapheme-splitter.js +16 -0
- package/dist/src/string-adapter/grapheme-splitter.js.map +1 -0
- package/dist/src/string-adapter/index.d.ts +4 -0
- package/dist/src/string-adapter/index.js +5 -0
- package/dist/src/string-adapter/index.js.map +1 -0
- package/dist/src/string-adapter/types.d.ts +19 -0
- package/dist/src/string-adapter/types.js +2 -0
- package/dist/src/string-adapter/types.js.map +1 -0
- package/dist/src/styles/timered-counter-datetime-styles.d.ts +1 -0
- package/dist/src/styles/timered-counter-datetime-styles.js +8 -0
- package/dist/src/styles/timered-counter-datetime-styles.js.map +1 -0
- package/dist/src/styles/timered-counter-number-styles.d.ts +1 -0
- package/dist/src/styles/timered-counter-number-styles.js +3 -0
- package/dist/src/styles/timered-counter-number-styles.js.map +1 -0
- package/dist/src/styles/timered-counter-string-styles.d.ts +1 -0
- package/dist/src/styles/timered-counter-string-styles.js +3 -0
- package/dist/src/styles/timered-counter-string-styles.js.map +1 -0
- package/dist/src/styles/timered-counter-styles.d.ts +1 -0
- package/dist/src/styles/timered-counter-styles.js +25 -0
- package/dist/src/styles/timered-counter-styles.js.map +1 -0
- package/dist/src/timered-counter-datetime-duration.d.ts +37 -0
- package/dist/src/timered-counter-datetime-duration.js +186 -0
- package/dist/src/timered-counter-datetime-duration.js.map +1 -0
- package/dist/src/timered-counter-number.d.ts +23 -0
- package/dist/src/timered-counter-number.js +114 -0
- package/dist/src/timered-counter-number.js.map +1 -0
- package/dist/src/timered-counter-string.d.ts +30 -0
- package/dist/src/timered-counter-string.js +138 -0
- package/dist/src/timered-counter-string.js.map +1 -0
- package/dist/src/timered-counter.d.ts +15 -0
- package/dist/src/timered-counter.js +80 -0
- package/dist/src/timered-counter.js.map +1 -0
- package/dist/src/transitions/roller/index.d.ts +1 -0
- package/dist/src/transitions/roller/index.js +2 -0
- package/dist/src/transitions/roller/index.js.map +1 -0
- package/dist/src/transitions/roller/roller-digit.d.ts +28 -0
- package/dist/src/transitions/roller/roller-digit.js +259 -0
- package/dist/src/transitions/roller/roller-digit.js.map +1 -0
- package/dist/src/transitions/roller/roller.d.ts +42 -0
- package/dist/src/transitions/roller/roller.js +235 -0
- package/dist/src/transitions/roller/roller.js.map +1 -0
- package/dist/src/transitions/roller/styles.d.ts +2 -0
- package/dist/src/transitions/roller/styles.js +77 -0
- package/dist/src/transitions/roller/styles.js.map +1 -0
- package/dist/src/types/duration.d.ts +33 -0
- package/dist/src/types/duration.js +35 -0
- package/dist/src/types/duration.js.map +1 -0
- package/dist/src/types/group.d.ts +67 -0
- package/dist/src/types/group.js +2 -0
- package/dist/src/types/group.js.map +1 -0
- package/dist/src/utils/any-base.d.ts +6 -0
- package/dist/src/utils/any-base.js +56 -0
- package/dist/src/utils/any-base.js.map +1 -0
- package/dist/src/utils/duration.d.ts +15 -0
- package/dist/src/utils/duration.js +66 -0
- package/dist/src/utils/duration.js.map +1 -0
- package/dist/src/utils/extract-group-option.d.ts +9 -0
- package/dist/src/utils/extract-group-option.js +81 -0
- package/dist/src/utils/extract-group-option.js.map +1 -0
- package/dist/src/utils/iso8601-duration.d.ts +4 -0
- package/dist/src/utils/iso8601-duration.js +32 -0
- package/dist/src/utils/iso8601-duration.js.map +1 -0
- package/dist/src/utils/localized-date-time-fields.d.ts +2 -0
- package/dist/src/utils/localized-date-time-fields.js +24 -0
- package/dist/src/utils/localized-date-time-fields.js.map +1 -0
- package/dist/src/utils/parse-json-string.d.ts +1 -0
- package/dist/src/utils/parse-json-string.js +9 -0
- package/dist/src/utils/parse-json-string.js.map +1 -0
- package/dist/src/utils/polyfill-keyframes.d.ts +1 -0
- package/dist/src/utils/polyfill-keyframes.js +19 -0
- package/dist/src/utils/polyfill-keyframes.js.map +1 -0
- package/dist/src/utils/preprocess-part-data.d.ts +25 -0
- package/dist/src/utils/preprocess-part-data.js +59 -0
- package/dist/src/utils/preprocess-part-data.js.map +1 -0
- package/dist/src/utils/transition-digit.d.ts +2 -0
- package/dist/src/utils/transition-digit.js +51 -0
- package/dist/src/utils/transition-digit.js.map +1 -0
- package/dist/src/utils/uuid.d.ts +1 -0
- package/dist/src/utils/uuid.js +7 -0
- package/dist/src/utils/uuid.js.map +1 -0
- package/dist/stories/story-parts/animation-events.d.ts +9 -0
- package/dist/stories/story-parts/animation-events.js +35 -0
- package/dist/stories/story-parts/animation-events.js.map +1 -0
- package/dist/stories/story-parts/animation-options.d.ts +8 -0
- package/dist/stories/story-parts/animation-options.js +25 -0
- package/dist/stories/story-parts/animation-options.js.map +1 -0
- package/dist/stories/story-parts/big-number.d.ts +8 -0
- package/dist/stories/story-parts/big-number.js +25 -0
- package/dist/stories/story-parts/big-number.js.map +1 -0
- package/dist/stories/story-parts/datetime-locale.d.ts +8 -0
- package/dist/stories/story-parts/datetime-locale.js +30 -0
- package/dist/stories/story-parts/datetime-locale.js.map +1 -0
- package/dist/stories/story-parts/datetime-precision.d.ts +8 -0
- package/dist/stories/story-parts/datetime-precision.js +82 -0
- package/dist/stories/story-parts/datetime-precision.js.map +1 -0
- package/dist/stories/story-parts/edge-case.d.ts +8 -0
- package/dist/stories/story-parts/edge-case.js +12 -0
- package/dist/stories/story-parts/edge-case.js.map +1 -0
- package/dist/stories/story-parts/emoji.d.ts +9 -0
- package/dist/stories/story-parts/emoji.js +20 -0
- package/dist/stories/story-parts/emoji.js.map +1 -0
- package/dist/stories/story-parts/locale-number.d.ts +7 -0
- package/dist/stories/story-parts/locale-number.js +23 -0
- package/dist/stories/story-parts/locale-number.js.map +1 -0
- package/dist/stories/story-parts/slots.d.ts +10 -0
- package/dist/stories/story-parts/slots.js +29 -0
- package/dist/stories/story-parts/slots.js.map +1 -0
- package/dist/stories/story-parts/styles.d.ts +7 -0
- package/dist/stories/story-parts/styles.js +34 -0
- package/dist/stories/story-parts/styles.js.map +1 -0
- package/dist/stories/story-parts/value-change.d.ts +9 -0
- package/dist/stories/story-parts/value-change.js +20 -0
- package/dist/stories/story-parts/value-change.js.map +1 -0
- package/dist/stories/timered-counter/decimaljs.stories.d.ts +6 -0
- package/dist/stories/timered-counter/decimaljs.stories.js +34 -0
- package/dist/stories/timered-counter/decimaljs.stories.js.map +1 -0
- package/dist/stories/timered-counter/index.stories.d.ts +9 -0
- package/dist/stories/timered-counter/index.stories.js +180 -0
- package/dist/stories/timered-counter/index.stories.js.map +1 -0
- package/dist/stories/timered-counter-datetime-duration/index.stories.d.ts +7 -0
- package/dist/stories/timered-counter-datetime-duration/index.stories.js +95 -0
- package/dist/stories/timered-counter-datetime-duration/index.stories.js.map +1 -0
- package/dist/stories/timered-counter-number/decimaljs.stories.d.ts +6 -0
- package/dist/stories/timered-counter-number/decimaljs.stories.js +34 -0
- package/dist/stories/timered-counter-number/decimaljs.stories.js.map +1 -0
- package/dist/stories/timered-counter-number/index.stories.d.ts +9 -0
- package/dist/stories/timered-counter-number/index.stories.js +188 -0
- package/dist/stories/timered-counter-number/index.stories.js.map +1 -0
- package/dist/stories/timered-counter-string/decimaljs.stories.d.ts +7 -0
- package/dist/stories/timered-counter-string/decimaljs.stories.js +55 -0
- package/dist/stories/timered-counter-string/decimaljs.stories.js.map +1 -0
- package/dist/stories/timered-counter-string/grapheme-splitter.stories.d.ts +7 -0
- package/dist/stories/timered-counter-string/grapheme-splitter.stories.js +56 -0
- package/dist/stories/timered-counter-string/grapheme-splitter.stories.js.map +1 -0
- package/dist/stories/timered-counter-string/index.stories.d.ts +9 -0
- package/dist/stories/timered-counter-string/index.stories.js +126 -0
- package/dist/stories/timered-counter-string/index.stories.js.map +1 -0
- package/dist/stories/timered-counter-string/intl-segmenter.stories.d.ts +7 -0
- package/dist/stories/timered-counter-string/intl-segmenter.stories.js +56 -0
- package/dist/stories/timered-counter-string/intl-segmenter.stories.js.map +1 -0
- package/dist/stories/utils/index.d.ts +8 -0
- package/dist/stories/utils/index.js +20 -0
- package/dist/stories/utils/index.js.map +1 -0
- package/dist/test/td-counter.test.d.ts +1 -0
- package/dist/test/td-counter.test.js +25 -0
- package/dist/test/td-counter.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +128 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
import { setCustomElementsManifest, } from '@storybook/web-components';
|
2
|
+
import { expect } from '@storybook/test';
|
3
|
+
import { range } from 'remeda';
|
4
|
+
import { faker } from '@faker-js/faker';
|
5
|
+
import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
|
6
|
+
import { setNumberAdapter, } from '../../src/index.js';
|
7
|
+
import { bigNumber } from '../story-parts/big-number.js';
|
8
|
+
import { setByAttr, setByProp } from '../utils/index.js';
|
9
|
+
import { animationEvents } from '../story-parts/animation-events.js';
|
10
|
+
export { Basic, AnimationOptions, Styles, Emoji } from './index.stories.js';
|
11
|
+
setCustomElementsManifest(customElementsManifest);
|
12
|
+
function equal(counter, a, b) {
|
13
|
+
a = counter.getAttribute('aria-label')?.replaceAll(/\s/g, ' ');
|
14
|
+
return expect(a).toBe(b.toString());
|
15
|
+
}
|
16
|
+
const meta = {
|
17
|
+
title: 'TimeredCounterString/with decimal.js',
|
18
|
+
component: 'timered-counter-string',
|
19
|
+
tags: ['autodocs', 'timered-counter-string'],
|
20
|
+
parameters: {
|
21
|
+
controls: { expanded: true },
|
22
|
+
},
|
23
|
+
beforeEach: () => {
|
24
|
+
setNumberAdapter('decimal.js');
|
25
|
+
},
|
26
|
+
};
|
27
|
+
export default meta;
|
28
|
+
export const Events = {
|
29
|
+
args: {
|
30
|
+
className: 'test-target',
|
31
|
+
animationOptions: { duration: 100 },
|
32
|
+
},
|
33
|
+
async play(context) {
|
34
|
+
const { canvasElement, step } = context;
|
35
|
+
const counter = canvasElement.querySelector('.test-target');
|
36
|
+
const list = range(0, 5).map(() => faker.lorem.sentence({ min: 1, max: 2 }));
|
37
|
+
await step('Testing with attribute', () => animationEvents(context, { counter, list, setBy: setByAttr, equal }));
|
38
|
+
await step('Testing with property', () => animationEvents(context, { counter, list, setBy: setByProp, equal }));
|
39
|
+
},
|
40
|
+
};
|
41
|
+
export const BigNumber = {
|
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
|
+
await step('Testing with attribute', async () => bigNumber(context, { counter, setBy: setByAttr, equal }));
|
52
|
+
await step('Testing with property', async () => bigNumber(context, { counter, setBy: setByProp, equal }));
|
53
|
+
},
|
54
|
+
};
|
55
|
+
//# sourceMappingURL=decimaljs.stories.js.map
|
@@ -0,0 +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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B,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 setNumberAdapter,\n type TimeredCounter,\n TimeredCounterString,\n} from '../../src/index.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 decimal.js',\n component: 'timered-counter-string',\n tags: ['autodocs', 'timered-counter-string'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n 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"]}
|
@@ -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>;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { setCustomElementsManifest, } from '@storybook/web-components';
|
2
|
+
import { expect } from '@storybook/test';
|
3
|
+
import { range } from 'remeda';
|
4
|
+
import { faker } from '@faker-js/faker';
|
5
|
+
import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
|
6
|
+
import { setNumberAdapter, setStringAdapter, } from '../../src/index.js';
|
7
|
+
import { bigNumber } from '../story-parts/big-number.js';
|
8
|
+
import { setByAttr, setByProp } from '../utils/index.js';
|
9
|
+
import { animationEvents } from '../story-parts/animation-events.js';
|
10
|
+
export { Basic, AnimationOptions, Styles, Emoji } from './index.stories.js';
|
11
|
+
setCustomElementsManifest(customElementsManifest);
|
12
|
+
function equal(counter, a, b) {
|
13
|
+
a = counter.getAttribute('aria-label')?.replaceAll(/\s/g, ' ');
|
14
|
+
return expect(a).toBe(b.toString());
|
15
|
+
}
|
16
|
+
const meta = {
|
17
|
+
title: 'TimeredCounterString/with grapheme-splitter',
|
18
|
+
component: 'timered-counter-string',
|
19
|
+
tags: ['autodocs', 'timered-counter-string'],
|
20
|
+
parameters: {
|
21
|
+
controls: { expanded: true },
|
22
|
+
},
|
23
|
+
beforeEach: () => {
|
24
|
+
setNumberAdapter('decimal.js');
|
25
|
+
setStringAdapter('grapheme-splitter');
|
26
|
+
},
|
27
|
+
};
|
28
|
+
export default meta;
|
29
|
+
export const Events = {
|
30
|
+
args: {
|
31
|
+
className: 'test-target',
|
32
|
+
animationOptions: { duration: 100 },
|
33
|
+
},
|
34
|
+
async play(context) {
|
35
|
+
const { canvasElement, step } = context;
|
36
|
+
const counter = canvasElement.querySelector('.test-target');
|
37
|
+
const list = range(0, 5).map(() => faker.lorem.sentence({ min: 1, max: 2 }));
|
38
|
+
await step('Testing with attribute', () => animationEvents(context, { counter, list, setBy: setByAttr, equal }));
|
39
|
+
await step('Testing with property', () => animationEvents(context, { counter, list, setBy: setByProp, equal }));
|
40
|
+
},
|
41
|
+
};
|
42
|
+
export const BigNumber = {
|
43
|
+
args: {
|
44
|
+
className: 'test-target',
|
45
|
+
animationOptions: {
|
46
|
+
duration: 100,
|
47
|
+
},
|
48
|
+
},
|
49
|
+
async play(context) {
|
50
|
+
const { canvasElement, step } = context;
|
51
|
+
const counter = canvasElement.querySelector('.test-target');
|
52
|
+
await step('Testing with attribute', async () => bigNumber(context, { counter, setBy: setByAttr, equal }));
|
53
|
+
await step('Testing with property', async () => bigNumber(context, { counter, setBy: setByProp, equal }));
|
54
|
+
},
|
55
|
+
};
|
56
|
+
//# sourceMappingURL=grapheme-splitter.stories.js.map
|
@@ -0,0 +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;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AC;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 setNumberAdapter,\n setStringAdapter,\n type TimeredCounter,\n TimeredCounterString,\n} from '../../src/index.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 setNumberAdapter('decimal.js');\n 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"]}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/web-components';
|
2
|
+
import { TimeredCounterString } from '../../src/index.js';
|
3
|
+
declare const meta: Meta;
|
4
|
+
export default meta;
|
5
|
+
export declare const Basic: StoryObj<TimeredCounterString>;
|
6
|
+
export declare const Events: StoryObj<TimeredCounterString>;
|
7
|
+
export declare const AnimationOptions: StoryObj<TimeredCounterString>;
|
8
|
+
export declare const Styles: StoryObj<TimeredCounterString>;
|
9
|
+
export declare const Emoji: StoryObj<TimeredCounterString>;
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import { setCustomElementsManifest, } from '@storybook/web-components';
|
2
|
+
import { expect } from '@storybook/test';
|
3
|
+
import { range } from 'remeda';
|
4
|
+
import { faker } from '@faker-js/faker';
|
5
|
+
import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
|
6
|
+
import { setNumberAdapter, } from '../../src/index.js';
|
7
|
+
import { setByAttr, setByProp } from '../utils/index.js';
|
8
|
+
import { valueChange } from '../story-parts/value-change.js';
|
9
|
+
import { animationEvents } from '../story-parts/animation-events.js';
|
10
|
+
import { animationOptions } from '../story-parts/animation-options.js';
|
11
|
+
import { styles } from '../story-parts/styles.js';
|
12
|
+
import { emoji } from '../story-parts/emoji.js';
|
13
|
+
setCustomElementsManifest(customElementsManifest);
|
14
|
+
//
|
15
|
+
// function setByAttr(element: TimeredCounter, attr: string, value: string) {
|
16
|
+
// element.setAttribute(attr, value);
|
17
|
+
// }
|
18
|
+
//
|
19
|
+
// function setByProp(element: TimeredCounter, prop: string, value: any) {
|
20
|
+
// // @ts-ignore
|
21
|
+
// element[prop] = value.toString();
|
22
|
+
// }
|
23
|
+
function equal(counter, a, b) {
|
24
|
+
a = counter.getAttribute('aria-label')?.replaceAll(/\s/g, ' ');
|
25
|
+
return expect(a).toBe(b.toString());
|
26
|
+
}
|
27
|
+
const meta = {
|
28
|
+
title: 'TimeredCounterString',
|
29
|
+
component: 'timered-counter-string',
|
30
|
+
tags: ['autodocs', 'timered-counter-string'],
|
31
|
+
parameters: {
|
32
|
+
controls: { expanded: true },
|
33
|
+
},
|
34
|
+
beforeEach: () => {
|
35
|
+
setNumberAdapter('number');
|
36
|
+
},
|
37
|
+
};
|
38
|
+
export default meta;
|
39
|
+
export const Basic = {
|
40
|
+
args: {
|
41
|
+
className: 'test-target',
|
42
|
+
animationOptions: { duration: 100 },
|
43
|
+
},
|
44
|
+
async play(context) {
|
45
|
+
const { canvasElement, step } = context;
|
46
|
+
const counter = canvasElement.querySelector('.test-target');
|
47
|
+
const list = [
|
48
|
+
'Hello, World!',
|
49
|
+
'你好,世界!',
|
50
|
+
'こんにちは、世界!',
|
51
|
+
'안녕하세요, 세계!',
|
52
|
+
// 太长了
|
53
|
+
// "Bonjour, le monde!",
|
54
|
+
'Hallo, Welt!',
|
55
|
+
'Ciao, mondo!',
|
56
|
+
'Olá, mundo!',
|
57
|
+
'Привет, мир!',
|
58
|
+
// '¡Hola, mundo!',
|
59
|
+
// 'Hej, världen!',
|
60
|
+
// 'Merhaba, Dünya!',
|
61
|
+
// 'مرحبا بالعالم!',
|
62
|
+
// 'שלום, עולם!',
|
63
|
+
// 'नमस्ते, दुनिया!',
|
64
|
+
// 'سلام دنیا!',
|
65
|
+
];
|
66
|
+
await step('Testing with attribute', async () => {
|
67
|
+
await valueChange(context, { counter, list, setBy: setByAttr, equal });
|
68
|
+
});
|
69
|
+
await step('Testing with property', async () => {
|
70
|
+
await valueChange(context, { counter, list, setBy: setByProp, equal });
|
71
|
+
});
|
72
|
+
},
|
73
|
+
};
|
74
|
+
export const Events = {
|
75
|
+
args: {
|
76
|
+
className: 'test-target',
|
77
|
+
animationOptions: { duration: 100 },
|
78
|
+
},
|
79
|
+
async play(context) {
|
80
|
+
const { canvasElement, step } = context;
|
81
|
+
const counter = canvasElement.querySelector('.test-target');
|
82
|
+
const list = range(0, 5).map(() => faker.lorem.word({ length: { min: 5, max: 10 } }));
|
83
|
+
await step('Testing with attribute', () => animationEvents(context, { counter, list, setBy: setByAttr, equal }));
|
84
|
+
await step('Testing with property', () => animationEvents(context, { counter, list, setBy: setByProp, equal }));
|
85
|
+
},
|
86
|
+
};
|
87
|
+
export const AnimationOptions = {
|
88
|
+
args: {
|
89
|
+
className: 'test-target',
|
90
|
+
animationOptions: { duration: 100 },
|
91
|
+
},
|
92
|
+
async play(context) {
|
93
|
+
const { canvasElement, step } = context;
|
94
|
+
const counter = canvasElement.querySelector('.test-target');
|
95
|
+
await step('Testing with attribute', () => animationOptions(context, { counter, setBy: setByAttr }));
|
96
|
+
},
|
97
|
+
};
|
98
|
+
export const Styles = {
|
99
|
+
args: {
|
100
|
+
className: 'test-target',
|
101
|
+
animationOptions: { duration: 100 },
|
102
|
+
},
|
103
|
+
async play(context) {
|
104
|
+
const { canvasElement, step } = context;
|
105
|
+
const counter = canvasElement.querySelector('.test-target');
|
106
|
+
await step('Testing with attribute', () => styles(context, { counter, setBy: setByAttr }));
|
107
|
+
await step('Testing with property', () => styles(context, { counter, setBy: setByProp }));
|
108
|
+
},
|
109
|
+
};
|
110
|
+
export const Emoji = {
|
111
|
+
args: {
|
112
|
+
className: 'test-target',
|
113
|
+
animationOptions: { duration: 100 },
|
114
|
+
// partsOptions: {
|
115
|
+
// fillChar: '1',
|
116
|
+
// },
|
117
|
+
},
|
118
|
+
async play(context) {
|
119
|
+
const { canvasElement, step } = context;
|
120
|
+
const counter = canvasElement.querySelector('.test-target');
|
121
|
+
const list = ['⌚', '↔️', '👩', '👩🏿', '🧑💻'];
|
122
|
+
await step('Testing with attribute', () => emoji(context, { counter, list, setBy: setByAttr, equal }));
|
123
|
+
await step('Testing with property', () => emoji(context, { counter, list, setBy: setByProp, equal }));
|
124
|
+
},
|
125
|
+
};
|
126
|
+
//# sourceMappingURL=index.stories.js.map
|
@@ -0,0 +1 @@
|
|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O,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAC3D,CAAC;QAEF,MAAM,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CACvC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAC3D,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 setNumberAdapter,\n type TimeredCounter,\n TimeredCounterString,\n} from '../../src/index.js';\nimport { setByAttr, setByProp } from '../utils/index.js';\nimport { valueChange } from '../story-parts/value-change.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 { emoji } from '../story-parts/emoji.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\n//\n// function setByAttr(element: TimeredCounter, attr: string, value: string) {\n// element.setAttribute(attr, value);\n// }\n//\n// function setByProp(element: TimeredCounter, prop: string, value: any) {\n// // @ts-ignore\n// element[prop] = value.toString();\n// }\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',\n component: 'timered-counter-string',\n tags: ['autodocs', 'timered-counter-string'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n setNumberAdapter('number');\n },\n};\nexport default meta;\n\nexport const Basic: StoryObj<TimeredCounterString> = {\n args: {\n className: 'test-target',\n animationOptions: { duration: 100 },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterString;\n\n const list: string[] = [\n 'Hello, World!',\n '你好,世界!',\n 'こんにちは、世界!',\n '안녕하세요, 세계!',\n // 太长了\n // \"Bonjour, le monde!\",\n 'Hallo, Welt!',\n 'Ciao, mondo!',\n 'Olá, mundo!',\n 'Привет, мир!',\n // '¡Hola, mundo!',\n // 'Hej, världen!',\n // 'Merhaba, Dünya!',\n // 'مرحبا بالعالم!',\n // 'שלום, עולם!',\n // 'नमस्ते, दुनिया!',\n // 'سلام دنیا!',\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 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.word({ length: { min: 5, max: 10 } }),\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 AnimationOptions: 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 await step('Testing with attribute', () =>\n animationOptions(context, { counter, setBy: setByAttr }),\n );\n },\n};\n\nexport const Styles: 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 await step('Testing with attribute', () =>\n styles(context, { counter, setBy: setByAttr }),\n );\n\n await step('Testing with property', () =>\n styles(context, { counter, setBy: setByProp }),\n );\n },\n};\n\nexport const Emoji: StoryObj<TimeredCounterString> = {\n args: {\n className: 'test-target',\n animationOptions: { duration: 100 },\n // partsOptions: {\n // fillChar: '1',\n // },\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: string[] = ['⌚', '↔️', '👩', '👩🏿', '🧑💻'];\n\n await step('Testing with attribute', () =>\n emoji(context, { counter, list, setBy: setByAttr, equal }),\n );\n\n await step('Testing with property', () =>\n emoji(context, { counter, list, setBy: setByProp, equal }),\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>;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { setCustomElementsManifest, } from '@storybook/web-components';
|
2
|
+
import { expect } from '@storybook/test';
|
3
|
+
import { range } from 'remeda';
|
4
|
+
import { faker } from '@faker-js/faker';
|
5
|
+
import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
|
6
|
+
import { setNumberAdapter, setStringAdapter, } from '../../src/index.js';
|
7
|
+
import { bigNumber } from '../story-parts/big-number.js';
|
8
|
+
import { setByAttr, setByProp } from '../utils/index.js';
|
9
|
+
import { animationEvents } from '../story-parts/animation-events.js';
|
10
|
+
export { Basic, AnimationOptions, Styles, Emoji } from './index.stories.js';
|
11
|
+
setCustomElementsManifest(customElementsManifest);
|
12
|
+
function equal(counter, a, b) {
|
13
|
+
a = counter.getAttribute('aria-label')?.replaceAll(/\s/g, ' ');
|
14
|
+
return expect(a).toBe(b.toString());
|
15
|
+
}
|
16
|
+
const meta = {
|
17
|
+
title: 'TimeredCounterString/with Intl Segmenter',
|
18
|
+
component: 'timered-counter-string',
|
19
|
+
tags: ['autodocs', 'timered-counter-string'],
|
20
|
+
parameters: {
|
21
|
+
controls: { expanded: true },
|
22
|
+
},
|
23
|
+
beforeEach: () => {
|
24
|
+
setNumberAdapter('decimal.js');
|
25
|
+
setStringAdapter('intl-segmenter');
|
26
|
+
},
|
27
|
+
};
|
28
|
+
export default meta;
|
29
|
+
export const Events = {
|
30
|
+
args: {
|
31
|
+
className: 'test-target',
|
32
|
+
animationOptions: { duration: 100 },
|
33
|
+
},
|
34
|
+
async play(context) {
|
35
|
+
const { canvasElement, step } = context;
|
36
|
+
const counter = canvasElement.querySelector('.test-target');
|
37
|
+
const list = range(0, 5).map(() => faker.lorem.sentence({ min: 1, max: 2 }));
|
38
|
+
await step('Testing with attribute', () => animationEvents(context, { counter, list, setBy: setByAttr, equal }));
|
39
|
+
await step('Testing with property', () => animationEvents(context, { counter, list, setBy: setByProp, equal }));
|
40
|
+
},
|
41
|
+
};
|
42
|
+
export const BigNumber = {
|
43
|
+
args: {
|
44
|
+
className: 'test-target',
|
45
|
+
animationOptions: {
|
46
|
+
duration: 100,
|
47
|
+
},
|
48
|
+
},
|
49
|
+
async play(context) {
|
50
|
+
const { canvasElement, step } = context;
|
51
|
+
const counter = canvasElement.querySelector('.test-target');
|
52
|
+
await step('Testing with attribute', async () => bigNumber(context, { counter, setBy: setByAttr, equal }));
|
53
|
+
await step('Testing with property', async () => bigNumber(context, { counter, setBy: setByProp, equal }));
|
54
|
+
},
|
55
|
+
};
|
56
|
+
//# sourceMappingURL=intl-segmenter.stories.js.map
|
@@ -0,0 +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,E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F,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 setNumberAdapter,\n setStringAdapter,\n type TimeredCounter,\n TimeredCounterString,\n} from '../../src/index.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 setNumberAdapter('decimal.js');\n 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"]}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { TimeredCounter } from '../../src/index.js';
|
2
|
+
export declare function equal(counter: TimeredCounter, a: any, b: any): Promise<void>;
|
3
|
+
export declare function setByAttr(element: TimeredCounter, attr: string, value: any): void;
|
4
|
+
export declare function setByProp(element: TimeredCounter, prop: string, value: any): void;
|
5
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
6
|
+
export type NoUndefinedField<T> = {
|
7
|
+
[P in keyof T]-?: T[P];
|
8
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { expect } from '@storybook/test';
|
2
|
+
import { isString } from 'remeda';
|
3
|
+
export function equal(counter, a, b) {
|
4
|
+
const na = counter.numberAdapter;
|
5
|
+
return expect(na.toString(a)).toBe(na.toString(na.create(b)));
|
6
|
+
}
|
7
|
+
export function setByAttr(element, attr, value) {
|
8
|
+
value = isString(value) ? value : value.toString();
|
9
|
+
element.setAttribute(attr, value);
|
10
|
+
}
|
11
|
+
export function setByProp(element, prop, value) {
|
12
|
+
// @ts-ignore
|
13
|
+
element[prop] = value;
|
14
|
+
}
|
15
|
+
export function sleep(ms) {
|
16
|
+
return new Promise(resolve => {
|
17
|
+
setTimeout(resolve, ms);
|
18
|
+
});
|
19
|
+
}
|
20
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../stories/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,MAAM,UAAU,KAAK,CAAC,OAAuB,EAAE,CAAM,EAAE,CAAM;IAC3D,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IACjC,OAAO,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAuB,EAAE,IAAY,EAAE,KAAU;IACzE,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnD,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAuB,EAAE,IAAY,EAAE,KAAU;IACzE,aAAa;IACb,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { expect } from '@storybook/test';\nimport { isString } from 'remeda';\nimport type { TimeredCounter } from '../../src/index.js';\n\nexport function equal(counter: TimeredCounter, a: any, b: any) {\n const na = counter.numberAdapter;\n return expect(na.toString(a)).toBe(na.toString(na.create(b)));\n}\n\nexport function setByAttr(element: TimeredCounter, attr: string, value: any) {\n value = isString(value) ? value : value.toString();\n element.setAttribute(attr, value);\n}\n\nexport function setByProp(element: TimeredCounter, prop: string, value: any) {\n // @ts-ignore\n element[prop] = value;\n}\n\nexport function sleep(ms: number) {\n return new Promise(resolve => {\n setTimeout(resolve, ms);\n });\n}\n\nexport type NoUndefinedField<T> = { [P in keyof T]-?: T[P] };\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
import { fixture, expect } from '@open-wc/testing';
|
3
|
+
describe('TimeredCounter', () => {
|
4
|
+
it('has a default header "Hey there" and counter 5', async () => {
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
6
|
+
const el = await fixture(html `<timered-counter></timered-counter>`);
|
7
|
+
// expect(el.header).to.equal('Hey there');
|
8
|
+
// expect(el.counter).to.equal(5);
|
9
|
+
});
|
10
|
+
it('increases the counter on button click', async () => {
|
11
|
+
const el = await fixture(html `<timered-counter></timered-counter>`);
|
12
|
+
el.shadowRoot.querySelector('button').click();
|
13
|
+
// expect(el.counter).to.equal(6);
|
14
|
+
});
|
15
|
+
it('can override the header via attribute', async () => {
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
17
|
+
const el = await fixture(html `<timered-counter header="attribute header"></timered-counter>`);
|
18
|
+
// expect(el.header).to.equal('attribute header');
|
19
|
+
});
|
20
|
+
it('passes the a11y audit', async () => {
|
21
|
+
const el = await fixture(html `<timered-counter></timered-counter>`);
|
22
|
+
await expect(el).shadowDom.to.be.accessible();
|
23
|
+
});
|
24
|
+
});
|
25
|
+
//# sourceMappingURL=td-counter.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"td-counter.test.js","sourceRoot":"","sources":["../../test/td-counter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGnD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC9D,6DAA6D;QAC7D,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,qCAAqC,CAC1C,CAAC;QAEF,2CAA2C;QAC3C,kCAAkC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,qCAAqC,CAC1C,CAAC;QACF,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,QAAQ,CAAE,CAAC,KAAK,EAAE,CAAC;QAEhD,kCAAkC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,6DAA6D;QAC7D,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,+DAA+D,CACpE,CAAC;QAEF,kDAAkD;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,qCAAqC,CAC1C,CAAC;QAEF,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\nimport { fixture, expect } from '@open-wc/testing';\nimport { TimeredCounter } from '../src/index.js';\n\ndescribe('TimeredCounter', () => {\n it('has a default header \"Hey there\" and counter 5', async () => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const el = await fixture<TimeredCounter>(\n html`<timered-counter></timered-counter>`,\n );\n\n // expect(el.header).to.equal('Hey there');\n // expect(el.counter).to.equal(5);\n });\n\n it('increases the counter on button click', async () => {\n const el = await fixture<TimeredCounter>(\n html`<timered-counter></timered-counter>`,\n );\n el.shadowRoot!.querySelector('button')!.click();\n\n // expect(el.counter).to.equal(6);\n });\n\n it('can override the header via attribute', async () => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const el = await fixture<TimeredCounter>(\n html`<timered-counter header=\"attribute header\"></timered-counter>`,\n );\n\n // expect(el.header).to.equal('attribute header');\n });\n\n it('passes the a11y audit', async () => {\n const el = await fixture<TimeredCounter>(\n html`<timered-counter></timered-counter>`,\n );\n\n await expect(el).shadowDom.to.be.accessible();\n });\n});\n"]}
|