reshaped 3.8.0-canary.0 → 3.8.0-canary.10
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 +101 -8
- package/README.md +2 -2
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +11 -11
- package/dist/components/Accordion/AccordionControlled.js +1 -0
- package/dist/components/Actionable/Actionable.js +17 -3
- package/dist/components/Actionable/Actionable.module.css +1 -1
- package/dist/components/Actionable/Actionable.types.d.ts +15 -3
- package/dist/components/Actionable/tests/Actionable.stories.d.ts +13 -1
- package/dist/components/Actionable/tests/Actionable.stories.js +127 -7
- package/dist/components/Alert/tests/Alert.stories.d.ts +6 -5
- package/dist/components/Alert/tests/Alert.stories.js +15 -2
- package/dist/components/Autocomplete/Autocomplete.js +2 -2
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +1 -1
- package/dist/components/Badge/Badge.module.css +1 -1
- package/dist/components/Badge/tests/Badge.stories.d.ts +5 -0
- package/dist/components/Badge/tests/Badge.stories.js +34 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -0
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +8 -4
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +57 -1
- package/dist/components/Button/Button.js +2 -2
- package/dist/components/Button/Button.types.d.ts +1 -1
- package/dist/components/Button/tests/Button.stories.d.ts +54 -12
- package/dist/components/Button/tests/Button.stories.js +725 -588
- package/dist/components/Calendar/CalendarMonth.js +1 -0
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/Card.module.css +1 -1
- package/dist/components/Card/tests/Card.stories.d.ts +29 -7
- package/dist/components/Card/tests/Card.stories.js +110 -65
- package/dist/components/Carousel/Carousel.js +1 -0
- package/dist/components/Carousel/Carousel.module.css +1 -1
- package/dist/components/Checkbox/Checkbox.module.css +1 -1
- package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +20 -4
- package/dist/components/Checkbox/tests/Checkbox.stories.js +150 -79
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +9 -2
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +67 -35
- package/dist/components/Container/tests/Container.stories.d.ts +2 -0
- package/dist/components/Container/tests/Container.stories.js +14 -0
- package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +10 -1
- package/dist/components/ContextMenu/tests/ContextMenu.stories.js +57 -13
- package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +5 -0
- package/dist/components/Dismissible/tests/Dismissible.stories.js +30 -1
- package/dist/components/Divider/tests/Divider.stories.d.ts +8 -3
- package/dist/components/Divider/tests/Divider.stories.js +71 -41
- package/dist/components/DropdownMenu/DropdownMenu.js +4 -4
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +2 -2
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +35 -6
- package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +222 -115
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +0 -15
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +0 -106
- package/dist/components/FileUpload/FileUpload.module.css +1 -1
- package/dist/components/Flyout/Flyout.module.css +1 -1
- package/dist/components/Flyout/Flyout.types.d.ts +9 -6
- package/dist/components/Flyout/FlyoutContent.js +4 -1
- package/dist/components/Flyout/FlyoutControlled.js +11 -3
- package/dist/components/Flyout/index.d.ts +1 -1
- package/dist/components/Flyout/tests/Flyout.stories.d.ts +12 -0
- package/dist/components/Flyout/tests/Flyout.stories.js +112 -6
- package/dist/components/Flyout/useFlyout.d.ts +1 -6
- package/dist/components/Flyout/useFlyout.js +7 -1
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +3 -2
- package/dist/components/Flyout/utilities/calculatePosition.js +85 -36
- package/dist/components/Flyout/utilities/flyout.js +24 -19
- package/dist/components/Flyout/utilities/getPositionFallbacks.js +3 -3
- package/dist/components/Flyout/utilities/helpers.d.ts +7 -0
- package/dist/components/Flyout/utilities/helpers.js +14 -0
- package/dist/components/Flyout/utilities/isFullyVisible.d.ts +4 -2
- package/dist/components/Flyout/utilities/isFullyVisible.js +6 -8
- package/dist/components/FormControl/FormControl.context.d.ts +1 -1
- package/dist/components/FormControl/tests/FormControl.stories.d.ts +2 -0
- package/dist/components/FormControl/tests/FormControl.stories.js +35 -0
- package/dist/components/Hidden/tests/Hidden.stories.d.ts +2 -0
- package/dist/components/Hidden/tests/Hidden.stories.js +9 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +2 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +9 -0
- package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +2 -0
- package/dist/components/Hotkey/tests/Hotkey.stories.js +15 -0
- package/dist/components/Icon/Icon.js +2 -2
- package/dist/components/Icon/Icon.types.d.ts +1 -1
- package/dist/components/Icon/tests/Icon.stories.d.ts +3 -0
- package/dist/components/Icon/tests/Icon.stories.js +29 -1
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/Link/Link.js +2 -2
- package/dist/components/Link/Link.types.d.ts +1 -1
- package/dist/components/Link/tests/Link.stories.d.ts +29 -6
- package/dist/components/Link/tests/Link.stories.js +141 -58
- package/dist/components/Link/tests/Link.test.stories.d.ts +1 -13
- package/dist/components/Link/tests/Link.test.stories.js +0 -76
- package/dist/components/Loader/tests/Loader.stories.d.ts +11 -2
- package/dist/components/Loader/tests/Loader.stories.js +52 -25
- package/dist/components/Loader/tests/Loader.test.stories.d.ts +0 -3
- package/dist/components/Loader/tests/Loader.test.stories.js +0 -21
- package/dist/components/MenuItem/MenuItem.js +2 -2
- package/dist/components/MenuItem/MenuItem.module.css +1 -1
- package/dist/components/MenuItem/MenuItem.types.d.ts +1 -1
- package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +37 -7
- package/dist/components/MenuItem/tests/MenuItem.stories.js +218 -112
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/Modal/Modal.module.css +1 -1
- package/dist/components/Modal/tests/Modal.stories.d.ts +53 -10
- package/dist/components/Modal/tests/Modal.stories.js +367 -210
- package/dist/components/Overlay/Overlay.js +2 -1
- package/dist/components/Overlay/tests/Overlay.stories.d.ts +15 -1
- package/dist/components/Overlay/tests/Overlay.stories.js +135 -1
- package/dist/components/Pagination/tests/Pagination.stories.d.ts +14 -1
- package/dist/components/Pagination/tests/Pagination.stories.js +93 -15
- package/dist/components/PinField/PinField.module.css +1 -1
- package/dist/components/PinField/tests/PinField.stories.d.ts +24 -3
- package/dist/components/PinField/tests/PinField.stories.js +194 -47
- package/dist/components/Popover/Popover.js +2 -2
- package/dist/components/Popover/Popover.module.css +1 -1
- package/dist/components/Popover/Popover.types.d.ts +3 -1
- package/dist/components/Progress/tests/Progress.stories.d.ts +19 -4
- package/dist/components/Progress/tests/Progress.stories.js +85 -49
- package/dist/components/Radio/Radio.module.css +1 -1
- package/dist/components/Radio/tests/Radio.stories.d.ts +25 -4
- package/dist/components/Radio/tests/Radio.stories.js +147 -65
- package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +9 -2
- package/dist/components/RadioGroup/tests/RadioGroup.stories.js +64 -38
- package/dist/components/Reshaped/Reshaped.css +1 -1
- package/dist/components/Scrim/tests/Scrim.stories.d.ts +10 -2
- package/dist/components/Scrim/tests/Scrim.stories.js +51 -31
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/Select/Select.d.ts +8 -1
- package/dist/components/Select/Select.js +22 -48
- package/dist/components/Select/Select.module.css +1 -1
- package/dist/components/Select/Select.types.d.ts +83 -38
- package/dist/components/Select/SelectCustom.d.ts +3 -0
- package/dist/components/Select/SelectCustom.js +12 -0
- package/dist/components/Select/SelectCustomControlled.d.ts +4 -0
- package/dist/components/Select/SelectCustomControlled.js +105 -0
- package/dist/components/Select/SelectCustomUncontrolled.d.ts +4 -0
- package/dist/components/Select/SelectCustomUncontrolled.js +18 -0
- package/dist/components/Select/SelectEndContent.d.ts +3 -0
- package/dist/components/Select/SelectEndContent.js +12 -0
- package/dist/components/Select/SelectNative.d.ts +4 -0
- package/dist/components/Select/SelectNative.js +29 -0
- package/dist/components/Select/SelectOption.d.ts +4 -0
- package/dist/components/Select/SelectOption.js +13 -0
- package/dist/components/Select/SelectOptionGroup.d.ts +4 -0
- package/dist/components/Select/SelectOptionGroup.js +9 -0
- package/dist/components/Select/SelectRoot.d.ts +4 -0
- package/dist/components/Select/SelectRoot.js +21 -0
- package/dist/components/Select/SelectStartContent.d.ts +3 -0
- package/dist/components/Select/SelectStartContent.js +20 -0
- package/dist/components/Select/SelectTrigger.d.ts +4 -0
- package/dist/components/Select/SelectTrigger.js +16 -0
- package/dist/components/Select/tests/Select.stories.d.ts +38 -10
- package/dist/components/Select/tests/Select.stories.js +504 -175
- package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +10 -2
- package/dist/components/Skeleton/tests/Skeleton.stories.js +46 -28
- package/dist/components/Slider/Slider.module.css +1 -1
- package/dist/components/Stepper/Stepper.js +2 -2
- package/dist/components/Stepper/Stepper.types.d.ts +2 -0
- package/dist/components/Stepper/tests/Stepper.stories.d.ts +18 -3
- package/dist/components/Stepper/tests/Stepper.stories.js +99 -47
- package/dist/components/Switch/Switch.module.css +1 -1
- package/dist/components/Switch/tests/Switch.stories.d.ts +10 -2
- package/dist/components/Switch/tests/Switch.stories.js +77 -23
- package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -10
- package/dist/components/Switch/tests/Switch.test.stories.js +0 -68
- package/dist/components/Table/Table.js +5 -3
- package/dist/components/Table/Table.module.css +1 -1
- package/dist/components/Table/tests/Table.stories.d.ts +25 -5
- package/dist/components/Table/tests/Table.stories.js +274 -177
- package/dist/components/Table/tests/Table.test.stories.d.ts +0 -5
- package/dist/components/Table/tests/Table.test.stories.js +0 -82
- package/dist/components/Tabs/Tabs.module.css +1 -1
- package/dist/components/Tabs/TabsControlled.js +1 -0
- package/dist/components/TextArea/TextArea.module.css +1 -1
- package/dist/components/TextArea/tests/TextArea.stories.d.ts +41 -9
- package/dist/components/TextArea/tests/TextArea.stories.js +179 -93
- package/dist/components/TextField/TextField.js +1 -1
- package/dist/components/TextField/TextField.module.css +1 -1
- package/dist/components/TextField/tests/TextField.stories.d.ts +41 -11
- package/dist/components/TextField/tests/TextField.stories.js +206 -132
- package/dist/components/TextField/tests/TextField.test.stories.d.ts +0 -13
- package/dist/components/TextField/tests/TextField.test.stories.js +0 -88
- package/dist/components/Theme/Theme.module.css +1 -1
- package/dist/components/Timeline/Timeline.js +2 -2
- package/dist/components/Timeline/tests/Timeline.stories.d.ts +10 -2
- package/dist/components/Timeline/tests/Timeline.stories.js +69 -45
- package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +0 -2
- package/dist/components/Timeline/tests/Timeline.test.stories.js +0 -21
- package/dist/components/Toast/ToastContainer.js +1 -0
- package/dist/components/Toast/ToastRegion.js +1 -0
- package/dist/components/Toast/tests/Toast.stories.d.ts +32 -8
- package/dist/components/Toast/tests/Toast.stories.js +111 -37
- package/dist/components/ToggleButton/ToggleButton.types.d.ts +1 -1
- package/dist/components/ToggleButtonGroup/ToggleButtonGroupControlled.js +1 -0
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tooltip/Tooltip.types.d.ts +2 -2
- package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +18 -4
- package/dist/components/Tooltip/tests/Tooltip.stories.js +139 -107
- package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +0 -6
- package/dist/components/Tooltip/tests/Tooltip.test.stories.js +0 -29
- package/dist/components/View/View.js +11 -4
- package/dist/components/View/tests/View.stories.d.ts +4 -0
- package/dist/components/View/tests/View.stories.js +39 -0
- package/dist/components/_private/Expandable/Expandable.js +3 -1
- package/dist/components/_private/Portal/Portal.js +4 -1
- package/dist/hooks/_private/useIsDismissible.d.ts +1 -0
- package/dist/hooks/_private/useIsDismissible.js +6 -6
- package/dist/hooks/_private/usePrevious.js +1 -0
- package/dist/hooks/tests/useDrag.stories.js +1 -1
- package/dist/hooks/useScrollLock.js +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/styles/resolvers/align/align.css +1 -1
- package/dist/styles/resolvers/aspectRatio/aspectRatio.css +1 -1
- package/dist/styles/resolvers/bleed/bleed.module.css +1 -1
- package/dist/styles/resolvers/justify/justify.css +1 -1
- package/dist/styles/resolvers/maxHeight/maxHeight.module.css +1 -1
- package/dist/styles/resolvers/maxWidth/maxWidth.module.css +1 -1
- package/dist/styles/resolvers/minHeight/minHeight.module.css +1 -1
- package/dist/styles/resolvers/minWidth/minWidth.module.css +1 -1
- package/dist/styles/resolvers/position/position.css +1 -1
- package/dist/styles/resolvers/textAlign/textAlign.css +1 -1
- package/dist/styles/resolvers/width/width.module.css +1 -1
- package/dist/utilities/scroll/disable.js +2 -2
- package/dist/utilities/scroll/index.d.ts +1 -1
- package/dist/utilities/scroll/index.js +1 -1
- package/dist/utilities/scroll/lock.d.ts +1 -2
- package/dist/utilities/scroll/lock.js +16 -15
- package/dist/utilities/scroll/lockSafari.js +1 -0
- package/package.json +44 -33
- package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +0 -32
- package/dist/components/Actionable/tests/Actionable.test.stories.js +0 -130
- package/dist/components/Alert/tests/Alert.test.stories.d.ts +0 -15
- package/dist/components/Alert/tests/Alert.test.stories.js +0 -26
- package/dist/components/Badge/tests/Badge.test.stories.d.ts +0 -20
- package/dist/components/Badge/tests/Badge.test.stories.js +0 -46
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +0 -23
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +0 -76
- package/dist/components/Button/tests/Button.test.stories.d.ts +0 -27
- package/dist/components/Button/tests/Button.test.stories.js +0 -112
- package/dist/components/Card/tests/Card.test.stories.d.ts +0 -35
- package/dist/components/Card/tests/Card.test.stories.js +0 -54
- package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +0 -25
- package/dist/components/Checkbox/tests/Checkbox.test.stories.js +0 -104
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +0 -22
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +0 -78
- package/dist/components/Container/tests/Container.test.stories.d.ts +0 -15
- package/dist/components/Container/tests/Container.test.stories.js +0 -26
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +0 -25
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +0 -53
- package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +0 -19
- package/dist/components/Dismissible/tests/Dismissible.test.stories.js +0 -42
- package/dist/components/Divider/tests/Divider.test.stories.d.ts +0 -18
- package/dist/components/Divider/tests/Divider.test.stories.js +0 -47
- package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +0 -20
- package/dist/components/FormControl/tests/FormControl.test.stories.js +0 -49
- package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +0 -15
- package/dist/components/Hidden/tests/Hidden.test.stories.js +0 -20
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +0 -15
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +0 -20
- package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +0 -15
- package/dist/components/Hotkey/tests/Hotkey.test.stories.js +0 -26
- package/dist/components/Icon/tests/Icon.test.stories.d.ts +0 -16
- package/dist/components/Icon/tests/Icon.test.stories.js +0 -35
- package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +0 -26
- package/dist/components/MenuItem/tests/MenuItem.test.stories.js +0 -100
- package/dist/components/Modal/tests/Modal.test.stories.d.ts +0 -31
- package/dist/components/Modal/tests/Modal.test.stories.js +0 -149
- package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +0 -28
- package/dist/components/Overlay/tests/Overlay.test.stories.js +0 -148
- package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +0 -23
- package/dist/components/Pagination/tests/Pagination.test.stories.js +0 -86
- package/dist/components/PinField/tests/PinField.test.stories.d.ts +0 -29
- package/dist/components/PinField/tests/PinField.test.stories.js +0 -177
- package/dist/components/Progress/tests/Progress.test.stories.d.ts +0 -16
- package/dist/components/Progress/tests/Progress.test.stories.js +0 -35
- package/dist/components/Radio/tests/Radio.test.stories.d.ts +0 -30
- package/dist/components/Radio/tests/Radio.test.stories.js +0 -118
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +0 -22
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +0 -78
- package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +0 -15
- package/dist/components/Scrim/tests/Scrim.test.stories.js +0 -25
- package/dist/components/Select/tests/Select.test.stories.d.ts +0 -27
- package/dist/components/Select/tests/Select.test.stories.js +0 -132
- package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +0 -15
- package/dist/components/Skeleton/tests/Skeleton.test.stories.js +0 -23
- package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +0 -20
- package/dist/components/Stepper/tests/Stepper.test.stories.js +0 -28
- package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +0 -28
- package/dist/components/TextArea/tests/TextArea.test.stories.js +0 -99
- package/dist/components/Toast/tests/Toast.test.stories.d.ts +0 -16
- package/dist/components/Toast/tests/Toast.test.stories.js +0 -101
- package/dist/components/View/tests/View.test.stories.d.ts +0 -24
- package/dist/components/View/tests/View.test.stories.js +0 -50
@@ -1,8 +1,10 @@
|
|
1
|
-
import { userEvent } from "storybook/test";
|
1
|
+
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
2
2
|
import { Example } from "../../../utilities/storybook/index.js";
|
3
3
|
import Overlay from "../index.js";
|
4
4
|
import Button from "../../Button/index.js";
|
5
5
|
import useToggle from "../../../hooks/useToggle.js";
|
6
|
+
import React from "react";
|
7
|
+
import { sleep } from "../../../utilities/helpers.js";
|
6
8
|
export default {
|
7
9
|
title: "Utility components/Overlay",
|
8
10
|
component: Overlay,
|
@@ -66,3 +68,135 @@ export const blurred = {
|
|
66
68
|
await userEvent.click(trigger);
|
67
69
|
},
|
68
70
|
};
|
71
|
+
export const renderProps = {
|
72
|
+
name: "children, render props",
|
73
|
+
render: () => (<Overlay active className="test-classname" attributes={{ "data-testid": "test-id" }}>
|
74
|
+
{(args) => (args.active ? "Opened" : "Closed")}
|
75
|
+
</Overlay>),
|
76
|
+
play: async ({ canvasElement }) => {
|
77
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
78
|
+
const root = canvas.getByText("Opened");
|
79
|
+
expect(root).toBeInTheDocument();
|
80
|
+
},
|
81
|
+
};
|
82
|
+
export const handlers = {
|
83
|
+
name: "onOpen, onClose, onAfterOpen, onAfterClose",
|
84
|
+
args: {
|
85
|
+
handleOpen: fn(),
|
86
|
+
handleClose: fn(),
|
87
|
+
handleAfterClose: fn(),
|
88
|
+
handleAfterOpen: fn(),
|
89
|
+
},
|
90
|
+
render: (args) => {
|
91
|
+
const overlayToggle = useToggle();
|
92
|
+
return (<>
|
93
|
+
<Button onClick={() => overlayToggle.toggle()}>Open overlay</Button>
|
94
|
+
<Overlay active={overlayToggle.active} onClose={(closeArgs) => {
|
95
|
+
overlayToggle.deactivate();
|
96
|
+
args.handleClose(closeArgs);
|
97
|
+
}} onOpen={args.handleOpen} onAfterOpen={args.handleAfterOpen} onAfterClose={args.handleAfterClose}>
|
98
|
+
Content
|
99
|
+
</Overlay>
|
100
|
+
</>);
|
101
|
+
},
|
102
|
+
play: async ({ canvasElement, args }) => {
|
103
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
104
|
+
const trigger = canvas.getAllByRole("button")[0];
|
105
|
+
let overlay;
|
106
|
+
await userEvent.click(trigger);
|
107
|
+
overlay = canvas.getByText("Content");
|
108
|
+
await waitFor(() => {
|
109
|
+
expect(args.handleOpen).toHaveBeenCalledTimes(1);
|
110
|
+
expect(args.handleOpen).toHaveBeenCalledWith();
|
111
|
+
});
|
112
|
+
// Wait for transition
|
113
|
+
await waitFor(() => {
|
114
|
+
expect(args.handleAfterOpen).toHaveBeenCalledTimes(1);
|
115
|
+
expect(args.handleAfterOpen).toHaveBeenCalledWith();
|
116
|
+
});
|
117
|
+
// Close by changing the state after the trigger click
|
118
|
+
await userEvent.click(trigger);
|
119
|
+
// Changing state doesn't trigger onClose
|
120
|
+
expect(args.handleClose).toHaveBeenCalledTimes(0);
|
121
|
+
// Wait for transition
|
122
|
+
await waitFor(() => {
|
123
|
+
expect(args.handleAfterClose).toHaveBeenCalledTimes(1);
|
124
|
+
expect(args.handleAfterClose).toHaveBeenCalledWith();
|
125
|
+
});
|
126
|
+
// Open
|
127
|
+
await userEvent.click(trigger);
|
128
|
+
overlay = canvas.getByText("Content");
|
129
|
+
// TODO: Fails CLI tests in Storybook without a timeout
|
130
|
+
await sleep(100);
|
131
|
+
// Close by clicking on the overlay
|
132
|
+
await userEvent.click(overlay);
|
133
|
+
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
134
|
+
expect(args.handleClose).toHaveBeenCalledWith({ reason: "overlay-click" });
|
135
|
+
await waitFor(() => {
|
136
|
+
expect(args.handleAfterClose).toHaveBeenCalledTimes(2);
|
137
|
+
expect(args.handleAfterClose).toHaveBeenCalledWith();
|
138
|
+
});
|
139
|
+
// Open
|
140
|
+
await userEvent.click(trigger);
|
141
|
+
// TODO: Fails CLI tests in Storybook without a timeout
|
142
|
+
await sleep(100);
|
143
|
+
// Close by pressing Escape
|
144
|
+
await userEvent.keyboard("{Escape}");
|
145
|
+
expect(args.handleClose).toHaveBeenCalledTimes(2);
|
146
|
+
expect(args.handleClose).toHaveBeenCalledWith({ reason: "escape-key" });
|
147
|
+
await waitFor(() => {
|
148
|
+
expect(args.handleAfterClose).toHaveBeenCalledTimes(3);
|
149
|
+
expect(args.handleAfterClose).toHaveBeenCalledWith();
|
150
|
+
});
|
151
|
+
},
|
152
|
+
};
|
153
|
+
export const disableCloseOnClick = {
|
154
|
+
name: "disableCloseOnClick",
|
155
|
+
args: {
|
156
|
+
handleClose: fn(),
|
157
|
+
},
|
158
|
+
render: (args) => (<Overlay active disableCloseOnClick onClose={(closeArgs) => {
|
159
|
+
args.handleClose(closeArgs);
|
160
|
+
}}>
|
161
|
+
Content
|
162
|
+
</Overlay>),
|
163
|
+
play: async ({ canvasElement, args }) => {
|
164
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
165
|
+
const overlay = canvas.getByText("Content");
|
166
|
+
await userEvent.click(overlay);
|
167
|
+
// TODO: Fails CLI tests in Storybook without a timeout
|
168
|
+
await sleep(100);
|
169
|
+
expect(args.handleClose).toHaveBeenCalledTimes(0);
|
170
|
+
await userEvent.keyboard("{Escape}");
|
171
|
+
expect(args.handleClose).toHaveBeenCalledTimes(1);
|
172
|
+
},
|
173
|
+
};
|
174
|
+
export const containerRef = {
|
175
|
+
name: "containerRef",
|
176
|
+
render: () => {
|
177
|
+
const containerRef = React.useRef(null);
|
178
|
+
return (<>
|
179
|
+
<div ref={containerRef} data-testid="test-id" style={{ height: 200 }}/>
|
180
|
+
<Overlay active containerRef={containerRef}>
|
181
|
+
Content
|
182
|
+
</Overlay>
|
183
|
+
</>);
|
184
|
+
},
|
185
|
+
play: ({ canvasElement }) => {
|
186
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
187
|
+
const container = canvas.getByTestId("test-id");
|
188
|
+
const overlay = canvas.getByText("Content");
|
189
|
+
expect(container).toContainElement(overlay);
|
190
|
+
},
|
191
|
+
};
|
192
|
+
export const className = {
|
193
|
+
name: "className, attributes",
|
194
|
+
render: () => (<Overlay active className="test-classname" attributes={{ "data-testid": "test-id" }}>
|
195
|
+
Content
|
196
|
+
</Overlay>),
|
197
|
+
play: async ({ canvasElement }) => {
|
198
|
+
const canvas = within(canvasElement.ownerDocument.body);
|
199
|
+
const root = canvas.getByTestId("test-id");
|
200
|
+
expect(root).toHaveClass("test-classname");
|
201
|
+
},
|
202
|
+
};
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { fn } from "storybook/test";
|
2
|
+
import { StoryObj } from "@storybook/react-vite";
|
1
3
|
declare const _default: {
|
2
4
|
title: string;
|
3
5
|
component: import("react").FC<import("./..").PaginationProps>;
|
@@ -8,4 +10,15 @@ declare const _default: {
|
|
8
10
|
};
|
9
11
|
};
|
10
12
|
export default _default;
|
11
|
-
export declare const truncate:
|
13
|
+
export declare const truncate: {
|
14
|
+
name: string;
|
15
|
+
render: () => import("react").JSX.Element;
|
16
|
+
};
|
17
|
+
export declare const render: StoryObj;
|
18
|
+
export declare const defaultPage: StoryObj<{
|
19
|
+
handleChange: ReturnType<typeof fn>;
|
20
|
+
}>;
|
21
|
+
export declare const page: StoryObj<{
|
22
|
+
handleChange: ReturnType<typeof fn>;
|
23
|
+
}>;
|
24
|
+
export declare const className: StoryObj;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Example } from "../../../utilities/storybook/index.js";
|
2
2
|
import Pagination from "../index.js";
|
3
|
+
import { expect, fn, userEvent, within } from "storybook/test";
|
3
4
|
export default {
|
4
5
|
title: "Components/Pagination",
|
5
6
|
component: Pagination,
|
@@ -9,19 +10,96 @@ export default {
|
|
9
10
|
},
|
10
11
|
},
|
11
12
|
};
|
12
|
-
export const truncate =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
export const truncate = {
|
14
|
+
name: "truncate",
|
15
|
+
render: () => {
|
16
|
+
return (<Example>
|
17
|
+
<Example.Item title="start">
|
18
|
+
<Pagination total={10} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
19
|
+
</Example.Item>
|
20
|
+
<Example.Item title="middle">
|
21
|
+
<Pagination total={10} defaultPage={5} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
22
|
+
</Example.Item>
|
23
|
+
<Example.Item title="end">
|
24
|
+
<Pagination total={10} defaultPage={10} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
25
|
+
</Example.Item>
|
26
|
+
<Example.Item title="no truncation">
|
27
|
+
<Pagination total={4} previousAriaLabel="Previous page" nextAriaLabel="Next page" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
28
|
+
</Example.Item>
|
29
|
+
</Example>);
|
30
|
+
},
|
31
|
+
};
|
32
|
+
export const render = {
|
33
|
+
name: "rendering",
|
34
|
+
render: () => (<div data-testid="root">
|
35
|
+
<Pagination total={10} previousAriaLabel="Previous" nextAriaLabel="Next" pageAriaLabel={(args) => `Page ${args.page}`}/>
|
36
|
+
</div>),
|
37
|
+
play: async ({ canvas }) => {
|
38
|
+
const root = within(canvas.getByTestId("root"));
|
39
|
+
const buttons = root.getAllByRole("button");
|
40
|
+
const pages = buttons.slice(1, -1);
|
41
|
+
const prevButton = root.getByLabelText("Previous");
|
42
|
+
const nextButton = root.getByLabelText("Next");
|
43
|
+
const firstPageButton = root.getByLabelText("Page 1");
|
44
|
+
expect(buttons.length).toBe(8);
|
45
|
+
expect(prevButton).toEqual(buttons[0]);
|
46
|
+
expect(prevButton).toBeDisabled();
|
47
|
+
expect(nextButton).toEqual(buttons.at(-1));
|
48
|
+
expect(nextButton).not.toBeDisabled();
|
49
|
+
expect(firstPageButton).toBeInTheDocument();
|
50
|
+
expect(firstPageButton).toEqual(pages[0]);
|
51
|
+
expect(firstPageButton).toHaveAttribute("aria-current", "true");
|
52
|
+
},
|
53
|
+
};
|
54
|
+
export const defaultPage = {
|
55
|
+
name: "defaultPage, uncontrolled",
|
56
|
+
args: {
|
57
|
+
handleChange: fn(),
|
58
|
+
},
|
59
|
+
render: (args) => (<div data-testid="root">
|
60
|
+
<Pagination total={10} defaultPage={2} onChange={args.handleChange} previousAriaLabel="Previous" nextAriaLabel="Next"/>
|
61
|
+
</div>),
|
62
|
+
play: async ({ canvas, args }) => {
|
63
|
+
const root = within(canvas.getByTestId("root"));
|
64
|
+
const buttons = root.getAllByRole("button");
|
65
|
+
const pages = buttons.slice(1, -1);
|
66
|
+
expect(pages[1]).toHaveAttribute("aria-current");
|
67
|
+
await userEvent.click(pages[2]);
|
68
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
69
|
+
expect(args.handleChange).toHaveBeenCalledWith({ page: 3 });
|
70
|
+
expect(pages[1]).toHaveAttribute("aria-current", "false");
|
71
|
+
expect(pages[2]).toHaveAttribute("aria-current", "true");
|
72
|
+
},
|
73
|
+
};
|
74
|
+
export const page = {
|
75
|
+
name: "page, controlled",
|
76
|
+
args: {
|
77
|
+
handleChange: fn(),
|
78
|
+
},
|
79
|
+
render: (args) => (<div data-testid="root">
|
80
|
+
<Pagination total={10} page={2} onChange={args.handleChange} previousAriaLabel="Previous" nextAriaLabel="Next"/>
|
81
|
+
</div>),
|
82
|
+
play: async ({ canvas, args }) => {
|
83
|
+
const root = within(canvas.getByTestId("root"));
|
84
|
+
const buttons = root.getAllByRole("button");
|
85
|
+
const pages = buttons.slice(1, -1);
|
86
|
+
expect(pages[1]).toHaveAttribute("aria-current");
|
87
|
+
await userEvent.click(pages[2]);
|
88
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
89
|
+
expect(args.handleChange).toHaveBeenCalledWith({ page: 3 });
|
90
|
+
// Stays the same because it's controlled
|
91
|
+
expect(pages[1]).toHaveAttribute("aria-current", "true");
|
92
|
+
expect(pages[2]).toHaveAttribute("aria-current", "false");
|
93
|
+
},
|
94
|
+
};
|
95
|
+
export const className = {
|
96
|
+
name: "className, attributes",
|
97
|
+
render: () => (<div data-testid="root">
|
98
|
+
<Pagination className="test-classname" attributes={{ id: "test-id" }} total={10} previousAriaLabel="Previous" nextAriaLabel="Next"/>
|
99
|
+
</div>),
|
100
|
+
play: async ({ canvas }) => {
|
101
|
+
const root = canvas.getByTestId("root").firstChild;
|
102
|
+
expect(root).toHaveClass("test-classname");
|
103
|
+
expect(root).toHaveAttribute("id", "test-id");
|
104
|
+
},
|
27
105
|
};
|
@@ -1 +1 @@
|
|
1
|
-
.root{display:inline-flex}.input,.root{vertical-align:top}.input{background:transparent;border:transparent;caret-color:transparent;color:transparent;font-size:16px;inset:0;outline:none;padding-left:100%;position:absolute}.item{box-sizing:border-box;cursor:text}.item--focused{border-color:var(--rs-color-border-primary);box-shadow:0 0 0 1px var(--rs-color-border-primary)}.item--focused:empty:before{animation:rs-pin-field-caret 1s ease-out infinite;background:var(--rs-color-foreground-neutral);border-radius:var(--rs-radius-circular);content:"";height:var(--rs-font-size-body-2);left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:1px}@media (hover:hover){.root:hover .input{pointer-events:none}}@keyframes rs-pin-field-caret{0%,49.9%,to{opacity:1}50%,99.9%{opacity:0}}
|
1
|
+
.root{display:inline-flex}.input,.root{vertical-align:top}.input{background:transparent;border:transparent;caret-color:transparent;clip-path:inset(0 calc(50% + var(--rs-unit-x2)) 0 0);color:transparent;font-size:16px;inset-block:0;inset-inline-start:0;outline:none;padding-left:100%;position:absolute}.item{box-sizing:border-box;cursor:text}.item--focused{border-color:var(--rs-color-border-primary);box-shadow:0 0 0 1px var(--rs-color-border-primary)}.item--focused:empty:before{animation:rs-pin-field-caret 1s ease-out infinite;background:var(--rs-color-foreground-neutral);border-radius:var(--rs-radius-circular);content:"";height:var(--rs-font-size-body-2);left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:1px}@media (hover:hover){.root:hover .input{pointer-events:none}}@keyframes rs-pin-field-caret{0%,49.9%,to{opacity:1}50%,99.9%{opacity:0}}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react-vite";
|
2
|
+
import { fn } from "storybook/test";
|
1
3
|
declare const _default: {
|
2
4
|
title: string;
|
3
5
|
component: import("react").FC<import("./..").PinFieldProps>;
|
@@ -8,6 +10,25 @@ declare const _default: {
|
|
8
10
|
};
|
9
11
|
};
|
10
12
|
export default _default;
|
11
|
-
export declare const base:
|
12
|
-
export declare const variant:
|
13
|
-
|
13
|
+
export declare const base: StoryObj;
|
14
|
+
export declare const variant: {
|
15
|
+
name: string;
|
16
|
+
render: () => import("react").JSX.Element;
|
17
|
+
};
|
18
|
+
export declare const size: {
|
19
|
+
name: string;
|
20
|
+
render: () => import("react").JSX.Element;
|
21
|
+
};
|
22
|
+
export declare const valueLength: StoryObj;
|
23
|
+
export declare const defaultValue: StoryObj<{
|
24
|
+
handleChange?: ReturnType<typeof fn>;
|
25
|
+
}>;
|
26
|
+
export declare const value: StoryObj<{
|
27
|
+
handleChange?: ReturnType<typeof fn>;
|
28
|
+
}>;
|
29
|
+
export declare const pattern: StoryObj<{
|
30
|
+
handleChange?: ReturnType<typeof fn>;
|
31
|
+
}>;
|
32
|
+
export declare const className: StoryObj;
|
33
|
+
export declare const formControl: StoryObj;
|
34
|
+
export declare const keyboard: StoryObj;
|
@@ -1,5 +1,7 @@
|
|
1
|
+
import { expect, fn, userEvent, waitFor } from "storybook/test";
|
1
2
|
import { Example } from "../../../utilities/storybook/index.js";
|
2
3
|
import PinField from "../index.js";
|
4
|
+
import FormControl from "../../FormControl/index.js";
|
3
5
|
export default {
|
4
6
|
title: "Components/PinField",
|
5
7
|
component: PinField,
|
@@ -9,54 +11,199 @@ export default {
|
|
9
11
|
},
|
10
12
|
},
|
11
13
|
};
|
12
|
-
export const base =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
<
|
35
|
-
|
36
|
-
|
37
|
-
export const variant = () => (<Example>
|
38
|
-
<Example.Item title="variant: faded">
|
39
|
-
<PinField name="pin" variant="faded" inputAttributes={{ "aria-label": "Pin" }}/>
|
40
|
-
</Example.Item>
|
41
|
-
</Example>);
|
42
|
-
export const size = () => (<Example>
|
43
|
-
<Example.Item title="size: small">
|
44
|
-
<PinField name="pin" size="small" inputAttributes={{ "aria-label": "Pin" }}/>
|
45
|
-
</Example.Item>
|
14
|
+
export const base = {
|
15
|
+
name: "base",
|
16
|
+
render: () => <PinField name="test-name" inputAttributes={{ "aria-label": "Label" }}/>,
|
17
|
+
play: async ({ canvas }) => {
|
18
|
+
const elInput = canvas.getByRole("textbox");
|
19
|
+
expect(elInput).toBeInTheDocument();
|
20
|
+
expect(elInput).toHaveAttribute("name", "test-name");
|
21
|
+
expect(elInput).toHaveAttribute("autocomplete", "one-time-code");
|
22
|
+
expect(elInput).toHaveAttribute("inputmode", "numeric");
|
23
|
+
},
|
24
|
+
};
|
25
|
+
export const variant = {
|
26
|
+
name: "variant",
|
27
|
+
render: () => (<Example>
|
28
|
+
<Example.Item title="variant: faded">
|
29
|
+
<PinField name="pin" variant="faded" inputAttributes={{ "aria-label": "Pin" }}/>
|
30
|
+
</Example.Item>
|
31
|
+
</Example>),
|
32
|
+
};
|
33
|
+
export const size = {
|
34
|
+
name: "size",
|
35
|
+
render: () => (<Example>
|
36
|
+
<Example.Item title="size: small">
|
37
|
+
<PinField name="pin" size="small" inputAttributes={{ "aria-label": "Pin" }}/>
|
38
|
+
</Example.Item>
|
46
39
|
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
<Example.Item title="size: medium">
|
41
|
+
<PinField name="pin" size="medium" inputAttributes={{ "aria-label": "Pin" }}/>
|
42
|
+
</Example.Item>
|
50
43
|
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
<Example.Item title="size: large">
|
45
|
+
<PinField name="pin" size="large" inputAttributes={{ "aria-label": "Pin" }}/>
|
46
|
+
</Example.Item>
|
54
47
|
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
<Example.Item title="size: xlarge">
|
49
|
+
<PinField name="pin" size="xlarge" inputAttributes={{ "aria-label": "Pin" }}/>
|
50
|
+
</Example.Item>
|
58
51
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
52
|
+
<Example.Item title="size: responsive, s: medium, m+: xlarge">
|
53
|
+
<PinField name="pin" size={{ s: "medium", m: "xlarge" }} inputAttributes={{ "aria-label": "Pin" }}/>
|
54
|
+
</Example.Item>
|
55
|
+
</Example>),
|
56
|
+
};
|
57
|
+
export const valueLength = {
|
58
|
+
name: "valueLength",
|
59
|
+
render: () => (<PinField name="test-name" valueLength={6} inputAttributes={{ "aria-label": "Label" }}/>),
|
60
|
+
play: async ({ canvas }) => {
|
61
|
+
const elInput = canvas.getByRole("textbox");
|
62
|
+
expect(elInput).toHaveAttribute("maxlength", "6");
|
63
|
+
},
|
64
|
+
};
|
65
|
+
export const defaultValue = {
|
66
|
+
name: "defaultValue, uncontrolled",
|
67
|
+
args: {
|
68
|
+
handleChange: fn(),
|
69
|
+
},
|
70
|
+
render: (args) => (<PinField name="test-name" onChange={args.handleChange} defaultValue="12" inputAttributes={{ "aria-label": "Label" }}/>),
|
71
|
+
play: async ({ canvas, args }) => {
|
72
|
+
const elInput = canvas.getByRole("textbox");
|
73
|
+
elInput.focus();
|
74
|
+
await userEvent.keyboard("3");
|
75
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
76
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
77
|
+
value: "123",
|
78
|
+
name: "test-name",
|
79
|
+
event: expect.objectContaining({ target: elInput }),
|
80
|
+
});
|
81
|
+
expect(elInput).toHaveValue("123");
|
82
|
+
},
|
83
|
+
};
|
84
|
+
export const value = {
|
85
|
+
name: "value, controlled",
|
86
|
+
args: {
|
87
|
+
handleChange: fn(),
|
88
|
+
},
|
89
|
+
render: (args) => (<PinField name="test-name" onChange={args.handleChange} value="12" inputAttributes={{ "aria-label": "Label" }}/>),
|
90
|
+
play: async ({ canvas, args }) => {
|
91
|
+
const elInput = canvas.getByRole("textbox");
|
92
|
+
elInput.focus();
|
93
|
+
await userEvent.keyboard("3");
|
94
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
95
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
96
|
+
value: "123",
|
97
|
+
name: "test-name",
|
98
|
+
event: expect.objectContaining({ target: elInput }),
|
99
|
+
});
|
100
|
+
expect(elInput).toHaveValue("12");
|
101
|
+
},
|
102
|
+
};
|
103
|
+
export const pattern = {
|
104
|
+
name: "pattern",
|
105
|
+
args: {
|
106
|
+
handleChange: fn(),
|
107
|
+
},
|
108
|
+
render: (args) => (<PinField name="test-name" pattern="alphabetic" defaultValue="ab" onChange={args.handleChange} inputAttributes={{ "aria-label": "Label" }}/>),
|
109
|
+
play: async ({ canvas, args }) => {
|
110
|
+
const elInput = canvas.getByRole("textbox");
|
111
|
+
elInput.focus();
|
112
|
+
await userEvent.keyboard("3");
|
113
|
+
expect(elInput).toHaveValue("ab");
|
114
|
+
expect(args.handleChange).toHaveBeenCalledTimes(0);
|
115
|
+
await userEvent.keyboard("c");
|
116
|
+
expect(elInput).toHaveValue("abc");
|
117
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
118
|
+
},
|
119
|
+
};
|
120
|
+
export const className = {
|
121
|
+
name: "className, attributes",
|
122
|
+
render: () => (<div data-testid="root">
|
123
|
+
<PinField name="test-name" className="test-classname" attributes={{ id: "test-id" }} inputAttributes={{ "aria-label": "Label", id: "test-input-id" }}/>
|
124
|
+
</div>),
|
125
|
+
play: async ({ canvas }) => {
|
126
|
+
const root = canvas.getByTestId("root").firstChild;
|
127
|
+
const input = canvas.queryByLabelText("Label");
|
128
|
+
expect(root).toHaveClass("test-classname");
|
129
|
+
expect(root).toHaveAttribute("id", "test-id");
|
130
|
+
expect(input).toHaveAttribute("id", "test-input-id");
|
131
|
+
},
|
132
|
+
};
|
133
|
+
export const formControl = {
|
134
|
+
name: "test: with FormControl",
|
135
|
+
render: () => (<FormControl>
|
136
|
+
<FormControl.Label>Label</FormControl.Label>
|
137
|
+
<PinField name="test-name"/>
|
138
|
+
</FormControl>),
|
139
|
+
play: async ({ canvas }) => {
|
140
|
+
const elInput = canvas.getByRole("textbox");
|
141
|
+
expect(elInput).toHaveAccessibleName("Label");
|
142
|
+
},
|
143
|
+
};
|
144
|
+
export const keyboard = {
|
145
|
+
name: "test: keyboard navigation",
|
146
|
+
render: () => <PinField name="test-name" inputAttributes={{ "aria-label": "Label" }}/>,
|
147
|
+
play: async ({ canvas }) => {
|
148
|
+
const elInput = canvas.getByRole("textbox");
|
149
|
+
elInput.focus();
|
150
|
+
expect(elInput.selectionStart).toEqual(0);
|
151
|
+
expect(elInput.selectionEnd).toEqual(0);
|
152
|
+
await userEvent.keyboard("1");
|
153
|
+
await waitFor(() => {
|
154
|
+
expect(elInput.selectionStart).toEqual(1);
|
155
|
+
expect(elInput.selectionEnd).toEqual(1);
|
156
|
+
});
|
157
|
+
await userEvent.keyboard("234");
|
158
|
+
await waitFor(() => {
|
159
|
+
expect(elInput.selectionStart).toEqual(3);
|
160
|
+
expect(elInput.selectionEnd).toEqual(4);
|
161
|
+
});
|
162
|
+
// Move back to the first character
|
163
|
+
await userEvent.keyboard("{ArrowLeft/}");
|
164
|
+
await waitFor(() => {
|
165
|
+
expect(elInput.selectionStart).toEqual(2);
|
166
|
+
expect(elInput.selectionEnd).toEqual(3);
|
167
|
+
});
|
168
|
+
await userEvent.keyboard("{ArrowLeft/}");
|
169
|
+
await waitFor(() => {
|
170
|
+
expect(elInput.selectionStart).toEqual(1);
|
171
|
+
expect(elInput.selectionEnd).toEqual(2);
|
172
|
+
});
|
173
|
+
await userEvent.keyboard("{ArrowLeft}");
|
174
|
+
await waitFor(() => {
|
175
|
+
expect(elInput.selectionStart).toEqual(0);
|
176
|
+
expect(elInput.selectionEnd).toEqual(1);
|
177
|
+
});
|
178
|
+
// Move to the third character
|
179
|
+
await userEvent.keyboard("{ArrowRight}");
|
180
|
+
await waitFor(() => {
|
181
|
+
expect(elInput.selectionStart).toEqual(1);
|
182
|
+
expect(elInput.selectionEnd).toEqual(2);
|
183
|
+
});
|
184
|
+
await userEvent.keyboard("{ArrowRight}");
|
185
|
+
await waitFor(() => {
|
186
|
+
expect(elInput.selectionStart).toEqual(2);
|
187
|
+
expect(elInput.selectionEnd).toEqual(3);
|
188
|
+
});
|
189
|
+
expect(elInput).toHaveValue("1234");
|
190
|
+
await userEvent.keyboard("{backspace}");
|
191
|
+
expect(elInput).toHaveValue("124");
|
192
|
+
await waitFor(() => {
|
193
|
+
expect(elInput.selectionStart).toEqual(2);
|
194
|
+
expect(elInput.selectionEnd).toEqual(3);
|
195
|
+
});
|
196
|
+
// Switched to type mode
|
197
|
+
await userEvent.keyboard("{ArrowRight}");
|
198
|
+
await waitFor(() => {
|
199
|
+
expect(elInput.selectionStart).toEqual(3);
|
200
|
+
expect(elInput.selectionStart).toEqual(3);
|
201
|
+
});
|
202
|
+
// Can't move further
|
203
|
+
await userEvent.keyboard("{ArrowRight}");
|
204
|
+
await waitFor(() => {
|
205
|
+
expect(elInput.selectionStart).toEqual(3);
|
206
|
+
expect(elInput.selectionStart).toEqual(3);
|
207
|
+
});
|
208
|
+
},
|
209
|
+
};
|
@@ -5,11 +5,11 @@ import Dismissible from "../Dismissible/index.js";
|
|
5
5
|
import s from "./Popover.module.css";
|
6
6
|
import { resolveMixin } from "../../styles/mixin.js";
|
7
7
|
const Popover = (props) => {
|
8
|
-
const { width, variant = "elevated", triggerType = "click", position = "bottom", elevation, ...flyoutProps } = props;
|
8
|
+
const { width, variant = "elevated", triggerType = "click", position = "bottom", elevation, borderRadius, ...flyoutProps } = props;
|
9
9
|
const padding = props.padding ?? (variant === "headless" ? 0 : 4);
|
10
10
|
const trapFocusMode = props.trapFocusMode ?? (triggerType === "hover" ? "content-menu" : undefined);
|
11
11
|
const mixinStyles = resolveMixin({ padding });
|
12
|
-
const contentClassName = classNames(s.content, !!width && s["content--has-width"], variant && s[`content--variant-${variant}`], elevation && s[`content--elevation-${elevation}`], mixinStyles.classNames);
|
12
|
+
const contentClassName = classNames(s.content, !!width && s["content--has-width"], variant && s[`content--variant-${variant}`], elevation && s[`content--elevation-${elevation}`], borderRadius && s[`content--radius-${borderRadius}`], mixinStyles.classNames);
|
13
13
|
return (_jsx(Flyout, { ...flyoutProps, position: position, trapFocusMode: trapFocusMode, triggerType: triggerType, width: width, contentClassName: contentClassName, contentAttributes: { style: { ...mixinStyles.variables } } }));
|
14
14
|
};
|
15
15
|
const PopoverDismissible = (props) => {
|
@@ -1 +1 @@
|
|
1
|
-
.content{max-width:360px}.content--variant-elevated{background:var(--rs-color-background-elevation-overlay);border-radius:var(--rs-radius-medium);box-shadow:var(--rs-
|
1
|
+
.content{max-width:360px}.content--variant-elevated{background:var(--rs-color-background-elevation-overlay);border-radius:var(--rs-radius-medium);box-shadow:0 0 0 1px var(--rs-color-border-neutral-faded) inset,var(--rs-shadow-overlay);color:var(--rs-color-foreground-neutral);min-width:220px}.content--variant-elevated.content--elevation-raised{box-shadow:0 0 0 1px var(--rs-color-border-neutral-faded) inset,var(--rs-shadow-raised)}.content--radius-small{border-radius:var(--rs-radius-small)}.content.content--has-width{max-width:none;min-width:0}@media (--rs-viewport-s ){.content{max-width:none}}
|
@@ -1,13 +1,15 @@
|
|
1
1
|
import type React from "react";
|
2
2
|
import type { FlyoutProps, FlyoutInstance } from "../Flyout";
|
3
3
|
export type Instance = FlyoutInstance;
|
4
|
-
export type Props = Pick<FlyoutProps, "id" | "position" | "forcePosition" | "fallbackPositions" | "onOpen" | "onClose" | "width" | "trapFocusMode" | "active" | "defaultActive" | "contentGap" | "contentShift" | "instanceRef" | "triggerType" | "disableHideAnimation" | "disableContentHover" | "disableCloseOnOutsideClick" | "autoFocus" | "containerRef" | "initialFocusRef" | "originCoordinates"> & {
|
4
|
+
export type Props = Pick<FlyoutProps, "id" | "position" | "forcePosition" | "fallbackPositions" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight" | "onOpen" | "onClose" | "width" | "trapFocusMode" | "active" | "defaultActive" | "contentGap" | "contentShift" | "instanceRef" | "triggerType" | "disableHideAnimation" | "disableContentHover" | "disableCloseOnOutsideClick" | "autoFocus" | "containerRef" | "initialFocusRef" | "originCoordinates"> & {
|
5
5
|
/** Node for inserting children */
|
6
6
|
children?: React.ReactNode;
|
7
7
|
/** Content element padding, unit token multiplier */
|
8
8
|
padding?: number;
|
9
9
|
/** Component elevation level */
|
10
10
|
elevation?: "raised" | "overlay";
|
11
|
+
/** Border radius for the content */
|
12
|
+
borderRadius?: "small" | "medium";
|
11
13
|
/** @deprecated use Flyout utility instead, will be removed in v4 */
|
12
14
|
variant?: "elevated" | "headless";
|
13
15
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
+
import { StoryObj } from "@storybook/react-vite";
|
2
3
|
declare const _default: {
|
3
4
|
title: string;
|
4
5
|
component: React.FC<import("./..").ProgressProps>;
|
@@ -9,7 +10,21 @@ declare const _default: {
|
|
9
10
|
};
|
10
11
|
};
|
11
12
|
export default _default;
|
12
|
-
export declare const value:
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
export declare const value: {
|
14
|
+
name: string;
|
15
|
+
render: () => React.JSX.Element;
|
16
|
+
};
|
17
|
+
export declare const size: {
|
18
|
+
name: string;
|
19
|
+
render: () => React.JSX.Element;
|
20
|
+
};
|
21
|
+
export declare const color: {
|
22
|
+
name: string;
|
23
|
+
render: () => React.JSX.Element;
|
24
|
+
};
|
25
|
+
export declare const duration: {
|
26
|
+
name: string;
|
27
|
+
render: () => React.JSX.Element;
|
28
|
+
};
|
29
|
+
export declare const render: StoryObj;
|
30
|
+
export declare const className: StoryObj;
|