reshaped 3.3.11 → 3.3.13
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 +12 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +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/Carousel.js +52 -4
- package/dist/components/Carousel/Carousel.types.d.ts +4 -0
- package/dist/components/Carousel/CarouselControl.js +1 -1
- package/dist/components/Carousel/tests/Carousel.stories.d.ts +23 -4
- package/dist/components/Carousel/tests/Carousel.stories.js +199 -102
- 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/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/index.d.ts +1 -1
- package/dist/components/Table/tests/Table.stories.d.ts +5 -5
- 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/index.d.ts +1 -1
- 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 +42 -41
- 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,101 @@
|
|
1
|
+
import { expect, within, userEvent, waitFor } from "@storybook/test";
|
2
|
+
import { useToast, ToastProvider } from "../index.js";
|
3
|
+
import Button from "../../Button/index.js";
|
4
|
+
export default {
|
5
|
+
title: "Components/Toast/tests",
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/toast",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const base = {
|
14
|
+
name: "base",
|
15
|
+
render: () => {
|
16
|
+
const toast = useToast();
|
17
|
+
return (<Button onClick={() => {
|
18
|
+
const id = toast.show({
|
19
|
+
title: "Title",
|
20
|
+
text: "Text",
|
21
|
+
children: "Children",
|
22
|
+
startSlot: "Slot",
|
23
|
+
actionsSlot: (<Button attributes={{ "data-testid": "trigger-id" }} onClick={() => toast.hide(id)}>
|
24
|
+
Trigger
|
25
|
+
</Button>),
|
26
|
+
});
|
27
|
+
}}>
|
28
|
+
Show toast
|
29
|
+
</Button>);
|
30
|
+
},
|
31
|
+
play: async ({ canvasElement }) => {
|
32
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
33
|
+
const button = canvas.getAllByRole("button")[0];
|
34
|
+
await userEvent.click(button);
|
35
|
+
const title = canvas.getByText("Title");
|
36
|
+
const text = canvas.getByText("Text");
|
37
|
+
const children = canvas.getByText("Children");
|
38
|
+
const slot = canvas.getByText("Slot");
|
39
|
+
const action = canvas.getByTestId("trigger-id");
|
40
|
+
expect(title).toBeInTheDocument();
|
41
|
+
expect(text).toBeInTheDocument();
|
42
|
+
expect(children).toBeInTheDocument();
|
43
|
+
expect(slot).toBeInTheDocument();
|
44
|
+
expect(action).toBeInTheDocument();
|
45
|
+
await userEvent.click(action);
|
46
|
+
await waitFor(() => {
|
47
|
+
expect(title).not.toBeInTheDocument();
|
48
|
+
});
|
49
|
+
},
|
50
|
+
};
|
51
|
+
const NestedDemo = () => {
|
52
|
+
const toast = useToast();
|
53
|
+
return (<Button onClick={() => {
|
54
|
+
toast.show({
|
55
|
+
text: "Content",
|
56
|
+
});
|
57
|
+
}}>
|
58
|
+
Show toast
|
59
|
+
</Button>);
|
60
|
+
};
|
61
|
+
export const nested = {
|
62
|
+
name: "ToastProvider",
|
63
|
+
render: () => {
|
64
|
+
return (<div data-testid="test-container-id">
|
65
|
+
<ToastProvider>
|
66
|
+
<NestedDemo />
|
67
|
+
</ToastProvider>
|
68
|
+
</div>);
|
69
|
+
},
|
70
|
+
play: async ({ canvasElement }) => {
|
71
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
72
|
+
const button = canvas.getAllByRole("button")[0];
|
73
|
+
await userEvent.click(button);
|
74
|
+
const container = canvas.getByTestId("test-container-id");
|
75
|
+
const toast = within(container).getByText("Content");
|
76
|
+
expect(toast).toBeInTheDocument();
|
77
|
+
},
|
78
|
+
};
|
79
|
+
export const className = {
|
80
|
+
name: "className, attributes",
|
81
|
+
render: () => {
|
82
|
+
const toast = useToast();
|
83
|
+
return (<Button onClick={() => {
|
84
|
+
const id = toast.show({
|
85
|
+
text: "Content",
|
86
|
+
attributes: { "data-testid": "test-id" },
|
87
|
+
className: "test-classname",
|
88
|
+
});
|
89
|
+
}}>
|
90
|
+
Show toast
|
91
|
+
</Button>);
|
92
|
+
},
|
93
|
+
play: async ({ canvasElement }) => {
|
94
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
95
|
+
const button = canvas.getAllByRole("button")[0];
|
96
|
+
await userEvent.click(button);
|
97
|
+
const toast = canvas.getByTestId("test-id");
|
98
|
+
expect(toast).toBeInTheDocument();
|
99
|
+
expect(toast).toHaveClass("test-classname");
|
100
|
+
},
|
101
|
+
};
|
@@ -4,7 +4,6 @@ import Popover from "../../Popover/index.js";
|
|
4
4
|
import Button from "../../Button/index.js";
|
5
5
|
import View from "../../View/index.js";
|
6
6
|
import useResponsiveClientValue from "../../../hooks/useResponsiveClientValue.js";
|
7
|
-
import Actionable from "../../Actionable/index.js";
|
8
7
|
export default {
|
9
8
|
title: "Components/Tooltip",
|
10
9
|
component: Tooltip,
|
@@ -109,19 +108,6 @@ export const edgeCases = () => (<Example>
|
|
109
108
|
</Tooltip>
|
110
109
|
</Example.Item>
|
111
110
|
|
112
|
-
<Example.Item title="tooltip with popover on different elements">
|
113
|
-
<Tooltip text="Tooltip" position="top">
|
114
|
-
{(attributes) => (<Actionable attributes={attributes} as="span">
|
115
|
-
<Popover position="bottom">
|
116
|
-
<Popover.Trigger>
|
117
|
-
{(popoverAttributes) => (<Button attributes={{ ...attributes, ...popoverAttributes }}>Action</Button>)}
|
118
|
-
</Popover.Trigger>
|
119
|
-
<Popover.Content>Popover</Popover.Content>
|
120
|
-
</Popover>
|
121
|
-
</Actionable>)}
|
122
|
-
</Tooltip>
|
123
|
-
</Example.Item>
|
124
|
-
|
125
111
|
<Example.Item title="nested popovers inside a tooltip">
|
126
112
|
<View direction="row" gap={2}>
|
127
113
|
<Tooltip position="top" text="Hello">
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: (props: import("./..").TooltipProps) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: string;
|
9
|
+
};
|
10
|
+
chromatic: {
|
11
|
+
disableSnapshot: boolean;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export default _default;
|
16
|
+
export declare const defaultActive: StoryObj<{
|
17
|
+
handleOpen: ReturnType<typeof fn>;
|
18
|
+
handleClose: ReturnType<typeof fn>;
|
19
|
+
}>;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { expect, fn, userEvent, within, waitFor } from "@storybook/test";
|
2
|
+
import Tooltip from "../index.js";
|
3
|
+
import Button from "../../Button/index.js";
|
4
|
+
export default {
|
5
|
+
title: "Components/Tooltip/tests",
|
6
|
+
component: Tooltip,
|
7
|
+
parameters: {
|
8
|
+
iframe: {
|
9
|
+
url: "https://reshaped.so/docs/components/tooltip",
|
10
|
+
},
|
11
|
+
chromatic: { disableSnapshot: true },
|
12
|
+
},
|
13
|
+
};
|
14
|
+
export const defaultActive = {
|
15
|
+
name: "uncontrolled",
|
16
|
+
args: {
|
17
|
+
handleOpen: fn(),
|
18
|
+
handleClose: fn(),
|
19
|
+
},
|
20
|
+
render: (args) => (<Tooltip text="Content" onOpen={args.handleOpen} onClose={args.handleClose}>
|
21
|
+
{(attributes) => <Button attributes={attributes}>Trigger</Button>}
|
22
|
+
</Tooltip>),
|
23
|
+
play: async ({ canvasElement, args }) => {
|
24
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
25
|
+
const trigger = canvas.getAllByRole("button")[0];
|
26
|
+
await userEvent.hover(trigger);
|
27
|
+
await waitFor(() => {
|
28
|
+
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
29
|
+
expect(args.handleOpen).toHaveBeenCalledWith();
|
30
|
+
});
|
31
|
+
const item = canvas.getByText("Content");
|
32
|
+
expect(item).toBeInTheDocument();
|
33
|
+
await userEvent.unhover(trigger);
|
34
|
+
await waitFor(() => {
|
35
|
+
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
36
|
+
expect(args.handleClose).toHaveBeenCalledWith();
|
37
|
+
expect(item).not.toBeInTheDocument();
|
38
|
+
});
|
39
|
+
},
|
40
|
+
};
|
@@ -135,9 +135,8 @@ const View = (props) => {
|
|
135
135
|
return child.props.children.map((child) => {
|
136
136
|
if (!child)
|
137
137
|
return null;
|
138
|
-
const index = usedIndex;
|
139
138
|
renderedItemIndex += 1;
|
140
|
-
return renderItem({ child, index });
|
139
|
+
return renderItem({ child, index: renderedItemIndex });
|
141
140
|
});
|
142
141
|
}
|
143
142
|
return renderItem({ child, index: usedIndex });
|
@@ -13,31 +13,115 @@ declare const _default: {
|
|
13
13
|
};
|
14
14
|
};
|
15
15
|
export default _default;
|
16
|
-
export declare const padding:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
export declare const
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
export declare const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
export declare const
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
export declare const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
export declare const
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
export declare const
|
41
|
-
|
42
|
-
|
43
|
-
|
16
|
+
export declare const padding: {
|
17
|
+
name: string;
|
18
|
+
render: () => React.JSX.Element;
|
19
|
+
};
|
20
|
+
export declare const direction: {
|
21
|
+
name: string;
|
22
|
+
render: () => React.JSX.Element;
|
23
|
+
};
|
24
|
+
export declare const gap: {
|
25
|
+
name: string;
|
26
|
+
render: () => React.JSX.Element;
|
27
|
+
};
|
28
|
+
export declare const divided: {
|
29
|
+
name: string;
|
30
|
+
render: () => React.JSX.Element;
|
31
|
+
};
|
32
|
+
export declare const bleed: {
|
33
|
+
name: string;
|
34
|
+
render: () => React.JSX.Element;
|
35
|
+
};
|
36
|
+
export declare const wrap: {
|
37
|
+
name: string;
|
38
|
+
render: () => React.JSX.Element;
|
39
|
+
};
|
40
|
+
export declare const align: {
|
41
|
+
name: string;
|
42
|
+
render: () => React.JSX.Element;
|
43
|
+
};
|
44
|
+
export declare const justify: {
|
45
|
+
name: string;
|
46
|
+
render: () => React.JSX.Element;
|
47
|
+
};
|
48
|
+
export declare const textAlign: {
|
49
|
+
name: string;
|
50
|
+
render: () => React.JSX.Element;
|
51
|
+
};
|
52
|
+
export declare const size: {
|
53
|
+
name: string;
|
54
|
+
render: () => React.JSX.Element;
|
55
|
+
};
|
56
|
+
export declare const ratio: {
|
57
|
+
name: string;
|
58
|
+
render: () => React.JSX.Element;
|
59
|
+
};
|
60
|
+
export declare const maxSize: {
|
61
|
+
name: string;
|
62
|
+
render: () => React.JSX.Element;
|
63
|
+
};
|
64
|
+
export declare const minSize: {
|
65
|
+
name: string;
|
66
|
+
render: () => React.JSX.Element;
|
67
|
+
};
|
68
|
+
export declare const background: {
|
69
|
+
name: string;
|
70
|
+
render: () => React.JSX.Element;
|
71
|
+
};
|
72
|
+
export declare const border: {
|
73
|
+
name: string;
|
74
|
+
render: () => React.JSX.Element;
|
75
|
+
};
|
76
|
+
export declare const radius: {
|
77
|
+
name: string;
|
78
|
+
render: () => React.JSX.Element;
|
79
|
+
};
|
80
|
+
export declare const shadow: {
|
81
|
+
name: string;
|
82
|
+
render: () => React.JSX.Element;
|
83
|
+
};
|
84
|
+
export declare const overflow: {
|
85
|
+
name: string;
|
86
|
+
render: () => React.JSX.Element;
|
87
|
+
};
|
88
|
+
export declare const positioning: {
|
89
|
+
name: string;
|
90
|
+
render: () => React.JSX.Element;
|
91
|
+
};
|
92
|
+
export declare const inset: {
|
93
|
+
name: string;
|
94
|
+
render: () => React.JSX.Element;
|
95
|
+
};
|
96
|
+
export declare const animated: {
|
97
|
+
name: string;
|
98
|
+
render: () => React.JSX.Element;
|
99
|
+
};
|
100
|
+
export declare const itemGapBefore: {
|
101
|
+
name: string;
|
102
|
+
render: () => React.JSX.Element;
|
103
|
+
};
|
104
|
+
export declare const itemGrow: {
|
105
|
+
name: string;
|
106
|
+
render: () => React.JSX.Element;
|
107
|
+
};
|
108
|
+
export declare const itemColumns: {
|
109
|
+
name: string;
|
110
|
+
render: () => React.JSX.Element;
|
111
|
+
};
|
112
|
+
export declare const itemOrder: {
|
113
|
+
name: string;
|
114
|
+
render: () => React.JSX.Element;
|
115
|
+
};
|
116
|
+
export declare const hiddenItem: {
|
117
|
+
name: string;
|
118
|
+
render: () => React.JSX.Element;
|
119
|
+
};
|
120
|
+
export declare const nestedGaps: {
|
121
|
+
name: string;
|
122
|
+
render: () => React.JSX.Element;
|
123
|
+
};
|
124
|
+
export declare const testComposition: {
|
125
|
+
name: string;
|
126
|
+
render: () => React.JSX.Element;
|
127
|
+
};
|