reshaped 3.8.8 → 3.9.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +11 -11
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Divider/Divider.js +3 -3
- package/dist/components/Divider/Divider.module.css +1 -1
- package/dist/components/Divider/Divider.types.d.ts +6 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +1 -1
- package/dist/components/Flyout/Flyout.constants.d.ts +1 -3
- package/dist/components/Flyout/Flyout.constants.js +1 -3
- package/dist/components/Flyout/Flyout.types.d.ts +2 -0
- package/dist/components/Flyout/FlyoutControlled.js +10 -11
- package/dist/components/Flyout/utilities/cooldown.js +1 -2
- package/dist/components/Icon/Icon.module.css +1 -1
- package/dist/components/Popover/Popover.types.d.ts +1 -1
- package/dist/components/Progress/Progress.module.css +1 -1
- package/dist/components/Select/Select.module.css +1 -1
- package/dist/components/Select/Select.types.d.ts +16 -11
- package/dist/components/Select/SelectCustomControlled.js +27 -10
- package/dist/components/Select/SelectGroup.d.ts +4 -0
- package/dist/components/Select/SelectGroup.js +10 -0
- package/dist/components/Select/SelectTrigger.js +1 -1
- package/dist/components/Select/index.d.ts +3 -2
- package/dist/components/Select/index.js +3 -2
- package/dist/components/Tabs/TabsContext.d.ts +1 -1
- package/dist/components/TextArea/TextArea.module.css +1 -1
- package/dist/components/TextArea/TextArea.types.d.ts +1 -1
- package/dist/components/TextField/TextField.module.css +1 -1
- package/dist/components/TextField/TextField.types.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/config/tailwind.d.ts +1 -1
- package/package.json +31 -30
- package/dist/components/Accordion/tests/Accordion.stories.d.ts +0 -44
- package/dist/components/Accordion/tests/Accordion.stories.js +0 -204
- package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +0 -40
- package/dist/components/ActionBar/tests/ActionBar.stories.js +0 -223
- package/dist/components/Actionable/tests/Actionable.stories.d.ts +0 -41
- package/dist/components/Actionable/tests/Actionable.stories.js +0 -220
- package/dist/components/Alert/tests/Alert.stories.d.ts +0 -24
- package/dist/components/Alert/tests/Alert.stories.js +0 -78
- package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +0 -32
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +0 -246
- package/dist/components/Avatar/tests/Avatar.stories.d.ts +0 -31
- package/dist/components/Avatar/tests/Avatar.stories.js +0 -176
- package/dist/components/Badge/tests/Badge.stories.d.ts +0 -55
- package/dist/components/Badge/tests/Badge.stories.js +0 -328
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +0 -40
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +0 -187
- package/dist/components/Button/tests/Button.stories.d.ts +0 -79
- package/dist/components/Button/tests/Button.stories.js +0 -789
- package/dist/components/Calendar/tests/Calendar.stories.d.ts +0 -29
- package/dist/components/Calendar/tests/Calendar.stories.js +0 -255
- package/dist/components/Card/tests/Card.stories.d.ts +0 -52
- package/dist/components/Card/tests/Card.stories.js +0 -125
- package/dist/components/Carousel/tests/Carousel.stories.d.ts +0 -34
- package/dist/components/Carousel/tests/Carousel.stories.js +0 -224
- package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +0 -30
- package/dist/components/Checkbox/tests/Checkbox.stories.js +0 -171
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +0 -19
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +0 -83
- package/dist/components/Container/tests/Container.stories.d.ts +0 -24
- package/dist/components/Container/tests/Container.stories.js +0 -75
- package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +0 -26
- package/dist/components/ContextMenu/tests/ContextMenu.stories.js +0 -70
- package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +0 -25
- package/dist/components/Dismissible/tests/Dismissible.stories.js +0 -97
- package/dist/components/Divider/tests/Divider.stories.d.ts +0 -18
- package/dist/components/Divider/tests/Divider.stories.js +0 -94
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +0 -53
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +0 -278
- package/dist/components/FileUpload/tests/FileUpload.stories.d.ts +0 -31
- package/dist/components/FileUpload/tests/FileUpload.stories.js +0 -140
- package/dist/components/Flyout/tests/Flyout.stories.d.ts +0 -102
- package/dist/components/Flyout/tests/Flyout.stories.js +0 -708
- package/dist/components/FormControl/tests/FormControl.stories.d.ts +0 -31
- package/dist/components/FormControl/tests/FormControl.stories.js +0 -143
- package/dist/components/Grid/tests/Grid.stories.d.ts +0 -38
- package/dist/components/Grid/tests/Grid.stories.js +0 -245
- package/dist/components/Hidden/tests/Hidden.stories.d.ts +0 -16
- package/dist/components/Hidden/tests/Hidden.stories.js +0 -48
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +0 -16
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +0 -28
- package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +0 -13
- package/dist/components/Hotkey/tests/Hotkey.stories.js +0 -53
- package/dist/components/Icon/tests/Icon.stories.d.ts +0 -25
- package/dist/components/Icon/tests/Icon.stories.js +0 -113
- package/dist/components/Image/tests/Image.stories.d.ts +0 -41
- package/dist/components/Image/tests/Image.stories.js +0 -196
- package/dist/components/Link/tests/Link.stories.d.ts +0 -42
- package/dist/components/Link/tests/Link.stories.js +0 -155
- package/dist/components/Loader/tests/Loader.stories.d.ts +0 -21
- package/dist/components/Loader/tests/Loader.stories.js +0 -68
- package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +0 -59
- package/dist/components/MenuItem/tests/MenuItem.stories.js +0 -236
- package/dist/components/Modal/tests/Modal.stories.d.ts +0 -64
- package/dist/components/Modal/tests/Modal.stories.js +0 -410
- package/dist/components/NumberField/tests/NumberField.stories.d.ts +0 -28
- package/dist/components/NumberField/tests/NumberField.stories.js +0 -258
- package/dist/components/Overlay/tests/Overlay.stories.d.ts +0 -28
- package/dist/components/Overlay/tests/Overlay.stories.js +0 -202
- package/dist/components/Pagination/tests/Pagination.stories.d.ts +0 -24
- package/dist/components/Pagination/tests/Pagination.stories.js +0 -105
- package/dist/components/PinField/tests/PinField.stories.d.ts +0 -34
- package/dist/components/PinField/tests/PinField.stories.js +0 -209
- package/dist/components/Popover/tests/Popover.stories.d.ts +0 -69
- package/dist/components/Popover/tests/Popover.stories.js +0 -340
- package/dist/components/Progress/tests/Progress.stories.d.ts +0 -30
- package/dist/components/Progress/tests/Progress.stories.js +0 -102
- package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.d.ts +0 -19
- package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.js +0 -92
- package/dist/components/Radio/tests/Radio.stories.d.ts +0 -35
- package/dist/components/Radio/tests/Radio.stories.js +0 -162
- package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +0 -19
- package/dist/components/RadioGroup/tests/RadioGroup.stories.js +0 -77
- package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +0 -34
- package/dist/components/Reshaped/tests/Reshaped.stories.js +0 -108
- package/dist/components/Resizable/tests/Resizable.stories.d.ts +0 -38
- package/dist/components/Resizable/tests/Resizable.stories.js +0 -185
- package/dist/components/Scrim/tests/Scrim.stories.d.ts +0 -20
- package/dist/components/Scrim/tests/Scrim.stories.js +0 -67
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +0 -37
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +0 -244
- package/dist/components/Select/SelectOptionGroup.d.ts +0 -4
- package/dist/components/Select/SelectOptionGroup.js +0 -9
- package/dist/components/Select/tests/Select.stories.d.ts +0 -47
- package/dist/components/Select/tests/Select.stories.js +0 -520
- package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +0 -20
- package/dist/components/Skeleton/tests/Skeleton.stories.js +0 -63
- package/dist/components/Slider/tests/Slider.stories.d.ts +0 -47
- package/dist/components/Slider/tests/Slider.stories.js +0 -279
- package/dist/components/Stepper/tests/Stepper.stories.d.ts +0 -31
- package/dist/components/Stepper/tests/Stepper.stories.js +0 -135
- package/dist/components/Switch/tests/Switch.stories.d.ts +0 -22
- package/dist/components/Switch/tests/Switch.stories.js +0 -137
- package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -13
- package/dist/components/Switch/tests/Switch.test.stories.js +0 -11
- package/dist/components/Table/tests/Table.stories.d.ts +0 -42
- package/dist/components/Table/tests/Table.stories.js +0 -348
- package/dist/components/Tabs/tests/Tabs.stories.d.ts +0 -62
- package/dist/components/Tabs/tests/Tabs.stories.js +0 -539
- package/dist/components/Text/tests/Text.stories.d.ts +0 -48
- package/dist/components/Text/tests/Text.stories.js +0 -201
- package/dist/components/TextArea/tests/TextArea.stories.d.ts +0 -53
- package/dist/components/TextArea/tests/TextArea.stories.js +0 -200
- package/dist/components/TextField/tests/TextField.stories.d.ts +0 -53
- package/dist/components/TextField/tests/TextField.stories.js +0 -237
- package/dist/components/Theme/tests/Theme.stories.d.ts +0 -25
- package/dist/components/Theme/tests/Theme.stories.js +0 -171
- package/dist/components/Timeline/tests/Timeline.stories.d.ts +0 -22
- package/dist/components/Timeline/tests/Timeline.stories.js +0 -86
- package/dist/components/Toast/tests/Toast.stories.d.ts +0 -41
- package/dist/components/Toast/tests/Toast.stories.js +0 -432
- package/dist/components/ToggleButton/tests/ToggleButton.stories.d.ts +0 -27
- package/dist/components/ToggleButton/tests/ToggleButton.stories.js +0 -97
- package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.d.ts +0 -27
- package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.js +0 -169
- package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +0 -28
- package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -182
- package/dist/components/View/tests/View.stories.d.ts +0 -141
- package/dist/components/View/tests/View.stories.js +0 -1329
- package/dist/components/_private/Portal/tests/Portal.stories.d.ts +0 -6
- package/dist/components/_private/Portal/tests/Portal.stories.js +0 -17
- package/dist/hooks/tests/useDrag.stories.d.ts +0 -31
- package/dist/hooks/tests/useDrag.stories.js +0 -147
- package/dist/hooks/tests/useElementId.stories.d.ts +0 -11
- package/dist/hooks/tests/useElementId.stories.js +0 -23
- package/dist/hooks/tests/useHandlerRef.stories.d.ts +0 -14
- package/dist/hooks/tests/useHandlerRef.stories.js +0 -44
- package/dist/hooks/tests/useHotkeys.stories.d.ts +0 -43
- package/dist/hooks/tests/useHotkeys.stories.js +0 -158
- package/dist/hooks/tests/useKeyboardArrowNavigation.stories.d.ts +0 -15
- package/dist/hooks/tests/useKeyboardArrowNavigation.stories.js +0 -128
- package/dist/hooks/tests/useKeyboardMode.stories.d.ts +0 -11
- package/dist/hooks/tests/useKeyboardMode.stories.js +0 -42
- package/dist/hooks/tests/useOnClickOutside.stories.d.ts +0 -23
- package/dist/hooks/tests/useOnClickOutside.stories.js +0 -111
- package/dist/hooks/tests/useRTL.stories.d.ts +0 -11
- package/dist/hooks/tests/useRTL.stories.js +0 -23
- package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +0 -18
- package/dist/hooks/tests/useResponsiveClientValue.stories.js +0 -30
- package/dist/hooks/tests/useScrollLock.stories.d.ts +0 -14
- package/dist/hooks/tests/useScrollLock.stories.js +0 -97
- package/dist/hooks/tests/useToggle.stories.d.ts +0 -13
- package/dist/hooks/tests/useToggle.stories.js +0 -59
- package/dist/tests/ShadowDOM.stories.d.ts +0 -6
- package/dist/tests/ShadowDOM.stories.js +0 -110
- package/dist/tests/themes.stories.d.ts +0 -16
- package/dist/tests/themes.stories.js +0 -327
- package/dist/utilities/a11y/tests/TrapFocus.stories.d.ts +0 -14
- package/dist/utilities/a11y/tests/TrapFocus.stories.js +0 -615
|
@@ -1,708 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
import { userEvent, waitFor, within, expect, fn } from "storybook/test";
|
|
4
|
-
import { Example } from "../../../utilities/storybook/index.js";
|
|
5
|
-
import Reshaped from "../../Reshaped/index.js";
|
|
6
|
-
import View from "../../View/index.js";
|
|
7
|
-
import Theme from "../../Theme/index.js";
|
|
8
|
-
import Button from "../../Button/index.js";
|
|
9
|
-
import Flyout from "../index.js";
|
|
10
|
-
import TextField from "../../TextField/index.js";
|
|
11
|
-
import Select from "../../Select/index.js";
|
|
12
|
-
import Switch from "../../Switch/index.js";
|
|
13
|
-
import { sleep } from "../../../utilities/helpers.js";
|
|
14
|
-
import Modal from "../../Modal/index.js";
|
|
15
|
-
export default { title: "Utility components/Flyout" };
|
|
16
|
-
const Content = (props) => (<div style={{
|
|
17
|
-
background: "var(--rs-color-background-elevation-overlay)",
|
|
18
|
-
padding: "var(--rs-unit-x4)",
|
|
19
|
-
height: props.height === false ? undefined : props.height || 150,
|
|
20
|
-
width: props.width === false ? undefined : props.width || 160,
|
|
21
|
-
borderRadius: "var(--rs-radius-medium)",
|
|
22
|
-
border: "1px solid var(--rs-color-border-neutral-faded)",
|
|
23
|
-
boxSizing: "border-box",
|
|
24
|
-
}}>
|
|
25
|
-
{props.children || "Content"}
|
|
26
|
-
</div>);
|
|
27
|
-
const Demo = (props) => {
|
|
28
|
-
const { position = "bottom-start", children, text, contentHeight, contentWidth, ...rest } = props;
|
|
29
|
-
return (<Flyout position={position} {...rest}>
|
|
30
|
-
<Flyout.Trigger>
|
|
31
|
-
{(attributes) => <Button attributes={attributes}>{text || position}</Button>}
|
|
32
|
-
</Flyout.Trigger>
|
|
33
|
-
<Flyout.Content attributes={{
|
|
34
|
-
style: {
|
|
35
|
-
background: "var(--rs-color-background-elevation-overlay)",
|
|
36
|
-
padding: "var(--rs-unit-x4)",
|
|
37
|
-
height: contentHeight === false ? undefined : contentHeight || 150,
|
|
38
|
-
width: contentWidth === false ? undefined : contentWidth || 160,
|
|
39
|
-
borderRadius: "var(--rs-radius-medium)",
|
|
40
|
-
border: "1px solid var(--rs-color-border-neutral-faded)",
|
|
41
|
-
boxSizing: "border-box",
|
|
42
|
-
},
|
|
43
|
-
}}>
|
|
44
|
-
{children || "Content"}
|
|
45
|
-
</Flyout.Content>
|
|
46
|
-
</Flyout>);
|
|
47
|
-
};
|
|
48
|
-
export const position = {
|
|
49
|
-
name: "position",
|
|
50
|
-
render: () => {
|
|
51
|
-
return (<View gap={4} padding={50} align="center" justify="center" height="100vh" width="120%">
|
|
52
|
-
<View gap={4} direction="row">
|
|
53
|
-
<Demo position="top-start" defaultActive/>
|
|
54
|
-
<Demo position="top"/>
|
|
55
|
-
<Demo position="top-end"/>
|
|
56
|
-
</View>
|
|
57
|
-
|
|
58
|
-
<View gap={4} direction="row">
|
|
59
|
-
<Demo position="end-top"/>
|
|
60
|
-
<Demo position="end"/>
|
|
61
|
-
<Demo position="end-bottom"/>
|
|
62
|
-
</View>
|
|
63
|
-
|
|
64
|
-
<View gap={4} direction="row">
|
|
65
|
-
<Demo position="start-top"/>
|
|
66
|
-
<Demo position="start"/>
|
|
67
|
-
<Demo position="start-bottom"/>
|
|
68
|
-
</View>
|
|
69
|
-
|
|
70
|
-
<View gap={4} direction="row">
|
|
71
|
-
<Demo position="bottom-start"/>
|
|
72
|
-
<Demo position="bottom"/>
|
|
73
|
-
<Demo position="bottom-end"/>
|
|
74
|
-
</View>
|
|
75
|
-
</View>);
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
export const defaultActive = {
|
|
79
|
-
name: "defaultActive, uncontrolled",
|
|
80
|
-
args: {
|
|
81
|
-
handleOpen: fn(),
|
|
82
|
-
handleClose: fn(),
|
|
83
|
-
},
|
|
84
|
-
render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} defaultActive>
|
|
85
|
-
<Flyout.Trigger>
|
|
86
|
-
{(attributes) => <Button attributes={attributes}>Trigger</Button>}
|
|
87
|
-
</Flyout.Trigger>
|
|
88
|
-
<Flyout.Content>
|
|
89
|
-
<Content />
|
|
90
|
-
</Flyout.Content>
|
|
91
|
-
</Flyout>),
|
|
92
|
-
play: async ({ canvasElement, args }) => {
|
|
93
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
94
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
95
|
-
let item = canvas.getByText("Content");
|
|
96
|
-
await sleep(500);
|
|
97
|
-
await userEvent.click(document.body);
|
|
98
|
-
await waitFor(() => {
|
|
99
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
|
100
|
-
expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
|
|
101
|
-
expect(item).not.toBeInTheDocument();
|
|
102
|
-
});
|
|
103
|
-
await userEvent.click(trigger);
|
|
104
|
-
await waitFor(() => {
|
|
105
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
|
106
|
-
expect(args.handleOpen).toHaveBeenCalledWith();
|
|
107
|
-
});
|
|
108
|
-
item = canvas.getByText("Content");
|
|
109
|
-
expect(item).toBeInTheDocument();
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
export const active = {
|
|
113
|
-
name: "active, controlled",
|
|
114
|
-
args: {
|
|
115
|
-
handleOpen: fn(),
|
|
116
|
-
handleClose: fn(),
|
|
117
|
-
},
|
|
118
|
-
render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} active>
|
|
119
|
-
<Flyout.Trigger>
|
|
120
|
-
{(attributes) => <Button attributes={attributes}>Trigger</Button>}
|
|
121
|
-
</Flyout.Trigger>
|
|
122
|
-
<Flyout.Content>
|
|
123
|
-
<Content />
|
|
124
|
-
</Flyout.Content>
|
|
125
|
-
</Flyout>),
|
|
126
|
-
play: async ({ canvasElement, args }) => {
|
|
127
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
128
|
-
const item = canvas.getByText("Content");
|
|
129
|
-
await userEvent.click(document.body);
|
|
130
|
-
await waitFor(() => {
|
|
131
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
|
132
|
-
expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
|
|
133
|
-
});
|
|
134
|
-
expect(item).toBeInTheDocument();
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
export const activeFalse = {
|
|
138
|
-
name: "active: false, controlled",
|
|
139
|
-
args: {
|
|
140
|
-
handleOpen: fn(),
|
|
141
|
-
handleClose: fn(),
|
|
142
|
-
},
|
|
143
|
-
render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} active={false}>
|
|
144
|
-
<Flyout.Trigger>
|
|
145
|
-
{(attributes) => <Button attributes={attributes}>Trigger</Button>}
|
|
146
|
-
</Flyout.Trigger>
|
|
147
|
-
<Flyout.Content>
|
|
148
|
-
<Content />
|
|
149
|
-
</Flyout.Content>
|
|
150
|
-
</Flyout>),
|
|
151
|
-
play: async ({ canvasElement, args }) => {
|
|
152
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
153
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
154
|
-
await userEvent.click(trigger);
|
|
155
|
-
await waitFor(() => {
|
|
156
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
|
157
|
-
expect(args.handleOpen).toHaveBeenCalledWith();
|
|
158
|
-
});
|
|
159
|
-
const item = canvas.queryByText("Content");
|
|
160
|
-
expect(item).not.toBeInTheDocument();
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
const modeContent = (<View direction="row" gap={2}>
|
|
164
|
-
<Button onClick={() => { }}>Action 1</Button>
|
|
165
|
-
<Button onClick={() => { }}>Action 2</Button>
|
|
166
|
-
<Button onClick={() => { }}>Action 3</Button>
|
|
167
|
-
</View>);
|
|
168
|
-
export const modes = {
|
|
169
|
-
name: "triggerType, trapFocusMode",
|
|
170
|
-
render: () => {
|
|
171
|
-
return (<Example>
|
|
172
|
-
<Example.Item title="triggerType: click">
|
|
173
|
-
<View direction="row" gap={4}>
|
|
174
|
-
<Demo position="bottom-start" trapFocusMode="dialog" text="dialog">
|
|
175
|
-
{modeContent}
|
|
176
|
-
</Demo>
|
|
177
|
-
<Demo position="bottom-start" trapFocusMode="action-menu" text="action-menu">
|
|
178
|
-
{modeContent}
|
|
179
|
-
</Demo>
|
|
180
|
-
<Demo position="bottom-start" trapFocusMode="action-bar" text="action-bar">
|
|
181
|
-
{modeContent}
|
|
182
|
-
</Demo>
|
|
183
|
-
<Demo position="bottom-start" trapFocusMode="content-menu" text="content-menu">
|
|
184
|
-
{modeContent}
|
|
185
|
-
</Demo>
|
|
186
|
-
<Demo position="bottom-start" trapFocusMode={false} text="false">
|
|
187
|
-
{modeContent}
|
|
188
|
-
</Demo>
|
|
189
|
-
</View>
|
|
190
|
-
</Example.Item>
|
|
191
|
-
|
|
192
|
-
<Example.Item title="triggerType: hover">
|
|
193
|
-
<View direction="row" gap={4}>
|
|
194
|
-
<Demo position="bottom-start" trapFocusMode="dialog" triggerType="hover" text="dialog">
|
|
195
|
-
{modeContent}
|
|
196
|
-
</Demo>
|
|
197
|
-
<Demo position="bottom-start" trapFocusMode="action-menu" triggerType="hover" text="action-menu">
|
|
198
|
-
{modeContent}
|
|
199
|
-
</Demo>
|
|
200
|
-
<Demo position="bottom-start" trapFocusMode="action-bar" triggerType="hover" text="action-bar">
|
|
201
|
-
{modeContent}
|
|
202
|
-
</Demo>
|
|
203
|
-
<Demo position="bottom-start" trapFocusMode="content-menu" triggerType="hover" text="content-menu">
|
|
204
|
-
{modeContent}
|
|
205
|
-
</Demo>
|
|
206
|
-
</View>
|
|
207
|
-
</Example.Item>
|
|
208
|
-
</Example>);
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
export const positionFallbacks = {
|
|
212
|
-
name: "fallbackPositions",
|
|
213
|
-
render: () => {
|
|
214
|
-
return (<Example>
|
|
215
|
-
<Example.Item title="position: top, default fallbacks">
|
|
216
|
-
<View justify="center" align="center">
|
|
217
|
-
<Demo position="top"/>
|
|
218
|
-
</View>
|
|
219
|
-
</Example.Item>
|
|
220
|
-
<Example.Item title="position: top, fallbackPositions: [start]">
|
|
221
|
-
<View justify="center" align="center">
|
|
222
|
-
<Demo position="top" fallbackPositions={["start"]} contentHeight={200} defaultActive/>
|
|
223
|
-
</View>
|
|
224
|
-
</Example.Item>
|
|
225
|
-
<Example.Item title="position: top, fallbackPositions: false">
|
|
226
|
-
<View justify="center" align="center">
|
|
227
|
-
<Demo position="top" fallbackPositions={false} contentHeight={400}/>
|
|
228
|
-
</View>
|
|
229
|
-
</Example.Item>
|
|
230
|
-
</Example>);
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
const FallbackAdjustLayoutControls = ({ containerRef, large, }) => {
|
|
234
|
-
const contentHeight = large ? "2000px" : "200px";
|
|
235
|
-
const contentWidth = large ? "2000px" : "300px";
|
|
236
|
-
return (<>
|
|
237
|
-
{/* Left side */}
|
|
238
|
-
<View position="absolute" insetStart={4} insetTop={10} gap={2}>
|
|
239
|
-
<Demo contentHeight={contentHeight} position="end" fallbackAdjustLayout fallbackPositions={false} containerRef={containerRef}/>
|
|
240
|
-
<Demo contentHeight={contentHeight} position="end-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
|
241
|
-
</View>
|
|
242
|
-
|
|
243
|
-
<View position="absolute" insetStart={4} insetTop={80} gap={2}>
|
|
244
|
-
<Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
245
|
-
<Demo position="top-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
246
|
-
<Demo position="bottom-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
247
|
-
<Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
248
|
-
</View>
|
|
249
|
-
|
|
250
|
-
<View position="absolute" insetBottom={4} insetStart={4} gap={2}>
|
|
251
|
-
<Demo contentHeight={contentHeight} position="end-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
|
252
|
-
<Demo contentHeight={contentHeight} position="end" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
|
253
|
-
</View>
|
|
254
|
-
|
|
255
|
-
{/* Right side */}
|
|
256
|
-
|
|
257
|
-
<View position="absolute" insetTop={10} insetEnd={4} gap={2}>
|
|
258
|
-
<Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
|
259
|
-
<Demo contentHeight={contentHeight} position="start-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
|
260
|
-
</View>
|
|
261
|
-
|
|
262
|
-
<View position="absolute" insetEnd={4} insetTop={80} gap={2}>
|
|
263
|
-
<Demo position="top-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
264
|
-
<Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
265
|
-
<Demo position="bottom-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
266
|
-
<Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
|
267
|
-
</View>
|
|
268
|
-
|
|
269
|
-
<View position="absolute" insetBottom={4} insetEnd={4} gap={2}>
|
|
270
|
-
<Demo contentHeight={contentHeight} position="start-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
|
271
|
-
<Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
|
272
|
-
</View>
|
|
273
|
-
</>);
|
|
274
|
-
};
|
|
275
|
-
export const fallbackAdjustLayout = {
|
|
276
|
-
name: "fallbackAdjustLayout",
|
|
277
|
-
render: () => {
|
|
278
|
-
return (<Demo contentHeight={false} position="bottom-start" width="200px" fallbackAdjustLayout defaultActive>
|
|
279
|
-
<div style={{ height: "600px" }}>Content</div>
|
|
280
|
-
</Demo>);
|
|
281
|
-
},
|
|
282
|
-
};
|
|
283
|
-
export const fallbackAdjustLayoutShift = {
|
|
284
|
-
name: "fallbackAdjustLayout, shift",
|
|
285
|
-
render: () => {
|
|
286
|
-
const containerRef = React.useRef(null);
|
|
287
|
-
return (<View gap={10}>
|
|
288
|
-
<View height="95vh" width="100%" align="center" justify="center">
|
|
289
|
-
<View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" padding={4} paddingBlock={15} overflow="auto">
|
|
290
|
-
<FallbackAdjustLayoutControls />
|
|
291
|
-
<View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
|
|
292
|
-
</View>
|
|
293
|
-
</View>
|
|
294
|
-
|
|
295
|
-
<View height="95vh" width="100%" align="center" justify="center">
|
|
296
|
-
<View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" attributes={{ ref: containerRef }} padding={4} paddingBlock={15} overflow="auto">
|
|
297
|
-
<FallbackAdjustLayoutControls containerRef={containerRef}/>
|
|
298
|
-
<View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
|
|
299
|
-
</View>
|
|
300
|
-
</View>
|
|
301
|
-
|
|
302
|
-
<FallbackAdjustLayoutControls />
|
|
303
|
-
<div style={{ height: "100vh", width: "250%" }}/>
|
|
304
|
-
</View>);
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
export const fallbackAdjustLayoutSize = {
|
|
308
|
-
name: "fallbackAdjustLayout, size",
|
|
309
|
-
render: () => {
|
|
310
|
-
const containerRef = React.useRef(null);
|
|
311
|
-
return (<View gap={10}>
|
|
312
|
-
<View height="95vh" width="100%" align="center" justify="center">
|
|
313
|
-
<View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" padding={4} paddingBlock={15} overflow="auto">
|
|
314
|
-
<FallbackAdjustLayoutControls large/>
|
|
315
|
-
<View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
|
|
316
|
-
</View>
|
|
317
|
-
</View>
|
|
318
|
-
|
|
319
|
-
<View height="95vh" width="100%" align="center" justify="center">
|
|
320
|
-
<View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" attributes={{ ref: containerRef }} padding={4} paddingBlock={15} overflow="auto">
|
|
321
|
-
<FallbackAdjustLayoutControls containerRef={containerRef} large/>
|
|
322
|
-
<View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
|
|
323
|
-
</View>
|
|
324
|
-
</View>
|
|
325
|
-
|
|
326
|
-
<FallbackAdjustLayoutControls large/>
|
|
327
|
-
<div style={{ height: "100vh", width: "250%" }}/>
|
|
328
|
-
</View>);
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
export const originCoordinates = {
|
|
332
|
-
name: "originCoordinates",
|
|
333
|
-
render: () => {
|
|
334
|
-
return (<View gap={4} direction="row">
|
|
335
|
-
<Demo position="bottom-start" originCoordinates={{ x: 150, y: 150 }} defaultActive/>
|
|
336
|
-
</View>);
|
|
337
|
-
},
|
|
338
|
-
};
|
|
339
|
-
export const width = {
|
|
340
|
-
name: "width",
|
|
341
|
-
render: () => (<Example>
|
|
342
|
-
<Example.Item title="width: 300px">
|
|
343
|
-
<Demo width="300px" position="bottom"/>
|
|
344
|
-
</Example.Item>
|
|
345
|
-
|
|
346
|
-
<Example.Item title="width: trigger">
|
|
347
|
-
<Demo width="trigger" contentWidth={false} defaultActive/>
|
|
348
|
-
</Example.Item>
|
|
349
|
-
</Example>),
|
|
350
|
-
};
|
|
351
|
-
export const contentGap = {
|
|
352
|
-
name: "contentGap",
|
|
353
|
-
render: () => <Demo contentGap={10} defaultActive/>,
|
|
354
|
-
};
|
|
355
|
-
export const contentShift = {
|
|
356
|
-
name: "contentShift",
|
|
357
|
-
render: () => <Demo contentShift={10} defaultActive/>,
|
|
358
|
-
};
|
|
359
|
-
export const disableContentHover = {
|
|
360
|
-
name: "disableContentHover",
|
|
361
|
-
render: () => <Demo triggerType="hover" disableContentHover/>,
|
|
362
|
-
// Can't trigger real mouse move from trigger to content in play function, so testing it manually
|
|
363
|
-
};
|
|
364
|
-
export const disableCloseOnOutsideClick = {
|
|
365
|
-
name: "disableCloseOnOutsideClick",
|
|
366
|
-
render: () => <Demo disableCloseOnOutsideClick/>,
|
|
367
|
-
play: async ({ canvasElement }) => {
|
|
368
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
369
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
370
|
-
await userEvent.click(trigger);
|
|
371
|
-
await waitFor(() => {
|
|
372
|
-
const content = canvas.getByText("Content");
|
|
373
|
-
expect(content).toBeVisible();
|
|
374
|
-
});
|
|
375
|
-
await userEvent.click(document.body);
|
|
376
|
-
await sleep(500);
|
|
377
|
-
const content = canvas.getByText("Content");
|
|
378
|
-
expect(content).toBeVisible();
|
|
379
|
-
},
|
|
380
|
-
};
|
|
381
|
-
export const disableHideAnimation = {
|
|
382
|
-
name: "disableHideAnimation",
|
|
383
|
-
render: () => <Demo disableHideAnimation defaultActive/>,
|
|
384
|
-
};
|
|
385
|
-
export const disabled = {
|
|
386
|
-
name: "disabled",
|
|
387
|
-
args: {
|
|
388
|
-
handleOpen: fn(),
|
|
389
|
-
},
|
|
390
|
-
render: () => (<Flyout disabled>
|
|
391
|
-
<Flyout.Trigger>
|
|
392
|
-
{(attributes) => <Button attributes={attributes}>Trigger</Button>}
|
|
393
|
-
</Flyout.Trigger>
|
|
394
|
-
<Flyout.Content>
|
|
395
|
-
<Content />
|
|
396
|
-
</Flyout.Content>
|
|
397
|
-
</Flyout>),
|
|
398
|
-
play: async ({ canvasElement, args }) => {
|
|
399
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
400
|
-
const button = canvas.getAllByRole("button")[0];
|
|
401
|
-
await userEvent.click(button);
|
|
402
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(0);
|
|
403
|
-
},
|
|
404
|
-
};
|
|
405
|
-
export const containerRef = {
|
|
406
|
-
name: "containerRef",
|
|
407
|
-
render: () => {
|
|
408
|
-
const portalRef = React.useRef(null);
|
|
409
|
-
const portalRef2 = React.useRef(null);
|
|
410
|
-
const portalRef3 = React.useRef(null);
|
|
411
|
-
return (<View gap={4} direction="row">
|
|
412
|
-
<View grow backgroundColor="neutral-faded" borderRadius="small" height={80} attributes={{ ref: portalRef, "data-testid": "container" }} justify="end" align="start" padding={4}>
|
|
413
|
-
<Demo containerRef={portalRef} position="bottom-start" defaultActive/>
|
|
414
|
-
</View>
|
|
415
|
-
<View grow backgroundColor="neutral-faded" borderRadius="small" height={80} attributes={{ ref: portalRef2 }} justify="start" align="end" padding={4}>
|
|
416
|
-
<Demo containerRef={portalRef2} position="top-end"/>
|
|
417
|
-
</View>
|
|
418
|
-
<View width={50} backgroundColor="neutral-faded" borderRadius="small" height={80} attributes={{ ref: portalRef3 }} padding={4} overflow="auto">
|
|
419
|
-
<View height={120} width="120%" justify="center" align="center">
|
|
420
|
-
<Demo containerRef={portalRef3} position="bottom-end"/>
|
|
421
|
-
</View>
|
|
422
|
-
</View>
|
|
423
|
-
</View>);
|
|
424
|
-
},
|
|
425
|
-
play: async ({ canvasElement }) => {
|
|
426
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
427
|
-
const containerEl = canvas.getByTestId("container");
|
|
428
|
-
const contentEl = canvas.getAllByText("Content")[0];
|
|
429
|
-
expect(containerEl).toContainElement(contentEl);
|
|
430
|
-
},
|
|
431
|
-
};
|
|
432
|
-
export const initialFocusRef = {
|
|
433
|
-
name: "initialFocusRef",
|
|
434
|
-
render: () => {
|
|
435
|
-
const initialFocusRef = React.useRef(null);
|
|
436
|
-
return (<Demo initialFocusRef={initialFocusRef}>
|
|
437
|
-
<View gap={4}>
|
|
438
|
-
<Button onClick={() => { }}>Action 1</Button>
|
|
439
|
-
<TextField name="foo" inputAttributes={{ ref: initialFocusRef }}/>
|
|
440
|
-
</View>
|
|
441
|
-
</Demo>);
|
|
442
|
-
},
|
|
443
|
-
play: async ({ canvasElement }) => {
|
|
444
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
445
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
446
|
-
await userEvent.click(trigger);
|
|
447
|
-
await waitFor(() => {
|
|
448
|
-
const input = canvas.getByRole("textbox");
|
|
449
|
-
expect(input).toBe(document.activeElement);
|
|
450
|
-
});
|
|
451
|
-
},
|
|
452
|
-
};
|
|
453
|
-
export const instanceRef = {
|
|
454
|
-
name: "instanceRef",
|
|
455
|
-
args: {
|
|
456
|
-
handleOpen: fn(),
|
|
457
|
-
handleClose: fn(),
|
|
458
|
-
},
|
|
459
|
-
render: (args) => {
|
|
460
|
-
const flyoutRef = React.useRef(null);
|
|
461
|
-
return (<View direction="row" gap={4}>
|
|
462
|
-
<Demo instanceRef={flyoutRef} disableCloseOnOutsideClick onOpen={args.handleOpen} onClose={args.handleClose}/>
|
|
463
|
-
|
|
464
|
-
<Button onClick={() => flyoutRef.current?.open()}>Open</Button>
|
|
465
|
-
<Button onClick={() => flyoutRef.current?.close()}>Close</Button>
|
|
466
|
-
</View>);
|
|
467
|
-
},
|
|
468
|
-
play: async ({ canvasElement, args }) => {
|
|
469
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
470
|
-
const openTrigger = canvas.getAllByRole("button")[1];
|
|
471
|
-
const closeTrigger = canvas.getAllByRole("button")[2];
|
|
472
|
-
await userEvent.click(openTrigger);
|
|
473
|
-
await waitFor(() => {
|
|
474
|
-
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
|
475
|
-
expect(args.handleOpen).toHaveBeenCalledWith();
|
|
476
|
-
});
|
|
477
|
-
await sleep(500);
|
|
478
|
-
await userEvent.click(closeTrigger);
|
|
479
|
-
await waitFor(() => {
|
|
480
|
-
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
|
481
|
-
expect(args.handleClose).toHaveBeenCalledWith({});
|
|
482
|
-
});
|
|
483
|
-
},
|
|
484
|
-
};
|
|
485
|
-
export const contentAttributes = {
|
|
486
|
-
name: "content: className, attributes",
|
|
487
|
-
render: () => {
|
|
488
|
-
return (<Flyout position="bottom" defaultActive>
|
|
489
|
-
<Flyout.Trigger>
|
|
490
|
-
{(attributes) => <Button attributes={attributes}>Trigger</Button>}
|
|
491
|
-
</Flyout.Trigger>
|
|
492
|
-
<Flyout.Content attributes={{ "data-testid": "test-id" }} className="test-classname">
|
|
493
|
-
<Content />
|
|
494
|
-
</Flyout.Content>
|
|
495
|
-
</Flyout>);
|
|
496
|
-
},
|
|
497
|
-
play: async ({ canvasElement }) => {
|
|
498
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
499
|
-
const content = canvas.getByTestId("test-id");
|
|
500
|
-
expect(content).toHaveClass("test-classname");
|
|
501
|
-
},
|
|
502
|
-
};
|
|
503
|
-
/*
|
|
504
|
-
* Test edge cases
|
|
505
|
-
*/
|
|
506
|
-
class CustomElement extends window.HTMLElement {
|
|
507
|
-
constructor() {
|
|
508
|
-
super();
|
|
509
|
-
this.attachShadow({ mode: "open" });
|
|
510
|
-
if (!this.shadowRoot)
|
|
511
|
-
return;
|
|
512
|
-
const node = (<Reshaped>
|
|
513
|
-
<Demo defaultActive>
|
|
514
|
-
Content
|
|
515
|
-
<div id="test-id"/>
|
|
516
|
-
</Demo>
|
|
517
|
-
</Reshaped>);
|
|
518
|
-
const root = createRoot(this.shadowRoot);
|
|
519
|
-
root.render(node);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
if (!window.customElements.get("custom-element-flyout")) {
|
|
523
|
-
window.customElements.define("custom-element-flyout", CustomElement);
|
|
524
|
-
}
|
|
525
|
-
export const testShadowDom = {
|
|
526
|
-
name: "test: shadow dom",
|
|
527
|
-
// @ts-ignore
|
|
528
|
-
render: () => <custom-element-flyout />,
|
|
529
|
-
};
|
|
530
|
-
export const testInsideFixed = {
|
|
531
|
-
name: "test: inside position fixed",
|
|
532
|
-
render: () => (<React.Fragment>
|
|
533
|
-
<View position="fixed" insetBottom={2} insetStart={2} insetEnd={2} backgroundColor="elevation-overlay" borderColor="neutral-faded" borderRadius="small" padding={4} zIndex={10} attributes={{ "data-testid": "container" }} height={20}>
|
|
534
|
-
<Demo defaultActive position="top-start"/>
|
|
535
|
-
</View>
|
|
536
|
-
<View paddingTop={18} gap={4}>
|
|
537
|
-
<View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
|
|
538
|
-
<View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
|
|
539
|
-
</View>
|
|
540
|
-
</React.Fragment>),
|
|
541
|
-
play: ({ canvas }) => {
|
|
542
|
-
const container = canvas.getByTestId("container");
|
|
543
|
-
const content = canvas.getByText("Content");
|
|
544
|
-
expect(container).toContainElement(content);
|
|
545
|
-
},
|
|
546
|
-
};
|
|
547
|
-
export const testInsideSticky = {
|
|
548
|
-
name: "test: inside position sticky",
|
|
549
|
-
render: () => (<React.Fragment>
|
|
550
|
-
<View position="sticky" insetTop={4} insetStart={0} insetEnd={0} backgroundColor="elevation-overlay" borderColor="neutral-faded" borderRadius="small" padding={4} zIndex={10} attributes={{ "data-testid": "container" }}>
|
|
551
|
-
<Demo defaultActive/>
|
|
552
|
-
</View>
|
|
553
|
-
<View gap={4} paddingTop={2}>
|
|
554
|
-
<View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
|
|
555
|
-
<View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
|
|
556
|
-
</View>
|
|
557
|
-
</React.Fragment>),
|
|
558
|
-
play: ({ canvas }) => {
|
|
559
|
-
const container = canvas.getByTestId("container");
|
|
560
|
-
const content = canvas.getByText("Content");
|
|
561
|
-
expect(container).toContainElement(content);
|
|
562
|
-
},
|
|
563
|
-
};
|
|
564
|
-
export const testInsideScrollable = {
|
|
565
|
-
name: "test: inside scrollable",
|
|
566
|
-
render: () => {
|
|
567
|
-
const containerRef = React.useRef(null);
|
|
568
|
-
return (<View padding={20}>
|
|
569
|
-
<View height={30} overflow="auto" backgroundColor="neutral-faded" borderRadius="small">
|
|
570
|
-
<View height={50} attributes={{ ref: containerRef }} padding={20} paddingBottom={30}>
|
|
571
|
-
<Demo position="bottom"/>
|
|
572
|
-
</View>
|
|
573
|
-
</View>
|
|
574
|
-
</View>);
|
|
575
|
-
},
|
|
576
|
-
};
|
|
577
|
-
export const testInsideModal = {
|
|
578
|
-
name: "test: inside modal",
|
|
579
|
-
render: () => {
|
|
580
|
-
return (<Modal active position="end">
|
|
581
|
-
<View gap={4} align="start">
|
|
582
|
-
<Modal.Title>Title</Modal.Title>
|
|
583
|
-
<Demo position="bottom-start"/>
|
|
584
|
-
<View height={300} width={25} backgroundColor="neutral-faded"/>
|
|
585
|
-
<Demo position="start"/>
|
|
586
|
-
<View height={300} width={25} backgroundColor="neutral-faded"/>
|
|
587
|
-
<Demo position="bottom-start"/>
|
|
588
|
-
</View>
|
|
589
|
-
</Modal>);
|
|
590
|
-
},
|
|
591
|
-
};
|
|
592
|
-
export const testDynamicBounds = {
|
|
593
|
-
name: "test: auto position update",
|
|
594
|
-
render: () => {
|
|
595
|
-
const [left, setLeft] = React.useState(50);
|
|
596
|
-
const [top, setTop] = React.useState(50);
|
|
597
|
-
const [size, setSize] = React.useState("medium");
|
|
598
|
-
const flyoutRef = React.useRef(null);
|
|
599
|
-
React.useEffect(() => {
|
|
600
|
-
flyoutRef.current?.updatePosition();
|
|
601
|
-
}, [left, top]);
|
|
602
|
-
return (<View gap={4}>
|
|
603
|
-
<View direction="row" gap={2}>
|
|
604
|
-
<Button onClick={() => setLeft((prev) => prev - 10)}>Left</Button>
|
|
605
|
-
<Button onClick={() => setLeft((prev) => prev + 10)}>Right</Button>
|
|
606
|
-
<Button onClick={() => setTop((prev) => prev - 10)}>Up</Button>
|
|
607
|
-
<Button onClick={() => setTop((prev) => prev + 10)}>Down</Button>
|
|
608
|
-
<Button onClick={() => {
|
|
609
|
-
setLeft(50);
|
|
610
|
-
setTop(50);
|
|
611
|
-
}}>
|
|
612
|
-
Center
|
|
613
|
-
</Button>
|
|
614
|
-
<Button onClick={() => setSize("large")}>Large button</Button>
|
|
615
|
-
<Button onClick={() => setSize("medium")}>Small button</Button>
|
|
616
|
-
</View>
|
|
617
|
-
<View height={100}>
|
|
618
|
-
<Flyout position="bottom" instanceRef={flyoutRef} disableCloseOnOutsideClick defaultActive>
|
|
619
|
-
<Flyout.Trigger>
|
|
620
|
-
{(attributes) => (<div style={{ position: "absolute", left: `${left}%`, top: `${top}%` }}>
|
|
621
|
-
<Button color="primary" attributes={attributes} size={size}>
|
|
622
|
-
Open
|
|
623
|
-
</Button>
|
|
624
|
-
</div>)}
|
|
625
|
-
</Flyout.Trigger>
|
|
626
|
-
<Flyout.Content>
|
|
627
|
-
<Content />
|
|
628
|
-
</Flyout.Content>
|
|
629
|
-
</Flyout>
|
|
630
|
-
</View>
|
|
631
|
-
</View>);
|
|
632
|
-
},
|
|
633
|
-
};
|
|
634
|
-
export const testScopedTheming = {
|
|
635
|
-
name: "test: content uses scope theme",
|
|
636
|
-
render: () => (<View gap={3} align="start">
|
|
637
|
-
<Button color="primary">Slate button</Button>
|
|
638
|
-
<Theme name="reshaped">
|
|
639
|
-
<Flyout triggerType="click" active position="bottom-start">
|
|
640
|
-
<Flyout.Trigger>
|
|
641
|
-
{(attributes) => (<Button color="primary" attributes={attributes}>
|
|
642
|
-
Reshaped button
|
|
643
|
-
</Button>)}
|
|
644
|
-
</Flyout.Trigger>
|
|
645
|
-
<Flyout.Content>
|
|
646
|
-
<Content>
|
|
647
|
-
<View gap={1}>
|
|
648
|
-
<View.Item>Portal content, rendered in body</View.Item>
|
|
649
|
-
<Button color="primary">Reshaped button</Button>
|
|
650
|
-
</View>
|
|
651
|
-
</Content>
|
|
652
|
-
</Flyout.Content>
|
|
653
|
-
</Flyout>
|
|
654
|
-
</Theme>
|
|
655
|
-
</View>),
|
|
656
|
-
};
|
|
657
|
-
export const testWithoutFocusable = {
|
|
658
|
-
name: "test: without focusable content",
|
|
659
|
-
render: () => <Demo position="bottom-start"/>,
|
|
660
|
-
play: async ({ canvasElement }) => {
|
|
661
|
-
const canvas = within(canvasElement.ownerDocument.body);
|
|
662
|
-
const trigger = canvas.getAllByRole("button")[0];
|
|
663
|
-
await userEvent.click(trigger);
|
|
664
|
-
await waitFor(() => {
|
|
665
|
-
const content = canvas.getByText("Content");
|
|
666
|
-
expect(content).toBeVisible();
|
|
667
|
-
});
|
|
668
|
-
expect(document.activeElement).toBe(trigger);
|
|
669
|
-
},
|
|
670
|
-
};
|
|
671
|
-
export const testChangeSize = {
|
|
672
|
-
name: "test: size updates",
|
|
673
|
-
render: () => {
|
|
674
|
-
const [position, setPosition] = React.useState("bottom-start");
|
|
675
|
-
const [updatedHeight, setUpdatedHeight] = React.useState(false);
|
|
676
|
-
return (<>
|
|
677
|
-
<View direction="row" gap={4} align="center">
|
|
678
|
-
<Select name="position" options={[
|
|
679
|
-
"bottom-start",
|
|
680
|
-
"bottom",
|
|
681
|
-
"bottom-end",
|
|
682
|
-
"top-start",
|
|
683
|
-
"top",
|
|
684
|
-
"top-end",
|
|
685
|
-
"start-top",
|
|
686
|
-
"start",
|
|
687
|
-
"start-bottom",
|
|
688
|
-
"end-top",
|
|
689
|
-
"end",
|
|
690
|
-
"end-bottom",
|
|
691
|
-
].map((p) => ({ label: p, value: p }))} onChange={(args) => setPosition(args.value)} value={position}/>
|
|
692
|
-
<Switch name="height" onChange={(args) => setUpdatedHeight(args.checked)}>
|
|
693
|
-
Change height
|
|
694
|
-
</Switch>
|
|
695
|
-
</View>
|
|
696
|
-
<div style={{
|
|
697
|
-
position: "fixed",
|
|
698
|
-
top: "50%",
|
|
699
|
-
left: "50%",
|
|
700
|
-
transform: "translate(-50%, -50%)",
|
|
701
|
-
}}>
|
|
702
|
-
<Demo position={position} disableCloseOnOutsideClick active contentHeight={false}>
|
|
703
|
-
<View backgroundColor="neutral-faded" borderRadius="small" height={updatedHeight ? 50 : 25} attributes={{ style: { transition: "0.2s ease-in-out" } }}/>
|
|
704
|
-
</Demo>
|
|
705
|
-
</div>
|
|
706
|
-
</>);
|
|
707
|
-
},
|
|
708
|
-
};
|