pixelize-design-library 2.4.2-beta.62 → 2.4.2-beta.64
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 +122 -2
- package/COMPONENT-GOTCHAS.md +51 -9
- package/DESIGN-GUIDE.md +13 -5
- package/dist/Components/Button/Button.styles.js +58 -23
- package/dist/Components/Card/CardProps.d.ts +2 -2
- package/dist/Components/ConfirmDialog/ConfirmDialog.js +2 -1
- package/dist/Components/CustomModulesTable/CustomModulesTable.js +6 -4
- package/dist/Components/CustomModulesTable/EditModuleModal.js +2 -1
- package/dist/Components/DatePicker/RangeDatePicker.js +2 -1
- package/dist/Components/DatePicker/SingleDatePicker.js +2 -1
- package/dist/Components/DatePicker/TimeOnlyPicker.js +2 -1
- package/dist/Components/DatePicker/dayStates.js +2 -1
- package/dist/Components/Drawer/Drawer.js +2 -1
- package/dist/Components/Dropdown/DropDown.js +4 -10
- package/dist/Components/FilePreview/FilePreview.js +2 -1
- package/dist/Components/FileUpload/FileUpload.js +9 -2
- package/dist/Components/FileUploader/FileUploader.js +4 -0
- package/dist/Components/FileUploader/FileUploaderProps.d.ts +1 -1
- package/dist/Components/FilterSidebar/FilterSidebar.js +7 -4
- package/dist/Components/Input/TextInput.styles.js +10 -6
- package/dist/Components/KanbanBoard/AccountCard.js +4 -2
- package/dist/Components/KanbanBoard/KanbanBoard.js +6 -5
- package/dist/Components/NavigationBar/NavigationBar.js +5 -3
- package/dist/Components/Notification/Notification.js +4 -3
- package/dist/Components/NotificationBell/NotificationPanel.js +4 -3
- package/dist/Components/OrgSwitcher/OrgSwitcher.js +2 -4
- package/dist/Components/OrganizationDetails/CreateOrgModal.js +2 -1
- package/dist/Components/OrganizationDetails/OrganizationDetails.js +5 -3
- package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +12 -7
- package/dist/Components/ScrollToTop/ScrollToTop.js +4 -3
- package/dist/Components/SearchSelect/SearchSelect.js +44 -35
- package/dist/Components/SearchSelect/searchSelectNav.d.ts +13 -0
- package/dist/Components/SearchSelect/searchSelectNav.js +40 -0
- package/dist/Components/Select/SelectPopup.js +3 -4
- package/dist/Components/Select/optionRowInk.d.ts +12 -0
- package/dist/Components/Select/optionRowInk.js +10 -1
- package/dist/Components/SelectSearch/SelectSearch.js +3 -11
- package/dist/Components/SettingRow/SettingRow.js +2 -1
- package/dist/Components/SettingRow/SettingsSection.js +2 -1
- package/dist/Components/SideBar/SecondaryBar.js +4 -3
- package/dist/Components/SideBar/SideBar.js +16 -13
- package/dist/Components/SideBar/SideBarProps.d.ts +1 -1
- package/dist/Components/SideBar/components/MenuItemBox.js +7 -4
- package/dist/Components/SideBar/components/MenuPopoverContent.js +2 -1
- package/dist/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/Components/SideBar/components/PinnedSection.js +7 -4
- package/dist/Components/SideBar/sidebarMotion.d.ts +2 -0
- package/dist/Components/SideBar/sidebarMotion.js +6 -0
- package/dist/Components/SignInActivityTable/SignInActivityTable.js +6 -4
- package/dist/Components/StageProgress/StageItem.js +5 -2
- package/dist/Components/StageProgress/StepperStage.js +2 -2
- package/dist/Components/StatCard/StatCard.js +2 -1
- package/dist/Components/Table/Table.js +9 -4
- package/dist/Components/Table/TableProps.d.ts +1 -1
- package/dist/Components/Table/components/TableActions.js +3 -2
- package/dist/Components/Table/components/TableBody.js +9 -1
- package/dist/Components/Table/components/TableHeader.js +7 -2
- package/dist/Components/Table/components/TableLoading.d.ts +4 -1
- package/dist/Components/Table/components/TableLoading.js +6 -5
- package/dist/Components/Table/filters/CompactSelect.js +3 -11
- package/dist/Components/Table/settings/TableSettings.js +7 -2
- package/dist/Components/Table/variants/TableVariantContext.d.ts +1 -1
- package/dist/Components/Table/variants/TableVariantContext.js +3 -3
- package/dist/Components/Table/variants/classic.js +3 -2
- package/dist/Components/Timeline/Timeline.js +11 -4
- package/dist/Components/Toaster/Toaster.js +19 -8
- package/dist/Components/Toggle/TableToggle.js +5 -2
- package/dist/Components/UserDetails/AddUserModal.js +2 -1
- package/dist/Components/UserDetails/ChangeRoleModal.js +2 -1
- package/dist/Components/UserDetails/UserDetails.js +3 -1
- package/dist/Components/WorkspaceWindow/WorkspaceTrayPreview.js +4 -0
- package/dist/Components/WorkspaceWindow/WorkspaceWindow.d.ts +2 -2
- package/dist/Components/WorkspaceWindow/WorkspaceWindow.js +25 -18
- package/dist/Components/WorkspaceWindow/WorkspaceWindowProps.d.ts +38 -2
- package/dist/Theme/chakra/Card.styles.d.ts +7 -1
- package/dist/Theme/chakra/Card.styles.js +4 -1
- package/dist/Theme/chakra/Menu.styles.d.ts +11 -5
- package/dist/Theme/chakra/Menu.styles.js +10 -0
- package/dist/Theme/chakra/Popover.styles.d.ts +2 -11
- package/dist/Theme/chakra/Popover.styles.js +2 -0
- package/dist/Theme/chakra/common.web.d.ts +4 -0
- package/dist/Theme/chakra/componentStyles.d.ts +19 -3
- package/dist/Theme/chakra/componentStyles.js +12 -8
- package/dist/Theme/chakra/motion.d.ts +1 -0
- package/dist/Theme/chakra/motion.js +2 -1
- package/dist/Theme/chakra/overlay.styles.d.ts +5 -0
- package/dist/Theme/chakra/overlay.styles.js +4 -1
- package/dist/Theme/themeProps.d.ts +4 -0
- package/dist/Theme/tokens/brands/index.d.ts +1 -0
- package/dist/Theme/tokens/brands/index.js +17 -1
- package/dist/Theme/tokens/brands/radiant/palette.light.js +15 -0
- package/dist/Theme/tokens/brands/rosewood/palette.light.js +10 -10
- package/dist/Theme/tokens/brands/zinc/palette.dark.d.ts +7 -29
- package/dist/Theme/tokens/brands/zinc/palette.dark.js +3 -35
- package/dist/Theme/tokens/builders/accentText.d.ts +2 -0
- package/dist/Theme/tokens/builders/accentText.js +7 -1
- package/dist/Theme/tokens/builders/buildDarkPalette.d.ts +6 -1
- package/dist/Theme/tokens/builders/buildDarkPalette.js +37 -8
- package/dist/Theme/tokens/builders/filledSurface.d.ts +5 -1
- package/dist/Theme/tokens/builders/filledSurface.js +17 -4
- package/dist/Theme/tokens/builders/mutedText.d.ts +1 -1
- package/dist/Theme/tokens/builders/mutedText.js +13 -3
- package/dist/Theme/tokens/builders/planeStep.d.ts +5 -0
- package/dist/Theme/tokens/builders/planeStep.js +21 -0
- package/dist/Theme/tokens/builders/planes.d.ts +4 -0
- package/dist/Theme/tokens/builders/planes.js +33 -0
- package/dist/Theme/tokens/builders/skeletonShimmer.d.ts +9 -0
- package/dist/Theme/tokens/builders/skeletonShimmer.js +25 -0
- package/dist/Theme/tokens/builders/surfaceRaised.d.ts +3 -1
- package/dist/Theme/tokens/builders/surfaceRaised.js +18 -8
- package/dist/Theme/tokens/builders/surfaceRungs.js +3 -1
- package/dist/Theme/tokens/primitives/index.d.ts +2 -2
- package/dist/Theme/tokens/primitives/index.js +4 -1
- package/dist/Theme/tokens/primitives/motion.d.ts +1 -0
- package/dist/Theme/tokens/primitives/motion.js +2 -1
- package/dist/Theme/tokens/primitives/shadows.d.ts +16 -0
- package/dist/Theme/tokens/primitives/shadows.js +56 -6
- package/dist/Theme/tokens/primitives/typography.js +1 -1
- package/dist/Utils/table.js +2 -2
- package/dist/esm/Components/Button/Button.styles.js +62 -27
- package/dist/esm/Components/ConfirmDialog/ConfirmDialog.js +2 -1
- package/dist/esm/Components/CustomModulesTable/CustomModulesTable.js +6 -4
- package/dist/esm/Components/CustomModulesTable/EditModuleModal.js +2 -1
- package/dist/esm/Components/DatePicker/RangeDatePicker.js +2 -1
- package/dist/esm/Components/DatePicker/SingleDatePicker.js +2 -1
- package/dist/esm/Components/DatePicker/TimeOnlyPicker.js +2 -1
- package/dist/esm/Components/DatePicker/dayStates.js +2 -1
- package/dist/esm/Components/Drawer/Drawer.js +2 -1
- package/dist/esm/Components/Dropdown/DropDown.js +4 -10
- package/dist/esm/Components/FilePreview/FilePreview.js +3 -2
- package/dist/esm/Components/FileUpload/FileUpload.js +10 -3
- package/dist/esm/Components/FileUploader/FileUploader.js +4 -0
- package/dist/esm/Components/FilterSidebar/FilterSidebar.js +7 -4
- package/dist/esm/Components/Input/TextInput.styles.js +10 -6
- package/dist/esm/Components/KanbanBoard/AccountCard.js +4 -2
- package/dist/esm/Components/KanbanBoard/KanbanBoard.js +6 -5
- package/dist/esm/Components/NavigationBar/NavigationBar.js +5 -3
- package/dist/esm/Components/Notification/Notification.js +4 -3
- package/dist/esm/Components/NotificationBell/NotificationPanel.js +4 -3
- package/dist/esm/Components/OrgSwitcher/OrgSwitcher.js +2 -4
- package/dist/esm/Components/OrganizationDetails/CreateOrgModal.js +2 -1
- package/dist/esm/Components/OrganizationDetails/OrganizationDetails.js +5 -3
- package/dist/esm/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +13 -8
- package/dist/esm/Components/ScrollToTop/ScrollToTop.js +5 -4
- package/dist/esm/Components/SearchSelect/SearchSelect.js +46 -37
- package/dist/esm/Components/SearchSelect/searchSelectNav.js +32 -0
- package/dist/esm/Components/Select/SelectPopup.js +4 -5
- package/dist/esm/Components/Select/optionRowInk.js +7 -0
- package/dist/esm/Components/SelectSearch/SelectSearch.js +4 -12
- package/dist/esm/Components/SettingRow/SettingRow.js +2 -1
- package/dist/esm/Components/SettingRow/SettingsSection.js +2 -1
- package/dist/esm/Components/SideBar/SecondaryBar.js +4 -3
- package/dist/esm/Components/SideBar/SideBar.js +17 -14
- package/dist/esm/Components/SideBar/components/MenuItemBox.js +7 -4
- package/dist/esm/Components/SideBar/components/MenuPopoverContent.js +2 -1
- package/dist/esm/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/esm/Components/SideBar/components/PinnedSection.js +7 -4
- package/dist/esm/Components/SideBar/sidebarMotion.js +3 -0
- package/dist/esm/Components/SignInActivityTable/SignInActivityTable.js +6 -4
- package/dist/esm/Components/StageProgress/StageItem.js +5 -2
- package/dist/esm/Components/StageProgress/StepperStage.js +2 -2
- package/dist/esm/Components/StatCard/StatCard.js +2 -1
- package/dist/esm/Components/Table/Table.js +12 -7
- package/dist/esm/Components/Table/components/TableActions.js +3 -2
- package/dist/esm/Components/Table/components/TableBody.js +10 -2
- package/dist/esm/Components/Table/components/TableHeader.js +9 -4
- package/dist/esm/Components/Table/components/TableLoading.js +5 -4
- package/dist/esm/Components/Table/filters/CompactSelect.js +4 -12
- package/dist/esm/Components/Table/settings/TableSettings.js +8 -3
- package/dist/esm/Components/Table/variants/TableVariantContext.js +3 -3
- package/dist/esm/Components/Table/variants/classic.js +3 -2
- package/dist/esm/Components/Timeline/Timeline.js +11 -4
- package/dist/esm/Components/Toaster/Toaster.js +20 -9
- package/dist/esm/Components/Toggle/TableToggle.js +5 -2
- package/dist/esm/Components/UserDetails/AddUserModal.js +2 -1
- package/dist/esm/Components/UserDetails/ChangeRoleModal.js +2 -1
- package/dist/esm/Components/UserDetails/UserDetails.js +3 -1
- package/dist/esm/Components/WorkspaceWindow/WorkspaceTrayPreview.js +4 -0
- package/dist/esm/Components/WorkspaceWindow/WorkspaceWindow.js +26 -19
- package/dist/esm/Theme/chakra/Card.styles.js +4 -1
- package/dist/esm/Theme/chakra/Menu.styles.js +10 -0
- package/dist/esm/Theme/chakra/Popover.styles.js +2 -0
- package/dist/esm/Theme/chakra/componentStyles.js +12 -8
- package/dist/esm/Theme/chakra/motion.js +1 -0
- package/dist/esm/Theme/chakra/overlay.styles.js +3 -0
- package/dist/esm/Theme/tokens/brands/index.js +16 -0
- package/dist/esm/Theme/tokens/brands/radiant/palette.light.js +15 -0
- package/dist/esm/Theme/tokens/brands/rosewood/palette.light.js +10 -10
- package/dist/esm/Theme/tokens/brands/zinc/palette.dark.js +3 -35
- package/dist/esm/Theme/tokens/builders/accentText.js +5 -0
- package/dist/esm/Theme/tokens/builders/buildDarkPalette.js +38 -9
- package/dist/esm/Theme/tokens/builders/filledSurface.js +18 -5
- package/dist/esm/Theme/tokens/builders/mutedText.js +12 -2
- package/dist/esm/Theme/tokens/builders/planeStep.js +14 -0
- package/dist/esm/Theme/tokens/builders/planes.js +28 -0
- package/dist/esm/Theme/tokens/builders/skeletonShimmer.js +21 -0
- package/dist/esm/Theme/tokens/builders/surfaceRaised.js +16 -7
- package/dist/esm/Theme/tokens/builders/surfaceRungs.js +3 -1
- package/dist/esm/Theme/tokens/primitives/index.js +1 -1
- package/dist/esm/Theme/tokens/primitives/motion.js +1 -0
- package/dist/esm/Theme/tokens/primitives/shadows.js +54 -5
- package/dist/esm/Theme/tokens/primitives/typography.js +1 -1
- package/dist/esm/Utils/table.js +2 -2
- package/dist/esm/index.js +4 -3
- package/dist/index.d.ts +5 -4
- package/dist/index.js +15 -6
- package/package.json +1 -1
|
@@ -5,9 +5,10 @@ import { Check, ChevronDown, ChevronUp, CircleX, Plus, X } from "lucide-react";
|
|
|
5
5
|
import { TextLabel } from "../Common/FormLabel.js";
|
|
6
6
|
import Tag from "../Tag/Tag.js";
|
|
7
7
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
8
|
+
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
8
9
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
9
|
-
import { optionRowSpec } from "../../Theme/tokens/primitives/optionRowSizes.js";
|
|
10
|
-
import { optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
10
|
+
import { OPTION_ROW_RADIUS, optionRowSpec } from "../../Theme/tokens/primitives/optionRowSizes.js";
|
|
11
|
+
import { optionRowCursorSx, optionRowFill, optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
11
12
|
import { useExclusiveOverlay } from "../../Hooks/useExclusiveOverlay.js";
|
|
12
13
|
import FieldMessage from "../Common/FieldMessage.js";
|
|
13
14
|
import { useFieldIds } from "../Common/useFieldIds.js";
|
|
@@ -22,6 +23,7 @@ import SelectTruncatedLabel from "./SelectTruncatedLabel.js";
|
|
|
22
23
|
import { getSearchSelectSizeStyles, } from "./searchSelectSize.js";
|
|
23
24
|
import Checkbox from "../Checkbox/Checkbox.js";
|
|
24
25
|
import { rafThrottle } from "../../Utils/rafThrottle.js";
|
|
26
|
+
import { ADD_NEW_ROW, NO_ROW, SELECT_ALL_ROW, firstRow, hasRow, lastRow, stepRow } from "./searchSelectNav.js";
|
|
25
27
|
const SEGMENT_TRANSITION = transitionFor(["background-color", "box-shadow"]);
|
|
26
28
|
const CHEVRON_TRANSITION = transitionFor(["transform", "color"], "base");
|
|
27
29
|
const normalizeSingleValue = (val) => {
|
|
@@ -39,17 +41,9 @@ const normalizeMultiValue = (val) => {
|
|
|
39
41
|
const DECORATIVE_CHECKBOX_SX = { pointerEvents: "none", "& input": { visibility: "hidden" } };
|
|
40
42
|
const OptionRow = React.memo(function OptionRow({ option, index, optionId, isSelected, isActive, isMultiple, spec, colors, rowBackgrounds, checkboxSize, onSelect, onActivate, }) {
|
|
41
43
|
const singleSelected = isSelected && !isMultiple;
|
|
42
|
-
return (_jsxs(Box, { id: optionId, "data-index": index, role: "option", "aria-selected": isSelected, py: spec.py, px: spec.px, minH: spec.minH, cursor: "pointer", bg:
|
|
43
|
-
? isActive
|
|
44
|
-
? rowBackgrounds.selectedActive
|
|
45
|
-
: rowBackgrounds.selected
|
|
46
|
-
: isActive
|
|
47
|
-
? rowBackgrounds.active
|
|
48
|
-
: "transparent", _hover: {
|
|
49
|
-
bg: isSelected ? rowBackgrounds.selectedActive : rowBackgrounds.active,
|
|
50
|
-
}, onClick: () => onSelect(option), onMouseEnter: () => onActivate(index), display: "flex", alignItems: "center", gap: spec.gap, color: optionRowInk(colors, singleSelected),
|
|
44
|
+
return (_jsxs(Box, { id: optionId, "data-index": index, role: "option", "aria-selected": isSelected, mx: spec.mx, py: spec.py, px: spec.px, minH: spec.minH, borderRadius: OPTION_ROW_RADIUS, cursor: "pointer", bg: optionRowFill(rowBackgrounds, isActive), onClick: () => onSelect(option), onMouseEnter: () => onActivate(index), display: "flex", alignItems: "center", gap: spec.gap, color: optionRowInk(colors, singleSelected),
|
|
51
45
|
// `view` is consumer JSX with no size of its own; it inherited the 16px body font.
|
|
52
|
-
fontSize: spec.fontSize, fontWeight: optionRowWeight(singleSelected),
|
|
46
|
+
fontSize: spec.fontSize, fontWeight: optionRowWeight(singleSelected), children: [isMultiple && (_jsx(Checkbox, { isChecked: isSelected, sx: DECORATIVE_CHECKBOX_SX, size: checkboxSize })), option.view ? (_jsx(_Fragment, { children: option.view })) : (_jsx(Text, { flex: 1, minW: 0, isTruncated: true, children: option.label })), singleSelected && (_jsx(Box, { as: Check, size: spec.iconSize, color: colors.accentText, flexShrink: 0 }))] }));
|
|
53
47
|
});
|
|
54
48
|
/** Full-featured combobox: search, chips, select-all, paginated infinite scroll — not DOM-virtualized despite the `virtualization` prop. */
|
|
55
49
|
/** Prefer `Select` with `native={false}` for new work — not yet a drop-in; see select-absorption-spec.md. */
|
|
@@ -94,7 +88,9 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
94
88
|
const listboxId = `${baseId}-listbox`;
|
|
95
89
|
const insideSelectPortalId = `${baseId}-inside-select`;
|
|
96
90
|
const getOptionId = (index) => `${baseId}-option-${index}`;
|
|
97
|
-
const
|
|
91
|
+
const selectAllId = `${baseId}-select-all`;
|
|
92
|
+
const addNewId = `${baseId}-add-new`;
|
|
93
|
+
const [activeIndex, setActiveIndex] = useState(NO_ROW);
|
|
98
94
|
const pendingFocusRestoreRef = useRef(false);
|
|
99
95
|
// NOTE: the ARIA host follows real focus; opening from a button doesn't move it.
|
|
100
96
|
const [focusedTrigger, setFocusedTrigger] = useState(null);
|
|
@@ -190,9 +186,22 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
190
186
|
}
|
|
191
187
|
setInputValue("");
|
|
192
188
|
};
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
const hasSelectAllRow = isMultiple && isSelectAll;
|
|
190
|
+
const hasAddNewRow = Boolean(addNew === null || addNew === void 0 ? void 0 : addNew.enabled);
|
|
191
|
+
const rowLayout = {
|
|
192
|
+
optionCount: filteredOptions.length,
|
|
193
|
+
hasSelectAll: hasSelectAllRow,
|
|
194
|
+
hasAddNew: hasAddNewRow,
|
|
195
|
+
};
|
|
196
|
+
const activeOptionId = !isOpen
|
|
197
|
+
? undefined
|
|
198
|
+
: activeIndex === SELECT_ALL_ROW && hasSelectAllRow
|
|
199
|
+
? selectAllId
|
|
200
|
+
: activeIndex === ADD_NEW_ROW && hasAddNewRow
|
|
201
|
+
? addNewId
|
|
202
|
+
: activeIndex >= 0 && filteredOptions[activeIndex]
|
|
203
|
+
? getOptionId(activeIndex)
|
|
204
|
+
: undefined;
|
|
196
205
|
// One element hosts the field's ARIA at a time: real focus wins, else render state.
|
|
197
206
|
const primaryTarget = focusedTrigger !== null && focusedTrigger !== void 0 ? focusedTrigger : (isOpen || inputValue || !selectedValues.length
|
|
198
207
|
? "input"
|
|
@@ -235,19 +244,14 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
235
244
|
setIsOpen(true);
|
|
236
245
|
};
|
|
237
246
|
const moveActive = (delta) => {
|
|
238
|
-
setActiveIndex((prev) =>
|
|
239
|
-
if (!filteredOptions.length)
|
|
240
|
-
return -1;
|
|
241
|
-
if (prev < 0)
|
|
242
|
-
return delta > 0 ? 0 : filteredOptions.length - 1;
|
|
243
|
-
return (prev + delta + filteredOptions.length) % filteredOptions.length;
|
|
244
|
-
});
|
|
247
|
+
setActiveIndex((prev) => stepRow(rowLayout, prev, delta));
|
|
245
248
|
};
|
|
246
249
|
const restoreFocus = () => {
|
|
247
250
|
pendingFocusRestoreRef.current = true;
|
|
248
251
|
};
|
|
249
252
|
// NOTE: only reacts to keys from the combobox triggers — without this guard, Tag's own "Remove" button lost its clicks.
|
|
250
253
|
const handleControlKeyDown = (e) => {
|
|
254
|
+
var _a;
|
|
251
255
|
const target = e.target;
|
|
252
256
|
const isKnownTrigger = target === inputRef.current ||
|
|
253
257
|
target === triggerButtonRef.current ||
|
|
@@ -275,15 +279,15 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
275
279
|
}
|
|
276
280
|
break;
|
|
277
281
|
case "Home":
|
|
278
|
-
if (isOpen &&
|
|
282
|
+
if (isOpen && firstRow(rowLayout) !== NO_ROW && !isTextInputTarget) {
|
|
279
283
|
e.preventDefault();
|
|
280
|
-
setActiveIndex(
|
|
284
|
+
setActiveIndex(firstRow(rowLayout));
|
|
281
285
|
}
|
|
282
286
|
break;
|
|
283
287
|
case "End":
|
|
284
|
-
if (isOpen &&
|
|
288
|
+
if (isOpen && lastRow(rowLayout) !== NO_ROW && !isTextInputTarget) {
|
|
285
289
|
e.preventDefault();
|
|
286
|
-
setActiveIndex(
|
|
290
|
+
setActiveIndex(lastRow(rowLayout));
|
|
287
291
|
}
|
|
288
292
|
break;
|
|
289
293
|
case "Enter":
|
|
@@ -291,6 +295,14 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
291
295
|
e.preventDefault();
|
|
292
296
|
openMenu();
|
|
293
297
|
}
|
|
298
|
+
else if (activeIndex === SELECT_ALL_ROW && hasSelectAllRow) {
|
|
299
|
+
e.preventDefault();
|
|
300
|
+
handleSelectAll();
|
|
301
|
+
}
|
|
302
|
+
else if (activeIndex === ADD_NEW_ROW && (addNew === null || addNew === void 0 ? void 0 : addNew.enabled)) {
|
|
303
|
+
e.preventDefault();
|
|
304
|
+
(_a = addNew.onClick) === null || _a === void 0 ? void 0 : _a.call(addNew);
|
|
305
|
+
}
|
|
294
306
|
else if (activeIndex >= 0 && filteredOptions[activeIndex]) {
|
|
295
307
|
e.preventDefault();
|
|
296
308
|
handleSelect(filteredOptions[activeIndex]);
|
|
@@ -309,7 +321,7 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
309
321
|
if (isOpen) {
|
|
310
322
|
e.preventDefault();
|
|
311
323
|
setIsOpen(false);
|
|
312
|
-
setActiveIndex(
|
|
324
|
+
setActiveIndex(NO_ROW);
|
|
313
325
|
restoreFocus();
|
|
314
326
|
}
|
|
315
327
|
break;
|
|
@@ -321,11 +333,12 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
321
333
|
// (e.g. typing), rather than leaving it pointing at a now out-of-range or stale option.
|
|
322
334
|
useEffect(() => {
|
|
323
335
|
if (!isOpen) {
|
|
324
|
-
setActiveIndex(
|
|
336
|
+
setActiveIndex(NO_ROW);
|
|
325
337
|
return;
|
|
326
338
|
}
|
|
327
|
-
|
|
328
|
-
|
|
339
|
+
const layout = { optionCount: filteredOptions.length, hasSelectAll: hasSelectAllRow, hasAddNew: hasAddNewRow };
|
|
340
|
+
setActiveIndex((prev) => (hasRow(prev, layout) ? prev : NO_ROW));
|
|
341
|
+
}, [isOpen, filteredOptions.length, hasSelectAllRow, hasAddNewRow]);
|
|
329
342
|
useEffect(() => {
|
|
330
343
|
var _a, _b;
|
|
331
344
|
if (!isOpen || activeIndex < 0 || !optionsListRef.current)
|
|
@@ -597,11 +610,7 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
597
610
|
}, children: [_jsxs(Box, { minW: "4.5rem", cursor: "pointer", display: "flex", justifyContent: "space-between", alignItems: "center", gap: 1, width: insideSelect.width, height: insideSelectBoxHeight, pl: "0.5rem", pr: "0.375rem", children: [insideLabel ? (_jsx(SelectTruncatedLabel, { label: insideLabel, maxWidth: insideSelect.width || "6rem", fontSize: s.fieldFontSize })) : (_jsx(Text, { fontSize: s.fieldFontSize, fontWeight: 500, color: theme.colors.textMuted, isTruncated: true, maxW: insideSelect.width || "6rem", children: insidePlaceholder })), _jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, color: customSelectOpen ? theme.colors.accentText : theme.colors.textMuted, transition: CHEVRON_TRANSITION, transform: customSelectOpen ? "rotate(180deg)" : "rotate(0deg)", children: _jsx(ChevronDown, { size: s.chevronSize }) })] }), customSelectOpen && (_jsx(Portal, { children: _jsx(Box, { ref: setInsideSelectMenuRef, id: insideSelectPortalId, role: "listbox", "aria-label": insidePlaceholder, onKeyDown: handleInsideMenuKeyDown, onFocus: stopFocusBubbling, onBlur: stopFocusBubbling, position: "fixed", style: { top: `${customSelectPos.top}px`, left: `${customSelectPos.left}px` }, zIndex: zIndices.popoverNested, bg: theme.colors.surfaceRaised, border: `${BORDER_WIDTHS.hairline} solid`, borderColor: theme.colors.boxborder[200], borderRadius: "xl", boxShadow: theme.shadows.lg, minW: `${customSelectPos.width}px`, maxW: "20rem", py: 1, overflow: "hidden", children: (_c = insideSelect.option) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
598
611
|
var _a;
|
|
599
612
|
const selected = ((_a = insideSelect.value) === null || _a === void 0 ? void 0 : _a.id) === item.id;
|
|
600
|
-
return (_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: spec.gap, minH: spec.minH, py: spec.py, px: spec.px, fontSize: spec.fontSize, fontWeight: optionRowWeight(selected), color: optionRowInk(theme.colors, selected), bg:
|
|
601
|
-
bg: selected
|
|
602
|
-
? rowBackgrounds.selectedActive
|
|
603
|
-
: rowBackgrounds.active,
|
|
604
|
-
}, cursor: "pointer", role: "option", "aria-selected": selected, tabIndex: -1, _focusVisible: insideFocusRing, onClick: (e) => {
|
|
613
|
+
return (_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: spec.gap, minH: spec.minH, py: spec.py, px: spec.px, fontSize: spec.fontSize, fontWeight: optionRowWeight(selected), color: optionRowInk(theme.colors, selected), bg: "transparent", ...optionRowCursorSx(rowBackgrounds), cursor: "pointer", role: "option", "aria-selected": selected, tabIndex: -1, _focusVisible: insideFocusRing, onClick: (e) => {
|
|
605
614
|
e.stopPropagation();
|
|
606
615
|
handleCustomSelect(item);
|
|
607
616
|
}, children: [_jsx(Text, { isTruncated: true, children: item.label }), selected && (_jsx(Check, { size: spec.iconSize, color: theme.colors.accentText }))] }, item.id));
|
|
@@ -640,6 +649,6 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
640
649
|
top: `${dropdownPos.top}px`,
|
|
641
650
|
left: `${dropdownPos.left}px`,
|
|
642
651
|
width: `${dropdownPos.width}px`,
|
|
643
|
-
}, zIndex: zIndices.popover, maxH: "20rem", borderWidth: 1, borderColor: theme.colors.boxborder[200], borderRadius: "xl", overflow: "hidden", bg: theme.colors.surfaceRaised, boxShadow: theme.shadows.lg, display: "flex", flexDirection: "column", children: [
|
|
652
|
+
}, zIndex: zIndices.popover, maxH: "20rem", borderWidth: 1, borderColor: theme.colors.boxborder[200], borderRadius: "xl", overflow: "hidden", bg: theme.colors.surfaceRaised, boxShadow: theme.shadows.lg, display: "flex", flexDirection: "column", children: [hasSelectAllRow && (_jsxs(Box, { id: selectAllId, role: "option", "aria-selected": allFilteredSelected, bg: activeIndex === SELECT_ALL_ROW ? rowBackgrounds.active : undefined, py: spec.py, px: spec.px, minH: spec.minH, cursor: "pointer", onClick: handleSelectAll, display: "flex", alignItems: "center", gap: spec.gap, color: theme.colors.text[700], borderBottom: `${BORDER_WIDTHS.hairline} solid ${raisedRule(theme.colors)}`, children: [_jsx(Checkbox, { isChecked: allFilteredSelected, sx: DECORATIVE_CHECKBOX_SX, size: s.checkboxSize }), _jsx(Text, { fontSize: spec.fontSize, children: allFilteredSelected ? "Unselect All" : "Select All" })] })), _jsx(Box, { ref: optionsListRef, flex: "1", overflowY: "auto", onScroll: handleScroll, maxH: "15rem", py: 1, borderBottom: `${BORDER_WIDTHS.hairline} solid`, borderColor: raisedRule(theme.colors), children: isOptionLoading && filteredOptions.length === 0 ? (_jsxs(Box, { py: spec.py, px: spec.px, display: "flex", alignItems: "center", gap: spec.gap, minH: spec.minH, color: theme.colors.textMuted, children: [_jsx(Spinner, { size: s.spinnerSize }), _jsx(Text, { fontSize: spec.fontSize, children: loadingText })] })) : !isOptionLoading && filteredOptions.length === 0 ? (_jsx(Text, { p: 3, fontSize: spec.fontSize, color: theme.colors.textMuted, children: "No results found" })) : (_jsxs(_Fragment, { children: [filteredOptions.map((option, index) => (_jsx(OptionRow, { option: option, index: index, optionId: getOptionId(index), isSelected: isSelected(option.id), isActive: index === activeIndex, isMultiple: isMultiple, spec: spec, colors: theme.colors, rowBackgrounds: rowBackgrounds, checkboxSize: s.checkboxSize, onSelect: selectOption, onActivate: setActiveIndex }, option.id))), ((pagination === null || pagination === void 0 ? void 0 : pagination.scrollLoading) || (isOptionLoading && filteredOptions.length > 0)) && (_jsxs(Box, { py: spec.py, px: spec.px, display: "flex", alignItems: "center", justifyContent: "center", gap: spec.gap, minH: spec.minH, color: theme.colors.textMuted, children: [_jsx(Spinner, { size: s.spinnerSize }), _jsx(Text, { fontSize: spec.fontSize, children: loadingText })] }))] })) }), (addNew === null || addNew === void 0 ? void 0 : addNew.enabled) && (_jsxs(Box, { id: addNewId, role: "option", "aria-selected": false, py: spec.py, px: spec.px, borderTop: `${BORDER_WIDTHS.hairline} solid`, borderColor: raisedRule(theme.colors), bg: activeIndex === ADD_NEW_ROW ? rowBackgrounds.active : theme.colors.surfaceRaised, display: "flex", alignItems: "center", gap: spec.gap, color: theme.colors.accentText, fontWeight: 500, minH: spec.minH, cursor: "pointer", onClick: addNew.onClick, _hover: { bg: rowBackgrounds.active }, children: [addNew.icon || _jsx(Plus, { size: s.addNewIconSize }), _jsx(Text, { fontSize: spec.fontSize, children: addNew.text || "Add New" })] }))] }) })), _jsx(FieldMessage, { error: error, errorMessage: errorMessage, helperText: helperText, helperId: ids.helperId, errorId: ids.errorId })] }));
|
|
644
653
|
};
|
|
645
654
|
export default SearchSelect;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const NO_ROW = -1;
|
|
2
|
+
export const SELECT_ALL_ROW = -2;
|
|
3
|
+
export const ADD_NEW_ROW = -3;
|
|
4
|
+
export const navRows = ({ optionCount, hasSelectAll, hasAddNew }) => [
|
|
5
|
+
...(hasSelectAll ? [SELECT_ALL_ROW] : []),
|
|
6
|
+
...Array.from({ length: optionCount }, (_, index) => index),
|
|
7
|
+
...(hasAddNew ? [ADD_NEW_ROW] : []),
|
|
8
|
+
];
|
|
9
|
+
export const hasRow = (row, { optionCount, hasSelectAll, hasAddNew }) => (row >= 0 && row < optionCount) || (row === SELECT_ALL_ROW && hasSelectAll) || (row === ADD_NEW_ROW && hasAddNew);
|
|
10
|
+
export const stepRow = (layout, current, delta) => {
|
|
11
|
+
const rows = navRows(layout);
|
|
12
|
+
if (!rows.length)
|
|
13
|
+
return NO_ROW;
|
|
14
|
+
const at = rows.indexOf(current);
|
|
15
|
+
if (at < 0)
|
|
16
|
+
return delta > 0 ? rows[0] : rows[rows.length - 1];
|
|
17
|
+
return rows[(at + delta + rows.length) % rows.length];
|
|
18
|
+
};
|
|
19
|
+
export const firstRow = ({ optionCount, hasSelectAll, hasAddNew }) => {
|
|
20
|
+
if (hasSelectAll)
|
|
21
|
+
return SELECT_ALL_ROW;
|
|
22
|
+
if (optionCount > 0)
|
|
23
|
+
return 0;
|
|
24
|
+
return hasAddNew ? ADD_NEW_ROW : NO_ROW;
|
|
25
|
+
};
|
|
26
|
+
export const lastRow = ({ optionCount, hasSelectAll, hasAddNew }) => {
|
|
27
|
+
if (hasAddNew)
|
|
28
|
+
return ADD_NEW_ROW;
|
|
29
|
+
if (optionCount > 0)
|
|
30
|
+
return optionCount - 1;
|
|
31
|
+
return hasSelectAll ? SELECT_ALL_ROW : NO_ROW;
|
|
32
|
+
};
|
|
@@ -3,9 +3,10 @@ import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, us
|
|
|
3
3
|
import { Box, Checkbox, FormControl, Input, Popover, PopoverAnchor, PopoverContent, Portal, Spinner, useDisclosure, useMergeRefs, } from "@chakra-ui/react";
|
|
4
4
|
import { Check, ChevronDown, X } from "lucide-react";
|
|
5
5
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
6
|
+
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
6
7
|
import { focusGlowShadow } from "../../Theme/chakra/focusRing.styles.js";
|
|
7
8
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
|
-
import { optionRowDescriptionInk, optionRowInk, optionRowWeight } from "./optionRowInk.js";
|
|
9
|
+
import { optionRowDescriptionInk, optionRowFill, optionRowInk, optionRowWeight } from "./optionRowInk.js";
|
|
9
10
|
import { optionRowSpec } from "../../Theme/tokens/primitives/optionRowSizes.js";
|
|
10
11
|
import { scrollbarStyles } from "../../Theme/tokens/builders/scrollbar.js";
|
|
11
12
|
import { CONTROL_SIZES, DEFAULT_CONTROL_SIZE } from "../../Theme/tokens/primitives/controlSizes.js";
|
|
@@ -35,9 +36,7 @@ const parseRemToPx = (value, fallbackPx) => {
|
|
|
35
36
|
};
|
|
36
37
|
const OptionRow = React.memo(function OptionRow({ option, index, listboxId, isSelected, isActive, isMulti, theme, backgrounds, spec, renderOption, onSelect, onActivate, }) {
|
|
37
38
|
const isSingleSelected = isSelected && !isMulti;
|
|
38
|
-
|
|
39
|
-
const restBg = isActive ? backgrounds.active : "transparent";
|
|
40
|
-
return (_jsxs(Box, { id: optionDomId(listboxId, option.id), "data-index": index, role: "option", "aria-selected": isSelected, "aria-disabled": option.isDisabled, onMouseEnter: () => onActivate(index), onClick: () => onSelect(option), mx: spec.mx, px: spec.px, py: spec.py, minH: spec.minH, borderRadius: "md", cursor: option.isDisabled ? "not-allowed" : "pointer", opacity: option.isDisabled ? 0.4 : 1, display: "flex", alignItems: "center", gap: spec.gap, fontSize: spec.fontSize, fontWeight: optionRowWeight(isSingleSelected), color: optionRowInk(theme.colors, isSingleSelected), bg: isSingleSelected ? selectedBg : restBg, transition: ROW_TRANSITION, sx: reducedMotionSx(), children: [isMulti ? (_jsx(Checkbox, { id: `${optionDomId(listboxId, option.id)}-checkbox`, isChecked: isSelected, isDisabled: option.isDisabled, pointerEvents: "none", tabIndex: -1, sx: DECORATIVE_CHECKBOX_SX })) : null, renderOption ? (_jsx(Box, { flex: 1, minW: 0, children: renderOption(option, { isSelected, isActive }) })) : (_jsxs(_Fragment, { children: [option.icon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, children: option.icon })) : null, _jsxs(Box, { flex: 1, minW: 0, isTruncated: true, children: [_jsx(Box, { as: "span", isTruncated: true, children: option.label }), option.description ? (_jsx(Box, { as: "span", display: "block", fontSize: spec.descriptionFontSize, color: optionRowDescriptionInk(theme.colors), isTruncated: true, children: option.description })) : null] })] })), isSingleSelected ? (_jsx(Box, { as: Check, size: spec.iconSize, color: theme.colors.accentText, flexShrink: 0 })) : null] }));
|
|
39
|
+
return (_jsxs(Box, { id: optionDomId(listboxId, option.id), "data-index": index, role: "option", "aria-selected": isSelected, "aria-disabled": option.isDisabled, onMouseEnter: () => onActivate(index), onClick: () => onSelect(option), mx: spec.mx, px: spec.px, py: spec.py, minH: spec.minH, borderRadius: "md", cursor: option.isDisabled ? "not-allowed" : "pointer", opacity: option.isDisabled ? 0.4 : 1, display: "flex", alignItems: "center", gap: spec.gap, fontSize: spec.fontSize, fontWeight: optionRowWeight(isSingleSelected), color: optionRowInk(theme.colors, isSingleSelected), bg: optionRowFill(backgrounds, isActive), transition: ROW_TRANSITION, sx: reducedMotionSx(), children: [isMulti ? (_jsx(Checkbox, { id: `${optionDomId(listboxId, option.id)}-checkbox`, isChecked: isSelected, isDisabled: option.isDisabled, pointerEvents: "none", tabIndex: -1, sx: DECORATIVE_CHECKBOX_SX })) : null, renderOption ? (_jsx(Box, { flex: 1, minW: 0, children: renderOption(option, { isSelected, isActive }) })) : (_jsxs(_Fragment, { children: [option.icon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, children: option.icon })) : null, _jsxs(Box, { flex: 1, minW: 0, isTruncated: true, children: [_jsx(Box, { as: "span", isTruncated: true, children: option.label }), option.description ? (_jsx(Box, { as: "span", display: "block", fontSize: spec.descriptionFontSize, color: optionRowDescriptionInk(theme.colors), isTruncated: true, children: option.description })) : null] })] })), isSingleSelected ? (_jsx(Box, { as: Check, size: spec.iconSize, color: theme.colors.accentText, flexShrink: 0 })) : null] }));
|
|
41
40
|
});
|
|
42
41
|
const buildGroupedRows = (options) => {
|
|
43
42
|
const rows = [];
|
|
@@ -436,7 +435,7 @@ const SelectPopup = forwardRef(function SelectPopup(props, ref) {
|
|
|
436
435
|
const selectedValueIds = selectedOptions.map((option) => option.id.toString());
|
|
437
436
|
const hiddenValues = !name ? [] : props.isMulti ? selectedValueIds : [(_c = selectedValueIds[0]) !== null && _c !== void 0 ? _c : ""];
|
|
438
437
|
const groupedRows = useMemo(() => (hasGroups ? buildGroupedRows(filteredOptions) : []), [hasGroups, filteredOptions]);
|
|
439
|
-
return (_jsxs(FormControl, { isInvalid: error, isDisabled: isDisabled, isReadOnly: isReadOnly, style: formControlStyle, width: width, children: [label && (_jsx(TextLabel, { label: label, id: ids.inputId, isRequired: isRequired, isInformation: isInformation, informationMessage: informationMessage })), _jsxs(Popover, { isOpen: isOpen, onClose: () => resetAndClose(), placement: "bottom-start", autoFocus: false, returnFocusOnClose: false, gutter: 4, children: [_jsx(PopoverAnchor, { children: _jsxs(Box, { as: "div", ref: mergedTriggerRef, ...ids.controlProps, role: "combobox", tabIndex: isDisabled ? -1 : 0, "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-controls": listboxId, "aria-owns": `${listboxId} ${filterInputId}`, "aria-activedescendant": activeDescendantId, "aria-disabled": isDisabled || undefined, "data-readonly": isReadOnly || undefined, "aria-required": isRequired || undefined, "aria-label": triggerAriaLabel(), "aria-labelledby": ariaLabelledBy, onClick: handleOpen, onKeyDown: handleTriggerKeyDown, display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%", textAlign: "left", cursor: isDisabled ? "not-allowed" : isReadOnly ? "default" : "pointer", "data-testid": dataTestId, sx: triggerSx, children: [_jsx(Box, { as: "span", display: "inline-flex", flexWrap: showChips ? "wrap" : "nowrap", alignItems: "center", gap: showChips ? 1 : 1.5, minW: 0, flex: 1, isTruncated: !showChips, children: showChips ? (_jsxs(_Fragment, { children: [visibleChipOptions.map((option) => (_jsx(Tag, { label: String(option.label), size: chipSize, variant: "subtle", icon: isInteractive ? X : undefined, onIconClick: isInteractive ? () => handleSelect(option) : undefined }, option.id))), overflowChipCount > 0 && (_jsx(Tag, { label: `+${overflowChipCount}`, size: chipSize, variant: "subtle", colorScheme: "gray" }))] })) : (_jsxs(_Fragment, { children: [triggerIcon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, children: triggerIcon })) : null, _jsx(Box, { as: "span", isTruncated: true, children: renderValue ? renderValue(selectedOptions) : defaultTriggerContent() })] })) }), showClear && (_jsx(Box, { as: "button", type: "button", "aria-label": "Clear selection", onClick: handleClear, display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0, ml: 2, color: colors.textMuted, _hover: { color: colors.text[700] }, children: _jsx(X, { size: CONTROL_SIZES[size].iconSize }) })), _jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, ml: 2, transition: CHEVRON_TRANSITION, transform: isOpen ? "rotate(180deg)" : "rotate(0deg)", color: colors.textMuted, sx: reducedMotionSx(), children: _jsx(ChevronDown, { size: CONTROL_SIZES[size].iconSize }) })] }) }), _jsx(Portal, { children: _jsxs(PopoverContent, { "aria-label": (_d = label !== null && label !== void 0 ? label : ariaLabel) !== null && _d !== void 0 ? _d : placeholder, width: "max-content", minWidth: triggerWidth ? `${triggerWidth}px` : undefined, maxWidth: "min(24rem, calc(100vw - 2rem))", borderRadius: "xl", boxShadow: theme.shadows.lg, overflow: "hidden", onKeyDown: handleListKeyDown, children: [_jsx(Box, { p: spec.mx, borderBottom: `${BORDER_WIDTHS.hairline} solid ${colors
|
|
438
|
+
return (_jsxs(FormControl, { isInvalid: error, isDisabled: isDisabled, isReadOnly: isReadOnly, style: formControlStyle, width: width, children: [label && (_jsx(TextLabel, { label: label, id: ids.inputId, isRequired: isRequired, isInformation: isInformation, informationMessage: informationMessage })), _jsxs(Popover, { isOpen: isOpen, onClose: () => resetAndClose(), placement: "bottom-start", autoFocus: false, returnFocusOnClose: false, gutter: 4, children: [_jsx(PopoverAnchor, { children: _jsxs(Box, { as: "div", ref: mergedTriggerRef, ...ids.controlProps, role: "combobox", tabIndex: isDisabled ? -1 : 0, "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-controls": listboxId, "aria-owns": `${listboxId} ${filterInputId}`, "aria-activedescendant": activeDescendantId, "aria-disabled": isDisabled || undefined, "data-readonly": isReadOnly || undefined, "aria-required": isRequired || undefined, "aria-label": triggerAriaLabel(), "aria-labelledby": ariaLabelledBy, onClick: handleOpen, onKeyDown: handleTriggerKeyDown, display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%", textAlign: "left", cursor: isDisabled ? "not-allowed" : isReadOnly ? "default" : "pointer", "data-testid": dataTestId, sx: triggerSx, children: [_jsx(Box, { as: "span", display: "inline-flex", flexWrap: showChips ? "wrap" : "nowrap", alignItems: "center", gap: showChips ? 1 : 1.5, minW: 0, flex: 1, isTruncated: !showChips, children: showChips ? (_jsxs(_Fragment, { children: [visibleChipOptions.map((option) => (_jsx(Tag, { label: String(option.label), size: chipSize, variant: "subtle", icon: isInteractive ? X : undefined, onIconClick: isInteractive ? () => handleSelect(option) : undefined }, option.id))), overflowChipCount > 0 && (_jsx(Tag, { label: `+${overflowChipCount}`, size: chipSize, variant: "subtle", colorScheme: "gray" }))] })) : (_jsxs(_Fragment, { children: [triggerIcon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, children: triggerIcon })) : null, _jsx(Box, { as: "span", isTruncated: true, children: renderValue ? renderValue(selectedOptions) : defaultTriggerContent() })] })) }), showClear && (_jsx(Box, { as: "button", type: "button", "aria-label": "Clear selection", onClick: handleClear, display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0, ml: 2, color: colors.textMuted, _hover: { color: colors.text[700] }, children: _jsx(X, { size: CONTROL_SIZES[size].iconSize }) })), _jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, ml: 2, transition: CHEVRON_TRANSITION, transform: isOpen ? "rotate(180deg)" : "rotate(0deg)", color: colors.textMuted, sx: reducedMotionSx(), children: _jsx(ChevronDown, { size: CONTROL_SIZES[size].iconSize }) })] }) }), _jsx(Portal, { children: _jsxs(PopoverContent, { "aria-label": (_d = label !== null && label !== void 0 ? label : ariaLabel) !== null && _d !== void 0 ? _d : placeholder, width: "max-content", minWidth: triggerWidth ? `${triggerWidth}px` : undefined, maxWidth: "min(24rem, calc(100vw - 2rem))", borderRadius: "xl", boxShadow: theme.shadows.lg, overflow: "hidden", onKeyDown: handleListKeyDown, children: [_jsx(Box, { p: spec.mx, borderBottom: `${BORDER_WIDTHS.hairline} solid ${raisedRule(colors)}`, display: isSearchable ? undefined : "none", children: _jsx(Input, { ref: filterInputRef, id: filterInputId, size: size, px: spec.px, placeholder: "Type to filter...", value: currentSearch, onChange: handleFilterChange, "aria-activedescendant": activeDescendantId, "aria-controls": listboxId, "aria-label": "Filter options", tabIndex: isSearchable ? undefined : -1 }) }), _jsxs(Box, { id: listboxId, ref: listRef, role: "listbox", "aria-label": (_e = label !== null && label !== void 0 ? label : ariaLabel) !== null && _e !== void 0 ? _e : placeholder, "aria-multiselectable": props.isMulti || undefined, "aria-busy": isLoading || undefined, maxH: maxMenuHeight, overflowY: "auto", py: 1, sx: listScrollStyles, onScroll: handleListScroll, children: [filteredOptions.length === 0 && !isLoading && !showCreateRow && (_jsx(Box, { mx: spec.mx, px: spec.px, py: spec.py, fontSize: spec.fontSize, color: colors.textMuted, children: noOptionsMessage !== null && noOptionsMessage !== void 0 ? noOptionsMessage : "No Options" })), showCreateRow && (_jsx(Box, { id: createRowId, role: "option", "aria-selected": false, "data-index": -1, onClick: handleCreate, mx: spec.mx, px: spec.px, py: spec.py, minH: spec.minH, borderRadius: "md", cursor: "pointer", fontSize: spec.fontSize, fontWeight: 600, color: colors.primary[600], bg: activeDescendantId === createRowId ? rowBackgrounds.active : "transparent", children: createLabel ? createLabel(currentSearch.trim()) : `Create "${currentSearch.trim()}"` })), hasGroups
|
|
440
439
|
? groupedRows.map((row) => {
|
|
441
440
|
var _a;
|
|
442
441
|
return row.kind === "header" ? (_jsx(Box, { mx: spec.mx, px: spec.px, pt: 2, pb: 1, fontSize: "xs-minus", fontWeight: 600, textTransform: "uppercase", letterSpacing: "0.03em", color: colors.textMuted, children: row.group }, row.key)) : (_jsx(OptionRow, { option: row.option, index: row.index, listboxId: listboxId, isSelected: selectedIds.has(row.option.id.toString()), isActive: row.index === activeIndex, isMulti: (_a = props.isMulti) !== null && _a !== void 0 ? _a : false, theme: theme, backgrounds: rowBackgrounds, spec: spec, renderOption: renderOption, onSelect: handleSelect, onActivate: setActiveIndex }, row.key));
|
|
@@ -5,6 +5,13 @@ import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
|
5
5
|
export const optionRowInk = (colors, isSingleSelected) => isSingleSelected ? colors.text[900] : colors.text[700];
|
|
6
6
|
// A 12px sub-line reached only 4.00:1 on the hovered selected row in dark.
|
|
7
7
|
export const optionRowDescriptionInk = (colors) => liftToContrast(colors.textMuted, listRowBackgrounds(colors).selectedActive, AA_NORMAL_TEXT);
|
|
8
|
+
/** The one fill an option row paints: the cursor's (hover or keyboard). Selection never fills a row. */
|
|
9
|
+
export const optionRowFill = (rows, isActive) => isActive ? rows.active : "transparent";
|
|
10
|
+
/** Fill for rows that take real DOM focus (roving tabindex) — `:hover` and `:focus` are the cursor. */
|
|
11
|
+
export const optionRowCursorSx = (rows) => ({
|
|
12
|
+
_hover: { bg: rows.active },
|
|
13
|
+
_focus: { bg: rows.active },
|
|
14
|
+
});
|
|
8
15
|
export const OPTION_ROW_REST_WEIGHT = 400;
|
|
9
16
|
// NOTE: 600 beside a tinted fill and a check read as three signals for one state.
|
|
10
17
|
export const OPTION_ROW_SELECTED_WEIGHT = 500;
|
|
@@ -12,8 +12,9 @@ import { DEFAULT_CONTROL_SIZE } from "../../Theme/tokens/primitives/controlSizes
|
|
|
12
12
|
import { optionRowSpec, OPTION_ROW_RADIUS } from "../../Theme/tokens/primitives/optionRowSizes.js";
|
|
13
13
|
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
14
14
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
15
|
+
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
15
16
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
16
|
-
import { optionRowDescriptionInk, optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
17
|
+
import { optionRowCursorSx, optionRowDescriptionInk, optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
17
18
|
import { useExclusiveOverlay } from "../../Hooks/useExclusiveOverlay.js";
|
|
18
19
|
import { PlusIcon, Check } from "lucide-react";
|
|
19
20
|
const ROW_TRANSITION = transitionFor(["background-color"]);
|
|
@@ -29,18 +30,9 @@ const RenderOptions = ({ isOptionLoading, filteredOptions, loadingText, handleOp
|
|
|
29
30
|
const selected = isOptionSelected(option);
|
|
30
31
|
const isSingleSelected = selected && !isMultipleSelect;
|
|
31
32
|
const isActive = index === activeIndex;
|
|
32
|
-
const rowBg = selected
|
|
33
|
-
? isActive
|
|
34
|
-
? rowBackgrounds.selectedActive
|
|
35
|
-
: rowBackgrounds.selected
|
|
36
|
-
: isActive
|
|
37
|
-
? rowBackgrounds.active
|
|
38
|
-
: "transparent";
|
|
39
33
|
return (_jsxs(Box, { as: "button", type: "button", ref: (el) => {
|
|
40
34
|
optionRefs.current[index] = el;
|
|
41
|
-
}, role: "option", "aria-selected": selected, tabIndex: isActive ? 0 : -1, w: `calc(100% - 2 * ${spec.mx})`, minH: spec.minH, textAlign: "left", border: "none", fontFamily: "inherit", bg:
|
|
42
|
-
bg: selected ? rowBackgrounds.selectedActive : rowBackgrounds.active,
|
|
43
|
-
}, onClick: () => handleOptionClick(option), onKeyDown: (e) => {
|
|
35
|
+
}, role: "option", "aria-selected": selected, tabIndex: isActive ? 0 : -1, w: `calc(100% - 2 * ${spec.mx})`, minH: spec.minH, textAlign: "left", border: "none", fontFamily: "inherit", bg: "transparent", mx: spec.mx, px: spec.px, py: spec.py, borderRadius: OPTION_ROW_RADIUS, fontSize: spec.fontSize, cursor: "pointer", color: optionRowInk(theme.colors, isSingleSelected), fontWeight: optionRowWeight(isSingleSelected), transition: ROW_TRANSITION, sx: reducedMotionSx(), ...optionRowCursorSx(rowBackgrounds), onClick: () => handleOptionClick(option), onKeyDown: (e) => {
|
|
44
36
|
if (e.key === "Enter" || e.key === " ") {
|
|
45
37
|
e.preventDefault();
|
|
46
38
|
handleOptionClick(option);
|
|
@@ -229,7 +221,7 @@ export default function SelectSearch({ options, initialSelectedOption, onOptionS
|
|
|
229
221
|
return;
|
|
230
222
|
}
|
|
231
223
|
openDropdown();
|
|
232
|
-
}, onChange: (e) => handleInputChange(e.target.value), placeholder: placeholder, onKeyDown: handleKeyDown, name: name, role: "combobox", "aria-autocomplete": "list", "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-controls": listboxId, "aria-required": isRequired || undefined, cursor: "pointer", sx: { ...fieldControlStyles(theme.colors), ...controlSizeStyles(size), ...reducedMotionSx() }, style: inputStyle }), rightIcon && (_jsx(InputRightElement, { pointerEvents: "none", height: "100%", display: "flex", alignItems: "center", children: rightIcon, style: { ...rightElementStyle } }))] }), isOpen && (_jsxs(Box, { ref: dropdownRef, marginTop: "0.313rem", position: "absolute", top: position === "below" ? "100%" : "auto", bottom: position === "above" ? "100%" : "auto", left: 0, right: 0, border: `${BORDER_WIDTHS.hairline} solid`, borderColor: theme.colors.boxborder[200], borderRadius: "xl", boxShadow: theme.shadows.lg, bg: theme.colors.surfaceRaised, maxHeight: "9.375rem", overflowY: "auto", zIndex: 10, children: [_jsx(Box, { id: listboxId, role: "listbox", "aria-label": label !== null && label !== void 0 ? label : placeholder, onKeyDown: handleListKeyDown, children: _jsx(RenderOptions, { isOptionLoading: isOptionLoading, filteredOptions: filteredOptions, loadingText: loadingText, handleOptionClick: handleOptionClick, isProfile: isProfile, isColorOptions: isColorOptions, isOptionSelected: isOptionSelected, activeIndex: activeIndex, optionRefs: optionRefs, size: size, isMultipleSelect: isMultipleSelect }) }), _jsx("hr", {}), isBottomIcon && (_jsxs(Box, { position: "sticky", bottom: 0, background: theme.colors.surfaceRaised, display: "flex", alignItems: "center", pl: "1rem", cursor: "pointer", onClick: handleBottomClick, borderColor: theme.colors
|
|
224
|
+
}, onChange: (e) => handleInputChange(e.target.value), placeholder: placeholder, onKeyDown: handleKeyDown, name: name, role: "combobox", "aria-autocomplete": "list", "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-controls": listboxId, "aria-required": isRequired || undefined, cursor: "pointer", sx: { ...fieldControlStyles(theme.colors), ...controlSizeStyles(size), ...reducedMotionSx() }, style: inputStyle }), rightIcon && (_jsx(InputRightElement, { pointerEvents: "none", height: "100%", display: "flex", alignItems: "center", children: rightIcon, style: { ...rightElementStyle } }))] }), isOpen && (_jsxs(Box, { ref: dropdownRef, marginTop: "0.313rem", position: "absolute", top: position === "below" ? "100%" : "auto", bottom: position === "above" ? "100%" : "auto", left: 0, right: 0, border: `${BORDER_WIDTHS.hairline} solid`, borderColor: theme.colors.boxborder[200], borderRadius: "xl", boxShadow: theme.shadows.lg, bg: theme.colors.surfaceRaised, maxHeight: "9.375rem", overflowY: "auto", zIndex: 10, children: [_jsx(Box, { id: listboxId, role: "listbox", "aria-label": label !== null && label !== void 0 ? label : placeholder, onKeyDown: handleListKeyDown, children: _jsx(RenderOptions, { isOptionLoading: isOptionLoading, filteredOptions: filteredOptions, loadingText: loadingText, handleOptionClick: handleOptionClick, isProfile: isProfile, isColorOptions: isColorOptions, isOptionSelected: isOptionSelected, activeIndex: activeIndex, optionRefs: optionRefs, size: size, isMultipleSelect: isMultipleSelect }) }), _jsx("hr", {}), isBottomIcon && (_jsxs(Box, { position: "sticky", bottom: 0, background: theme.colors.surfaceRaised, display: "flex", alignItems: "center", pl: "1rem", cursor: "pointer", onClick: handleBottomClick, borderColor: raisedRule(theme.colors), zIndex: 1, borderTop: `1px solid ${raisedRule(theme.colors)}`, children: [_jsx(Box, { children: BottomIcon ? BottomIcon : _jsx(PlusIcon, { size: "1rem" }) }), _jsx(Box, { fontSize: "sm", color: BottomTextColor
|
|
233
225
|
? BottomTextColor
|
|
234
226
|
: theme.colors.accentText, padding: "8px 8px", children: BottomText || "Add New" })] }))] })), _jsx(FieldMessage, { error: error, errorMessage: errorMessage, helperText: helperText, helperId: ids.helperId, errorId: ids.errorId })] }) }) }));
|
|
235
227
|
}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { Box, Divider, Flex, Grid, Text } from "@chakra-ui/react";
|
|
3
3
|
import { cloneElement, isValidElement, useId } from "react";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
|
+
import { cardRule } from "../../Theme/tokens/builders/planeStep.js";
|
|
5
6
|
/** One settings-form row: title + description left, one right-aligned control; stacks on mobile. */
|
|
6
7
|
const SettingRow = ({ title, description, control, htmlFor, descriptionId, isDisabled = false }) => {
|
|
7
8
|
var _a;
|
|
@@ -17,6 +18,6 @@ const SettingRow = ({ title, description, control, htmlFor, descriptionId, isDis
|
|
|
17
18
|
"aria-describedby": (_a = controlProps === null || controlProps === void 0 ? void 0 : controlProps["aria-describedby"]) !== null && _a !== void 0 ? _a : resolvedDescriptionId,
|
|
18
19
|
})
|
|
19
20
|
: control;
|
|
20
|
-
return (_jsxs(_Fragment, { children: [_jsx(Divider, { borderColor: colors
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx(Divider, { borderColor: cardRule(colors) }), _jsxs(Grid, { templateColumns: { base: "1fr", md: "15rem 1fr" }, gap: { base: 2, md: 6 }, py: 4, alignItems: "start", opacity: isDisabled ? 0.5 : 1, "aria-disabled": isDisabled || undefined, children: [_jsxs(Box, { children: [htmlFor ? (_jsx(Text, { as: "label", htmlFor: htmlFor, display: "block", fontSize: "sm", fontWeight: 500, color: colors.text[800], children: title })) : (_jsx(Text, { id: titleId, fontSize: "sm", fontWeight: 500, color: colors.text[800], children: title })), _jsx(Text, { id: resolvedDescriptionId, mt: 0.5, fontSize: "xs-plus", color: colors.textMuted, children: description })] }), _jsx(Flex, { minW: 0, justify: { base: "flex-start", md: "flex-end" }, children: namedControl })] })] }));
|
|
21
22
|
};
|
|
22
23
|
export default SettingRow;
|
|
@@ -2,10 +2,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Box, Divider, Flex, Heading, Text } from "@chakra-ui/react";
|
|
3
3
|
import Card from "../Card/Card.js";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
|
+
import { cardRule } from "../../Theme/tokens/builders/planeStep.js";
|
|
5
6
|
/** Titled Card wrapping SettingRows; rows and an optional footer separate with one divider each, never a nested border. */
|
|
6
7
|
const SettingsSection = ({ id, title, description, children, footer, action, isDanger = false }) => {
|
|
7
8
|
const { colors } = useCustomTheme();
|
|
8
9
|
const titleColor = isDanger ? colors.semanticText.error : colors.header[900];
|
|
9
|
-
return (_jsxs(Card, { id: id, scrollMarginTop: 4, borderColor: isDanger ? colors.semanticText.error : undefined, header: _jsxs(Flex, { align: "flex-start", gap: 3, children: [_jsxs(Box, { flex: 1, minW: 0, children: [_jsx(Heading, { as: "h2", fontSize: "md", fontWeight: 600, color: titleColor, children: title }), description && (_jsx(Text, { mt: 0.5, fontSize: "xs", fontWeight: 400, color: colors.textMuted, children: description }))] }), action && _jsx(Box, { flexShrink: 0, children: action })] }), children: [children, footer && (_jsxs(_Fragment, { children: [_jsx(Divider, { borderColor: colors
|
|
10
|
+
return (_jsxs(Card, { id: id, scrollMarginTop: 4, variant: isDanger ? "outline" : undefined, borderColor: isDanger ? colors.semanticText.error : undefined, header: _jsxs(Flex, { align: "flex-start", gap: 3, children: [_jsxs(Box, { flex: 1, minW: 0, children: [_jsx(Heading, { as: "h2", fontSize: "md", fontWeight: 600, color: titleColor, children: title }), description && (_jsx(Text, { mt: 0.5, fontSize: "xs", fontWeight: 400, color: colors.textMuted, children: description }))] }), action && _jsx(Box, { flexShrink: 0, children: action })] }), children: [children, footer && (_jsxs(_Fragment, { children: [_jsx(Divider, { borderColor: cardRule(colors) }), _jsx(Box, { pt: 4, children: footer })] }))] }));
|
|
10
11
|
};
|
|
11
12
|
export default SettingsSection;
|
|
@@ -17,6 +17,7 @@ import { sidebarRowPeak } from "../../Theme/tokens/builders/sidebarAccent.js";
|
|
|
17
17
|
import { scaleFor } from "../../Theme/chakra/paletteFromTheme.js";
|
|
18
18
|
import { fullViewportHeight } from "../../Theme/tokens/builders/viewportHeight.js";
|
|
19
19
|
import { SIDEBAR_ROW } from "./sidebarScale.js";
|
|
20
|
+
import { SIDEBAR_BG_TRANSITION, SIDEBAR_INK_TRANSITION } from "./sidebarMotion.js";
|
|
20
21
|
const softBadge = (colors, colorScheme, surface) => {
|
|
21
22
|
const tone = resolveSoftTone(colors, scaleFor(colors, colorScheme), surface);
|
|
22
23
|
return { bg: tone.bg, color: tone.fg };
|
|
@@ -48,7 +49,7 @@ const CollapsedItem = ({ item, isActive, itemFontSize, onItemClick }) => {
|
|
|
48
49
|
e.preventDefault();
|
|
49
50
|
if (!blocked)
|
|
50
51
|
onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item);
|
|
51
|
-
}, bg: isActive ? "whiteAlpha.300" : "transparent", transition:
|
|
52
|
+
}, bg: isActive ? "whiteAlpha.300" : "transparent", transition: SIDEBAR_BG_TRANSITION, sx: sidebarFocusStyles(theme.colors), children: _jsxs(Box, { position: "relative", display: "flex", alignItems: "center", children: [_jsx(Icon, { as: item.icon, fontSize: SIDEBAR_ROW.iconSize, color: isActive ? activeAccent.icon : theme.colors.sidebar.mutedIcon, _groupHover: isActive ? undefined : { color: theme.colors.white }, transition: SIDEBAR_INK_TRANSITION }), badgeVal != null && (_jsx(Box, { position: "absolute", top: "0", right: "0", w: "0.375rem", h: "0.375rem", borderRadius: "full", bg: theme.colors.sidebar.semanticText.error }))] }) }) }), _jsx(Portal, { children: _jsx(PopoverContent, { borderRadius: "lg", bg: theme.colors.sidebar.elevated, boxShadow: "lg", minW: "10rem", maxW: "14rem", py: "0.125rem", ml: "-0.5rem", cursor: blocked ? "not-allowed" : "pointer", zIndex: zIndices.popover, color: theme.colors.white, border: 'none', children: _jsx(PopoverBody, { p: 3, children: _jsxs(Flex, { align: "center", gap: 2, justify: "space-between", children: [_jsxs(Flex, { align: "center", gap: 2, flex: "1", minW: 0, children: [_jsx(Icon, { as: item.icon, fontSize: "md", flexShrink: 0 }), _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: itemFontSize, fontWeight: 500, as: "p", children: item.title })] }), item.locked ? (item.lockedReason ? (_jsx(ToolTip, { label: item.lockedReason, placement: "top", children: _jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon }) })) : (_jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon }))) : (badgeVal != null && (_jsx(Badge, { ...softBadge(theme.colors, colorScheme, sidebarRowPeak(theme.colors.sidebar.elevated)), fontSize: "xs", variant: variant, borderRadius: radius, children: badgeVal })))] }) }) }) })] }));
|
|
52
53
|
};
|
|
53
54
|
const ExpandedItem = ({ item, isActive, itemFontSize, onItemClick }) => {
|
|
54
55
|
var _a;
|
|
@@ -62,7 +63,7 @@ const ExpandedItem = ({ item, isActive, itemFontSize, onItemClick }) => {
|
|
|
62
63
|
e.preventDefault();
|
|
63
64
|
if (!blocked)
|
|
64
65
|
onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item);
|
|
65
|
-
}, borderLeft: "2px solid", borderLeftColor: isActive ? theme.colors.sidebar.activeIcon : "transparent", transition:
|
|
66
|
+
}, borderLeft: "2px solid", borderLeftColor: isActive ? theme.colors.sidebar.activeIcon : "transparent", transition: SIDEBAR_BG_TRANSITION, sx: sidebarFocusStyles(theme.colors), children: [_jsxs(Flex, { align: "center", gap: 2, flex: "1", minW: 0, overflow: "hidden", children: [_jsx(Icon, { as: item.icon, fontSize: SIDEBAR_ROW.iconSize, flexShrink: 0, color: isActive ? activeAccent.icon : theme.colors.sidebar.mutedIcon, _groupHover: isActive ? undefined : { color: theme.colors.white }, transition: SIDEBAR_INK_TRANSITION }), _jsx(Box, { flex: "1", minW: 0, children: _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: itemFontSize, fontWeight: isActive ? 600 : 500, color: isActive ? activeAccent.label : theme.colors.white, _groupHover: isActive ? undefined : { color: theme.colors.white }, as: "p", children: item.title }) })] }), item.locked ? (_jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon })) : (badgeVal != null && (_jsx(Badge, { ...softBadge(theme.colors, colorScheme, sidebarRowPeak(theme.colors.sidebar.background[500])), fontSize: "xs", variant: variant, borderRadius: radius, children: badgeVal })))] }));
|
|
66
67
|
return item.locked && item.lockedReason ? (_jsx(ToolTip, { label: item.lockedReason, placement: "top", children: row })) : (row);
|
|
67
68
|
};
|
|
68
69
|
const SecondaryBar = ({ items = [], defaultCollapsed = true, collapsedWidth = "3.5rem", expandedWidth = "10rem", headerFontSize = SIDEBAR_ROW.fontSize, itemFontSize = SIDEBAR_ROW.fontSize, selected, onItemClick, title, icon, }) => {
|
|
@@ -71,7 +72,7 @@ const SecondaryBar = ({ items = [], defaultCollapsed = true, collapsedWidth = "3
|
|
|
71
72
|
const scrollContainerId = sanitizeId(useId());
|
|
72
73
|
const [collapsed, setCollapsed] = useState(defaultCollapsed);
|
|
73
74
|
const width = collapsed ? collapsedWidth : expandedWidth;
|
|
74
|
-
return (_jsx(Box, { as: "nav", "aria-label": title ? `${title} navigation` : "Secondary navigation", transition: transitionFor(["width"], "base"), pos: "sticky", top: 0, sx: fullViewportHeight, w: width, bg: theme.colors.sidebar.background[500], borderLeft: "1px solid", borderColor: theme.colors.sidebar.divider, boxShadow: theme.shadows.md, zIndex: 1, children: _jsxs(VStack, { align: "stretch", spacing: 0, h: "100%", children: [_jsxs(Flex, { align: "center", justify: collapsed ? "center" : "space-between", px: collapsed ? 0 : "10px", gap: "7px", h: HEADER_HEIGHT, overflow: "hidden", borderBottom: "1px solid", borderColor: theme.colors.sidebar.divider, flexShrink: 0, children: [!collapsed && (_jsxs(_Fragment, { children: [icon && (_jsx(Icon, { as: icon, fontSize: SIDEBAR_ROW.iconSize, color: activeAccent.icon, flexShrink: 0 })), _jsx(Box, { flex: "1", minW: 0, children: _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: headerFontSize, fontWeight: 600, color: theme.colors.white, as: "p", children: title !== null && title !== void 0 ? title : "" }) })] })), _jsx(Box, { as: "button", type: "button", "aria-label": collapsed ? "Expand navigation panel" : "Collapse navigation panel", "aria-expanded": !collapsed, border: "none", bg: "transparent", w: "24px", h: "24px", borderRadius: "lg", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer", flexShrink: 0, onClick: () => setCollapsed((c) => !c), _hover: { bg: "whiteAlpha.200" }, transition:
|
|
75
|
+
return (_jsx(Box, { as: "nav", "aria-label": title ? `${title} navigation` : "Secondary navigation", transition: transitionFor(["width"], "base"), pos: "sticky", top: 0, sx: fullViewportHeight, w: width, bg: theme.colors.sidebar.background[500], borderLeft: "1px solid", borderColor: theme.colors.sidebar.divider, boxShadow: theme.shadows.md, zIndex: 1, children: _jsxs(VStack, { align: "stretch", spacing: 0, h: "100%", children: [_jsxs(Flex, { align: "center", justify: collapsed ? "center" : "space-between", px: collapsed ? 0 : "10px", gap: "7px", h: HEADER_HEIGHT, overflow: "hidden", borderBottom: "1px solid", borderColor: theme.colors.sidebar.divider, flexShrink: 0, children: [!collapsed && (_jsxs(_Fragment, { children: [icon && (_jsx(Icon, { as: icon, fontSize: SIDEBAR_ROW.iconSize, color: activeAccent.icon, flexShrink: 0 })), _jsx(Box, { flex: "1", minW: 0, children: _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: headerFontSize, fontWeight: 600, color: theme.colors.white, as: "p", children: title !== null && title !== void 0 ? title : "" }) })] })), _jsx(Box, { as: "button", type: "button", "aria-label": collapsed ? "Expand navigation panel" : "Collapse navigation panel", "aria-expanded": !collapsed, border: "none", bg: "transparent", w: "24px", h: "24px", borderRadius: "lg", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer", flexShrink: 0, onClick: () => setCollapsed((c) => !c), _hover: { bg: "whiteAlpha.200" }, transition: SIDEBAR_BG_TRANSITION, sx: sidebarFocusStyles(theme.colors), children: collapsed ? (_jsx(ToolTip, { label: title !== null && title !== void 0 ? title : "", placement: "right", children: _jsx(ChevronRight, { size: 13, color: theme.colors.sidebar.mutedIcon }) })) : (_jsx(ChevronLeft, { size: 13, color: theme.colors.sidebar.mutedIcon })) })] }), _jsx(Box, { id: scrollContainerId, flex: "1", minH: 0, overflowY: "auto", overflowX: "hidden", py: 2, px: "6px", sx: cssForScrollBar(theme), children: items.map((item) => {
|
|
75
76
|
var _a;
|
|
76
77
|
const isActive = String(selected) === String(item.id) ||
|
|
77
78
|
String(selected) === String(item.title);
|
|
@@ -8,7 +8,8 @@ import { cssForScrollBar, HEADER_HEIGHT } from "../../Constants/Sidebar.js";
|
|
|
8
8
|
import { overlayScrimStyles } from "../../Theme/chakra/overlay.styles.js";
|
|
9
9
|
import { REDUCED_MOTION_QUERY } from "../../Theme/chakra/motion.js";
|
|
10
10
|
import { sidebarFocusStyles } from "./sidebarFocus.js";
|
|
11
|
-
import { MOTION_EASE, MOTION_MS } from "../../Theme/tokens/primitives/motion.js";
|
|
11
|
+
import { MOTION_EASE, MOTION_EASE_OUT, MOTION_MS, transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
12
|
+
import { SIDEBAR_BG_TRANSITION } from "./sidebarMotion.js";
|
|
12
13
|
import { ArrowLeftToLine, ArrowRightToLine, ChevronLeft, Maximize2, MoreVertical, PanelLeft, Plus, X } from "lucide-react";
|
|
13
14
|
// Overlay stacking — mirrors theme.zIndices (overlay=1300 scrim, modal=1400 panel).
|
|
14
15
|
const Z_SCRIM = 1300;
|
|
@@ -17,7 +18,6 @@ const Z_PANEL = 1400;
|
|
|
17
18
|
// expanded 13rem for comfortable touch targets, but below the old 16rem that was
|
|
18
19
|
// too wide on phones. Still capped by `maxW: 88vw` on very small screens.
|
|
19
20
|
const RAIL_WIDTH = "4.688rem";
|
|
20
|
-
const PANEL_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
21
21
|
const EXPANDED_WIDTH = "13rem";
|
|
22
22
|
const COLLAPSE_MS = { ...MOTION_MS, slow: 260 };
|
|
23
23
|
const NO_ACTIVE_MENU = "\u0000pinned-active";
|
|
@@ -26,13 +26,16 @@ const inlineTransitions = (collapse) => {
|
|
|
26
26
|
var _a;
|
|
27
27
|
if (collapse === "none")
|
|
28
28
|
return { width: "none", shadow: "none" };
|
|
29
|
-
const ms = COLLAPSE_MS[(_a = collapse.speed) !== null && _a !== void 0 ? _a : "
|
|
29
|
+
const ms = COLLAPSE_MS[(_a = collapse.speed) !== null && _a !== void 0 ? _a : "base"];
|
|
30
30
|
return {
|
|
31
|
-
width: `width ${ms}ms ${
|
|
31
|
+
width: `width ${ms}ms ${MOTION_EASE_OUT}`,
|
|
32
32
|
shadow: collapse.animateShadow === false ? "none" : `box-shadow ${ms}ms ${MOTION_EASE}`,
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
const OVERLAY_WIDTH = "14.7rem";
|
|
36
|
+
const SCRIM_TRANSITION = transitionFor(["opacity", "visibility"], "base");
|
|
37
|
+
const OVERLAY_SLIDE = transitionFor(["transform"], "enter", "out");
|
|
38
|
+
const OVERLAY_WIDTH_TRANSITION = transitionFor(["width"], "enter", "out");
|
|
36
39
|
const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
37
40
|
import MenuItems from "./components/MenuItems.js";
|
|
38
41
|
import DefaultLogo from "../../Assets/defaultLogo.js";
|
|
@@ -56,7 +59,7 @@ const SidebarHeader = ({ logo, companyName, companySubtitle, toggle, isLoading,
|
|
|
56
59
|
// Rail-safe pairing, not a raw primary fill: primary[500] equals the rail itself on
|
|
57
60
|
// some brands (zinc), making the tile disappear. See THEME-CONTRACT.md sidebar rules.
|
|
58
61
|
bg: theme.colors.sidebar.activeBg, color: activeAccent.label, borderRadius: "lg", boxSize: "1.75rem", display: "flex", alignItems: "center", justifyContent: "center", fontWeight: 700, flexShrink: 0, cursor: toggle ? "pointer" : undefined, onClick: toggle ? onToggle : undefined, children: _jsx(DefaultLogo, {}) }));
|
|
59
|
-
return (_jsxs(Flex, { h: HEADER_HEIGHT, w: "100%", alignItems: "center", justifyContent: toggle ? "center" : "flex-start", gap: 2, px: toggle ? "8px" : "10px", borderBottom: "1px solid", borderColor: theme.colors.sidebar.divider, minW: 0, overflow: "hidden", flexShrink: 0, children: [logoNode, !toggle && (_jsxs(Box, { flex: "1", minW: 0, children: [_jsx(OverflowTooltipText, { placement: "right", fontWeight: 600, fontSize: SIDEBAR_CHROME.titleFontSize, textAlign: "left", color: theme.colors.white, lineHeight: "1.3", as: "p", width: "100%", children: companyName !== null && companyName !== void 0 ? companyName : "" }), companySubtitle && (_jsx(Text, { fontSize: SIDEBAR_CHROME.metaFontSize, color: theme.colors.sidebar.mutedLabel, lineHeight: "1.3", isTruncated: true, children: companySubtitle }))] })), !toggle && (_jsx(Box, { as: "button", type: "button", onClick: overlay ? onClose : onToggle, "aria-label": overlay ? "Close menu" : "Collapse sidebar", w: "22px", h: "22px", borderRadius: "lg", bg: "whiteAlpha.200", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, position: "relative", _hover: { bg: "whiteAlpha.300" }, transition:
|
|
62
|
+
return (_jsxs(Flex, { h: HEADER_HEIGHT, w: "100%", alignItems: "center", justifyContent: toggle ? "center" : "flex-start", gap: 2, px: toggle ? "8px" : "10px", borderBottom: "1px solid", borderColor: theme.colors.sidebar.divider, minW: 0, overflow: "hidden", flexShrink: 0, children: [logoNode, !toggle && (_jsxs(Box, { flex: "1", minW: 0, children: [_jsx(OverflowTooltipText, { placement: "right", fontWeight: 600, fontSize: SIDEBAR_CHROME.titleFontSize, textAlign: "left", color: theme.colors.white, lineHeight: "1.3", as: "p", width: "100%", children: companyName !== null && companyName !== void 0 ? companyName : "" }), companySubtitle && (_jsx(Text, { fontSize: SIDEBAR_CHROME.metaFontSize, color: theme.colors.sidebar.mutedLabel, lineHeight: "1.3", isTruncated: true, children: companySubtitle }))] })), !toggle && (_jsx(Box, { as: "button", type: "button", onClick: overlay ? onClose : onToggle, "aria-label": overlay ? "Close menu" : "Collapse sidebar", w: "22px", h: "22px", borderRadius: "lg", bg: "whiteAlpha.200", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, position: "relative", _hover: { bg: "whiteAlpha.300" }, transition: SIDEBAR_BG_TRANSITION, sx: {
|
|
60
63
|
...sidebarFocusStyles(theme.colors),
|
|
61
64
|
"&::after": {
|
|
62
65
|
content: '""',
|
|
@@ -76,7 +79,7 @@ const SkeletonMenuRow = ({ toggle }) => {
|
|
|
76
79
|
const AddNewButton = ({ toggle, onClick, overlay }) => {
|
|
77
80
|
const theme = useCustomTheme();
|
|
78
81
|
const activeAccent = getSidebarActiveAccent(theme.colors);
|
|
79
|
-
return (_jsxs(Flex, { as: "button", type: "button", "data-group": "", "aria-label": "Add New", alignItems: "center", gap: "9px", px: "10px", py: overlay ? "11px" : "7px", borderRadius: "lg", cursor: "pointer", border: "none", bg: "transparent", w: "100%", mb: "2px", justifyContent: toggle ? "center" : "flex-start", _hover: { backgroundColor: "whiteAlpha.200" }, transition:
|
|
82
|
+
return (_jsxs(Flex, { as: "button", type: "button", "data-group": "", "aria-label": "Add New", alignItems: "center", gap: "9px", px: "10px", py: overlay ? "11px" : "7px", borderRadius: "lg", cursor: "pointer", border: "none", bg: "transparent", w: "100%", mb: "2px", justifyContent: toggle ? "center" : "flex-start", _hover: { backgroundColor: "whiteAlpha.200" }, transition: SIDEBAR_BG_TRANSITION, sx: sidebarFocusStyles(theme.colors), onClick: onClick, children: [_jsx(Box, { w: "18px", h: "18px", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, children: _jsx(Plus, { size: 16, color: activeAccent.icon }) }), !toggle && (_jsx(Text, { fontSize: SIDEBAR_ROW.fontSize, color: theme.colors.white, fontWeight: 500, children: "Add New" }))] }));
|
|
80
83
|
};
|
|
81
84
|
const deriveInitials = (user) => {
|
|
82
85
|
if (user.initials)
|
|
@@ -94,13 +97,13 @@ const UserFooter = ({ user, toggle, overlay }) => {
|
|
|
94
97
|
const avatar = user.avatarUrl ? (_jsx(Image, { src: user.avatarUrl, alt: user.name, boxSize: "26px", borderRadius: "full", objectFit: "cover", flexShrink: 0 })) : (_jsx(Box, { boxSize: "26px", borderRadius: "full",
|
|
95
98
|
// Same rail-safe pairing as the logo tile — primary.opacity[32] was invisible on zinc/skyline.
|
|
96
99
|
bg: theme.colors.sidebar.activeBg, color: activeAccent.label, display: "flex", alignItems: "center", justifyContent: "center", fontSize: SIDEBAR_CHROME.metaFontSize, fontWeight: 600, flexShrink: 0, children: deriveInitials(user) }));
|
|
97
|
-
return (_jsx(Box, { borderTop: "1px solid", borderColor: theme.colors.sidebar.divider, py: 2, px: "6px", flexShrink: 0, children: _jsxs(Flex, { as: "button", type: "button", onClick: user.onClick, align: "center", gap: 2, px: 2, py: overlay ? "10px" : "6px", w: "100%", borderRadius: "lg", cursor: "pointer", bg: "transparent", border: "none", justify: toggle ? "center" : "flex-start", _hover: { bg: "whiteAlpha.200" }, transition:
|
|
100
|
+
return (_jsx(Box, { borderTop: "1px solid", borderColor: theme.colors.sidebar.divider, py: 2, px: "6px", flexShrink: 0, children: _jsxs(Flex, { as: "button", type: "button", onClick: user.onClick, align: "center", gap: 2, px: 2, py: overlay ? "10px" : "6px", w: "100%", borderRadius: "lg", cursor: "pointer", bg: "transparent", border: "none", justify: toggle ? "center" : "flex-start", _hover: { bg: "whiteAlpha.200" }, transition: SIDEBAR_BG_TRANSITION, sx: sidebarFocusStyles(theme.colors), children: [avatar, !toggle && (_jsxs(Box, { flex: "1", minW: 0, textAlign: "left", children: [_jsx(Text, { fontSize: SIDEBAR_CHROME.labelFontSize, fontWeight: 500, color: theme.colors.white, isTruncated: true, children: user.name }), user.role && (_jsx(Text, { fontSize: SIDEBAR_CHROME.metaFontSize, color: theme.colors.sidebar.mutedLabel, isTruncated: true, children: user.role }))] })), !toggle && _jsx(MoreVertical, { size: 14, color: theme.colors.sidebar.mutedIcon })] }) }));
|
|
98
101
|
};
|
|
99
102
|
// Footer "cell" — one segment of the Collapse | Hide/Show control.
|
|
100
103
|
const ControlCell = ({ onClick, ariaLabel, label, accent, children }) => {
|
|
101
104
|
const theme = useCustomTheme();
|
|
102
105
|
const activeAccent = getSidebarActiveAccent(theme.colors);
|
|
103
|
-
return (_jsxs(Flex, { as: "button", type: "button", "aria-label": ariaLabel, flex: "1", minW: 0, alignItems: "center", justifyContent: "center", gap: "7px", px: "10px", py: "14px", cursor: "pointer", border: "none", bg: accent ? "whiteAlpha.300" : "transparent", onClick: onClick, _hover: { bg: accent ? "whiteAlpha.400" : "whiteAlpha.200" }, transition:
|
|
106
|
+
return (_jsxs(Flex, { as: "button", type: "button", "aria-label": ariaLabel, flex: "1", minW: 0, alignItems: "center", justifyContent: "center", gap: "7px", px: "10px", py: "14px", cursor: "pointer", border: "none", bg: accent ? "whiteAlpha.300" : "transparent", onClick: onClick, _hover: { bg: accent ? "whiteAlpha.400" : "whiteAlpha.200" }, transition: SIDEBAR_BG_TRANSITION, sx: sidebarFocusStyles(theme.colors), children: [children, label && (_jsx(Text, { fontSize: SIDEBAR_CHROME.labelFontSize, color: accent ? activeAccent.label : theme.colors.sidebar.mutedLabel, fontWeight: 500, children: label }))] }));
|
|
104
107
|
};
|
|
105
108
|
// Collapse (mini-rail) sits next to the Hide/Show navbar-mode toggle. In the
|
|
106
109
|
// desktop mobile-nav overlay only "Show" (return to the docked sidebar) is shown;
|
|
@@ -119,7 +122,7 @@ const FooterControls = ({ toggle, overlay, mobileNav, onToggleCollapse, onToggle
|
|
|
119
122
|
return shell(_jsxs(_Fragment, { children: [_jsx(ControlCell, { onClick: onToggleCollapse, ariaLabel: toggle ? "Expand sidebar" : undefined, label: toggle ? undefined : "Collapse", children: toggle ? (_jsx(ArrowRightToLine, { size: 14, color: iconColor })) : (_jsx(ArrowLeftToLine, { size: 14, color: iconColor })) }), onToggleMobileNav && (_jsx(ControlCell, { onClick: onToggleMobileNav, ariaLabel: toggle ? "Show sidebar in overlay mode" : undefined, label: toggle ? undefined : "Hide", children: _jsx(Maximize2, { size: 14, color: iconColor }) }))] }));
|
|
120
123
|
};
|
|
121
124
|
// --- Main Sidebar component ---
|
|
122
|
-
export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSecondaryNavClick, toggle, changeToggle, logo, companyName, companySubtitle, user, isDisableAddNew = false, onAddNewClick, selectedSubMenu, selectedSecondaryItem, isLoading, loadingLines, open = true, otherApps, mobileOpen = false, onMobileClose, mobileNav = false, onToggleMobileNav, peekOpen = false, onPeekEnd, pinnedItems, pinnedLabel, onUnpin, activePinnedId, pinnedLimit, pinnedLabels, collapseTransition = { speed: "
|
|
125
|
+
export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSecondaryNavClick, toggle, changeToggle, logo, companyName, companySubtitle, user, isDisableAddNew = false, onAddNewClick, selectedSubMenu, selectedSecondaryItem, isLoading, loadingLines, open = true, otherApps, mobileOpen = false, onMobileClose, mobileNav = false, onToggleMobileNav, peekOpen = false, onPeekEnd, pinnedItems, pinnedLabel, onUnpin, activePinnedId, pinnedLimit, pinnedLabels, collapseTransition = { speed: "base" }, autoCollapse = true, }) {
|
|
123
126
|
var _a, _b;
|
|
124
127
|
const theme = useCustomTheme();
|
|
125
128
|
const scrollContainerId = sanitizeId(useId());
|
|
@@ -329,14 +332,14 @@ export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSeco
|
|
|
329
332
|
onMobileClose === null || onMobileClose === void 0 ? void 0 : onMobileClose();
|
|
330
333
|
};
|
|
331
334
|
const baseTransform = isOverlayOpen ? "translateX(0)" : "translateX(-100%)";
|
|
332
|
-
return (_jsxs(_Fragment, { children: [_jsx(Box, { display: mobileNav ? "block" : { base: "block", lg: "none" }, position: "fixed", inset: 0, ...overlayScrimStyles(theme.colors), zIndex: Z_SCRIM, opacity: isOverlayOpen ? 1 : 0, visibility: isOverlayOpen ? "visible" : "hidden", transition:
|
|
335
|
+
return (_jsxs(_Fragment, { children: [_jsx(Box, { display: mobileNav ? "block" : { base: "block", lg: "none" }, position: "fixed", inset: 0, ...overlayScrimStyles(theme.colors), zIndex: Z_SCRIM, opacity: isOverlayOpen ? 1 : 0, visibility: isOverlayOpen ? "visible" : "hidden", transition: SCRIM_TRANSITION, sx: { [REDUCED_MOTION_QUERY]: { transition: "none" } }, onClick: closeOverlay, "aria-hidden": "true" }), _jsxs(Box, { ref: panelRef, onKeyDown: trapTab, tabIndex: overlay ? -1 : undefined, outline: "none", position: mobileNav ? "fixed" : { base: "fixed", lg: "sticky" }, top: 0, left: mobileNav ? 0 : { base: 0, lg: "auto" }, bottom: mobileNav ? 0 : { base: 0, lg: "auto" }, zIndex: mobileNav ? Z_PANEL : { base: Z_PANEL, lg: "auto" }, maxW: mobileNav ? "88vw" : { base: "88vw", lg: "none" }, transform: mobileNav ? baseTransform : { base: baseTransform, lg: "none" }, transition: mobileNav
|
|
333
336
|
? dragging
|
|
334
337
|
? "none"
|
|
335
|
-
:
|
|
338
|
+
: OVERLAY_SLIDE
|
|
336
339
|
: {
|
|
337
340
|
base: dragging
|
|
338
341
|
? "none"
|
|
339
|
-
:
|
|
342
|
+
: OVERLAY_SLIDE,
|
|
340
343
|
lg: inline.shadow,
|
|
341
344
|
}, borderRadius: "none", boxShadow: mobileNav ? theme.shadows["2xl"] : { base: theme.shadows["2xl"], lg: theme.shadows.lg }, display: "flex", background: theme.colors.sidebar.background[500], borderRight: "1px solid", borderColor: theme.colors.sidebar.divider, role: overlay ? "dialog" : undefined, "aria-modal": overlay ? true : undefined, "aria-label": overlay ? "Main navigation" : undefined, ...(overlay && !isOverlayOpen ? { inert: "" } : {}), sx: {
|
|
342
345
|
...fullViewportHeight,
|
|
@@ -345,6 +348,6 @@ export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSeco
|
|
|
345
348
|
}, onMouseLeave: overlayPeeking ? onPeekEnd : undefined, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, children: [_jsx(Box, { width: mobileNav
|
|
346
349
|
? OVERLAY_WIDTH
|
|
347
350
|
: { base: OVERLAY_WIDTH, lg: effToggle ? RAIL_WIDTH : EXPANDED_WIDTH }, transition: mobileNav
|
|
348
|
-
?
|
|
349
|
-
: { base:
|
|
351
|
+
? OVERLAY_WIDTH_TRANSITION
|
|
352
|
+
: { base: OVERLAY_WIDTH_TRANSITION, lg: inline.width }, display: "flex", flexDirection: "column", justifyContent: "space-between", sx: { "@media (prefers-reduced-motion: reduce)": { transition: "none" } }, children: _jsxs(Flex, { flexDir: "column", w: "100%", as: "nav", "aria-label": "Main navigation", h: "100%", children: [_jsx(SidebarHeader, { logo: logo, companyName: companyName, companySubtitle: companySubtitle, toggle: effToggle, isLoading: isLoading, onToggle: changeToggle, overlay: overlay, onClose: onMobileClose }), _jsx(Box, { id: scrollContainerId, flex: "1", minH: 0, w: "100%", overflowY: "auto", overflowX: "hidden", py: 2, px: "6px", sx: cssForScrollBar(theme), children: isLoading ? (Array.from({ length: loadingLines !== null && loadingLines !== void 0 ? loadingLines : 15 }).map((_, i) => (_jsx(SkeletonMenuRow, { toggle: effToggle }, i)))) : (_jsxs(_Fragment, { children: [pinnedItems && pinnedItems.length > 0 && (_jsx(PinnedSection, { items: pinnedItems, label: pinnedLabel, limit: pinnedLimit, toggle: effToggle, overlay: overlay, activeId: activePinnedId, labels: pinnedLabels, onItemClick: handleMenuClickInternal, onUnpin: onUnpin })), _jsx(MenuItems, { activeMenu: pinnedActive ? NO_ACTIVE_MENU : activeMenu, menus: menus, handleMenuClick: handleMenuClickInternal, toggle: effToggle, selectedSubMenu: selectedSubMenu, overlay: overlay, containerId: scrollContainerId })] })) }), _jsxs(Box, { flexShrink: 0, children: [!isDisableAddNew && (_jsx(Box, { borderTop: "1px solid", borderColor: theme.colors.sidebar.divider, py: 2, px: "6px", children: _jsx(AddNewButton, { toggle: effToggle, onClick: onAddNewClick, overlay: overlay }) })), _jsx(OtherApps, { toggle: effToggle, otherApps: otherApps !== null && otherApps !== void 0 ? otherApps : [] }), user && _jsx(UserFooter, { user: user, toggle: effToggle, overlay: overlay }), _jsx(FooterControls, { toggle: effToggle, overlay: overlay, mobileNav: mobileNav, onToggleCollapse: changeToggle, onToggleMobileNav: onToggleMobileNav })] })] }) }), secondaryItems.length > 0 && (_jsx(SecondaryBar, { items: secondaryItems, defaultCollapsed: effToggle, collapsedWidth: "3.5rem", expandedWidth: "10rem", selected: selectedSecondaryItem, onItemClick: handleSecondaryNavClick, title: activeTop === null || activeTop === void 0 ? void 0 : activeTop.title, icon: activeTop === null || activeTop === void 0 ? void 0 : activeTop.icon })), overlay && (_jsx(Box, { display: mobileOpen ? "block" : "none", position: "absolute", top: "50%", right: "6px", transform: "translateY(-50%)", w: "4px", h: "42px", borderRadius: "full", bg: theme.colors.sidebar.mutedIcon, "aria-hidden": "true" }))] })] }));
|
|
350
353
|
}
|