reshaped 3.3.11 → 3.3.12
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/CHANGELOG.md +9 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +16 -17
- package/dist/cjs/themes/_generator/utilities/generateColors.d.ts +1 -1
- package/dist/cjs/themes/_generator/utilities/generateColors.js +3 -2
- package/dist/cjs/themes/_generator/utilities/tests/color.test.js +32 -31
- package/dist/cjs/themes/slate/theme.css +1 -1
- package/dist/components/Accordion/tests/Accordion.stories.d.ts +30 -8
- package/dist/components/Accordion/tests/Accordion.stories.js +172 -119
- package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +12 -3
- package/dist/components/ActionBar/tests/ActionBar.stories.js +51 -36
- package/dist/components/ActionBar/tests/ActionBar.test.stories.d.ts +15 -0
- package/dist/components/ActionBar/tests/ActionBar.test.stories.js +26 -0
- package/dist/components/Actionable/Actionable.js +1 -1
- package/dist/components/Actionable/tests/Actionable.stories.d.ts +19 -5
- package/dist/components/Actionable/tests/Actionable.stories.js +88 -63
- package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +32 -0
- package/dist/components/Actionable/tests/Actionable.test.stories.js +130 -0
- package/dist/components/Alert/Alert.js +1 -1
- package/dist/components/Alert/tests/Alert.stories.d.ts +12 -3
- package/dist/components/Alert/tests/Alert.stories.js +51 -86
- package/dist/components/Alert/tests/Alert.test.stories.d.ts +15 -0
- package/dist/components/Alert/tests/Alert.test.stories.js +26 -0
- package/dist/components/Autocomplete/Autocomplete.js +9 -2
- package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +6 -2
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +94 -111
- package/dist/components/Autocomplete/tests/Autocomplete.test.stories.d.ts +23 -0
- package/dist/components/Autocomplete/tests/Autocomplete.test.stories.js +86 -0
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Avatar/tests/Avatar.stories.d.ts +14 -4
- package/dist/components/Avatar/tests/Avatar.stories.js +94 -80
- package/dist/components/Avatar/tests/Avatar.test.stories.d.ts +17 -0
- package/dist/components/Avatar/tests/Avatar.test.stories.js +39 -0
- package/dist/components/Badge/tests/Badge.stories.d.ts +33 -8
- package/dist/components/Badge/tests/Badge.stories.js +238 -212
- package/dist/components/Badge/tests/Badge.test.stories.d.ts +20 -0
- package/dist/components/Badge/tests/Badge.test.stories.js +44 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +1 -0
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +24 -5
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +114 -95
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +23 -0
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +76 -0
- package/dist/components/Button/Button.js +5 -2
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Button/Button.types.d.ts +1 -0
- package/dist/components/Button/tests/Button.stories.d.ts +2 -2
- package/dist/components/Button/tests/Button.stories.js +77 -74
- package/dist/components/Button/tests/Button.test.stories.d.ts +27 -0
- package/dist/components/Button/tests/Button.test.stories.js +112 -0
- package/dist/components/Calendar/tests/Calendar.test.stories.d.ts +26 -0
- package/dist/components/Calendar/tests/Calendar.test.stories.js +161 -0
- package/dist/components/Card/tests/Card.stories.d.ts +0 -1
- package/dist/components/Card/tests/Card.stories.js +0 -11
- package/dist/components/Card/tests/Card.test.stories.d.ts +35 -0
- package/dist/components/Card/tests/Card.test.stories.js +54 -0
- package/dist/components/Carousel/CarouselControl.js +1 -1
- package/dist/components/Carousel/tests/Carousel.stories.d.ts +3 -0
- package/dist/components/Carousel/tests/Carousel.stories.js +4 -0
- package/dist/components/Carousel/tests/Carousel.test.stories.d.ts +17 -0
- package/dist/components/Carousel/tests/Carousel.test.stories.js +52 -0
- package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +25 -0
- package/dist/components/Checkbox/tests/Checkbox.test.stories.js +104 -0
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +22 -0
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +78 -0
- package/dist/components/Container/Container.module.css +1 -1
- package/dist/components/Container/tests/Container.stories.d.ts +12 -3
- package/dist/components/Container/tests/Container.stories.js +50 -31
- package/dist/components/Container/tests/Container.test.stories.d.ts +15 -0
- package/dist/components/Container/tests/Container.test.stories.js +26 -0
- package/dist/components/ContextMenu/ContextMenu.js +13 -9
- package/dist/components/ContextMenu/tests/ContextMenu.stories.js +2 -3
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +26 -0
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +53 -0
- package/dist/components/Dismissible/Dismissible.js +1 -1
- package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +10 -3
- package/dist/components/Dismissible/tests/Dismissible.stories.js +51 -34
- package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +19 -0
- package/dist/components/Dismissible/tests/Dismissible.test.stories.js +42 -0
- package/dist/components/Divider/tests/Divider.test.stories.d.ts +18 -0
- package/dist/components/Divider/tests/Divider.test.stories.js +47 -0
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +37 -0
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +117 -0
- package/dist/components/FileUpload/tests/FileUpload.test.stories.d.ts +22 -0
- package/dist/components/FileUpload/tests/FileUpload.test.stories.js +52 -0
- package/dist/components/FormControl/FormControlCaption.js +1 -1
- package/dist/components/FormControl/FormControlLabel.js +1 -1
- package/dist/components/FormControl/tests/FormControl.stories.d.ts +11 -5
- package/dist/components/FormControl/tests/FormControl.stories.js +78 -73
- package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +20 -0
- package/dist/components/FormControl/tests/FormControl.test.stories.js +49 -0
- package/dist/components/Grid/tests/Grid.stories.d.ts +20 -5
- package/dist/components/Grid/tests/Grid.stories.js +164 -149
- package/dist/components/Grid/tests/Grid.test.stories.d.ts +19 -0
- package/dist/components/Grid/tests/Grid.test.stories.js +42 -0
- package/dist/components/Hidden/tests/Hidden.stories.d.ts +4 -1
- package/dist/components/Hidden/tests/Hidden.stories.js +28 -25
- package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +15 -0
- package/dist/components/Hidden/tests/Hidden.test.stories.js +20 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +4 -1
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +8 -5
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +15 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +20 -0
- package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +15 -0
- package/dist/components/Hotkey/tests/Hotkey.test.stories.js +26 -0
- package/dist/components/Icon/tests/Icon.stories.d.ts +12 -3
- package/dist/components/Icon/tests/Icon.stories.js +69 -60
- package/dist/components/Icon/tests/Icon.test.stories.d.ts +16 -0
- package/dist/components/Icon/tests/Icon.test.stories.js +35 -0
- package/dist/components/Image/tests/Image.stories.d.ts +24 -5
- package/dist/components/Image/tests/Image.stories.js +95 -75
- package/dist/components/Image/tests/Image.test.stories.d.ts +25 -0
- package/dist/components/Image/tests/Image.test.stories.js +80 -0
- package/dist/components/Link/tests/Link.test.stories.d.ts +29 -0
- package/dist/components/Link/tests/Link.test.stories.js +87 -0
- package/dist/components/Loader/Loader.js +1 -1
- package/dist/components/Loader/Loader.types.d.ts +1 -0
- package/dist/components/Loader/tests/Loader.stories.js +8 -8
- package/dist/components/Loader/tests/Loader.test.stories.d.ts +16 -0
- package/dist/components/Loader/tests/Loader.test.stories.js +32 -0
- package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +26 -0
- package/dist/components/MenuItem/tests/MenuItem.test.stories.js +100 -0
- package/dist/components/Modal/tests/Modal.test.stories.d.ts +32 -0
- package/dist/components/Modal/tests/Modal.test.stories.js +149 -0
- package/dist/components/Overlay/tests/Overlay.stories.d.ts +4 -2
- package/dist/components/Overlay/tests/Overlay.stories.js +53 -53
- package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +28 -0
- package/dist/components/Overlay/tests/Overlay.test.stories.js +146 -0
- package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +23 -0
- package/dist/components/Pagination/tests/Pagination.test.stories.js +86 -0
- package/dist/components/PinField/tests/PinField.stories.d.ts +0 -1
- package/dist/components/PinField/tests/PinField.stories.js +10 -19
- package/dist/components/PinField/tests/PinField.test.stories.d.ts +29 -0
- package/dist/components/PinField/tests/PinField.test.stories.js +177 -0
- package/dist/components/Popover/tests/Popover.test.stories.d.ts +40 -0
- package/dist/components/Popover/tests/Popover.test.stories.js +167 -0
- package/dist/components/Progress/Progress.js +2 -2
- package/dist/components/Progress/Progress.types.d.ts +1 -0
- package/dist/components/Progress/tests/Progress.stories.js +10 -10
- package/dist/components/Progress/tests/Progress.test.stories.d.ts +16 -0
- package/dist/components/Progress/tests/Progress.test.stories.js +35 -0
- package/dist/components/Radio/tests/Radio.test.stories.d.ts +30 -0
- package/dist/components/Radio/tests/Radio.test.stories.js +118 -0
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +22 -0
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +78 -0
- package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +33 -0
- package/dist/components/Reshaped/tests/Reshaped.stories.js +88 -0
- package/dist/components/Resizable/Resizable.js +1 -0
- package/dist/components/Resizable/tests/Resizable.stories.d.ts +3 -0
- package/dist/components/Resizable/tests/Resizable.stories.js +4 -0
- package/dist/components/Resizable/tests/Resizable.test.stories.d.ts +19 -0
- package/dist/components/Resizable/tests/Resizable.test.stories.js +25 -0
- package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +15 -0
- package/dist/components/Scrim/tests/Scrim.test.stories.js +25 -0
- package/dist/components/ScrollArea/ScrollArea.js +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +17 -4
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +114 -139
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +23 -0
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +66 -0
- package/dist/components/Select/tests/Select.stories.d.ts +1 -1
- package/dist/components/Select/tests/Select.stories.js +5 -12
- package/dist/components/Select/tests/Select.test.stories.d.ts +27 -0
- package/dist/components/Select/tests/Select.test.stories.js +132 -0
- package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +15 -0
- package/dist/components/Skeleton/tests/Skeleton.test.stories.js +23 -0
- package/dist/components/Slider/tests/Slider.stories.d.ts +0 -1
- package/dist/components/Slider/tests/Slider.stories.js +8 -9
- package/dist/components/Slider/tests/Slider.test.stories.d.ts +38 -0
- package/dist/components/Slider/tests/Slider.test.stories.js +150 -0
- package/dist/components/Stepper/Stepper.js +1 -1
- package/dist/components/Stepper/tests/Stepper.stories.js +0 -3
- package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +18 -0
- package/dist/components/Stepper/tests/Stepper.test.stories.js +28 -0
- package/dist/components/Switch/tests/Switch.test.stories.d.ts +23 -0
- package/dist/components/Switch/tests/Switch.test.stories.js +79 -0
- package/dist/components/Table/tests/Table.test.stories.d.ts +25 -0
- package/dist/components/Table/tests/Table.test.stories.js +93 -0
- package/dist/components/Tabs/tests/Tabs.stories.js +4 -4
- package/dist/components/Tabs/tests/Tabs.test.stories.d.ts +28 -0
- package/dist/components/Tabs/tests/Tabs.test.stories.js +128 -0
- package/dist/components/Text/tests/Text.stories.d.ts +28 -7
- package/dist/components/Text/tests/Text.stories.js +148 -125
- package/dist/components/Text/tests/Text.test.stories.d.ts +18 -0
- package/dist/components/Text/tests/Text.test.stories.js +49 -0
- package/dist/components/TextArea/TextArea.module.css +1 -1
- package/dist/components/TextArea/tests/TextArea.stories.js +1 -1
- package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +29 -0
- package/dist/components/TextArea/tests/TextArea.test.stories.js +99 -0
- package/dist/components/TextField/tests/TextField.stories.js +1 -1
- package/dist/components/TextField/tests/TextField.test.stories.d.ts +29 -0
- package/dist/components/TextField/tests/TextField.test.stories.js +99 -0
- package/dist/components/Theme/tests/Theme.test.stories.d.ts +24 -0
- package/dist/components/Theme/tests/Theme.test.stories.js +133 -0
- package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +18 -0
- package/dist/components/Timeline/tests/Timeline.test.stories.js +32 -0
- package/dist/components/Toast/tests/Toast.test.stories.d.ts +16 -0
- package/dist/components/Toast/tests/Toast.test.stories.js +101 -0
- package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -14
- package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +19 -0
- package/dist/components/Tooltip/tests/Tooltip.test.stories.js +40 -0
- package/dist/components/View/View.js +1 -2
- package/dist/components/View/tests/View.stories.d.ts +112 -28
- package/dist/components/View/tests/View.stories.js +1092 -1012
- package/dist/components/View/tests/View.test.stories.d.ts +20 -0
- package/dist/components/View/tests/View.test.stories.js +50 -0
- package/dist/components/_private/Flyout/FlyoutContent.js +1 -1
- package/dist/components/_private/Flyout/tests/Flyout.stories.js +4 -4
- package/dist/components/_private/Flyout/tests/Flyout.test.stories.d.ts +28 -0
- package/dist/components/_private/Flyout/tests/Flyout.test.stories.js +205 -0
- package/dist/components/_private/Portal/tests/Portal.stories.js +1 -1
- package/dist/hooks/_private/useSingletonHotkeys.d.ts +3 -3
- package/dist/hooks/_private/useSingletonHotkeys.js +1 -1
- package/dist/hooks/tests/useDrag.stories.js +1 -0
- package/dist/hooks/tests/useDrag.test.stories.d.ts +26 -0
- package/dist/hooks/tests/useDrag.test.stories.js +120 -0
- package/dist/hooks/tests/useElementId.stories.d.ts +6 -0
- package/dist/hooks/tests/useElementId.stories.js +19 -0
- package/dist/hooks/tests/useHotkeys.test.stories.d.ts +39 -0
- package/dist/hooks/tests/useHotkeys.test.stories.js +119 -0
- package/dist/hooks/tests/useRTL.stories.d.ts +6 -0
- package/dist/hooks/tests/useRTL.stories.js +25 -0
- package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +9 -1
- package/dist/hooks/tests/useResponsiveClientValue.stories.js +22 -9
- package/dist/hooks/tests/useScrollLock.stories.d.ts +6 -0
- package/dist/hooks/tests/useScrollLock.stories.js +22 -0
- package/dist/hooks/tests/useToggle.stories.d.ts +8 -0
- package/dist/hooks/tests/useToggle.stories.js +54 -0
- package/dist/hooks/useHotkeys.js +0 -2
- package/dist/hooks/useScrollLock.d.ts +1 -0
- package/dist/hooks/useScrollLock.js +7 -3
- package/dist/tests/ShadowDOM.stories.js +1 -1
- package/dist/themes/_generator/tests/themes.stories.d.ts +3 -0
- package/dist/themes/_generator/tests/themes.stories.js +7 -11
- package/dist/themes/_generator/utilities/generateColors.d.ts +1 -1
- package/dist/themes/_generator/utilities/generateColors.js +3 -2
- package/dist/themes/slate/theme.css +1 -1
- package/dist/utilities/helpers.d.ts +1 -0
- package/dist/utilities/helpers.js +3 -0
- package/dist/utilities/scroll/lock.d.ts +1 -0
- package/dist/utilities/scroll/lock.js +3 -3
- package/dist/utilities/scroll/lockSafari.d.ts +1 -1
- package/dist/utilities/scroll/lockSafari.js +4 -5
- package/dist/utilities/scroll/lockStandard.d.ts +4 -1
- package/dist/utilities/scroll/lockStandard.js +7 -2
- package/dist/utilities/storybook/Example.js +1 -2
- package/package.json +20 -19
- package/dist/components/Theme/tests/Theme.stories.d.ts +0 -13
- package/dist/components/Theme/tests/Theme.stories.js +0 -80
- package/dist/utilities/storybook/Example.module.css +0 -1
@@ -0,0 +1,38 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: (props: import("./..").SliderProps) => import("react").JSX.Element;
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: string;
|
9
|
+
};
|
10
|
+
chromatic: {
|
11
|
+
disableSnapshot: boolean;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export default _default;
|
16
|
+
export declare const defaultValue: StoryObj<{
|
17
|
+
handleChange: ReturnType<typeof fn>;
|
18
|
+
handleChangeCommit: ReturnType<typeof fn>;
|
19
|
+
}>;
|
20
|
+
export declare const value: StoryObj<{
|
21
|
+
handleChange: ReturnType<typeof fn>;
|
22
|
+
handleChangeCommit: ReturnType<typeof fn>;
|
23
|
+
}>;
|
24
|
+
export declare const rangeDefaultValue: StoryObj<{
|
25
|
+
handleChange: ReturnType<typeof fn>;
|
26
|
+
handleChangeCommit: ReturnType<typeof fn>;
|
27
|
+
}>;
|
28
|
+
export declare const rangeValue: StoryObj<{
|
29
|
+
handleChange: ReturnType<typeof fn>;
|
30
|
+
handleChangeCommit: ReturnType<typeof fn>;
|
31
|
+
}>;
|
32
|
+
export declare const minMax: StoryObj;
|
33
|
+
export declare const step: StoryObj;
|
34
|
+
export declare const stepFloat: StoryObj;
|
35
|
+
export declare const renderValue: StoryObj;
|
36
|
+
export declare const withoutTooltipValue: StoryObj;
|
37
|
+
export declare const disabled: StoryObj;
|
38
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,150 @@
|
|
1
|
+
import { expect, fn, fireEvent } from "@storybook/test";
|
2
|
+
import Slider from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Slider/tests",
|
5
|
+
component: Slider,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/slider",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const defaultValue = {
|
14
|
+
name: "defaultValue, uncontrolled",
|
15
|
+
args: {
|
16
|
+
handleChange: fn(),
|
17
|
+
handleChangeCommit: fn(),
|
18
|
+
},
|
19
|
+
render: (args) => (<Slider name="test-name" defaultValue={50} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>),
|
20
|
+
play: async ({ canvas, args }) => {
|
21
|
+
const input = canvas.getByRole("slider");
|
22
|
+
expect(input).toHaveValue("50");
|
23
|
+
fireEvent.change(input, { target: { value: 51 } });
|
24
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
25
|
+
expect(args.handleChange).toHaveBeenCalledWith({ value: 51, name: "test-name" });
|
26
|
+
expect(input).toHaveValue("51");
|
27
|
+
},
|
28
|
+
};
|
29
|
+
export const value = {
|
30
|
+
name: "value, controlled",
|
31
|
+
args: {
|
32
|
+
handleChange: fn(),
|
33
|
+
handleChangeCommit: fn(),
|
34
|
+
},
|
35
|
+
render: (args) => (<Slider name="test-name" value={50} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>),
|
36
|
+
play: async ({ canvas, args }) => {
|
37
|
+
const input = canvas.getByRole("slider");
|
38
|
+
expect(input).toHaveValue("50");
|
39
|
+
fireEvent.change(input, { target: { value: 51 } });
|
40
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
41
|
+
expect(args.handleChange).toHaveBeenCalledWith({ value: 51, name: "test-name" });
|
42
|
+
expect(input).toHaveValue("50");
|
43
|
+
},
|
44
|
+
};
|
45
|
+
export const rangeDefaultValue = {
|
46
|
+
name: "range, defaultValue, uncontrolled",
|
47
|
+
args: {
|
48
|
+
handleChange: fn(),
|
49
|
+
handleChangeCommit: fn(),
|
50
|
+
},
|
51
|
+
render: (args) => (<Slider range name="test-name" defaultMinValue={50} defaultMaxValue={70} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>),
|
52
|
+
play: async ({ canvas, args }) => {
|
53
|
+
const [minInput, maxInput] = canvas.getAllByRole("slider");
|
54
|
+
expect(minInput).toHaveValue("50");
|
55
|
+
expect(maxInput).toHaveValue("70");
|
56
|
+
fireEvent.change(minInput, { target: { value: 51 } });
|
57
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
58
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
59
|
+
minValue: 51,
|
60
|
+
maxValue: 70,
|
61
|
+
name: "test-name",
|
62
|
+
});
|
63
|
+
expect(minInput).toHaveValue("51");
|
64
|
+
expect(maxInput).toHaveValue("70");
|
65
|
+
},
|
66
|
+
};
|
67
|
+
export const rangeValue = {
|
68
|
+
name: "range, value, controlled",
|
69
|
+
args: {
|
70
|
+
handleChange: fn(),
|
71
|
+
handleChangeCommit: fn(),
|
72
|
+
},
|
73
|
+
render: (args) => (<Slider range name="test-name" minValue={50} maxValue={70} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>),
|
74
|
+
play: async ({ canvas, args }) => {
|
75
|
+
const [minInput, maxInput] = canvas.getAllByRole("slider");
|
76
|
+
expect(minInput).toHaveValue("50");
|
77
|
+
expect(maxInput).toHaveValue("70");
|
78
|
+
fireEvent.change(minInput, { target: { value: 51 } });
|
79
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
80
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
81
|
+
minValue: 51,
|
82
|
+
maxValue: 70,
|
83
|
+
name: "test-name",
|
84
|
+
});
|
85
|
+
expect(minInput).toHaveValue("50");
|
86
|
+
expect(maxInput).toHaveValue("70");
|
87
|
+
},
|
88
|
+
};
|
89
|
+
export const minMax = {
|
90
|
+
name: "min, max",
|
91
|
+
render: () => <Slider name="nmae" range min={50} max={70}/>,
|
92
|
+
play: async ({ canvas }) => {
|
93
|
+
const [minInputEl, maxInputEl] = canvas.getAllByRole("slider");
|
94
|
+
expect(minInputEl).toHaveAttribute("min", "50");
|
95
|
+
expect(minInputEl).toHaveAttribute("max", "70");
|
96
|
+
expect(maxInputEl).toHaveAttribute("min", "50");
|
97
|
+
expect(maxInputEl).toHaveAttribute("max", "70");
|
98
|
+
},
|
99
|
+
};
|
100
|
+
export const step = {
|
101
|
+
name: "step",
|
102
|
+
render: () => <Slider name="name" defaultValue={11} step={5}/>,
|
103
|
+
play: async ({ canvas }) => {
|
104
|
+
const inputEl = canvas.getByRole("slider");
|
105
|
+
expect(inputEl).toHaveValue("10");
|
106
|
+
},
|
107
|
+
};
|
108
|
+
export const stepFloat = {
|
109
|
+
name: "step, float",
|
110
|
+
render: () => <Slider name="name" defaultValue={20.24} step={0.1}/>,
|
111
|
+
play: async ({ canvas }) => {
|
112
|
+
const inputEl = canvas.getByRole("slider");
|
113
|
+
expect(inputEl).toHaveValue("20.2");
|
114
|
+
},
|
115
|
+
};
|
116
|
+
export const renderValue = {
|
117
|
+
name: "renderValue",
|
118
|
+
render: () => <Slider name="name" defaultValue={50} renderValue={(args) => `$${args.value}`}/>,
|
119
|
+
play: async ({ canvas }) => {
|
120
|
+
const tooltipEl = canvas.getByText(`$50`);
|
121
|
+
expect(tooltipEl).toBeInTheDocument();
|
122
|
+
},
|
123
|
+
};
|
124
|
+
export const withoutTooltipValue = {
|
125
|
+
name: "renderValue=false",
|
126
|
+
render: () => <Slider name="name" defaultValue={50} renderValue={false}/>,
|
127
|
+
play: async ({ canvas }) => {
|
128
|
+
const tooltipEl = canvas.queryByText(`$50`);
|
129
|
+
expect(tooltipEl).not.toBeInTheDocument();
|
130
|
+
},
|
131
|
+
};
|
132
|
+
export const disabled = {
|
133
|
+
name: "disabled",
|
134
|
+
render: () => <Slider name="name" defaultValue={50} disabled/>,
|
135
|
+
play: async ({ canvas }) => {
|
136
|
+
const inputEl = canvas.getByRole("slider");
|
137
|
+
expect(inputEl).toBeDisabled();
|
138
|
+
},
|
139
|
+
};
|
140
|
+
export const className = {
|
141
|
+
name: "className, attributes",
|
142
|
+
render: () => (<div data-testid="root">
|
143
|
+
<Slider name="name" className="test-classname" attributes={{ id: "test-id" }}/>
|
144
|
+
</div>),
|
145
|
+
play: async ({ canvas }) => {
|
146
|
+
const root = canvas.getByTestId("root").firstChild;
|
147
|
+
expect(root).toHaveClass("test-classname");
|
148
|
+
expect(root).toHaveAttribute("id", "test-id");
|
149
|
+
},
|
150
|
+
};
|
@@ -13,7 +13,7 @@ const StepperItemPrivate = (props) => {
|
|
13
13
|
const { title, subtitle, children, direction, className, attributes, labelDisplay, step, completed, active, last, } = props;
|
14
14
|
const labelHidden = labelDisplay && responsivePropDependency(labelDisplay, (value) => value === "hidden");
|
15
15
|
const labelNode = (_jsx(View, { gap: 3, grow: true, children: _jsxs(View.Item, { children: [_jsx(Text, { variant: "body-3", weight: "medium", children: title }), _jsx(Text, { variant: "caption-1", color: "neutral-faded", children: subtitle })] }) }));
|
16
|
-
return (_jsxs(View, {
|
16
|
+
return (_jsxs(View, { attributes: attributes, className: className, children: [_jsxs(View, { direction: "row", gap: 2, align: "center", position: "static", children: [_jsxs(View.Item, { children: [_jsx(View, { align: "center", justify: "center", backgroundColor: active || completed ? "primary" : "neutral-faded", borderColor: active || completed ? undefined : "neutral-faded", borderRadius: "circular", as: "span", width: 8, height: 8, zIndex: 5, children: _jsx(Text, { variant: "body-3", weight: active ? "bold" : "medium", children: completed ? _jsx(Icon, { svg: IconCheckmark, size: 4 }) : step }) }), direction === "column" && !last && _jsx(Divider, { vertical: true, className: s.verticalDivider })] }), labelDisplay ? _jsx(Hidden, { hide: labelHidden, children: labelNode }) : labelNode] }), direction === "column" && children && (_jsx(Expandable, { active: active, children: _jsx(View, { paddingStart: 10, paddingTop: 2, children: children }) }))] }));
|
17
17
|
};
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
19
19
|
const StepperItem = (_) => null;
|
@@ -73,9 +73,6 @@ export const labelDisplay = () => (<Example>
|
|
73
73
|
</Example.Item>
|
74
74
|
</Example>);
|
75
75
|
export const edgeCases = () => (<Example>
|
76
|
-
<Example.Item title="collapsible">
|
77
|
-
<Demo />
|
78
|
-
</Example.Item>
|
79
76
|
<Example.Item title={[
|
80
77
|
"multiline subtitle",
|
81
78
|
"should wrap the text correctly",
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
component: {
|
5
|
+
(props: import("./..").StepperProps): import("react").JSX.Element;
|
6
|
+
Item: (_: import("../Stepper.types").ItemProps) => null;
|
7
|
+
};
|
8
|
+
parameters: {
|
9
|
+
iframe: {
|
10
|
+
url: string;
|
11
|
+
};
|
12
|
+
chromatic: {
|
13
|
+
disableSnapshot: boolean;
|
14
|
+
};
|
15
|
+
};
|
16
|
+
};
|
17
|
+
export default _default;
|
18
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { expect } from "@storybook/test";
|
2
|
+
import Stepper from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Stepper/tests",
|
5
|
+
component: Stepper,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/stepper",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const className = {
|
14
|
+
name: "className, attributes",
|
15
|
+
render: () => (<div data-testid="root">
|
16
|
+
<Stepper className="test-classname" attributes={{ id: "test-id" }}>
|
17
|
+
<Stepper.Item attributes={{ id: "test-item-id" }} className="test-item-classname"/>
|
18
|
+
</Stepper>
|
19
|
+
</div>),
|
20
|
+
play: async ({ canvas }) => {
|
21
|
+
const root = canvas.getByTestId("root").firstChild;
|
22
|
+
const item = root?.firstChild;
|
23
|
+
expect(root).toHaveClass("test-classname");
|
24
|
+
expect(root).toHaveAttribute("id", "test-id");
|
25
|
+
expect(item).toHaveClass("test-item-classname");
|
26
|
+
expect(item).toHaveAttribute("id", "test-item-id");
|
27
|
+
},
|
28
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: (props: import("./..").SwitchProps) => import("react").JSX.Element;
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: string;
|
9
|
+
};
|
10
|
+
chromatic: {
|
11
|
+
disableSnapshot: boolean;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export default _default;
|
16
|
+
export declare const defaultChecked: StoryObj<{
|
17
|
+
handleChange: ReturnType<typeof fn>;
|
18
|
+
}>;
|
19
|
+
export declare const checked: StoryObj<{
|
20
|
+
handleChange: ReturnType<typeof fn>;
|
21
|
+
}>;
|
22
|
+
export declare const disabled: StoryObj;
|
23
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { expect, fn, userEvent } from "@storybook/test";
|
2
|
+
import Switch from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Switch/tests",
|
5
|
+
component: Switch,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/switch",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const defaultChecked = {
|
14
|
+
name: "defaultChecked, uncontrolled",
|
15
|
+
args: {
|
16
|
+
handleChange: fn(),
|
17
|
+
},
|
18
|
+
render: (args) => (<Switch name="test-name" defaultChecked onChange={args.handleChange}>
|
19
|
+
Label
|
20
|
+
</Switch>),
|
21
|
+
play: async ({ canvas, args }) => {
|
22
|
+
const input = canvas.getByRole("checkbox");
|
23
|
+
expect(input).toBeChecked();
|
24
|
+
await userEvent.click(input);
|
25
|
+
expect(args.handleChange).toBeCalledTimes(1);
|
26
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
27
|
+
name: "test-name",
|
28
|
+
checked: false,
|
29
|
+
event: expect.objectContaining({ target: input }),
|
30
|
+
});
|
31
|
+
expect(input).not.toBeChecked();
|
32
|
+
},
|
33
|
+
};
|
34
|
+
export const checked = {
|
35
|
+
name: "checked, uncontrolled",
|
36
|
+
args: {
|
37
|
+
handleChange: fn(),
|
38
|
+
},
|
39
|
+
render: (args) => (<Switch name="test-name" checked onChange={args.handleChange}>
|
40
|
+
Label
|
41
|
+
</Switch>),
|
42
|
+
play: async ({ canvas, args }) => {
|
43
|
+
const input = canvas.getByRole("checkbox");
|
44
|
+
expect(input).toBeChecked();
|
45
|
+
await userEvent.click(input);
|
46
|
+
expect(args.handleChange).toBeCalledTimes(1);
|
47
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
48
|
+
name: "test-name",
|
49
|
+
checked: false,
|
50
|
+
event: expect.objectContaining({ target: input }),
|
51
|
+
});
|
52
|
+
expect(input).toBeChecked();
|
53
|
+
},
|
54
|
+
};
|
55
|
+
export const disabled = {
|
56
|
+
name: "disabled",
|
57
|
+
render: () => (<Switch disabled name="name">
|
58
|
+
Label
|
59
|
+
</Switch>),
|
60
|
+
play: async ({ canvas }) => {
|
61
|
+
const input = canvas.getByRole("checkbox");
|
62
|
+
expect(input).toBeDisabled();
|
63
|
+
},
|
64
|
+
};
|
65
|
+
export const className = {
|
66
|
+
name: "className, attributes",
|
67
|
+
render: () => (<div data-testid="root">
|
68
|
+
<Switch className="test-classname" attributes={{ id: "test-id" }} inputAttributes={{ "aria-label": "test select", id: "test-input-id" }} name="name">
|
69
|
+
Label
|
70
|
+
</Switch>
|
71
|
+
</div>),
|
72
|
+
play: async ({ canvas }) => {
|
73
|
+
const root = canvas.getByTestId("root").firstChild;
|
74
|
+
const input = canvas.getByRole("checkbox");
|
75
|
+
expect(root).toHaveClass("test-classname");
|
76
|
+
expect(root).toHaveAttribute("id", "test-id");
|
77
|
+
expect(input).toHaveAttribute("id", "test-input-id");
|
78
|
+
},
|
79
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
component: {
|
5
|
+
(props: import("./..").TableProps): import("react").JSX.Element;
|
6
|
+
Cell: (props: import("../Table.types").CellProps) => import("react").JSX.Element;
|
7
|
+
Heading: (props: import("../Table.types").HeadingProps) => import("react").JSX.Element;
|
8
|
+
Row: (props: import("../Table.types").RowProps) => import("react").JSX.Element;
|
9
|
+
Body: (props: import("../Table.types").BodyProps) => import("react").JSX.Element;
|
10
|
+
Head: (props: import("../Table.types").HeadProps) => import("react").JSX.Element;
|
11
|
+
};
|
12
|
+
parameters: {
|
13
|
+
iframe: {
|
14
|
+
url: string;
|
15
|
+
};
|
16
|
+
chromatic: {
|
17
|
+
disableSnapshot: boolean;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
};
|
21
|
+
export default _default;
|
22
|
+
export declare const render: StoryObj;
|
23
|
+
export declare const tbody: StoryObj;
|
24
|
+
export declare const tabIndex: StoryObj;
|
25
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import { expect } from "@storybook/test";
|
2
|
+
import Table from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Table/tests",
|
5
|
+
component: Table,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/table",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const render = {
|
14
|
+
name: "rendering",
|
15
|
+
render: () => (<Table>
|
16
|
+
<Table.Head>
|
17
|
+
<Table.Row>
|
18
|
+
<Table.Heading>Heading</Table.Heading>
|
19
|
+
<Table.Heading>Heading</Table.Heading>
|
20
|
+
</Table.Row>
|
21
|
+
</Table.Head>
|
22
|
+
<Table.Body>
|
23
|
+
<Table.Row>
|
24
|
+
<Table.Cell>Content</Table.Cell>
|
25
|
+
<Table.Cell>Content</Table.Cell>
|
26
|
+
</Table.Row>
|
27
|
+
</Table.Body>
|
28
|
+
</Table>),
|
29
|
+
play: async ({ canvas }) => {
|
30
|
+
const body = canvas.getAllByRole("rowgroup");
|
31
|
+
const rows = canvas.getAllByRole("row");
|
32
|
+
const headings = canvas.getAllByRole("columnheader");
|
33
|
+
const cells = canvas.getAllByRole("cell");
|
34
|
+
expect(body).toHaveLength(2);
|
35
|
+
expect(rows).toHaveLength(2);
|
36
|
+
expect(headings).toHaveLength(2);
|
37
|
+
expect(cells).toHaveLength(2);
|
38
|
+
expect(canvas.getAllByText("Heading")).toHaveLength(2);
|
39
|
+
expect(canvas.getAllByText("Content")).toHaveLength(2);
|
40
|
+
},
|
41
|
+
};
|
42
|
+
export const tbody = {
|
43
|
+
name: "tbody rendering",
|
44
|
+
render: () => (<Table>
|
45
|
+
<Table.Row>
|
46
|
+
<Table.Heading>Heading</Table.Heading>
|
47
|
+
<Table.Heading>Heading</Table.Heading>
|
48
|
+
</Table.Row>
|
49
|
+
</Table>),
|
50
|
+
play: async ({ canvas }) => {
|
51
|
+
const body = canvas.getByRole("rowgroup");
|
52
|
+
expect(body).toBeInTheDocument();
|
53
|
+
},
|
54
|
+
};
|
55
|
+
export const tabIndex = {
|
56
|
+
name: "adds tabIndex for clickable rows",
|
57
|
+
render: () => (<Table>
|
58
|
+
<Table.Row>
|
59
|
+
<Table.Cell />
|
60
|
+
</Table.Row>
|
61
|
+
<Table.Row onClick={() => { }}>
|
62
|
+
<Table.Cell />
|
63
|
+
</Table.Row>
|
64
|
+
<Table.Row attributes={{ onClick: () => { } }}>
|
65
|
+
<Table.Cell />
|
66
|
+
</Table.Row>
|
67
|
+
</Table>),
|
68
|
+
play: async ({ canvas }) => {
|
69
|
+
const elRows = canvas.getAllByRole("row");
|
70
|
+
expect(elRows[0]).not.toHaveAttribute("tabIndex");
|
71
|
+
expect(elRows[1]).toHaveAttribute("tabIndex", "0");
|
72
|
+
expect(elRows[2]).toHaveAttribute("tabIndex", "0");
|
73
|
+
},
|
74
|
+
};
|
75
|
+
export const className = {
|
76
|
+
name: "className, attributes",
|
77
|
+
render: () => (<div data-testid="root">
|
78
|
+
<Table className="test-classname" attributes={{ id: "test-id" }}>
|
79
|
+
<Table.Row attributes={{ id: "test-row-id" }}>
|
80
|
+
<Table.Cell attributes={{ id: "test-cell-id" }}></Table.Cell>
|
81
|
+
</Table.Row>
|
82
|
+
</Table>
|
83
|
+
</div>),
|
84
|
+
play: async ({ canvas }) => {
|
85
|
+
const root = canvas.getByTestId("root").firstChild;
|
86
|
+
const row = canvas.getByRole("row");
|
87
|
+
const cell = canvas.getByRole("cell");
|
88
|
+
expect(root).toHaveClass("test-classname");
|
89
|
+
expect(root).toHaveAttribute("id", "test-id");
|
90
|
+
expect(row).toHaveAttribute("id", "test-row-id");
|
91
|
+
expect(cell).toHaveAttribute("id", "test-cell-id");
|
92
|
+
},
|
93
|
+
};
|
@@ -302,7 +302,7 @@ export const edgeCaseDom = () => {
|
|
302
302
|
<Text>Section 1</Text>
|
303
303
|
|
304
304
|
<View gap={1} direction="row">
|
305
|
-
{[...Array(4)].map((i) => (<View grow height="100px" backgroundColor="neutral-faded" key={i}/>))}
|
305
|
+
{[...Array(4)].map((_, i) => (<View grow height="100px" backgroundColor="neutral-faded" key={i}/>))}
|
306
306
|
</View>
|
307
307
|
</View>
|
308
308
|
|
@@ -310,7 +310,7 @@ export const edgeCaseDom = () => {
|
|
310
310
|
<Text>Section 2</Text>
|
311
311
|
|
312
312
|
<View gap={1} direction="row">
|
313
|
-
{[...Array(4)].map((i) => (<View grow height="100px" backgroundColor="neutral-faded"/>))}
|
313
|
+
{[...Array(4)].map((_, i) => (<View key={i} grow height="100px" backgroundColor="neutral-faded"/>))}
|
314
314
|
</View>
|
315
315
|
</View>
|
316
316
|
|
@@ -318,7 +318,7 @@ export const edgeCaseDom = () => {
|
|
318
318
|
<Text>Section 3</Text>
|
319
319
|
|
320
320
|
<View gap={1} direction="row">
|
321
|
-
{[...Array(4)].map((i) => (<View grow height="100px" backgroundColor="neutral-faded"/>))}
|
321
|
+
{[...Array(4)].map((_, i) => (<View key={i} grow height="100px" backgroundColor="neutral-faded"/>))}
|
322
322
|
</View>
|
323
323
|
</View>
|
324
324
|
|
@@ -326,7 +326,7 @@ export const edgeCaseDom = () => {
|
|
326
326
|
<Text>Section 4</Text>
|
327
327
|
|
328
328
|
<View gap={1} direction="row">
|
329
|
-
{[...Array(4)].map((i) => (<View grow height="100px" backgroundColor="neutral-faded"/>))}
|
329
|
+
{[...Array(4)].map((_, i) => (<View key={i} grow height="100px" backgroundColor="neutral-faded"/>))}
|
330
330
|
</View>
|
331
331
|
</View>
|
332
332
|
</View>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: {
|
6
|
+
(props: import("./..").TabsProps): import("react").JSX.Element;
|
7
|
+
Item: import("react").ForwardRefExoticComponent<import("./..").TabsItemProps & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
8
|
+
List: (props: import("../Tabs.types").ListProps) => import("react").JSX.Element;
|
9
|
+
Panel: (props: import("../Tabs.types").PanelProps) => import("react").JSX.Element;
|
10
|
+
};
|
11
|
+
parameters: {
|
12
|
+
iframe: {
|
13
|
+
url: string;
|
14
|
+
};
|
15
|
+
chromatic: {
|
16
|
+
disableSnapshot: boolean;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
};
|
20
|
+
export default _default;
|
21
|
+
export declare const base: StoryObj;
|
22
|
+
export declare const defaultValue: StoryObj<{
|
23
|
+
handleChange: ReturnType<typeof fn>;
|
24
|
+
}>;
|
25
|
+
export declare const value: StoryObj<{
|
26
|
+
handleChange: ReturnType<typeof fn>;
|
27
|
+
}>;
|
28
|
+
export declare const className: StoryObj;
|