reshaped 3.9.0-canary.0 → 3.9.0-canary.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/dist/bundle.css +1 -1
- package/dist/bundle.js +10 -10
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Card/Card.module.css +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/Flyout/Flyout.constants.d.ts +1 -3
- package/dist/components/Flyout/Flyout.constants.js +1 -3
- package/dist/components/Flyout/FlyoutControlled.js +6 -8
- package/dist/components/Flyout/utilities/cooldown.js +1 -2
- package/dist/components/Icon/Icon.module.css +1 -1
- package/dist/components/Progress/Progress.module.css +1 -1
- package/dist/components/Reshaped/Reshaped.css +1 -1
- package/dist/components/Text/Text.module.css +1 -1
- package/dist/components/Theme/Theme.module.css +1 -1
- package/dist/hooks/useOnClickOutside.js +2 -4
- package/dist/themes/_generator/tokens/css.js +2 -2
- package/dist/themes/figma/theme.css +1 -1
- package/dist/themes/fragments/twitter/theme.css +1 -1
- package/dist/themes/reshaped/theme.css +1 -1
- package/dist/themes/slate/theme.css +1 -1
- package/package.json +40 -35
- package/dist/components/Accordion/tests/Accordion.stories.d.ts +0 -44
- package/dist/components/Accordion/tests/Accordion.stories.js +0 -204
- package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +0 -40
- package/dist/components/ActionBar/tests/ActionBar.stories.js +0 -223
- package/dist/components/Actionable/tests/Actionable.stories.d.ts +0 -41
- package/dist/components/Actionable/tests/Actionable.stories.js +0 -220
- package/dist/components/Alert/tests/Alert.stories.d.ts +0 -24
- package/dist/components/Alert/tests/Alert.stories.js +0 -78
- package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +0 -32
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +0 -246
- package/dist/components/Avatar/tests/Avatar.stories.d.ts +0 -31
- package/dist/components/Avatar/tests/Avatar.stories.js +0 -176
- package/dist/components/Badge/tests/Badge.stories.d.ts +0 -55
- package/dist/components/Badge/tests/Badge.stories.js +0 -328
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +0 -40
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +0 -187
- package/dist/components/Button/tests/Button.stories.d.ts +0 -79
- package/dist/components/Button/tests/Button.stories.js +0 -789
- package/dist/components/Calendar/tests/Calendar.stories.d.ts +0 -29
- package/dist/components/Calendar/tests/Calendar.stories.js +0 -255
- package/dist/components/Card/tests/Card.stories.d.ts +0 -52
- package/dist/components/Card/tests/Card.stories.js +0 -125
- package/dist/components/Carousel/tests/Carousel.stories.d.ts +0 -34
- package/dist/components/Carousel/tests/Carousel.stories.js +0 -224
- package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +0 -30
- package/dist/components/Checkbox/tests/Checkbox.stories.js +0 -171
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +0 -19
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +0 -83
- package/dist/components/Container/tests/Container.stories.d.ts +0 -24
- package/dist/components/Container/tests/Container.stories.js +0 -75
- package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +0 -26
- package/dist/components/ContextMenu/tests/ContextMenu.stories.js +0 -70
- package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +0 -25
- package/dist/components/Dismissible/tests/Dismissible.stories.js +0 -97
- package/dist/components/Divider/tests/Divider.stories.d.ts +0 -20
- package/dist/components/Divider/tests/Divider.stories.js +0 -120
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +0 -53
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +0 -278
- package/dist/components/FileUpload/tests/FileUpload.stories.d.ts +0 -31
- package/dist/components/FileUpload/tests/FileUpload.stories.js +0 -140
- package/dist/components/Flyout/tests/Flyout.stories.d.ts +0 -103
- package/dist/components/Flyout/tests/Flyout.stories.js +0 -738
- package/dist/components/FormControl/tests/FormControl.stories.d.ts +0 -31
- package/dist/components/FormControl/tests/FormControl.stories.js +0 -143
- package/dist/components/Grid/tests/Grid.stories.d.ts +0 -38
- package/dist/components/Grid/tests/Grid.stories.js +0 -245
- package/dist/components/Hidden/tests/Hidden.stories.d.ts +0 -16
- package/dist/components/Hidden/tests/Hidden.stories.js +0 -48
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +0 -16
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +0 -28
- package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +0 -13
- package/dist/components/Hotkey/tests/Hotkey.stories.js +0 -53
- package/dist/components/Icon/tests/Icon.stories.d.ts +0 -25
- package/dist/components/Icon/tests/Icon.stories.js +0 -113
- package/dist/components/Image/tests/Image.stories.d.ts +0 -41
- package/dist/components/Image/tests/Image.stories.js +0 -196
- package/dist/components/Link/tests/Link.stories.d.ts +0 -42
- package/dist/components/Link/tests/Link.stories.js +0 -155
- package/dist/components/Loader/tests/Loader.stories.d.ts +0 -21
- package/dist/components/Loader/tests/Loader.stories.js +0 -68
- package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +0 -59
- package/dist/components/MenuItem/tests/MenuItem.stories.js +0 -236
- package/dist/components/Modal/tests/Modal.stories.d.ts +0 -64
- package/dist/components/Modal/tests/Modal.stories.js +0 -410
- package/dist/components/NumberField/tests/NumberField.stories.d.ts +0 -28
- package/dist/components/NumberField/tests/NumberField.stories.js +0 -258
- package/dist/components/Overlay/tests/Overlay.stories.d.ts +0 -28
- package/dist/components/Overlay/tests/Overlay.stories.js +0 -202
- package/dist/components/Pagination/tests/Pagination.stories.d.ts +0 -24
- package/dist/components/Pagination/tests/Pagination.stories.js +0 -105
- package/dist/components/PinField/tests/PinField.stories.d.ts +0 -34
- package/dist/components/PinField/tests/PinField.stories.js +0 -209
- package/dist/components/Popover/tests/Popover.stories.d.ts +0 -69
- package/dist/components/Popover/tests/Popover.stories.js +0 -340
- package/dist/components/Progress/tests/Progress.stories.d.ts +0 -30
- package/dist/components/Progress/tests/Progress.stories.js +0 -102
- package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.d.ts +0 -19
- package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.js +0 -92
- package/dist/components/Radio/tests/Radio.stories.d.ts +0 -35
- package/dist/components/Radio/tests/Radio.stories.js +0 -162
- package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +0 -19
- package/dist/components/RadioGroup/tests/RadioGroup.stories.js +0 -77
- package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +0 -34
- package/dist/components/Reshaped/tests/Reshaped.stories.js +0 -108
- package/dist/components/Resizable/tests/Resizable.stories.d.ts +0 -38
- package/dist/components/Resizable/tests/Resizable.stories.js +0 -185
- package/dist/components/Scrim/tests/Scrim.stories.d.ts +0 -20
- package/dist/components/Scrim/tests/Scrim.stories.js +0 -67
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +0 -37
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +0 -244
- package/dist/components/Select/tests/Select.stories.d.ts +0 -53
- package/dist/components/Select/tests/Select.stories.js +0 -616
- package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +0 -20
- package/dist/components/Skeleton/tests/Skeleton.stories.js +0 -63
- package/dist/components/Slider/tests/Slider.stories.d.ts +0 -47
- package/dist/components/Slider/tests/Slider.stories.js +0 -279
- package/dist/components/Stepper/tests/Stepper.stories.d.ts +0 -31
- package/dist/components/Stepper/tests/Stepper.stories.js +0 -135
- package/dist/components/Switch/tests/Switch.stories.d.ts +0 -22
- package/dist/components/Switch/tests/Switch.stories.js +0 -137
- package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -13
- package/dist/components/Switch/tests/Switch.test.stories.js +0 -11
- package/dist/components/Table/tests/Table.stories.d.ts +0 -42
- package/dist/components/Table/tests/Table.stories.js +0 -348
- package/dist/components/Tabs/tests/Tabs.stories.d.ts +0 -62
- package/dist/components/Tabs/tests/Tabs.stories.js +0 -539
- package/dist/components/Text/tests/Text.stories.d.ts +0 -48
- package/dist/components/Text/tests/Text.stories.js +0 -201
- package/dist/components/TextArea/tests/TextArea.stories.d.ts +0 -53
- package/dist/components/TextArea/tests/TextArea.stories.js +0 -204
- package/dist/components/TextField/tests/TextField.stories.d.ts +0 -54
- package/dist/components/TextField/tests/TextField.stories.js +0 -252
- package/dist/components/Theme/tests/Theme.stories.d.ts +0 -25
- package/dist/components/Theme/tests/Theme.stories.js +0 -171
- package/dist/components/Timeline/tests/Timeline.stories.d.ts +0 -22
- package/dist/components/Timeline/tests/Timeline.stories.js +0 -86
- package/dist/components/Toast/tests/Toast.stories.d.ts +0 -41
- package/dist/components/Toast/tests/Toast.stories.js +0 -432
- package/dist/components/ToggleButton/tests/ToggleButton.stories.d.ts +0 -27
- package/dist/components/ToggleButton/tests/ToggleButton.stories.js +0 -97
- package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.d.ts +0 -27
- package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.js +0 -169
- package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +0 -28
- package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -182
- package/dist/components/View/tests/View.stories.d.ts +0 -141
- package/dist/components/View/tests/View.stories.js +0 -1329
- package/dist/components/_private/Portal/tests/Portal.stories.d.ts +0 -6
- package/dist/components/_private/Portal/tests/Portal.stories.js +0 -17
- package/dist/hooks/tests/useDrag.stories.d.ts +0 -31
- package/dist/hooks/tests/useDrag.stories.js +0 -147
- package/dist/hooks/tests/useElementId.stories.d.ts +0 -11
- package/dist/hooks/tests/useElementId.stories.js +0 -23
- package/dist/hooks/tests/useHandlerRef.stories.d.ts +0 -14
- package/dist/hooks/tests/useHandlerRef.stories.js +0 -44
- package/dist/hooks/tests/useHotkeys.stories.d.ts +0 -43
- package/dist/hooks/tests/useHotkeys.stories.js +0 -158
- package/dist/hooks/tests/useKeyboardArrowNavigation.stories.d.ts +0 -15
- package/dist/hooks/tests/useKeyboardArrowNavigation.stories.js +0 -128
- package/dist/hooks/tests/useKeyboardMode.stories.d.ts +0 -11
- package/dist/hooks/tests/useKeyboardMode.stories.js +0 -42
- package/dist/hooks/tests/useOnClickOutside.stories.d.ts +0 -23
- package/dist/hooks/tests/useOnClickOutside.stories.js +0 -111
- package/dist/hooks/tests/useRTL.stories.d.ts +0 -11
- package/dist/hooks/tests/useRTL.stories.js +0 -23
- package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +0 -18
- package/dist/hooks/tests/useResponsiveClientValue.stories.js +0 -30
- package/dist/hooks/tests/useScrollLock.stories.d.ts +0 -14
- package/dist/hooks/tests/useScrollLock.stories.js +0 -97
- package/dist/hooks/tests/useToggle.stories.d.ts +0 -13
- package/dist/hooks/tests/useToggle.stories.js +0 -59
- package/dist/tests/ShadowDOM.stories.d.ts +0 -6
- package/dist/tests/ShadowDOM.stories.js +0 -110
- package/dist/tests/themes.stories.d.ts +0 -16
- package/dist/tests/themes.stories.js +0 -327
- package/dist/utilities/a11y/tests/TrapFocus.stories.d.ts +0 -14
- package/dist/utilities/a11y/tests/TrapFocus.stories.js +0 -615
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { expect, fn, userEvent } from "storybook/test";
|
|
2
|
-
import FormControl from "../../FormControl/index.js";
|
|
3
|
-
import NumberField from "../index.js";
|
|
4
|
-
import { Example } from "../../../utilities/storybook/index.js";
|
|
5
|
-
export default {
|
|
6
|
-
title: "Components/NumberField",
|
|
7
|
-
component: NumberField,
|
|
8
|
-
parameters: {
|
|
9
|
-
iframe: {
|
|
10
|
-
url: "https://reshaped.so/docs/components/number-field",
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export const variant = {
|
|
15
|
-
name: "variant",
|
|
16
|
-
render: () => {
|
|
17
|
-
return (<Example>
|
|
18
|
-
<Example.Item title="variant: outline">
|
|
19
|
-
<NumberField name="test-name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>
|
|
20
|
-
</Example.Item>
|
|
21
|
-
<Example.Item title="variant: faded">
|
|
22
|
-
<NumberField variant="faded" name="test-name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>
|
|
23
|
-
</Example.Item>
|
|
24
|
-
<Example.Item title="variant: headless">
|
|
25
|
-
<NumberField variant="headless" name="test-name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>
|
|
26
|
-
</Example.Item>
|
|
27
|
-
</Example>);
|
|
28
|
-
},
|
|
29
|
-
play: async ({ canvas }) => {
|
|
30
|
-
const input = canvas.getAllByRole("textbox")[0];
|
|
31
|
-
const [increaseButton, decreaseButton] = canvas.getAllByRole("button");
|
|
32
|
-
expect(input).toHaveAttribute("name", "test-name");
|
|
33
|
-
expect(increaseButton).toHaveAccessibleName("Increase");
|
|
34
|
-
expect(decreaseButton).toHaveAccessibleName("Decrease");
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
export const size = {
|
|
38
|
-
name: "size",
|
|
39
|
-
render: () => {
|
|
40
|
-
return (<Example>
|
|
41
|
-
<Example.Item title="size: small">
|
|
42
|
-
<NumberField size="small" name="test-name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" suffix="m2" inputAttributes={{ "aria-label": "Label" }}/>
|
|
43
|
-
</Example.Item>
|
|
44
|
-
<Example.Item title="size: medium">
|
|
45
|
-
<NumberField size="medium" name="test-name" suffix="m2" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>
|
|
46
|
-
</Example.Item>
|
|
47
|
-
<Example.Item title="size: large">
|
|
48
|
-
<NumberField size="large" name="test-name" suffix="m2" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>
|
|
49
|
-
</Example.Item>
|
|
50
|
-
<Example.Item title="size: xlarge">
|
|
51
|
-
<NumberField size="xlarge" name="test-name" suffix="m2" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>
|
|
52
|
-
</Example.Item>
|
|
53
|
-
</Example>);
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
export const disabled = {
|
|
57
|
-
name: "disabled",
|
|
58
|
-
args: {
|
|
59
|
-
handleChange: fn(),
|
|
60
|
-
},
|
|
61
|
-
render: (args) => (<NumberField name="test-name" onChange={args.handleChange} increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" disabled inputAttributes={{ "aria-label": "Label" }}/>),
|
|
62
|
-
play: async ({ canvas, args }) => {
|
|
63
|
-
const input = canvas.getByRole("textbox");
|
|
64
|
-
const increaseButton = document.querySelector('[aria-label="Increase"]');
|
|
65
|
-
const decreaseButton = document.querySelector('[aria-label="Decrease"]');
|
|
66
|
-
expect(input).toBeDisabled();
|
|
67
|
-
await userEvent.click(increaseButton);
|
|
68
|
-
expect(args.handleChange).not.toHaveBeenCalled();
|
|
69
|
-
await userEvent.click(decreaseButton);
|
|
70
|
-
expect(args.handleChange).not.toHaveBeenCalled();
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
export const defaultValue = {
|
|
74
|
-
name: "defaultValue, uncontrolled",
|
|
75
|
-
args: {
|
|
76
|
-
handleChange: fn(),
|
|
77
|
-
},
|
|
78
|
-
render: (args) => (<NumberField name="test-name" defaultValue={2} onChange={args.handleChange} increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>),
|
|
79
|
-
play: async ({ canvas, args }) => {
|
|
80
|
-
const input = canvas.getByRole("textbox");
|
|
81
|
-
const [increaseButton, decreaseButton] = canvas.getAllByRole("button");
|
|
82
|
-
expect(input).toHaveValue("2");
|
|
83
|
-
input.focus();
|
|
84
|
-
await userEvent.keyboard("3");
|
|
85
|
-
expect(args.handleChange).toBeCalledTimes(1);
|
|
86
|
-
expect(args.handleChange).toHaveBeenLastCalledWith({
|
|
87
|
-
name: "test-name",
|
|
88
|
-
value: 23,
|
|
89
|
-
});
|
|
90
|
-
expect(input).toHaveValue("23");
|
|
91
|
-
await userEvent.click(increaseButton);
|
|
92
|
-
expect(args.handleChange).toBeCalledTimes(2);
|
|
93
|
-
expect(args.handleChange).toHaveBeenLastCalledWith({
|
|
94
|
-
name: "test-name",
|
|
95
|
-
value: 24,
|
|
96
|
-
});
|
|
97
|
-
expect(input).toHaveValue("24");
|
|
98
|
-
await userEvent.click(decreaseButton);
|
|
99
|
-
expect(args.handleChange).toBeCalledTimes(3);
|
|
100
|
-
expect(args.handleChange).toHaveBeenLastCalledWith({
|
|
101
|
-
name: "test-name",
|
|
102
|
-
value: 23,
|
|
103
|
-
});
|
|
104
|
-
expect(input).toHaveValue("23");
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
export const value = {
|
|
108
|
-
name: "value, controlled",
|
|
109
|
-
args: {
|
|
110
|
-
handleChange: fn(),
|
|
111
|
-
},
|
|
112
|
-
render: (args) => (<NumberField name="test-name" value={2} onChange={args.handleChange} increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>),
|
|
113
|
-
play: async ({ canvas, args }) => {
|
|
114
|
-
const input = canvas.getByRole("textbox");
|
|
115
|
-
const [increaseButton, decreaseButton] = canvas.getAllByRole("button");
|
|
116
|
-
expect(input).toHaveValue("2");
|
|
117
|
-
input.focus();
|
|
118
|
-
await userEvent.keyboard("3");
|
|
119
|
-
expect(args.handleChange).toBeCalledTimes(1);
|
|
120
|
-
expect(args.handleChange).toHaveBeenLastCalledWith({
|
|
121
|
-
name: "test-name",
|
|
122
|
-
value: 23,
|
|
123
|
-
});
|
|
124
|
-
expect(input).toHaveValue("23");
|
|
125
|
-
await userEvent.click(increaseButton);
|
|
126
|
-
expect(args.handleChange).toBeCalledTimes(2);
|
|
127
|
-
expect(args.handleChange).toHaveBeenLastCalledWith({
|
|
128
|
-
name: "test-name",
|
|
129
|
-
value: 24,
|
|
130
|
-
});
|
|
131
|
-
expect(input).toHaveValue("23");
|
|
132
|
-
await userEvent.click(decreaseButton);
|
|
133
|
-
expect(args.handleChange).toBeCalledTimes(3);
|
|
134
|
-
expect(args.handleChange).toHaveBeenLastCalledWith({
|
|
135
|
-
name: "test-name",
|
|
136
|
-
value: 22,
|
|
137
|
-
});
|
|
138
|
-
expect(input).toHaveValue("23");
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
export const minMax = {
|
|
142
|
-
name: "min, max",
|
|
143
|
-
render: () => (<NumberField name="test-name" defaultValue={6} min={5} max={10} increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>),
|
|
144
|
-
play: async ({ canvas }) => {
|
|
145
|
-
const input = canvas.getByRole("textbox");
|
|
146
|
-
const [increaseButton, decreaseButton] = canvas.getAllByRole("button");
|
|
147
|
-
expect(input).toHaveValue("6");
|
|
148
|
-
await userEvent.click(increaseButton);
|
|
149
|
-
await userEvent.click(increaseButton);
|
|
150
|
-
await userEvent.click(increaseButton);
|
|
151
|
-
await userEvent.click(increaseButton);
|
|
152
|
-
await userEvent.click(increaseButton);
|
|
153
|
-
expect(input).toHaveValue("10");
|
|
154
|
-
await userEvent.click(decreaseButton);
|
|
155
|
-
await userEvent.click(decreaseButton);
|
|
156
|
-
await userEvent.click(decreaseButton);
|
|
157
|
-
await userEvent.click(decreaseButton);
|
|
158
|
-
await userEvent.click(decreaseButton);
|
|
159
|
-
await userEvent.click(decreaseButton);
|
|
160
|
-
expect(input).toHaveValue("5");
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
export const step = {
|
|
164
|
-
name: "step",
|
|
165
|
-
render: () => (<NumberField name="test-name" defaultValue={6} step={0.5} increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>),
|
|
166
|
-
play: async ({ canvas }) => {
|
|
167
|
-
const input = canvas.getByRole("textbox");
|
|
168
|
-
const [increaseButton, decreaseButton] = canvas.getAllByRole("button");
|
|
169
|
-
expect(input).toHaveValue("6");
|
|
170
|
-
await userEvent.click(increaseButton);
|
|
171
|
-
expect(input).toHaveValue("6.5");
|
|
172
|
-
await userEvent.click(decreaseButton);
|
|
173
|
-
await userEvent.click(decreaseButton);
|
|
174
|
-
expect(input).toHaveValue("5.5");
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
export const className = {
|
|
178
|
-
name: "className, attributes",
|
|
179
|
-
render: () => (<div data-testid="root">
|
|
180
|
-
<NumberField className="test-classname" attributes={{ id: "test-id" }} name="name" inputAttributes={{ id: "test-input-id", "aria-label": "Label" }} increaseAriaLabel="Increase" decreaseAriaLabel="Decrease"/>
|
|
181
|
-
</div>),
|
|
182
|
-
play: async ({ canvas }) => {
|
|
183
|
-
const root = canvas.getByTestId("root").firstChild;
|
|
184
|
-
const input = canvas.getByRole("textbox");
|
|
185
|
-
expect(root).toHaveClass("test-classname");
|
|
186
|
-
expect(root).toHaveAttribute("id", "test-id");
|
|
187
|
-
expect(input).toHaveAttribute("id", "test-input-id");
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
export const formControl = {
|
|
191
|
-
name: "test: FormControl",
|
|
192
|
-
render: () => (<Example>
|
|
193
|
-
<Example.Item title="FormControl">
|
|
194
|
-
<FormControl>
|
|
195
|
-
<FormControl.Label>Label</FormControl.Label>
|
|
196
|
-
<NumberField name="name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease"/>
|
|
197
|
-
<FormControl.Helper>Helper</FormControl.Helper>
|
|
198
|
-
</FormControl>
|
|
199
|
-
</Example.Item>
|
|
200
|
-
|
|
201
|
-
<Example.Item title="FormControl, disabled">
|
|
202
|
-
<FormControl disabled>
|
|
203
|
-
<FormControl.Label>Label</FormControl.Label>
|
|
204
|
-
<NumberField name="name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease"/>
|
|
205
|
-
<FormControl.Helper>Helper</FormControl.Helper>
|
|
206
|
-
</FormControl>
|
|
207
|
-
</Example.Item>
|
|
208
|
-
|
|
209
|
-
<Example.Item title="FormControl, error">
|
|
210
|
-
<FormControl hasError>
|
|
211
|
-
<FormControl.Label>Label</FormControl.Label>
|
|
212
|
-
<NumberField name="name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease"/>
|
|
213
|
-
<FormControl.Error>Error</FormControl.Error>
|
|
214
|
-
</FormControl>
|
|
215
|
-
</Example.Item>
|
|
216
|
-
</Example>),
|
|
217
|
-
};
|
|
218
|
-
export const valueChanges = {
|
|
219
|
-
name: "test: keyboard",
|
|
220
|
-
render: () => (<Example>
|
|
221
|
-
<Example.Item title="keyboard">
|
|
222
|
-
<NumberField name="name" increaseAriaLabel="Increase" decreaseAriaLabel="Decrease" inputAttributes={{ "aria-label": "Label" }}/>
|
|
223
|
-
</Example.Item>
|
|
224
|
-
</Example>),
|
|
225
|
-
play: async ({ canvas }) => {
|
|
226
|
-
const input = canvas.getByRole("textbox");
|
|
227
|
-
input.focus();
|
|
228
|
-
await userEvent.keyboard("-");
|
|
229
|
-
expect(input).toHaveValue("-");
|
|
230
|
-
await userEvent.keyboard("1");
|
|
231
|
-
expect(input).toHaveValue("-1");
|
|
232
|
-
await userEvent.keyboard("-");
|
|
233
|
-
expect(input).toHaveValue("-1");
|
|
234
|
-
await userEvent.keyboard("2");
|
|
235
|
-
expect(input).toHaveValue("-12");
|
|
236
|
-
await userEvent.keyboard("{ArrowUp}");
|
|
237
|
-
expect(input).toHaveValue("-11");
|
|
238
|
-
await userEvent.keyboard("{ArrowDown}");
|
|
239
|
-
expect(input).toHaveValue("-12");
|
|
240
|
-
await userEvent.keyboard(".");
|
|
241
|
-
expect(input).toHaveValue("-12.");
|
|
242
|
-
await userEvent.keyboard("3");
|
|
243
|
-
expect(input).toHaveValue("-12.3");
|
|
244
|
-
await userEvent.keyboard(".");
|
|
245
|
-
expect(input).toHaveValue("-12.3");
|
|
246
|
-
await userEvent.keyboard("-");
|
|
247
|
-
expect(input).toHaveValue("-12.3");
|
|
248
|
-
await userEvent.keyboard("{ArrowUp}");
|
|
249
|
-
await userEvent.keyboard("{ArrowUp}");
|
|
250
|
-
await userEvent.keyboard("{ArrowUp}");
|
|
251
|
-
await userEvent.keyboard("{ArrowUp}");
|
|
252
|
-
await userEvent.keyboard("{ArrowUp}");
|
|
253
|
-
expect(input).toHaveValue("-7.3");
|
|
254
|
-
await userEvent.keyboard("{ArrowDown}");
|
|
255
|
-
expect(input).toHaveValue("-8.3");
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
|
-
// Value change edge cases
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { fn } from "storybook/test";
|
|
3
|
-
import React from "react";
|
|
4
|
-
declare const _default: {
|
|
5
|
-
title: string;
|
|
6
|
-
component: React.FC<import("./..").OverlayProps>;
|
|
7
|
-
parameters: {
|
|
8
|
-
iframe: {
|
|
9
|
-
url: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
14
|
-
export declare const base: StoryObj;
|
|
15
|
-
export declare const transparent: StoryObj;
|
|
16
|
-
export declare const blurred: StoryObj;
|
|
17
|
-
export declare const renderProps: StoryObj;
|
|
18
|
-
export declare const handlers: StoryObj<{
|
|
19
|
-
handleOpen: ReturnType<typeof fn>;
|
|
20
|
-
handleAfterOpen: ReturnType<typeof fn>;
|
|
21
|
-
handleClose: ReturnType<typeof fn>;
|
|
22
|
-
handleAfterClose: ReturnType<typeof fn>;
|
|
23
|
-
}>;
|
|
24
|
-
export declare const disableCloseOnClick: StoryObj<{
|
|
25
|
-
handleClose: ReturnType<typeof fn>;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const containerRef: StoryObj;
|
|
28
|
-
export declare const className: StoryObj;
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
|
2
|
-
import { Example } from "../../../utilities/storybook/index.js";
|
|
3
|
-
import Overlay from "../index.js";
|
|
4
|
-
import Button from "../../Button/index.js";
|
|
5
|
-
import useToggle from "../../../hooks/useToggle.js";
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { sleep } from "../../../utilities/helpers.js";
|
|
8
|
-
export default {
|
|
9
|
-
title: "Utility components/Overlay",
|
|
10
|
-
component: Overlay,
|
|
11
|
-
parameters: {
|
|
12
|
-
iframe: {
|
|
13
|
-
url: "https://reshaped.so/docs/utilities/overlay",
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
export const base = {
|
|
18
|
-
name: "base",
|
|
19
|
-
render: () => {
|
|
20
|
-
const overlayToggle = useToggle(false);
|
|
21
|
-
return (<Example>
|
|
22
|
-
<Example.Item title="base">
|
|
23
|
-
<Button onClick={overlayToggle.activate}>Open overlay</Button>
|
|
24
|
-
<Overlay active={overlayToggle.active} onClose={overlayToggle.deactivate}>
|
|
25
|
-
Overlay content
|
|
26
|
-
</Overlay>
|
|
27
|
-
</Example.Item>
|
|
28
|
-
</Example>);
|
|
29
|
-
},
|
|
30
|
-
play: async ({ canvas }) => {
|
|
31
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
32
|
-
await userEvent.click(trigger);
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
export const transparent = {
|
|
36
|
-
name: "transparent",
|
|
37
|
-
render: () => {
|
|
38
|
-
const overlayToggle = useToggle(false);
|
|
39
|
-
return (<Example>
|
|
40
|
-
<Example.Item title="base">
|
|
41
|
-
<Button onClick={overlayToggle.activate}>Open overlay</Button>
|
|
42
|
-
<Overlay active={overlayToggle.active} onClose={overlayToggle.deactivate} transparent>
|
|
43
|
-
Overlay content
|
|
44
|
-
</Overlay>
|
|
45
|
-
</Example.Item>
|
|
46
|
-
</Example>);
|
|
47
|
-
},
|
|
48
|
-
play: async ({ canvas }) => {
|
|
49
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
50
|
-
await userEvent.click(trigger);
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
export const blurred = {
|
|
54
|
-
name: "blurred",
|
|
55
|
-
render: () => {
|
|
56
|
-
const overlayToggle = useToggle(false);
|
|
57
|
-
return (<Example>
|
|
58
|
-
<Example.Item title="base">
|
|
59
|
-
<Button onClick={overlayToggle.activate}>Open overlay</Button>
|
|
60
|
-
<Overlay active={overlayToggle.active} onClose={overlayToggle.deactivate} blurred>
|
|
61
|
-
Overlay content
|
|
62
|
-
</Overlay>
|
|
63
|
-
</Example.Item>
|
|
64
|
-
</Example>);
|
|
65
|
-
},
|
|
66
|
-
play: async ({ canvas }) => {
|
|
67
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
68
|
-
await userEvent.click(trigger);
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
export const renderProps = {
|
|
72
|
-
name: "children, render props",
|
|
73
|
-
render: () => (<Overlay active className="test-classname" attributes={{ "data-testid": "test-id" }}>
|
|
74
|
-
{(args) => (args.active ? "Opened" : "Closed")}
|
|
75
|
-
</Overlay>),
|
|
76
|
-
play: async ({ canvasElement }) => {
|
|
77
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
78
|
-
const root = canvas.getByText("Opened");
|
|
79
|
-
expect(root).toBeInTheDocument();
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
export const handlers = {
|
|
83
|
-
name: "onOpen, onClose, onAfterOpen, onAfterClose",
|
|
84
|
-
args: {
|
|
85
|
-
handleOpen: fn(),
|
|
86
|
-
handleClose: fn(),
|
|
87
|
-
handleAfterClose: fn(),
|
|
88
|
-
handleAfterOpen: fn(),
|
|
89
|
-
},
|
|
90
|
-
render: (args) => {
|
|
91
|
-
const overlayToggle = useToggle();
|
|
92
|
-
return (<>
|
|
93
|
-
<Button onClick={() => overlayToggle.toggle()}>Open overlay</Button>
|
|
94
|
-
<Overlay active={overlayToggle.active} onClose={(closeArgs) => {
|
|
95
|
-
overlayToggle.deactivate();
|
|
96
|
-
args.handleClose(closeArgs);
|
|
97
|
-
}} onOpen={args.handleOpen} onAfterOpen={args.handleAfterOpen} onAfterClose={args.handleAfterClose}>
|
|
98
|
-
Content
|
|
99
|
-
</Overlay>
|
|
100
|
-
</>);
|
|
101
|
-
},
|
|
102
|
-
play: async ({ canvasElement, args }) => {
|
|
103
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
104
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
105
|
-
let overlay;
|
|
106
|
-
await userEvent.click(trigger);
|
|
107
|
-
overlay = canvas.getByText("Content");
|
|
108
|
-
await waitFor(() => {
|
|
109
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
|
110
|
-
expect(args.handleOpen).toHaveBeenCalledWith();
|
|
111
|
-
});
|
|
112
|
-
// Wait for transition
|
|
113
|
-
await waitFor(() => {
|
|
114
|
-
expect(args.handleAfterOpen).toHaveBeenCalledTimes(1);
|
|
115
|
-
expect(args.handleAfterOpen).toHaveBeenCalledWith();
|
|
116
|
-
});
|
|
117
|
-
// Close by changing the state after the trigger click
|
|
118
|
-
await userEvent.click(trigger);
|
|
119
|
-
// Changing state doesn't trigger onClose
|
|
120
|
-
expect(args.handleClose).toHaveBeenCalledTimes(0);
|
|
121
|
-
// Wait for transition
|
|
122
|
-
await waitFor(() => {
|
|
123
|
-
expect(args.handleAfterClose).toHaveBeenCalledTimes(1);
|
|
124
|
-
expect(args.handleAfterClose).toHaveBeenCalledWith();
|
|
125
|
-
});
|
|
126
|
-
// Open
|
|
127
|
-
await userEvent.click(trigger);
|
|
128
|
-
overlay = canvas.getByText("Content");
|
|
129
|
-
// TODO: Fails CLI tests in Storybook without a timeout
|
|
130
|
-
await sleep(100);
|
|
131
|
-
// Close by clicking on the overlay
|
|
132
|
-
await userEvent.click(overlay);
|
|
133
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
|
134
|
-
expect(args.handleClose).toHaveBeenCalledWith({ reason: "overlay-click" });
|
|
135
|
-
await waitFor(() => {
|
|
136
|
-
expect(args.handleAfterClose).toHaveBeenCalledTimes(2);
|
|
137
|
-
expect(args.handleAfterClose).toHaveBeenCalledWith();
|
|
138
|
-
});
|
|
139
|
-
// Open
|
|
140
|
-
await userEvent.click(trigger);
|
|
141
|
-
// TODO: Fails CLI tests in Storybook without a timeout
|
|
142
|
-
await sleep(100);
|
|
143
|
-
// Close by pressing Escape
|
|
144
|
-
await userEvent.keyboard("{Escape}");
|
|
145
|
-
expect(args.handleClose).toHaveBeenCalledTimes(2);
|
|
146
|
-
expect(args.handleClose).toHaveBeenCalledWith({ reason: "escape-key" });
|
|
147
|
-
await waitFor(() => {
|
|
148
|
-
expect(args.handleAfterClose).toHaveBeenCalledTimes(3);
|
|
149
|
-
expect(args.handleAfterClose).toHaveBeenCalledWith();
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
export const disableCloseOnClick = {
|
|
154
|
-
name: "disableCloseOnClick",
|
|
155
|
-
args: {
|
|
156
|
-
handleClose: fn(),
|
|
157
|
-
},
|
|
158
|
-
render: (args) => (<Overlay active disableCloseOnClick onClose={(closeArgs) => {
|
|
159
|
-
args.handleClose(closeArgs);
|
|
160
|
-
}}>
|
|
161
|
-
Content
|
|
162
|
-
</Overlay>),
|
|
163
|
-
play: async ({ canvasElement, args }) => {
|
|
164
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
165
|
-
const overlay = canvas.getByText("Content");
|
|
166
|
-
await userEvent.click(overlay);
|
|
167
|
-
// TODO: Fails CLI tests in Storybook without a timeout
|
|
168
|
-
await sleep(100);
|
|
169
|
-
expect(args.handleClose).toHaveBeenCalledTimes(0);
|
|
170
|
-
await userEvent.keyboard("{Escape}");
|
|
171
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
export const containerRef = {
|
|
175
|
-
name: "containerRef",
|
|
176
|
-
render: () => {
|
|
177
|
-
const containerRef = React.useRef(null);
|
|
178
|
-
return (<>
|
|
179
|
-
<div ref={containerRef} data-testid="test-id" style={{ height: 200 }}/>
|
|
180
|
-
<Overlay active containerRef={containerRef}>
|
|
181
|
-
Content
|
|
182
|
-
</Overlay>
|
|
183
|
-
</>);
|
|
184
|
-
},
|
|
185
|
-
play: ({ canvasElement }) => {
|
|
186
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
187
|
-
const container = canvas.getByTestId("test-id");
|
|
188
|
-
const overlay = canvas.getByText("Content");
|
|
189
|
-
expect(container).toContainElement(overlay);
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
export const className = {
|
|
193
|
-
name: "className, attributes",
|
|
194
|
-
render: () => (<Overlay active className="test-classname" attributes={{ "data-testid": "test-id" }}>
|
|
195
|
-
Content
|
|
196
|
-
</Overlay>),
|
|
197
|
-
play: async ({ canvasElement }) => {
|
|
198
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
199
|
-
const root = canvas.getByTestId("test-id");
|
|
200
|
-
expect(root).toHaveClass("test-classname");
|
|
201
|
-
},
|
|
202
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { fn } from "storybook/test";
|
|
2
|
-
import { StoryObj } from "@storybook/react-vite";
|
|
3
|
-
declare const _default: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: import("react").FC<import("./..").PaginationProps>;
|
|
6
|
-
parameters: {
|
|
7
|
-
iframe: {
|
|
8
|
-
url: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
|
13
|
-
export declare const truncate: {
|
|
14
|
-
name: string;
|
|
15
|
-
render: () => import("react").JSX.Element;
|
|
16
|
-
};
|
|
17
|
-
export declare const render: StoryObj;
|
|
18
|
-
export declare const defaultPage: StoryObj<{
|
|
19
|
-
handleChange: ReturnType<typeof fn>;
|
|
20
|
-
}>;
|
|
21
|
-
export declare const page: StoryObj<{
|
|
22
|
-
handleChange: ReturnType<typeof fn>;
|
|
23
|
-
}>;
|
|
24
|
-
export declare const className: StoryObj;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { Example } from "../../../utilities/storybook/index.js";
|
|
2
|
-
import Pagination from "../index.js";
|
|
3
|
-
import { expect, fn, userEvent, within } from "storybook/test";
|
|
4
|
-
export default {
|
|
5
|
-
title: "Components/Pagination",
|
|
6
|
-
component: Pagination,
|
|
7
|
-
parameters: {
|
|
8
|
-
iframe: {
|
|
9
|
-
url: "https://reshaped.so/docs/components/pagination",
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export const truncate = {
|
|
14
|
-
name: "truncate",
|
|
15
|
-
render: () => {
|
|
16
|
-
return (<Example>
|
|
17
|
-
<Example.Item title="start">
|
|
18
|
-
<Pagination total={10} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
|
19
|
-
</Example.Item>
|
|
20
|
-
<Example.Item title="middle">
|
|
21
|
-
<Pagination total={10} defaultPage={5} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
|
22
|
-
</Example.Item>
|
|
23
|
-
<Example.Item title="end">
|
|
24
|
-
<Pagination total={10} defaultPage={10} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
|
25
|
-
</Example.Item>
|
|
26
|
-
<Example.Item title="no truncation">
|
|
27
|
-
<Pagination total={4} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
|
28
|
-
</Example.Item>
|
|
29
|
-
</Example>);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
export const render = {
|
|
33
|
-
name: "rendering",
|
|
34
|
-
render: () => (<div data-testid="root">
|
|
35
|
-
<Pagination total={10} previousAriaLabel="Previous" nextAriaLabel="Next" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
|
36
|
-
</div>),
|
|
37
|
-
play: async ({ canvas }) => {
|
|
38
|
-
const root = within(canvas.getByTestId("root"));
|
|
39
|
-
const buttons = root.getAllByRole("button");
|
|
40
|
-
const pages = buttons.slice(1, -1);
|
|
41
|
-
const prevButton = root.getByLabelText("Previous");
|
|
42
|
-
const nextButton = root.getByLabelText("Next");
|
|
43
|
-
const firstPageButton = root.getByLabelText("Page 1");
|
|
44
|
-
expect(buttons.length).toBe(8);
|
|
45
|
-
expect(prevButton).toEqual(buttons[0]);
|
|
46
|
-
expect(prevButton).toBeDisabled();
|
|
47
|
-
expect(nextButton).toEqual(buttons.at(-1));
|
|
48
|
-
expect(nextButton).not.toBeDisabled();
|
|
49
|
-
expect(firstPageButton).toBeInTheDocument();
|
|
50
|
-
expect(firstPageButton).toEqual(pages[0]);
|
|
51
|
-
expect(firstPageButton).toHaveAttribute("aria-current", "true");
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
export const defaultPage = {
|
|
55
|
-
name: "defaultPage, uncontrolled",
|
|
56
|
-
args: {
|
|
57
|
-
handleChange: fn(),
|
|
58
|
-
},
|
|
59
|
-
render: (args) => (<div data-testid="root">
|
|
60
|
-
<Pagination total={10} defaultPage={2} onChange={args.handleChange} previousAriaLabel="Previous" nextAriaLabel="Next"/>
|
|
61
|
-
</div>),
|
|
62
|
-
play: async ({ canvas, args }) => {
|
|
63
|
-
const root = within(canvas.getByTestId("root"));
|
|
64
|
-
const buttons = root.getAllByRole("button");
|
|
65
|
-
const pages = buttons.slice(1, -1);
|
|
66
|
-
expect(pages[1]).toHaveAttribute("aria-current");
|
|
67
|
-
await userEvent.click(pages[2]);
|
|
68
|
-
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
|
69
|
-
expect(args.handleChange).toHaveBeenCalledWith({ page: 3 });
|
|
70
|
-
expect(pages[1]).toHaveAttribute("aria-current", "false");
|
|
71
|
-
expect(pages[2]).toHaveAttribute("aria-current", "true");
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
export const page = {
|
|
75
|
-
name: "page, controlled",
|
|
76
|
-
args: {
|
|
77
|
-
handleChange: fn(),
|
|
78
|
-
},
|
|
79
|
-
render: (args) => (<div data-testid="root">
|
|
80
|
-
<Pagination total={10} page={2} onChange={args.handleChange} previousAriaLabel="Previous" nextAriaLabel="Next"/>
|
|
81
|
-
</div>),
|
|
82
|
-
play: async ({ canvas, args }) => {
|
|
83
|
-
const root = within(canvas.getByTestId("root"));
|
|
84
|
-
const buttons = root.getAllByRole("button");
|
|
85
|
-
const pages = buttons.slice(1, -1);
|
|
86
|
-
expect(pages[1]).toHaveAttribute("aria-current");
|
|
87
|
-
await userEvent.click(pages[2]);
|
|
88
|
-
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
|
89
|
-
expect(args.handleChange).toHaveBeenCalledWith({ page: 3 });
|
|
90
|
-
// Stays the same because it's controlled
|
|
91
|
-
expect(pages[1]).toHaveAttribute("aria-current", "true");
|
|
92
|
-
expect(pages[2]).toHaveAttribute("aria-current", "false");
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
export const className = {
|
|
96
|
-
name: "className, attributes",
|
|
97
|
-
render: () => (<div data-testid="root">
|
|
98
|
-
<Pagination className="test-classname" attributes={{ id: "test-id" }} total={10} previousAriaLabel="Previous" nextAriaLabel="Next"/>
|
|
99
|
-
</div>),
|
|
100
|
-
play: async ({ canvas }) => {
|
|
101
|
-
const root = canvas.getByTestId("root").firstChild;
|
|
102
|
-
expect(root).toHaveClass("test-classname");
|
|
103
|
-
expect(root).toHaveAttribute("id", "test-id");
|
|
104
|
-
},
|
|
105
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { fn } from "storybook/test";
|
|
3
|
-
declare const _default: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: import("react").FC<import("./..").PinFieldProps>;
|
|
6
|
-
parameters: {
|
|
7
|
-
iframe: {
|
|
8
|
-
url: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
|
13
|
-
export declare const base: StoryObj;
|
|
14
|
-
export declare const variant: {
|
|
15
|
-
name: string;
|
|
16
|
-
render: () => import("react").JSX.Element;
|
|
17
|
-
};
|
|
18
|
-
export declare const size: {
|
|
19
|
-
name: string;
|
|
20
|
-
render: () => import("react").JSX.Element;
|
|
21
|
-
};
|
|
22
|
-
export declare const valueLength: StoryObj;
|
|
23
|
-
export declare const defaultValue: StoryObj<{
|
|
24
|
-
handleChange?: ReturnType<typeof fn>;
|
|
25
|
-
}>;
|
|
26
|
-
export declare const value: StoryObj<{
|
|
27
|
-
handleChange?: ReturnType<typeof fn>;
|
|
28
|
-
}>;
|
|
29
|
-
export declare const pattern: StoryObj<{
|
|
30
|
-
handleChange?: ReturnType<typeof fn>;
|
|
31
|
-
}>;
|
|
32
|
-
export declare const className: StoryObj;
|
|
33
|
-
export declare const formControl: StoryObj;
|
|
34
|
-
export declare const keyboard: StoryObj;
|