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,20 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
component: {
|
5
|
+
<As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewProps<As>): React.ReactNode;
|
6
|
+
Item: <As extends keyof React.JSX.IntrinsicElements = "div">(props: import("./..").ViewItemProps<As>) => React.ReactNode;
|
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 asProp: StoryObj;
|
19
|
+
export declare const className: StoryObj;
|
20
|
+
export declare const itemClassName: StoryObj;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { expect } from "@storybook/test";
|
2
|
+
import View from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Utilities/View/tests",
|
5
|
+
component: View,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/utilities/view",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const asProp = {
|
14
|
+
name: "as",
|
15
|
+
render: () => (<View as="ul">
|
16
|
+
<View.Item as="li">Content</View.Item>
|
17
|
+
</View>),
|
18
|
+
play: async ({ canvas }) => {
|
19
|
+
const list = canvas.getByRole("list");
|
20
|
+
const item = canvas.getByRole("listitem");
|
21
|
+
expect(list).toBeInTheDocument();
|
22
|
+
expect(item).toBeInTheDocument();
|
23
|
+
},
|
24
|
+
};
|
25
|
+
export const className = {
|
26
|
+
name: "className, attributes",
|
27
|
+
render: () => (<div data-testid="root">
|
28
|
+
<View className="test-classname" attributes={{ id: "test-id" }}>
|
29
|
+
Content
|
30
|
+
</View>
|
31
|
+
</div>),
|
32
|
+
play: async ({ canvas }) => {
|
33
|
+
const root = canvas.getByTestId("root").firstChild;
|
34
|
+
expect(root).toHaveClass("test-classname");
|
35
|
+
expect(root).toHaveAttribute("id", "test-id");
|
36
|
+
},
|
37
|
+
};
|
38
|
+
export const itemClassName = {
|
39
|
+
name: "item className, attributes",
|
40
|
+
render: () => (<div data-testid="root">
|
41
|
+
<View.Item className="test-classname" attributes={{ id: "test-id" }}>
|
42
|
+
Content
|
43
|
+
</View.Item>
|
44
|
+
</div>),
|
45
|
+
play: async ({ canvas }) => {
|
46
|
+
const root = canvas.getByTestId("root").firstChild;
|
47
|
+
expect(root).toHaveClass("test-classname");
|
48
|
+
expect(root).toHaveAttribute("id", "test-id");
|
49
|
+
},
|
50
|
+
};
|
@@ -51,7 +51,7 @@ const FlyoutContent = (props) => {
|
|
51
51
|
const content = (_jsx(ContentProvider, { value: { elRef: flyoutElRef }, children: _jsx("div", { className: contentClassNames, style: {
|
52
52
|
...styles,
|
53
53
|
"--rs-flyout-gap": contentGap,
|
54
|
-
}, ref: flyoutElRef, onTransitionEnd: handleTransitionEnd, onMouseEnter: triggerType === "hover" ? handleMouseEnter : undefined, onMouseLeave: triggerType === "hover" ? handleMouseLeave : undefined, onMouseDown: handleContentMouseDown, onTouchStart: handleContentMouseDown, onMouseUp: handleContentMouseUp, onTouchEnd: handleContentMouseUp, children: _jsx("div", { role: role, ...attributes, id: id, "aria-modal":
|
54
|
+
}, ref: flyoutElRef, onTransitionEnd: handleTransitionEnd, onMouseEnter: triggerType === "hover" ? handleMouseEnter : undefined, onMouseLeave: triggerType === "hover" ? handleMouseLeave : undefined, onMouseDown: handleContentMouseDown, onTouchStart: handleContentMouseDown, onMouseUp: handleContentMouseUp, onTouchEnd: handleContentMouseUp, children: _jsx("div", { role: role, ...attributes, id: id, "aria-modal": role === "dialog" ? true : undefined, style: contentAttributes?.style, className: innerClassNames, children: children }) }) }));
|
55
55
|
const closestScrollable = triggerElRef && findClosestRenderContainer({ el: triggerElRef.current });
|
56
56
|
const scrollableRef = closestScrollable === document.body || !closestScrollable
|
57
57
|
? undefined
|
@@ -7,7 +7,7 @@ import Theme from "../../../Theme/index.js";
|
|
7
7
|
import Button from "../../../Button/index.js";
|
8
8
|
import Flyout from "../index.js";
|
9
9
|
import TextField from "../../../TextField/index.js";
|
10
|
-
export default { title: "
|
10
|
+
export default { title: "Internal/Flyout" };
|
11
11
|
const Demo = (props) => {
|
12
12
|
const { position = "bottom-start", children, ...rest } = props;
|
13
13
|
return (<Flyout triggerType="click" position={position} {...rest}>
|
@@ -311,11 +311,11 @@ export const testDisableOutsideClick = () => {
|
|
311
311
|
};
|
312
312
|
export const testScopedTheming = () => (<View gap={3} align="start">
|
313
313
|
<Button color="primary">Reshaped button</Button>
|
314
|
-
<Theme name="
|
314
|
+
<Theme name="slate">
|
315
315
|
<Flyout triggerType="click" active position="bottom-start">
|
316
316
|
<Flyout.Trigger>
|
317
317
|
{(attributes) => (<Button color="primary" attributes={attributes}>
|
318
|
-
|
318
|
+
Slate button
|
319
319
|
</Button>)}
|
320
320
|
</Flyout.Trigger>
|
321
321
|
<Flyout.Content>
|
@@ -327,7 +327,7 @@ export const testScopedTheming = () => (<View gap={3} align="start">
|
|
327
327
|
}}>
|
328
328
|
<View gap={1}>
|
329
329
|
<View.Item>Portal content, rendered in body</View.Item>
|
330
|
-
<Button color="primary">
|
330
|
+
<Button color="primary">Slate button</Button>
|
331
331
|
</View>
|
332
332
|
</div>
|
333
333
|
</Flyout.Content>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
};
|
6
|
+
export default _default;
|
7
|
+
export declare const defaultActive: StoryObj<{
|
8
|
+
handleOpen: ReturnType<typeof fn>;
|
9
|
+
handleClose: ReturnType<typeof fn>;
|
10
|
+
}>;
|
11
|
+
export declare const active: StoryObj<{
|
12
|
+
handleOpen: ReturnType<typeof fn>;
|
13
|
+
handleClose: ReturnType<typeof fn>;
|
14
|
+
}>;
|
15
|
+
export declare const activeFalse: StoryObj<{
|
16
|
+
handleOpen: ReturnType<typeof fn>;
|
17
|
+
handleClose: ReturnType<typeof fn>;
|
18
|
+
}>;
|
19
|
+
export declare const triggerType: StoryObj<{
|
20
|
+
handleOpen: ReturnType<typeof fn>;
|
21
|
+
handleClose: ReturnType<typeof fn>;
|
22
|
+
}>;
|
23
|
+
export declare const disabled: StoryObj<{
|
24
|
+
handleOpen: ReturnType<typeof fn>;
|
25
|
+
}>;
|
26
|
+
export declare const containerRef: StoryObj;
|
27
|
+
export declare const shadowDom: StoryObj;
|
28
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,205 @@
|
|
1
|
+
import { expect, fn, userEvent, within, waitFor } from "@storybook/test";
|
2
|
+
import Flyout from "../index.js";
|
3
|
+
import Button from "../../../Button/index.js";
|
4
|
+
import Reshaped from "../../../Reshaped/index.js";
|
5
|
+
import { useRef } from "react";
|
6
|
+
import { createRoot } from "react-dom/client";
|
7
|
+
import { sleep } from "../../../../utilities/helpers.js";
|
8
|
+
export default {
|
9
|
+
title: "Internal/Flyout/tests",
|
10
|
+
};
|
11
|
+
export const defaultActive = {
|
12
|
+
name: "defaultActive, uncontrolled",
|
13
|
+
args: {
|
14
|
+
handleOpen: fn(),
|
15
|
+
handleClose: fn(),
|
16
|
+
},
|
17
|
+
render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} defaultActive>
|
18
|
+
<Flyout.Trigger>
|
19
|
+
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
20
|
+
</Flyout.Trigger>
|
21
|
+
<Flyout.Content>Content</Flyout.Content>
|
22
|
+
</Flyout>),
|
23
|
+
play: async ({ canvasElement, args }) => {
|
24
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
25
|
+
const trigger = canvas.getAllByRole("button")[0];
|
26
|
+
let item = canvas.getByText("Content");
|
27
|
+
await sleep(500);
|
28
|
+
await userEvent.click(document.body);
|
29
|
+
await waitFor(() => {
|
30
|
+
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
31
|
+
expect(args.handleClose).toHaveBeenCalledWith();
|
32
|
+
expect(item).not.toBeInTheDocument();
|
33
|
+
});
|
34
|
+
await userEvent.click(trigger);
|
35
|
+
await waitFor(() => {
|
36
|
+
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
37
|
+
expect(args.handleOpen).toHaveBeenCalledWith();
|
38
|
+
});
|
39
|
+
item = canvas.getByText("Content");
|
40
|
+
expect(item).toBeInTheDocument();
|
41
|
+
},
|
42
|
+
};
|
43
|
+
export const active = {
|
44
|
+
name: "active, controlled",
|
45
|
+
args: {
|
46
|
+
handleOpen: fn(),
|
47
|
+
handleClose: fn(),
|
48
|
+
},
|
49
|
+
render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} active>
|
50
|
+
<Flyout.Trigger>
|
51
|
+
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
52
|
+
</Flyout.Trigger>
|
53
|
+
<Flyout.Content>Content</Flyout.Content>
|
54
|
+
</Flyout>),
|
55
|
+
play: async ({ canvasElement, args }) => {
|
56
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
57
|
+
const item = canvas.getByText("Content");
|
58
|
+
await userEvent.click(document.body);
|
59
|
+
await waitFor(() => {
|
60
|
+
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
61
|
+
expect(args.handleClose).toHaveBeenCalledWith();
|
62
|
+
});
|
63
|
+
expect(item).toBeInTheDocument();
|
64
|
+
},
|
65
|
+
};
|
66
|
+
export const activeFalse = {
|
67
|
+
name: "active false, controlled",
|
68
|
+
args: {
|
69
|
+
handleOpen: fn(),
|
70
|
+
handleClose: fn(),
|
71
|
+
},
|
72
|
+
render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} active={false}>
|
73
|
+
<Flyout.Trigger>
|
74
|
+
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
75
|
+
</Flyout.Trigger>
|
76
|
+
<Flyout.Content>Content</Flyout.Content>
|
77
|
+
</Flyout>),
|
78
|
+
play: async ({ canvasElement, args }) => {
|
79
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
80
|
+
const trigger = canvas.getAllByRole("button")[0];
|
81
|
+
await userEvent.click(trigger);
|
82
|
+
await waitFor(() => {
|
83
|
+
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
84
|
+
expect(args.handleOpen).toHaveBeenCalledWith();
|
85
|
+
});
|
86
|
+
const item = canvas.queryByText("Content");
|
87
|
+
expect(item).not.toBeInTheDocument();
|
88
|
+
},
|
89
|
+
};
|
90
|
+
export const triggerType = {
|
91
|
+
name: "triggerType hover",
|
92
|
+
args: {
|
93
|
+
handleOpen: fn(),
|
94
|
+
handleClose: fn(),
|
95
|
+
},
|
96
|
+
render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} triggerType="hover">
|
97
|
+
<Flyout.Trigger>
|
98
|
+
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
99
|
+
</Flyout.Trigger>
|
100
|
+
<Flyout.Content>Content</Flyout.Content>
|
101
|
+
</Flyout>),
|
102
|
+
play: async ({ canvasElement, args }) => {
|
103
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
104
|
+
const trigger = canvas.getAllByRole("button")[0];
|
105
|
+
await userEvent.hover(trigger);
|
106
|
+
await waitFor(() => {
|
107
|
+
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
108
|
+
expect(args.handleOpen).toHaveBeenCalledWith();
|
109
|
+
});
|
110
|
+
await userEvent.unhover(trigger);
|
111
|
+
await waitFor(() => {
|
112
|
+
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
113
|
+
expect(args.handleClose).toHaveBeenCalledWith();
|
114
|
+
});
|
115
|
+
},
|
116
|
+
};
|
117
|
+
export const disabled = {
|
118
|
+
name: "disabled",
|
119
|
+
args: {
|
120
|
+
handleOpen: fn(),
|
121
|
+
},
|
122
|
+
render: () => (<div data-testid="root">
|
123
|
+
<Flyout disabled>
|
124
|
+
<Flyout.Trigger>
|
125
|
+
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
126
|
+
</Flyout.Trigger>
|
127
|
+
<Flyout.Content className="test-classname" attributes={{ "data-testid": "test-id" }}>
|
128
|
+
Content
|
129
|
+
</Flyout.Content>
|
130
|
+
</Flyout>
|
131
|
+
</div>),
|
132
|
+
play: async ({ canvasElement, args }) => {
|
133
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
134
|
+
const button = canvas.getAllByRole("button")[0];
|
135
|
+
await userEvent.click(button);
|
136
|
+
expect(args.handleOpen).toHaveBeenCalledTimes(0);
|
137
|
+
},
|
138
|
+
};
|
139
|
+
export const containerRef = {
|
140
|
+
name: "containerRef",
|
141
|
+
render: () => {
|
142
|
+
const portalRef = useRef(null);
|
143
|
+
return (<div ref={portalRef} data-testid="test-id">
|
144
|
+
<Flyout containerRef={portalRef} active>
|
145
|
+
<Flyout.Trigger>
|
146
|
+
{(attributes) => <Button attributes={attributes}>Trigger</Button>}
|
147
|
+
</Flyout.Trigger>
|
148
|
+
<Flyout.Content>Content</Flyout.Content>
|
149
|
+
</Flyout>
|
150
|
+
</div>);
|
151
|
+
},
|
152
|
+
play: async ({ canvasElement }) => {
|
153
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
154
|
+
const containerEl = canvas.getByTestId("test-id");
|
155
|
+
const contentEl = canvas.getByText("Content");
|
156
|
+
expect(containerEl).toContainElement(contentEl);
|
157
|
+
},
|
158
|
+
};
|
159
|
+
class CustomElement extends window.HTMLElement {
|
160
|
+
constructor() {
|
161
|
+
super();
|
162
|
+
this.attachShadow({ mode: "open" });
|
163
|
+
if (!this.shadowRoot)
|
164
|
+
return;
|
165
|
+
const root = createRoot(this.shadowRoot);
|
166
|
+
root.render(<Reshaped>
|
167
|
+
<Flyout active>
|
168
|
+
<Flyout.Trigger>
|
169
|
+
{(attributes) => <button {...attributes}>Trigger</button>}
|
170
|
+
</Flyout.Trigger>
|
171
|
+
<Flyout.Content>
|
172
|
+
<div id="test-id"/>
|
173
|
+
</Flyout.Content>
|
174
|
+
</Flyout>
|
175
|
+
</Reshaped>);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
window.customElements.define("custom-element-flyout", CustomElement);
|
179
|
+
export const shadowDom = {
|
180
|
+
name: "shadow DOM",
|
181
|
+
// @ts-ignore
|
182
|
+
render: () => <custom-element-flyout />,
|
183
|
+
play: async () => {
|
184
|
+
expect(document.querySelector("custom-element-flyout")?.shadowRoot?.querySelector(`#test-id`)).toBeTruthy();
|
185
|
+
expect(document.body.querySelector(`#test-id`)).toBe(null);
|
186
|
+
},
|
187
|
+
};
|
188
|
+
export const className = {
|
189
|
+
name: "className, attributes",
|
190
|
+
render: () => (<div data-testid="root">
|
191
|
+
<Flyout active>
|
192
|
+
<Flyout.Trigger>
|
193
|
+
{(attributes) => <Button attributes={attributes}>Open</Button>}
|
194
|
+
</Flyout.Trigger>
|
195
|
+
<Flyout.Content className="test-classname" attributes={{ "data-testid": "test-id" }}>
|
196
|
+
Content
|
197
|
+
</Flyout.Content>
|
198
|
+
</Flyout>
|
199
|
+
</div>),
|
200
|
+
play: async ({ canvasElement }) => {
|
201
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
202
|
+
const menu = await canvas.findByTestId("test-id");
|
203
|
+
expect(menu).toHaveClass("test-classname");
|
204
|
+
},
|
205
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import Portal from "../index.js";
|
3
|
-
export default { title: "
|
3
|
+
export default { title: "Internal/Portal" };
|
4
4
|
export const base = () => {
|
5
5
|
const ref = React.useRef(null);
|
6
6
|
const [mounted, setMounted] = React.useState(false);
|
@@ -10,17 +10,17 @@ type HotkeyOptions = {
|
|
10
10
|
};
|
11
11
|
type Context = {
|
12
12
|
isPressed: (key: string) => boolean;
|
13
|
-
addHotkeys: (hotkeys: Hotkeys, ref: React.RefObject<HTMLElement>, options?: HotkeyOptions) => (() => void) | undefined;
|
13
|
+
addHotkeys: (hotkeys: Hotkeys, ref: React.RefObject<HTMLElement | null>, options?: HotkeyOptions) => (() => void) | undefined;
|
14
14
|
};
|
15
15
|
type HotkeyData = {
|
16
16
|
callback: Callback;
|
17
|
-
ref: React.RefObject<HTMLElement>;
|
17
|
+
ref: React.RefObject<HTMLElement | null>;
|
18
18
|
options: HotkeyOptions;
|
19
19
|
};
|
20
20
|
export declare class HotkeyStore {
|
21
21
|
hotkeyMap: Record<string, Set<HotkeyData>>;
|
22
22
|
getSize: () => number;
|
23
|
-
bindHotkeys: (hotkeys: Hotkeys, ref: React.RefObject<HTMLElement>, options: HotkeyOptions) => void;
|
23
|
+
bindHotkeys: (hotkeys: Hotkeys, ref: React.RefObject<HTMLElement | null>, options: HotkeyOptions) => void;
|
24
24
|
unbindHotkeys: (hotkeys: Hotkeys) => void;
|
25
25
|
handleKeyDown: (pressedMap: PressedMap, e: KeyboardEvent) => void;
|
26
26
|
}
|
@@ -82,7 +82,7 @@ export class HotkeyStore {
|
|
82
82
|
if (hotkeyData?.size) {
|
83
83
|
hotkeyData.forEach((data) => {
|
84
84
|
const eventTarget = e.composedPath()[0];
|
85
|
-
if (data.ref
|
85
|
+
if (data.ref.current &&
|
86
86
|
!(eventTarget === data.ref.current || data.ref.current.contains(eventTarget))) {
|
87
87
|
return;
|
88
88
|
}
|
@@ -17,6 +17,7 @@ function Example() {
|
|
17
17
|
<View height={8} width={8} borderRadius="small" animated backgroundColor={active ? "primary" : "neutral"} attributes={{
|
18
18
|
role: "button",
|
19
19
|
tabIndex: 0,
|
20
|
+
"aria-label": "Drag",
|
20
21
|
ref,
|
21
22
|
style: { translate: `${state.x}px ${state.y}px`, cursor: active ? "grabbing" : "grab" },
|
22
23
|
}}/>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
parameters: {
|
6
|
+
chromatic: {
|
7
|
+
disableSnapshot: boolean;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
};
|
11
|
+
export default _default;
|
12
|
+
export declare const mouseEvents: StoryObj<{
|
13
|
+
handleDrag: ReturnType<typeof fn>;
|
14
|
+
}>;
|
15
|
+
export declare const touchEvents: StoryObj<{
|
16
|
+
handleDrag: ReturnType<typeof fn>;
|
17
|
+
}>;
|
18
|
+
export declare const orientationHorizontal: StoryObj<{
|
19
|
+
handleDrag: ReturnType<typeof fn>;
|
20
|
+
}>;
|
21
|
+
export declare const orientationVertical: StoryObj<{
|
22
|
+
handleDrag: ReturnType<typeof fn>;
|
23
|
+
}>;
|
24
|
+
export declare const disabled: StoryObj<{
|
25
|
+
handleDrag: ReturnType<typeof fn>;
|
26
|
+
}>;
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import { fireEvent, fn, expect } from "@storybook/test";
|
2
|
+
import View from "../../components/View/index.js";
|
3
|
+
import useDrag from "../useDrag.js";
|
4
|
+
export default {
|
5
|
+
title: "Hooks/useDrag/tests",
|
6
|
+
parameters: {
|
7
|
+
chromatic: { disableSnapshot: true },
|
8
|
+
},
|
9
|
+
};
|
10
|
+
const Demo = (props) => {
|
11
|
+
const { ref, containerRef } = useDrag((options) => {
|
12
|
+
props.onDrag(options);
|
13
|
+
}, {
|
14
|
+
orientation: props.orientation,
|
15
|
+
disabled: props.disabled,
|
16
|
+
});
|
17
|
+
return (<View backgroundColor="neutral-faded" width="200px" height="200px" attributes={{ ref: containerRef, "data-testid": "test-id" }}>
|
18
|
+
<View height={8} width={8} backgroundColor="primary" attributes={{
|
19
|
+
"data-testid": "test-handle-id",
|
20
|
+
ref,
|
21
|
+
}}/>
|
22
|
+
</View>);
|
23
|
+
};
|
24
|
+
export const mouseEvents = {
|
25
|
+
name: "onDrag, mouse events",
|
26
|
+
args: {
|
27
|
+
handleDrag: fn(),
|
28
|
+
},
|
29
|
+
render: (args) => {
|
30
|
+
return <Demo onDrag={args.handleDrag}/>;
|
31
|
+
},
|
32
|
+
play: ({ canvas, args }) => {
|
33
|
+
const trigger = canvas.getByTestId("test-handle-id");
|
34
|
+
fireEvent.mouseDown(trigger);
|
35
|
+
fireEvent.mouseMove(document.body, { clientX: 100, clientY: 50 });
|
36
|
+
expect(args.handleDrag).toHaveBeenCalledTimes(1);
|
37
|
+
expect(args.handleDrag).toHaveBeenCalledWith(expect.objectContaining({ x: 100, y: 50 }));
|
38
|
+
fireEvent.mouseUp(trigger);
|
39
|
+
fireEvent.mouseUp(document.body, { clientX: 50, clientY: 100 });
|
40
|
+
expect(args.handleDrag).toHaveBeenCalledTimes(1);
|
41
|
+
},
|
42
|
+
};
|
43
|
+
export const touchEvents = {
|
44
|
+
name: "onDrag, touch events",
|
45
|
+
args: {
|
46
|
+
handleDrag: fn(),
|
47
|
+
},
|
48
|
+
render: (args) => {
|
49
|
+
return <Demo onDrag={args.handleDrag}/>;
|
50
|
+
},
|
51
|
+
play: ({ canvas, args }) => {
|
52
|
+
const createTouch = (target, x, y) => {
|
53
|
+
return new Touch({
|
54
|
+
identifier: Date.now(),
|
55
|
+
target,
|
56
|
+
clientX: x,
|
57
|
+
clientY: y,
|
58
|
+
screenX: x,
|
59
|
+
screenY: y,
|
60
|
+
pageX: x,
|
61
|
+
pageY: y,
|
62
|
+
});
|
63
|
+
};
|
64
|
+
const trigger = canvas.getByTestId("test-handle-id");
|
65
|
+
fireEvent.touchStart(trigger, { changedTouches: [createTouch(trigger, 0, 0)] });
|
66
|
+
fireEvent.touchMove(document.body, { changedTouches: [createTouch(trigger, 100, 50)] });
|
67
|
+
expect(args.handleDrag).toHaveBeenCalledTimes(1);
|
68
|
+
expect(args.handleDrag).toHaveBeenCalledWith(expect.objectContaining({ x: 100, y: 50 }));
|
69
|
+
fireEvent.touchEnd(trigger);
|
70
|
+
fireEvent.touchEnd(document.body, { changedTouches: [createTouch(trigger, 100, 50)] });
|
71
|
+
expect(args.handleDrag).toHaveBeenCalledTimes(1);
|
72
|
+
},
|
73
|
+
};
|
74
|
+
export const orientationHorizontal = {
|
75
|
+
name: "orientation horizontal",
|
76
|
+
args: {
|
77
|
+
handleDrag: fn(),
|
78
|
+
},
|
79
|
+
render: (args) => {
|
80
|
+
return <Demo onDrag={args.handleDrag} orientation="horizontal"/>;
|
81
|
+
},
|
82
|
+
play: ({ canvas, args }) => {
|
83
|
+
const trigger = canvas.getByTestId("test-handle-id");
|
84
|
+
fireEvent.mouseDown(trigger);
|
85
|
+
fireEvent.mouseMove(document.body, { clientX: 100, clientY: 50 });
|
86
|
+
expect(args.handleDrag).toHaveBeenCalledTimes(1);
|
87
|
+
expect(args.handleDrag).toHaveBeenCalledWith(expect.objectContaining({ x: 100, y: 0 }));
|
88
|
+
},
|
89
|
+
};
|
90
|
+
export const orientationVertical = {
|
91
|
+
name: "orientation vertical",
|
92
|
+
args: {
|
93
|
+
handleDrag: fn(),
|
94
|
+
},
|
95
|
+
render: (args) => {
|
96
|
+
return <Demo onDrag={args.handleDrag} orientation="vertical"/>;
|
97
|
+
},
|
98
|
+
play: ({ canvas, args }) => {
|
99
|
+
const trigger = canvas.getByTestId("test-handle-id");
|
100
|
+
fireEvent.mouseDown(trigger);
|
101
|
+
fireEvent.mouseMove(document.body, { clientX: 100, clientY: 50 });
|
102
|
+
expect(args.handleDrag).toHaveBeenCalledTimes(1);
|
103
|
+
expect(args.handleDrag).toHaveBeenCalledWith(expect.objectContaining({ x: 0, y: 50 }));
|
104
|
+
},
|
105
|
+
};
|
106
|
+
export const disabled = {
|
107
|
+
name: "disabled",
|
108
|
+
args: {
|
109
|
+
handleDrag: fn(),
|
110
|
+
},
|
111
|
+
render: (args) => {
|
112
|
+
return <Demo onDrag={args.handleDrag} disabled/>;
|
113
|
+
},
|
114
|
+
play: ({ canvas, args }) => {
|
115
|
+
const trigger = canvas.getByTestId("test-handle-id");
|
116
|
+
fireEvent.mouseDown(trigger);
|
117
|
+
fireEvent.mouseMove(document.body, { clientX: 100, clientY: 50 });
|
118
|
+
expect(args.handleDrag).toHaveBeenCalledTimes(0);
|
119
|
+
},
|
120
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { expect, waitFor } from "@storybook/test";
|
3
|
+
import useElementId from "../useElementId.js";
|
4
|
+
export default { title: "Hooks/useElementId" };
|
5
|
+
const Component = (props) => {
|
6
|
+
const id = useElementId(props.id);
|
7
|
+
return <div id={id}>{id}</div>;
|
8
|
+
};
|
9
|
+
export const id = {
|
10
|
+
name: "passed id",
|
11
|
+
render: () => {
|
12
|
+
return <Component id="hey"/>;
|
13
|
+
},
|
14
|
+
play: async () => {
|
15
|
+
waitFor(() => {
|
16
|
+
expect(document.querySelector("#hey")).toBeTruthy();
|
17
|
+
});
|
18
|
+
},
|
19
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
parameters: {
|
6
|
+
chromatic: {
|
7
|
+
disableSnapshot: boolean;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
};
|
11
|
+
export default _default;
|
12
|
+
export declare const singleKey: StoryObj<{
|
13
|
+
handleHotkey: ReturnType<typeof fn>;
|
14
|
+
}>;
|
15
|
+
export declare const modKey: StoryObj<{
|
16
|
+
handleHotkey: ReturnType<typeof fn>;
|
17
|
+
}>;
|
18
|
+
export declare const modKeyHold: StoryObj<{
|
19
|
+
handleHotkey: ReturnType<typeof fn>;
|
20
|
+
}>;
|
21
|
+
export declare const keyList: StoryObj<{
|
22
|
+
handleHotkey: ReturnType<typeof fn>;
|
23
|
+
}>;
|
24
|
+
export declare const keyCombination: StoryObj<{
|
25
|
+
handleHotkey: ReturnType<typeof fn>;
|
26
|
+
}>;
|
27
|
+
export declare const keyCombinationFormat: StoryObj<{
|
28
|
+
handleHotkey: ReturnType<typeof fn>;
|
29
|
+
}>;
|
30
|
+
export declare const keyCombinationOrder: StoryObj<{
|
31
|
+
handleHotkey: ReturnType<typeof fn>;
|
32
|
+
}>;
|
33
|
+
export declare const keyCombinationMoreThanRequired: StoryObj<{
|
34
|
+
handleHotkey: ReturnType<typeof fn>;
|
35
|
+
}>;
|
36
|
+
export declare const optionModified: StoryObj<{
|
37
|
+
handleHotkey: ReturnType<typeof fn>;
|
38
|
+
handleHotkeyModified: ReturnType<typeof fn>;
|
39
|
+
}>;
|