reshaped 3.8.0-canary.1 → 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 +83 -18
- 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 +7 -7
- package/dist/components/Flyout/FlyoutContent.js +4 -1
- package/dist/components/Flyout/FlyoutControlled.js +10 -3
- package/dist/components/Flyout/index.d.ts +1 -1
- package/dist/components/Flyout/tests/Flyout.stories.d.ts +8 -0
- package/dist/components/Flyout/tests/Flyout.stories.js +81 -33
- package/dist/components/Flyout/useFlyout.d.ts +1 -7
- package/dist/components/Flyout/useFlyout.js +5 -1
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +3 -2
- package/dist/components/Flyout/utilities/calculatePosition.js +47 -22
- package/dist/components/Flyout/utilities/flyout.js +3 -2
- package/dist/components/Flyout/utilities/getPositionFallbacks.js +3 -3
- package/dist/components/Flyout/utilities/isFullyVisible.d.ts +0 -2
- package/dist/components/Flyout/utilities/isFullyVisible.js +5 -7
- 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/tests/PinField.stories.d.ts +1 -1
- package/dist/components/PinField/tests/PinField.stories.js +1 -1
- 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 +23 -23
- 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/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
@@ -33,6 +33,14 @@ export declare const fallbackAdjustLayout: {
|
|
33
33
|
name: string;
|
34
34
|
render: () => React.JSX.Element;
|
35
35
|
};
|
36
|
+
export declare const fallbackAdjustLayoutShift: {
|
37
|
+
name: string;
|
38
|
+
render: () => React.JSX.Element;
|
39
|
+
};
|
40
|
+
export declare const fallbackAdjustLayoutSize: {
|
41
|
+
name: string;
|
42
|
+
render: () => React.JSX.Element;
|
43
|
+
};
|
36
44
|
export declare const originCoordinates: {
|
37
45
|
name: string;
|
38
46
|
render: () => React.JSX.Element;
|
@@ -17,7 +17,7 @@ const Content = (props) => (<div style={{
|
|
17
17
|
background: "var(--rs-color-background-elevation-overlay)",
|
18
18
|
padding: "var(--rs-unit-x4)",
|
19
19
|
height: props.height === false ? undefined : props.height || 150,
|
20
|
-
|
20
|
+
width: props.width === false ? undefined : props.width || 160,
|
21
21
|
borderRadius: "var(--rs-radius-medium)",
|
22
22
|
border: "1px solid var(--rs-color-border-neutral-faded)",
|
23
23
|
boxSizing: "border-box",
|
@@ -30,10 +30,18 @@ const Demo = (props) => {
|
|
30
30
|
<Flyout.Trigger>
|
31
31
|
{(attributes) => <Button attributes={attributes}>{text || position}</Button>}
|
32
32
|
</Flyout.Trigger>
|
33
|
-
<Flyout.Content
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
<Flyout.Content attributes={{
|
34
|
+
style: {
|
35
|
+
background: "var(--rs-color-background-elevation-overlay)",
|
36
|
+
padding: "var(--rs-unit-x4)",
|
37
|
+
height: contentHeight === false ? undefined : contentHeight || 150,
|
38
|
+
width: contentWidth === false ? undefined : contentWidth || 160,
|
39
|
+
borderRadius: "var(--rs-radius-medium)",
|
40
|
+
border: "1px solid var(--rs-color-border-neutral-faded)",
|
41
|
+
boxSizing: "border-box",
|
42
|
+
},
|
43
|
+
}}>
|
44
|
+
{children || "Content"}
|
37
45
|
</Flyout.Content>
|
38
46
|
</Flyout>);
|
39
47
|
};
|
@@ -222,42 +230,58 @@ export const positionFallbacks = {
|
|
222
230
|
</Example>);
|
223
231
|
},
|
224
232
|
};
|
225
|
-
const FallbackAdjustLayoutControls = ({ containerRef, }) =>
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
233
|
+
const FallbackAdjustLayoutControls = ({ containerRef, large, }) => {
|
234
|
+
const contentHeight = large ? "2000px" : "200px";
|
235
|
+
const contentWidth = large ? "2000px" : "300px";
|
236
|
+
return (<>
|
237
|
+
{/* Left side */}
|
238
|
+
<View position="absolute" insetStart={4} insetTop={10} gap={2}>
|
239
|
+
<Demo contentHeight={contentHeight} position="end" fallbackAdjustLayout fallbackPositions={false} containerRef={containerRef}/>
|
240
|
+
<Demo contentHeight={contentHeight} position="end-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
241
|
+
</View>
|
231
242
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
243
|
+
<View position="absolute" insetStart={4} insetTop={80} gap={2}>
|
244
|
+
<Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
245
|
+
<Demo position="top-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
246
|
+
<Demo position="bottom-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
247
|
+
<Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
248
|
+
</View>
|
236
249
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
250
|
+
<View position="absolute" insetBottom={4} insetStart={4} gap={2}>
|
251
|
+
<Demo contentHeight={contentHeight} position="end-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
252
|
+
<Demo contentHeight={contentHeight} position="end" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
253
|
+
</View>
|
241
254
|
|
242
|
-
|
255
|
+
{/* Right side */}
|
243
256
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
257
|
+
<View position="absolute" insetTop={10} insetEnd={4} gap={2}>
|
258
|
+
<Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
259
|
+
<Demo contentHeight={contentHeight} position="start-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
260
|
+
</View>
|
248
261
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
262
|
+
<View position="absolute" insetEnd={4} insetTop={80} gap={2}>
|
263
|
+
<Demo position="top-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
264
|
+
<Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
265
|
+
<Demo position="bottom-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
266
|
+
<Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
|
267
|
+
</View>
|
253
268
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
269
|
+
<View position="absolute" insetBottom={4} insetEnd={4} gap={2}>
|
270
|
+
<Demo contentHeight={contentHeight} position="start-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
271
|
+
<Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
|
272
|
+
</View>
|
273
|
+
</>);
|
274
|
+
};
|
259
275
|
export const fallbackAdjustLayout = {
|
260
276
|
name: "fallbackAdjustLayout",
|
277
|
+
render: () => {
|
278
|
+
return (<Demo contentHeight={false} position="bottom-start" width="200px" fallbackAdjustLayout defaultActive>
|
279
|
+
<div style={{ height: "600px" }}>Content</div>
|
280
|
+
</Demo>);
|
281
|
+
},
|
282
|
+
};
|
283
|
+
export const fallbackAdjustLayoutShift = {
|
284
|
+
name: "fallbackAdjustLayout, shift",
|
261
285
|
render: () => {
|
262
286
|
const containerRef = React.useRef(null);
|
263
287
|
return (<View gap={10}>
|
@@ -280,6 +304,30 @@ export const fallbackAdjustLayout = {
|
|
280
304
|
</View>);
|
281
305
|
},
|
282
306
|
};
|
307
|
+
export const fallbackAdjustLayoutSize = {
|
308
|
+
name: "fallbackAdjustLayout, size",
|
309
|
+
render: () => {
|
310
|
+
const containerRef = React.useRef(null);
|
311
|
+
return (<View gap={10}>
|
312
|
+
<View height="95vh" width="100%" align="center" justify="center">
|
313
|
+
<View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" padding={4} paddingBlock={15} overflow="auto">
|
314
|
+
<FallbackAdjustLayoutControls large/>
|
315
|
+
<View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
|
316
|
+
</View>
|
317
|
+
</View>
|
318
|
+
|
319
|
+
<View height="95vh" width="100%" align="center" justify="center">
|
320
|
+
<View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" attributes={{ ref: containerRef }} padding={4} paddingBlock={15} overflow="auto">
|
321
|
+
<FallbackAdjustLayoutControls containerRef={containerRef} large/>
|
322
|
+
<View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
|
323
|
+
</View>
|
324
|
+
</View>
|
325
|
+
|
326
|
+
<FallbackAdjustLayoutControls large/>
|
327
|
+
<div style={{ height: "100vh", width: "250%" }}/>
|
328
|
+
</View>);
|
329
|
+
},
|
330
|
+
};
|
283
331
|
export const originCoordinates = {
|
284
332
|
name: "originCoordinates",
|
285
333
|
render: () => {
|
@@ -1,14 +1,8 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type * as G from "../../types/global";
|
3
3
|
import type * as T from "./Flyout.types";
|
4
|
-
type UseFlyout = (args: {
|
5
|
-
width?: T.Width;
|
6
|
-
position?: T.Position;
|
7
|
-
defaultActive?: boolean;
|
4
|
+
type UseFlyout = (args: Pick<T.Props, "width" | "position" | "defaultActive" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight" | "contentGap" | "contentShift"> & {
|
8
5
|
fallbackPositions?: T.Position[];
|
9
|
-
fallbackAdjustLayout?: boolean;
|
10
|
-
contentGap?: number;
|
11
|
-
contentShift?: number;
|
12
6
|
container?: HTMLElement | null;
|
13
7
|
triggerElRef: React.RefObject<HTMLElement | null>;
|
14
8
|
flyoutElRef: React.RefObject<HTMLElement | null>;
|
@@ -38,7 +38,7 @@ const flyoutReducer = (state, action) => {
|
|
38
38
|
};
|
39
39
|
const useFlyout = (args) => {
|
40
40
|
const { triggerElRef, flyoutElRef, triggerBounds, contentGap, contentShift, ...options } = args;
|
41
|
-
const { position: defaultPosition = "bottom", fallbackPositions, width, container,
|
41
|
+
const { position: defaultPosition = "bottom", fallbackPositions, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, width, container, } = options;
|
42
42
|
const lastUsedPositionRef = React.useRef(defaultPosition);
|
43
43
|
// Memo the array internally to avoid new arrays triggering useCallback
|
44
44
|
const cachedFallbackPositions = React.useMemo(() => fallbackPositions,
|
@@ -77,6 +77,8 @@ const useFlyout = (args) => {
|
|
77
77
|
position: changePositon ? defaultPosition : lastUsedPositionRef.current,
|
78
78
|
fallbackPositions: changePositon ? cachedFallbackPositions : [],
|
79
79
|
fallbackAdjustLayout,
|
80
|
+
fallbackMinWidth,
|
81
|
+
fallbackMinHeight,
|
80
82
|
lastUsedPosition: lastUsedPositionRef.current,
|
81
83
|
onPositionChoose: handlePosition,
|
82
84
|
rtl: isRTL,
|
@@ -103,6 +105,8 @@ const useFlyout = (args) => {
|
|
103
105
|
contentGap,
|
104
106
|
contentShift,
|
105
107
|
handlePosition,
|
108
|
+
fallbackMinWidth,
|
109
|
+
fallbackMinHeight,
|
106
110
|
]);
|
107
111
|
React.useEffect(() => {
|
108
112
|
if (state.status === "rendered")
|
@@ -10,15 +10,16 @@ declare const calculatePosition: (args: {
|
|
10
10
|
};
|
11
11
|
passedContainer?: HTMLElement | null;
|
12
12
|
containerBounds: DOMRect;
|
13
|
-
} & Pick<T.Options, "position" | "rtl" | "width" | "contentGap" | "contentShift" | "fallbackAdjustLayout">) => {
|
13
|
+
} & Pick<T.Options, "position" | "rtl" | "width" | "contentGap" | "contentShift" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight">) => {
|
14
14
|
position: T.Position;
|
15
15
|
styles: {
|
16
|
-
width: string | number | undefined;
|
17
16
|
left: number | undefined;
|
18
17
|
right: number | undefined;
|
19
18
|
top: number | undefined;
|
20
19
|
bottom: number | undefined;
|
21
20
|
transform: string;
|
21
|
+
height: number | undefined;
|
22
|
+
width: string | number | undefined;
|
22
23
|
};
|
23
24
|
boundaries: {
|
24
25
|
left: number;
|
@@ -4,12 +4,14 @@ const SCREEN_OFFSET = 8;
|
|
4
4
|
* Calculate styles for the current position
|
5
5
|
*/
|
6
6
|
const calculatePosition = (args) => {
|
7
|
-
const { triggerBounds, flyoutBounds, containerBounds, position: passedPosition, rtl, width, contentGap = 0, contentShift = 0, passedContainer, fallbackAdjustLayout, } = args;
|
8
|
-
const isFullWidth =
|
7
|
+
const { triggerBounds, flyoutBounds, containerBounds, position: passedPosition, rtl, width: passedWidth, contentGap = 0, contentShift = 0, passedContainer, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, } = args;
|
8
|
+
const isFullWidth = passedWidth === "full" || passedWidth === "100%";
|
9
9
|
let left = 0;
|
10
10
|
let top = 0;
|
11
11
|
let bottom = null;
|
12
12
|
let right = null;
|
13
|
+
let height = undefined;
|
14
|
+
let width = undefined;
|
13
15
|
let position = passedPosition;
|
14
16
|
if (rtl)
|
15
17
|
position = getRTLPosition(position);
|
@@ -96,57 +98,80 @@ const calculatePosition = (args) => {
|
|
96
98
|
break;
|
97
99
|
}
|
98
100
|
if (fallbackAdjustLayout) {
|
99
|
-
const
|
100
|
-
|
101
|
-
|
102
|
-
|
101
|
+
const getOverflow = () => {
|
102
|
+
return {
|
103
|
+
top: -top + scrollY + SCREEN_OFFSET,
|
104
|
+
bottom: top + flyoutHeight + SCREEN_OFFSET - scrollY - renderContainerHeight,
|
105
|
+
left: -left + scrollX + SCREEN_OFFSET,
|
106
|
+
right: left + flyoutWidth + SCREEN_OFFSET - scrollX - renderContainerWidth,
|
107
|
+
};
|
108
|
+
};
|
109
|
+
const overflow = getOverflow();
|
103
110
|
if (isHorizontalPosition) {
|
104
|
-
if (
|
111
|
+
if (overflow.top > 0) {
|
105
112
|
top = SCREEN_OFFSET + scrollY;
|
106
113
|
if (bottom !== null)
|
107
|
-
bottom = bottom -
|
114
|
+
bottom = bottom - overflow.top;
|
108
115
|
}
|
109
|
-
else if (
|
110
|
-
|
111
|
-
top = top - bottomOverflowSize;
|
116
|
+
else if (overflow.bottom > 0) {
|
117
|
+
top = top - overflow.bottom;
|
112
118
|
}
|
113
119
|
}
|
114
120
|
else {
|
115
|
-
if (
|
121
|
+
if (overflow.left > 0) {
|
116
122
|
left = SCREEN_OFFSET + scrollX;
|
117
123
|
if (right !== null)
|
118
|
-
right = right -
|
124
|
+
right = right - overflow.left;
|
119
125
|
}
|
120
|
-
else if (
|
121
|
-
left = left -
|
126
|
+
else if (overflow.right > 0) {
|
127
|
+
left = left - overflow.right;
|
122
128
|
}
|
123
129
|
}
|
130
|
+
const updatedOverflow = getOverflow();
|
131
|
+
if (updatedOverflow.top > 0) {
|
132
|
+
height = Math.max(fallbackMinHeight ? parseInt(fallbackMinHeight) : 0, flyoutHeight - updatedOverflow.top);
|
133
|
+
top = top + (flyoutHeight - height);
|
134
|
+
}
|
135
|
+
else if (updatedOverflow.bottom > 0) {
|
136
|
+
height = Math.max(fallbackMinHeight ? parseInt(fallbackMinHeight) : 0, flyoutHeight - updatedOverflow.bottom);
|
137
|
+
if (bottom !== null)
|
138
|
+
bottom = bottom + (flyoutHeight - height);
|
139
|
+
}
|
140
|
+
if (updatedOverflow.left > 0) {
|
141
|
+
width = Math.max(fallbackMinWidth ? parseInt(fallbackMinWidth) : 0, flyoutWidth - updatedOverflow.left);
|
142
|
+
left = left + (flyoutWidth - width);
|
143
|
+
}
|
144
|
+
else if (updatedOverflow.right > 0) {
|
145
|
+
width = Math.max(fallbackMinWidth ? parseInt(fallbackMinWidth) : 0, flyoutWidth - updatedOverflow.right);
|
146
|
+
if (right !== null)
|
147
|
+
right = right + (flyoutWidth - width);
|
148
|
+
}
|
124
149
|
}
|
125
|
-
let widthStyle;
|
126
150
|
if (isFullWidth) {
|
127
151
|
left = SCREEN_OFFSET;
|
128
|
-
|
152
|
+
width = window.innerWidth - SCREEN_OFFSET * 2;
|
129
153
|
}
|
130
|
-
else if (
|
131
|
-
|
154
|
+
else if (passedWidth === "trigger") {
|
155
|
+
width = triggerBounds.width;
|
132
156
|
}
|
133
157
|
const translateX = right !== null ? -right : left;
|
134
158
|
const translateY = bottom !== null ? -bottom : top;
|
135
159
|
return {
|
136
160
|
position,
|
137
161
|
styles: {
|
138
|
-
width: widthStyle ?? width,
|
139
162
|
left: right === null ? 0 : undefined,
|
140
163
|
right: right === null ? undefined : 0,
|
141
164
|
top: bottom === null ? 0 : undefined,
|
142
165
|
bottom: bottom === null ? undefined : 0,
|
143
166
|
transform: `translate(${translateX}px, ${translateY}px)`,
|
167
|
+
height,
|
168
|
+
width: width ?? passedWidth,
|
144
169
|
},
|
145
170
|
boundaries: {
|
146
171
|
left,
|
147
172
|
top,
|
148
|
-
height: Math.ceil(flyoutHeight),
|
149
|
-
width:
|
173
|
+
height: height ?? Math.ceil(flyoutHeight),
|
174
|
+
width: width ?? Math.ceil(flyoutWidth),
|
150
175
|
},
|
151
176
|
};
|
152
177
|
};
|
@@ -7,7 +7,7 @@ import { resetStyles } from "../Flyout.constants.js";
|
|
7
7
|
* Set position of the target element to fit on the screen
|
8
8
|
*/
|
9
9
|
const flyout = (args) => {
|
10
|
-
const { triggerEl, flyoutEl, triggerBounds: passedTriggerBounds, contentShift = 0, contentGap = 0, position, fallbackPositions, fallbackAdjustLayout, width, container: passedContainer, lastUsedPosition, onPositionChoose, rtl, } = args;
|
10
|
+
const { triggerEl, flyoutEl, triggerBounds: passedTriggerBounds, contentShift = 0, contentGap = 0, position, fallbackPositions, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, width, container: passedContainer, lastUsedPosition, onPositionChoose, rtl, } = args;
|
11
11
|
const targetClone = flyoutEl.cloneNode(true);
|
12
12
|
const baseUnit = getComputedStyle(flyoutEl).getPropertyValue("--rs-unit-x1");
|
13
13
|
const unitModifier = baseUnit ? parseInt(baseUnit) : 4;
|
@@ -55,6 +55,8 @@ const flyout = (args) => {
|
|
55
55
|
passedContainer: passedContainer ||
|
56
56
|
(closestFixedContainer !== document.body ? closestFixedContainer : undefined),
|
57
57
|
fallbackAdjustLayout,
|
58
|
+
fallbackMinWidth,
|
59
|
+
fallbackMinHeight,
|
58
60
|
});
|
59
61
|
};
|
60
62
|
const testVisibility = (calculated) => {
|
@@ -62,7 +64,6 @@ const flyout = (args) => {
|
|
62
64
|
flyoutBounds: calculated.boundaries,
|
63
65
|
visualContainerBounds,
|
64
66
|
renderContainerBounds,
|
65
|
-
container,
|
66
67
|
});
|
67
68
|
};
|
68
69
|
let calculated = null;
|
@@ -14,7 +14,7 @@ const fallbackOrder = {
|
|
14
14
|
};
|
15
15
|
// Get an order of positions to try to fit flyout on the screen based on its starting position
|
16
16
|
const getPositionFallbacks = (position, availableFallbacks) => {
|
17
|
-
const result = [position];
|
17
|
+
const result = new Set([position]);
|
18
18
|
const chunks = position.split("-");
|
19
19
|
const [firstChunk] = chunks;
|
20
20
|
const passedPositionOrder = positions[firstChunk];
|
@@ -31,9 +31,9 @@ const getPositionFallbacks = (position, availableFallbacks) => {
|
|
31
31
|
const position = fallbackOrder[index];
|
32
32
|
if (availableFallbacks?.indexOf(position) === -1)
|
33
33
|
return;
|
34
|
-
result.
|
34
|
+
result.add(position);
|
35
35
|
});
|
36
36
|
});
|
37
|
-
return result;
|
37
|
+
return Array.from(result);
|
38
38
|
};
|
39
39
|
export default getPositionFallbacks;
|
@@ -8,7 +8,5 @@ declare const isFullyVisible: (args: {
|
|
8
8
|
visualContainerBounds: DOMRect;
|
9
9
|
/** Bounds of the container where flyout content is rendered */
|
10
10
|
renderContainerBounds: DOMRect;
|
11
|
-
/** Container where the flyout content is rendered */
|
12
|
-
container: HTMLElement;
|
13
11
|
}) => boolean;
|
14
12
|
export default isFullyVisible;
|
@@ -2,20 +2,18 @@
|
|
2
2
|
* Check if element visually fits within its render container
|
3
3
|
*/
|
4
4
|
const isFullyVisible = (args) => {
|
5
|
-
const { flyoutBounds, visualContainerBounds, renderContainerBounds
|
6
|
-
|
7
|
-
const scrollY = container === document.body ? window.scrollY : container.scrollTop;
|
8
|
-
if (renderContainerBounds.left + flyoutBounds.left - scrollX < visualContainerBounds.left) {
|
5
|
+
const { flyoutBounds, visualContainerBounds, renderContainerBounds } = args;
|
6
|
+
if (renderContainerBounds.left + flyoutBounds.left < visualContainerBounds.left) {
|
9
7
|
return false;
|
10
8
|
}
|
11
|
-
if (renderContainerBounds.top + flyoutBounds.top
|
9
|
+
if (renderContainerBounds.top + flyoutBounds.top < visualContainerBounds.top) {
|
12
10
|
return false;
|
13
11
|
}
|
14
|
-
if (renderContainerBounds.left + flyoutBounds.left + flyoutBounds.width
|
12
|
+
if (renderContainerBounds.left + flyoutBounds.left + flyoutBounds.width >
|
15
13
|
visualContainerBounds.right) {
|
16
14
|
return false;
|
17
15
|
}
|
18
|
-
if (renderContainerBounds.top + flyoutBounds.top + flyoutBounds.height
|
16
|
+
if (renderContainerBounds.top + flyoutBounds.top + flyoutBounds.height >
|
19
17
|
visualContainerBounds.bottom) {
|
20
18
|
return false;
|
21
19
|
}
|
@@ -51,7 +51,7 @@ export declare const useFormControl: () => {
|
|
51
51
|
results?: number | undefined | undefined;
|
52
52
|
security?: string | undefined | undefined;
|
53
53
|
unselectable?: "on" | "off" | undefined | undefined;
|
54
|
-
popover?: "" | "auto" | "manual" | undefined | undefined;
|
54
|
+
popover?: "" | "auto" | "manual" | "hint" | undefined | undefined;
|
55
55
|
popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
|
56
56
|
popoverTarget?: string | undefined | undefined;
|
57
57
|
inert?: boolean | undefined | undefined;
|
@@ -3,6 +3,8 @@ import { Example } from "../../../utilities/storybook/index.js";
|
|
3
3
|
import FormControl from "../index.js";
|
4
4
|
import TextField from "../../TextField/index.js";
|
5
5
|
import View from "../../View/index.js";
|
6
|
+
import RadioGroup from "../../RadioGroup/index.js";
|
7
|
+
import Radio from "../../Radio/index.js";
|
6
8
|
export default {
|
7
9
|
title: "Utility components/FormControl",
|
8
10
|
component: FormControl,
|
@@ -106,3 +108,36 @@ export const composition = {
|
|
106
108
|
</Example.Item>
|
107
109
|
</Example>),
|
108
110
|
};
|
111
|
+
export const className = {
|
112
|
+
name: "className, attributes",
|
113
|
+
render: () => (<FormControl id="test-id" hasError>
|
114
|
+
<FormControl.Label>Label</FormControl.Label>
|
115
|
+
<TextField name="name"/>
|
116
|
+
<FormControl.Helper>Caption</FormControl.Helper>
|
117
|
+
<FormControl.Error>Error</FormControl.Error>
|
118
|
+
</FormControl>),
|
119
|
+
play: async ({ canvas }) => {
|
120
|
+
const input = canvas.getByRole("textbox");
|
121
|
+
const label = canvas.getByText("Label");
|
122
|
+
expect(input).toHaveAttribute("id", "test-id");
|
123
|
+
expect(input).toHaveAttribute("aria-describedby", `test-id-caption test-id-error`);
|
124
|
+
expect(label).toHaveAttribute("for", "test-id");
|
125
|
+
expect(label).toHaveAttribute("id", `test-id-label`);
|
126
|
+
},
|
127
|
+
};
|
128
|
+
export const group = {
|
129
|
+
name: "group",
|
130
|
+
render: () => (<FormControl group>
|
131
|
+
<FormControl.Label>Label</FormControl.Label>
|
132
|
+
<RadioGroup name="name">
|
133
|
+
<View gap={2}>
|
134
|
+
<Radio value="1">One</Radio>
|
135
|
+
<Radio value="2">Two</Radio>
|
136
|
+
</View>
|
137
|
+
</RadioGroup>
|
138
|
+
</FormControl>),
|
139
|
+
play: async ({ canvas }) => {
|
140
|
+
const group = canvas.getByRole("group");
|
141
|
+
expect(group).toBeInTheDocument();
|
142
|
+
},
|
143
|
+
};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react-vite";
|
1
2
|
declare const _default: {
|
2
3
|
title: string;
|
3
4
|
component: import("react").FC<import("./..").HiddenProps>;
|
@@ -12,3 +13,4 @@ export declare const visibility: {
|
|
12
13
|
name: string;
|
13
14
|
render: () => import("react").JSX.Element;
|
14
15
|
};
|
16
|
+
export declare const as: StoryObj;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Example } from "../../../utilities/storybook/index.js";
|
2
2
|
import Hidden from "../index.js";
|
3
|
+
import { expect } from "storybook/test";
|
3
4
|
export default {
|
4
5
|
title: "Utility components/Hidden",
|
5
6
|
component: Hidden,
|
@@ -37,3 +38,11 @@ export const visibility = {
|
|
37
38
|
</Example.Item>
|
38
39
|
</Example>),
|
39
40
|
};
|
41
|
+
export const as = {
|
42
|
+
name: "as",
|
43
|
+
render: () => <Hidden as="span">Content</Hidden>,
|
44
|
+
play: ({ canvas }) => {
|
45
|
+
const el = canvas.getByText("Content");
|
46
|
+
expect(el.tagName).toEqual("SPAN");
|
47
|
+
},
|
48
|
+
};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react-vite";
|
1
2
|
declare const _default: {
|
2
3
|
title: string;
|
3
4
|
component: import("react").FC<import("./..").HiddenVisuallyProps>;
|
@@ -12,3 +13,4 @@ export declare const visibility: {
|
|
12
13
|
name: string;
|
13
14
|
render: () => import("react").JSX.Element;
|
14
15
|
};
|
16
|
+
export declare const children: StoryObj;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Example } from "../../../utilities/storybook/index.js";
|
2
2
|
import HiddenVisually from "../index.js";
|
3
|
+
import { expect } from "storybook/test";
|
3
4
|
export default {
|
4
5
|
title: "Utility components/HiddenVisually",
|
5
6
|
component: HiddenVisually,
|
@@ -17,3 +18,11 @@ export const visibility = {
|
|
17
18
|
</Example.Item>
|
18
19
|
</Example>),
|
19
20
|
};
|
21
|
+
export const children = {
|
22
|
+
name: "children",
|
23
|
+
render: () => <HiddenVisually>Content</HiddenVisually>,
|
24
|
+
play: ({ canvas }) => {
|
25
|
+
const el = canvas.getByText("Content");
|
26
|
+
expect(el).toBeInTheDocument();
|
27
|
+
},
|
28
|
+
};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react-vite";
|
1
2
|
declare const _default: {
|
2
3
|
title: string;
|
3
4
|
component: import("react").FC<import("..").HotkeyProps>;
|
@@ -9,3 +10,4 @@ declare const _default: {
|
|
9
10
|
};
|
10
11
|
export default _default;
|
11
12
|
export declare const base: () => import("react").JSX.Element;
|
13
|
+
export declare const className: StoryObj;
|
@@ -3,6 +3,7 @@ import useHotkeys from "../../../hooks/useHotkeys.js";
|
|
3
3
|
import View from "../../View/index.js";
|
4
4
|
import TextField from "../../TextField/index.js";
|
5
5
|
import Hotkey from "../Hotkey.js";
|
6
|
+
import { expect } from "storybook/test";
|
6
7
|
export default {
|
7
8
|
title: "Components/Hotkey",
|
8
9
|
component: Hotkey,
|
@@ -36,3 +37,17 @@ export const base = () => (<Example>
|
|
36
37
|
</View>
|
37
38
|
</Example.Item>
|
38
39
|
</Example>);
|
40
|
+
export const className = {
|
41
|
+
name: "className, attributes",
|
42
|
+
render: () => (<div data-testid="root">
|
43
|
+
<Hotkey className="test-classname" attributes={{ id: "test-id" }}>
|
44
|
+
⌘K
|
45
|
+
</Hotkey>
|
46
|
+
</div>),
|
47
|
+
play: async ({ canvas }) => {
|
48
|
+
const root = canvas.getByTestId("root").firstChild;
|
49
|
+
expect(root).toHaveClass("test-classname");
|
50
|
+
expect(root).toHaveAttribute("id", "test-id");
|
51
|
+
expect(root?.tagName).toBe("KBD");
|
52
|
+
},
|
53
|
+
};
|
@@ -7,11 +7,11 @@ const Icon = (props) => {
|
|
7
7
|
const { svg: Component, className, color, size = "1em", autoWidth, attributes } = props;
|
8
8
|
const mixinStyles = resolveMixin({ height: size });
|
9
9
|
const rootClassName = classNames(s.root, className, mixinStyles.classNames, color && s[`--color-${color}`], autoWidth && s["--auto"]);
|
10
|
-
const icon = React.isValidElement(Component) ? Component : _jsx(Component, {});
|
10
|
+
const icon = React.isValidElement(Component) || Component === null ? Component : _jsx(Component, {});
|
11
11
|
const style = { ...attributes?.style, ...mixinStyles.variables };
|
12
12
|
return (
|
13
13
|
// All icons are decorative, a11y attributes should be set for buttons wrapping them
|
14
|
-
_jsx("span", { ...attributes, "aria-hidden": "true", className: rootClassName, style: style, children: React.cloneElement(icon, { focusable: false }) }));
|
14
|
+
_jsx("span", { ...attributes, "aria-hidden": "true", className: rootClassName, style: style, children: icon && React.cloneElement(icon, { focusable: false }) }));
|
15
15
|
};
|
16
16
|
Icon.displayName = "Icon";
|
17
17
|
export default Icon;
|
@@ -2,7 +2,7 @@ import type React from "react";
|
|
2
2
|
import type * as G from "../../types/global";
|
3
3
|
export type Props = {
|
4
4
|
/** Icon svg component or node */
|
5
|
-
svg: React.ReactElement | React.ComponentType;
|
5
|
+
svg: React.ReactElement | React.ComponentType | null;
|
6
6
|
/** Icon size, literal css value or unit token multiplier */
|
7
7
|
size?: G.Responsive<number | string>;
|
8
8
|
/** Icon color, based on the color tokens */
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react-vite";
|
1
2
|
declare const _default: {
|
2
3
|
title: string;
|
3
4
|
component: import("react").FC<import("./..").IconProps>;
|
@@ -20,3 +21,5 @@ export declare const autoWidth: {
|
|
20
21
|
name: string;
|
21
22
|
render: () => import("react").JSX.Element;
|
22
23
|
};
|
24
|
+
export declare const className: StoryObj;
|
25
|
+
export declare const render: StoryObj;
|