reshaped 3.6.0-canary.0 → 3.6.0-canary.2
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 +21 -2
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +11 -11
- package/dist/components/Accordion/AccordionControlled.js +1 -1
- package/dist/components/Accordion/AccordionTrigger.js +1 -1
- package/dist/components/ActionBar/ActionBar.js +1 -1
- package/dist/components/Actionable/Actionable.js +1 -1
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +1 -0
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Badge/Badge.js +1 -1
- package/dist/components/Badge/BadgeContainer.js +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/ButtonGroup.js +1 -1
- package/dist/components/Calendar/CalendarDate.js +1 -1
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/Card/tests/Card.stories.d.ts +1 -1
- package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
- package/dist/components/Carousel/Carousel.js +4 -3
- package/dist/components/Carousel/CarouselControl.js +1 -1
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Checkbox/Checkbox.module.css +1 -1
- package/dist/components/Container/Container.js +1 -1
- package/dist/components/Dismissible/Dismissible.js +1 -1
- package/dist/components/Divider/Divider.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/FileUpload/FileUpload.js +1 -1
- package/dist/components/Flyout/Flyout.types.d.ts +3 -2
- package/dist/components/Flyout/FlyoutContent.js +14 -11
- package/dist/components/Flyout/tests/Flyout.stories.d.ts +4 -0
- package/dist/components/Flyout/tests/Flyout.stories.js +20 -4
- package/dist/components/Flyout/useFlyout.js +13 -9
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +1 -1
- package/dist/components/Flyout/utilities/calculatePosition.js +1 -1
- package/dist/components/Flyout/utilities/flyout.js +4 -4
- package/dist/components/FormControl/FormControl.context.d.ts +0 -2
- package/dist/components/Grid/Grid.js +1 -1
- package/dist/components/Hidden/Hidden.js +1 -1
- package/dist/components/Hotkey/Hotkey.js +1 -1
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Image/Image.js +1 -1
- package/dist/components/Link/Link.js +1 -1
- package/dist/components/Loader/Loader.js +1 -1
- package/dist/components/MenuItem/MenuItem.js +1 -1
- package/dist/components/Modal/Modal.js +2 -2
- package/dist/components/Modal/Modal.module.css +1 -1
- package/dist/components/NumberField/NumberFieldControlled.js +1 -1
- package/dist/components/Overlay/Overlay.js +3 -3
- package/dist/components/Overlay/Overlay.module.css +1 -1
- package/dist/components/Overlay/Overlay.types.d.ts +1 -0
- package/dist/components/PinField/PinFieldControlled.js +1 -1
- package/dist/components/Popover/Popover.js +3 -3
- package/dist/components/Popover/Popover.module.css +1 -1
- package/dist/components/Popover/Popover.types.d.ts +1 -0
- package/dist/components/Popover/tests/Popover.stories.d.ts +46 -7
- package/dist/components/Popover/tests/Popover.stories.js +209 -85
- package/dist/components/Progress/Progress.js +1 -1
- package/dist/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/Radio/Radio.module.css +1 -1
- package/dist/components/Reshaped/Reshaped.js +1 -1
- package/dist/components/Resizable/Resizable.js +1 -1
- package/dist/components/Scrim/Scrim.js +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +8 -11
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +13 -4
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +129 -30
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Slider/Slider.types.d.ts +34 -7
- package/dist/components/Slider/SliderControlled.js +32 -20
- package/dist/components/Slider/SliderThumb.js +4 -4
- package/dist/components/Slider/SliderUncontrolled.js +3 -2
- package/dist/components/Slider/tests/Slider.stories.d.ts +38 -8
- package/dist/components/Slider/tests/Slider.stories.js +268 -54
- package/dist/components/Stepper/Stepper.js +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Table/Table.js +6 -3
- package/dist/components/Table/Table.module.css +1 -1
- package/dist/components/Tabs/TabsItem.js +1 -1
- package/dist/components/Tabs/TabsList.js +3 -34
- package/dist/components/Tabs/TabsPanel.js +1 -1
- package/dist/components/Text/Text.js +1 -1
- package/dist/components/TextArea/TextArea.js +1 -1
- package/dist/components/TextField/TextField.js +1 -1
- package/dist/components/Theme/Theme.js +1 -1
- package/dist/components/Timeline/Timeline.js +1 -1
- package/dist/components/Toast/ToastContainer.js +1 -1
- package/dist/components/Toast/ToastRegion.js +1 -1
- package/dist/components/View/View.js +1 -1
- package/dist/components/_private/Aligner/Aligner.js +1 -1
- package/dist/components/_private/Expandable/Expandable.js +1 -1
- package/dist/components/_private/HiddenInput/HiddenInput.js +1 -1
- package/dist/hooks/_private/useFadeSide.d.ts +5 -0
- package/dist/hooks/_private/useFadeSide.js +47 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles/align/index.js +1 -1
- package/dist/styles/aspectRatio/index.js +1 -1
- package/dist/styles/bleed/index.js +1 -1
- package/dist/styles/border/index.js +1 -1
- package/dist/styles/height/index.js +1 -1
- package/dist/styles/inset/index.js +1 -1
- package/dist/styles/justify/index.js +1 -1
- package/dist/styles/maxHeight/index.js +1 -1
- package/dist/styles/maxWidth/index.js +1 -1
- package/dist/styles/minHeight/index.js +1 -1
- package/dist/styles/minWidth/index.js +1 -1
- package/dist/styles/padding/index.js +1 -1
- package/dist/styles/position/index.js +1 -1
- package/dist/styles/radius/index.js +1 -1
- package/dist/styles/textAlign/index.js +1 -1
- package/dist/styles/width/index.js +1 -1
- package/dist/utilities/dom/event.d.ts +7 -0
- package/dist/utilities/dom/event.js +11 -0
- package/dist/utilities/dom/find.d.ts +1 -1
- package/dist/utilities/dom/find.js +2 -2
- package/dist/utilities/dom/index.d.ts +1 -0
- package/dist/utilities/dom/index.js +1 -0
- package/dist/utilities/helpers.d.ts +1 -15
- package/dist/utilities/helpers.js +11 -133
- package/dist/utilities/props.d.ts +13 -0
- package/dist/utilities/props.js +83 -0
- package/package.json +25 -26
- package/dist/components/Popover/tests/Popover.test.stories.d.ts +0 -39
- package/dist/components/Popover/tests/Popover.test.stories.js +0 -167
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +0 -23
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +0 -66
- package/dist/components/Slider/tests/Slider.test.stories.d.ts +0 -38
- package/dist/components/Slider/tests/Slider.test.stories.js +0 -150
@@ -1,167 +0,0 @@
|
|
1
|
-
import { expect, fn, userEvent, within, waitFor } from "@storybook/test";
|
2
|
-
import Popover from "../index.js";
|
3
|
-
import Button from "../../Button/index.js";
|
4
|
-
import { sleep } from "../../../utilities/helpers.js";
|
5
|
-
export default {
|
6
|
-
title: "Components/Popover/tests",
|
7
|
-
component: Popover,
|
8
|
-
parameters: {
|
9
|
-
iframe: {
|
10
|
-
url: "https://reshaped.so/docs/components/popover",
|
11
|
-
},
|
12
|
-
chromatic: { disableSnapshot: true },
|
13
|
-
},
|
14
|
-
};
|
15
|
-
export const defaultActive = {
|
16
|
-
name: "defaultActive, uncontrolled",
|
17
|
-
args: {
|
18
|
-
handleOpen: fn(),
|
19
|
-
handleClose: fn(),
|
20
|
-
},
|
21
|
-
render: (args) => (<Popover onOpen={args.handleOpen} onClose={args.handleClose} defaultActive>
|
22
|
-
<Popover.Trigger>
|
23
|
-
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
24
|
-
</Popover.Trigger>
|
25
|
-
<Popover.Content>Content</Popover.Content>
|
26
|
-
</Popover>),
|
27
|
-
play: async ({ canvasElement, args }) => {
|
28
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
29
|
-
const trigger = canvas.getAllByRole("button")[0];
|
30
|
-
let item = canvas.getByText("Content");
|
31
|
-
// Wait for the open animation
|
32
|
-
await sleep(500);
|
33
|
-
await userEvent.click(document.body);
|
34
|
-
await waitFor(() => {
|
35
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
36
|
-
expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
|
37
|
-
expect(item).not.toBeInTheDocument();
|
38
|
-
});
|
39
|
-
await userEvent.click(trigger);
|
40
|
-
await waitFor(() => {
|
41
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
42
|
-
expect(args.handleOpen).toHaveBeenCalledWith();
|
43
|
-
});
|
44
|
-
item = canvas.getByText("Content");
|
45
|
-
expect(item).toBeInTheDocument();
|
46
|
-
},
|
47
|
-
};
|
48
|
-
export const active = {
|
49
|
-
name: "active, controlled",
|
50
|
-
args: {
|
51
|
-
handleOpen: fn(),
|
52
|
-
handleClose: fn(),
|
53
|
-
},
|
54
|
-
render: (args) => (<Popover onOpen={args.handleOpen} onClose={args.handleClose} active>
|
55
|
-
<Popover.Trigger>
|
56
|
-
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
57
|
-
</Popover.Trigger>
|
58
|
-
<Popover.Content>Content</Popover.Content>
|
59
|
-
</Popover>),
|
60
|
-
play: async ({ canvasElement, args }) => {
|
61
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
62
|
-
const item = canvas.getByText("Content");
|
63
|
-
await userEvent.click(document.body);
|
64
|
-
await waitFor(() => {
|
65
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
66
|
-
expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
|
67
|
-
});
|
68
|
-
expect(item).toBeInTheDocument();
|
69
|
-
},
|
70
|
-
};
|
71
|
-
export const activeFalse = {
|
72
|
-
name: "active false, controlled",
|
73
|
-
args: {
|
74
|
-
handleOpen: fn(),
|
75
|
-
handleClose: fn(),
|
76
|
-
},
|
77
|
-
render: (args) => (<Popover onOpen={args.handleOpen} onClose={args.handleClose} active={false}>
|
78
|
-
<Popover.Trigger>
|
79
|
-
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
80
|
-
</Popover.Trigger>
|
81
|
-
<Popover.Content>Content</Popover.Content>
|
82
|
-
</Popover>),
|
83
|
-
play: async ({ canvasElement, args }) => {
|
84
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
85
|
-
const trigger = canvas.getAllByRole("button")[0];
|
86
|
-
await userEvent.click(trigger);
|
87
|
-
await waitFor(() => {
|
88
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
89
|
-
expect(args.handleOpen).toHaveBeenCalledWith();
|
90
|
-
});
|
91
|
-
const item = canvas.queryByText("Content");
|
92
|
-
expect(item).not.toBeInTheDocument();
|
93
|
-
},
|
94
|
-
};
|
95
|
-
export const dismissible = {
|
96
|
-
name: "dismissible, onClose, className, attributes, closeAriaLabel",
|
97
|
-
args: {
|
98
|
-
handleClose: fn(),
|
99
|
-
},
|
100
|
-
render: (args) => (<Popover onClose={args.handleClose} defaultActive>
|
101
|
-
<Popover.Trigger>
|
102
|
-
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
103
|
-
</Popover.Trigger>
|
104
|
-
<Popover.Content>
|
105
|
-
<Popover.Dismissible closeAriaLabel="Close" attributes={{ "data-testid": "test-id" }} className="test-classname">
|
106
|
-
Content
|
107
|
-
</Popover.Dismissible>
|
108
|
-
</Popover.Content>
|
109
|
-
</Popover>),
|
110
|
-
play: async ({ canvasElement, args }) => {
|
111
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
112
|
-
const dismissible = canvas.getByTestId("test-id");
|
113
|
-
const closeButton = within(dismissible).getByRole("button");
|
114
|
-
expect(dismissible).toHaveClass("test-classname");
|
115
|
-
expect(closeButton).toHaveAccessibleName("Close");
|
116
|
-
await userEvent.click(closeButton);
|
117
|
-
await waitFor(() => {
|
118
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
119
|
-
expect(args.handleClose).toHaveBeenCalledWith({});
|
120
|
-
});
|
121
|
-
},
|
122
|
-
};
|
123
|
-
export const triggerType = {
|
124
|
-
name: "triggerType hover",
|
125
|
-
args: {
|
126
|
-
handleOpen: fn(),
|
127
|
-
handleClose: fn(),
|
128
|
-
},
|
129
|
-
render: (args) => (<Popover onOpen={args.handleOpen} onClose={args.handleClose} triggerType="hover">
|
130
|
-
<Popover.Trigger>
|
131
|
-
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
132
|
-
</Popover.Trigger>
|
133
|
-
<Popover.Content>Content</Popover.Content>
|
134
|
-
</Popover>),
|
135
|
-
play: async ({ canvasElement, args }) => {
|
136
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
137
|
-
const trigger = canvas.getAllByRole("button")[0];
|
138
|
-
await userEvent.hover(trigger);
|
139
|
-
await waitFor(() => {
|
140
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
141
|
-
expect(args.handleOpen).toHaveBeenCalledWith();
|
142
|
-
});
|
143
|
-
await userEvent.unhover(trigger);
|
144
|
-
await waitFor(() => {
|
145
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
146
|
-
expect(args.handleClose).toHaveBeenCalledWith({});
|
147
|
-
});
|
148
|
-
},
|
149
|
-
};
|
150
|
-
export const className = {
|
151
|
-
name: "className, attributes",
|
152
|
-
render: () => (<div data-testid="root">
|
153
|
-
<Popover active>
|
154
|
-
<Popover.Trigger>
|
155
|
-
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
156
|
-
</Popover.Trigger>
|
157
|
-
<Popover.Content className="test-classname" attributes={{ "data-testid": "test-id" }}>
|
158
|
-
Content
|
159
|
-
</Popover.Content>
|
160
|
-
</Popover>
|
161
|
-
</div>),
|
162
|
-
play: async ({ canvasElement }) => {
|
163
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
164
|
-
const menu = await canvas.findByTestId("test-id");
|
165
|
-
expect(menu).toHaveClass("test-classname");
|
166
|
-
},
|
167
|
-
};
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { StoryObj } from "@storybook/react";
|
3
|
-
import { fn } from "@storybook/test";
|
4
|
-
declare const _default: {
|
5
|
-
title: string;
|
6
|
-
component: React.ForwardRefExoticComponent<import("./..").ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
|
7
|
-
parameters: {
|
8
|
-
iframe: {
|
9
|
-
url: string;
|
10
|
-
};
|
11
|
-
a11y: {
|
12
|
-
disable: boolean;
|
13
|
-
};
|
14
|
-
chromatic: {
|
15
|
-
disableSnapshot: boolean;
|
16
|
-
};
|
17
|
-
};
|
18
|
-
};
|
19
|
-
export default _default;
|
20
|
-
export declare const onScroll: StoryObj<{
|
21
|
-
handleScroll: ReturnType<typeof fn>;
|
22
|
-
}>;
|
23
|
-
export declare const className: StoryObj;
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { expect, fn, userEvent, waitFor } from "@storybook/test";
|
3
|
-
import Button from "../../Button/index.js";
|
4
|
-
import ScrollArea from "../index.js";
|
5
|
-
import View from "../../View/index.js";
|
6
|
-
export default {
|
7
|
-
title: "Utility components/ScrollArea/tests",
|
8
|
-
component: ScrollArea,
|
9
|
-
parameters: {
|
10
|
-
iframe: {
|
11
|
-
url: "https://reshaped.so/docs/utilities/text",
|
12
|
-
},
|
13
|
-
// Skip because axe core incorrectly reports contrast issues
|
14
|
-
a11y: {
|
15
|
-
disable: true,
|
16
|
-
},
|
17
|
-
chromatic: { disableSnapshot: true },
|
18
|
-
},
|
19
|
-
};
|
20
|
-
export const onScroll = {
|
21
|
-
name: "ref, onScroll",
|
22
|
-
args: {
|
23
|
-
handleScroll: fn(),
|
24
|
-
},
|
25
|
-
render: (args) => {
|
26
|
-
const ref = React.useRef(null);
|
27
|
-
return (<View gap={4}>
|
28
|
-
<View.Item>
|
29
|
-
<Button onClick={() => ref.current?.scrollBy({ top: 50, left: 50 })}>Scroll</Button>
|
30
|
-
</View.Item>
|
31
|
-
<ScrollArea height="100px" ref={ref} scrollbarDisplay="visible" onScroll={args.handleScroll}>
|
32
|
-
<View backgroundColor="neutral-faded" padding={4} width="1000px" height="200px">
|
33
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
34
|
-
has been the industry's standard dummy text ever since the 1500s, when an unknown
|
35
|
-
printer took a galley of type and scrambled it to make a type specimen book. It has
|
36
|
-
survived not only five centuries, but also the leap into electronic typesetting,
|
37
|
-
remaining essentially unchanged. It was popularised in the 1960s with the release of
|
38
|
-
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
|
39
|
-
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
40
|
-
</View>
|
41
|
-
</ScrollArea>
|
42
|
-
</View>);
|
43
|
-
},
|
44
|
-
play: async ({ canvas, args }) => {
|
45
|
-
const trigger = canvas.getAllByRole("button")[0];
|
46
|
-
await userEvent.click(trigger);
|
47
|
-
await waitFor(() => {
|
48
|
-
expect(args.handleScroll).toHaveBeenCalledTimes(1);
|
49
|
-
// x value is flaky, so only testing y here
|
50
|
-
expect(args.handleScroll).toHaveBeenCalledWith(expect.objectContaining({ y: 0.5 }));
|
51
|
-
});
|
52
|
-
},
|
53
|
-
};
|
54
|
-
export const className = {
|
55
|
-
name: "className, attributes",
|
56
|
-
render: () => (<div data-testid="root">
|
57
|
-
<ScrollArea className="test-classname" attributes={{ id: "test-id" }}>
|
58
|
-
Content
|
59
|
-
</ScrollArea>
|
60
|
-
</div>),
|
61
|
-
play: async ({ canvas }) => {
|
62
|
-
const root = canvas.getByTestId("root").firstChild;
|
63
|
-
expect(root).toHaveClass("test-classname");
|
64
|
-
expect(root).toHaveAttribute("id", "test-id");
|
65
|
-
},
|
66
|
-
};
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import { StoryObj } from "@storybook/react";
|
2
|
-
import { fn } from "@storybook/test";
|
3
|
-
declare const _default: {
|
4
|
-
title: string;
|
5
|
-
component: import("react").FC<import("./..").SliderProps>;
|
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;
|
@@ -1,150 +0,0 @@
|
|
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
|
-
};
|