@backstage/ui 0.6.0 → 0.7.0-next.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 +11 -0
- package/css/styles.css +92 -138
- package/dist/components/Avatar/Avatar.esm.js +29 -0
- package/dist/components/Avatar/Avatar.esm.js.map +1 -0
- package/dist/components/Box/Box.esm.js +34 -0
- package/dist/components/Box/Box.esm.js.map +1 -0
- package/dist/components/Box/Box.props.esm.js +7 -0
- package/dist/components/Box/Box.props.esm.js.map +1 -0
- package/dist/components/Button/Button.esm.js +41 -0
- package/dist/components/Button/Button.esm.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.esm.js +37 -0
- package/dist/components/ButtonIcon/ButtonIcon.esm.js.map +1 -0
- package/dist/components/ButtonLink/ButtonLink.esm.js +42 -0
- package/dist/components/ButtonLink/ButtonLink.esm.js.map +1 -0
- package/dist/components/Card/Card.esm.js +53 -0
- package/dist/components/Card/Card.esm.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.esm.js +74 -0
- package/dist/components/Checkbox/Checkbox.esm.js.map +1 -0
- package/dist/components/Collapsible/Collapsible.esm.js +50 -0
- package/dist/components/Collapsible/Collapsible.esm.js.map +1 -0
- package/dist/components/Container/Container.esm.js +35 -0
- package/dist/components/Container/Container.esm.js.map +1 -0
- package/dist/components/DataTable/DataTable.esm.js +26 -0
- package/dist/components/DataTable/DataTable.esm.js.map +1 -0
- package/dist/components/DataTable/Pagination/DataTablePagination.esm.js +84 -0
- package/dist/components/DataTable/Pagination/DataTablePagination.esm.js.map +1 -0
- package/dist/components/DataTable/Root/DataTableRoot.esm.js +24 -0
- package/dist/components/DataTable/Root/DataTableRoot.esm.js.map +1 -0
- package/dist/components/DataTable/Table/DataTableTable.esm.js +64 -0
- package/dist/components/DataTable/Table/DataTableTable.esm.js.map +1 -0
- package/dist/components/FieldError/FieldError.esm.js +22 -0
- package/dist/components/FieldError/FieldError.esm.js.map +1 -0
- package/dist/components/FieldLabel/FieldLabel.esm.js +27 -0
- package/dist/components/FieldLabel/FieldLabel.esm.js.map +1 -0
- package/dist/components/Flex/Flex.esm.js +26 -0
- package/dist/components/Flex/Flex.esm.js.map +1 -0
- package/dist/components/Flex/Flex.props.esm.js +31 -0
- package/dist/components/Flex/Flex.props.esm.js.map +1 -0
- package/dist/components/Grid/Grid.esm.js +43 -0
- package/dist/components/Grid/Grid.esm.js.map +1 -0
- package/dist/components/Grid/Grid.props.esm.js +58 -0
- package/dist/components/Grid/Grid.props.esm.js.map +1 -0
- package/dist/components/Header/Header.esm.js +46 -0
- package/dist/components/Header/Header.esm.js.map +1 -0
- package/dist/components/Header/HeaderToolbar.esm.js +132 -0
- package/dist/components/Header/HeaderToolbar.esm.js.map +1 -0
- package/dist/components/HeaderPage/HeaderPage.esm.js +57 -0
- package/dist/components/HeaderPage/HeaderPage.esm.js.map +1 -0
- package/dist/components/Icon/Icon.esm.js +29 -0
- package/dist/components/Icon/Icon.esm.js.map +1 -0
- package/dist/components/Icon/context.esm.js +10 -0
- package/dist/components/Icon/context.esm.js.map +1 -0
- package/dist/components/Icon/icons.esm.js +63 -0
- package/dist/components/Icon/icons.esm.js.map +1 -0
- package/dist/components/Icon/provider.esm.js +12 -0
- package/dist/components/Icon/provider.esm.js.map +1 -0
- package/dist/components/Link/Link.esm.js +67 -0
- package/dist/components/Link/Link.esm.js.map +1 -0
- package/dist/components/Menu/Combobox.esm.js +212 -0
- package/dist/components/Menu/Combobox.esm.js.map +1 -0
- package/dist/components/Menu/Menu.esm.js +224 -0
- package/dist/components/Menu/Menu.esm.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.esm.js +71 -0
- package/dist/components/RadioGroup/RadioGroup.esm.js.map +1 -0
- package/dist/components/ScrollArea/ScrollArea.esm.js +63 -0
- package/dist/components/ScrollArea/ScrollArea.esm.js.map +1 -0
- package/dist/components/SearchField/SearchField.esm.js +107 -0
- package/dist/components/SearchField/SearchField.esm.js.map +1 -0
- package/dist/components/Select/Select.esm.js +89 -0
- package/dist/components/Select/Select.esm.js.map +1 -0
- package/dist/components/Select/Select.styles.css.esm.js +7 -0
- package/dist/components/Select/Select.styles.css.esm.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.esm.js +22 -0
- package/dist/components/Skeleton/Skeleton.esm.js.map +1 -0
- package/dist/components/Switch/Switch.esm.js +18 -0
- package/dist/components/Switch/Switch.esm.js.map +1 -0
- package/dist/components/Table/Table.esm.js +68 -0
- package/dist/components/Table/Table.esm.js.map +1 -0
- package/dist/components/Table/TableCell/TableCell.esm.js +13 -0
- package/dist/components/Table/TableCell/TableCell.esm.js.map +1 -0
- package/dist/components/Table/TableCellLink/TableCellLink.esm.js +28 -0
- package/dist/components/Table/TableCellLink/TableCellLink.esm.js.map +1 -0
- package/dist/components/Table/TableCellProfile/TableCellProfile.esm.js +40 -0
- package/dist/components/Table/TableCellProfile/TableCellProfile.esm.js.map +1 -0
- package/dist/components/Table/TableCellText/TableCellText.esm.js +27 -0
- package/dist/components/Table/TableCellText/TableCellText.esm.js.map +1 -0
- package/dist/components/Tabs/Tabs.esm.js +139 -0
- package/dist/components/Tabs/Tabs.esm.js.map +1 -0
- package/dist/components/Tabs/TabsIndicators.esm.js +140 -0
- package/dist/components/Tabs/TabsIndicators.esm.js.map +1 -0
- package/dist/components/Text/Text.esm.js +40 -0
- package/dist/components/Text/Text.esm.js.map +1 -0
- package/dist/components/TextField/TextField.esm.js +88 -0
- package/dist/components/TextField/TextField.esm.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.esm.js +34 -0
- package/dist/components/Tooltip/Tooltip.esm.js.map +1 -0
- package/dist/hooks/useBreakpoint.esm.js +43 -0
- package/dist/hooks/useBreakpoint.esm.js.map +1 -0
- package/dist/hooks/useIsomorphicLayoutEffect.esm.js +6 -0
- package/dist/hooks/useIsomorphicLayoutEffect.esm.js.map +1 -0
- package/dist/hooks/useMediaQuery.esm.js +44 -0
- package/dist/hooks/useMediaQuery.esm.js.map +1 -0
- package/dist/hooks/useStyles.esm.js +46 -0
- package/dist/hooks/useStyles.esm.js.map +1 -0
- package/dist/index.d.ts +1410 -0
- package/dist/index.esm.js +39 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js +29 -0
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js.map +1 -0
- package/dist/props/display.props.esm.js +12 -0
- package/dist/props/display.props.esm.js.map +1 -0
- package/dist/props/gap-props.esm.js +15 -0
- package/dist/props/gap-props.esm.js.map +1 -0
- package/dist/props/height.props.esm.js +23 -0
- package/dist/props/height.props.esm.js.map +1 -0
- package/dist/props/margin.props.esm.js +54 -0
- package/dist/props/margin.props.esm.js.map +1 -0
- package/dist/props/padding.props.esm.js +54 -0
- package/dist/props/padding.props.esm.js.map +1 -0
- package/dist/props/position.props.esm.js +18 -0
- package/dist/props/position.props.esm.js.map +1 -0
- package/dist/props/prop-def.esm.js +4 -0
- package/dist/props/prop-def.esm.js.map +1 -0
- package/dist/props/spacing.props.esm.js +28 -0
- package/dist/props/spacing.props.esm.js.map +1 -0
- package/dist/props/width.props.esm.js +23 -0
- package/dist/props/width.props.esm.js.map +1 -0
- package/dist/utils/componentDefinitions.esm.js +272 -0
- package/dist/utils/componentDefinitions.esm.js.map +1 -0
- package/dist/utils/extractProps.esm.js +49 -0
- package/dist/utils/extractProps.esm.js.map +1 -0
- package/package.json +11 -3
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useId, useState, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import '../Icon/context.esm.js';
|
|
5
|
+
import '../Box/Box.esm.js';
|
|
6
|
+
import '../Grid/Grid.esm.js';
|
|
7
|
+
import '../Flex/Flex.esm.js';
|
|
8
|
+
import '../Container/Container.esm.js';
|
|
9
|
+
import '../Avatar/Avatar.esm.js';
|
|
10
|
+
import '../Button/Button.esm.js';
|
|
11
|
+
import '../Card/Card.esm.js';
|
|
12
|
+
import '../Collapsible/Collapsible.esm.js';
|
|
13
|
+
import '../DataTable/DataTable.esm.js';
|
|
14
|
+
import '../FieldLabel/FieldLabel.esm.js';
|
|
15
|
+
import 'react-aria-components';
|
|
16
|
+
import '@remixicon/react';
|
|
17
|
+
import '../ButtonIcon/ButtonIcon.esm.js';
|
|
18
|
+
import './Menu.esm.js';
|
|
19
|
+
import '../Text/Text.esm.js';
|
|
20
|
+
import 'motion/react';
|
|
21
|
+
import 'react-router-dom';
|
|
22
|
+
import '../Tabs/Tabs.esm.js';
|
|
23
|
+
import { Icon } from '../Icon/Icon.esm.js';
|
|
24
|
+
import '../ButtonLink/ButtonLink.esm.js';
|
|
25
|
+
import '../Checkbox/Checkbox.esm.js';
|
|
26
|
+
import '../RadioGroup/RadioGroup.esm.js';
|
|
27
|
+
import '../Table/Table.esm.js';
|
|
28
|
+
import '../TextField/TextField.esm.js';
|
|
29
|
+
import '../Tooltip/Tooltip.esm.js';
|
|
30
|
+
import '../ScrollArea/ScrollArea.esm.js';
|
|
31
|
+
import '../SearchField/SearchField.esm.js';
|
|
32
|
+
import '../Link/Link.esm.js';
|
|
33
|
+
import '../Select/Select.esm.js';
|
|
34
|
+
import '../Switch/Switch.esm.js';
|
|
35
|
+
|
|
36
|
+
const getListboxItemId = (listboxId, optionValue) => `${listboxId}-option-${optionValue}`;
|
|
37
|
+
function ComboboxItem({
|
|
38
|
+
option,
|
|
39
|
+
optionIndex,
|
|
40
|
+
value,
|
|
41
|
+
activeOptionIndex,
|
|
42
|
+
onItemActive,
|
|
43
|
+
onItemSelect,
|
|
44
|
+
listboxId
|
|
45
|
+
}) {
|
|
46
|
+
const isSelected = value?.includes(option.value) ?? false;
|
|
47
|
+
const isHighlighted = optionIndex === activeOptionIndex;
|
|
48
|
+
const itemId = getListboxItemId(listboxId, option.value);
|
|
49
|
+
const itemRef = useRef(null);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (isHighlighted && itemRef.current) {
|
|
52
|
+
itemRef.current.scrollIntoView({ block: "nearest" });
|
|
53
|
+
}
|
|
54
|
+
}, [isHighlighted]);
|
|
55
|
+
return /* @__PURE__ */ jsxs(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
ref: itemRef,
|
|
59
|
+
className: "bui-SubmenuComboboxItem",
|
|
60
|
+
id: itemId,
|
|
61
|
+
role: "option",
|
|
62
|
+
"aria-selected": isSelected,
|
|
63
|
+
"data-highlighted": isHighlighted ? true : void 0,
|
|
64
|
+
"data-selected": isSelected ? true : void 0,
|
|
65
|
+
"data-disabled": option.disabled ? true : void 0,
|
|
66
|
+
onMouseOver: () => !option.disabled && onItemActive(optionIndex),
|
|
67
|
+
onClick: () => !option.disabled && onItemSelect(option.value),
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx("div", { className: "bui-SubmenuComboboxItemCheckbox", children: isSelected && /* @__PURE__ */ jsx(Icon, { "aria-hidden": "true", name: "check", size: 12 }) }),
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: "bui-SubmenuComboboxItemLabel", children: option.label })
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const Combobox = forwardRef(
|
|
76
|
+
(props, ref) => {
|
|
77
|
+
const {
|
|
78
|
+
options,
|
|
79
|
+
value,
|
|
80
|
+
onValueChange,
|
|
81
|
+
multiselect = false,
|
|
82
|
+
className,
|
|
83
|
+
...rest
|
|
84
|
+
} = props;
|
|
85
|
+
const triggerId = useId();
|
|
86
|
+
const listboxId = `${triggerId}-listbox`;
|
|
87
|
+
const [filterString, setFilterString] = useState("");
|
|
88
|
+
const [activeOptionIndex, setActiveOptionIndex] = useState(0);
|
|
89
|
+
const filteredOptions = useMemo(() => {
|
|
90
|
+
if (!filterString) return options;
|
|
91
|
+
const lowerFilterString = filterString.toLocaleLowerCase("en-US");
|
|
92
|
+
return options.filter(
|
|
93
|
+
(option) => option.label.toLocaleLowerCase("en-US").includes(lowerFilterString)
|
|
94
|
+
);
|
|
95
|
+
}, [filterString, options]);
|
|
96
|
+
const activeDescendantId = activeOptionIndex >= 0 && filteredOptions.length > 0 ? getListboxItemId(listboxId, filteredOptions[activeOptionIndex].value) : void 0;
|
|
97
|
+
const handleValueChange = useCallback(
|
|
98
|
+
(toggledValue) => {
|
|
99
|
+
let newValue;
|
|
100
|
+
if (multiselect) {
|
|
101
|
+
newValue = value?.includes(toggledValue) ? value.filter((v) => v !== toggledValue) : [...value ?? [], toggledValue];
|
|
102
|
+
} else {
|
|
103
|
+
newValue = value?.includes(toggledValue) ? [] : [toggledValue];
|
|
104
|
+
}
|
|
105
|
+
onValueChange?.(newValue);
|
|
106
|
+
},
|
|
107
|
+
[multiselect, onValueChange, value]
|
|
108
|
+
);
|
|
109
|
+
const handleSearchChange = useCallback(
|
|
110
|
+
(e) => {
|
|
111
|
+
setFilterString(e.target.value);
|
|
112
|
+
setActiveOptionIndex(0);
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
},
|
|
115
|
+
[]
|
|
116
|
+
);
|
|
117
|
+
const handleKeyDown = useCallback(
|
|
118
|
+
(e) => {
|
|
119
|
+
let wasEscapeKey = false;
|
|
120
|
+
switch (e.key) {
|
|
121
|
+
case "ArrowDown":
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
setActiveOptionIndex(
|
|
124
|
+
(prev) => Math.min(prev + 1, filteredOptions.length - 1)
|
|
125
|
+
);
|
|
126
|
+
break;
|
|
127
|
+
case "ArrowUp":
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
setActiveOptionIndex((prev) => Math.max(prev - 1, 0));
|
|
130
|
+
break;
|
|
131
|
+
case "Home":
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
setActiveOptionIndex(0);
|
|
134
|
+
break;
|
|
135
|
+
case "End":
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
setActiveOptionIndex(Math.max(filteredOptions.length - 1, 0));
|
|
138
|
+
break;
|
|
139
|
+
case "Enter":
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
if (activeOptionIndex >= 0 && !filteredOptions[activeOptionIndex].disabled) {
|
|
142
|
+
handleValueChange(filteredOptions[activeOptionIndex].value);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case "Escape":
|
|
146
|
+
wasEscapeKey = true;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
if (!wasEscapeKey) {
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
[filteredOptions, activeOptionIndex, handleValueChange]
|
|
154
|
+
);
|
|
155
|
+
return /* @__PURE__ */ jsxs(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
ref,
|
|
159
|
+
role: "combobox",
|
|
160
|
+
className: clsx("bui-MenuCombobox", className),
|
|
161
|
+
...rest,
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsx(
|
|
164
|
+
"input",
|
|
165
|
+
{
|
|
166
|
+
className: "bui-SubmenuComboboxSearch",
|
|
167
|
+
type: "text",
|
|
168
|
+
role: "combobox",
|
|
169
|
+
placeholder: "Filter...",
|
|
170
|
+
"aria-labelledby": triggerId,
|
|
171
|
+
"aria-controls": listboxId,
|
|
172
|
+
"aria-autocomplete": "list",
|
|
173
|
+
"aria-activedescendant": activeDescendantId,
|
|
174
|
+
"aria-expanded": "true",
|
|
175
|
+
"aria-haspopup": "listbox",
|
|
176
|
+
value: filterString,
|
|
177
|
+
onKeyDown: handleKeyDown,
|
|
178
|
+
onChange: handleSearchChange
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsx(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
role: "listbox",
|
|
185
|
+
id: listboxId,
|
|
186
|
+
tabIndex: -1,
|
|
187
|
+
"aria-multiselectable": multiselect ? true : void 0,
|
|
188
|
+
className: "bui-SubmenuComboboxItems",
|
|
189
|
+
children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "bui-SubmenuComboboxNoResults", children: "No results found" }) : filteredOptions.map((option, index) => /* @__PURE__ */ jsx(
|
|
190
|
+
ComboboxItem,
|
|
191
|
+
{
|
|
192
|
+
option,
|
|
193
|
+
optionIndex: index,
|
|
194
|
+
value,
|
|
195
|
+
activeOptionIndex,
|
|
196
|
+
onItemActive: setActiveOptionIndex,
|
|
197
|
+
onItemSelect: handleValueChange,
|
|
198
|
+
listboxId
|
|
199
|
+
},
|
|
200
|
+
option.value
|
|
201
|
+
))
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
Combobox.displayName = "Combobox";
|
|
210
|
+
|
|
211
|
+
export { Combobox };
|
|
212
|
+
//# sourceMappingURL=Combobox.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.esm.js","sources":["../../../src/components/Menu/Combobox.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n forwardRef,\n useState,\n useMemo,\n useCallback,\n useId,\n ChangeEvent,\n KeyboardEvent,\n useRef,\n useEffect,\n} from 'react';\nimport clsx from 'clsx';\nimport { MenuComboboxOption, MenuComboboxProps } from './types';\nimport { Icon } from '../..';\n\nconst getListboxItemId = (listboxId: string, optionValue: string): string =>\n `${listboxId}-option-${optionValue}`;\n\n// Internal component for rendering individual items\nfunction ComboboxItem({\n option,\n optionIndex,\n value,\n activeOptionIndex,\n onItemActive,\n onItemSelect,\n listboxId,\n}: {\n option: MenuComboboxOption;\n optionIndex: number;\n value?: string[];\n activeOptionIndex: number;\n onItemActive: (index: number) => void;\n onItemSelect: (value: string) => void;\n listboxId: string;\n}) {\n const isSelected = value?.includes(option.value) ?? false;\n const isHighlighted = optionIndex === activeOptionIndex;\n const itemId = getListboxItemId(listboxId, option.value);\n\n const itemRef = useRef<HTMLDivElement>(null);\n\n // Scroll the item into view when it becomes highlighted\n useEffect(() => {\n if (isHighlighted && itemRef.current) {\n itemRef.current.scrollIntoView({ block: 'nearest' });\n }\n }, [isHighlighted]);\n\n return (\n <div\n ref={itemRef}\n className=\"bui-SubmenuComboboxItem\"\n id={itemId}\n role=\"option\"\n aria-selected={isSelected}\n data-highlighted={isHighlighted ? true : undefined}\n data-selected={isSelected ? true : undefined}\n data-disabled={option.disabled ? true : undefined}\n onMouseOver={() => !option.disabled && onItemActive(optionIndex)}\n onClick={() => !option.disabled && onItemSelect(option.value)}\n >\n <div className=\"bui-SubmenuComboboxItemCheckbox\">\n {isSelected && <Icon aria-hidden=\"true\" name=\"check\" size={12} />}\n </div>\n <div className=\"bui-SubmenuComboboxItemLabel\">{option.label}</div>\n </div>\n );\n}\n\n/** @public */\nexport const Combobox = forwardRef<HTMLDivElement, MenuComboboxProps>(\n (props, ref) => {\n const {\n options,\n value,\n onValueChange,\n multiselect = false,\n className,\n ...rest\n } = props;\n\n const triggerId = useId();\n const listboxId = `${triggerId}-listbox`;\n\n // State management\n const [filterString, setFilterString] = useState<string>('');\n const [activeOptionIndex, setActiveOptionIndex] = useState<number>(0);\n\n // Filter options based on input\n const filteredOptions = useMemo(() => {\n if (!filterString) return options;\n const lowerFilterString = filterString.toLocaleLowerCase('en-US');\n return options.filter(option =>\n option.label.toLocaleLowerCase('en-US').includes(lowerFilterString),\n );\n }, [filterString, options]);\n\n // Get the active descendant ID for accessibility\n const activeDescendantId =\n activeOptionIndex >= 0 && filteredOptions.length > 0\n ? getListboxItemId(listboxId, filteredOptions[activeOptionIndex].value)\n : undefined;\n\n const handleValueChange = useCallback(\n (toggledValue: string) => {\n let newValue: string[];\n if (multiselect) {\n newValue = value?.includes(toggledValue)\n ? value.filter(v => v !== toggledValue)\n : [...(value ?? []), toggledValue];\n } else {\n newValue = value?.includes(toggledValue) ? [] : [toggledValue];\n }\n\n onValueChange?.(newValue);\n },\n [multiselect, onValueChange, value],\n );\n\n const handleSearchChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setFilterString(e.target.value);\n setActiveOptionIndex(0);\n e.preventDefault();\n },\n [],\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n let wasEscapeKey = false;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n setActiveOptionIndex(prev =>\n Math.min(prev + 1, filteredOptions.length - 1),\n );\n break;\n case 'ArrowUp':\n e.preventDefault();\n setActiveOptionIndex(prev => Math.max(prev - 1, 0));\n break;\n case 'Home':\n e.preventDefault();\n setActiveOptionIndex(0);\n break;\n case 'End':\n e.preventDefault();\n setActiveOptionIndex(Math.max(filteredOptions.length - 1, 0));\n break;\n case 'Enter':\n e.preventDefault();\n if (\n activeOptionIndex >= 0 &&\n !filteredOptions[activeOptionIndex].disabled\n ) {\n handleValueChange(filteredOptions[activeOptionIndex].value);\n }\n break;\n case 'Escape':\n // The Menu component should handle this\n wasEscapeKey = true;\n break;\n default:\n break;\n }\n\n if (!wasEscapeKey) {\n // Stop propagation so Menu components don't prevent the input from updating\n e.stopPropagation();\n }\n },\n [filteredOptions, activeOptionIndex, handleValueChange],\n );\n\n return (\n <div\n ref={ref}\n role=\"combobox\"\n className={clsx('bui-MenuCombobox', className)}\n {...rest}\n >\n <input\n className=\"bui-SubmenuComboboxSearch\"\n type=\"text\"\n role=\"combobox\"\n placeholder=\"Filter...\"\n aria-labelledby={triggerId}\n aria-controls={listboxId}\n aria-autocomplete=\"list\"\n aria-activedescendant={activeDescendantId}\n aria-expanded=\"true\"\n aria-haspopup=\"listbox\"\n value={filterString}\n onKeyDown={handleKeyDown}\n onChange={handleSearchChange}\n />\n <div\n role=\"listbox\"\n id={listboxId}\n tabIndex={-1}\n aria-multiselectable={multiselect ? true : undefined}\n className=\"bui-SubmenuComboboxItems\"\n >\n {filteredOptions.length === 0 ? (\n <div className=\"bui-SubmenuComboboxNoResults\">No results found</div>\n ) : (\n filteredOptions.map((option, index) => (\n <ComboboxItem\n key={option.value}\n option={option}\n optionIndex={index}\n value={value}\n activeOptionIndex={activeOptionIndex}\n onItemActive={setActiveOptionIndex}\n onItemSelect={handleValueChange}\n listboxId={listboxId}\n />\n ))\n )}\n </div>\n </div>\n );\n },\n);\nCombobox.displayName = 'Combobox';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,mBAAmB,CAAC,SAAA,EAAmB,gBAC3C,CAAG,EAAA,SAAS,WAAW,WAAW,CAAA,CAAA;AAGpC,SAAS,YAAa,CAAA;AAAA,EACpB,MAAA;AAAA,EACA,WAAA;AAAA,EACA,KAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAQG,EAAA;AACD,EAAA,MAAM,UAAa,GAAA,KAAA,EAAO,QAAS,CAAA,MAAA,CAAO,KAAK,CAAK,IAAA,KAAA;AACpD,EAAA,MAAM,gBAAgB,WAAgB,KAAA,iBAAA;AACtC,EAAA,MAAM,MAAS,GAAA,gBAAA,CAAiB,SAAW,EAAA,MAAA,CAAO,KAAK,CAAA;AAEvD,EAAM,MAAA,OAAA,GAAU,OAAuB,IAAI,CAAA;AAG3C,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,aAAA,IAAiB,QAAQ,OAAS,EAAA;AACpC,MAAA,OAAA,CAAQ,OAAQ,CAAA,cAAA,CAAe,EAAE,KAAA,EAAO,WAAW,CAAA;AAAA;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EAAA,QAAA,EAAA,kBAAA,EAAgB,CAE9D,GAAA,eAAA,CAAgB,GAAI,CAAA,CAAC,QAAQ,KAC3B,qBAAA,GAAA;AAAA,gBAAC,YAAA;AAAA,gBAAA;AAAA,kBAEC,MAAA;AAAA,kBACA,WAAa,EAAA,KAAA;AAAA,kBACb,KAAA;AAAA,kBACA,iBAAA;AAAA,kBACA,YAAc,EAAA,oBAAA;AAAA,kBACd,YAAc,EAAA,iBAAA;AAAA,kBACd;AAAA,iBAAA;AAAA,gBAPK,MAAO,CAAA;AAAA,eASf;AAAA;AAAA;AAEL;AAAA;AAAA,KACF;AAAA;AAGN;AACA,QAAA,CAAS,WAAc,GAAA,UAAA;;;;"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { Menu as Menu$1 } from '@base-ui-components/react/menu';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { Combobox } from './Combobox.esm.js';
|
|
6
|
+
import '@remixicon/react';
|
|
7
|
+
import { Icon } from '../Icon/Icon.esm.js';
|
|
8
|
+
import '../Icon/context.esm.js';
|
|
9
|
+
import { useStyles } from '../../hooks/useStyles.esm.js';
|
|
10
|
+
|
|
11
|
+
const MenuTrigger = forwardRef(({ className, ...props }, ref) => {
|
|
12
|
+
const { classNames } = useStyles("Menu");
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
Menu$1.Trigger,
|
|
15
|
+
{
|
|
16
|
+
ref,
|
|
17
|
+
className: clsx(classNames.trigger, className),
|
|
18
|
+
...props
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
MenuTrigger.displayName = Menu$1.Trigger.displayName;
|
|
23
|
+
const MenuBackdrop = forwardRef(({ className, ...props }, ref) => {
|
|
24
|
+
const { classNames } = useStyles("Menu");
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
Menu$1.Backdrop,
|
|
27
|
+
{
|
|
28
|
+
ref,
|
|
29
|
+
className: clsx(classNames.backdrop, className),
|
|
30
|
+
...props
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
MenuBackdrop.displayName = Menu$1.Backdrop.displayName;
|
|
35
|
+
const MenuPositioner = forwardRef(({ className, ...props }, ref) => {
|
|
36
|
+
const { classNames } = useStyles("Menu");
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
Menu$1.Positioner,
|
|
39
|
+
{
|
|
40
|
+
ref,
|
|
41
|
+
className: clsx(classNames.positioner, className),
|
|
42
|
+
...props
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
MenuPositioner.displayName = Menu$1.Positioner.displayName;
|
|
47
|
+
const MenuPopup = forwardRef(({ className, ...props }, ref) => {
|
|
48
|
+
const { classNames } = useStyles("Menu");
|
|
49
|
+
return /* @__PURE__ */ jsx(
|
|
50
|
+
Menu$1.Popup,
|
|
51
|
+
{
|
|
52
|
+
ref,
|
|
53
|
+
className: clsx(classNames.popup, className),
|
|
54
|
+
...props
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
MenuPopup.displayName = Menu$1.Popup.displayName;
|
|
59
|
+
const MenuArrow = forwardRef(({ className, ...props }, ref) => {
|
|
60
|
+
const { classNames } = useStyles("Menu");
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
Menu$1.Arrow,
|
|
63
|
+
{
|
|
64
|
+
ref,
|
|
65
|
+
className: clsx(classNames.arrow, className),
|
|
66
|
+
...props
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
MenuArrow.displayName = Menu$1.Arrow.displayName;
|
|
71
|
+
const MenuItem = forwardRef(({ className, ...props }, ref) => {
|
|
72
|
+
const { classNames } = useStyles("Menu");
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
Menu$1.Item,
|
|
75
|
+
{
|
|
76
|
+
ref,
|
|
77
|
+
className: clsx(classNames.item, className),
|
|
78
|
+
...props
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
MenuItem.displayName = Menu$1.Item.displayName;
|
|
83
|
+
const MenuGroup = forwardRef(({ className, ...props }, ref) => {
|
|
84
|
+
const { classNames } = useStyles("Menu");
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
Menu$1.Group,
|
|
87
|
+
{
|
|
88
|
+
ref,
|
|
89
|
+
className: clsx(classNames.group, className),
|
|
90
|
+
...props
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
MenuGroup.displayName = Menu$1.Group.displayName;
|
|
95
|
+
const MenuGroupLabel = forwardRef(({ className, ...props }, ref) => {
|
|
96
|
+
const { classNames } = useStyles("Menu");
|
|
97
|
+
return /* @__PURE__ */ jsx(
|
|
98
|
+
Menu$1.GroupLabel,
|
|
99
|
+
{
|
|
100
|
+
ref,
|
|
101
|
+
className: clsx(classNames.groupLabel, className),
|
|
102
|
+
...props
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
MenuGroupLabel.displayName = Menu$1.GroupLabel.displayName;
|
|
107
|
+
const MenuRadioGroup = forwardRef(({ className, ...props }, ref) => {
|
|
108
|
+
const { classNames } = useStyles("Menu");
|
|
109
|
+
return /* @__PURE__ */ jsx(
|
|
110
|
+
Menu$1.RadioGroup,
|
|
111
|
+
{
|
|
112
|
+
ref,
|
|
113
|
+
className: clsx(classNames.radioGroup, className),
|
|
114
|
+
...props
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
MenuRadioGroup.displayName = Menu$1.RadioGroup.displayName;
|
|
119
|
+
const MenuRadioItem = forwardRef(({ className, ...props }, ref) => {
|
|
120
|
+
const { classNames } = useStyles("Menu");
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
Menu$1.RadioItem,
|
|
123
|
+
{
|
|
124
|
+
ref,
|
|
125
|
+
className: clsx(classNames.radioItem, className),
|
|
126
|
+
...props
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
MenuRadioItem.displayName = Menu$1.RadioItem.displayName;
|
|
131
|
+
const MenuRadioItemIndicator = forwardRef(({ className, ...props }, ref) => {
|
|
132
|
+
const { classNames } = useStyles("Menu");
|
|
133
|
+
return /* @__PURE__ */ jsx(
|
|
134
|
+
Menu$1.RadioItemIndicator,
|
|
135
|
+
{
|
|
136
|
+
ref,
|
|
137
|
+
className: clsx(classNames.radioItemIndicator, className),
|
|
138
|
+
...props
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
MenuRadioItemIndicator.displayName = Menu$1.RadioItemIndicator.displayName;
|
|
143
|
+
const MenuCheckboxItem = forwardRef(({ className, ...props }, ref) => {
|
|
144
|
+
const { classNames } = useStyles("Menu");
|
|
145
|
+
return /* @__PURE__ */ jsx(
|
|
146
|
+
Menu$1.CheckboxItem,
|
|
147
|
+
{
|
|
148
|
+
ref,
|
|
149
|
+
className: clsx(classNames.checkboxItem, className),
|
|
150
|
+
...props
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
MenuCheckboxItem.displayName = Menu$1.CheckboxItem.displayName;
|
|
155
|
+
const MenuCheckboxItemIndicator = forwardRef(({ className, ...props }, ref) => {
|
|
156
|
+
const { classNames } = useStyles("Menu");
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
Menu$1.CheckboxItemIndicator,
|
|
159
|
+
{
|
|
160
|
+
ref,
|
|
161
|
+
className: clsx(classNames.checkboxItemIndicator, className),
|
|
162
|
+
...props
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
MenuCheckboxItemIndicator.displayName = Menu$1.CheckboxItemIndicator.displayName;
|
|
167
|
+
const MenuSubmenuTrigger = forwardRef(({ className, children, ...props }, ref) => {
|
|
168
|
+
const { classNames } = useStyles("Menu");
|
|
169
|
+
return /* @__PURE__ */ jsxs(
|
|
170
|
+
Menu$1.SubmenuTrigger,
|
|
171
|
+
{
|
|
172
|
+
ref,
|
|
173
|
+
className: clsx(classNames.submenuTrigger, className),
|
|
174
|
+
...props,
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ jsx("div", { children }),
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
Icon,
|
|
179
|
+
{
|
|
180
|
+
"aria-label": "Submenu indicator icon",
|
|
181
|
+
name: "chevron-right",
|
|
182
|
+
size: 20
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
MenuSubmenuTrigger.displayName = Menu$1.SubmenuTrigger.displayName;
|
|
190
|
+
const MenuSeparator = forwardRef(({ className, ...props }, ref) => {
|
|
191
|
+
const { classNames } = useStyles("Menu");
|
|
192
|
+
return /* @__PURE__ */ jsx(
|
|
193
|
+
Menu$1.Separator,
|
|
194
|
+
{
|
|
195
|
+
ref,
|
|
196
|
+
className: clsx(classNames.separator, className),
|
|
197
|
+
...props
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
MenuSeparator.displayName = Menu$1.Separator.displayName;
|
|
202
|
+
const Menu = {
|
|
203
|
+
Root: Menu$1.Root,
|
|
204
|
+
Trigger: MenuTrigger,
|
|
205
|
+
Portal: Menu$1.Portal,
|
|
206
|
+
Backdrop: MenuBackdrop,
|
|
207
|
+
Positioner: MenuPositioner,
|
|
208
|
+
Popup: MenuPopup,
|
|
209
|
+
Arrow: MenuArrow,
|
|
210
|
+
Item: MenuItem,
|
|
211
|
+
Group: MenuGroup,
|
|
212
|
+
GroupLabel: MenuGroupLabel,
|
|
213
|
+
RadioGroup: MenuRadioGroup,
|
|
214
|
+
RadioItem: MenuRadioItem,
|
|
215
|
+
RadioItemIndicator: MenuRadioItemIndicator,
|
|
216
|
+
CheckboxItem: MenuCheckboxItem,
|
|
217
|
+
CheckboxItemIndicator: MenuCheckboxItemIndicator,
|
|
218
|
+
SubmenuTrigger: MenuSubmenuTrigger,
|
|
219
|
+
Separator: MenuSeparator,
|
|
220
|
+
Combobox
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export { Menu };
|
|
224
|
+
//# sourceMappingURL=Menu.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Menu.esm.js","sources":["../../../src/components/Menu/Menu.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport { Menu as MenuPrimitive } from '@base-ui-components/react/menu';\nimport clsx from 'clsx';\nimport { MenuComponent } from './types';\nimport { Combobox } from './Combobox';\nimport { Icon } from '../Icon';\nimport { useStyles } from '../../hooks/useStyles';\n\nconst MenuTrigger = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Trigger>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Trigger\n ref={ref}\n className={clsx(classNames.trigger, className)}\n {...props}\n />\n );\n});\nMenuTrigger.displayName = MenuPrimitive.Trigger.displayName;\n\nconst MenuBackdrop = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Backdrop>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Backdrop>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Backdrop\n ref={ref}\n className={clsx(classNames.backdrop, className)}\n {...props}\n />\n );\n});\nMenuBackdrop.displayName = MenuPrimitive.Backdrop.displayName;\n\nconst MenuPositioner = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Positioner>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Positioner>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Positioner\n ref={ref}\n className={clsx(classNames.positioner, className)}\n {...props}\n />\n );\n});\nMenuPositioner.displayName = MenuPrimitive.Positioner.displayName;\n\nconst MenuPopup = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Popup>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Popup>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Popup\n ref={ref}\n className={clsx(classNames.popup, className)}\n {...props}\n />\n );\n});\nMenuPopup.displayName = MenuPrimitive.Popup.displayName;\n\nconst MenuArrow = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Arrow>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Arrow>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Arrow\n ref={ref}\n className={clsx(classNames.arrow, className)}\n {...props}\n />\n );\n});\nMenuArrow.displayName = MenuPrimitive.Arrow.displayName;\n\nconst MenuItem = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Item>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Item\n ref={ref}\n className={clsx(classNames.item, className)}\n {...props}\n />\n );\n});\nMenuItem.displayName = MenuPrimitive.Item.displayName;\n\nconst MenuGroup = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Group>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Group>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Group\n ref={ref}\n className={clsx(classNames.group, className)}\n {...props}\n />\n );\n});\nMenuGroup.displayName = MenuPrimitive.Group.displayName;\n\nconst MenuGroupLabel = forwardRef<\n React.ElementRef<typeof MenuPrimitive.GroupLabel>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.GroupLabel>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.GroupLabel\n ref={ref}\n className={clsx(classNames.groupLabel, className)}\n {...props}\n />\n );\n});\nMenuGroupLabel.displayName = MenuPrimitive.GroupLabel.displayName;\n\nconst MenuRadioGroup = forwardRef<\n React.ElementRef<typeof MenuPrimitive.RadioGroup>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioGroup>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.RadioGroup\n ref={ref}\n className={clsx(classNames.radioGroup, className)}\n {...props}\n />\n );\n});\nMenuRadioGroup.displayName = MenuPrimitive.RadioGroup.displayName;\n\nconst MenuRadioItem = forwardRef<\n React.ElementRef<typeof MenuPrimitive.RadioItem>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioItem>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.RadioItem\n ref={ref}\n className={clsx(classNames.radioItem, className)}\n {...props}\n />\n );\n});\nMenuRadioItem.displayName = MenuPrimitive.RadioItem.displayName;\n\nconst MenuRadioItemIndicator = forwardRef<\n React.ElementRef<typeof MenuPrimitive.RadioItemIndicator>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.RadioItemIndicator>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.RadioItemIndicator\n ref={ref}\n className={clsx(classNames.radioItemIndicator, className)}\n {...props}\n />\n );\n});\nMenuRadioItemIndicator.displayName =\n MenuPrimitive.RadioItemIndicator.displayName;\n\nconst MenuCheckboxItem = forwardRef<\n React.ElementRef<typeof MenuPrimitive.CheckboxItem>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.CheckboxItem>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.CheckboxItem\n ref={ref}\n className={clsx(classNames.checkboxItem, className)}\n {...props}\n />\n );\n});\nMenuCheckboxItem.displayName = MenuPrimitive.CheckboxItem.displayName;\n\nconst MenuCheckboxItemIndicator = forwardRef<\n React.ElementRef<typeof MenuPrimitive.CheckboxItemIndicator>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.CheckboxItemIndicator>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.CheckboxItemIndicator\n ref={ref}\n className={clsx(classNames.checkboxItemIndicator, className)}\n {...props}\n />\n );\n});\nMenuCheckboxItemIndicator.displayName =\n MenuPrimitive.CheckboxItemIndicator.displayName;\n\nconst MenuSubmenuTrigger = forwardRef<\n React.ElementRef<typeof MenuPrimitive.SubmenuTrigger>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.SubmenuTrigger>\n>(({ className, children, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.SubmenuTrigger\n ref={ref}\n className={clsx(classNames.submenuTrigger, className)}\n {...props}\n >\n <div>{children}</div>\n <Icon\n aria-label=\"Submenu indicator icon\"\n name=\"chevron-right\"\n size={20}\n />\n </MenuPrimitive.SubmenuTrigger>\n );\n});\nMenuSubmenuTrigger.displayName = MenuPrimitive.SubmenuTrigger.displayName;\n\nconst MenuSeparator = forwardRef<\n React.ElementRef<typeof MenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof MenuPrimitive.Separator>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Menu');\n\n return (\n <MenuPrimitive.Separator\n ref={ref}\n className={clsx(classNames.separator, className)}\n {...props}\n />\n );\n});\nMenuSeparator.displayName = MenuPrimitive.Separator.displayName;\n\n/** @public */\nexport const Menu: MenuComponent = {\n Root: MenuPrimitive.Root,\n Trigger: MenuTrigger,\n Portal: MenuPrimitive.Portal,\n Backdrop: MenuBackdrop,\n Positioner: MenuPositioner,\n Popup: MenuPopup,\n Arrow: MenuArrow,\n Item: MenuItem,\n Group: MenuGroup,\n GroupLabel: MenuGroupLabel,\n RadioGroup: MenuRadioGroup,\n RadioItem: MenuRadioItem,\n RadioItemIndicator: MenuRadioItemIndicator,\n CheckboxItem: MenuCheckboxItem,\n CheckboxItemIndicator: MenuCheckboxItemIndicator,\n SubmenuTrigger: MenuSubmenuTrigger,\n Separator: MenuSeparator,\n Combobox,\n};\n"],"names":["MenuPrimitive"],"mappings":";;;;;;;;;;AAwBA,MAAM,WAAA,GAAc,WAGlB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,MAAM,CAAA;AAEvC,EACE,uBAAA,GAAA;AAAA,IAACA,MAAc,CAAA,OAAA;AAAA,IAAd;AAAA,MACC,GAAA;AAAA,MACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,OAAA,EAAS,SAAS,CAAA;AAAA,MAC5C,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC,CAAA;AACD,WAAY,CAAA,WAAA,GAAcA,OAAc,OAAQ,CAAA,WAAA;AAEhD,MAAM,YAAA,GAAe,WAGnB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,MAAM,CAAA;AAEvC,EACE,uBAAA,GAAA;AAAA,IAACA,MAAc,CAAA,QAAA;AAAA,IAAd;AAAA,MACC,GAAA;AAAA,MACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,QAAA,EAAU,SAAS,CAAA;AAAA,MAC7C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sBAAA;AAAA,EACpB,YAAc,EAAA,gBAAA;AAAA,EACd,qBAAuB,EAAA,yBAAA;AAAA,EACvB,cAAgB,EAAA,kBAAA;AAAA,EAChB,SAAW,EAAA,aAAA;AAAA,EACX;AACF;;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useEffect } from 'react';
|
|
3
|
+
import { RadioGroup as RadioGroup$1, Radio as Radio$1 } from 'react-aria-components';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { FieldLabel } from '../FieldLabel/FieldLabel.esm.js';
|
|
6
|
+
import { FieldError } from '../FieldError/FieldError.esm.js';
|
|
7
|
+
import { useStyles } from '../../hooks/useStyles.esm.js';
|
|
8
|
+
|
|
9
|
+
const RadioGroup = forwardRef(
|
|
10
|
+
(props, ref) => {
|
|
11
|
+
const {
|
|
12
|
+
className,
|
|
13
|
+
label,
|
|
14
|
+
secondaryLabel,
|
|
15
|
+
description,
|
|
16
|
+
isRequired,
|
|
17
|
+
"aria-label": ariaLabel,
|
|
18
|
+
"aria-labelledby": ariaLabelledBy,
|
|
19
|
+
children,
|
|
20
|
+
...rest
|
|
21
|
+
} = props;
|
|
22
|
+
const { classNames } = useStyles("RadioGroup");
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
25
|
+
console.warn(
|
|
26
|
+
"RadioGroup requires either a visible label, aria-label, or aria-labelledby for accessibility"
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}, [label, ariaLabel, ariaLabelledBy]);
|
|
30
|
+
const secondaryLabelText = secondaryLabel || (isRequired ? "Required" : null);
|
|
31
|
+
return /* @__PURE__ */ jsxs(
|
|
32
|
+
RadioGroup$1,
|
|
33
|
+
{
|
|
34
|
+
className: clsx(classNames.root, className),
|
|
35
|
+
"aria-label": ariaLabel,
|
|
36
|
+
"aria-labelledby": ariaLabelledBy,
|
|
37
|
+
...rest,
|
|
38
|
+
ref,
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
FieldLabel,
|
|
42
|
+
{
|
|
43
|
+
label,
|
|
44
|
+
secondaryLabel: secondaryLabelText,
|
|
45
|
+
description
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ jsx("div", { className: classNames.content, children }),
|
|
49
|
+
/* @__PURE__ */ jsx(FieldError, {})
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
RadioGroup.displayName = "RadioGroup";
|
|
56
|
+
const Radio = forwardRef((props, ref) => {
|
|
57
|
+
const { className, ...rest } = props;
|
|
58
|
+
const { classNames } = useStyles("RadioGroup");
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
Radio$1,
|
|
61
|
+
{
|
|
62
|
+
className: clsx(classNames.radio, className),
|
|
63
|
+
...rest,
|
|
64
|
+
ref
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
RadioGroup.displayName = "RadioGroup";
|
|
69
|
+
|
|
70
|
+
export { Radio, RadioGroup };
|
|
71
|
+
//# sourceMappingURL=RadioGroup.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.esm.js","sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef, useEffect } from 'react';\nimport {\n RadioGroup as AriaRadioGroup,\n Radio as AriaRadio,\n} from 'react-aria-components';\nimport clsx from 'clsx';\nimport { FieldLabel } from '../FieldLabel';\nimport { FieldError } from '../FieldError';\nimport { useStyles } from '../../hooks/useStyles';\n\nimport type { RadioGroupProps, RadioProps } from './types';\n\n/** @public */\nexport const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(\n (props, ref) => {\n const {\n className,\n label,\n secondaryLabel,\n description,\n isRequired,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n children,\n ...rest\n } = props;\n\n const { classNames } = useStyles('RadioGroup');\n\n useEffect(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n 'RadioGroup requires either a visible label, aria-label, or aria-labelledby for accessibility',\n );\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n // If a secondary label is provided, use it. Otherwise, use 'Required' if the field is required.\n const secondaryLabelText =\n secondaryLabel || (isRequired ? 'Required' : null);\n\n return (\n <AriaRadioGroup\n className={clsx(classNames.root, className)}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n {...rest}\n ref={ref}\n >\n <FieldLabel\n label={label}\n secondaryLabel={secondaryLabelText}\n description={description}\n />\n <div className={classNames.content}>{children}</div>\n <FieldError />\n </AriaRadioGroup>\n );\n },\n);\n\nRadioGroup.displayName = 'RadioGroup';\n\n/** @public */\nexport const Radio = forwardRef<HTMLLabelElement, RadioProps>((props, ref) => {\n const { className, ...rest } = props;\n\n const { classNames } = useStyles('RadioGroup');\n\n return (\n <AriaRadio\n className={clsx(classNames.radio, className)}\n {...rest}\n ref={ref}\n />\n );\n});\n\nRadioGroup.displayName = 'RadioGroup';\n"],"names":["AriaRadioGroup","AriaRadio"],"mappings":";;;;;;;;AA6BO,MAAM,UAAa,GAAA,UAAA;AAAA,EACxB,CAAC,OAAO,GAAQ,KAAA;AACd,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,KAAA;AAAA,MACA,cAAA;AA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A,KAAA;AAE/B,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,YAAY,CAAA;AAE7C,EACE,uBAAA,GAAA;AAAA,IAACC,OAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,KAAA,EAAO,SAAS,CAAA;AAAA,MAC1C,GAAG,IAAA;AAAA,MACJ;AAAA;AAAA,GACF;AAEJ,CAAC;AAED,UAAA,CAAW,WAAc,GAAA,YAAA;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { ScrollArea as ScrollArea$1 } from '@base-ui-components/react/scroll-area';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useStyles } from '../../hooks/useStyles.esm.js';
|
|
6
|
+
|
|
7
|
+
const ScrollAreaRoot = forwardRef(({ className, ...props }, ref) => {
|
|
8
|
+
const { classNames } = useStyles("ScrollArea");
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
ScrollArea$1.Root,
|
|
11
|
+
{
|
|
12
|
+
ref,
|
|
13
|
+
className: clsx(classNames.root, className),
|
|
14
|
+
...props
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
ScrollAreaRoot.displayName = ScrollArea$1.Root.displayName;
|
|
19
|
+
const ScrollAreaViewport = forwardRef(({ className, ...props }, ref) => {
|
|
20
|
+
const { classNames } = useStyles("ScrollArea");
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
ScrollArea$1.Viewport,
|
|
23
|
+
{
|
|
24
|
+
ref,
|
|
25
|
+
className: clsx(classNames.viewport, className),
|
|
26
|
+
...props
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
ScrollAreaViewport.displayName = ScrollArea$1.Viewport.displayName;
|
|
31
|
+
const ScrollAreaScrollbar = forwardRef(({ className, ...props }, ref) => {
|
|
32
|
+
const { classNames } = useStyles("ScrollArea");
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
ScrollArea$1.Scrollbar,
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
className: clsx(classNames.scrollbar, className),
|
|
38
|
+
...props
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
ScrollAreaScrollbar.displayName = ScrollArea$1.Scrollbar.displayName;
|
|
43
|
+
const ScrollAreaThumb = forwardRef(({ className, ...props }, ref) => {
|
|
44
|
+
const { classNames } = useStyles("ScrollArea");
|
|
45
|
+
return /* @__PURE__ */ jsx(
|
|
46
|
+
ScrollArea$1.Thumb,
|
|
47
|
+
{
|
|
48
|
+
ref,
|
|
49
|
+
className: clsx(classNames.thumb, className),
|
|
50
|
+
...props
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
ScrollAreaThumb.displayName = ScrollArea$1.Thumb.displayName;
|
|
55
|
+
const ScrollArea = {
|
|
56
|
+
Root: ScrollAreaRoot,
|
|
57
|
+
Viewport: ScrollAreaViewport,
|
|
58
|
+
Scrollbar: ScrollAreaScrollbar,
|
|
59
|
+
Thumb: ScrollAreaThumb
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { ScrollArea };
|
|
63
|
+
//# sourceMappingURL=ScrollArea.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollArea.esm.js","sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport { ScrollArea as ScrollAreaPrimitive } from '@base-ui-components/react/scroll-area';\nimport clsx from 'clsx';\nimport { useStyles } from '../../hooks/useStyles';\n\nconst ScrollAreaRoot = forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('ScrollArea');\n\n return (\n <ScrollAreaPrimitive.Root\n ref={ref}\n className={clsx(classNames.root, className)}\n {...props}\n />\n );\n});\nScrollAreaRoot.displayName = ScrollAreaPrimitive.Root.displayName;\n\nconst ScrollAreaViewport = forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Viewport>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Viewport>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('ScrollArea');\n\n return (\n <ScrollAreaPrimitive.Viewport\n ref={ref}\n className={clsx(classNames.viewport, className)}\n {...props}\n />\n );\n});\nScrollAreaViewport.displayName = ScrollAreaPrimitive.Viewport.displayName;\n\nconst ScrollAreaScrollbar = forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Scrollbar>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Scrollbar>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('ScrollArea');\n\n return (\n <ScrollAreaPrimitive.Scrollbar\n ref={ref}\n className={clsx(classNames.scrollbar, className)}\n {...props}\n />\n );\n});\nScrollAreaScrollbar.displayName = ScrollAreaPrimitive.Scrollbar.displayName;\n\nconst ScrollAreaThumb = forwardRef<\n React.ElementRef<typeof ScrollAreaPrimitive.Thumb>,\n React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Thumb>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('ScrollArea');\n\n return (\n <ScrollAreaPrimitive.Thumb\n ref={ref}\n className={clsx(classNames.thumb, className)}\n {...props}\n />\n );\n});\nScrollAreaThumb.displayName = ScrollAreaPrimitive.Thumb.displayName;\n\n/** @public */\nexport const ScrollArea = {\n Root: ScrollAreaRoot,\n Viewport: ScrollAreaViewport,\n Scrollbar: ScrollAreaScrollbar,\n Thumb: ScrollAreaThumb,\n};\n"],"names":["ScrollAreaPrimitive"],"mappings":";;;;;;AAqBA,MAAM,cAAA,GAAiB,WAGrB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,YAAY,CAAA;AAE7C,EACE,uBAAA,GAAA;AAAA,IAACA,YAAoB,CAAA,IAAA;AAAA,IAApB;AAAA,MACC,GAAA;AAAA,MACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,IAAA,EAAM,SAAS,CAAA;AAAA,MACzC,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC,CAAA;AACD,cAAe,CAAA,WAAA,GAAcA,aAAoB,IAAK,CAAA,WAAA;AAEtD,MAAM,kBAAA,GAAqB,WAGzB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,YAAY,CAAA;AAE7C,EACE,uBAAA,GAAA;AAAA,IAACA,YAAoB,CAAA,QAAA;AAAA,IAApB;AAAA,MACC,GAAA;AAAA,MACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,QAAA,EAAU,SAAS,CAAA;AAAA,MAC7C,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC,CAAA;AACD,kBAAmB,CAAA,WAAA,GAAcA,aAAoB,QAAS,CAAA,WAAA;AAE9D,MAAM,mBAAA,GAAsB,WAG1B,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,YAAY,CAAA;AAE7C,EACE,uBAAA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