reshaped 3.7.0-canary.9 → 3.7.0
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 +36 -1
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +1 -2
- package/dist/bundle.js +11 -11
- package/dist/cjs/themes/_generator/tokens/color/utilities/generateColors.js +1 -1
- package/dist/cjs/themes/_generator/tokens/css.js +2 -2
- package/dist/cjs/themes/figma/theme.css +1 -1
- package/dist/cjs/themes/fragments/twitter/theme.css +1 -1
- package/dist/cjs/themes/reshaped/theme.css +1 -1
- package/dist/cjs/themes/slate/theme.css +1 -1
- package/dist/components/Accordion/Accordion.types.d.ts +2 -0
- package/dist/components/ActionBar/ActionBar.js +12 -4
- package/dist/components/ActionBar/ActionBar.module.css +1 -1
- package/dist/components/ActionBar/ActionBar.types.d.ts +4 -1
- package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +19 -1
- package/dist/components/ActionBar/tests/ActionBar.stories.js +161 -3
- package/dist/components/Actionable/Actionable.js +3 -3
- package/dist/components/Actionable/Actionable.module.css +1 -1
- package/dist/components/Actionable/Actionable.types.d.ts +1 -0
- package/dist/components/Autocomplete/Autocomplete.js +66 -25
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +2 -0
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +8 -8
- package/dist/components/Avatar/Avatar.js +4 -4
- package/dist/components/Badge/Badge.js +3 -3
- package/dist/components/Badge/Badge.module.css +1 -1
- package/dist/components/Badge/Badge.types.d.ts +4 -4
- package/dist/components/Badge/tests/Badge.stories.js +11 -0
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Calendar/Calendar.types.d.ts +1 -0
- package/dist/components/Calendar/Calendar.utils.d.ts +11 -0
- package/dist/components/Calendar/Calendar.utils.js +25 -0
- package/dist/components/Calendar/CalendarDate.js +6 -2
- package/dist/components/Calendar/CalendarMonth.js +9 -23
- package/dist/components/Calendar/tests/Calendar.stories.js +9 -2
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/Card.js +9 -12
- package/dist/components/Card/Card.module.css +1 -1
- package/dist/components/Card/tests/Card.stories.d.ts +1 -1
- package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
- package/dist/components/Carousel/Carousel.js +3 -1
- package/dist/components/Carousel/Carousel.types.d.ts +1 -0
- package/dist/components/Carousel/CarouselControl.d.ts +1 -2
- package/dist/components/Carousel/CarouselControl.js +8 -7
- package/dist/components/Checkbox/Checkbox.module.css +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +9 -6
- package/dist/components/FileUpload/FileUpload.js +5 -3
- package/dist/components/FileUpload/FileUpload.module.css +1 -1
- package/dist/components/FileUpload/FileUpload.types.d.ts +5 -1
- package/dist/components/FileUpload/tests/FileUpload.stories.d.ts +18 -2
- package/dist/components/FileUpload/tests/FileUpload.stories.js +102 -23
- package/dist/components/Flyout/Flyout.module.css +1 -1
- package/dist/components/Flyout/Flyout.types.d.ts +2 -1
- package/dist/components/Flyout/FlyoutContent.js +3 -3
- package/dist/components/Flyout/FlyoutControlled.js +7 -3
- package/dist/components/Flyout/FlyoutTrigger.js +4 -3
- package/dist/components/FormControl/FormControl.module.css +1 -1
- package/dist/components/FormControl/tests/FormControl.stories.d.ts +4 -0
- package/dist/components/FormControl/tests/FormControl.stories.js +18 -0
- package/dist/components/Grid/Grid.js +5 -11
- package/dist/components/Grid/Grid.types.d.ts +2 -0
- package/dist/components/Grid/tests/Grid.stories.js +12 -1
- package/dist/components/HiddenVisually/HiddenVisually.module.css +1 -1
- package/dist/components/Icon/Icon.js +4 -4
- package/dist/components/Image/Image.js +4 -15
- 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 -0
- package/dist/components/Modal/Modal.js +4 -4
- package/dist/components/Modal/Modal.module.css +1 -1
- package/dist/components/Modal/tests/Modal.test.stories.js +2 -2
- package/dist/components/Overlay/tests/Overlay.test.stories.js +4 -2
- package/dist/components/PinField/PinField.module.css +1 -1
- package/dist/components/Popover/Popover.js +5 -5
- package/dist/components/Popover/Popover.module.css +1 -1
- package/dist/components/Popover/Popover.types.d.ts +1 -1
- package/dist/components/Popover/tests/Popover.stories.d.ts +1 -0
- package/dist/components/Popover/tests/Popover.stories.js +24 -4
- package/dist/components/ProgressIndicator/ProgressIndicator.module.css +1 -1
- package/dist/components/Reshaped/Reshaped.css +1 -1
- package/dist/components/Resizable/Resizable.module.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +5 -7
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/Select/Select.module.css +1 -1
- package/dist/components/Slider/Slider.module.css +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Switch/Switch.module.css +1 -1
- package/dist/components/Table/Table.js +4 -7
- package/dist/components/Tabs/TabsItem.js +2 -1
- package/dist/components/Tabs/TabsList.js +2 -2
- package/dist/components/Text/Text.js +4 -4
- package/dist/components/TextField/TextField.module.css +1 -1
- package/dist/components/TextField/tests/TextField.stories.js +3 -1
- package/dist/components/Theme/Theme.js +7 -2
- package/dist/components/Theme/Theme.types.d.ts +12 -13
- package/dist/components/Theme/index.d.ts +1 -1
- package/dist/components/Theme/tests/{Theme.test.stories.d.ts → Theme.stories.d.ts} +1 -0
- package/dist/components/Theme/tests/{Theme.test.stories.js → Theme.stories.js} +39 -1
- package/dist/components/Theme/useTheme.d.ts +6 -6
- package/dist/components/View/View.js +43 -60
- package/dist/components/View/View.module.css +1 -1
- package/dist/components/View/View.types.d.ts +7 -0
- package/dist/components/View/tests/View.stories.d.ts +4 -0
- package/dist/components/View/tests/View.stories.js +65 -1
- package/dist/components/_private/Portal/Portal.js +9 -1
- package/dist/config/tailwind.d.ts +1 -1
- package/dist/hooks/_private/useIsDismissible.js +11 -8
- package/dist/index.d.ts +1 -2
- package/dist/styles/mixin.d.ts +6 -0
- package/dist/styles/mixin.js +71 -0
- package/dist/styles/resolvers/align/align.css +1 -0
- package/dist/styles/resolvers/align/index.d.ts +4 -0
- package/dist/styles/resolvers/align/index.js +10 -0
- package/dist/styles/resolvers/aspectRatio/aspectRatio.css +1 -0
- package/dist/styles/resolvers/aspectRatio/index.d.ts +4 -0
- package/dist/styles/resolvers/aspectRatio/index.js +10 -0
- package/dist/styles/resolvers/bleed/bleed.module.css +1 -0
- package/dist/styles/resolvers/bleed/index.d.ts +3 -0
- package/dist/styles/{bleed → resolvers/bleed}/index.js +4 -4
- package/dist/styles/resolvers/border/border.module.css +1 -0
- package/dist/styles/resolvers/border/borderWidth.css +1 -0
- package/dist/styles/resolvers/border/index.d.ts +11 -0
- package/dist/styles/resolvers/border/index.js +74 -0
- package/dist/styles/resolvers/height/index.d.ts +3 -0
- package/dist/styles/{height → resolvers/height}/index.js +4 -4
- package/dist/styles/resolvers/inset/index.d.ts +10 -0
- package/dist/styles/resolvers/inset/index.js +38 -0
- package/dist/styles/resolvers/inset/inset.css +1 -0
- package/dist/styles/resolvers/justify/index.d.ts +4 -0
- package/dist/styles/resolvers/justify/index.js +10 -0
- package/dist/styles/resolvers/justify/justify.css +1 -0
- package/dist/styles/resolvers/margin/index.d.ts +10 -0
- package/dist/styles/resolvers/margin/index.js +38 -0
- package/dist/styles/resolvers/margin/margin.css +1 -0
- package/dist/styles/resolvers/maxHeight/index.d.ts +3 -0
- package/dist/styles/{maxHeight → resolvers/maxHeight}/index.js +4 -4
- package/dist/styles/resolvers/maxHeight/maxHeight.module.css +1 -0
- package/dist/styles/resolvers/maxWidth/index.d.ts +3 -0
- package/dist/styles/{maxWidth → resolvers/maxWidth}/index.js +4 -4
- package/dist/styles/resolvers/maxWidth/maxWidth.module.css +1 -0
- package/dist/styles/resolvers/minHeight/index.d.ts +3 -0
- package/dist/styles/{minHeight → resolvers/minHeight}/index.js +4 -4
- package/dist/styles/resolvers/minHeight/minHeight.module.css +1 -0
- package/dist/styles/resolvers/minWidth/index.d.ts +3 -0
- package/dist/styles/{minWidth → resolvers/minWidth}/index.js +4 -4
- package/dist/styles/resolvers/minWidth/minWidth.module.css +1 -0
- package/dist/styles/resolvers/padding/index.d.ts +10 -0
- package/dist/styles/resolvers/padding/index.js +38 -0
- package/dist/styles/resolvers/padding/padding.css +1 -0
- package/dist/styles/resolvers/position/index.d.ts +4 -0
- package/dist/styles/resolvers/position/index.js +9 -0
- package/dist/styles/resolvers/position/position.css +1 -0
- package/dist/styles/resolvers/radius/index.d.ts +3 -0
- package/dist/styles/resolvers/radius/index.js +10 -0
- package/dist/styles/resolvers/textAlign/index.d.ts +4 -0
- package/dist/styles/resolvers/textAlign/index.js +10 -0
- package/dist/styles/resolvers/textAlign/textAlign.css +1 -0
- package/dist/styles/resolvers/width/index.d.ts +3 -0
- package/dist/styles/{width → resolvers/width}/index.js +4 -4
- package/dist/styles/resolvers/width/width.module.css +1 -0
- package/dist/styles/types.d.ts +63 -16
- package/dist/themes/_generator/tokens/color/utilities/generateColors.js +1 -1
- package/dist/themes/_generator/tokens/css.js +2 -2
- package/dist/themes/figma/theme.css +1 -1
- package/dist/themes/fragments/twitter/theme.css +1 -1
- package/dist/themes/reshaped/theme.css +1 -1
- package/dist/themes/slate/theme.css +1 -1
- package/dist/types/global.d.ts +5 -0
- package/dist/utilities/a11y/tests/TrapFocus.stories.js +4 -4
- package/package.json +24 -24
- package/dist/components/ActionBar/tests/ActionBar.test.stories.d.ts +0 -15
- package/dist/components/ActionBar/tests/ActionBar.test.stories.js +0 -26
- package/dist/components/FileUpload/tests/FileUpload.test.stories.d.ts +0 -21
- package/dist/components/FileUpload/tests/FileUpload.test.stories.js +0 -52
- package/dist/styles/align/align.css +0 -1
- package/dist/styles/align/index.d.ts +0 -4
- package/dist/styles/align/index.js +0 -10
- package/dist/styles/aspectRatio/aspectRatio.css +0 -1
- package/dist/styles/aspectRatio/index.d.ts +0 -4
- package/dist/styles/aspectRatio/index.js +0 -9
- package/dist/styles/bleed/bleed.module.css +0 -1
- package/dist/styles/bleed/index.d.ts +0 -3
- package/dist/styles/border/border.module.css +0 -1
- package/dist/styles/border/index.d.ts +0 -3
- package/dist/styles/border/index.js +0 -10
- package/dist/styles/height/index.d.ts +0 -3
- package/dist/styles/inset/index.d.ts +0 -5
- package/dist/styles/inset/index.js +0 -11
- package/dist/styles/inset/inset.css +0 -1
- package/dist/styles/justify/index.d.ts +0 -4
- package/dist/styles/justify/index.js +0 -10
- package/dist/styles/justify/justify.css +0 -1
- package/dist/styles/maxHeight/index.d.ts +0 -3
- package/dist/styles/maxHeight/maxHeight.module.css +0 -1
- package/dist/styles/maxWidth/index.d.ts +0 -3
- package/dist/styles/maxWidth/maxWidth.module.css +0 -1
- package/dist/styles/minHeight/index.d.ts +0 -3
- package/dist/styles/minHeight/minHeight.module.css +0 -1
- package/dist/styles/minWidth/index.d.ts +0 -3
- package/dist/styles/minWidth/minWidth.module.css +0 -1
- package/dist/styles/padding/index.d.ts +0 -4
- package/dist/styles/padding/index.js +0 -9
- package/dist/styles/padding/padding.css +0 -1
- package/dist/styles/position/index.d.ts +0 -4
- package/dist/styles/position/index.js +0 -9
- package/dist/styles/position/position.css +0 -1
- package/dist/styles/radius/index.d.ts +0 -3
- package/dist/styles/radius/index.js +0 -10
- package/dist/styles/textAlign/index.d.ts +0 -4
- package/dist/styles/textAlign/index.js +0 -10
- package/dist/styles/textAlign/textAlign.css +0 -1
- package/dist/styles/width/index.d.ts +0 -3
- package/dist/styles/width/width.module.css +0 -1
- /package/dist/styles/{height → resolvers/height}/height.module.css +0 -0
- /package/dist/styles/{radius → resolvers/radius}/radius.module.css +0 -0
@@ -3,16 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
4
4
|
import TextField from "../TextField/index.js";
|
5
5
|
import DropdownMenu from "../DropdownMenu/index.js";
|
6
|
-
import { getActiveElement } from "../../utilities/a11y/index.js";
|
7
6
|
import * as keys from "../../constants/keys.js";
|
8
7
|
import useHotkeys from "../../hooks/useHotkeys.js";
|
9
8
|
import useHandlerRef from "../../hooks/useHandlerRef.js";
|
10
9
|
import s from "./Autocomplete.module.css";
|
10
|
+
import useElementId from "../../hooks/useElementId.js";
|
11
|
+
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
11
12
|
const AutocompleteContext = React.createContext({});
|
12
13
|
const Autocomplete = (props) => {
|
13
14
|
const { children, onChange, onInput, onItemSelect, name, containerRef, instanceRef, onBackspace, onEnter, active, onOpen, onClose, ...textFieldProps } = props;
|
15
|
+
const [highlightedId, setHighlightedId] = React.useState();
|
14
16
|
const onBackspaceRef = useHandlerRef(onBackspace);
|
15
|
-
const
|
17
|
+
const contentRef = React.useRef(null);
|
16
18
|
const internalInputRef = React.useRef(null);
|
17
19
|
const inputAttributesRef = textFieldProps.inputAttributes?.ref;
|
18
20
|
const inputRef = inputAttributesRef && typeof inputAttributesRef !== "string" && "current" in inputAttributesRef
|
@@ -23,15 +25,18 @@ const Autocomplete = (props) => {
|
|
23
25
|
const lockedRef = React.useRef(false);
|
24
26
|
const onOpenRef = useHandlerRef(onOpen);
|
25
27
|
const onCloseRef = useHandlerRef(onClose);
|
28
|
+
const onChangeRef = useHandlerRef(onChange);
|
29
|
+
const onItemSelectRef = useHandlerRef(onItemSelect);
|
30
|
+
const onEnterRef = useHandlerRef(onEnter);
|
26
31
|
const isDropdownActive = hasChildren && (active ?? internalActive);
|
27
|
-
const lockDropdown = () => {
|
32
|
+
const lockDropdown = React.useCallback(() => {
|
28
33
|
// Prevent dropdown from re-opening when clicked on item with mouse
|
29
34
|
// and focus moves to the item and back to the input
|
30
35
|
lockedRef.current = true;
|
31
36
|
setTimeout(() => {
|
32
37
|
lockedRef.current = false;
|
33
38
|
}, 100);
|
34
|
-
};
|
39
|
+
}, []);
|
35
40
|
const handleOpen = React.useCallback(() => {
|
36
41
|
if (lockedRef.current)
|
37
42
|
return;
|
@@ -42,11 +47,11 @@ const Autocomplete = (props) => {
|
|
42
47
|
setInternalActive(false);
|
43
48
|
onCloseRef.current?.(args);
|
44
49
|
};
|
45
|
-
const handleItemClick = (args) => {
|
46
|
-
|
47
|
-
|
50
|
+
const handleItemClick = React.useCallback((args) => {
|
51
|
+
onChangeRef.current?.({ value: args.value, name });
|
52
|
+
onItemSelectRef.current?.(args);
|
48
53
|
lockDropdown();
|
49
|
-
};
|
54
|
+
}, [lockDropdown, onChangeRef, onItemSelectRef, name]);
|
50
55
|
const handleChange = (args) => {
|
51
56
|
onChange?.(args);
|
52
57
|
handleOpen();
|
@@ -64,27 +69,56 @@ const Autocomplete = (props) => {
|
|
64
69
|
lockDropdown();
|
65
70
|
inputRef.current?.focus();
|
66
71
|
};
|
72
|
+
const getOptionElements = React.useCallback(() => {
|
73
|
+
const contentEl = contentRef.current;
|
74
|
+
if (!contentEl)
|
75
|
+
return [];
|
76
|
+
return Array.from(contentEl.querySelectorAll("[role=option]:not([disabled])"));
|
77
|
+
}, []);
|
67
78
|
useHotkeys({
|
79
|
+
[keys.ENTER]: () => {
|
80
|
+
const options = getOptionElements();
|
81
|
+
const highlightedOption = options.find((el) => el.id === highlightedId);
|
82
|
+
highlightedOption?.click();
|
83
|
+
onEnterRef.current?.();
|
84
|
+
},
|
68
85
|
[keys.BACKSPACE]: () => {
|
69
86
|
onBackspaceRef.current?.();
|
70
87
|
},
|
71
|
-
[keys.
|
72
|
-
|
88
|
+
[keys.UP]: () => {
|
89
|
+
const options = getOptionElements();
|
90
|
+
if (options.length) {
|
91
|
+
const highlightedIndex = options.findIndex((el) => el.id === highlightedId);
|
92
|
+
const nextOption = options.at(highlightedIndex - 1) || options.at(-1);
|
93
|
+
setHighlightedId(nextOption.id);
|
94
|
+
}
|
73
95
|
},
|
74
|
-
}, [onBackspaceRef, onEnterRef], {
|
75
|
-
ref: inputRef,
|
76
|
-
disabled: !onBackspaceRef.current && !onEnterRef.current,
|
77
|
-
});
|
78
|
-
useHotkeys({
|
79
96
|
[keys.DOWN]: () => {
|
80
97
|
handleOpen();
|
98
|
+
const options = getOptionElements();
|
99
|
+
if (options.length) {
|
100
|
+
const highlightedIndex = options.findIndex((el) => el.id === highlightedId);
|
101
|
+
const nextOption = options.at(highlightedIndex + 1) || options.at(0);
|
102
|
+
setHighlightedId(nextOption.id);
|
103
|
+
}
|
81
104
|
},
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
105
|
+
}, [handleOpen, getOptionElements, highlightedId], { ref: inputRef, preventDefault: true });
|
106
|
+
useIsomorphicLayoutEffect(() => {
|
107
|
+
if (!isDropdownActive)
|
108
|
+
return;
|
109
|
+
requestAnimationFrame(() => {
|
110
|
+
const options = getOptionElements();
|
111
|
+
const firstId = options[0]?.id;
|
112
|
+
if (firstId)
|
113
|
+
setHighlightedId(firstId);
|
114
|
+
});
|
115
|
+
}, [isDropdownActive]);
|
116
|
+
const contextValue = React.useMemo(() => ({
|
117
|
+
onItemClick: handleItemClick,
|
118
|
+
highlightedId,
|
119
|
+
setHighlightedId,
|
120
|
+
}), [highlightedId, handleItemClick]);
|
121
|
+
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: {
|
88
122
|
...textFieldProps.attributes,
|
89
123
|
// Ignoring the type check since TS can't infer the correct html element type
|
90
124
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -104,18 +138,25 @@ const Autocomplete = (props) => {
|
|
104
138
|
onClick: attributes.onFocus,
|
105
139
|
ref: inputRef,
|
106
140
|
role: "combobox",
|
107
|
-
|
141
|
+
"aria-activedescendant": highlightedId,
|
142
|
+
"aria-haspopup": "listbox",
|
143
|
+
"aria-autocomplete": "list",
|
144
|
+
} })) }), _jsx(DropdownMenu.Content, { attributes: { onClick: handleContentClick, role: "listbox", ref: contentRef }, children: children })] }) }));
|
108
145
|
};
|
109
146
|
const AutocompleteItem = (props) => {
|
110
|
-
const { value, data, onClick, ...menuItemProps } = props;
|
111
|
-
const { onItemClick } = React.useContext(AutocompleteContext);
|
147
|
+
const { value, data, onClick, disabled, ...menuItemProps } = props;
|
148
|
+
const { onItemClick, highlightedId } = React.useContext(AutocompleteContext);
|
149
|
+
const id = useElementId();
|
150
|
+
const highlighted = highlightedId === id;
|
112
151
|
const handleClick = (e) => {
|
113
152
|
onClick?.(e);
|
114
153
|
onItemClick({ value, data });
|
115
154
|
};
|
116
|
-
return (_jsx(DropdownMenu.Item, { ...menuItemProps, className: [
|
155
|
+
return (_jsx(DropdownMenu.Item, { ...menuItemProps, className: [disabled && s["item--disabled"], menuItemProps.className], highlighted: highlighted, disabled: disabled, attributes: {
|
117
156
|
...menuItemProps.attributes,
|
118
157
|
role: "option",
|
158
|
+
id,
|
159
|
+
tabIndex: highlighted ? 0 : -1,
|
119
160
|
}, onClick: handleClick }));
|
120
161
|
};
|
121
162
|
Autocomplete.Item = AutocompleteItem;
|
@@ -15,6 +15,8 @@ export type Props = TextFieldProps & Pick<DropdownMenuProps, "containerRef" | "i
|
|
15
15
|
export type ItemProps = MenuItemProps & SelectArgs;
|
16
16
|
export type Context = {
|
17
17
|
onItemClick: (args: SelectArgs) => void;
|
18
|
+
highlightedId?: string;
|
19
|
+
setHighlightedId: (value?: string) => void;
|
18
20
|
};
|
19
21
|
export type Instance = DropdownMenuInstance;
|
20
22
|
export {};
|
@@ -33,7 +33,7 @@ export const active = {
|
|
33
33
|
}} onClose={() => {
|
34
34
|
args.handleClose();
|
35
35
|
toggle.deactivate();
|
36
|
-
}}>
|
36
|
+
}} onChange={(args) => console.log(args)}>
|
37
37
|
{["Pizza", "Pie", "Ice-cream"].map((v, i) => {
|
38
38
|
return (<Autocomplete.Item key={v} value={v}>
|
39
39
|
{v}
|
@@ -46,7 +46,7 @@ export const active = {
|
|
46
46
|
},
|
47
47
|
play: async ({ canvasElement, args }) => {
|
48
48
|
const canvas = within(canvasElement.ownerDocument.body);
|
49
|
-
const input = canvas.getByRole("combobox");
|
49
|
+
// const input = canvas.getByRole("combobox");
|
50
50
|
const list = await canvas.findByRole("listbox");
|
51
51
|
expect(list).toBeInTheDocument();
|
52
52
|
expect(args.handleOpen).not.toHaveBeenCalled();
|
@@ -101,11 +101,11 @@ export const base = {
|
|
101
101
|
});
|
102
102
|
expect(options).toHaveLength(3);
|
103
103
|
await waitFor(() => {
|
104
|
-
expect(options[0]).toHaveAttribute("
|
104
|
+
expect(options[0]).toHaveAttribute("tabindex", "0");
|
105
105
|
});
|
106
|
-
expect(options[1]).
|
107
|
-
await userEvent.keyboard("{ArrowDown
|
108
|
-
await userEvent.keyboard("{Enter
|
106
|
+
expect(options[1]).toHaveAttribute("tabindex", "-1");
|
107
|
+
await userEvent.keyboard("{ArrowDown}");
|
108
|
+
await userEvent.keyboard("{Enter}");
|
109
109
|
expect(input).toHaveValue("Pie");
|
110
110
|
expect(args.handleItemSelect).toHaveBeenCalledTimes(1);
|
111
111
|
expect(args.handleItemSelect).toHaveBeenCalledWith({
|
@@ -115,7 +115,7 @@ export const base = {
|
|
115
115
|
// Give browser time to focus on the input
|
116
116
|
await sleep(100);
|
117
117
|
// Test click selection after opening with down arrow
|
118
|
-
await userEvent.keyboard("{ArrowDown
|
118
|
+
await userEvent.keyboard("{ArrowDown}");
|
119
119
|
await waitFor(() => {
|
120
120
|
options = canvas.getAllByRole("option");
|
121
121
|
});
|
@@ -126,7 +126,7 @@ export const base = {
|
|
126
126
|
value: "Pizza",
|
127
127
|
});
|
128
128
|
input.focus();
|
129
|
-
await userEvent.keyboard("{Backspace
|
129
|
+
await userEvent.keyboard("{Backspace}");
|
130
130
|
await waitFor(() => {
|
131
131
|
expect(args.handleBackspace).toHaveBeenCalledTimes(1);
|
132
132
|
expect(args.handleBackspace).toHaveBeenCalledWith();
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import { classNames, responsivePropDependency } from "../../utilities/props.js";
|
3
|
-
import
|
3
|
+
import { resolveMixin } from "../../styles/mixin.js";
|
4
4
|
import Icon from "../Icon/index.js";
|
5
5
|
import View from "../View/index.js";
|
6
6
|
import s from "./Avatar.module.css";
|
@@ -16,8 +16,8 @@ const Avatar = (props) => {
|
|
16
16
|
return "small";
|
17
17
|
})
|
18
18
|
: "circular";
|
19
|
-
const
|
20
|
-
const rootClassNames = classNames(s.root, className,
|
19
|
+
const mixinStyles = resolveMixin({ height: size });
|
20
|
+
const rootClassNames = classNames(s.root, className, mixinStyles?.classNames, color && s[`--color-${color}`], variant && s[`--variant-${variant}`]);
|
21
21
|
const renderContent = () => {
|
22
22
|
if (src) {
|
23
23
|
/**
|
@@ -39,7 +39,7 @@ const Avatar = (props) => {
|
|
39
39
|
}
|
40
40
|
return initials;
|
41
41
|
};
|
42
|
-
return (_jsx(View, { borderRadius: radius, attributes: { ...attributes, style: { ...
|
42
|
+
return (_jsx(View, { borderRadius: radius, attributes: { ...attributes, style: { ...mixinStyles?.variables } }, backgroundColor: variant === "faded" ? `${color}-${variant}` : color, className: rootClassNames, children: renderContent() }));
|
43
43
|
};
|
44
44
|
Avatar.displayName = "Avatar";
|
45
45
|
export default Avatar;
|
@@ -10,15 +10,15 @@ import { forwardRef } from "react";
|
|
10
10
|
const Badge = forwardRef((props, ref) => {
|
11
11
|
const { children, color, rounded, size = "medium", icon, endIcon, variant, hidden, href, onClick, onDismiss, dismissAriaLabel, className, attributes, } = props;
|
12
12
|
const isActionable = !!(onClick || href);
|
13
|
-
const iconSize = size === "
|
13
|
+
const iconSize = size === "small" ? 3 : 4;
|
14
14
|
const rootClassName = classNames(s.root, className, rounded && s["--rounded"], hidden && s["--hidden"], size && s[`--size-${size}`], color && s[`--color-${color}`], variant && s[`--variant-${variant}`], isActionable && s["--actionable"]);
|
15
15
|
const hnadleDismiss = (e) => {
|
16
16
|
e.stopPropagation();
|
17
17
|
onDismiss?.();
|
18
18
|
};
|
19
|
-
return (_jsxs(Actionable, { onClick: onClick, href: href, className: rootClassName, attributes: attributes, ref: ref, children: [icon && _jsx(Icon, { svg: icon, autoWidth: true, size: iconSize }), children && (_jsx(Text, { variant: size === "large" ? "body-3" : "caption-1", weight: "medium", attributes: {
|
19
|
+
return (_jsxs(Actionable, { onClick: onClick, href: href, className: rootClassName, attributes: attributes, ref: ref, touchHitbox: true, children: [icon && _jsx(Icon, { svg: icon, autoWidth: true, size: iconSize, className: s.icon }), children && (_jsx(Text, { variant: size === "large" ? "body-3" : "caption-1", weight: "medium", attributes: {
|
20
20
|
"aria-hidden": hidden ? "true" : undefined,
|
21
|
-
}, children: children })), endIcon && _jsx(Icon, { svg: endIcon, autoWidth: true, size: iconSize }), onDismiss && (_jsx(Actionable, { onClick: hnadleDismiss, className: s.dismiss, as: "span", attributes: { "aria-label": dismissAriaLabel }, children: _jsx(Icon, { svg: IconClose, size: iconSize }) }))] }));
|
21
|
+
}, children: children })), endIcon && _jsx(Icon, { svg: endIcon, autoWidth: true, size: iconSize, className: s.icon }), onDismiss && (_jsx(Actionable, { onClick: hnadleDismiss, className: s.dismiss, as: "span", attributes: { "aria-label": dismissAriaLabel }, touchHitbox: true, children: _jsx(Icon, { svg: IconClose, size: iconSize }) }))] }));
|
22
22
|
});
|
23
23
|
Badge.Container = BadgeContainer;
|
24
24
|
Badge.displayName = "Badge";
|
@@ -1 +1 @@
|
|
1
|
-
.root{align-items:center;backface-visibility:hidden;background:var(--rs-color-background-neutral);border:1px solid transparent;box-sizing:border-box;color:var(--rs-color-foreground-neutral);display:inline-flex;gap:var(--rs-badge-gap);justify-content:center;min-width:calc(var(--rs-badge-line-height) + 2px + (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}.
|
1
|
+
.root{align-items:center;backface-visibility:hidden;background:var(--rs-color-background-neutral);border:1px solid transparent;border-radius:var(--rs-radius-small);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) + 2px + (var(--rs-badge-p-v) * 2));min-width:calc(var(--rs-badge-line-height) + 2px + (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{background:none;border-color:var(--rs-color-border-neutral)}.root.--color-positive{background:var(--rs-color-background-positive);border-color:var(--rs-color-background-positive);color:var(--rs-color-on-background-positive)}.root.--color-positive.--variant-faded{background:var(--rs-color-background-positive-faded);border-color:var(--rs-color-background-positive-faded);color:var(--rs-color-foreground-positive)}.root.--color-positive.--variant-outline{background:none;border-color:var(--rs-color-border-positive-faded);color:var(--rs-color-foreground-positive)}.root.--color-critical{background:var(--rs-color-background-critical);border-color:var(--rs-color-background-critical);color:var(--rs-color-on-background-critical)}.root.--color-critical.--variant-faded{background:var(--rs-color-background-critical-faded);border-color:var(--rs-color-background-critical-faded);color:var(--rs-color-foreground-critical)}.root.--color-critical.--variant-outline{background:none;border-color:var(--rs-color-border-critical-faded);color:var(--rs-color-foreground-critical)}.root.--color-warning{background:var(--rs-color-background-warning);border-color:var(--rs-color-background-warning);color:var(--rs-color-on-background-warning)}.root.--color-warning.--variant-faded{background:var(--rs-color-background-warning-faded);border-color:var(--rs-color-background-warning-faded);color:var(--rs-color-foreground-warning)}.root.--color-warning.--variant-outline{background:none;border-color:var(--rs-color-border-warning-faded);color:var(--rs-color-foreground-warning)}.root.--color-primary{background:var(--rs-color-background-primary);border-color:var(--rs-color-background-primary);color:var(--rs-color-on-background-primary)}.root.--color-primary.--variant-faded{background:var(--rs-color-background-primary-faded);border-color:var(--rs-color-background-primary-faded);color:var(--rs-color-foreground-primary)}.root.--color-primary.--variant-outline{background:none;border-color:var(--rs-color-border-primary-faded);color:var(--rs-color-foreground-primary)}.root.--size-small{--rs-badge-p-v:1px;--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:calc(var(--rs-unit-x1) - 1px);--rs-badge-p-h:calc(var(--rs-unit-x2) - 1px);--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:calc(var(--rs-unit-x1) - 1px);--rs-badge-p-h:calc(var(--rs-unit-x2) - 1px);--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%}
|
@@ -3,21 +3,21 @@ import type { ActionableProps, ActionableRef } from "../Actionable";
|
|
3
3
|
import type { IconProps } from "../Icon";
|
4
4
|
import type * as G from "../../types/global";
|
5
5
|
type BaseProps = {
|
6
|
+
color?: "neutral" | "critical" | "warning" | "positive" | "primary";
|
6
7
|
size?: "small" | "medium" | "large";
|
7
|
-
icon?: IconProps["svg"];
|
8
8
|
endIcon?: IconProps["svg"];
|
9
9
|
rounded?: boolean;
|
10
10
|
hidden?: boolean;
|
11
11
|
className?: G.ClassName;
|
12
12
|
} & Pick<ActionableProps, "href" | "onClick" | "attributes">;
|
13
13
|
type WithChildren = BaseProps & {
|
14
|
-
children
|
15
|
-
|
14
|
+
children?: React.ReactNode;
|
15
|
+
icon?: IconProps["svg"];
|
16
16
|
variant?: "faded" | "outline";
|
17
17
|
};
|
18
18
|
type WithEmpty = BaseProps & {
|
19
|
-
color: "critical" | "warning" | "positive" | "primary";
|
20
19
|
children?: never;
|
20
|
+
icon?: never;
|
21
21
|
variant?: never;
|
22
22
|
};
|
23
23
|
type WithDismissible = {
|
@@ -119,6 +119,7 @@ export const icon = {
|
|
119
119
|
<Badge icon={IconCheckmark} endIcon={IconChevronRight} size="small">
|
120
120
|
Badge
|
121
121
|
</Badge>
|
122
|
+
<Badge icon={IconCheckmark} size="small"/>
|
122
123
|
</View>
|
123
124
|
</Example.Item>
|
124
125
|
<Example.Item title="size: medium">
|
@@ -126,6 +127,7 @@ export const icon = {
|
|
126
127
|
<Badge icon={IconCheckmark} endIcon={IconChevronRight}>
|
127
128
|
Badge
|
128
129
|
</Badge>
|
130
|
+
<Badge icon={IconCheckmark}/>
|
129
131
|
</View>
|
130
132
|
</Example.Item>
|
131
133
|
<Example.Item title="size: large">
|
@@ -133,6 +135,8 @@ export const icon = {
|
|
133
135
|
<Badge size="large" icon={IconCheckmark} endIcon={IconChevronRight}>
|
134
136
|
Badge
|
135
137
|
</Badge>
|
138
|
+
|
139
|
+
<Badge icon={IconCheckmark} size="large"/>
|
136
140
|
</View>
|
137
141
|
</Example.Item>
|
138
142
|
</Example>),
|
@@ -203,6 +207,13 @@ export const empty = {
|
|
203
207
|
<Badge rounded size="large" color="critical"/>
|
204
208
|
</View>
|
205
209
|
</Example.Item>
|
210
|
+
<Example.Item title="empty, rounded, all sizes, color: neutral">
|
211
|
+
<View direction="row" gap={3}>
|
212
|
+
<Badge rounded size="small" color="neutral"/>
|
213
|
+
<Badge rounded/>
|
214
|
+
<Badge rounded size="large"/>
|
215
|
+
</View>
|
216
|
+
</Example.Item>
|
206
217
|
</Example>),
|
207
218
|
};
|
208
219
|
export const container = {
|
@@ -1 +1 @@
|
|
1
|
-
.root{--rs-p-v:var(--rs-button-p-v);--rs-p-h:var(--rs-button-p-h);--rs-button-highlight-opacity:0;--rs-button-highlight-opacity-base:0;--rs-button-border-color:transparent;--rs-button-border-width:0px;align-items:center;border:var(--rs-button-border-width) solid var(--rs-button-border-color);border-radius:var(--rs-button-radius);box-sizing:border-box;cursor:pointer;display:inline-flex;justify-content:center;overflow:hidden;padding:calc(var(--rs-unit-x1) - var(--rs-button-border-width)) calc(var(--rs-p-h) - var(--rs-button-border-width));position:relative;text-align:initial;text-decoration:none;transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:background-color,box-shadow,border-color,color,transform;z-index:0;-webkit-tap-highlight-color:transparent;background-color:var(--rs-button-background-color);color:var(--rs-button-foreground-color);font-family:var(--rs-font-family-body);font-size:var(--rs-button-font-size);font-weight:var(--rs-font-weight-medium);letter-spacing:var(--rs-button-letter-spacing);line-height:var(--rs-button-line-height);min-height:calc(var(--rs-button-line-height) + var(--rs-p-v) * 2);min-width:calc(var(--rs-button-line-height) - (var(--rs-unit-x1) * 2) + (var(--rs-button-p-h) * 2))}.root:active{transform:scale(.98)}.root:before{background:var(--rs-button-highlight-color,var(--rs-button-foreground-color));content:"";inset:0;opacity:var(--rs-button-highlight-opacity-base);position:absolute;transform:translateZ(0);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity}@media (hover:hover) and (pointer:fine){.root:hover:not(.--loading,.--highlighted,.--disabled):before{opacity:var(--rs-button-highlight-opacity)}}.root.--highlighted:before{opacity:calc(var(--rs-button-highlight-opacity) + max(.04, var(--rs-button-highlight-opacity) / 2))}.text{align-items:center;display:flex;gap:var(--rs-button-gap)}.icon{margin-inline-end:var(--rs-button-gap)}.icon:last-child{margin-inline-end:0}.icon.--icon-position-end{margin-inline-end:0;margin-inline-start:var(--rs-button-gap)}.icon,.text{position:relative;z-index:5}.loader{align-items:center;display:none;inset:0;justify-content:center;position:absolute}.root.--icon-only .icon{margin:0 calc(var(--rs-unit-x1) * -1)}.root.--loading{cursor:default}.root.--loading:active{transform:none}.root.--loading .icon,.root.--loading .text{visibility:hidden}.root.--loading .loader{display:flex}.root.--rounded{border-radius:999px}.--size-small{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width{text-align:center;width:100%}.root.--variant-solid.--color-neutral{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-neutral);--rs-button-foreground-color:var(--rs-color-on-background-neutral)}.root.--variant-solid.--color-primary{--rs-button-highlight-opacity:0.08;--rs-button-background-color:var(--rs-color-background-primary);--rs-button-foreground-color:var(--rs-color-on-background-primary)}.root.--variant-solid.--color-critical{--rs-button-highlight-opacity:0.08;--rs-button-background-color:var(--rs-color-background-critical);--rs-button-foreground-color:var(--rs-color-on-background-critical)}.root.--variant-solid.--color-positive{--rs-button-highlight-opacity:0.08;--rs-button-background-color:var(--rs-color-background-positive);--rs-button-foreground-color:var(--rs-color-on-background-positive)}.root.--variant-solid.--color-media{--rs-button-highlight-opacity:0.06;--rs-button-background-color:var(--rs-color-white);--rs-button-foreground-color:var(--rs-color-black)}.root.--variant-faded.--color-neutral{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-neutral-faded);--rs-button-foreground-color:var(--rs-color-foreground-neutral)}.root.--variant-faded.--color-primary{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-primary-faded);--rs-button-foreground-color:var(--rs-color-foreground-primary)}.root.--variant-faded.--color-critical{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-critical-faded);--rs-button-foreground-color:var(--rs-color-foreground-critical)}.root.--variant-faded.--color-positive{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-positive-faded);--rs-button-foreground-color:var(--rs-color-foreground-positive)}.root.--variant-faded.--color-media{--rs-button-highlight-opacity-base:0.24;--rs-button-highlight-opacity:0.32;--rs-button-foreground-color:var(--rs-color-white);--rs-button-highlight-color:var(--rs-color-black)}.root.--variant-faded.--color-inherit{--rs-button-highlight-opacity-base:0.12;--rs-button-highlight-opacity:0.16;--rs-button-foreground-color:inherit;--rs-button-highlight-color:currentcolor}.root.--variant-outline{--rs-button-border-width:1px;--rs-button-highlight-opacity:0.06}.root.--variant-outline.--color-primary{--rs-button-foreground-color:var(--rs-color-foreground-primary);--rs-button-border-color:var(--rs-color-border-primary-faded);--rs-button-highlight-color:var(--rs-color-background-primary)}.root.--variant-outline.--color-critical{--rs-button-foreground-color:var(--rs-color-foreground-critical);--rs-button-border-color:var(--rs-color-border-critical-faded);--rs-button-highlight-color:var(--rs-color-background-critical)}.root.--variant-outline.--color-positive{--rs-button-foreground-color:var(--rs-color-foreground-positive);--rs-button-border-color:var(--rs-color-border-positive-faded);--rs-button-highlight-color:var(--rs-color-background-positive)}.root.--variant-outline.--color-neutral{--rs-button-highlight-opacity:0.24;--rs-button-foreground-color:var(--rs-color-foreground-neutral);--rs-button-border-color:var(--rs-color-border-neutral);--rs-button-highlight-color:var(--rs-color-background-neutral)}.root.--variant-outline.--color-inherit{--rs-button-border-width:0px;--rs-button-foreground-color:inherit;--rs-button-highlight-color:currentcolor}.root.--variant-outline.--color-inherit:after{border:1px solid;border-radius:var(--rs-button-radius);content:"";inset:0;opacity:.28;pointer-events:none;position:absolute}.root.--variant-ghost{--rs-button-highlight-opacity:0.12}.root.--variant-ghost.--color-neutral{--rs-button-highlight-opacity:0.32;--rs-button-foreground-color:var(--rs-color-foreground-neutral);--rs-button-highlight-color:var(--rs-color-background-neutral)}.root.--variant-ghost.--color-primary{--rs-button-foreground-color:var(--rs-color-foreground-primary);--rs-button-highlight-color:var(--rs-color-background-primary)}.root.--variant-ghost.--color-critical{--rs-button-foreground-color:var(--rs-color-foreground-critical);--rs-button-highlight-color:var(--rs-color-background-critical)}.root.--variant-ghost.--color-positive{--rs-button-foreground-color:var(--rs-color-foreground-positive);--rs-button-highlight-color:var(--rs-color-background-positive)}.root.--variant-ghost.--color-inherit{--rs-button-foreground-color:inherit;--rs-button-highlight-color:currentcolor}.root.--elevated:not(:focus),[data-rs-keyboard] .root.--elevated:not(:focus){box-shadow:var(--rs-shadow-raised)}.root.--elevated.--variant-outline.--color-critical,.root.--elevated.--variant-outline.--color-neutral,.root.--elevated.--variant-outline.--color-positive,.root.--elevated.--variant-outline.--color-primary{background:var(--rs-color-background-elevation-raised)}.root.--disabled:active{transform:none!important}.root.--disabled.--color-critical,.root.--disabled.--color-critical.--highlighted,.root.--disabled.--color-critical:hover,.root.--disabled.--color-inherit,.root.--disabled.--color-inherit.--highlighted,.root.--disabled.--color-inherit:hover,.root.--disabled.--color-neutral,.root.--disabled.--color-neutral.--highlighted,.root.--disabled.--color-neutral:hover,.root.--disabled.--color-positive,.root.--disabled.--color-positive.--highlighted,.root.--disabled.--color-positive:hover,.root.--disabled.--color-primary,.root.--disabled.--color-primary.--highlighted,.root.--disabled.--color-primary:hover{background-color:var(--rs-color-background-disabled)!important;border-color:var(--rs-color-border-disabled)!important;color:var(--rs-color-foreground-disabled)!important}.root.--disabled.--color-critical.--highlighted:before,.root.--disabled.--color-critical:before,.root.--disabled.--color-critical:hover:before,.root.--disabled.--color-inherit.--highlighted:before,.root.--disabled.--color-inherit:before,.root.--disabled.--color-inherit:hover:before,.root.--disabled.--color-neutral.--highlighted:before,.root.--disabled.--color-neutral:before,.root.--disabled.--color-neutral:hover:before,.root.--disabled.--color-positive.--highlighted:before,.root.--disabled.--color-positive:before,.root.--disabled.--color-positive:hover:before,.root.--disabled.--color-primary.--highlighted:before,.root.--disabled.--color-primary:before,.root.--disabled.--color-primary:hover:before{opacity:0!important}.root.--disabled.--color-critical.--highlighted.--variant-faded,.root.--disabled.--color-critical.--variant-faded,.root.--disabled.--color-critical:hover.--variant-faded,.root.--disabled.--color-inherit.--highlighted.--variant-faded,.root.--disabled.--color-inherit.--variant-faded,.root.--disabled.--color-inherit:hover.--variant-faded,.root.--disabled.--color-neutral.--highlighted.--variant-faded,.root.--disabled.--color-neutral.--variant-faded,.root.--disabled.--color-neutral:hover.--variant-faded,.root.--disabled.--color-positive.--highlighted.--variant-faded,.root.--disabled.--color-positive.--variant-faded,.root.--disabled.--color-positive:hover.--variant-faded,.root.--disabled.--color-primary.--highlighted.--variant-faded,.root.--disabled.--color-primary.--variant-faded,.root.--disabled.--color-primary:hover.--variant-faded{background-color:var(--rs-color-background-disabled-faded)!important}.root.--disabled.--color-critical.--highlighted.--variant-outline,.root.--disabled.--color-critical.--variant-outline,.root.--disabled.--color-critical:hover.--variant-outline,.root.--disabled.--color-inherit.--highlighted.--variant-outline,.root.--disabled.--color-inherit.--variant-outline,.root.--disabled.--color-inherit:hover.--variant-outline,.root.--disabled.--color-neutral.--highlighted.--variant-outline,.root.--disabled.--color-neutral.--variant-outline,.root.--disabled.--color-neutral:hover.--variant-outline,.root.--disabled.--color-positive.--highlighted.--variant-outline,.root.--disabled.--color-positive.--variant-outline,.root.--disabled.--color-positive:hover.--variant-outline,.root.--disabled.--color-primary.--highlighted.--variant-outline,.root.--disabled.--color-primary.--variant-outline,.root.--disabled.--color-primary:hover.--variant-outline{background-color:transparent!important}.root.--disabled.--color-critical.--highlighted.--variant-ghost,.root.--disabled.--color-critical.--variant-ghost,.root.--disabled.--color-critical:hover.--variant-ghost,.root.--disabled.--color-inherit.--highlighted.--variant-ghost,.root.--disabled.--color-inherit.--variant-ghost,.root.--disabled.--color-inherit:hover.--variant-ghost,.root.--disabled.--color-neutral.--highlighted.--variant-ghost,.root.--disabled.--color-neutral.--variant-ghost,.root.--disabled.--color-neutral:hover.--variant-ghost,.root.--disabled.--color-positive.--highlighted.--variant-ghost,.root.--disabled.--color-positive.--variant-ghost,.root.--disabled.--color-positive:hover.--variant-ghost,.root.--disabled.--color-primary.--highlighted.--variant-ghost,.root.--disabled.--color-primary.--variant-ghost,.root.--disabled.--color-primary:hover.--variant-ghost{background-color:transparent!important;border-color:transparent!important}.root.--disabled.--color-media,.root.--disabled.--color-media.--highlighted,.root.--disabled.--color-media:hover{opacity:.4!important}.group .root{border-radius:0}.group .root:first-child{border-end-start-radius:var(--rs-button-radius);border-start-start-radius:var(--rs-button-radius)}.group .root:not(:first-child){border-inline-start:1px solid var(--rs-button-group-separator-color)}.group .root:last-child{border-end-end-radius:var(--rs-button-radius);border-start-end-radius:var(--rs-button-radius)}.group .root.--variant-solid.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral)}.group .root.--variant-ghost.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral-faded)}.group .root.--variant-solid.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive)}.group .root.--variant-ghost.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-solid.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical)}.group .root.--variant-ghost.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-solid.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary)}.group .root.--variant-ghost.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-faded.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-faded.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-faded.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-solid.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.group .root.--variant-faded.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.14)}.group .root.--variant-faded.--color-white,.group .root.--variant-ghost.--color-black,.group .root.--variant-solid.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-black),0.2)}.group .root.--variant-ghost.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.aligner{line-height:0}@media (--rs-viewport-m ){.--size-small--m{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--m{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--m{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--m{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--m{text-align:center;width:100%}.--full-width-false--m{text-align:initial;width:auto}}@media (--rs-viewport-l ){.--size-small--l{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--l{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--l{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--l{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--l{text-align:center;width:100%}.--full-width-false--l{text-align:initial;width:auto}}@media (--rs-viewport-xl ){.--size-small--xl{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--xl{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--xl{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--xl{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--xl{text-align:center;width:100%}.--full-width-false--xl{text-align:initial;width:auto}}
|
1
|
+
.root{--rs-p-v:var(--rs-button-p-v);--rs-p-h:var(--rs-button-p-h);--rs-button-highlight-opacity:0;--rs-button-highlight-opacity-base:0;--rs-button-border-color:transparent;--rs-button-border-width:0px;align-items:center;border:var(--rs-button-border-width) solid var(--rs-button-border-color);border-radius:var(--rs-button-radius);box-sizing:border-box;cursor:pointer;display:inline-flex;justify-content:center;overflow:hidden;padding:calc(var(--rs-unit-x1) - var(--rs-button-border-width)) calc(var(--rs-p-h) - var(--rs-button-border-width));position:relative;text-align:initial;text-decoration:none;transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:background-color,box-shadow,border-color,color,transform;z-index:0;-webkit-tap-highlight-color:transparent;background-color:var(--rs-button-background-color);color:var(--rs-button-foreground-color);font-family:var(--rs-font-family-body);font-size:var(--rs-button-font-size);font-weight:var(--rs-font-weight-medium);letter-spacing:var(--rs-button-letter-spacing);line-height:var(--rs-button-line-height);min-height:calc(var(--rs-button-line-height) + var(--rs-p-v) * 2);min-width:calc(var(--rs-button-line-height) - (var(--rs-unit-x1) * 2) + (var(--rs-button-p-h) * 2))}.root:before{background:var(--rs-button-highlight-color,var(--rs-button-foreground-color));content:"";inset:0;opacity:var(--rs-button-highlight-opacity-base);position:absolute;transform:translateZ(0);transition:var(--rs-duration-fast) var(--rs-easing-standard);transition-property:opacity}@media (hover:hover) and (pointer:fine){.root:hover:not(.--loading,.--highlighted,.--disabled,:active):before{opacity:var(--rs-button-highlight-opacity)}}.root.--highlighted:before,.root:active:not(.--loading,.--disabled):before{opacity:calc(var(--rs-button-highlight-opacity) + max(.04, var(--rs-button-highlight-opacity) / 2))}.text{align-items:center;display:flex;gap:var(--rs-button-gap)}.icon{margin-inline-end:var(--rs-button-gap)}.icon:last-child{margin-inline-end:0}.icon.--icon-position-end{margin-inline-end:0;margin-inline-start:var(--rs-button-gap)}.icon,.text{position:relative;z-index:5}.loader{align-items:center;display:none;inset:0;justify-content:center;position:absolute}.root.--icon-only .icon{margin:0 calc(var(--rs-unit-x1) * -1)}.root.--loading{cursor:default}.root.--loading .icon,.root.--loading .text{visibility:hidden}.root.--loading .loader{display:flex}.root.--rounded{border-radius:var(--rs-radius-circular)}.--size-small{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width{text-align:center;width:100%}.root.--variant-solid.--color-neutral{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-neutral);--rs-button-foreground-color:var(--rs-color-on-background-neutral)}.root.--variant-solid.--color-primary{--rs-button-highlight-opacity:0.08;--rs-button-background-color:var(--rs-color-background-primary);--rs-button-foreground-color:var(--rs-color-on-background-primary)}.root.--variant-solid.--color-critical{--rs-button-highlight-opacity:0.08;--rs-button-background-color:var(--rs-color-background-critical);--rs-button-foreground-color:var(--rs-color-on-background-critical)}.root.--variant-solid.--color-positive{--rs-button-highlight-opacity:0.08;--rs-button-background-color:var(--rs-color-background-positive);--rs-button-foreground-color:var(--rs-color-on-background-positive)}.root.--variant-solid.--color-media{--rs-button-highlight-opacity:0.06;--rs-button-background-color:var(--rs-color-white);--rs-button-foreground-color:var(--rs-color-black)}.root.--variant-faded.--color-neutral{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-neutral-faded);--rs-button-foreground-color:var(--rs-color-foreground-neutral)}.root.--variant-faded.--color-primary{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-primary-faded);--rs-button-foreground-color:var(--rs-color-foreground-primary)}.root.--variant-faded.--color-critical{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-critical-faded);--rs-button-foreground-color:var(--rs-color-foreground-critical)}.root.--variant-faded.--color-positive{--rs-button-highlight-opacity:0.04;--rs-button-background-color:var(--rs-color-background-positive-faded);--rs-button-foreground-color:var(--rs-color-foreground-positive)}.root.--variant-faded.--color-media{--rs-button-highlight-opacity-base:0.24;--rs-button-highlight-opacity:0.32;--rs-button-foreground-color:var(--rs-color-white);--rs-button-highlight-color:var(--rs-color-black)}.root.--variant-faded.--color-inherit{--rs-button-highlight-opacity-base:0.12;--rs-button-highlight-opacity:0.16;--rs-button-foreground-color:inherit;--rs-button-highlight-color:currentcolor}.root.--variant-outline{--rs-button-border-width:1px;--rs-button-highlight-opacity:0.06}.root.--variant-outline.--color-primary{--rs-button-foreground-color:var(--rs-color-foreground-primary);--rs-button-border-color:var(--rs-color-border-primary-faded);--rs-button-highlight-color:var(--rs-color-background-primary)}.root.--variant-outline.--color-critical{--rs-button-foreground-color:var(--rs-color-foreground-critical);--rs-button-border-color:var(--rs-color-border-critical-faded);--rs-button-highlight-color:var(--rs-color-background-critical)}.root.--variant-outline.--color-positive{--rs-button-foreground-color:var(--rs-color-foreground-positive);--rs-button-border-color:var(--rs-color-border-positive-faded);--rs-button-highlight-color:var(--rs-color-background-positive)}.root.--variant-outline.--color-neutral{--rs-button-highlight-opacity:0.24;--rs-button-foreground-color:var(--rs-color-foreground-neutral);--rs-button-border-color:var(--rs-color-border-neutral);--rs-button-highlight-color:var(--rs-color-background-neutral)}.root.--variant-outline.--color-inherit{--rs-button-border-width:0px;--rs-button-foreground-color:inherit;--rs-button-highlight-color:currentcolor}.root.--variant-outline.--color-inherit:after{border:1px solid;border-radius:var(--rs-button-radius);content:"";inset:0;opacity:.28;pointer-events:none;position:absolute}.root.--variant-ghost{--rs-button-highlight-opacity:0.12}.root.--variant-ghost.--color-neutral{--rs-button-highlight-opacity:0.32;--rs-button-foreground-color:var(--rs-color-foreground-neutral);--rs-button-highlight-color:var(--rs-color-background-neutral)}.root.--variant-ghost.--color-primary{--rs-button-foreground-color:var(--rs-color-foreground-primary);--rs-button-highlight-color:var(--rs-color-background-primary)}.root.--variant-ghost.--color-critical{--rs-button-foreground-color:var(--rs-color-foreground-critical);--rs-button-highlight-color:var(--rs-color-background-critical)}.root.--variant-ghost.--color-positive{--rs-button-foreground-color:var(--rs-color-foreground-positive);--rs-button-highlight-color:var(--rs-color-background-positive)}.root.--variant-ghost.--color-inherit{--rs-button-foreground-color:inherit;--rs-button-highlight-color:currentcolor}.root.--elevated:not(:focus),[data-rs-keyboard] .root.--elevated:not(:focus){box-shadow:var(--rs-shadow-raised)}.root.--elevated.--variant-outline.--color-critical,.root.--elevated.--variant-outline.--color-neutral,.root.--elevated.--variant-outline.--color-positive,.root.--elevated.--variant-outline.--color-primary{background:var(--rs-color-background-elevation-raised)}.root.--disabled.--color-critical,.root.--disabled.--color-critical.--highlighted,.root.--disabled.--color-critical:active,.root.--disabled.--color-critical:hover,.root.--disabled.--color-inherit,.root.--disabled.--color-inherit.--highlighted,.root.--disabled.--color-inherit:active,.root.--disabled.--color-inherit:hover,.root.--disabled.--color-neutral,.root.--disabled.--color-neutral.--highlighted,.root.--disabled.--color-neutral:active,.root.--disabled.--color-neutral:hover,.root.--disabled.--color-positive,.root.--disabled.--color-positive.--highlighted,.root.--disabled.--color-positive:active,.root.--disabled.--color-positive:hover,.root.--disabled.--color-primary,.root.--disabled.--color-primary.--highlighted,.root.--disabled.--color-primary:active,.root.--disabled.--color-primary:hover{background-color:var(--rs-color-background-disabled)!important;border-color:var(--rs-color-border-disabled)!important;color:var(--rs-color-foreground-disabled)!important}.root.--disabled.--color-critical.--highlighted:before,.root.--disabled.--color-critical:active:before,.root.--disabled.--color-critical:before,.root.--disabled.--color-critical:hover:before,.root.--disabled.--color-inherit.--highlighted:before,.root.--disabled.--color-inherit:active:before,.root.--disabled.--color-inherit:before,.root.--disabled.--color-inherit:hover:before,.root.--disabled.--color-neutral.--highlighted:before,.root.--disabled.--color-neutral:active:before,.root.--disabled.--color-neutral:before,.root.--disabled.--color-neutral:hover:before,.root.--disabled.--color-positive.--highlighted:before,.root.--disabled.--color-positive:active:before,.root.--disabled.--color-positive:before,.root.--disabled.--color-positive:hover:before,.root.--disabled.--color-primary.--highlighted:before,.root.--disabled.--color-primary:active:before,.root.--disabled.--color-primary:before,.root.--disabled.--color-primary:hover:before{opacity:0!important}.root.--disabled.--color-critical.--highlighted.--variant-faded,.root.--disabled.--color-critical.--variant-faded,.root.--disabled.--color-critical:active.--variant-faded,.root.--disabled.--color-critical:hover.--variant-faded,.root.--disabled.--color-inherit.--highlighted.--variant-faded,.root.--disabled.--color-inherit.--variant-faded,.root.--disabled.--color-inherit:active.--variant-faded,.root.--disabled.--color-inherit:hover.--variant-faded,.root.--disabled.--color-neutral.--highlighted.--variant-faded,.root.--disabled.--color-neutral.--variant-faded,.root.--disabled.--color-neutral:active.--variant-faded,.root.--disabled.--color-neutral:hover.--variant-faded,.root.--disabled.--color-positive.--highlighted.--variant-faded,.root.--disabled.--color-positive.--variant-faded,.root.--disabled.--color-positive:active.--variant-faded,.root.--disabled.--color-positive:hover.--variant-faded,.root.--disabled.--color-primary.--highlighted.--variant-faded,.root.--disabled.--color-primary.--variant-faded,.root.--disabled.--color-primary:active.--variant-faded,.root.--disabled.--color-primary:hover.--variant-faded{background-color:var(--rs-color-background-disabled-faded)!important}.root.--disabled.--color-critical.--highlighted.--variant-outline,.root.--disabled.--color-critical.--variant-outline,.root.--disabled.--color-critical:active.--variant-outline,.root.--disabled.--color-critical:hover.--variant-outline,.root.--disabled.--color-inherit.--highlighted.--variant-outline,.root.--disabled.--color-inherit.--variant-outline,.root.--disabled.--color-inherit:active.--variant-outline,.root.--disabled.--color-inherit:hover.--variant-outline,.root.--disabled.--color-neutral.--highlighted.--variant-outline,.root.--disabled.--color-neutral.--variant-outline,.root.--disabled.--color-neutral:active.--variant-outline,.root.--disabled.--color-neutral:hover.--variant-outline,.root.--disabled.--color-positive.--highlighted.--variant-outline,.root.--disabled.--color-positive.--variant-outline,.root.--disabled.--color-positive:active.--variant-outline,.root.--disabled.--color-positive:hover.--variant-outline,.root.--disabled.--color-primary.--highlighted.--variant-outline,.root.--disabled.--color-primary.--variant-outline,.root.--disabled.--color-primary:active.--variant-outline,.root.--disabled.--color-primary:hover.--variant-outline{background-color:transparent!important}.root.--disabled.--color-critical.--highlighted.--variant-ghost,.root.--disabled.--color-critical.--variant-ghost,.root.--disabled.--color-critical:active.--variant-ghost,.root.--disabled.--color-critical:hover.--variant-ghost,.root.--disabled.--color-inherit.--highlighted.--variant-ghost,.root.--disabled.--color-inherit.--variant-ghost,.root.--disabled.--color-inherit:active.--variant-ghost,.root.--disabled.--color-inherit:hover.--variant-ghost,.root.--disabled.--color-neutral.--highlighted.--variant-ghost,.root.--disabled.--color-neutral.--variant-ghost,.root.--disabled.--color-neutral:active.--variant-ghost,.root.--disabled.--color-neutral:hover.--variant-ghost,.root.--disabled.--color-positive.--highlighted.--variant-ghost,.root.--disabled.--color-positive.--variant-ghost,.root.--disabled.--color-positive:active.--variant-ghost,.root.--disabled.--color-positive:hover.--variant-ghost,.root.--disabled.--color-primary.--highlighted.--variant-ghost,.root.--disabled.--color-primary.--variant-ghost,.root.--disabled.--color-primary:active.--variant-ghost,.root.--disabled.--color-primary:hover.--variant-ghost{background-color:transparent!important;border-color:transparent!important}.root.--disabled.--color-media,.root.--disabled.--color-media.--highlighted,.root.--disabled.--color-media:active,.root.--disabled.--color-media:hover{opacity:.4!important}.group .root{border-radius:0}.group .root:first-child{border-end-start-radius:var(--rs-button-radius);border-start-start-radius:var(--rs-button-radius)}.group .root:not(:first-child){border-inline-start:1px solid var(--rs-button-group-separator-color)}.group .root:last-child{border-end-end-radius:var(--rs-button-radius);border-start-end-radius:var(--rs-button-radius)}.group .root.--variant-solid.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral)}.group .root.--variant-ghost.--color-neutral{--rs-button-group-separator-color:var(--rs-color-border-neutral-faded)}.group .root.--variant-solid.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive)}.group .root.--variant-ghost.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-solid.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical)}.group .root.--variant-ghost.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-solid.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary)}.group .root.--variant-ghost.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-faded.--color-positive{--rs-button-group-separator-color:var(--rs-color-border-positive-faded)}.group .root.--variant-faded.--color-critical{--rs-button-group-separator-color:var(--rs-color-border-critical-faded)}.group .root.--variant-faded.--color-primary{--rs-button-group-separator-color:var(--rs-color-border-primary-faded)}.group .root.--variant-solid.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.group .root.--variant-faded.--color-black{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.14)}.group .root.--variant-faded.--color-white,.group .root.--variant-ghost.--color-black,.group .root.--variant-solid.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-black),0.2)}.group .root.--variant-ghost.--color-white{--rs-button-group-separator-color:rgba(var(--rs-color-rgb-white),0.28)}.aligner{line-height:0}@media (--rs-viewport-m ){.--size-small--m{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--m{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--m{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--m{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--m{text-align:center;width:100%}.--full-width-false--m{text-align:initial;width:auto}}@media (--rs-viewport-l ){.--size-small--l{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--l{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--l{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--l{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--l{text-align:center;width:100%}.--full-width-false--l{text-align:initial;width:auto}}@media (--rs-viewport-xl ){.--size-small--xl{--rs-button-p-v:var(--rs-unit-x1);--rs-button-p-h:var(--rs-unit-x2);--rs-button-gap:var(--rs-unit-x1);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-medium--xl{--rs-button-p-v:var(--rs-unit-x2);--rs-button-p-h:var(--rs-unit-x3);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-3);--rs-button-font-size:var(--rs-font-size-body-3);--rs-button-letter-spacing:var(--rs-letter-spacing-body-3);--rs-button-radius:var(--rs-radius-small)}.--size-large--xl{--rs-button-p-v:var(--rs-unit-x3);--rs-button-p-h:var(--rs-unit-x4);--rs-button-gap:var(--rs-unit-x2);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--size-xlarge--xl{--rs-button-p-v:var(--rs-unit-x4);--rs-button-p-h:var(--rs-unit-x5);--rs-button-gap:var(--rs-unit-x3);--rs-button-line-height:var(--rs-line-height-body-2);--rs-button-font-size:var(--rs-font-size-body-2);--rs-button-letter-spacing:var(--rs-letter-spacing-body-2);--rs-button-radius:var(--rs-radius-medium)}.--full-width-true--xl{text-align:center;width:100%}.--full-width-false--xl{text-align:initial;width:auto}}
|
@@ -88,6 +88,7 @@ export type DateProps = {
|
|
88
88
|
startValue: Date | null;
|
89
89
|
endValue: Date | null;
|
90
90
|
renderAriaLabel?: MonthProps["renderDateAriaLabel"];
|
91
|
+
onDateFocus: (date: Date) => void;
|
91
92
|
} & Pick<MonthProps, "hoveredDate" | "onDateHover" | "onDateHoverEnd" | "onChange" | "range" | "min" | "max" | "selectedDates">;
|
92
93
|
export type ControlsProps = {
|
93
94
|
selectionMode: SelectionMode;
|
@@ -41,3 +41,14 @@ export declare const applyNavigationBounds: (args: {
|
|
41
41
|
isFirstMonth: boolean | undefined;
|
42
42
|
isLastMonth: boolean | undefined;
|
43
43
|
};
|
44
|
+
/**
|
45
|
+
* Decide if date has to be focusable with Tab (only one date should be)
|
46
|
+
* 1. If there is a selected value - it's focusable
|
47
|
+
* 2. Otherwise, today's date is focusable
|
48
|
+
* 3. Otherwise, first non-disabled date is focusable
|
49
|
+
*/
|
50
|
+
export declare const isDateFocusable: (args: {
|
51
|
+
date: Date;
|
52
|
+
lastFocusedDate?: Date;
|
53
|
+
startValue: Date | null;
|
54
|
+
}) => boolean;
|
@@ -108,3 +108,28 @@ export const applyNavigationBounds = (args) => {
|
|
108
108
|
isLastMonth: max && max < nextMonthFirstDate,
|
109
109
|
};
|
110
110
|
};
|
111
|
+
/**
|
112
|
+
* Decide if date has to be focusable with Tab (only one date should be)
|
113
|
+
* 1. If there is a selected value - it's focusable
|
114
|
+
* 2. Otherwise, today's date is focusable
|
115
|
+
* 3. Otherwise, first non-disabled date is focusable
|
116
|
+
*/
|
117
|
+
export const isDateFocusable = (args) => {
|
118
|
+
const { date, startValue, lastFocusedDate } = args;
|
119
|
+
const today = new Date();
|
120
|
+
const renderedMonth = date.getMonth();
|
121
|
+
const valueMonth = startValue?.getMonth();
|
122
|
+
const todayMonth = today.getMonth();
|
123
|
+
const lastFocusedMonth = lastFocusedDate?.getMonth();
|
124
|
+
const isoDate = getLocalISODate({ date });
|
125
|
+
const isoToday = getLocalISODate({ date: today });
|
126
|
+
const isoValueDate = startValue && getLocalISODate({ date: startValue });
|
127
|
+
const isoLastFocusedDate = lastFocusedDate && getLocalISODate({ date: lastFocusedDate });
|
128
|
+
if (lastFocusedDate && renderedMonth === lastFocusedMonth)
|
129
|
+
return isoDate === isoLastFocusedDate;
|
130
|
+
if (startValue && renderedMonth === valueMonth)
|
131
|
+
return isoDate === isoValueDate;
|
132
|
+
if (renderedMonth === todayMonth)
|
133
|
+
return isoDate === isoToday;
|
134
|
+
return true;
|
135
|
+
};
|
@@ -5,7 +5,7 @@ import { classNames } from "../../utilities/props.js";
|
|
5
5
|
import { getLocalISODate } from "./Calendar.utils.js";
|
6
6
|
import s from "./Calendar.module.css";
|
7
7
|
const CalendarDate = (props) => {
|
8
|
-
const { date, isoDate, startValue, endValue, disabled, focusable, onChange, range, hoveredDate, onDateHover, onDateHoverEnd, renderAriaLabel, selectedDates, } = props;
|
8
|
+
const { date, isoDate, startValue, endValue, disabled, focusable, onChange, range, hoveredDate, onDateHover, onDateHoverEnd, onDateFocus, renderAriaLabel, selectedDates, } = props;
|
9
9
|
if (!date)
|
10
10
|
return _jsx("td", { className: s.cell, "aria-hidden": "true" });
|
11
11
|
const isoStartValue = startValue && getLocalISODate({ date: startValue });
|
@@ -57,6 +57,10 @@ const CalendarDate = (props) => {
|
|
57
57
|
const handleMouseLeave = () => {
|
58
58
|
onDateHoverEnd(date);
|
59
59
|
};
|
60
|
+
const handleFocus = () => {
|
61
|
+
handleMouseEnter();
|
62
|
+
onDateFocus(date);
|
63
|
+
};
|
60
64
|
return (_jsx("td", { className: dateClassNames, role: disabled ? "presentation" : "gridcell", children: _jsx(Actionable, { fullWidth: true, insetFocus: true, className: s["cell-button"], disabled: disabled, onClick: handleClick, attributes: {
|
61
65
|
role: "checkbox",
|
62
66
|
tabIndex: focusable ? 0 : -1,
|
@@ -68,7 +72,7 @@ const CalendarDate = (props) => {
|
|
68
72
|
"data-rs-date": getLocalISODate({ date }),
|
69
73
|
onMouseEnter: handleMouseEnter,
|
70
74
|
onMouseLeave: handleMouseLeave,
|
71
|
-
onFocus:
|
75
|
+
onFocus: handleFocus,
|
72
76
|
onBlur: handleMouseLeave,
|
73
77
|
}, children: date.getDate() }) }));
|
74
78
|
};
|
@@ -1,11 +1,13 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
3
|
-
import {
|
3
|
+
import { useState } from "react";
|
4
|
+
import { getMonthWeeks, getWeekdayNames, getLocalISODate, isDateFocusable } from "./Calendar.utils.js";
|
4
5
|
import CalendarDate from "./CalendarDate.js";
|
5
6
|
import s from "./Calendar.module.css";
|
6
7
|
const CalendarMonth = (props) => {
|
7
8
|
const { date, value, onChange, min, max, range, firstWeekDay, selectedDates, hoveredDate, onDateHover, onDateHoverEnd, renderWeekDay, renderDateAriaLabel, } = props;
|
8
9
|
let foundFocusableDate = false;
|
10
|
+
const [lastFocusedDate, setLastFocusedDate] = useState();
|
9
11
|
const month = date.getMonth();
|
10
12
|
const weeks = getMonthWeeks({ date, firstWeekDay });
|
11
13
|
const weekdayNames = getWeekdayNames({ firstWeekDay, renderWeekDay });
|
@@ -13,33 +15,17 @@ const CalendarMonth = (props) => {
|
|
13
15
|
const key = [month, week[0]?.getDate()].filter(Boolean).join("-");
|
14
16
|
return (_jsx("tr", { className: s.row, children: week.map((date, index) => {
|
15
17
|
const disabled = !!date && ((min && date < min) || (max && date > max));
|
16
|
-
const month = date?.getMonth();
|
17
|
-
const today = new Date();
|
18
|
-
const isoToday = getLocalISODate({ date: today });
|
19
18
|
const startValue = value && "start" in value ? value.start : value;
|
20
19
|
const endValue = value && "end" in value ? value.end : value;
|
21
20
|
const isoDate = date && getLocalISODate({ date });
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
*/
|
28
|
-
let focusable = false;
|
29
|
-
if (!foundFocusableDate && date) {
|
30
|
-
if (!!startValue && startValue.getMonth() === date?.getMonth()) {
|
31
|
-
focusable = getLocalISODate({ date: startValue }) === getLocalISODate({ date });
|
32
|
-
}
|
33
|
-
else if (isoDate && month === today.getMonth()) {
|
34
|
-
focusable = isoDate >= isoToday && !disabled;
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
focusable = !disabled;
|
38
|
-
}
|
39
|
-
}
|
21
|
+
const focusable = disabled
|
22
|
+
? false
|
23
|
+
: !foundFocusableDate &&
|
24
|
+
!!date &&
|
25
|
+
isDateFocusable({ date, lastFocusedDate, startValue });
|
40
26
|
if (focusable)
|
41
27
|
foundFocusableDate = true;
|
42
|
-
return (_jsx(CalendarDate, { date: date, isoDate: isoDate, disabled: disabled, range: range, focusable: focusable, startValue: startValue, endValue: endValue, onChange: onChange, hoveredDate: hoveredDate, onDateHover: onDateHover, onDateHoverEnd: onDateHoverEnd, renderAriaLabel: renderDateAriaLabel, selectedDates: selectedDates }, index));
|
28
|
+
return (_jsx(CalendarDate, { date: date, isoDate: isoDate, disabled: disabled, range: range, focusable: focusable, startValue: startValue, endValue: endValue, onChange: onChange, hoveredDate: hoveredDate, onDateHover: onDateHover, onDateHoverEnd: onDateHoverEnd, onDateFocus: setLastFocusedDate, renderAriaLabel: renderDateAriaLabel, selectedDates: selectedDates }, index));
|
43
29
|
}) }, key));
|
44
30
|
}) })] }));
|
45
31
|
};
|
@@ -222,12 +222,19 @@ export const keyboardNavigation = {
|
|
222
222
|
</Example.Item>
|
223
223
|
</Example>),
|
224
224
|
play: async ({ canvas }) => {
|
225
|
-
const
|
226
|
-
|
225
|
+
const buttons = canvas.getAllByRole("button");
|
226
|
+
buttons[2].focus();
|
227
|
+
await userEvent.keyboard("{Tab/}");
|
228
|
+
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-01");
|
227
229
|
await userEvent.keyboard("{ArrowRight/}");
|
228
230
|
waitFor(() => {
|
229
231
|
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-02");
|
230
232
|
});
|
233
|
+
await userEvent.keyboard("{Shift>}{Tab/}{/Shift}");
|
234
|
+
await userEvent.keyboard("{Tab/}");
|
235
|
+
waitFor(() => {
|
236
|
+
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-02");
|
237
|
+
});
|
231
238
|
await userEvent.keyboard("{ArrowLeft/}");
|
232
239
|
waitFor(() => {
|
233
240
|
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-01");
|