pixelize-design-library 2.4.2-beta.59 → 2.4.2-beta.60
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 +78 -9
- package/COMPONENT-GOTCHAS.md +118 -17
- package/DESIGN-GUIDE.md +17 -6
- package/dist/Components/AudioRecorder/AudioRecorder.d.ts +8 -0
- package/dist/Components/AudioRecorder/AudioRecorder.js +169 -0
- package/dist/Components/AudioRecorder/AudioRecorderProps.d.ts +20 -0
- package/dist/Components/AudioRecorder/AudioRecorderProps.js +2 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBar.d.ts +3 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBar.js +43 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBarProps.d.ts +35 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBarProps.js +2 -0
- package/dist/Components/BulkSelectionBar/index.d.ts +2 -0
- package/dist/Components/BulkSelectionBar/index.js +8 -0
- package/dist/Components/CalendarGrid/CalendarGrid.d.ts +3 -0
- package/dist/Components/CalendarGrid/CalendarGrid.js +173 -0
- package/dist/Components/CalendarGrid/CalendarGridProps.d.ts +54 -0
- package/dist/Components/CalendarGrid/CalendarGridProps.js +2 -0
- package/dist/Components/CalendarGrid/calendarMath.d.ts +49 -0
- package/dist/Components/CalendarGrid/calendarMath.js +178 -0
- package/dist/Components/CircularProgress/CircularProgress.d.ts +4 -0
- package/dist/Components/CircularProgress/CircularProgress.js +39 -0
- package/dist/Components/CircularProgress/CircularProgressProps.d.ts +22 -0
- package/dist/Components/CircularProgress/CircularProgressProps.js +2 -0
- package/dist/Components/CircularProgress/arc.d.ts +12 -0
- package/dist/Components/CircularProgress/arc.js +16 -0
- package/dist/Components/Common/fieldStyles.d.ts +1 -0
- package/dist/Components/Common/fieldStyles.js +2 -1
- package/dist/Components/Drawer/Drawer.d.ts +1 -1
- package/dist/Components/Drawer/Drawer.js +4 -2
- package/dist/Components/Drawer/DrawerProps.d.ts +3 -1
- package/dist/Components/EmptyState/EmptyState.js +2 -1
- package/dist/Components/EmptyState/EmptyStateProps.d.ts +2 -2
- package/dist/Components/FormDrawer/FormDrawer.d.ts +2 -0
- package/dist/Components/FormDrawer/FormDrawer.js +97 -0
- package/dist/Components/FormDrawer/FormDrawerProps.d.ts +55 -0
- package/dist/Components/FormDrawer/FormDrawerProps.js +2 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.d.ts +1 -1
- package/dist/Components/LauncherTrigger/LauncherTrigger.js +8 -1
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.d.ts +2 -0
- package/dist/Components/Modal/Modal.d.ts +1 -1
- package/dist/Components/Modal/Modal.js +4 -2
- package/dist/Components/Modal/ModalProps.d.ts +3 -1
- package/dist/Components/Modal/warnDroppedSlotChildren.d.ts +2 -0
- package/dist/Components/Modal/warnDroppedSlotChildren.js +45 -0
- package/dist/Components/NavLauncher/NavLauncher.js +83 -26
- package/dist/Components/NavLauncher/NavLauncherProps.d.ts +6 -6
- package/dist/Components/NavLauncher/launcherParts.d.ts +60 -1
- package/dist/Components/NavLauncher/launcherParts.js +93 -11
- package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +5 -0
- package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewerProps.d.ts +1 -1
- package/dist/Components/QueryState/QueryStateBoundary.d.ts +2 -2
- package/dist/Components/QueryState/QueryStateBoundary.js +9 -3
- package/dist/Components/QueryState/QueryStateProps.d.ts +19 -2
- package/dist/Components/SectionRail/SectionRail.d.ts +3 -0
- package/dist/Components/SectionRail/SectionRail.js +49 -0
- package/dist/Components/SectionRail/SectionRailProps.d.ts +23 -0
- package/dist/Components/SectionRail/SectionRailProps.js +2 -0
- package/dist/Components/SectionRail/index.d.ts +2 -0
- package/dist/Components/SectionRail/index.js +8 -0
- package/dist/Components/SegmentedControl/SegmentedControl.js +9 -14
- package/dist/Components/SegmentedControl/segmentedInk.d.ts +0 -2
- package/dist/Components/SegmentedControl/segmentedInk.js +1 -5
- package/dist/Components/StatCard/StatCard.d.ts +1 -1
- package/dist/Components/StatCard/StatCard.js +6 -2
- package/dist/Components/StatCard/StatCardProps.d.ts +3 -0
- package/dist/Components/StatusTag/StatusTag.d.ts +4 -0
- package/dist/Components/StatusTag/StatusTag.js +24 -0
- package/dist/Components/StatusTag/StatusTagProps.d.ts +20 -0
- package/dist/Components/StatusTag/StatusTagProps.js +2 -0
- package/dist/Components/Table/Table.d.ts +1 -1
- package/dist/Components/Table/Table.js +6 -2
- package/dist/Components/Table/TableProps.d.ts +20 -0
- package/dist/Components/Table/components/TableBody.d.ts +1 -1
- package/dist/Components/Table/components/TableBody.js +43 -18
- package/dist/Components/Table/components/TableHeader.d.ts +1 -1
- package/dist/Components/Table/components/TableHeader.js +7 -5
- package/dist/Components/Table/components/rowDetail.d.ts +32 -0
- package/dist/Components/Table/components/rowDetail.js +20 -0
- package/dist/Components/Table/hooks/useRowExpansion.d.ts +7 -0
- package/dist/Components/Table/hooks/useRowExpansion.js +27 -0
- package/dist/Components/Tabs/Tabs.d.ts +1 -1
- package/dist/Components/Tabs/Tabs.js +15 -2
- package/dist/Components/Tabs/TabsProps.d.ts +6 -2
- package/dist/Components/Tabs/components/Tab.js +4 -33
- package/dist/Components/Tabs/components/TabLinkList.d.ts +7 -0
- package/dist/Components/Tabs/components/TabLinkList.js +34 -0
- package/dist/Components/Tabs/useTabAppearance.d.ts +17 -0
- package/dist/Components/Tabs/useTabAppearance.js +67 -0
- package/dist/Components/Tag/Tag.js +11 -1
- package/dist/Components/Tag/TagProps.d.ts +4 -0
- package/dist/Components/Tag/tagDot.d.ts +3 -0
- package/dist/Components/Tag/tagDot.js +21 -0
- package/dist/esm/Components/AudioRecorder/AudioRecorder.js +161 -0
- package/dist/esm/Components/AudioRecorder/AudioRecorderProps.js +1 -0
- package/dist/esm/Components/BulkSelectionBar/BulkSelectionBar.js +38 -0
- package/dist/esm/Components/BulkSelectionBar/BulkSelectionBarProps.js +1 -0
- package/dist/esm/Components/BulkSelectionBar/index.js +1 -0
- package/dist/esm/Components/CalendarGrid/CalendarGrid.js +168 -0
- package/dist/esm/Components/CalendarGrid/CalendarGridProps.js +1 -0
- package/dist/esm/Components/CalendarGrid/calendarMath.js +155 -0
- package/dist/esm/Components/CircularProgress/CircularProgress.js +37 -0
- package/dist/esm/Components/CircularProgress/CircularProgressProps.js +1 -0
- package/dist/esm/Components/CircularProgress/arc.js +11 -0
- package/dist/esm/Components/Common/fieldStyles.js +2 -1
- package/dist/esm/Components/Drawer/Drawer.js +4 -2
- package/dist/esm/Components/EmptyState/EmptyState.js +2 -1
- package/dist/esm/Components/FormDrawer/FormDrawer.js +58 -0
- package/dist/esm/Components/FormDrawer/FormDrawerProps.js +1 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTrigger.js +5 -1
- package/dist/esm/Components/Modal/Modal.js +4 -2
- package/dist/esm/Components/Modal/warnDroppedSlotChildren.js +38 -0
- package/dist/esm/Components/NavLauncher/NavLauncher.js +85 -28
- package/dist/esm/Components/NavLauncher/launcherParts.js +88 -11
- package/dist/esm/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +5 -0
- package/dist/esm/Components/QueryState/QueryStateBoundary.js +10 -4
- package/dist/esm/Components/SectionRail/SectionRail.js +44 -0
- package/dist/esm/Components/SectionRail/SectionRailProps.js +1 -0
- package/dist/esm/Components/SectionRail/index.js +1 -0
- package/dist/esm/Components/SegmentedControl/SegmentedControl.js +11 -16
- package/dist/esm/Components/SegmentedControl/segmentedInk.js +0 -3
- package/dist/esm/Components/StatCard/StatCard.js +6 -2
- package/dist/esm/Components/StatusTag/StatusTag.js +19 -0
- package/dist/esm/Components/StatusTag/StatusTagProps.js +1 -0
- package/dist/esm/Components/Table/Table.js +7 -3
- package/dist/esm/Components/Table/components/TableBody.js +43 -18
- package/dist/esm/Components/Table/components/TableHeader.js +7 -5
- package/dist/esm/Components/Table/components/rowDetail.js +14 -0
- package/dist/esm/Components/Table/hooks/useRowExpansion.js +23 -0
- package/dist/esm/Components/Tabs/Tabs.js +15 -2
- package/dist/esm/Components/Tabs/components/Tab.js +4 -33
- package/dist/esm/Components/Tabs/components/TabLinkList.js +29 -0
- package/dist/esm/Components/Tabs/useTabAppearance.js +63 -0
- package/dist/esm/Components/Tag/Tag.js +12 -2
- package/dist/esm/Components/Tag/tagDot.js +17 -0
- package/dist/esm/index.js +7 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +18 -4
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { Box, Flex, Heading, IconButton, Text } from "@chakra-ui/react";
|
|
|
3
3
|
import { Compass, Search as SearchIcon, X } from "lucide-react";
|
|
4
4
|
import { useCallback, useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
5
5
|
import { useMatchMedia } from "../../Hooks/useMatchMedia.js";
|
|
6
|
-
import {
|
|
6
|
+
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
7
7
|
import { chartMode } from "../../Theme/tokens/builders/chartColorsFromTheme.js";
|
|
8
8
|
import { placeholderInk } from "../../Theme/tokens/builders/placeholderInk.js";
|
|
9
9
|
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
@@ -13,9 +13,12 @@ import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
|
13
13
|
import { assignAppHues } from "../AppSwitcher/AppMark.js";
|
|
14
14
|
import Drawer, { DrawerBody, DrawerFooter, DrawerHeader, } from "../Drawer/Drawer.js";
|
|
15
15
|
import EmptyState from "../EmptyState/EmptyState.js";
|
|
16
|
-
import Kbd from "../Kbd/Kbd.js";
|
|
16
|
+
import Kbd, { KbdShortcut } from "../Kbd/Kbd.js";
|
|
17
|
+
import ToolTip from "../ToolTip/ToolTip.js";
|
|
18
|
+
import { useIsTruncated } from "../../Hooks/useIsTruncated.js";
|
|
19
|
+
import { shortcutKeys } from "../AppSwitcher/AppSwitcherProps.js";
|
|
17
20
|
import Skeletons from "../Skeletons/Skeletons.js";
|
|
18
|
-
import { AppsSection, CountBadge, Highlight, isPlainClick, ITEM_SELECTOR, ModuleRow, NewTag, PinnedTile, PinTextButton, RailRow, RowActions, RowIcon, RowTip, SectionHeader, } from "./launcherParts.js";
|
|
21
|
+
import { activeRowSurface, AppsSection, CountBadge, Highlight, isPlainClick, ITEM_SELECTOR, ModuleRow, NewTag, PinnedTile, PinTextButton, RailRow, ROW_CONTAINER, RowActions, RowIcon, RowTip, SectionHeader, titleInset, WIDE_ROW, } from "./launcherParts.js";
|
|
19
22
|
import { searchLauncherSections } from "./match.js";
|
|
20
23
|
import NewTabLink from "./NewTabLink.js";
|
|
21
24
|
import PinToggle from "./PinToggle.js";
|
|
@@ -23,6 +26,11 @@ const NO_APPS = [];
|
|
|
23
26
|
const MD_QUERY = "(min-width: 48em)";
|
|
24
27
|
const XL_QUERY = "(min-width: 80em)";
|
|
25
28
|
const CELL_SELECTOR = "[data-nav-cell]";
|
|
29
|
+
const RAIL_WIDTH = "clamp(20rem, 30%, 26rem)";
|
|
30
|
+
const PINNED_COLUMNS = 2;
|
|
31
|
+
const ENTER_CHIP_WIDTH = 50;
|
|
32
|
+
const ARROW_KEYS = ["↑", "↓", "←", "→"];
|
|
33
|
+
const ENTER_KEY = shortcutKeys("enter")[0];
|
|
26
34
|
const DEFAULT_LABELS = {
|
|
27
35
|
title: "Menu",
|
|
28
36
|
searchPlaceholder: "Search menus and screens",
|
|
@@ -59,8 +67,6 @@ const DEFAULT_LABELS = {
|
|
|
59
67
|
footerNote: "Pins follow your account",
|
|
60
68
|
suggestionsHint: "Try one of these",
|
|
61
69
|
};
|
|
62
|
-
const isApplePlatform = () => typeof navigator !== "undefined" &&
|
|
63
|
-
/Mac|iPhone|iPad/.test(navigator.platform);
|
|
64
70
|
const visibleSections = (sections) => sections
|
|
65
71
|
.map((section) => ({
|
|
66
72
|
...section,
|
|
@@ -83,15 +89,15 @@ const GRID_COLUMNS = {
|
|
|
83
89
|
md: "repeat(2, minmax(0, 1fr))",
|
|
84
90
|
xl: "repeat(3, minmax(0, 1fr))",
|
|
85
91
|
};
|
|
86
|
-
function ItemGrid({ children }) {
|
|
87
|
-
return (_jsx(Box, { "data-nav-grid": true, display: "grid", gridTemplateColumns: GRID_COLUMNS, gap: "1px 8px", alignItems: "start", children: children }));
|
|
92
|
+
function ItemGrid({ children, columns, }) {
|
|
93
|
+
return (_jsx(Box, { "data-nav-grid": true, "data-nav-columns": columns, display: "grid", gridTemplateColumns: GRID_COLUMNS, gap: "1px 8px", alignItems: "start", children: children }));
|
|
88
94
|
}
|
|
89
95
|
function Pane({ children }) {
|
|
90
96
|
return (_jsx(Flex, { direction: "column", gap: "14px", flex: 1, minW: 0, px: "18px", pt: "12px", pb: "16px", overflowY: { base: "visible", lg: "auto" }, children: children }));
|
|
91
97
|
}
|
|
92
98
|
function Rail({ label, children }) {
|
|
93
99
|
const { colors } = useCustomTheme();
|
|
94
|
-
return (_jsx(Flex, { as: "aside", "aria-label": label, direction: "column", gap: "16px", w: { base: "100%", lg:
|
|
100
|
+
return (_jsx(Flex, { as: "aside", "aria-label": label, direction: "column", gap: "16px", w: { base: "100%", lg: RAIL_WIDTH }, flexShrink: 0, px: "14px", pt: "12px", pb: "16px", bg: colors.backgroundColor.subtle, borderTopWidth: { base: "1px", lg: 0 }, borderLeftWidth: { base: 0, lg: "1px" }, borderColor: colors.boxborder[200], overflowY: { base: "visible", lg: "auto" }, children: children }));
|
|
95
101
|
}
|
|
96
102
|
function SkeletonLayout({ label }) {
|
|
97
103
|
return (_jsxs(Flex, { role: "status", "aria-busy": "true", "aria-label": label, direction: { base: "column", lg: "row" }, flex: 1, minH: 0, children: [_jsx(Pane, { children: [0, 1, 2].map((section) => (_jsxs(Box, { children: [_jsx(Skeletons, { type: "skeleton", height: "0.75rem", width: "6rem" }), _jsx(ItemGrid, { children: [0, 1, 2, 3].map((row) => (_jsxs(Flex, { align: "center", gap: "10px", h: "34px", mt: 2, children: [_jsx(Skeletons, { type: "skeleton", height: "1rem", width: "1rem" }), _jsx(Skeletons, { type: "skeleton", height: "0.875rem", width: "8rem" })] }, row))) })] }, section))) }), _jsx(Rail, { label: label, children: [0, 1].map((group) => (_jsxs(Box, { children: [_jsx(Skeletons, { type: "skeleton", height: "0.75rem", width: "5rem" }), [0, 1, 2].map((row) => (_jsx(Skeletons, { type: "skeleton", height: "1.5rem", width: "100%", mt: 2 }, row)))] }, group))) })] }));
|
|
@@ -110,13 +116,25 @@ function SearchRow({ item, query, isActive, link, labels, optionId, isPinned, ca
|
|
|
110
116
|
const hasStar = Boolean(item.screenId) && canPin;
|
|
111
117
|
const base = item.badge ? 24 : 0;
|
|
112
118
|
const open = base + (hasStar ? 46 : item.href ? 24 : 0);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
const fullLabel = isScreen ? `${item.label} — ${item.context}` : item.label;
|
|
120
|
+
const title = useIsTruncated(fullLabel);
|
|
121
|
+
const context = useIsTruncated(item.context);
|
|
122
|
+
const titleRef = title.ref;
|
|
123
|
+
const contextRef = context.ref;
|
|
124
|
+
const tipLabel = isScreen || !item.context ? fullLabel : `${fullLabel} · ${item.context}`;
|
|
125
|
+
return (_jsx(ToolTip, { label: tipLabel, placement: "top-start", isDisabled: !title.isTruncated && !context.isTruncated, children: _jsxs(Flex, { role: "presentation", "data-group": true, "data-reveal": isActive, position: "relative", align: "flex-start", gap: "10px", minH: "34px", pl: "8px", pr: "4px", pt: "7px", pb: "5px", borderRadius: "8px", transition: transitionFor(["background-color"]), onMouseMove: onHover, sx: isActive
|
|
126
|
+
? { ...ROW_CONTAINER, ...activeRowSurface(colors) }
|
|
127
|
+
: ROW_CONTAINER, children: [_jsxs(Flex, { id: optionId, role: "option", "aria-selected": isActive, "data-active": isActive, flex: 1, minW: 0, align: "flex-start", gap: "10px", cursor: "pointer", onClick: () => {
|
|
128
|
+
if (!item.href)
|
|
129
|
+
onOpen();
|
|
130
|
+
}, children: [_jsx(RowIcon, { icon: item.icon, size: 16, mt: "2px" }), _jsxs(Flex, { direction: "column", flex: 1, minW: 0, children: [_jsxs(Flex, { align: "center", gap: "6px", minW: 0, h: "19px", sx: titleInset(base, open, ENTER_CHIP_WIDTH), children: [_jsxs(Text, { ref: titleRef, fontSize: "13.5px", fontWeight: 500, color: colors.text[900], noOfLines: 1, minW: 0, children: [_jsx(Highlight, { text: item.label, query: query }), isScreen ? (_jsx(Text, { as: "span", fontWeight: 400, color: colors.textMuted, children: ` — ${item.context}` })) : null] }), item.isNew ? _jsx(NewTag, { label: labels.newBadge }) : null, item.keywordHint ? (_jsx(Text, { as: "span", fontSize: "11.5px", color: colors.textMuted, whiteSpace: "nowrap", children: ` · ${item.keywordHint}` })) : null, item.hint ? (_jsx(Text, { as: "span", fontSize: "11.5px", color: colors.textMuted, whiteSpace: "nowrap", children: item.hint })) : null] }), item.context && !isScreen ? (_jsx(Text, { ref: contextRef, fontSize: "11.5px", lineHeight: "15px", color: colors.textMuted, noOfLines: 1, children: item.context })) : null] })] }), item.href ? (_jsx(Box, { as: link.linkAs, href: item.href, tabIndex: -1, "aria-hidden": true, onClick: link.onPlainClick, position: "absolute", inset: 0, borderRadius: "8px" })) : null, _jsx(RowActions, { children: _jsxs(Box, { "aria-hidden": true, display: "contents", children: [isActive ? (_jsx(Box, { sx: {
|
|
131
|
+
display: "none",
|
|
132
|
+
[WIDE_ROW]: { display: "inline-flex" },
|
|
133
|
+
"@media (hover: none)": { display: "none" },
|
|
134
|
+
}, children: _jsx(KbdShortcut, { shortcut: "enter", size: "xs" }) })) : null, _jsx(CountBadge, { value: item.badge }), hasStar ? (_jsx(PinToggle, { isPinned: isPinned, label: isPinned ? labels.unpin(item.label) : labels.pin(item.label), title: "", onToggle: onPin, tabIndex: -1 })) : null, item.href ? (_jsx(NewTabLink, { href: item.href, label: labels.openInNewTab(isScreen ? `${item.label} — ${item.context}` : item.label), linkAs: link.linkAs, tabIndex: -1 })) : null] }) }), hasStar ? (_jsx(RowTip, { text: isPinned ? labels.unpinTip : labels.pinTip })) : null] }) }));
|
|
117
135
|
}
|
|
118
136
|
/** Left-drawer navigation launcher: browse every module, pins, Frequent, Recent, search and (compact) the suite's apps. */
|
|
119
|
-
export default function NavLauncher({ isOpen, onClose, sections: rawSections, pinnedIds, frequentIds, recentIds, onTogglePin, onNavigate, linkAs = "a", actions, extraResults, query: controlledQuery, onQueryChange, isSearching = false, isLoading = false, keyScreenLimit = 3, frequentLimit = 4, suggestions, searchHint, openShortcutHint, modKeyLabel, maxWidth = "
|
|
137
|
+
export default function NavLauncher({ isOpen, onClose, sections: rawSections, pinnedIds, frequentIds, recentIds, onTogglePin, onNavigate, linkAs = "a", actions, extraResults, query: controlledQuery, onQueryChange, isSearching = false, isLoading = false, keyScreenLimit = 3, frequentLimit = 4, suggestions, searchHint, openShortcutHint, modKeyLabel, maxWidth = "1080px", labels: labelOverrides, apps, currentAppId, onAppSelect, appsVisibility = "apps-on-compact", "data-testid": testId, }) {
|
|
120
138
|
const theme = useCustomTheme();
|
|
121
139
|
const { colors } = theme;
|
|
122
140
|
const inputRef = useRef(null);
|
|
@@ -167,6 +185,7 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
167
185
|
const results = useMemo(() => groups.flatMap((g) => g.items), [groups]);
|
|
168
186
|
const groupStarts = useMemo(() => groups.map((_, i) => groups.slice(0, i).reduce((n, g) => n + g.items.length, 0)), [groups]);
|
|
169
187
|
const isSearchView = query.trim().length > 0;
|
|
188
|
+
const active = Math.min(activeIndex, Math.max(results.length - 1, 0));
|
|
170
189
|
const link = useMemo(() => ({
|
|
171
190
|
linkAs,
|
|
172
191
|
onPlainClick: (event) => {
|
|
@@ -187,16 +206,20 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
187
206
|
onNavigate(item.href, { newTab });
|
|
188
207
|
}, [onClose, onNavigate]);
|
|
189
208
|
const moveFocus = (delta) => {
|
|
190
|
-
var _a, _b;
|
|
209
|
+
var _a, _b, _c;
|
|
191
210
|
const items = Array.from((_b = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(ITEM_SELECTOR)) !== null && _b !== void 0 ? _b : []);
|
|
192
211
|
if (items.length === 0)
|
|
193
212
|
return;
|
|
194
213
|
const current = items.indexOf(document.activeElement);
|
|
214
|
+
if (typeof delta === "number" && current + delta < 0) {
|
|
215
|
+
(_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
195
218
|
const next = delta === "first"
|
|
196
219
|
? 0
|
|
197
220
|
: delta === "last"
|
|
198
221
|
? items.length - 1
|
|
199
|
-
: Math.min(items.length - 1,
|
|
222
|
+
: Math.min(items.length - 1, current + delta);
|
|
200
223
|
items[next].focus();
|
|
201
224
|
};
|
|
202
225
|
const onInputKeyDown = (event) => {
|
|
@@ -211,15 +234,15 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
211
234
|
return;
|
|
212
235
|
if (event.key === "ArrowDown") {
|
|
213
236
|
event.preventDefault();
|
|
214
|
-
setActiveIndex((
|
|
237
|
+
setActiveIndex((active + 1) % results.length);
|
|
215
238
|
}
|
|
216
239
|
else if (event.key === "ArrowUp") {
|
|
217
240
|
event.preventDefault();
|
|
218
|
-
setActiveIndex((
|
|
241
|
+
setActiveIndex((active - 1 + results.length) % results.length);
|
|
219
242
|
}
|
|
220
|
-
else if (event.key === "Enter") {
|
|
243
|
+
else if (event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
221
244
|
event.preventDefault();
|
|
222
|
-
open(results[
|
|
245
|
+
open(results[active], event.metaKey || event.ctrlKey);
|
|
223
246
|
}
|
|
224
247
|
};
|
|
225
248
|
const moveInGrid = (event, cell) => {
|
|
@@ -233,6 +256,7 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
233
256
|
return;
|
|
234
257
|
}
|
|
235
258
|
const down = event.key === "ArrowDown";
|
|
259
|
+
const columns = Number(grid === null || grid === void 0 ? void 0 : grid.dataset.navColumns);
|
|
236
260
|
const within = cells[index + (down ? columns : -columns)];
|
|
237
261
|
if (within)
|
|
238
262
|
return focusCell(within);
|
|
@@ -271,8 +295,8 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
271
295
|
return true;
|
|
272
296
|
};
|
|
273
297
|
const onBodyKeyDown = (event) => {
|
|
274
|
-
var _a;
|
|
275
|
-
if (
|
|
298
|
+
var _a, _b;
|
|
299
|
+
if (event.target === inputRef.current)
|
|
276
300
|
return;
|
|
277
301
|
const isArrow = event.key.startsWith("Arrow");
|
|
278
302
|
const cell = event.target.closest(CELL_SELECTOR);
|
|
@@ -288,6 +312,11 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
288
312
|
event.preventDefault();
|
|
289
313
|
moveFocus(event.key === "Home" ? "first" : "last");
|
|
290
314
|
}
|
|
315
|
+
else if (event.key === "Backspace" && query) {
|
|
316
|
+
event.preventDefault();
|
|
317
|
+
setQuery(query.slice(0, -1));
|
|
318
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
319
|
+
}
|
|
291
320
|
else if (event.key.length === 1 &&
|
|
292
321
|
!event.metaKey &&
|
|
293
322
|
!event.ctrlKey &&
|
|
@@ -297,14 +326,42 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
297
326
|
return;
|
|
298
327
|
event.preventDefault();
|
|
299
328
|
setQuery(query + event.key);
|
|
300
|
-
(
|
|
329
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
301
330
|
}
|
|
302
331
|
};
|
|
303
332
|
useEffect(() => {
|
|
304
333
|
var _a, _b, _c;
|
|
305
334
|
(_c = (_b = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('[data-active="true"]')) === null || _b === void 0 ? void 0 : _b.scrollIntoView) === null || _c === void 0 ? void 0 : _c.call(_b, { block: "nearest" });
|
|
306
|
-
}, [
|
|
335
|
+
}, [active, results]);
|
|
336
|
+
const lastItemIndex = useRef(-1);
|
|
337
|
+
useEffect(() => {
|
|
338
|
+
if (!isOpen)
|
|
339
|
+
return undefined;
|
|
340
|
+
const remember = (event) => {
|
|
341
|
+
var _a, _b;
|
|
342
|
+
const items = Array.from((_b = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(ITEM_SELECTOR)) !== null && _b !== void 0 ? _b : []);
|
|
343
|
+
lastItemIndex.current = items.indexOf(event.target);
|
|
344
|
+
};
|
|
345
|
+
const forget = () => {
|
|
346
|
+
lastItemIndex.current = -1;
|
|
347
|
+
};
|
|
348
|
+
document.addEventListener("focusin", remember);
|
|
349
|
+
document.addEventListener("pointerdown", forget);
|
|
350
|
+
return () => {
|
|
351
|
+
document.removeEventListener("focusin", remember);
|
|
352
|
+
document.removeEventListener("pointerdown", forget);
|
|
353
|
+
};
|
|
354
|
+
}, [isOpen]);
|
|
307
355
|
const appList = apps !== null && apps !== void 0 ? apps : NO_APPS;
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
var _a, _b;
|
|
358
|
+
if (lastItemIndex.current < 0 || document.activeElement !== document.body)
|
|
359
|
+
return;
|
|
360
|
+
const items = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(ITEM_SELECTOR);
|
|
361
|
+
if (!(items === null || items === void 0 ? void 0 : items.length))
|
|
362
|
+
return (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
363
|
+
items[Math.min(lastItemIndex.current, items.length - 1)].focus();
|
|
364
|
+
}, [appList]);
|
|
308
365
|
const hues = useMemo(() => assignAppHues(appList, chartMode(colors)), [appList, colors]);
|
|
309
366
|
const showApps = appList.some((app) => app.id !== currentAppId) &&
|
|
310
367
|
(appsVisibility === "always" || !isDesktop);
|
|
@@ -322,8 +379,8 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
322
379
|
const railFrequent = frequentItems
|
|
323
380
|
.filter(({ screen }) => !pinned.has(screen.id))
|
|
324
381
|
.slice(0, frequentLimit);
|
|
325
|
-
const rail = (_jsxs(Rail, { label: labels.quickAccess, children: [_jsxs(Flex, { as: "section", direction: "column", gap: "6px", children: [_jsx(SectionHeader, { label: labels.pinned, meta: `(${pinnedItems.length})`, isRail: true }), pinnedItems.length === 0 ? (_jsx(Text, { fontSize: "13px", color: colors.textMuted, px: "4px", children: labels.pinnedEmpty })) : (_jsx(Box, { display: "grid", gridTemplateColumns:
|
|
326
|
-
const browsePane = sections.length === 0 ? (_jsx(EmptyState, { title: labels.empty, titleAs: "h3", size: "sm" })) : (sections.map((section) => (_jsxs(Flex, { as: "section", "aria-label": section.label, direction: "column", gap: "3px", children: [_jsx(SectionHeader, { label: section.label, meta: `(${section.modules.length})` }), _jsx(ItemGrid, { children: section.modules.map((module) => {
|
|
382
|
+
const rail = (_jsxs(Rail, { label: labels.quickAccess, children: [_jsxs(Flex, { as: "section", direction: "column", gap: "6px", children: [_jsx(SectionHeader, { label: labels.pinned, meta: `(${pinnedItems.length})`, isRail: true }), pinnedItems.length === 0 ? (_jsx(Text, { fontSize: "13px", color: colors.textMuted, px: "4px", children: labels.pinnedEmpty })) : (_jsx(Box, { "data-nav-grid": true, "data-nav-columns": PINNED_COLUMNS, display: "grid", gridTemplateColumns: `repeat(${PINNED_COLUMNS}, minmax(0, 1fr))`, gap: "6px", children: pinnedItems.map(({ screen, module }) => (_jsx(PinnedTile, { screen: screen, module: module, link: link, labels: labels, onTogglePin: togglePinFor(screen.id) }, screen.id))) }))] }), railFrequent.length ? (_jsxs(Flex, { as: "section", direction: "column", gap: "2px", children: [_jsx(SectionHeader, { label: labels.frequent, isRail: true, hasCount: false }), railFrequent.map(({ screen, module }) => (_jsx(RailRow, { screen: screen, module: module, link: link, isStrong: true, pinId: onTogglePin ? screen.id : undefined, trailing: _jsxs(_Fragment, { children: [onTogglePin ? (_jsx(PinTextButton, { label: labels.pin(screen.label), text: labels.pinShort, onToggle: () => onTogglePin(screen.id) })) : null, _jsx(NewTabLink, { href: screen.href, label: labels.openInNewTab(screen.label), linkAs: link.linkAs })] }) }, screen.id)))] })) : null, recentItems.length ? (_jsxs(Flex, { as: "section", direction: "column", gap: "2px", children: [_jsx(SectionHeader, { label: labels.recent, isRail: true, hasCount: false }), recentItems.map(({ screen, module }) => (_jsx(RailRow, { screen: screen, module: module, link: link, trailing: _jsx(NewTabLink, { href: screen.href, label: labels.openInNewTab(screen.label), linkAs: link.linkAs }) }, screen.id)))] })) : null, appsBlock] }));
|
|
383
|
+
const browsePane = sections.length === 0 ? (_jsx(EmptyState, { title: labels.empty, titleAs: "h3", size: "sm" })) : (sections.map((section) => (_jsxs(Flex, { as: "section", "aria-label": section.label, direction: "column", gap: "3px", children: [_jsx(SectionHeader, { label: section.label, meta: `(${section.modules.length})` }), _jsx(ItemGrid, { columns: columns, children: section.modules.map((module) => {
|
|
327
384
|
const pinId = module.screens[0].id;
|
|
328
385
|
return (_jsx(ModuleRow, { module: module, keyScreens: module.screens
|
|
329
386
|
.filter((s) => s.isKey && s.href !== module.href)
|
|
@@ -337,9 +394,9 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
337
394
|
const noResults = (_jsxs(Flex, { direction: "column", align: "center", gap: "12px", py: "48px", px: "20px", textAlign: "center", role: "status", children: [_jsx(Flex, { boxSize: "40px", borderRadius: "12px", bg: colors.backgroundColor.subtle, color: colors.textMuted, align: "center", justify: "center", children: _jsx(SearchIcon, { size: 18, strokeWidth: 2, "aria-hidden": true }) }), _jsxs(Flex, { direction: "column", gap: "3px", children: [_jsx(Text, { fontSize: "14px", fontWeight: 600, color: colors.text[900], children: isSearching ? labels.searching : labels.noResults(trimmed) }), isSearching ? null : (_jsx(Text, { fontSize: "12.5px", color: colors.textMuted, children: (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length)
|
|
338
395
|
? labels.suggestionsHint
|
|
339
396
|
: labels.noResultsHint }))] }), !isSearching && (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) ? (_jsx(Flex, { wrap: "wrap", justify: "center", gap: "6px", children: suggestions.map((suggestion) => (_jsx(Box, { as: "button", type: "button", onClick: () => pickSuggestion(suggestion), h: "28px", px: "11px", borderRadius: "full", borderWidth: "1px", borderColor: colors.boxborder[200], bg: colors.surfaceRaised, fontSize: "12.5px", fontWeight: 500, color: colors.text[900], transition: transitionFor(["background-color"]), _hover: { bg: listRowBackgrounds(colors).active }, sx: focusVisibleStyles(colors), children: suggestion }, suggestion))) })) : null] }));
|
|
340
|
-
const searchPane = hasResults ? (_jsx(Flex, { role: "listbox", id: listboxId, "aria-label": labels.title, "aria-busy": isSearching || undefined, direction: "column", gap: "14px", children: groups.map((group, groupIndex) => (_jsxs(Flex, { role: "group", "aria-label": group.meta ? `${group.label}, ${group.meta}` : group.label, direction: "column", gap: "3px", children: [_jsx(SectionHeader, { label: group.label, meta: group.meta ? `(${group.meta})` : undefined, isDecorative: true }), _jsx(ItemGrid, { children: group.items.map((item, itemIndex) => {
|
|
397
|
+
const searchPane = hasResults ? (_jsx(Flex, { role: "listbox", id: listboxId, "aria-label": labels.title, "aria-busy": isSearching || undefined, direction: "column", gap: "14px", children: groups.map((group, groupIndex) => (_jsxs(Flex, { role: "group", "aria-label": group.meta ? `${group.label}, ${group.meta}` : group.label, direction: "column", gap: "3px", children: [_jsx(SectionHeader, { label: group.label, meta: group.meta ? `(${group.meta})` : undefined, isDecorative: true }), _jsx(ItemGrid, { columns: columns, children: group.items.map((item, itemIndex) => {
|
|
341
398
|
const index = groupStarts[groupIndex] + itemIndex;
|
|
342
|
-
return (_jsx(SearchRow, { item: item, query: query, isActive: index ===
|
|
399
|
+
return (_jsx(SearchRow, { item: item, query: query, isActive: index === active, link: link, labels: labels, optionId: optionId(index), isPinned: item.screenId ? pinned.has(item.screenId) : false, canPin: Boolean(onTogglePin) && item.kind === "module", onPin: () => item.screenId && (onTogglePin === null || onTogglePin === void 0 ? void 0 : onTogglePin(item.screenId)), onOpen: () => open(item, false), onHover: () => setActiveIndex(index) }, item.id));
|
|
343
400
|
}) })] }, group.id))) })) : (noResults);
|
|
344
401
|
const body = isLoading ? (_jsx(SkeletonLayout, { label: labels.loading })) : (_jsxs(_Fragment, { children: [_jsx(Pane, { children: isSearchView ? searchPane : browsePane }), rail] }));
|
|
345
402
|
const pill = resolveFilledSurface(colors.primary, colors);
|
|
@@ -352,5 +409,5 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
352
409
|
boxShadow: colors.boxShadow.default,
|
|
353
410
|
overflow: "hidden",
|
|
354
411
|
...{ "data-testid": testId },
|
|
355
|
-
}, children: [_jsx(DrawerHeader, { p: 0, flexShrink: 0, children: _jsxs(Flex, { align: "center", gap: "12px", h: "60px", pl: "18px", pr: "12px", children: [_jsxs(Heading, { as: "h2", display: "inline-flex", alignItems: "center", gap: "7px", h: "32px", pl: "9px", pr: "11px", borderRadius: "9px", bg: pill.fill, color: pill.color, fontSize: "13px", fontWeight: 600, flexShrink: 0, children: [_jsx(Compass, { size: 16, strokeWidth: 2, "aria-hidden": true }), labels.title] }), _jsx(SearchField, { inputRef: inputRef, value: query, onChange: setQuery, onKeyDown: onInputKeyDown, labels: labels, hint: searchHint, listboxId: listboxId, activeId: isSearchView && hasResults ? optionId(
|
|
412
|
+
}, children: [_jsx(DrawerHeader, { p: 0, flexShrink: 0, children: _jsxs(Flex, { align: "center", gap: "12px", h: "60px", pl: "18px", pr: "12px", children: [_jsxs(Heading, { as: "h2", display: "inline-flex", alignItems: "center", gap: "7px", h: "32px", pl: "9px", pr: "11px", borderRadius: "9px", bg: pill.fill, color: pill.color, fontSize: "13px", fontWeight: 600, flexShrink: 0, children: [_jsx(Compass, { size: 16, strokeWidth: 2, "aria-hidden": true }), labels.title] }), _jsx(SearchField, { inputRef: inputRef, value: query, onChange: setQuery, onKeyDown: onInputKeyDown, labels: labels, hint: searchHint, listboxId: listboxId, activeId: isSearchView && hasResults ? optionId(active) : undefined, isExpanded: isSearchView, hasResults: hasResults }), _jsx(IconButton, { "aria-label": labels.close, icon: _jsx(X, { size: 18, "aria-hidden": true }), variant: "ghost", boxSize: "34px", minW: "34px", borderRadius: "9px", color: colors.textMuted, ml: "auto", onClick: onClose })] }) }), _jsx(DrawerBody, { p: 0, display: "flex", flexDirection: { base: "column", lg: "row" }, overflowY: { base: "auto", lg: "hidden" }, minH: 0, children: _jsx(Flex, { ref: bodyRef, onKeyDown: onBodyKeyDown, direction: { base: "column", lg: "row" }, flex: 1, minH: 0, minW: 0, children: body }) }), _jsxs(DrawerFooter, { p: 0, minH: "32px", flexShrink: 0, px: "18px", py: "6px", gap: "6px 14px", flexWrap: "wrap", bg: colors.backgroundColor.subtle, fontSize: "11.5px", color: colors.textMuted, whiteSpace: "nowrap", justifyContent: "flex-start", children: [_jsxs(Flex, { gap: "6px 14px", align: "center", wrap: "wrap", "aria-hidden": true, sx: { "@media (hover: none)": { display: "none" } }, children: [openShortcutHint ? (_jsxs(Flex, { as: "span", align: "center", gap: "5px", children: [_jsx(Kbd, { size: "xs", children: openShortcutHint }), labels.hintOpenMenu] })) : null, _jsxs(Flex, { as: "span", align: "center", gap: "5px", children: [_jsx(Flex, { as: "span", gap: "2px", children: ARROW_KEYS.map((arrow) => (_jsx(Kbd, { size: "xs", children: arrow }, arrow))) }), labels.hintMove] }), _jsxs(Flex, { as: "span", align: "center", gap: "5px", children: [_jsx(KbdShortcut, { shortcut: "enter", size: "xs" }), labels.hintOpen] }), _jsxs(Flex, { as: "span", align: "center", gap: "5px", children: [modKeyLabel ? (_jsxs(Flex, { as: "span", gap: "4px", children: [_jsx(Kbd, { size: "xs", children: modKeyLabel }), _jsx(Kbd, { size: "xs", children: ENTER_KEY })] })) : (_jsx(KbdShortcut, { shortcut: "mod+enter", size: "xs" })), labels.hintNewTab] }), onTogglePin ? (_jsxs(Flex, { as: "span", align: "center", gap: "5px", children: [_jsx(Kbd, { size: "xs", children: "P" }), labels.hintPin] })) : null, _jsxs(Flex, { as: "span", align: "center", gap: "5px", children: [_jsx(KbdShortcut, { shortcut: "esc", size: "xs" }), labels.hintClose] })] }), _jsx(Text, { as: "span", ml: "auto", children: labels.footerNote })] })] }));
|
|
356
413
|
}
|
|
@@ -2,11 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { Box, Flex, Heading, Text } from "@chakra-ui/react";
|
|
3
3
|
import { Lock, Star } from "lucide-react";
|
|
4
4
|
import { Fragment, } from "react";
|
|
5
|
-
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
5
|
+
import { FOCUS_VISIBLE_OVER_STATE, focusVisibleStyles, } from "../../Theme/chakra/focusRing.styles.js";
|
|
6
6
|
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
7
|
+
import { AA_NON_TEXT, liftToContrast, } from "../../Theme/tokens/builders/outlineRung.js";
|
|
7
8
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
9
|
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
9
10
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
11
|
+
import OverflowToolTip from "../ToolTip/OverflowToolTip.js";
|
|
10
12
|
import AppMark from "../AppSwitcher/AppMark.js";
|
|
11
13
|
import { highlightSegments } from "./match.js";
|
|
12
14
|
import NewTabLink from "./NewTabLink.js";
|
|
@@ -18,6 +20,66 @@ export const isPlainClick = (event) => event.button === 0 &&
|
|
|
18
20
|
!event.ctrlKey &&
|
|
19
21
|
!event.shiftKey &&
|
|
20
22
|
!event.altKey;
|
|
23
|
+
const ROW_FOCUS = "data-row-focus";
|
|
24
|
+
const ROW_PR = "--row-pr";
|
|
25
|
+
const REVEALED = "[data-group]:hover &, [data-group]:focus-within &, [data-group][data-reveal=true] &";
|
|
26
|
+
const NARROW_ROW = "@container launcher-row (max-width: 219px)";
|
|
27
|
+
export const WIDE_ROW = "@container launcher-row (min-width: 300px)";
|
|
28
|
+
export const ROW_CONTAINER = {
|
|
29
|
+
containerType: "inline-size",
|
|
30
|
+
containerName: "launcher-row",
|
|
31
|
+
};
|
|
32
|
+
export const activeRowStyle = (colors) => {
|
|
33
|
+
const fill = listRowBackgrounds(colors).active;
|
|
34
|
+
const edge = liftToContrast(liftToContrast(colors.primary[500], fill, AA_NON_TEXT), colors.surfaceRaised, AA_NON_TEXT);
|
|
35
|
+
return { edge, fill };
|
|
36
|
+
};
|
|
37
|
+
export const activeRowSurface = (colors) => {
|
|
38
|
+
const { edge, fill } = activeRowStyle(colors);
|
|
39
|
+
return {
|
|
40
|
+
backgroundColor: fill,
|
|
41
|
+
boxShadow: `inset 0 0 0 1px ${edge}`,
|
|
42
|
+
outline: "2px solid transparent",
|
|
43
|
+
outlineOffset: "-2px",
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const titleInset = (base, open, chip = 0) => ({
|
|
47
|
+
paddingRight: `var(${ROW_PR})`,
|
|
48
|
+
[ROW_PR]: `${base}px`,
|
|
49
|
+
[REVEALED]: { [ROW_PR]: `${open}px` },
|
|
50
|
+
...(chip
|
|
51
|
+
? {
|
|
52
|
+
[WIDE_ROW]: {
|
|
53
|
+
"[data-group][data-reveal=true] &": { [ROW_PR]: `${open + chip}px` },
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
[NARROW_ROW]: { [REVEALED]: { [ROW_PR]: `${base}px` } },
|
|
58
|
+
});
|
|
59
|
+
const markRowFocus = (event, isOn) => { var _a; return (_a = event.currentTarget.closest("[data-group]")) === null || _a === void 0 ? void 0 : _a.toggleAttribute(ROW_FOCUS, isOn); };
|
|
60
|
+
export const useRowFocus = (isBordered = false) => {
|
|
61
|
+
const { colors } = useCustomTheme();
|
|
62
|
+
const { edge, fill } = activeRowStyle(colors);
|
|
63
|
+
const lit = isBordered
|
|
64
|
+
? { backgroundColor: fill, borderColor: edge }
|
|
65
|
+
: activeRowSurface(colors);
|
|
66
|
+
return {
|
|
67
|
+
sx: { [`&[${ROW_FOCUS}]`]: lit },
|
|
68
|
+
primary: {
|
|
69
|
+
onFocus: (event) => markRowFocus(event, event.currentTarget.matches(":focus-visible")),
|
|
70
|
+
onBlur: (event) => markRowFocus(event, false),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export const stretchedLink = (radius) => ({
|
|
75
|
+
outline: "none",
|
|
76
|
+
_after: {
|
|
77
|
+
content: '""',
|
|
78
|
+
position: "absolute",
|
|
79
|
+
inset: 0,
|
|
80
|
+
borderRadius: radius,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
21
83
|
export const useRowHover = () => {
|
|
22
84
|
const { colors } = useCustomTheme();
|
|
23
85
|
const hover = listRowBackgrounds(colors).active;
|
|
@@ -47,10 +109,19 @@ export function RowIcon({ icon: Icon, size, stroke = 1.75, mt }) {
|
|
|
47
109
|
}
|
|
48
110
|
export function Highlight({ text, query }) {
|
|
49
111
|
const { colors } = useCustomTheme();
|
|
50
|
-
return (_jsx(_Fragment, { children: highlightSegments(text, query).map((segment, i) => segment.isMatch ? (_jsx(Box, { as: "mark", bg:
|
|
112
|
+
return (_jsx(_Fragment, { children: highlightSegments(text, query).map((segment, i) => segment.isMatch ? (_jsx(Box, { as: "mark", bg: "transparent", color: "inherit", fontWeight: 650, textDecoration: "underline", textDecorationColor: colors.primary.opacity[48], textDecorationThickness: "1.5px", textUnderlineOffset: "2px", children: segment.text }, i)) : (_jsx(Fragment, { children: segment.text }, i))) }));
|
|
51
113
|
}
|
|
52
114
|
export function RowActions({ children }) {
|
|
53
|
-
|
|
115
|
+
const { colors } = useCustomTheme();
|
|
116
|
+
const revealed = REVEALED.replace(/ &/g, " > &");
|
|
117
|
+
return (_jsx(Flex, { sx: {
|
|
118
|
+
[NARROW_ROW]: {
|
|
119
|
+
[revealed]: {
|
|
120
|
+
backgroundColor: activeRowStyle(colors).fill,
|
|
121
|
+
borderRadius: "6px",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
}, position: "absolute", top: "7px", right: "4px", h: "19px", align: "center", gap: "2px", zIndex: 1, children: children }));
|
|
54
125
|
}
|
|
55
126
|
export function RowTip({ text }) {
|
|
56
127
|
const { colors } = useCustomTheme();
|
|
@@ -59,19 +130,21 @@ export function RowTip({ text }) {
|
|
|
59
130
|
export function ModuleRow({ module, keyScreens, isPinned, onTogglePin, pinId, labels, link, }) {
|
|
60
131
|
const { colors } = useCustomTheme();
|
|
61
132
|
const hover = useRowHover();
|
|
133
|
+
const focus = useRowFocus();
|
|
62
134
|
const ring = focusVisibleStyles(colors);
|
|
63
135
|
const base = typeof module.badge === "number" || module.badge ? 24 : 0;
|
|
64
136
|
const open = base + (onTogglePin ? 46 : 24);
|
|
65
|
-
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "flex-start", gap: "10px", minH: "34px", pl: "8px", pr: "4px", pt: "7px", pb: "5px", borderRadius: "8px", transition: transitionFor(["background-color"]), _hover: hover._hover, _focusWithin: hover._focusWithin, children: [_jsx(RowIcon, { icon: module.icon, size: 16, mt: "2px" }), _jsxs(Flex, { direction: "column", flex: 1, minW: 0, children: [_jsxs(Flex, { align: "center", gap: "6px", h: "19px", minW: 0,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
137
|
+
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "flex-start", gap: "10px", minH: "34px", pl: "8px", pr: "4px", pt: "7px", pb: "5px", borderRadius: "8px", transition: transitionFor(["background-color"]), _hover: hover._hover, _focusWithin: hover._focusWithin, sx: { ...focus.sx, ...ROW_CONTAINER }, children: [_jsx(RowIcon, { icon: module.icon, size: 16, mt: "2px" }), _jsxs(Flex, { direction: "column", flex: 1, minW: 0, children: [_jsxs(Flex, { align: "center", gap: "6px", h: "19px", minW: 0, sx: titleInset(base, open), children: [_jsx(OverflowToolTip, { label: module.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: module.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": onTogglePin ? pinId : undefined, onClick: link.onPlainClick, minW: 0, fontSize: "13.5px", fontWeight: 500, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("8px"), children: module.label }) }), module.isNew ? _jsx(NewTag, { label: labels.newBadge }) : null] }), keyScreens.length ? (_jsx(OverflowToolTip, { label: keyScreens.map((screen) => screen.label).join(" · "), placement: "bottom-start", children: _jsx(Box, { role: "group", "aria-label": `${module.label} ${labels.screens}`, position: "relative", zIndex: 1, w: "fit-content", maxW: "100%", fontSize: "11.5px", lineHeight: "15px", color: colors.textMuted, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", children: keyScreens.map((screen, i) => (_jsxs(Fragment, { children: [i > 0 ? (_jsx(Box, { as: "span", "aria-hidden": true, mx: "5px", opacity: 0.7, children: "\u00B7" })) : null, _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, onClick: link.onPlainClick, color: "inherit", borderRadius: "sm", position: "relative", zIndex: 1, _hover: {
|
|
138
|
+
textDecoration: "underline",
|
|
139
|
+
textUnderlineOffset: "2px",
|
|
140
|
+
}, sx: ring, children: screen.label })] }, screen.id))) }) })) : null] }), _jsxs(RowActions, { children: [_jsx(CountBadge, { value: module.badge }), onTogglePin ? (_jsx(PinToggle, { isPinned: isPinned, label: isPinned ? labels.unpin(module.label) : labels.pin(module.label), title: "", onToggle: onTogglePin })) : null, _jsx(NewTabLink, { href: module.href, label: labels.openInNewTab(module.label), linkAs: link.linkAs })] }), onTogglePin ? (_jsx(RowTip, { text: isPinned ? labels.unpinTip : labels.pinTip })) : null] }));
|
|
69
141
|
}
|
|
70
142
|
export function RailRow({ screen, module, link, isStrong = false, trailing, pinId, }) {
|
|
71
143
|
var _a;
|
|
72
144
|
const { colors } = useCustomTheme();
|
|
73
145
|
const hover = useRowHover();
|
|
74
|
-
|
|
146
|
+
const focus = useRowFocus();
|
|
147
|
+
return (_jsxs(Flex, { "data-group": true, position: "relative", align: "center", gap: "10px", h: "32px", pl: "8px", pr: "4px", borderRadius: "8px", transition: transitionFor(["background-color"]), _hover: hover._hover, _focusWithin: hover._focusWithin, sx: focus.sx, children: [_jsx(RowIcon, { icon: (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon, size: 15 }), _jsx(OverflowToolTip, { label: screen.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": pinId, onClick: link.onPlainClick, flex: 1, minW: 0, fontSize: "13px", fontWeight: isStrong ? 500 : 400, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("8px"), children: screen.label }) }), _jsx(Flex, { position: "relative", zIndex: 1, align: "center", gap: "2px", children: trailing })] }));
|
|
75
148
|
}
|
|
76
149
|
export function PinTextButton({ label, text, onToggle }) {
|
|
77
150
|
const { colors } = useCustomTheme();
|
|
@@ -85,12 +158,13 @@ export function PinnedTile({ screen, module, link, labels, onTogglePin, }) {
|
|
|
85
158
|
var _a;
|
|
86
159
|
const { colors } = useCustomTheme();
|
|
87
160
|
const Icon = (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon;
|
|
88
|
-
|
|
161
|
+
const focus = useRowFocus(true);
|
|
162
|
+
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "center", gap: "8px", h: "36px", pl: "9px", pr: "4px", borderRadius: "9px", borderWidth: "1px", borderColor: colors.boxborder[200], bg: colors.surfaceRaised, transition: transitionFor(["border-color", "background-color"]), _hover: { borderColor: colors.gray[300] }, sx: focus.sx, children: [Icon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, color: colors.accentText, children: _jsx(Icon, { size: 15, strokeWidth: 1.8, "aria-hidden": true }) })) : null, _jsx(OverflowToolTip, { label: screen.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": onTogglePin ? screen.id : undefined, onClick: link.onPlainClick, flex: 1, minW: 0, fontSize: "13px", fontWeight: 500, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("9px"), children: screen.label }) }), _jsx(CountBadge, { value: screen.badge, size: "tile" }), onTogglePin ? (_jsx(Box, { position: "relative", zIndex: 1, flexShrink: 0, w: "0", overflow: "hidden", transition: transitionFor(["width"]), _groupHover: { w: "22px" }, _groupFocusWithin: { w: "22px" }, children: _jsx(PinToggle, { isPinned: true, size: 12, label: labels.unpin(screen.label), title: labels.unpinTip, onToggle: onTogglePin }) })) : null] }));
|
|
89
163
|
}
|
|
90
164
|
export function AppsSection({ apps, hues, currentAppId, heading, onSelect, }) {
|
|
91
165
|
const { colors } = useCustomTheme();
|
|
92
166
|
const rows = listRowBackgrounds(colors);
|
|
93
|
-
const
|
|
167
|
+
const rowRing = activeRowSurface(colors);
|
|
94
168
|
return (_jsxs(Box, { children: [_jsx(SectionHeader, { label: heading, isRail: true, hasCount: false }), _jsx(Box, { as: "ul", listStyleType: "none", m: 0, p: 0, "aria-label": heading, children: apps.map((app, index) => {
|
|
95
169
|
var _a;
|
|
96
170
|
const isCurrent = app.id === currentAppId;
|
|
@@ -105,6 +179,9 @@ export function AppsSection({ apps, hues, currentAppId, heading, onSelect, }) {
|
|
|
105
179
|
}
|
|
106
180
|
: {}), "aria-current": isCurrent ? "true" : undefined, title: app.locked
|
|
107
181
|
? ((_a = app.lockedReason) !== null && _a !== void 0 ? _a : `${app.name} is not available on your plan`)
|
|
108
|
-
: undefined, "data-app-locked": app.locked ? "true" : undefined, align: "center", gap: 3, minH: "44px", px: 2, py: 1, borderRadius: "8px", textDecoration: "none", cursor: interactive ? "pointer" : "default", bg: isCurrent ? rows.selected : "transparent", transition: transitionFor(["background-color"]), _hover: interactive ? { bg: rows.active } : undefined, sx:
|
|
182
|
+
: undefined, "data-app-locked": app.locked ? "true" : undefined, "aria-disabled": app.locked ? "true" : undefined, align: "center", gap: 3, minH: "44px", px: 2, py: 1, borderRadius: "8px", textDecoration: "none", cursor: interactive ? "pointer" : "default", bg: isCurrent ? rows.selected : "transparent", transition: transitionFor(["background-color"]), _hover: interactive ? { bg: rows.active } : undefined, sx: {
|
|
183
|
+
_focusVisible: rowRing,
|
|
184
|
+
[FOCUS_VISIBLE_OVER_STATE]: rowRing,
|
|
185
|
+
}, children: [_jsx(AppMark, { app: app, hue: hues[index], boxSize: "28px", iconSize: 15, muted: app.locked }), _jsx(OverflowToolTip, { label: app.name, placement: "top-start", children: _jsx(Text, { flex: 1, minW: 0, fontSize: "sm", fontWeight: "medium", noOfLines: 1, color: app.locked ? colors.textMuted : colors.text[900], children: app.name }) }), app.locked ? (_jsx(Box, { as: Lock, size: 14, color: colors.textMuted, flexShrink: 0, "aria-hidden": true })) : null] }) }, app.id || app.name));
|
|
109
186
|
}) })] }));
|
|
110
187
|
}
|
|
@@ -10,6 +10,11 @@ import { hexToRgb } from "../../Theme/tokens/builders/color.js";
|
|
|
10
10
|
export default function ProfilePhotoViewer({ photoUrl, onPhotoChange, imageWidth = "100px", imageAlt = "Profile Photo", imageObjectFit = "cover", imageBorderRadius = "full", editIconSize = "sm", editIconPositionRight = "0px", editIconPositionBottom = "0px", isRound = true, boxStyle, isEditable = false, isView = false, style, handleIsView, fallbackText, revealOnHover = true, }) {
|
|
11
11
|
var _a, _b, _c, _d, _e;
|
|
12
12
|
const [photo, setPhoto] = useState(photoUrl);
|
|
13
|
+
const [syncedUrl, setSyncedUrl] = useState(photoUrl);
|
|
14
|
+
if (photoUrl !== syncedUrl) {
|
|
15
|
+
setSyncedUrl(photoUrl);
|
|
16
|
+
setPhoto(photoUrl);
|
|
17
|
+
}
|
|
13
18
|
const fileInputRef = useRef(null);
|
|
14
19
|
const theme = useCustomTheme();
|
|
15
20
|
const c = theme.colors;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Flex, VisuallyHidden } from "@chakra-ui/react";
|
|
2
|
+
import { Box, Flex, VisuallyHidden } from "@chakra-ui/react";
|
|
3
|
+
import { Lock } from "lucide-react";
|
|
3
4
|
import EmptyState from "../EmptyState/EmptyState.js";
|
|
4
5
|
import Skeletons from "../Skeletons/Skeletons.js";
|
|
5
6
|
import ErrorState from "./ErrorState.js";
|
|
6
7
|
const DefaultLoading = () => (_jsxs(Flex, { role: "status", direction: "column", gap: 4, w: "100%", py: 2, children: [_jsx(VisuallyHidden, { children: "Loading" }), _jsx(Skeletons, { type: "skeleton", height: 4, width: "40%" }), Array.from({ length: 4 }, (_, i) => (_jsxs(Flex, { direction: "column", gap: 2, children: [_jsx(Skeletons, { type: "skeleton", height: 2.5, width: "100%" }), _jsx(Skeletons, { type: "skeleton", height: 2.5, width: "70%" })] }, i)))] }));
|
|
7
8
|
const hasError = (error) => error !== undefined && error !== null && error !== false;
|
|
8
|
-
/** Renders one of loading / error / empty / children for a content region; agnostic of the fetching library. */
|
|
9
|
-
const QueryStateBoundary = ({ isLoading = false, error, isEmpty = false, loadingFallback, emptyFallback, empty, errorTitle, errorDescription, onRetry, isRetrying, minH = "24rem", children, }) => {
|
|
10
|
-
|
|
9
|
+
/** Renders one of loading / forbidden / error / empty / children for a content region; agnostic of the fetching library. */
|
|
10
|
+
const QueryStateBoundary = ({ isLoading = false, isForbidden = false, forbidden, hasData = false, error, isEmpty = false, loadingFallback, emptyFallback, empty, errorTitle, errorDescription, onRetry, isRetrying, minH = "24rem", children, }) => {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
if (isLoading && !hasData)
|
|
11
13
|
return _jsx(_Fragment, { children: loadingFallback !== null && loadingFallback !== void 0 ? loadingFallback : _jsx(DefaultLoading, {}) });
|
|
14
|
+
const forbiddenNow = typeof isForbidden === "function" ? hasError(error) && isForbidden(error) : isForbidden;
|
|
15
|
+
if (forbiddenNow) {
|
|
16
|
+
return (_jsx(Box, { role: "status", w: "100%", children: _jsx(EmptyState, { colorScheme: "gray", icon: (_a = forbidden === null || forbidden === void 0 ? void 0 : forbidden.icon) !== null && _a !== void 0 ? _a : Lock, title: (_b = forbidden === null || forbidden === void 0 ? void 0 : forbidden.title) !== null && _b !== void 0 ? _b : "You don't have access", description: (_c = forbidden === null || forbidden === void 0 ? void 0 : forbidden.description) !== null && _c !== void 0 ? _c : "Ask an administrator to give you access to view this.", action: forbidden === null || forbidden === void 0 ? void 0 : forbidden.action, minH: minH }) }));
|
|
17
|
+
}
|
|
12
18
|
if (hasError(error)) {
|
|
13
19
|
const description = typeof errorDescription === "function" ? errorDescription(error) : errorDescription;
|
|
14
20
|
return (_jsx(ErrorState, { title: errorTitle, description: description, onRetry: onRetry, isRetrying: isRetrying, minH: minH }));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Box, Flex, Text, VisuallyHidden, useTheme } from "@chakra-ui/react";
|
|
4
|
+
import Select from "../Select/Select.js";
|
|
5
|
+
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
6
|
+
import { focusVisibleRing } from "../../Theme/chakra/focusRing.styles.js";
|
|
7
|
+
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
|
+
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
9
|
+
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
10
|
+
const FALLBACK_BREAKPOINTS = { sm: "30em", md: "48em", lg: "62em" };
|
|
11
|
+
const matchesMinWidth = (query) => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : true;
|
|
12
|
+
const useMinWidth = (minWidth) => {
|
|
13
|
+
const query = `(min-width: ${minWidth})`;
|
|
14
|
+
const [matches, setMatches] = useState(() => matchesMinWidth(query));
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
var _a;
|
|
17
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function")
|
|
18
|
+
return undefined;
|
|
19
|
+
const list = window.matchMedia(query);
|
|
20
|
+
const update = () => setMatches(list.matches);
|
|
21
|
+
update();
|
|
22
|
+
(_a = list.addEventListener) === null || _a === void 0 ? void 0 : _a.call(list, "change", update);
|
|
23
|
+
return () => { var _a; return (_a = list.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(list, "change", update); };
|
|
24
|
+
}, [query]);
|
|
25
|
+
return matches;
|
|
26
|
+
};
|
|
27
|
+
const SectionRail = ({ sections, activeId, onSelect, "aria-label": ariaLabel, dirtyHint, collapseBelow = "md", }) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const { colors } = useCustomTheme();
|
|
30
|
+
const { breakpoints } = useTheme();
|
|
31
|
+
const isRail = useMinWidth((_a = breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints[collapseBelow]) !== null && _a !== void 0 ? _a : FALLBACK_BREAKPOINTS[collapseBelow]);
|
|
32
|
+
const rows = listRowBackgrounds(colors);
|
|
33
|
+
if (!isRail) {
|
|
34
|
+
return (_jsx(Select, { "aria-label": ariaLabel, width: "100%", value: activeId, options: sections.map((section) => ({
|
|
35
|
+
id: section.id,
|
|
36
|
+
label: section.isDirty ? `${section.label} (${dirtyHint})` : section.label,
|
|
37
|
+
})), onChange: (option) => option && onSelect(String(option.id)) }));
|
|
38
|
+
}
|
|
39
|
+
return (_jsx(Flex, { as: "nav", "aria-label": ariaLabel, direction: "column", gap: "2px", children: sections.map((section) => {
|
|
40
|
+
const isActive = section.id === activeId;
|
|
41
|
+
return (_jsxs(Flex, { as: "button", type: "button", align: "center", gap: 2, minH: "2rem", px: 3, py: 1.5, borderRadius: "md", fontSize: "sm", fontWeight: isActive ? 600 : 500, textAlign: "left", "aria-current": isActive ? "true" : undefined, bg: isActive ? rows.selected : "transparent", color: isActive ? colors.accentText : colors.text[800], transition: transitionFor(["background-color", "color"]), _hover: { bg: isActive ? rows.selectedActive : rows.active }, _focusVisible: focusVisibleRing(colors), sx: reducedMotionSx(), onClick: () => onSelect(section.id), children: [section.icon ? (_jsx(Box, { as: "span", "aria-hidden": true, display: "inline-flex", flexShrink: 0, children: section.icon })) : null, _jsx(Text, { as: "span", noOfLines: 1, flex: "1", minW: 0, children: section.label }), section.isDirty ? (_jsxs(_Fragment, { children: [_jsx(Box, { as: "span", "aria-hidden": true, boxSize: "6px", borderRadius: "full", flexShrink: 0, bg: colors.semanticText.warning }), _jsx(VisuallyHidden, { children: dirtyHint })] })) : null] }, section.id));
|
|
42
|
+
}) }));
|
|
43
|
+
};
|
|
44
|
+
export default SectionRail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SectionRail } from "./SectionRail.js";
|