reshaped 3.3.10 → 3.3.12
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 +9 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +10 -10
- package/dist/cjs/themes/_generator/utilities/generateColors.d.ts +1 -1
- package/dist/cjs/themes/_generator/utilities/generateColors.js +3 -2
- package/dist/cjs/themes/_generator/utilities/tests/color.test.js +32 -31
- package/dist/cjs/themes/slate/theme.css +1 -1
- package/dist/components/Accordion/tests/Accordion.stories.d.ts +30 -8
- package/dist/components/Accordion/tests/Accordion.stories.js +172 -119
- package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +12 -3
- package/dist/components/ActionBar/tests/ActionBar.stories.js +51 -36
- package/dist/components/ActionBar/tests/ActionBar.test.stories.d.ts +15 -0
- package/dist/components/ActionBar/tests/ActionBar.test.stories.js +26 -0
- package/dist/components/Actionable/Actionable.js +1 -1
- package/dist/components/Actionable/Actionable.types.d.ts +3 -3
- package/dist/components/Actionable/tests/Actionable.stories.d.ts +19 -5
- package/dist/components/Actionable/tests/Actionable.stories.js +88 -63
- package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +32 -0
- package/dist/components/Actionable/tests/Actionable.test.stories.js +130 -0
- package/dist/components/Alert/Alert.js +1 -1
- package/dist/components/Alert/tests/Alert.stories.d.ts +12 -3
- package/dist/components/Alert/tests/Alert.stories.js +51 -86
- package/dist/components/Alert/tests/Alert.test.stories.d.ts +15 -0
- package/dist/components/Alert/tests/Alert.test.stories.js +26 -0
- package/dist/components/Autocomplete/Autocomplete.js +9 -2
- package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +6 -2
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +94 -111
- package/dist/components/Autocomplete/tests/Autocomplete.test.stories.d.ts +23 -0
- package/dist/components/Autocomplete/tests/Autocomplete.test.stories.js +86 -0
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Avatar/tests/Avatar.stories.d.ts +14 -4
- package/dist/components/Avatar/tests/Avatar.stories.js +94 -80
- package/dist/components/Avatar/tests/Avatar.test.stories.d.ts +17 -0
- package/dist/components/Avatar/tests/Avatar.test.stories.js +39 -0
- package/dist/components/Badge/tests/Badge.stories.d.ts +33 -8
- package/dist/components/Badge/tests/Badge.stories.js +238 -212
- package/dist/components/Badge/tests/Badge.test.stories.d.ts +20 -0
- package/dist/components/Badge/tests/Badge.test.stories.js +44 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +1 -0
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +24 -5
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +114 -95
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +23 -0
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +76 -0
- package/dist/components/Button/Button.js +5 -2
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Button/Button.types.d.ts +1 -0
- package/dist/components/Button/tests/Button.stories.d.ts +2 -2
- package/dist/components/Button/tests/Button.stories.js +77 -74
- package/dist/components/Button/tests/Button.test.stories.d.ts +27 -0
- package/dist/components/Button/tests/Button.test.stories.js +112 -0
- package/dist/components/Calendar/tests/Calendar.test.stories.d.ts +26 -0
- package/dist/components/Calendar/tests/Calendar.test.stories.js +161 -0
- package/dist/components/Card/Card.d.ts +3 -3
- package/dist/components/Card/Card.types.d.ts +1 -1
- package/dist/components/Card/tests/Card.stories.d.ts +3 -4
- package/dist/components/Card/tests/Card.stories.js +0 -11
- package/dist/components/Card/tests/Card.test.stories.d.ts +35 -0
- package/dist/components/Card/tests/Card.test.stories.js +54 -0
- package/dist/components/Carousel/Carousel.types.d.ts +1 -1
- package/dist/components/Carousel/CarouselControl.js +1 -1
- package/dist/components/Carousel/tests/Carousel.stories.d.ts +3 -0
- package/dist/components/Carousel/tests/Carousel.stories.js +5 -1
- package/dist/components/Carousel/tests/Carousel.test.stories.d.ts +17 -0
- package/dist/components/Carousel/tests/Carousel.test.stories.js +52 -0
- package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +25 -0
- package/dist/components/Checkbox/tests/Checkbox.test.stories.js +104 -0
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +22 -0
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +78 -0
- package/dist/components/Container/Container.module.css +1 -1
- package/dist/components/Container/tests/Container.stories.d.ts +12 -3
- package/dist/components/Container/tests/Container.stories.js +50 -31
- package/dist/components/Container/tests/Container.test.stories.d.ts +15 -0
- package/dist/components/Container/tests/Container.test.stories.js +26 -0
- package/dist/components/ContextMenu/ContextMenu.js +13 -9
- package/dist/components/ContextMenu/tests/ContextMenu.stories.js +2 -3
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +26 -0
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +53 -0
- package/dist/components/Dismissible/Dismissible.js +1 -1
- package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +10 -3
- package/dist/components/Dismissible/tests/Dismissible.stories.js +51 -34
- package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +19 -0
- package/dist/components/Dismissible/tests/Dismissible.test.stories.js +42 -0
- package/dist/components/Divider/tests/Divider.test.stories.d.ts +18 -0
- package/dist/components/Divider/tests/Divider.test.stories.js +47 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +37 -0
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +117 -0
- package/dist/components/FileUpload/tests/FileUpload.test.stories.d.ts +22 -0
- package/dist/components/FileUpload/tests/FileUpload.test.stories.js +52 -0
- package/dist/components/FormControl/FormControl.context.d.ts +12 -0
- package/dist/components/FormControl/FormControlCaption.js +1 -1
- package/dist/components/FormControl/FormControlLabel.js +1 -1
- package/dist/components/FormControl/tests/FormControl.stories.d.ts +11 -5
- package/dist/components/FormControl/tests/FormControl.stories.js +78 -73
- package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +20 -0
- package/dist/components/FormControl/tests/FormControl.test.stories.js +49 -0
- package/dist/components/Grid/Grid.d.ts +2 -2
- package/dist/components/Grid/Grid.types.d.ts +3 -2
- package/dist/components/Grid/tests/Grid.stories.d.ts +22 -7
- package/dist/components/Grid/tests/Grid.stories.js +164 -149
- package/dist/components/Grid/tests/Grid.test.stories.d.ts +19 -0
- package/dist/components/Grid/tests/Grid.test.stories.js +42 -0
- package/dist/components/Hidden/Hidden.types.d.ts +1 -1
- package/dist/components/Hidden/tests/Hidden.stories.d.ts +4 -1
- package/dist/components/Hidden/tests/Hidden.stories.js +28 -25
- package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +15 -0
- package/dist/components/Hidden/tests/Hidden.test.stories.js +20 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +4 -1
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +8 -5
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +15 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +20 -0
- package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +15 -0
- package/dist/components/Hotkey/tests/Hotkey.test.stories.js +26 -0
- package/dist/components/Icon/tests/Icon.stories.d.ts +12 -3
- package/dist/components/Icon/tests/Icon.stories.js +69 -60
- package/dist/components/Icon/tests/Icon.test.stories.d.ts +16 -0
- package/dist/components/Icon/tests/Icon.test.stories.js +35 -0
- package/dist/components/Image/tests/Image.stories.d.ts +24 -5
- package/dist/components/Image/tests/Image.stories.js +95 -75
- package/dist/components/Image/tests/Image.test.stories.d.ts +25 -0
- package/dist/components/Image/tests/Image.test.stories.js +80 -0
- package/dist/components/Link/tests/Link.test.stories.d.ts +29 -0
- package/dist/components/Link/tests/Link.test.stories.js +87 -0
- package/dist/components/Loader/Loader.js +1 -1
- package/dist/components/Loader/Loader.types.d.ts +1 -0
- package/dist/components/Loader/tests/Loader.stories.js +8 -8
- package/dist/components/Loader/tests/Loader.test.stories.d.ts +16 -0
- package/dist/components/Loader/tests/Loader.test.stories.js +32 -0
- package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +26 -0
- package/dist/components/MenuItem/tests/MenuItem.test.stories.js +100 -0
- package/dist/components/Modal/Modal.types.d.ts +1 -1
- package/dist/components/Modal/tests/Modal.test.stories.d.ts +32 -0
- package/dist/components/Modal/tests/Modal.test.stories.js +149 -0
- package/dist/components/Overlay/Overlay.types.d.ts +1 -1
- package/dist/components/Overlay/tests/Overlay.stories.d.ts +4 -2
- package/dist/components/Overlay/tests/Overlay.stories.js +53 -53
- package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +28 -0
- package/dist/components/Overlay/tests/Overlay.test.stories.js +146 -0
- package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +23 -0
- package/dist/components/Pagination/tests/Pagination.test.stories.js +86 -0
- package/dist/components/PinField/tests/PinField.stories.d.ts +0 -1
- package/dist/components/PinField/tests/PinField.stories.js +10 -19
- package/dist/components/PinField/tests/PinField.test.stories.d.ts +29 -0
- package/dist/components/PinField/tests/PinField.test.stories.js +177 -0
- package/dist/components/Popover/tests/Popover.test.stories.d.ts +40 -0
- package/dist/components/Popover/tests/Popover.test.stories.js +167 -0
- package/dist/components/Progress/Progress.js +2 -2
- package/dist/components/Progress/Progress.types.d.ts +1 -0
- package/dist/components/Progress/tests/Progress.stories.js +10 -10
- package/dist/components/Progress/tests/Progress.test.stories.d.ts +16 -0
- package/dist/components/Progress/tests/Progress.test.stories.js +35 -0
- package/dist/components/Radio/tests/Radio.test.stories.d.ts +30 -0
- package/dist/components/Radio/tests/Radio.test.stories.js +118 -0
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +22 -0
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +78 -0
- package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +33 -0
- package/dist/components/Reshaped/tests/Reshaped.stories.js +88 -0
- package/dist/components/Resizable/Resizable.js +4 -1
- package/dist/components/Resizable/Resizable.types.d.ts +2 -2
- package/dist/components/Resizable/tests/Resizable.stories.d.ts +3 -0
- package/dist/components/Resizable/tests/Resizable.stories.js +4 -0
- package/dist/components/Resizable/tests/Resizable.test.stories.d.ts +19 -0
- package/dist/components/Resizable/tests/Resizable.test.stories.js +25 -0
- package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +15 -0
- package/dist/components/Scrim/tests/Scrim.test.stories.js +25 -0
- package/dist/components/ScrollArea/ScrollArea.js +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +17 -4
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +114 -139
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +23 -0
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +66 -0
- package/dist/components/Select/tests/Select.stories.d.ts +1 -1
- package/dist/components/Select/tests/Select.stories.js +5 -12
- package/dist/components/Select/tests/Select.test.stories.d.ts +27 -0
- package/dist/components/Select/tests/Select.test.stories.js +132 -0
- package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +15 -0
- package/dist/components/Skeleton/tests/Skeleton.test.stories.js +23 -0
- package/dist/components/Slider/Slider.types.d.ts +1 -1
- package/dist/components/Slider/tests/Slider.stories.d.ts +0 -1
- package/dist/components/Slider/tests/Slider.stories.js +8 -9
- package/dist/components/Slider/tests/Slider.test.stories.d.ts +38 -0
- package/dist/components/Slider/tests/Slider.test.stories.js +150 -0
- package/dist/components/Stepper/Stepper.js +1 -1
- package/dist/components/Stepper/tests/Stepper.stories.js +0 -3
- package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +18 -0
- package/dist/components/Stepper/tests/Stepper.test.stories.js +28 -0
- package/dist/components/Switch/tests/Switch.test.stories.d.ts +23 -0
- package/dist/components/Switch/tests/Switch.test.stories.js +79 -0
- package/dist/components/Table/tests/Table.test.stories.d.ts +25 -0
- package/dist/components/Table/tests/Table.test.stories.js +93 -0
- package/dist/components/Tabs/Tabs.types.d.ts +3 -3
- package/dist/components/Tabs/TabsContext.d.ts +3 -3
- package/dist/components/Tabs/TabsItem.js +1 -1
- package/dist/components/Tabs/tests/Tabs.stories.js +4 -4
- package/dist/components/Tabs/tests/Tabs.test.stories.d.ts +28 -0
- package/dist/components/Tabs/tests/Tabs.test.stories.js +128 -0
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/Text/Text.types.d.ts +1 -1
- package/dist/components/Text/tests/Text.stories.d.ts +29 -8
- package/dist/components/Text/tests/Text.stories.js +148 -125
- package/dist/components/Text/tests/Text.test.stories.d.ts +18 -0
- package/dist/components/Text/tests/Text.test.stories.js +49 -0
- package/dist/components/TextArea/TextArea.module.css +1 -1
- package/dist/components/TextArea/tests/TextArea.stories.js +1 -1
- package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +29 -0
- package/dist/components/TextArea/tests/TextArea.test.stories.js +99 -0
- package/dist/components/TextField/TextField.js +3 -1
- package/dist/components/TextField/tests/TextField.stories.js +1 -1
- package/dist/components/TextField/tests/TextField.test.stories.d.ts +29 -0
- package/dist/components/TextField/tests/TextField.test.stories.js +99 -0
- package/dist/components/Theme/Theme.types.d.ts +2 -2
- package/dist/components/Theme/tests/Theme.test.stories.d.ts +24 -0
- package/dist/components/Theme/tests/Theme.test.stories.js +133 -0
- package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +18 -0
- package/dist/components/Timeline/tests/Timeline.test.stories.js +32 -0
- package/dist/components/Toast/ToastContainer.js +1 -1
- package/dist/components/Toast/tests/Toast.test.stories.d.ts +16 -0
- package/dist/components/Toast/tests/Toast.test.stories.js +101 -0
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +1 -1
- package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -14
- package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +19 -0
- package/dist/components/Tooltip/tests/Tooltip.test.stories.js +40 -0
- package/dist/components/View/View.d.ts +2 -2
- package/dist/components/View/View.js +4 -4
- package/dist/components/View/View.types.d.ts +2 -2
- package/dist/components/View/tests/View.stories.d.ts +114 -30
- package/dist/components/View/tests/View.stories.js +1092 -1012
- package/dist/components/View/tests/View.test.stories.d.ts +20 -0
- package/dist/components/View/tests/View.test.stories.js +50 -0
- package/dist/components/_private/Flyout/Flyout.types.d.ts +6 -6
- package/dist/components/_private/Flyout/FlyoutContent.js +1 -1
- package/dist/components/_private/Flyout/FlyoutControlled.js +5 -3
- package/dist/components/_private/Flyout/tests/Flyout.stories.js +5 -5
- package/dist/components/_private/Flyout/tests/Flyout.test.stories.d.ts +28 -0
- package/dist/components/_private/Flyout/tests/Flyout.test.stories.js +205 -0
- package/dist/components/_private/Flyout/useFlyout.d.ts +3 -3
- package/dist/components/_private/Portal/Portal.types.d.ts +3 -3
- package/dist/components/_private/Portal/tests/Portal.stories.js +1 -1
- package/dist/hooks/_private/useIsDismissible.d.ts +1 -1
- package/dist/hooks/_private/useOnClickOutside.d.ts +1 -1
- package/dist/hooks/_private/useSingletonHotkeys.d.ts +3 -3
- package/dist/hooks/_private/useSingletonHotkeys.js +1 -1
- package/dist/hooks/tests/useDrag.stories.js +1 -0
- package/dist/hooks/tests/useDrag.test.stories.d.ts +26 -0
- package/dist/hooks/tests/useDrag.test.stories.js +120 -0
- package/dist/hooks/tests/useElementId.stories.d.ts +6 -0
- package/dist/hooks/tests/useElementId.stories.js +19 -0
- package/dist/hooks/tests/useHotkeys.test.stories.d.ts +39 -0
- package/dist/hooks/tests/useHotkeys.test.stories.js +119 -0
- package/dist/hooks/tests/useRTL.stories.d.ts +6 -0
- package/dist/hooks/tests/useRTL.stories.js +25 -0
- package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +9 -1
- package/dist/hooks/tests/useResponsiveClientValue.stories.js +22 -9
- package/dist/hooks/tests/useScrollLock.stories.d.ts +6 -0
- package/dist/hooks/tests/useScrollLock.stories.js +22 -0
- package/dist/hooks/tests/useToggle.stories.d.ts +8 -0
- package/dist/hooks/tests/useToggle.stories.js +54 -0
- package/dist/hooks/useDrag.d.ts +3 -3
- package/dist/hooks/useHotkeys.d.ts +2 -2
- package/dist/hooks/useHotkeys.js +3 -1
- package/dist/hooks/useScrollLock.d.ts +2 -1
- package/dist/hooks/useScrollLock.js +7 -3
- package/dist/tests/ShadowDOM.stories.js +1 -1
- package/dist/themes/_generator/tests/themes.stories.d.ts +3 -0
- package/dist/themes/_generator/tests/themes.stories.js +7 -11
- package/dist/themes/_generator/utilities/generateColors.d.ts +1 -1
- package/dist/themes/_generator/utilities/generateColors.js +3 -2
- package/dist/themes/slate/theme.css +1 -1
- package/dist/types/global.d.ts +1 -1
- package/dist/utilities/helpers.d.ts +1 -0
- package/dist/utilities/helpers.js +3 -0
- package/dist/utilities/scroll/lock.d.ts +1 -0
- package/dist/utilities/scroll/lock.js +3 -3
- package/dist/utilities/scroll/lockSafari.d.ts +1 -1
- package/dist/utilities/scroll/lockSafari.js +4 -5
- package/dist/utilities/scroll/lockStandard.d.ts +4 -1
- package/dist/utilities/scroll/lockStandard.js +7 -2
- package/dist/utilities/storybook/Example.js +1 -2
- package/package.json +22 -21
- package/dist/components/Theme/tests/Theme.stories.d.ts +0 -13
- package/dist/components/Theme/tests/Theme.stories.js +0 -80
- package/dist/utilities/storybook/Example.module.css +0 -1
@@ -19,6 +19,7 @@ const PrivateResizableHandle = (props) => {
|
|
19
19
|
return (_jsx(View.Item, { className: handleClassNames, attributes: {
|
20
20
|
role: "button",
|
21
21
|
tabIndex: 0,
|
22
|
+
"aria-hidden": true,
|
22
23
|
ref: (el) => {
|
23
24
|
// @ts-ignore
|
24
25
|
ref.current = el;
|
@@ -138,7 +139,9 @@ const Resizable = (props) => {
|
|
138
139
|
}
|
139
140
|
if (isComponent && child.type === Resizable.Item && child.props) {
|
140
141
|
const index = currentHandleIndex;
|
141
|
-
return (_jsx(PrivateResizableItem, { ...child.props, index: currentItemIndex++, ref: (el) =>
|
142
|
+
return (_jsx(PrivateResizableItem, { ...child.props, index: currentItemIndex++, ref: (el) => {
|
143
|
+
itemsRef.current[index] = { el, props: child.props };
|
144
|
+
} }));
|
142
145
|
}
|
143
146
|
return null;
|
144
147
|
});
|
@@ -15,11 +15,11 @@ export type PrivateItemProps = ItemProps & {
|
|
15
15
|
};
|
16
16
|
export type HandleProps = {
|
17
17
|
children?: (attributes: {
|
18
|
-
ref: React.RefObject<HTMLButtonElement>;
|
18
|
+
ref: React.RefObject<HTMLButtonElement | null>;
|
19
19
|
}) => React.ReactNode;
|
20
20
|
};
|
21
21
|
export type PrivateHandleProps = HandleProps & {
|
22
|
-
containerRef: React.RefObject<HTMLDivElement>;
|
22
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
23
23
|
index: number;
|
24
24
|
onDrag: (args: UseDragCallbackArgs & {
|
25
25
|
index: number;
|
@@ -9,6 +9,10 @@ export default {
|
|
9
9
|
iframe: {
|
10
10
|
url: "https://reshaped.so/docs/utilities/Resizable",
|
11
11
|
},
|
12
|
+
// Skip because of the aria-hidden applied to buttons, they're not needed for the screen reader navigation
|
13
|
+
a11y: {
|
14
|
+
disable: true,
|
15
|
+
},
|
12
16
|
},
|
13
17
|
};
|
14
18
|
export const base = () => (<Example>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
component: {
|
5
|
+
(props: import("./..").ResizableProps): import("react").JSX.Element;
|
6
|
+
Item: import("react").FC<import("./..").ResizableItemProps>;
|
7
|
+
Handle: import("react").FC<import("./..").ResizableHandleProps>;
|
8
|
+
};
|
9
|
+
parameters: {
|
10
|
+
iframe: {
|
11
|
+
url: string;
|
12
|
+
};
|
13
|
+
chromatic: {
|
14
|
+
disableSnapshot: boolean;
|
15
|
+
};
|
16
|
+
};
|
17
|
+
};
|
18
|
+
export default _default;
|
19
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { expect } from "@storybook/test";
|
2
|
+
import Resizable from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Resizable/tests",
|
5
|
+
component: Resizable,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/utilities/Resizable",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const className = {
|
14
|
+
name: "className, attributes",
|
15
|
+
render: () => (<div data-testid="root">
|
16
|
+
<Resizable className="test-classname" attributes={{ id: "test-id" }}>
|
17
|
+
<Resizable.Item>Content</Resizable.Item>
|
18
|
+
</Resizable>
|
19
|
+
</div>),
|
20
|
+
play: async ({ canvas }) => {
|
21
|
+
const root = canvas.getByTestId("root").firstChild;
|
22
|
+
expect(root).toHaveClass("test-classname");
|
23
|
+
expect(root).toHaveAttribute("id", "test-id");
|
24
|
+
},
|
25
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
component: (props: import("./..").ScrimProps) => import("react").JSX.Element;
|
5
|
+
parameters: {
|
6
|
+
iframe: {
|
7
|
+
url: string;
|
8
|
+
};
|
9
|
+
chromatic: {
|
10
|
+
disableSnapshot: boolean;
|
11
|
+
};
|
12
|
+
};
|
13
|
+
};
|
14
|
+
export default _default;
|
15
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { expect } from "@storybook/test";
|
2
|
+
import Scrim from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Scrim/tests",
|
5
|
+
component: Scrim,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/scrim",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const className = {
|
14
|
+
name: "className, attributes",
|
15
|
+
render: () => (<div data-testid="root">
|
16
|
+
<Scrim className="test-classname" attributes={{ id: "test-id" }}>
|
17
|
+
Content
|
18
|
+
</Scrim>
|
19
|
+
</div>),
|
20
|
+
play: async ({ canvas }) => {
|
21
|
+
const root = canvas.getByTestId("root").firstChild;
|
22
|
+
expect(root).toHaveClass("test-classname");
|
23
|
+
expect(root).toHaveAttribute("id", "test-id");
|
24
|
+
},
|
25
|
+
};
|
@@ -134,6 +134,6 @@ const ScrollArea = forwardRef((props, ref) => {
|
|
134
134
|
observer.observe(contentEl);
|
135
135
|
return () => observer.disconnect();
|
136
136
|
}, [updateScroll]);
|
137
|
-
return (_jsxs("div", { ...attributes, className: rootClassNames, style: rootVariables, children: [_jsx("div", { className: s.scrollable, ref: scrollableRef, onScroll: handleScroll, children: _jsx("div", { className: s.content, ref: contentRef, children: children }) }), scrollRatio.y < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { vertical: true, onThumbMove: handleThumbYMove, ratio: scrollRatio.y, position: scrollPosition.y })), scrollRatio.x < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { onThumbMove: handleThumbXMove, ratio: scrollRatio.x, position: scrollPosition.x }))] }));
|
137
|
+
return (_jsxs("div", { ...attributes, className: rootClassNames, style: rootVariables, children: [_jsx("div", { className: s.scrollable, ref: scrollableRef, onScroll: handleScroll, tabIndex: 0, children: _jsx("div", { className: s.content, ref: contentRef, children: children }) }), scrollRatio.y < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { vertical: true, onThumbMove: handleThumbYMove, ratio: scrollRatio.y, position: scrollPosition.y })), scrollRatio.x < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { onThumbMove: handleThumbXMove, ratio: scrollRatio.x, position: scrollPosition.x }))] }));
|
138
138
|
});
|
139
139
|
export default ScrollArea;
|
@@ -1 +1 @@
|
|
1
|
-
.root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);overflow:hidden}.root
|
1
|
+
.root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);height:100%;overflow:hidden;position:relative}[data-rs-keyboard] .root:has(.scrollable:focus){box-shadow:var(--rs-focus-shadow)}.scrollable{height:100%;overflow:auto;position:relative;scrollbar-width:none;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.content{display:inline-block;min-height:100%;min-width:100%;vertical-align:top}.scrollbar{box-sizing:initial;padding:var(--rs-scroll-area-thumb-offset);position:absolute}.thumb{height:100%;position:relative;width:100%}.thumb:before{background:var(--rs-color-foreground-neutral);border-radius:999px;content:"";display:block;opacity:0;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--scrollbar-y{inset-block:0;inset-inline-end:0;width:var(--rs-scroll-area-thumb-size)}.--scrollbar-y .thumb:before{height:calc(var(--rs-scroll-area-ratio) * 100%);inset-block-start:calc(var(--rs-scroll-area-position) * 100%);width:100%}.--scrollbar-x{height:var(--rs-scroll-area-thumb-size);inset-block-end:0;inset-inline:0}.--scrollbar-x .thumb:before{height:100%;inset-inline-start:calc(var(--rs-scroll-area-position) * 100%);width:calc(var(--rs-scroll-area-ratio) * 100%)}.--scrollbar-y:not(:last-child){inset-block-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--scrollbar-y~.--scrollbar-x{inset-inline-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--display-hover:hover>.scrollbar .thumb:before,.--display-visible .thumb:before{opacity:.2}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
+
import { StoryObj } from "@storybook/react";
|
2
3
|
declare const _default: {
|
3
4
|
title: string;
|
4
5
|
component: React.ForwardRefExoticComponent<import("./..").ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
|
@@ -6,10 +7,22 @@ declare const _default: {
|
|
6
7
|
iframe: {
|
7
8
|
url: string;
|
8
9
|
};
|
10
|
+
a11y: {
|
11
|
+
disable: boolean;
|
12
|
+
};
|
9
13
|
};
|
10
14
|
};
|
11
15
|
export default _default;
|
12
|
-
export declare const direction:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
export declare const direction: {
|
17
|
+
name: string;
|
18
|
+
render: () => React.JSX.Element;
|
19
|
+
};
|
20
|
+
export declare const visibility: {
|
21
|
+
name: string;
|
22
|
+
render: () => React.JSX.Element;
|
23
|
+
};
|
24
|
+
export declare const composition: {
|
25
|
+
name: string;
|
26
|
+
render: () => React.JSX.Element;
|
27
|
+
};
|
28
|
+
export declare const dynamicHeight: StoryObj;
|
@@ -1,10 +1,8 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import { useRef } from "react";
|
3
2
|
import { Example } from "../../../utilities/storybook/index.js";
|
4
3
|
import ScrollArea from "../index.js";
|
5
4
|
import View from "../../View/index.js";
|
6
5
|
import Button from "../../Button/index.js";
|
7
|
-
import useToggle from "../../../hooks/useToggle.js";
|
8
6
|
export default {
|
9
7
|
title: "Utilities/ScrollArea",
|
10
8
|
component: ScrollArea,
|
@@ -12,150 +10,105 @@ export default {
|
|
12
10
|
iframe: {
|
13
11
|
url: "https://reshaped.so/docs/utilities/scroll-area",
|
14
12
|
},
|
13
|
+
// Skip because axe core incorrectly reports contrast issues
|
14
|
+
a11y: {
|
15
|
+
disable: true,
|
16
|
+
},
|
15
17
|
},
|
16
18
|
};
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
<
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
</View>
|
33
|
-
</ScrollArea>
|
34
|
-
</View>);
|
35
|
-
};
|
36
|
-
export const direction = () => (<Example>
|
37
|
-
<Example.Item title="vertical">
|
38
|
-
<ScrollArea height="100px" scrollbarDisplay="visible" onScroll={console.log}>
|
39
|
-
<View backgroundColor="neutral-faded" padding={4}>
|
40
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
|
41
|
-
been the industry's standard dummy text ever since the 1500s, when an unknown printer took
|
42
|
-
a galley of type and scrambled it to make a type specimen book. It has survived not only
|
43
|
-
five centuries, but also the leap into electronic typesetting, remaining essentially
|
44
|
-
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
|
45
|
-
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
|
46
|
-
PageMaker including versions of Lorem Ipsum.
|
47
|
-
</View>
|
48
|
-
</ScrollArea>
|
49
|
-
</Example.Item>
|
50
|
-
<Example.Item title="horizontal">
|
51
|
-
<ScrollArea height="120px" scrollbarDisplay="visible" onScroll={console.log}>
|
52
|
-
<View backgroundColor="neutral-faded" padding={4} width="500px">
|
53
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
|
54
|
-
been the industry's standard dummy text ever since the 1500s
|
55
|
-
</View>
|
56
|
-
</ScrollArea>
|
57
|
-
</Example.Item>
|
58
|
-
<Example.Item title="both directions">
|
59
|
-
<ScrollArea height="100px" scrollbarDisplay="visible">
|
60
|
-
<View backgroundColor="neutral-faded" padding={4} width="500px">
|
61
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
|
62
|
-
been the industry's standard dummy text ever since the 1500s, when an unknown printer took
|
63
|
-
a galley of type and scrambled it to make a type specimen book. It has survived not only
|
64
|
-
five centuries, but also the leap into electronic typesetting, remaining essentially
|
65
|
-
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
|
66
|
-
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
|
67
|
-
PageMaker including versions of Lorem Ipsum.
|
68
|
-
</View>
|
69
|
-
</ScrollArea>
|
70
|
-
</Example.Item>
|
71
|
-
</Example>);
|
72
|
-
export const visibility = () => (<Example>
|
73
|
-
<Example.Item title="visibility: hover">
|
74
|
-
<ScrollArea height="100px">
|
75
|
-
<View backgroundColor="neutral-faded" padding={4}>
|
76
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
|
77
|
-
been the industry's standard dummy text ever since the 1500s, when an unknown printer took
|
78
|
-
a galley of type and scrambled it to make a type specimen book. It has survived not only
|
79
|
-
five centuries, but also the leap into electronic typesetting, remaining essentially
|
80
|
-
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
|
81
|
-
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
|
82
|
-
PageMaker including versions of Lorem Ipsum.
|
83
|
-
</View>
|
84
|
-
</ScrollArea>
|
85
|
-
</Example.Item>
|
86
|
-
<Example.Item title="visibility: hidden">
|
87
|
-
<ScrollArea height="100px" scrollbarDisplay="hidden">
|
88
|
-
<View backgroundColor="neutral-faded" padding={4}>
|
89
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
|
90
|
-
been the industry's standard dummy text ever since the 1500s, when an unknown printer took
|
91
|
-
a galley of type and scrambled it to make a type specimen book. It has survived not only
|
92
|
-
five centuries, but also the leap into electronic typesetting, remaining essentially
|
93
|
-
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
|
94
|
-
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
|
95
|
-
PageMaker including versions of Lorem Ipsum.
|
96
|
-
</View>
|
97
|
-
</ScrollArea>
|
98
|
-
</Example.Item>
|
99
|
-
<Example.Item title="visibility: visible">
|
100
|
-
<ScrollArea height="100px" scrollbarDisplay="visible">
|
101
|
-
<View backgroundColor="neutral-faded" padding={4}>
|
102
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
|
103
|
-
been the industry's standard dummy text ever since the 1500s, when an unknown printer took
|
104
|
-
a galley of type and scrambled it to make a type specimen book. It has survived not only
|
105
|
-
five centuries, but also the leap into electronic typesetting, remaining essentially
|
106
|
-
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
|
107
|
-
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
|
108
|
-
PageMaker including versions of Lorem Ipsum.
|
109
|
-
</View>
|
110
|
-
</ScrollArea>
|
111
|
-
</Example.Item>
|
112
|
-
</Example>);
|
113
|
-
export const ref = () => (<Example>
|
114
|
-
<Example.Item title="external ref">
|
115
|
-
<Demo />
|
116
|
-
</Example.Item>
|
117
|
-
</Example>);
|
118
|
-
export const edgeCases = () => {
|
119
|
-
const toggle = useToggle(true);
|
120
|
-
const [count, setCount] = React.useState(20);
|
121
|
-
return (<Example>
|
122
|
-
<Example.Item title="dynamic content update">
|
123
|
-
<View gap={4}>
|
124
|
-
<Button onClick={toggle.toggle}>Toggle</Button>
|
125
|
-
<ScrollArea height="100px" scrollbarDisplay="visible" ref={ref}>
|
126
|
-
<View backgroundColor="neutral-faded" padding={4} width={toggle.active ? "120%" : "90%"}>
|
127
|
-
{toggle.active ? (<React.Fragment>
|
128
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
|
129
|
-
Ipsum has been the industry's standard dummy text ever since the 1500s, when an
|
130
|
-
unknown printer took a galley of type and scrambled it to make a type specimen
|
131
|
-
book. It has survived not only five centuries, but also the leap into electronic
|
132
|
-
typesetting, remaining essentially unchanged. It was popularised in the 1960s with
|
133
|
-
the release of Letraset sheets containing Lorem Ipsum passages, and more recently
|
134
|
-
with desktop publishing software like Aldus PageMaker including versions of Lorem
|
135
|
-
Ipsum.
|
136
|
-
</React.Fragment>) : null}
|
137
|
-
</View>
|
138
|
-
</ScrollArea>
|
139
|
-
</View>
|
19
|
+
export const direction = {
|
20
|
+
name: "direction",
|
21
|
+
render: () => (<Example>
|
22
|
+
<Example.Item title="vertical">
|
23
|
+
<ScrollArea height="100px" scrollbarDisplay="visible">
|
24
|
+
<View backgroundColor="elevation-base" padding={4}>
|
25
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
26
|
+
has been the industry's standard dummy text ever since the 1500s, when an unknown
|
27
|
+
printer took a galley of type and scrambled it to make a type specimen book. It has
|
28
|
+
survived not only five centuries, but also the leap into electronic typesetting,
|
29
|
+
remaining essentially unchanged. It was popularised in the 1960s with the release of
|
30
|
+
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
|
31
|
+
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
32
|
+
</View>
|
33
|
+
</ScrollArea>
|
140
34
|
</Example.Item>
|
141
35
|
|
142
|
-
<Example.Item title="
|
143
|
-
<
|
144
|
-
<
|
36
|
+
<Example.Item title="horizontal">
|
37
|
+
<ScrollArea height="100px" scrollbarDisplay="visible">
|
38
|
+
<View backgroundColor="elevation-base" padding={4} width="150%" height="100px">
|
39
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
40
|
+
has been the industry's standard dummy text ever since the 1500s
|
41
|
+
</View>
|
42
|
+
</ScrollArea>
|
43
|
+
</Example.Item>
|
145
44
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
45
|
+
<Example.Item title="horizontal, vertical">
|
46
|
+
<ScrollArea height="100px" scrollbarDisplay="visible">
|
47
|
+
<View backgroundColor="elevation-base" padding={4} width="150%">
|
48
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
49
|
+
has been the industry's standard dummy text ever since the 1500s, when an unknown
|
50
|
+
printer took a galley of type and scrambled it to make a type specimen book. It has
|
51
|
+
survived not only five centuries, but also the leap into electronic typesetting,
|
52
|
+
remaining essentially unchanged. It was popularised in the 1960s with the release of
|
53
|
+
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
|
54
|
+
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
55
|
+
</View>
|
56
|
+
</ScrollArea>
|
57
|
+
</Example.Item>
|
58
|
+
</Example>),
|
59
|
+
};
|
60
|
+
export const visibility = {
|
61
|
+
name: "scrollbarDisplay",
|
62
|
+
render: () => (<Example>
|
63
|
+
<Example.Item title="visibility: hover">
|
64
|
+
<ScrollArea height="100px">
|
65
|
+
<View backgroundColor="elevation-base" padding={4}>
|
66
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
67
|
+
has been the industry's standard dummy text ever since the 1500s, when an unknown
|
68
|
+
printer took a galley of type and scrambled it to make a type specimen book. It has
|
69
|
+
survived not only five centuries, but also the leap into electronic typesetting,
|
70
|
+
remaining essentially unchanged. It was popularised in the 1960s with the release of
|
71
|
+
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
|
72
|
+
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
73
|
+
</View>
|
74
|
+
</ScrollArea>
|
75
|
+
</Example.Item>
|
76
|
+
|
77
|
+
<Example.Item title="visibility: hidden">
|
78
|
+
<ScrollArea height="100px" scrollbarDisplay="hidden">
|
79
|
+
<View backgroundColor="elevation-base" padding={4}>
|
80
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
81
|
+
has been the industry's standard dummy text ever since the 1500s, when an unknown
|
82
|
+
printer took a galley of type and scrambled it to make a type specimen book. It has
|
83
|
+
survived not only five centuries, but also the leap into electronic typesetting,
|
84
|
+
remaining essentially unchanged. It was popularised in the 1960s with the release of
|
85
|
+
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
|
86
|
+
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
87
|
+
</View>
|
88
|
+
</ScrollArea>
|
154
89
|
</Example.Item>
|
155
90
|
|
156
|
-
<Example.Item title="
|
91
|
+
<Example.Item title="visibility: visible">
|
92
|
+
<ScrollArea height="100px" scrollbarDisplay="visible">
|
93
|
+
<View backgroundColor="elevation-base" padding={4}>
|
94
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
95
|
+
has been the industry's standard dummy text ever since the 1500s, when an unknown
|
96
|
+
printer took a galley of type and scrambled it to make a type specimen book. It has
|
97
|
+
survived not only five centuries, but also the leap into electronic typesetting,
|
98
|
+
remaining essentially unchanged. It was popularised in the 1960s with the release of
|
99
|
+
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
|
100
|
+
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
101
|
+
</View>
|
102
|
+
</ScrollArea>
|
103
|
+
</Example.Item>
|
104
|
+
</Example>),
|
105
|
+
};
|
106
|
+
export const composition = {
|
107
|
+
name: "composition",
|
108
|
+
render: () => (<Example>
|
109
|
+
<Example.Item title="nested">
|
157
110
|
<ScrollArea height="100px">
|
158
|
-
<View padding={
|
111
|
+
<View padding={4} paddingInline={16}>
|
159
112
|
<ScrollArea height="200px">
|
160
113
|
{Array(20)
|
161
114
|
.fill("")
|
@@ -166,5 +119,27 @@ export const edgeCases = () => {
|
|
166
119
|
</View>
|
167
120
|
</ScrollArea>
|
168
121
|
</Example.Item>
|
169
|
-
</Example>)
|
122
|
+
</Example>),
|
123
|
+
};
|
124
|
+
export const dynamicHeight = {
|
125
|
+
name: "composition, dynamic height change",
|
126
|
+
render: () => {
|
127
|
+
const [count, setCount] = React.useState(10);
|
128
|
+
return (<View gap={4}>
|
129
|
+
<View.Item>
|
130
|
+
<Button onClick={() => setCount((prev) => prev + 10)}>Add more items</Button>
|
131
|
+
</View.Item>
|
132
|
+
|
133
|
+
<ScrollArea height="200px" scrollbarDisplay="visible">
|
134
|
+
<View gap={2}>
|
135
|
+
{new Array(count).fill("").map((_, i) => (<View.Item key={i}>Item {i + 1}</View.Item>))}
|
136
|
+
</View>
|
137
|
+
</ScrollArea>
|
138
|
+
</View>);
|
139
|
+
},
|
140
|
+
// TODO: After Using play(), Storybook makes the scroll lag, but not when triggered manually in the browser
|
141
|
+
// play: async ({ canvas }) => {
|
142
|
+
// const trigger = canvas.getAllByRole("button")[0];
|
143
|
+
// await userEvent.click(trigger);
|
144
|
+
// },
|
170
145
|
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { StoryObj } from "@storybook/react";
|
3
|
+
import { fn } from "@storybook/test";
|
4
|
+
declare const _default: {
|
5
|
+
title: string;
|
6
|
+
component: React.ForwardRefExoticComponent<import("./..").ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
|
7
|
+
parameters: {
|
8
|
+
iframe: {
|
9
|
+
url: string;
|
10
|
+
};
|
11
|
+
a11y: {
|
12
|
+
disable: boolean;
|
13
|
+
};
|
14
|
+
chromatic: {
|
15
|
+
disableSnapshot: boolean;
|
16
|
+
};
|
17
|
+
};
|
18
|
+
};
|
19
|
+
export default _default;
|
20
|
+
export declare const onScroll: StoryObj<{
|
21
|
+
handleScroll: ReturnType<typeof fn>;
|
22
|
+
}>;
|
23
|
+
export declare const className: StoryObj;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { expect, fn, userEvent, waitFor } from "@storybook/test";
|
3
|
+
import Button from "../../Button/index.js";
|
4
|
+
import ScrollArea from "../index.js";
|
5
|
+
import View from "../../View/index.js";
|
6
|
+
export default {
|
7
|
+
title: "Utilities/ScrollArea/tests",
|
8
|
+
component: ScrollArea,
|
9
|
+
parameters: {
|
10
|
+
iframe: {
|
11
|
+
url: "https://reshaped.so/docs/utilities/text",
|
12
|
+
},
|
13
|
+
// Skip because axe core incorrectly reports contrast issues
|
14
|
+
a11y: {
|
15
|
+
disable: true,
|
16
|
+
},
|
17
|
+
chromatic: { disableSnapshot: true },
|
18
|
+
},
|
19
|
+
};
|
20
|
+
export const onScroll = {
|
21
|
+
name: "ref, onScroll",
|
22
|
+
args: {
|
23
|
+
handleScroll: fn(),
|
24
|
+
},
|
25
|
+
render: (args) => {
|
26
|
+
const ref = React.useRef(null);
|
27
|
+
return (<View gap={4}>
|
28
|
+
<View.Item>
|
29
|
+
<Button onClick={() => ref.current?.scrollBy({ top: 50, left: 50 })}>Scroll</Button>
|
30
|
+
</View.Item>
|
31
|
+
<ScrollArea height="100px" ref={ref} scrollbarDisplay="visible" onScroll={args.handleScroll}>
|
32
|
+
<View backgroundColor="neutral-faded" padding={4} width="1000px" height="200px">
|
33
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
|
34
|
+
has been the industry's standard dummy text ever since the 1500s, when an unknown
|
35
|
+
printer took a galley of type and scrambled it to make a type specimen book. It has
|
36
|
+
survived not only five centuries, but also the leap into electronic typesetting,
|
37
|
+
remaining essentially unchanged. It was popularised in the 1960s with the release of
|
38
|
+
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
|
39
|
+
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
40
|
+
</View>
|
41
|
+
</ScrollArea>
|
42
|
+
</View>);
|
43
|
+
},
|
44
|
+
play: async ({ canvas, args }) => {
|
45
|
+
const trigger = canvas.getAllByRole("button")[0];
|
46
|
+
await userEvent.click(trigger);
|
47
|
+
await waitFor(() => {
|
48
|
+
expect(args.handleScroll).toHaveBeenCalledTimes(1);
|
49
|
+
// x value is flaky, so only testing y here
|
50
|
+
expect(args.handleScroll).toHaveBeenCalledWith(expect.objectContaining({ y: 0.5 }));
|
51
|
+
});
|
52
|
+
},
|
53
|
+
};
|
54
|
+
export const className = {
|
55
|
+
name: "className, attributes",
|
56
|
+
render: () => (<div data-testid="root">
|
57
|
+
<ScrollArea className="test-classname" attributes={{ id: "test-id" }}>
|
58
|
+
Content
|
59
|
+
</ScrollArea>
|
60
|
+
</div>),
|
61
|
+
play: async ({ canvas }) => {
|
62
|
+
const root = canvas.getByTestId("root").firstChild;
|
63
|
+
expect(root).toHaveClass("test-classname");
|
64
|
+
expect(root).toHaveAttribute("id", "test-id");
|
65
|
+
},
|
66
|
+
};
|
@@ -8,7 +8,7 @@ declare const _default: {
|
|
8
8
|
};
|
9
9
|
};
|
10
10
|
export default _default;
|
11
|
-
export declare const
|
11
|
+
export declare const value: () => import("react").JSX.Element;
|
12
12
|
export declare const variants: () => import("react").JSX.Element;
|
13
13
|
export declare const size: () => import("react").JSX.Element;
|
14
14
|
export declare const disabled: () => import("react").JSX.Element;
|
@@ -13,23 +13,16 @@ export default {
|
|
13
13
|
},
|
14
14
|
},
|
15
15
|
};
|
16
|
-
export const
|
17
|
-
<Example.Item title="
|
18
|
-
<Select name="animal"
|
16
|
+
export const value = () => (<Example>
|
17
|
+
<Example.Item title="defaultValue">
|
18
|
+
<Select name="animal" defaultValue="dog" inputAttributes={{ "aria-label": "test select" }} options={[
|
19
19
|
{ label: "Dog", value: "dog" },
|
20
20
|
{ label: "Turtle", value: "turtle" },
|
21
21
|
]}/>
|
22
22
|
</Example.Item>
|
23
23
|
|
24
|
-
<Example.Item title="
|
25
|
-
<Select name="animal" inputAttributes={{ "aria-label": "test select" }}
|
26
|
-
{ label: "Dog", value: "dog" },
|
27
|
-
{ label: "Turtle", value: "turtle" },
|
28
|
-
]}/>
|
29
|
-
</Example.Item>
|
30
|
-
|
31
|
-
<Example.Item title="selected, uncontrolled">
|
32
|
-
<Select name="animal" inputAttributes={{ "aria-label": "test select" }} placeholder="Select an animal" value="dog" options={[
|
24
|
+
<Example.Item title="placeholder">
|
25
|
+
<Select name="animal" placeholder="Select an animal" inputAttributes={{ "aria-label": "test select" }} options={[
|
33
26
|
{ label: "Dog", value: "dog" },
|
34
27
|
{ label: "Turtle", value: "turtle" },
|
35
28
|
]}/>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: (props: import("./..").SelectProps) => import("react").JSX.Element;
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: string;
|
9
|
+
};
|
10
|
+
chromatic: {
|
11
|
+
disableSnapshot: boolean;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export default _default;
|
16
|
+
export declare const render: StoryObj;
|
17
|
+
export declare const startSlot: StoryObj;
|
18
|
+
export declare const placeholder: StoryObj;
|
19
|
+
export declare const id: StoryObj;
|
20
|
+
export declare const disabled: StoryObj;
|
21
|
+
export declare const defaultValue: StoryObj<{
|
22
|
+
handleChange: ReturnType<typeof fn>;
|
23
|
+
}>;
|
24
|
+
export declare const value: StoryObj<{
|
25
|
+
handleChange: ReturnType<typeof fn>;
|
26
|
+
}>;
|
27
|
+
export declare const className: StoryObj;
|