reshaped 3.8.0-canary.1 → 3.8.0-canary.11
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 +97 -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 +49 -10
- package/dist/components/Modal/tests/Modal.stories.js +350 -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/Text/Text.module.css +1 -1
- 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/useOnClickOutside.js +0 -2
- 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
@@ -1,11 +1,11 @@
|
|
1
1
|
"use client";
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
3
3
|
import { forwardRef } from "react";
|
4
4
|
import { classNames } from "../../utilities/props.js";
|
5
5
|
import * as keys from "../../constants/keys.js";
|
6
6
|
import s from "./Actionable.module.css";
|
7
7
|
const Actionable = forwardRef((props, ref) => {
|
8
|
-
const { children, href, onClick, type, disabled, insetFocus, disableFocusRing, borderRadius, as, stopPropagation, fullWidth, touchHitbox, className, attributes, } = props;
|
8
|
+
const { children, render, href, onClick, type, disabled, insetFocus, disableFocusRing, borderRadius, as, stopPropagation, fullWidth, touchHitbox, className, attributes, } = props;
|
9
9
|
const rootClassNames = classNames(s.root, className, disabled && s["--disabled"], borderRadius && s[`--radius-${borderRadius}`], insetFocus && s["--inset"], disableFocusRing && s["--disabled-focus-ring"], fullWidth && s["--full-width"]);
|
10
10
|
const rootAttributes = { ...attributes };
|
11
11
|
const hasClickHandler = onClick || attributes?.onClick;
|
@@ -57,7 +57,21 @@ const Actionable = forwardRef((props, ref) => {
|
|
57
57
|
event.preventDefault();
|
58
58
|
handlePress(event);
|
59
59
|
};
|
60
|
-
|
60
|
+
const childrenNode = (_jsxs(_Fragment, { children: [touchHitbox && (isLink || isButton) && !disabled && _jsx("span", { className: s.touch }), children] }));
|
61
|
+
const tagAttributes = {
|
62
|
+
ref: ref,
|
63
|
+
// rootAttributes can receive ref from Flyout
|
64
|
+
...rootAttributes,
|
65
|
+
className: rootClassNames,
|
66
|
+
onClick: handlePress,
|
67
|
+
onKeyDown: handleKeyDown,
|
68
|
+
"aria-disabled": disabled ? true : undefined,
|
69
|
+
children: childrenNode,
|
70
|
+
};
|
71
|
+
// eslint-disable-next-line react-hooks/refs
|
72
|
+
if (render)
|
73
|
+
return render(tagAttributes);
|
74
|
+
return _jsx(TagName, { ...tagAttributes });
|
61
75
|
});
|
62
76
|
Actionable.displayName = "Actionable";
|
63
77
|
export default Actionable;
|
@@ -1 +1 @@
|
|
1
|
-
@layer rs.reset{.root{background:none;border:0;color:inherit;display:inline-block;font-size:inherit;font-weight:inherit;isolation:isolate;line-height:inherit;margin:0;padding:0;position:relative;text-align:initial;text-decoration:none;vertical-align:top;-webkit-tap-highlight-color:transparent}}.touch{height:100%;inset:50%;min-height:24px;min-width:24px;position:absolute;transform:translate(-50%,-50%);width:100%}.root:focus{outline:none}[data-rs-keyboard] .root:focus{box-shadow:var(--rs-focus
|
1
|
+
@layer rs.reset{.root{background:none;border:0;color:inherit;display:inline-block;font-size:inherit;font-weight:inherit;isolation:isolate;line-height:inherit;margin:0;padding:0;position:relative;text-align:initial;text-decoration:none;vertical-align:top;-webkit-tap-highlight-color:transparent}}.touch{height:100%;inset:50%;min-height:24px;min-width:24px;position:absolute;transform:translate(-50%,-50%);width:100%}.root:focus{outline:none}[data-rs-keyboard] .root:focus{box-shadow:var(--rs-shadow-focus);outline:none;z-index:var(--rs-z-index-relative)}[data-rs-keyboard] .root.--inset:focus{box-shadow:var(--rs-shadow-focus-inset)}[data-rs-keyboard] .root.--disabled-focus-ring:focus,[data-rs-keyboard] .root.--radius-inherit:focus{box-shadow:none}[data-rs-keyboard] .root.--radius-inherit:focus>*{box-shadow:var(--rs-shadow-focus)}[data-rs-keyboard] .root.--radius-inherit.--inset:focus>*{box-shadow:var(--rs-shadow-focus-inset)}[role=button].root,button.root{cursor:pointer;user-select:none}.root.--disabled,.root[disabled]{cursor:not-allowed}.root.--disabled:active,.root[disabled]:active{transform:none}.root.--full-width{width:100%}
|
@@ -1,8 +1,21 @@
|
|
1
1
|
import type React from "react";
|
2
2
|
import type * as G from "../../types/global";
|
3
|
+
export type AttributesRef = React.RefObject<HTMLButtonElement | null>;
|
4
|
+
type Attributes = G.Attributes<"button"> & Omit<React.JSX.IntrinsicElements["a"], keyof G.Attributes<"button">> & {
|
5
|
+
ref?: AttributesRef;
|
6
|
+
};
|
3
7
|
export type Props = {
|
4
8
|
/** Node for inserting the content */
|
5
9
|
children?: React.ReactNode;
|
10
|
+
/** Render a custom root element, useful for integrating with routers */
|
11
|
+
render?: (attributes: Attributes & {
|
12
|
+
ref: AttributesRef;
|
13
|
+
className: string;
|
14
|
+
onClick: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
15
|
+
onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
|
16
|
+
"aria-disabled"?: boolean;
|
17
|
+
children: React.ReactNode;
|
18
|
+
}) => React.ReactNode;
|
6
19
|
/** Callback when clicked, renders it as a button tag if href is not provided */
|
7
20
|
onClick?: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
8
21
|
/** URL, renders it as an anchor tag */
|
@@ -28,8 +41,7 @@ export type Props = {
|
|
28
41
|
/** Additional classname for the root element */
|
29
42
|
className?: G.ClassName;
|
30
43
|
/** Additional attributes for the root element */
|
31
|
-
attributes?:
|
32
|
-
ref?: React.RefObject<HTMLButtonElement | HTMLAnchorElement | null>;
|
33
|
-
};
|
44
|
+
attributes?: Attributes;
|
34
45
|
};
|
35
46
|
export type Ref = React.Ref<HTMLButtonElement | HTMLAnchorElement>;
|
47
|
+
export {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { StoryObj } from "@storybook/react-vite";
|
2
|
+
import { fn } from "storybook/test";
|
2
3
|
declare const _default: {
|
3
4
|
title: string;
|
4
5
|
component: import("react").ForwardRefExoticComponent<import("./..").ActionableProps & import("react").RefAttributes<import("./..").ActionableRef>>;
|
@@ -9,7 +10,10 @@ declare const _default: {
|
|
9
10
|
};
|
10
11
|
};
|
11
12
|
export default _default;
|
12
|
-
export declare const base: StoryObj
|
13
|
+
export declare const base: StoryObj<{
|
14
|
+
handleClick: ReturnType<typeof fn>;
|
15
|
+
handleSecondClick: ReturnType<typeof fn>;
|
16
|
+
}>;
|
13
17
|
export declare const disabled: StoryObj;
|
14
18
|
export declare const fullWidth: StoryObj;
|
15
19
|
export declare const insetFocus: {
|
@@ -27,3 +31,11 @@ export declare const borderRadius: {
|
|
27
31
|
render: () => import("react").JSX.Element;
|
28
32
|
play: () => Promise<void>;
|
29
33
|
};
|
34
|
+
export declare const type: StoryObj<{
|
35
|
+
handleSubmit: ReturnType<typeof fn>;
|
36
|
+
}>;
|
37
|
+
export declare const as: StoryObj;
|
38
|
+
export declare const stopPropagation: StoryObj<{
|
39
|
+
handleParentClick: ReturnType<typeof fn>;
|
40
|
+
}>;
|
41
|
+
export declare const className: StoryObj;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { userEvent, expect } from "storybook/test";
|
1
|
+
import { userEvent, expect, fn } from "storybook/test";
|
2
2
|
import { Example } from "../../../utilities/storybook/index.js";
|
3
3
|
import Actionable from "../index.js";
|
4
4
|
import View from "../../View/index.js";
|
@@ -12,17 +12,64 @@ export default {
|
|
12
12
|
},
|
13
13
|
};
|
14
14
|
export const base = {
|
15
|
-
name: "
|
16
|
-
|
17
|
-
|
15
|
+
name: "href, onClick",
|
16
|
+
args: {
|
17
|
+
handleClick: fn(),
|
18
|
+
handleSecondClick: fn(),
|
19
|
+
},
|
20
|
+
render: (args) => (<Example>
|
21
|
+
<Example.Item title="span">
|
22
|
+
<Actionable>Span</Actionable>
|
23
|
+
</Example.Item>
|
24
|
+
<Example.Item title="onClick">
|
25
|
+
<Actionable onClick={args.handleClick}>Button</Actionable>
|
26
|
+
</Example.Item>
|
27
|
+
<Example.Item title="href">
|
18
28
|
<Actionable href="https://reshaped.so" attributes={{ target: "_blank" }}>
|
19
29
|
Link
|
20
30
|
</Actionable>
|
21
31
|
</Example.Item>
|
22
|
-
|
23
|
-
|
32
|
+
|
33
|
+
<Example.Item title="attributes.href">
|
34
|
+
<Actionable attributes={{ href: "https://reshaped.so" }}>Link with attributes</Actionable>
|
35
|
+
</Example.Item>
|
36
|
+
|
37
|
+
<Example.Item title="href, onClick">
|
38
|
+
<Actionable onClick={(e) => {
|
39
|
+
e.preventDefault();
|
40
|
+
args.handleSecondClick(e);
|
41
|
+
}} href="https://reshaped.so">
|
42
|
+
Link with onClick
|
43
|
+
</Actionable>
|
24
44
|
</Example.Item>
|
25
45
|
</Example>),
|
46
|
+
play: async ({ canvas, args }) => {
|
47
|
+
const span = canvas.getByText("Span");
|
48
|
+
const link = canvas.getByText("Link");
|
49
|
+
const button = canvas.getByText("Button");
|
50
|
+
const linkWithAttributes = canvas.getByText("Link with attributes");
|
51
|
+
const linkWithOnClick = canvas.getByText("Link with onClick");
|
52
|
+
expect(span).toBeInTheDocument();
|
53
|
+
expect(span.tagName).toBe("SPAN");
|
54
|
+
expect(link).toBeInTheDocument();
|
55
|
+
expect(link).toHaveRole("link");
|
56
|
+
expect(link).toHaveAttribute("href", "https://reshaped.so");
|
57
|
+
await userEvent.click(button);
|
58
|
+
expect(button).toBeInTheDocument();
|
59
|
+
expect(button).toHaveRole("button");
|
60
|
+
expect(button).toHaveAttribute("type", "button");
|
61
|
+
expect(args.handleClick).toHaveBeenCalledTimes(1);
|
62
|
+
expect(args.handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: button }));
|
63
|
+
expect(linkWithAttributes).toBeInTheDocument();
|
64
|
+
expect(linkWithAttributes).toHaveRole("link");
|
65
|
+
expect(linkWithAttributes).toHaveAttribute("href", "https://reshaped.so");
|
66
|
+
await userEvent.click(linkWithOnClick);
|
67
|
+
expect(linkWithOnClick).toBeInTheDocument();
|
68
|
+
expect(linkWithOnClick).toHaveRole("link");
|
69
|
+
expect(linkWithOnClick).toHaveAttribute("href", "https://reshaped.so");
|
70
|
+
expect(args.handleSecondClick).toHaveBeenCalledTimes(1);
|
71
|
+
expect(args.handleSecondClick).toHaveBeenCalledWith(expect.objectContaining({ target: linkWithOnClick }));
|
72
|
+
},
|
26
73
|
};
|
27
74
|
export const disabled = {
|
28
75
|
name: "disabled",
|
@@ -88,7 +135,7 @@ export const disableFocusRing = {
|
|
88
135
|
export const borderRadius = {
|
89
136
|
name: "borderRadius",
|
90
137
|
render: () => (<Example>
|
91
|
-
<Example.Item title="
|
138
|
+
<Example.Item title="borderRadius: inherit">
|
92
139
|
<Actionable borderRadius="inherit" onClick={() => { }}>
|
93
140
|
<View borderRadius="large">Actionable</View>
|
94
141
|
</Actionable>
|
@@ -98,3 +145,76 @@ export const borderRadius = {
|
|
98
145
|
await userEvent.keyboard("{Tab/}");
|
99
146
|
},
|
100
147
|
};
|
148
|
+
export const type = {
|
149
|
+
name: "type",
|
150
|
+
args: {
|
151
|
+
handleSubmit: fn(),
|
152
|
+
},
|
153
|
+
render: (args) => (<Example>
|
154
|
+
<Example.Item title="type: submit">
|
155
|
+
<form onSubmit={(e) => {
|
156
|
+
e.preventDefault();
|
157
|
+
args.handleSubmit();
|
158
|
+
}}>
|
159
|
+
<Actionable onClick={() => { }} type="submit">
|
160
|
+
Submit
|
161
|
+
</Actionable>
|
162
|
+
</form>
|
163
|
+
</Example.Item>
|
164
|
+
</Example>),
|
165
|
+
play: async ({ canvas, args }) => {
|
166
|
+
const button = canvas.getAllByRole("button")[0];
|
167
|
+
await userEvent.click(button);
|
168
|
+
expect(args.handleSubmit).toHaveBeenCalledTimes(1);
|
169
|
+
},
|
170
|
+
};
|
171
|
+
export const as = {
|
172
|
+
name: "as, render",
|
173
|
+
render: () => (<Example>
|
174
|
+
<Example.Item title="as: span">
|
175
|
+
<Actionable onClick={() => { }} as="span">
|
176
|
+
Trigger
|
177
|
+
</Actionable>
|
178
|
+
</Example.Item>
|
179
|
+
<Example.Item title="render, disabled">
|
180
|
+
<Actionable disabled onClick={() => { }} render={(props) => <section {...props}/>}>
|
181
|
+
Trigger
|
182
|
+
</Actionable>
|
183
|
+
</Example.Item>
|
184
|
+
</Example>),
|
185
|
+
play: ({ canvas }) => {
|
186
|
+
const [asEl, renderEl] = canvas.getAllByText("Trigger");
|
187
|
+
expect(asEl.tagName).toBe("SPAN");
|
188
|
+
expect(renderEl.tagName).toBe("SECTION");
|
189
|
+
expect(renderEl).toHaveAttribute("aria-disabled", "true");
|
190
|
+
},
|
191
|
+
};
|
192
|
+
export const stopPropagation = {
|
193
|
+
name: "stopPropagation",
|
194
|
+
args: {
|
195
|
+
handleParentClick: fn(),
|
196
|
+
},
|
197
|
+
render: (args) => (<div onClick={args.handleParentClick}>
|
198
|
+
<Actionable stopPropagation onClick={() => { }}>
|
199
|
+
Trigger
|
200
|
+
</Actionable>
|
201
|
+
</div>),
|
202
|
+
play: async ({ canvas, args }) => {
|
203
|
+
const button = canvas.getAllByRole("button")[0];
|
204
|
+
await userEvent.click(button);
|
205
|
+
expect(args.handleParentClick).not.toHaveBeenCalled();
|
206
|
+
},
|
207
|
+
};
|
208
|
+
export const className = {
|
209
|
+
name: "className, attributes",
|
210
|
+
render: () => (<div data-testid="root">
|
211
|
+
<Actionable className="test-classname" attributes={{ id: "test-id" }}>
|
212
|
+
Trigger
|
213
|
+
</Actionable>
|
214
|
+
</div>),
|
215
|
+
play: async ({ canvas }) => {
|
216
|
+
const root = canvas.getByTestId("root").firstChild;
|
217
|
+
expect(root).toHaveClass("test-classname");
|
218
|
+
expect(root).toHaveAttribute("id", "test-id");
|
219
|
+
},
|
220
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import { StoryObj } from "@storybook/react-vite";
|
2
2
|
declare const _default: {
|
3
3
|
title: string;
|
4
|
-
component:
|
4
|
+
component: import("react").FC<import("./..").AlertProps>;
|
5
5
|
parameters: {
|
6
6
|
iframe: {
|
7
7
|
url: string;
|
@@ -11,13 +11,14 @@ declare const _default: {
|
|
11
11
|
export default _default;
|
12
12
|
export declare const color: {
|
13
13
|
name: string;
|
14
|
-
render: () =>
|
14
|
+
render: () => import("react").JSX.Element;
|
15
15
|
};
|
16
16
|
export declare const inline: {
|
17
17
|
name: string;
|
18
|
-
render: () =>
|
18
|
+
render: () => import("react").JSX.Element;
|
19
19
|
};
|
20
20
|
export declare const bleed: {
|
21
21
|
name: string;
|
22
|
-
render: () =>
|
22
|
+
render: () => import("react").JSX.Element;
|
23
23
|
};
|
24
|
+
export declare const className: StoryObj;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import
|
2
|
-
import { Example } from "../../../utilities/storybook/index.js";
|
1
|
+
import { Example, Placeholder } from "../../../utilities/storybook/index.js";
|
3
2
|
import Alert from "../index.js";
|
4
3
|
import Link from "../../Link/index.js";
|
5
4
|
import IconZap from "../../../icons/Zap.js";
|
5
|
+
import { expect } from "storybook/test";
|
6
6
|
export default {
|
7
7
|
title: "Components/Alert",
|
8
8
|
component: Alert,
|
@@ -63,3 +63,16 @@ export const bleed = {
|
|
63
63
|
</Example.Item>
|
64
64
|
</Example>),
|
65
65
|
};
|
66
|
+
export const className = {
|
67
|
+
name: "className, attributes",
|
68
|
+
render: () => (<div data-testid="root">
|
69
|
+
<Alert className="test-classname" attributes={{ id: "test-id" }}>
|
70
|
+
<Placeholder />
|
71
|
+
</Alert>
|
72
|
+
</div>),
|
73
|
+
play: async ({ canvas }) => {
|
74
|
+
const root = canvas.getByTestId("root").firstChild;
|
75
|
+
expect(root).toHaveClass("test-classname");
|
76
|
+
expect(root).toHaveAttribute("id", "test-id");
|
77
|
+
},
|
78
|
+
};
|
@@ -11,7 +11,7 @@ import useElementId from "../../hooks/useElementId.js";
|
|
11
11
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
12
12
|
const AutocompleteContext = React.createContext({});
|
13
13
|
const Autocomplete = (props) => {
|
14
|
-
const { children, onChange, onInput, onItemSelect, name, containerRef, instanceRef, onBackspace, onEnter, active, onOpen, onClose, ...textFieldProps } = props;
|
14
|
+
const { children, onChange, onInput, onItemSelect, name, containerRef, instanceRef, onBackspace, onEnter, active, onOpen, onClose, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, ...textFieldProps } = props;
|
15
15
|
const [highlightedId, setHighlightedId] = React.useState();
|
16
16
|
const onBackspaceRef = useHandlerRef(onBackspace);
|
17
17
|
const contentRef = React.useRef(null);
|
@@ -120,7 +120,7 @@ const Autocomplete = (props) => {
|
|
120
120
|
highlightedId,
|
121
121
|
setHighlightedId,
|
122
122
|
}), [highlightedId, handleItemClick]);
|
123
|
-
return (_jsx(AutocompleteContext.Provider, { value: contextValue, children: _jsxs(DropdownMenu, { position: "bottom", width: "trigger", triggerType: "focus", trapFocusMode: false, active: isDropdownActive, onClose: handleClose, onOpen: handleOpen, containerRef: containerRef, disableHideAnimation: true, instanceRef: instanceRef, children: [_jsx(DropdownMenu.Trigger, { children: ({ ref, ...attributes }) => (_jsx(TextField, { ...textFieldProps, name: name, onChange: handleChange, focused: isDropdownActive, attributes: {
|
123
|
+
return (_jsx(AutocompleteContext.Provider, { value: contextValue, children: _jsxs(DropdownMenu, { position: "bottom", width: "trigger", triggerType: "focus", trapFocusMode: false, active: isDropdownActive, onClose: handleClose, onOpen: handleOpen, containerRef: containerRef, fallbackAdjustLayout: fallbackAdjustLayout, fallbackMinWidth: fallbackMinWidth, fallbackMinHeight: fallbackMinHeight, disableHideAnimation: true, instanceRef: instanceRef, children: [_jsx(DropdownMenu.Trigger, { children: ({ ref, ...attributes }) => (_jsx(TextField, { ...textFieldProps, name: name, onChange: handleChange, focused: isDropdownActive, attributes: {
|
124
124
|
...textFieldProps.attributes,
|
125
125
|
// Ignoring the type check since TS can't infer the correct html element type
|
126
126
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -7,7 +7,7 @@ type SelectArgs = {
|
|
7
7
|
/** Additional data that will be passed to the onItemSelect callback */
|
8
8
|
data?: unknown;
|
9
9
|
};
|
10
|
-
export type Props = TextFieldProps & Pick<DropdownMenuProps, "containerRef" | "instanceRef" | "active" | "onOpen" | "onClose"> & {
|
10
|
+
export type Props = TextFieldProps & Pick<DropdownMenuProps, "containerRef" | "instanceRef" | "active" | "onOpen" | "onClose" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight"> & {
|
11
11
|
/** Callback for when value changes from user input */
|
12
12
|
onInput?: TextFieldProps["onChange"];
|
13
13
|
/** Callback for when an item is selected in the dropdown */
|
@@ -1 +1 @@
|
|
1
|
-
.root{align-items:center;backface-visibility:hidden;background:var(--rs-color-background-neutral);border
|
1
|
+
.root{--rs-badge-border-color:transparent;align-items:center;backface-visibility:hidden;background:var(--rs-color-background-neutral);border-radius:var(--rs-radius-small);box-shadow:0 0 0 1px var(--rs-badge-border-color) inset;box-sizing:border-box;color:var(--rs-color-foreground-neutral);display:inline-flex;gap:var(--rs-badge-gap);justify-content:center;min-height:calc(var(--rs-badge-line-height) + (var(--rs-badge-p-v) * 2));min-width:calc(var(--rs-badge-line-height) + (var(--rs-badge-p-v) * 2));padding:var(--rs-badge-p-v) var(--rs-badge-p-h);transition:var(--rs-duration-medium) var(--rs-easing-standard);transition-property:transform,opacity;vertical-align:top}.root:empty{height:var(--rs-badge-empty-size);min-height:auto;min-width:auto;padding:0;width:var(--rs-badge-empty-size)}.icon:only-child{margin-inline:calc(var(--rs-unit-x1) * -1)}.dismiss{border-radius:var(--rs-radius-small);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity}@media (hover:hover) and (pointer:fine){.root .dismiss:hover,.root.--actionable:hover:not(:has(.dismiss:hover)){opacity:.8}}.root.--variant-faded{background:var(--rs-color-background-neutral-faded);color:var(--rs-color-foreground-neutral-faded)}.root.--variant-outline{--rs-badge-border-color:var(--rs-color-border-neutral);background:none}.root.--color-positive{background:var(--rs-color-background-positive);color:var(--rs-color-on-background-positive)}.root.--color-positive.--variant-faded{background:var(--rs-color-background-positive-faded);color:var(--rs-color-foreground-positive)}.root.--color-positive.--variant-outline{--rs-badge-border-color:var(--rs-color-border-positive-faded);background:none;color:var(--rs-color-foreground-positive)}.root.--color-critical{background:var(--rs-color-background-critical);color:var(--rs-color-on-background-critical)}.root.--color-critical.--variant-faded{background:var(--rs-color-background-critical-faded);color:var(--rs-color-foreground-critical)}.root.--color-critical.--variant-outline{--rs-badge-border-color:var(--rs-color-border-critical-faded);background:none;color:var(--rs-color-foreground-critical)}.root.--color-warning{background:var(--rs-color-background-warning);color:var(--rs-color-on-background-warning)}.root.--color-warning.--variant-faded{background:var(--rs-color-background-warning-faded);color:var(--rs-color-foreground-warning)}.root.--color-warning.--variant-outline{--rs-badge-border-color:var(--rs-color-border-warning-faded);background:none;color:var(--rs-color-foreground-warning)}.root.--color-primary{background:var(--rs-color-background-primary);color:var(--rs-color-on-background-primary)}.root.--color-primary.--variant-faded{background:var(--rs-color-background-primary-faded);color:var(--rs-color-foreground-primary)}.root.--color-primary.--variant-outline{--rs-badge-border-color:var(--rs-color-border-primary-faded);background:none;color:var(--rs-color-foreground-primary)}.root.--size-small{--rs-badge-p-v:calc(var(--rs-unit-x1) / 2);--rs-badge-p-h:var(--rs-unit-x1);--rs-badge-line-height:var(--rs-line-height-caption-1);--rs-badge-empty-size:var(--rs-unit-x2);--rs-badge-gap:calc(var(--rs-unit-x1) / 2)}.root.--size-medium{--rs-badge-p-v:var(--rs-unit-x1);--rs-badge-p-h:var(--rs-unit-x2);--rs-badge-line-height:var(--rs-line-height-caption-1);--rs-badge-empty-size:var(--rs-unit-x3);--rs-badge-gap:var(--rs-unit-x1)}.root.--size-large{--rs-badge-p-v:var(--rs-unit-x1);--rs-badge-p-h:var(--rs-unit-x2);--rs-badge-line-height:var(--rs-line-height-body-3);--rs-badge-empty-size:var(--rs-unit-x4);--rs-badge-gap:var(--rs-unit-x1)}.root.--rounded{border-radius:var(--rs-radius-circular)}.root.--hidden{opacity:0;transform:scale(.2)}.container{display:inline-block;position:relative;vertical-align:top}.container .root{inset-inline-end:0;pointer-events:none;position:absolute;transform:translate(50%,var(--rs-badge-translate-y)) scale(1);z-index:10}.container .root.--hidden{transform:translate(50%,var(--rs-badge-translate-y)) scale(.2)}[dir=rtl] .container .root{transform:translate(-50%,var(--rs-badge-translate-y)) scale(1)}[dir=rtl] .container .root.--hidden{transform:translate(-50%,var(--rs-badge-translate-y)) scale(.2)}.--container-overlap .root{inset-inline-end:14%}.--container-position-top-end .root{--rs-badge-translate-y:-50%;top:0}.--container-position-top-end.--container-overlap .root{top:14%}.--container-position-bottom-end .root{--rs-badge-translate-y:50%;bottom:0}.--container-position-bottom-end.--container-overlap .root{bottom:14%}
|
@@ -42,3 +42,8 @@ export declare const container: {
|
|
42
42
|
name: string;
|
43
43
|
render: () => React.JSX.Element;
|
44
44
|
};
|
45
|
+
export declare const href: StoryObj;
|
46
|
+
export declare const onClick: StoryObj<{
|
47
|
+
handleClick: ReturnType<typeof fn>;
|
48
|
+
}>;
|
49
|
+
export declare const className: StoryObj;
|
@@ -282,3 +282,37 @@ export const container = {
|
|
282
282
|
</Example>);
|
283
283
|
},
|
284
284
|
};
|
285
|
+
export const href = {
|
286
|
+
name: "href",
|
287
|
+
render: () => (<Badge href="https://reshaped.so" dismissAriaLabel="Dismiss">
|
288
|
+
Badge
|
289
|
+
</Badge>),
|
290
|
+
play: async ({ canvas }) => {
|
291
|
+
const link = canvas.getByRole("link");
|
292
|
+
expect(link).toHaveAttribute("href", "https://reshaped.so");
|
293
|
+
},
|
294
|
+
};
|
295
|
+
export const onClick = {
|
296
|
+
name: "onClick",
|
297
|
+
args: {
|
298
|
+
handleClick: fn(),
|
299
|
+
},
|
300
|
+
render: (args) => <Badge onClick={args.handleClick}>Badge</Badge>,
|
301
|
+
play: async ({ canvas, args }) => {
|
302
|
+
const button = canvas.getAllByRole("button")[0];
|
303
|
+
await userEvent.click(button);
|
304
|
+
expect(args.handleClick).toHaveBeenCalledTimes(1);
|
305
|
+
expect(args.handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: button }));
|
306
|
+
},
|
307
|
+
};
|
308
|
+
export const className = {
|
309
|
+
name: "className, attributes",
|
310
|
+
render: () => (<div data-testid="root">
|
311
|
+
<Badge color="primary" className="test-classname" attributes={{ id: "test-id" }}/>
|
312
|
+
</div>),
|
313
|
+
play: async ({ canvas }) => {
|
314
|
+
const root = canvas.getByTestId("root").firstChild;
|
315
|
+
expect(root).toHaveClass("test-classname");
|
316
|
+
expect(root).toHaveAttribute("id", "test-id");
|
317
|
+
},
|
318
|
+
};
|
@@ -27,6 +27,7 @@ const Breadcrumbs = (props) => {
|
|
27
27
|
const isAfterCollapse = renderIndex > lastCollapsedIndex;
|
28
28
|
const isDisplayed = !visibleItems || isBeforeCollapse || isAfterCollapse || expanded;
|
29
29
|
const isCollapseButton = renderIndex === lastCollapsedIndex;
|
30
|
+
// eslint-disable-next-line react-hooks/immutability
|
30
31
|
renderIndex += 1;
|
31
32
|
let itemNode = null;
|
32
33
|
if (isDisplayed) {
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { fn } from "storybook/test";
|
2
|
+
import { StoryObj } from "@storybook/react-vite";
|
1
3
|
declare const _default: {
|
2
4
|
title: string;
|
3
5
|
component: import("react").FC<import("./..").BreadcrumbsProps> & {
|
@@ -26,11 +28,13 @@ export declare const slots: {
|
|
26
28
|
name: string;
|
27
29
|
render: () => import("react").JSX.Element;
|
28
30
|
};
|
29
|
-
export declare const collapsed:
|
30
|
-
name: string;
|
31
|
-
render: () => import("react").JSX.Element;
|
32
|
-
};
|
31
|
+
export declare const collapsed: StoryObj;
|
33
32
|
export declare const multiline: {
|
34
33
|
name: string;
|
35
34
|
render: () => import("react").JSX.Element;
|
36
35
|
};
|
36
|
+
export declare const onClick: StoryObj<{
|
37
|
+
handleClick: ReturnType<typeof fn>;
|
38
|
+
}>;
|
39
|
+
export declare const href: StoryObj;
|
40
|
+
export declare const className: StoryObj;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { expect, fn, userEvent } from "storybook/test";
|
1
2
|
import { Example } from "../../../utilities/storybook/index.js";
|
2
3
|
import Breadcrumbs from "../index.js";
|
3
4
|
import Badge from "../../Badge/index.js";
|
@@ -84,7 +85,7 @@ export const slots = {
|
|
84
85
|
</Example>),
|
85
86
|
};
|
86
87
|
export const collapsed = {
|
87
|
-
name: "
|
88
|
+
name: "collapsed",
|
88
89
|
render: () => (<Example>
|
89
90
|
<Example.Item title="collapsed, 3 items shown by default">
|
90
91
|
<Breadcrumbs defaultVisibleItems={3} ariaLabel="breadcrumbs one" expandAriaLabel="Expand items">
|
@@ -116,6 +117,18 @@ export const collapsed = {
|
|
116
117
|
</Breadcrumbs>
|
117
118
|
</Example.Item>
|
118
119
|
</Example>),
|
120
|
+
play: async ({ canvas }) => {
|
121
|
+
let triggers = canvas.getAllByRole("button");
|
122
|
+
expect(triggers[0]).toHaveTextContent("Item 1");
|
123
|
+
expect(triggers[1]).toHaveAccessibleName("Expand items");
|
124
|
+
expect(triggers[2]).toHaveTextContent("Item 4");
|
125
|
+
await userEvent.click(triggers[1]);
|
126
|
+
triggers = canvas.getAllByRole("button");
|
127
|
+
expect(triggers[0]).toHaveTextContent("Item 1");
|
128
|
+
expect(triggers[1]).toHaveTextContent("Item 2");
|
129
|
+
expect(triggers[2]).toHaveTextContent("Item 3");
|
130
|
+
expect(triggers[3]).toHaveTextContent("Item 4");
|
131
|
+
},
|
119
132
|
};
|
120
133
|
export const multiline = {
|
121
134
|
name: "composition, multiline",
|
@@ -129,3 +142,46 @@ export const multiline = {
|
|
129
142
|
</Example.Item>
|
130
143
|
</Example>),
|
131
144
|
};
|
145
|
+
export const onClick = {
|
146
|
+
name: "item, onClick, disabled",
|
147
|
+
args: {
|
148
|
+
handleClick: fn(),
|
149
|
+
},
|
150
|
+
render: (args) => (<Breadcrumbs>
|
151
|
+
<Breadcrumbs.Item onClick={args.handleClick}>Trigger</Breadcrumbs.Item>
|
152
|
+
<Breadcrumbs.Item onClick={args.handleClick} disabled>
|
153
|
+
Trigger
|
154
|
+
</Breadcrumbs.Item>
|
155
|
+
</Breadcrumbs>),
|
156
|
+
play: async ({ args, canvas }) => {
|
157
|
+
const triggers = canvas.getAllByRole("button");
|
158
|
+
await userEvent.click(triggers[0]);
|
159
|
+
expect(args.handleClick).toHaveBeenCalledTimes(1);
|
160
|
+
expect(args.handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: triggers[0] }));
|
161
|
+
await userEvent.click(triggers[1]);
|
162
|
+
expect(args.handleClick).toHaveBeenCalledTimes(1);
|
163
|
+
},
|
164
|
+
};
|
165
|
+
export const href = {
|
166
|
+
name: "item, href",
|
167
|
+
render: () => (<Breadcrumbs>
|
168
|
+
<Breadcrumbs.Item href="https://reshaped.so">Trigger</Breadcrumbs.Item>
|
169
|
+
</Breadcrumbs>),
|
170
|
+
play: async ({ canvas }) => {
|
171
|
+
const triggers = canvas.getAllByRole("link");
|
172
|
+
expect(triggers[0]).toHaveAttribute("href", "https://reshaped.so");
|
173
|
+
},
|
174
|
+
};
|
175
|
+
export const className = {
|
176
|
+
name: "className, attributes",
|
177
|
+
render: () => (<div data-testid="root">
|
178
|
+
<Breadcrumbs className="test-classname" attributes={{ id: "test-id" }}>
|
179
|
+
<Breadcrumbs.Item>Trigger</Breadcrumbs.Item>
|
180
|
+
</Breadcrumbs>
|
181
|
+
</div>),
|
182
|
+
play: async ({ canvas }) => {
|
183
|
+
const root = canvas.getByTestId("root").firstChild;
|
184
|
+
expect(root).toHaveClass("test-classname");
|
185
|
+
expect(root).toHaveAttribute("id", "test-id");
|
186
|
+
},
|
187
|
+
};
|
@@ -8,7 +8,7 @@ import ButtonGroup from "./ButtonGroup.js";
|
|
8
8
|
import ButtonAligner from "./ButtonAligner.js";
|
9
9
|
import s from "./Button.module.css";
|
10
10
|
const Button = forwardRef((props, ref) => {
|
11
|
-
const { variant = "solid", color = "neutral", elevated, highlighted, fullWidth, loading, loadingAriaLabel, disabled, type, href, size = "medium", children, rounded, onClick, icon, endIcon, stopPropagation, as, className, attributes, } = props;
|
11
|
+
const { variant = "solid", color = "neutral", elevated, highlighted, fullWidth, loading, loadingAriaLabel, disabled, type, href, size = "medium", children, rounded, onClick, icon, endIcon, stopPropagation, as, render, className, attributes, } = props;
|
12
12
|
const iconOnly = (icon || endIcon) && !children;
|
13
13
|
const rootClassName = classNames(s.root, className, color && s[`--color-${color}`], variant && s[`--variant-${variant}`], responsiveClassNames(s, "--size", size), responsiveClassNames(s, "--full-width", fullWidth), elevated && variant !== "ghost" && s["--elevated"], rounded && s["--rounded"], disabled && s["--disabled"], loading && s["--loading"], highlighted && s["--highlighted"], iconOnly && s["--icon-only"]);
|
14
14
|
const renderIcon = (position) => {
|
@@ -30,7 +30,7 @@ const Button = forwardRef((props, ref) => {
|
|
30
30
|
return (_jsxs(Actionable, { disabled: disabled || loading, className: rootClassName, attributes: {
|
31
31
|
...attributes,
|
32
32
|
"data-rs-aligner-target": true,
|
33
|
-
}, type: type, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, children: [loading && (_jsx("div", { className: s.loader, children: _jsx(Loader, { color: "inherit", attributes: { "aria-label": loadingAriaLabel } }) })), renderIcon("start"), children && _jsx("span", { className: s.text, children: children }), renderIcon("end")] }));
|
33
|
+
}, type: type, onClick: onClick, href: href, ref: ref, as: as, stopPropagation: stopPropagation, render: render, children: [loading && (_jsx("div", { className: s.loader, children: _jsx(Loader, { color: "inherit", attributes: { "aria-label": loadingAriaLabel } }) })), renderIcon("start"), children && _jsx("span", { className: s.text, children: children }), renderIcon("end")] }));
|
34
34
|
});
|
35
35
|
Button.Group = ButtonGroup;
|
36
36
|
Button.Aligner = ButtonAligner;
|
@@ -4,7 +4,7 @@ import type { ActionableProps, ActionableRef } from "../Actionable";
|
|
4
4
|
import type { AlignerProps as BaseAlignerProps } from "../_private/Aligner";
|
5
5
|
import type * as G from "../../types/global";
|
6
6
|
export type Size = "xlarge" | "large" | "medium" | "small";
|
7
|
-
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "as" | "stopPropagation"> & {
|
7
|
+
export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "as" | "stopPropagation" | "render"> & {
|
8
8
|
/** Component color scheme
|
9
9
|
* @default "neutral"
|
10
10
|
*/
|