pixelize-design-library 2.4.2-beta.64 → 2.4.2-beta.65
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 +83 -8
- package/COMPONENT-GOTCHAS.md +37 -4
- package/DESIGN-GUIDE.md +7 -3
- package/dist/Components/CopyButton/CopyButton.d.ts +3 -1
- package/dist/Components/CopyButton/CopyButton.js +2 -2
- package/dist/Components/Drawer/Drawer.d.ts +1 -1
- package/dist/Components/Drawer/Drawer.js +6 -2
- package/dist/Components/Drawer/DrawerProps.d.ts +4 -0
- package/dist/Components/FormDrawer/FormDrawer.d.ts +1 -1
- package/dist/Components/FormDrawer/FormDrawer.js +3 -3
- package/dist/Components/FormDrawer/FormDrawerProps.d.ts +2 -0
- package/dist/Components/Modal/dialogNaming.d.ts +8 -0
- package/dist/Components/Modal/dialogNaming.js +21 -0
- package/dist/Components/NavLauncher/LauncherTabs.js +2 -2
- package/dist/Components/NavLauncher/NavLauncher.d.ts +1 -1
- package/dist/Components/NavLauncher/NavLauncher.js +257 -47
- package/dist/Components/NavLauncher/NavLauncherProps.d.ts +79 -3
- package/dist/Components/NavLauncher/ScopeBar.d.ts +14 -0
- package/dist/Components/NavLauncher/ScopeBar.js +137 -0
- package/dist/Components/NavLauncher/engine/distance.d.ts +4 -0
- package/dist/Components/NavLauncher/engine/distance.js +41 -0
- package/dist/Components/NavLauncher/engine/engine.d.ts +84 -0
- package/dist/Components/NavLauncher/engine/engine.js +471 -0
- package/dist/Components/NavLauncher/engine/fold.d.ts +15 -0
- package/dist/Components/NavLauncher/engine/fold.js +83 -0
- package/dist/Components/NavLauncher/engine/index.d.ts +21 -0
- package/dist/Components/NavLauncher/engine/index.js +17 -0
- package/dist/Components/NavLauncher/launcherParts.d.ts +2 -0
- package/dist/Components/NavLauncher/launcherParts.js +11 -7
- package/dist/Components/NavLauncher/match.d.ts +13 -2
- package/dist/Components/NavLauncher/match.js +26 -12
- package/dist/Components/NavLauncher/searchLayout.d.ts +60 -0
- package/dist/Components/NavLauncher/searchLayout.js +108 -0
- package/dist/Components/NavLauncher/spotlight.d.ts +39 -0
- package/dist/Components/NavLauncher/spotlight.js +202 -0
- package/dist/Components/NavLauncher/spotlightParts.d.ts +49 -0
- package/dist/Components/NavLauncher/spotlightParts.js +108 -0
- package/dist/Components/Table/components/TableHeader.js +3 -1
- package/dist/Components/Table/components/TableLoading.js +8 -2
- package/dist/Components/WizardDialog/WizardDialog.d.ts +1 -1
- package/dist/Components/WizardDialog/WizardDialog.js +15 -3
- package/dist/Components/WizardDialog/WizardDialogProps.d.ts +5 -3
- package/dist/Components/WorkspaceWindow/WorkspaceWindow.js +3 -2
- package/dist/Components/WorkspaceWindow/WorkspaceWindowProps.d.ts +2 -8
- package/dist/Theme/chakra/ringShadow.d.ts +3 -0
- package/dist/Theme/chakra/ringShadow.js +7 -0
- package/dist/Theme/tokens/builders/buildDarkPalette.d.ts +1 -1
- package/dist/Theme/tokens/builders/buildDarkPalette.js +5 -5
- package/dist/esm/Components/CopyButton/CopyButton.js +2 -2
- package/dist/esm/Components/Drawer/Drawer.js +6 -2
- package/dist/esm/Components/FormDrawer/FormDrawer.js +3 -3
- package/dist/esm/Components/Modal/dialogNaming.js +18 -0
- package/dist/esm/Components/NavLauncher/LauncherTabs.js +2 -2
- package/dist/esm/Components/NavLauncher/NavLauncher.js +259 -49
- package/dist/esm/Components/NavLauncher/ScopeBar.js +134 -0
- package/dist/esm/Components/NavLauncher/engine/distance.js +37 -0
- package/dist/esm/Components/NavLauncher/engine/engine.js +458 -0
- package/dist/esm/Components/NavLauncher/engine/fold.js +74 -0
- package/dist/esm/Components/NavLauncher/engine/index.js +14 -0
- package/dist/esm/Components/NavLauncher/launcherParts.js +10 -6
- package/dist/esm/Components/NavLauncher/match.js +25 -12
- package/dist/esm/Components/NavLauncher/searchLayout.js +100 -0
- package/dist/esm/Components/NavLauncher/spotlight.js +194 -0
- package/dist/esm/Components/NavLauncher/spotlightParts.js +95 -0
- package/dist/esm/Components/Table/components/TableHeader.js +4 -2
- package/dist/esm/Components/Table/components/TableLoading.js +6 -3
- package/dist/esm/Components/WizardDialog/WizardDialog.js +15 -3
- package/dist/esm/Components/WorkspaceWindow/WorkspaceWindow.js +4 -3
- package/dist/esm/Theme/chakra/ringShadow.js +3 -0
- package/dist/esm/Theme/tokens/builders/buildDarkPalette.js +5 -5
- package/dist/esm/index.js +2 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -1
- package/package.json +1 -1
|
@@ -18,12 +18,16 @@ import ToolTip from "../ToolTip/ToolTip.js";
|
|
|
18
18
|
import { useIsTruncated } from "../../Hooks/useIsTruncated.js";
|
|
19
19
|
import { shortcutKeys } from "../AppSwitcher/AppSwitcherProps.js";
|
|
20
20
|
import Skeletons from "../Skeletons/Skeletons.js";
|
|
21
|
-
import { activeRowSurface, AppsSection, CountBadge, Highlight, isPlainClick, ITEM_SELECTOR, ModuleRow, NewTag, PinnedTile, PinTextButton, RailRow, ROW_CONTAINER, RowActions, RowIcon, RowTip, SectionHeader, titleInset, TouchDensity, useTouchDensity, WIDE_ROW, } from "./launcherParts.js";
|
|
21
|
+
import { activeRowSurface, AppsSection, CountBadge, Highlight, HighlightOptionsProvider, isPlainClick, ITEM_SELECTOR, ModuleRow, NewTag, PinnedTile, PinTextButton, RailRow, ROW_CONTAINER, RowActions, RowIcon, RowTip, SectionHeader, titleInset, TouchDensity, useTouchDensity, WIDE_ROW, } from "./launcherParts.js";
|
|
22
22
|
import { LauncherTabs, panelId, tabId, } from "./LauncherTabs.js";
|
|
23
|
-
import { searchLauncherSections } from "./match.js";
|
|
23
|
+
import { filterItems, searchLauncherSections, } from "./match.js";
|
|
24
24
|
import NewTabLink from "./NewTabLink.js";
|
|
25
25
|
import PinToggle from "./PinToggle.js";
|
|
26
26
|
import { moveResult } from "./resultNavigation.js";
|
|
27
|
+
import { ScopeBar } from "./ScopeBar.js";
|
|
28
|
+
import { countByScope, inScope, layoutSearch, scopeGroups, takeTopHit, } from "./searchLayout.js";
|
|
29
|
+
import { createSpotlightIndex, matchAnswers, SCOPE_ACTIONS, SCOPE_ALL, SCOPE_SCREENS, searchSpotlight, spotlightBoosts, } from "./spotlight.js";
|
|
30
|
+
import { AnswerCard, describeFacts, PreviewPane, QuickActionsRow, ShowMoreOption, TopHitCard, } from "./spotlightParts.js";
|
|
27
31
|
const NO_APPS = [];
|
|
28
32
|
const MD_QUERY = "(min-width: 48em)";
|
|
29
33
|
const LG_QUERY = "(min-width: 62em)";
|
|
@@ -47,6 +51,11 @@ const RESULT_KEYS = [
|
|
|
47
51
|
];
|
|
48
52
|
const TEXT_TARGET = "input, textarea, select, [contenteditable=true]";
|
|
49
53
|
const ROW_HEIGHT = 46;
|
|
54
|
+
const SPOTLIGHT_GROUP_LIMIT = 5;
|
|
55
|
+
const FIELD_MIN_WIDTH = "max(15rem, 36%)";
|
|
56
|
+
const NO_GROUPS = new Set();
|
|
57
|
+
const NO_RESULTS = [];
|
|
58
|
+
const NO_SEARCH_GROUPS = [];
|
|
50
59
|
const DEFAULT_LABELS = {
|
|
51
60
|
title: "Menu",
|
|
52
61
|
searchPlaceholder: "Search menus and screens",
|
|
@@ -71,7 +80,6 @@ const DEFAULT_LABELS = {
|
|
|
71
80
|
hintNewTab: "new tab",
|
|
72
81
|
hintPin: "pin",
|
|
73
82
|
hintClose: "close",
|
|
74
|
-
hintOpenMenu: "open",
|
|
75
83
|
hintClickNewTab: "+ click for new tab",
|
|
76
84
|
newTabTip: "Open in new tab",
|
|
77
85
|
resultsCount: (count) => `${count} ${count === 1 ? "result" : "results"}`,
|
|
@@ -89,6 +97,31 @@ const DEFAULT_LABELS = {
|
|
|
89
97
|
pinShort: "Pin",
|
|
90
98
|
footerNote: "Pins follow your account",
|
|
91
99
|
suggestionsHint: "Try one of these",
|
|
100
|
+
topHit: "Top hit",
|
|
101
|
+
matchedOn: "Matches",
|
|
102
|
+
answers: "Answers",
|
|
103
|
+
hintCopy: "copy",
|
|
104
|
+
scopes: "Search in",
|
|
105
|
+
scopeAll: "All",
|
|
106
|
+
scopeChanged: (label) => `Showing ${label}`,
|
|
107
|
+
scopeCount: (label, count) => `${label}, ${count} ${count === 1 ? "result" : "results"}`,
|
|
108
|
+
scopeEmpty: (label) => `Type to search ${label}`,
|
|
109
|
+
quickActions: "Quick actions",
|
|
110
|
+
showMore: (count) => `Show ${count} more`,
|
|
111
|
+
preview: "Preview",
|
|
112
|
+
copy: (label) => `Copy ${label}`,
|
|
113
|
+
copied: "Copied",
|
|
114
|
+
copySelected: "Clipboard blocked, text selected — copy it with your keyboard",
|
|
115
|
+
};
|
|
116
|
+
const selectNode = (node) => {
|
|
117
|
+
var _a;
|
|
118
|
+
const selection = (_a = window.getSelection) === null || _a === void 0 ? void 0 : _a.call(window);
|
|
119
|
+
if (!node || !selection)
|
|
120
|
+
return;
|
|
121
|
+
const range = document.createRange();
|
|
122
|
+
range.selectNodeContents(node);
|
|
123
|
+
selection.removeAllRanges();
|
|
124
|
+
selection.addRange(range);
|
|
92
125
|
};
|
|
93
126
|
const visibleSections = (sections) => sections
|
|
94
127
|
.map((section) => ({
|
|
@@ -125,15 +158,15 @@ function Rail({ label, children, scrolls = false, }) {
|
|
|
125
158
|
function SkeletonLayout({ label }) {
|
|
126
159
|
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))) })] }));
|
|
127
160
|
}
|
|
128
|
-
function SearchField({ inputRef, value, onChange, onKeyDown, labels, hint, listboxId, activeId, isExpanded, hasResults, }) {
|
|
161
|
+
function SearchField({ inputRef, value, onChange, onKeyDown, labels, placeholder, hint, listboxId, activeId, isExpanded, hasResults, minW, }) {
|
|
129
162
|
const { colors } = useCustomTheme();
|
|
130
|
-
return (_jsxs(Flex, { flex: 1, minW:
|
|
163
|
+
return (_jsxs(Flex, { flex: 1, minW: minW, h: { base: "40px", md: "44px" }, align: "center", gap: "10px", pl: "14px", pr: "10px", borderRadius: { base: "10px", md: "12px" }, borderWidth: "1px", borderColor: colors.primary[500], bg: colors.surfaceRaised, boxShadow: `0 0 0 3px ${colors.primary.opacity[16]}`, children: [_jsx(Box, { as: "span", color: colors.accentText, display: "inline-flex", flexShrink: 0, children: _jsx(SearchIcon, { size: 18, strokeWidth: 2.2, "aria-hidden": true }) }), _jsx(Box, { as: "input", ref: inputRef, value: value, onChange: (event) => onChange(event.target.value), onKeyDown: onKeyDown, placeholder: placeholder, "aria-label": labels.searchPlaceholder, role: "combobox", "aria-expanded": isExpanded, "aria-controls": isExpanded && hasResults ? listboxId : undefined, "aria-autocomplete": "list", "aria-activedescendant": activeId, autoComplete: "off", flex: 1, minW: 0, h: "100%", border: 0, outline: "none", bg: "transparent", fontSize: "16px", color: colors.text[900], _placeholder: { color: placeholderInk(colors), opacity: 1 } }), value ? (_jsx(Box, { as: "button", type: "button", "aria-label": labels.clearSearch, onClick: () => {
|
|
131
164
|
var _a;
|
|
132
165
|
onChange("");
|
|
133
166
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
134
167
|
}, boxSize: "24px", borderRadius: "6px", bg: colors.backgroundColor.subtle, color: colors.textMuted, display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0, sx: focusVisibleStyles(colors), children: _jsx(X, { size: 12, strokeWidth: 2.4, "aria-hidden": true }) })) : null, hint ? (_jsx(Box, { "aria-hidden": true, display: { base: "none", md: "block" }, children: _jsx(Kbd, { size: "xs", children: hint }) })) : null] }));
|
|
135
168
|
}
|
|
136
|
-
function SearchRow({ item, query, isActive, link, labels, optionId, isPinned, canPin, onPin, onOpen, onHover, }) {
|
|
169
|
+
function SearchRow({ item, query, isActive, link, labels, optionId, isPinned, canPin, onPin, onOpen, onHover, describedBy, }) {
|
|
137
170
|
const { colors } = useCustomTheme();
|
|
138
171
|
const isTouch = useTouchDensity();
|
|
139
172
|
const isScreen = item.kind === "screen";
|
|
@@ -148,17 +181,18 @@ function SearchRow({ item, query, isActive, link, labels, optionId, isPinned, ca
|
|
|
148
181
|
const tipLabel = isScreen || !item.context ? fullLabel : `${fullLabel} · ${item.context}`;
|
|
149
182
|
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: isTouch ? "44px" : "34px", pl: "8px", pr: "4px", pt: isTouch ? "12px" : "7px", pb: isTouch ? "8px" : "5px", borderRadius: "8px", transition: transitionFor(["background-color"]), onMouseMove: onHover, sx: isActive
|
|
150
183
|
? { ...ROW_CONTAINER, ...activeRowSurface(colors) }
|
|
151
|
-
: 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: () => {
|
|
184
|
+
: ROW_CONTAINER, children: [_jsxs(Flex, { id: optionId, role: "option", "aria-selected": isActive, "aria-describedby": describedBy, "data-active": isActive, flex: 1, minW: 0, align: "flex-start", gap: "10px", cursor: "pointer", onClick: () => {
|
|
152
185
|
if (!item.href)
|
|
153
186
|
onOpen();
|
|
154
|
-
}, 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: {
|
|
187
|
+
}, 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", overflow: item.keywordHint ? "hidden" : undefined, 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, ...(item.keywordHint ? { flexShrink: 0, maxW: "100%" } : {}), 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", minW: 0, flexShrink: 100, overflow: "hidden", textOverflow: "ellipsis", 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: {
|
|
155
188
|
display: "none",
|
|
156
189
|
[WIDE_ROW]: { display: "inline-flex" },
|
|
157
190
|
"@media (hover: none)": { display: "none" },
|
|
158
191
|
}, 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), tip: labels.newTabTip, linkAs: link.linkAs, tabIndex: -1 })) : null] }) }), hasStar ? (_jsx(RowTip, { text: isPinned ? labels.unpinTip : labels.pinTip })) : null] }) }));
|
|
159
192
|
}
|
|
160
193
|
/** Left-drawer navigation launcher: browse every module, pins, Frequent, Recent, search and (compact) the suite's apps. */
|
|
161
|
-
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, modKeyLabel, headerActions, maxWidth = "1080px", labels: labelOverrides, apps, currentAppId, onAppSelect, appsVisibility = "apps-on-compact", "data-testid": testId, }) {
|
|
194
|
+
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, modKeyLabel, headerActions, maxWidth = "1080px", labels: labelOverrides, apps, currentAppId, onAppSelect, appsVisibility = "apps-on-compact", searchMode = "classic", synonyms, scopes, activeScope, onScopeChange, quickActions, answers, groupLimit, "data-testid": testId, }) {
|
|
195
|
+
var _a, _b, _c;
|
|
162
196
|
const theme = useCustomTheme();
|
|
163
197
|
const { colors } = theme;
|
|
164
198
|
const inputRef = useRef(null);
|
|
@@ -171,54 +205,157 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
171
205
|
const [innerQuery, setInnerQuery] = useState("");
|
|
172
206
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
173
207
|
const [tab, setTab] = useState("menu");
|
|
208
|
+
const [innerScope, setInnerScope] = useState(SCOPE_ALL);
|
|
209
|
+
const [expanded, setExpanded] = useState(NO_GROUPS);
|
|
210
|
+
const [announcement, setAnnouncement] = useState({ text: "", n: 0 });
|
|
174
211
|
const navigating = useRef(false);
|
|
175
212
|
const labels = useMemo(() => ({ ...DEFAULT_LABELS, ...labelOverrides }), [labelOverrides]);
|
|
176
213
|
const isControlled = controlledQuery !== undefined;
|
|
177
214
|
const query = isControlled ? controlledQuery : innerQuery;
|
|
215
|
+
const isSpotlight = searchMode === "spotlight";
|
|
178
216
|
const setQuery = useCallback((next) => {
|
|
179
217
|
if (!isControlled)
|
|
180
218
|
setInnerQuery(next);
|
|
181
219
|
onQueryChange === null || onQueryChange === void 0 ? void 0 : onQueryChange(next);
|
|
182
220
|
}, [isControlled, onQueryChange]);
|
|
183
|
-
const
|
|
184
|
-
|
|
221
|
+
const scopeList = useMemo(() => {
|
|
222
|
+
if (!(scopes === null || scopes === void 0 ? void 0 : scopes.length))
|
|
223
|
+
return [];
|
|
224
|
+
if (scopes.some((s) => s.id === SCOPE_ALL))
|
|
225
|
+
return [...scopes];
|
|
226
|
+
return [{ id: SCOPE_ALL, label: labels.scopeAll }, ...scopes];
|
|
227
|
+
}, [scopes, labels.scopeAll]);
|
|
228
|
+
const rawScope = activeScope !== null && activeScope !== void 0 ? activeScope : innerScope;
|
|
229
|
+
const scope = scopeList.some((s) => s.id === rawScope) ? rawScope : SCOPE_ALL;
|
|
230
|
+
const announce = useCallback((text) => setAnnouncement((prev) => ({ text, n: prev.n + 1 })), []);
|
|
231
|
+
const setScope = useCallback((next, isSilent = false) => {
|
|
232
|
+
var _a;
|
|
233
|
+
if (activeScope === undefined)
|
|
234
|
+
setInnerScope(next);
|
|
235
|
+
onScopeChange === null || onScopeChange === void 0 ? void 0 : onScopeChange(next);
|
|
236
|
+
const label = (_a = scopeList.find((s) => s.id === next)) === null || _a === void 0 ? void 0 : _a.label;
|
|
237
|
+
if (!isSilent && label)
|
|
238
|
+
announce(labels.scopeChanged(label));
|
|
239
|
+
}, [activeScope, onScopeChange, scopeList, announce, labels]);
|
|
240
|
+
const latest = useRef({ query, setQuery, scope, setScope });
|
|
241
|
+
latest.current = { query, setQuery, scope, setScope };
|
|
185
242
|
useEffect(() => {
|
|
186
243
|
if (isOpen)
|
|
187
244
|
return;
|
|
188
245
|
setTab("menu");
|
|
246
|
+
setExpanded(NO_GROUPS);
|
|
247
|
+
setAnnouncement({ text: "", n: 0 });
|
|
189
248
|
if (latest.current.query !== "")
|
|
190
249
|
latest.current.setQuery("");
|
|
250
|
+
if (latest.current.scope !== SCOPE_ALL)
|
|
251
|
+
latest.current.setScope(SCOPE_ALL, true);
|
|
191
252
|
}, [isOpen]);
|
|
192
253
|
useEffect(() => {
|
|
193
254
|
navigating.current = false;
|
|
194
255
|
setActiveIndex(0);
|
|
195
|
-
}, [query]);
|
|
256
|
+
}, [query, scope]);
|
|
196
257
|
const sections = useMemo(() => visibleSections(rawSections), [rawSections]);
|
|
197
258
|
const byId = useMemo(() => indexScreens(sections), [sections]);
|
|
198
259
|
const pinned = useMemo(() => new Set(pinnedIds), [pinnedIds]);
|
|
199
260
|
const pinnedItems = useMemo(() => pinnedIds.flatMap((id) => { var _a; return (_a = byId.get(id)) !== null && _a !== void 0 ? _a : []; }), [pinnedIds, byId]);
|
|
200
261
|
const frequentItems = useMemo(() => frequentIds.flatMap((id) => { var _a; return (_a = byId.get(id)) !== null && _a !== void 0 ? _a : []; }), [frequentIds, byId]);
|
|
201
262
|
const recentItems = useMemo(() => recentIds.flatMap((id) => { var _a; return (_a = byId.get(id)) !== null && _a !== void 0 ? _a : []; }), [recentIds, byId]);
|
|
202
|
-
const
|
|
263
|
+
const spotIndex = useMemo(() => isSpotlight
|
|
264
|
+
? createSpotlightIndex(sections, actions, labels.actionsGroup)
|
|
265
|
+
: null, [isSpotlight, sections, actions, labels.actionsGroup]);
|
|
266
|
+
const boosts = useMemo(() => spotIndex
|
|
267
|
+
? spotlightBoosts(spotIndex, { pinnedIds, frequentIds, recentIds })
|
|
268
|
+
: undefined, [spotIndex, pinnedIds, frequentIds, recentIds]);
|
|
269
|
+
const modelGroups = useMemo(() => {
|
|
270
|
+
if (spotIndex) {
|
|
271
|
+
return searchSpotlight(spotIndex, {
|
|
272
|
+
query,
|
|
273
|
+
extraResults,
|
|
274
|
+
synonyms,
|
|
275
|
+
boosts,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
const local = (extraResults !== null && extraResults !== void 0 ? extraResults : []).map((g) => g.matchLocally ? { ...g, items: filterItems(g.items, query) } : g);
|
|
279
|
+
const found = searchLauncherSections({
|
|
280
|
+
query,
|
|
281
|
+
sections,
|
|
282
|
+
actions,
|
|
283
|
+
extraResults: local,
|
|
284
|
+
actionsLabel: labels.actionsGroup,
|
|
285
|
+
});
|
|
286
|
+
const scopeOf = new Map(local.map((g) => { var _a; return [g.id, (_a = g.scope) !== null && _a !== void 0 ? _a : g.id]; }));
|
|
287
|
+
return [
|
|
288
|
+
...found.sections.map((s) => ({
|
|
289
|
+
id: `section:${s.id}`,
|
|
290
|
+
label: s.label,
|
|
291
|
+
scope: SCOPE_SCREENS,
|
|
292
|
+
isSection: true,
|
|
293
|
+
items: s.items,
|
|
294
|
+
})),
|
|
295
|
+
...found.groups.map((g) => {
|
|
296
|
+
var _a;
|
|
297
|
+
return ({
|
|
298
|
+
...g,
|
|
299
|
+
scope: g.id === "actions" ? SCOPE_ACTIONS : ((_a = scopeOf.get(g.id)) !== null && _a !== void 0 ? _a : g.id),
|
|
300
|
+
isSection: false,
|
|
301
|
+
});
|
|
302
|
+
}),
|
|
303
|
+
];
|
|
304
|
+
}, [
|
|
305
|
+
spotIndex,
|
|
203
306
|
query,
|
|
307
|
+
extraResults,
|
|
308
|
+
synonyms,
|
|
309
|
+
boosts,
|
|
204
310
|
sections,
|
|
205
311
|
actions,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
})),
|
|
216
|
-
...found.groups,
|
|
217
|
-
], [found, labels]);
|
|
218
|
-
const results = useMemo(() => groups.flatMap((g) => g.items), [groups]);
|
|
219
|
-
const groupStarts = useMemo(() => groups.map((_, i) => groups.slice(0, i).reduce((n, g) => n + g.items.length, 0)), [groups]);
|
|
312
|
+
labels.actionsGroup,
|
|
313
|
+
]);
|
|
314
|
+
const matchedAnswers = useMemo(() => matchAnswers(answers, query, synonyms), [answers, query, synonyms]);
|
|
315
|
+
const answerResults = scope === SCOPE_ALL ? matchedAnswers : NO_RESULTS;
|
|
316
|
+
const scoped = useMemo(() => {
|
|
317
|
+
const groups = inScope(modelGroups, scope);
|
|
318
|
+
return isSpotlight ? takeTopHit(groups) : { groups };
|
|
319
|
+
}, [modelGroups, scope, isSpotlight]);
|
|
320
|
+
const highlightOptions = useMemo(() => (isSpotlight ? { fuzzy: true, synonyms } : undefined), [isSpotlight, synonyms]);
|
|
220
321
|
const isSearchView = query.trim().length > 0;
|
|
221
|
-
const
|
|
322
|
+
const hasScopes = scopeList.length > 1;
|
|
323
|
+
const currentScope = scopeList.find((s) => s.id === scope);
|
|
324
|
+
const isScopeBrowse = !isSearchView && hasScopes && scope !== SCOPE_ALL && scope !== SCOPE_SCREENS;
|
|
325
|
+
const isListView = isSearchView || isScopeBrowse;
|
|
326
|
+
const browseGroups = useMemo(() => isScopeBrowse
|
|
327
|
+
? scopeGroups({
|
|
328
|
+
scope,
|
|
329
|
+
actions,
|
|
330
|
+
extraResults,
|
|
331
|
+
actionsLabel: labels.actionsGroup,
|
|
332
|
+
})
|
|
333
|
+
: NO_SEARCH_GROUPS, [isScopeBrowse, scope, actions, extraResults, labels.actionsGroup]);
|
|
334
|
+
const limit = groupLimit !== null && groupLimit !== void 0 ? groupLimit : (isSpotlight ? SPOTLIGHT_GROUP_LIMIT : undefined);
|
|
335
|
+
const layout = useMemo(() => isScopeBrowse
|
|
336
|
+
? layoutSearch({ answers: NO_RESULTS, groups: browseGroups, expanded })
|
|
337
|
+
: layoutSearch({
|
|
338
|
+
answers: answerResults,
|
|
339
|
+
topHit: scoped.topHit,
|
|
340
|
+
groups: scoped.groups,
|
|
341
|
+
limit,
|
|
342
|
+
expanded,
|
|
343
|
+
}), [isScopeBrowse, browseGroups, answerResults, scoped, limit, expanded]);
|
|
344
|
+
const scopeChips = useMemo(() => {
|
|
345
|
+
const counts = isSearchView && hasScopes
|
|
346
|
+
? countByScope(modelGroups, matchedAnswers.length)
|
|
347
|
+
: undefined;
|
|
348
|
+
return scopeList.map((s) => {
|
|
349
|
+
var _a;
|
|
350
|
+
return ({
|
|
351
|
+
id: s.id,
|
|
352
|
+
label: s.label,
|
|
353
|
+
count: counts ? ((_a = counts.get(s.id)) !== null && _a !== void 0 ? _a : 0) : undefined,
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
}, [isSearchView, hasScopes, modelGroups, matchedAnswers, scopeList]);
|
|
357
|
+
const entries = layout.entries;
|
|
358
|
+
const active = Math.min(activeIndex, Math.max(entries.length - 1, 0));
|
|
222
359
|
const appList = apps !== null && apps !== void 0 ? apps : NO_APPS;
|
|
223
360
|
const showApps = appList.some((app) => app.id !== currentAppId) &&
|
|
224
361
|
(appsVisibility === "always" || !isDesktop);
|
|
@@ -233,12 +370,9 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
233
370
|
: []),
|
|
234
371
|
...(showApps ? [{ id: "apps", label: labels.tabApps }] : []),
|
|
235
372
|
], [hasQuick, showApps, labels]);
|
|
236
|
-
const isTabbed = !isLg && !
|
|
373
|
+
const isTabbed = !isLg && !isListView && !isLoading && tabs.length > 1;
|
|
237
374
|
const activeTab = tabs.some((item) => item.id === tab) ? tab : "menu";
|
|
238
|
-
const countText = isSearchView &&
|
|
239
|
-
? labels.resultsCount(results.length)
|
|
240
|
-
: "";
|
|
241
|
-
const groupSizes = useMemo(() => groups.map((g) => g.items.length), [groups]);
|
|
375
|
+
const countText = isSearchView && layout.total > 0 ? labels.resultsCount(layout.total) : "";
|
|
242
376
|
const link = useMemo(() => ({
|
|
243
377
|
linkAs,
|
|
244
378
|
onPlainClick: (event) => {
|
|
@@ -258,6 +392,38 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
258
392
|
onClose();
|
|
259
393
|
onNavigate(item.href, { newTab });
|
|
260
394
|
}, [onClose, onNavigate]);
|
|
395
|
+
const copyValue = useCallback(async (value, node) => {
|
|
396
|
+
try {
|
|
397
|
+
await navigator.clipboard.writeText(value);
|
|
398
|
+
announce(labels.copied);
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
selectNode(node);
|
|
402
|
+
announce(labels.copySelected);
|
|
403
|
+
}
|
|
404
|
+
}, [announce, labels]);
|
|
405
|
+
const onCopied = useCallback(() => announce(labels.copied), [announce, labels]);
|
|
406
|
+
const onCopyBlocked = useCallback((node) => {
|
|
407
|
+
selectNode(node);
|
|
408
|
+
announce(labels.copySelected);
|
|
409
|
+
}, [announce, labels]);
|
|
410
|
+
const activate = (index, newTab) => {
|
|
411
|
+
var _a, _b;
|
|
412
|
+
const entry = entries[index];
|
|
413
|
+
if (!entry)
|
|
414
|
+
return;
|
|
415
|
+
if (entry.type === "more") {
|
|
416
|
+
setExpanded((prev) => new Set(prev).add(entry.groupId));
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const { item } = entry;
|
|
420
|
+
if (entry.type === "answer" && !item.run && !item.href) {
|
|
421
|
+
const node = document.getElementById(`${baseId}-opt-${index}-value`);
|
|
422
|
+
void copyValue((_b = (_a = item.answer) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : item.label, node);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
open(item, newTab);
|
|
426
|
+
};
|
|
261
427
|
const focusField = (shouldSelect = false) => {
|
|
262
428
|
var _a, _b;
|
|
263
429
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -309,18 +475,18 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
309
475
|
(height > 0 && byDistance.length ? byDistance[0] : fallback).focus();
|
|
310
476
|
};
|
|
311
477
|
const onInputKeyDown = (event) => {
|
|
312
|
-
if (!
|
|
478
|
+
if (!isListView) {
|
|
313
479
|
if (event.key === "ArrowDown") {
|
|
314
480
|
event.preventDefault();
|
|
315
481
|
moveFocus("first");
|
|
316
482
|
}
|
|
317
483
|
return;
|
|
318
484
|
}
|
|
319
|
-
if (
|
|
485
|
+
if (entries.length === 0 || event.nativeEvent.isComposing)
|
|
320
486
|
return;
|
|
321
487
|
if (event.key === "Enter") {
|
|
322
488
|
event.preventDefault();
|
|
323
|
-
|
|
489
|
+
activate(active, event.metaKey || event.ctrlKey);
|
|
324
490
|
return;
|
|
325
491
|
}
|
|
326
492
|
const hasModifier = event.altKey || event.metaKey || event.ctrlKey || event.shiftKey;
|
|
@@ -341,7 +507,7 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
341
507
|
event.preventDefault();
|
|
342
508
|
navigating.current = true;
|
|
343
509
|
const pageRows = Math.max(3, Math.floor(scrollHeight(input) / ROW_HEIGHT) - 1);
|
|
344
|
-
setActiveIndex(moveResult(
|
|
510
|
+
setActiveIndex(moveResult(layout.sizes, columns, active, event.key, pageRows));
|
|
345
511
|
};
|
|
346
512
|
const moveInGrid = (event, cell) => {
|
|
347
513
|
var _a, _b, _c, _d;
|
|
@@ -479,7 +645,7 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
479
645
|
useEffect(() => {
|
|
480
646
|
var _a, _b, _c;
|
|
481
647
|
(_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" });
|
|
482
|
-
}, [active,
|
|
648
|
+
}, [active, entries]);
|
|
483
649
|
const lastItemIndex = useRef(-1);
|
|
484
650
|
useEffect(() => {
|
|
485
651
|
if (!isOpen)
|
|
@@ -518,38 +684,82 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
518
684
|
const listboxId = `${baseId}-results`;
|
|
519
685
|
const optionId = (index) => `${baseId}-opt-${index}`;
|
|
520
686
|
const togglePinFor = (id) => onTogglePin ? () => onTogglePin(id) : undefined;
|
|
521
|
-
const hasResults =
|
|
687
|
+
const hasResults = entries.length > 0;
|
|
522
688
|
const trimmed = query.trim();
|
|
523
689
|
const pinnedColumns = !isLg && isDesktop ? 3 : PINNED_COLUMNS;
|
|
524
690
|
const quickSections = (_jsxs(_Fragment, { 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": pinnedColumns, display: "grid", gridTemplateColumns: `repeat(${pinnedColumns}, 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), tip: labels.newTabTip, 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), tip: labels.newTabTip, linkAs: link.linkAs }) }, screen.id)))] })) : null] }));
|
|
525
691
|
const rail = (_jsxs(Rail, { label: labels.quickAccess, scrolls: isLg, children: [quickSections, showApps ? renderApps(false) : null] }));
|
|
526
|
-
const
|
|
692
|
+
const quickBlock = scope === SCOPE_ALL && (quickActions === null || quickActions === void 0 ? void 0 : quickActions.length) ? (_jsxs(Flex, { as: "section", direction: "column", gap: "8px", children: [_jsx(SectionHeader, { label: labels.quickActions, isDecorative: true, hasCount: false }), _jsx(QuickActionsRow, { items: quickActions, label: labels.quickActions, link: link, onRun: (item) => open(item, false) })] })) : null;
|
|
693
|
+
const sectionsPane = 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) => {
|
|
527
694
|
const pinId = module.screens[0].id;
|
|
528
695
|
return (_jsx(ModuleRow, { module: module, keyScreens: module.screens
|
|
529
696
|
.filter((s) => s.isKey && s.href !== module.href)
|
|
530
697
|
.slice(0, keyScreenLimit), isPinned: pinned.has(pinId), onTogglePin: togglePinFor(pinId), pinId: pinId, labels: labels, link: link }, module.id));
|
|
531
698
|
}) })] }, section.id))));
|
|
699
|
+
const browsePane = (_jsxs(_Fragment, { children: [quickBlock, sectionsPane] }));
|
|
532
700
|
const pickSuggestion = (value) => {
|
|
533
701
|
var _a;
|
|
534
702
|
setQuery(value);
|
|
535
703
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
536
704
|
};
|
|
537
|
-
const
|
|
705
|
+
const hasHint = !isSearching && !isScopeBrowse;
|
|
706
|
+
const emptyTitle = isSearching
|
|
707
|
+
? labels.searching
|
|
708
|
+
: isScopeBrowse
|
|
709
|
+
? labels.scopeEmpty((_a = currentScope === null || currentScope === void 0 ? void 0 : currentScope.label) !== null && _a !== void 0 ? _a : "")
|
|
710
|
+
: labels.noResults(trimmed);
|
|
711
|
+
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: emptyTitle }), hasHint ? (_jsx(Text, { fontSize: "12.5px", color: colors.textMuted, children: (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length)
|
|
538
712
|
? labels.suggestionsHint
|
|
539
|
-
: labels.noResultsHint }))] }),
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
713
|
+
: labels.noResultsHint })) : null] }), hasHint && (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] }));
|
|
714
|
+
const factsId = (index) => `${optionId(index)}-facts`;
|
|
715
|
+
const describedBy = (item, index) => { var _a; return ((_a = item.facts) === null || _a === void 0 ? void 0 : _a.length) ? factsId(index) : undefined; };
|
|
716
|
+
const cardProps = (item, index) => ({
|
|
717
|
+
item,
|
|
718
|
+
isActive: index === active,
|
|
719
|
+
optionId: optionId(index),
|
|
720
|
+
link,
|
|
721
|
+
labels,
|
|
722
|
+
onOpen: () => activate(index, false),
|
|
723
|
+
onHover: () => setActiveIndex(index),
|
|
724
|
+
describedBy: describedBy(item, index),
|
|
725
|
+
});
|
|
726
|
+
const renderBlock = (block) => {
|
|
727
|
+
if (block.type === "answers") {
|
|
728
|
+
return (_jsx(Flex, { role: "group", "aria-label": labels.answers, direction: "column", gap: "6px", children: block.items.map((item, i) => (_jsx(AnswerCard, { ...cardProps(item, block.start + i) }, item.id))) }, "answers"));
|
|
729
|
+
}
|
|
730
|
+
if (block.type === "top") {
|
|
731
|
+
return (_jsxs(Flex, { role: "group", "aria-label": labels.topHit, direction: "column", gap: "6px", children: [_jsx(SectionHeader, { label: labels.topHit, isDecorative: true }), _jsx(TopHitCard, { ...cardProps(block.item, block.start), query: query })] }, "top"));
|
|
732
|
+
}
|
|
733
|
+
const { group, more } = block;
|
|
734
|
+
const meta = group.isSection ? labels.found(group.items.length) : undefined;
|
|
735
|
+
return (_jsxs(Flex, { role: "group", "aria-label": meta ? `${group.label}, ${meta}` : group.label, direction: "column", gap: "3px", children: [_jsx(SectionHeader, { label: group.label, meta: meta ? `(${meta})` : undefined, isDecorative: true }), _jsx(ItemGrid, { columns: columns, children: block.visible.map((item, i) => {
|
|
736
|
+
const index = block.start + i;
|
|
737
|
+
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), describedBy: describedBy(item, index) }, item.id));
|
|
738
|
+
}) }), more ? (_jsx(ShowMoreOption, { count: more.count, isActive: more.index === active, optionId: optionId(more.index), label: labels.showMore, onExpand: () => activate(more.index, false), onHover: () => setActiveIndex(more.index) })) : null] }, group.id));
|
|
739
|
+
};
|
|
740
|
+
const searchPane = hasResults ? (_jsxs(HighlightOptionsProvider, { value: highlightOptions, children: [_jsx(Flex, { role: "listbox", id: listboxId, "aria-label": labels.title, "aria-busy": isSearching || undefined, direction: "column", gap: "14px", children: layout.blocks.map(renderBlock) }), entries.map((entry, index) => {
|
|
741
|
+
var _a;
|
|
742
|
+
return entry.type !== "more" && ((_a = entry.item.facts) === null || _a === void 0 ? void 0 : _a.length) ? (_jsx("span", { id: factsId(index), hidden: true, children: describeFacts(entry.item.facts) }, entry.item.id)) : null;
|
|
743
|
+
})] })) : (noResults);
|
|
744
|
+
const showPreview = isLg &&
|
|
745
|
+
isListView &&
|
|
746
|
+
entries.some((entry) => { var _a; return entry.type !== "more" && ((_a = entry.item.facts) === null || _a === void 0 ? void 0 : _a.length); });
|
|
747
|
+
const activeEntry = entries[active];
|
|
748
|
+
const activeItem = activeEntry && activeEntry.type !== "more" ? activeEntry.item : undefined;
|
|
749
|
+
const dock = !isLg && isListView && !isLoading && ((_b = activeItem === null || activeItem === void 0 ? void 0 : activeItem.facts) === null || _b === void 0 ? void 0 : _b.length) ? (_jsx(PreviewPane, { item: activeItem, placement: "dock", labels: labels, onCopied: onCopied, onCopyBlocked: onCopyBlocked })) : null;
|
|
750
|
+
const stacked = (_jsxs(_Fragment, { children: [_jsx(Pane, { scrolls: isLg, children: isListView ? searchPane : browsePane }), showPreview ? (_jsx(PreviewPane, { item: activeItem, placement: "side", width: RAIL_WIDTH, labels: labels, onCopied: onCopied, onCopyBlocked: onCopyBlocked })) : (rail)] }));
|
|
545
751
|
const body = isLoading ? _jsx(SkeletonLayout, { label: labels.loading }) : stacked;
|
|
752
|
+
const titleId = `${baseId}-title`;
|
|
753
|
+
const scopeBar = hasScopes ? (_jsx(ScopeBar, { scopes: scopeChips, value: scope, onChange: (next) => setScope(next), label: labels.scopes, countLabel: labels.scopeCount })) : null;
|
|
754
|
+
const inlineScopes = isDesktop ? scopeBar : null;
|
|
755
|
+
const scopeRow = isDesktop ? null : scopeBar;
|
|
546
756
|
const tabPanels = {
|
|
547
757
|
menu: _jsx(Pane, { children: browsePane }),
|
|
548
758
|
quick: (_jsx(Flex, { direction: "column", gap: "16px", px: "18px", pt: "14px", pb: "16px", children: quickSections })),
|
|
549
759
|
apps: (_jsx(Box, { px: "14px", pt: "10px", pb: "16px", children: renderApps(true) })),
|
|
550
760
|
};
|
|
551
761
|
const compactBody = (_jsx(Flex, { "data-scroll-region": true, role: isTabbed ? "tabpanel" : undefined, id: isTabbed ? panelId(baseId) : undefined, "aria-labelledby": isTabbed ? tabId(baseId, activeTab) : undefined, direction: "column", flex: 1, minH: 0, overflowY: "auto", children: isTabbed ? tabPanels[activeTab] : body }));
|
|
552
|
-
return (_jsx(TouchDensity, { value: !isLg, children: _jsxs(Drawer, { isOpen: isOpen, onClose: onClose, placement: "left", size: "full", initialFocusRef: inputRef, hideCloseButton: true, closeOnEsc: false, contentProps: {
|
|
762
|
+
return (_jsx(TouchDensity, { value: !isLg, children: _jsxs(Drawer, { isOpen: isOpen, onClose: onClose, placement: "left", size: "full", initialFocusRef: inputRef, hideCloseButton: true, closeOnEsc: false, "aria-labelledby": titleId, contentProps: {
|
|
553
763
|
maxW: { base: "100vw", lg: `min(${maxWidth}, calc(100vw - 56px))` },
|
|
554
764
|
h: { base: "100%", lg: "auto" },
|
|
555
765
|
maxH: "100%",
|
|
@@ -559,5 +769,5 @@ export default function NavLauncher({ isOpen, onClose, sections: rawSections, pi
|
|
|
559
769
|
overflow: "hidden",
|
|
560
770
|
onKeyDown: onContentKeyDown,
|
|
561
771
|
...{ "data-testid": testId },
|
|
562
|
-
}, children: [
|
|
772
|
+
}, children: [_jsxs(DrawerHeader, { p: 0, flexShrink: 0, children: [_jsxs(Flex, { "data-testid": "launcher-header-row", align: "center", gap: { base: "8px", md: "12px" }, minH: { base: "60px", md: "68px" }, pl: { base: "12px", md: "18px" }, pr: { base: "8px", md: "12px" }, children: [_jsx(VisuallyHidden, { as: "h2", id: titleId, children: labels.title }), _jsx(SearchField, { inputRef: inputRef, value: query, onChange: setQuery, onKeyDown: onInputKeyDown, labels: labels, placeholder: (_c = currentScope === null || currentScope === void 0 ? void 0 : currentScope.placeholder) !== null && _c !== void 0 ? _c : labels.searchPlaceholder, hint: searchHint, listboxId: listboxId, activeId: isListView && hasResults ? optionId(active) : undefined, isExpanded: isListView, hasResults: hasResults, minW: inlineScopes ? FIELD_MIN_WIDTH : 0 }), inlineScopes, _jsx(Box, { "aria-hidden": true, "data-testid": "launcher-count", display: { base: "none", sm: "block" }, flexShrink: 0, overflow: "hidden", w: countText ? "88px" : "0", opacity: countText ? 1 : 0, textAlign: "right", fontSize: "13px", whiteSpace: "nowrap", color: colors.textMuted, transition: transitionFor(["width", "opacity"]), sx: { fontVariantNumeric: "tabular-nums", ...reducedMotionSx() }, children: countText }), headerActions ? (_jsx(Flex, { align: "center", gap: "4px", flexShrink: 0, children: headerActions })) : null, _jsx(IconButton, { "aria-label": labels.close, icon: _jsx(X, { size: 18, "aria-hidden": true }), variant: "ghost", boxSize: { base: "40px", md: "44px" }, minW: { base: "40px", md: "44px" }, borderRadius: "10px", flexShrink: 0, color: colors.textMuted, onClick: onClose })] }), scopeRow ? (_jsx(Box, { "data-testid": "launcher-scope-row", pl: "7px", pr: "3px", mt: "-6px", pb: "4px", children: scopeRow })) : null] }), _jsx(DrawerBody, { p: 0, display: "flex", flexDirection: "column", overflowY: "hidden", minH: 0, children: _jsxs(Flex, { ref: bodyRef, direction: "column", flex: 1, minH: 0, minW: 0, children: [_jsx(VisuallyHidden, { "data-testid": "launcher-live", "aria-live": "polite", "aria-atomic": "true", children: countText }), _jsx(VisuallyHidden, { "data-testid": "launcher-announce", "aria-live": "polite", "aria-atomic": "true", children: _jsx("span", { children: announcement.text }, announcement.n) }), isTabbed ? (_jsx(LauncherTabs, { tabs: tabs, selected: activeTab, onSelect: setTab, idBase: baseId, label: labels.tabsLabel, onLeaveUp: () => focusField(), onLeaveDown: () => moveFocus("first") })) : null, isLg ? (_jsx(Flex, { direction: "row", flex: 1, minH: 0, minW: 0, children: body })) : (compactBody), dock] }) }), _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: [_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] }), _jsxs(Flex, { as: "span", align: "center", gap: "5px", children: [_jsx(Kbd, { size: "xs", children: modKeyLabel !== null && modKeyLabel !== void 0 ? modKeyLabel : MOD_KEY }), labels.hintClickNewTab] }), 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 })] })] }) }));
|
|
563
773
|
}
|