pixelize-design-library 2.4.2-beta.58 → 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 +149 -5
- package/COMPONENT-GOTCHAS.md +205 -18
- package/DESIGN-GUIDE.md +43 -9
- package/dist/Components/AppSwitcher/AppSwitcher.js +5 -1
- package/dist/Components/AppSwitcher/AppSwitcherProps.d.ts +2 -0
- package/dist/Components/AppSwitcher/AppSwitcherProps.js +7 -4
- 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/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Components/Breadcrumbs/Breadcrumbs.js +33 -10
- package/dist/Components/Breadcrumbs/BreadcrumbsProps.d.ts +16 -2
- 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/Card/Card.d.ts +3 -1
- package/dist/Components/Card/Card.js +12 -2
- package/dist/Components/Card/CardProps.d.ts +5 -1
- 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/Editor/Editor.js +50 -2
- package/dist/Components/Editor/EditorFieldBar.d.ts +15 -0
- package/dist/Components/Editor/EditorFieldBar.js +19 -0
- package/dist/Components/Editor/EditorProps.d.ts +74 -1
- package/dist/Components/Editor/MakeDynamicDialog.d.ts +12 -0
- package/dist/Components/Editor/MakeDynamicDialog.js +59 -0
- package/dist/Components/Editor/editorLabels.d.ts +4 -0
- package/dist/Components/Editor/editorLabels.js +24 -0
- package/dist/Components/Editor/editorTokenStyles.d.ts +28 -0
- package/dist/Components/Editor/editorTokenStyles.js +30 -0
- package/dist/Components/Editor/editorTokens.d.ts +26 -0
- package/dist/Components/Editor/editorTokens.js +134 -0
- package/dist/Components/Editor/useEditorBridge.d.ts +40 -0
- package/dist/Components/Editor/useEditorBridge.js +141 -0
- 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/Kbd/Kbd.d.ts +6 -0
- package/dist/Components/Kbd/Kbd.js +33 -0
- package/dist/Components/Kbd/KbdProps.d.ts +17 -0
- package/dist/Components/Kbd/KbdProps.js +2 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.d.ts +4 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.js +48 -0
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.d.ts +18 -0
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.js +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.d.ts +3 -0
- package/dist/Components/NavLauncher/NavLauncher.js +452 -0
- package/dist/Components/NavLauncher/NavLauncherProps.d.ts +187 -0
- package/dist/Components/NavLauncher/NavLauncherProps.js +2 -0
- package/dist/Components/NavLauncher/NewTabLink.d.ts +3 -0
- package/dist/Components/NavLauncher/NewTabLink.js +14 -0
- package/dist/Components/NavLauncher/PinToggle.d.ts +3 -0
- package/dist/Components/NavLauncher/PinToggle.js +21 -0
- package/dist/Components/NavLauncher/launcherParts.d.ts +152 -0
- package/dist/Components/NavLauncher/launcherParts.js +212 -0
- package/dist/Components/NavLauncher/match.d.ts +53 -0
- package/dist/Components/NavLauncher/match.js +178 -0
- package/dist/Components/NavLauncher/revealStyles.d.ts +4 -0
- package/dist/Components/NavLauncher/revealStyles.js +19 -0
- package/dist/Components/NavigationBar/NavigationBar.d.ts +1 -1
- package/dist/Components/NavigationBar/NavigationBar.js +2 -2
- package/dist/Components/NavigationBar/NavigationBarProps.d.ts +2 -0
- package/dist/Components/PageHeader/PageHeader.d.ts +1 -1
- package/dist/Components/PageHeader/PageHeader.js +9 -2
- package/dist/Components/PageHeader/PageHeaderProps.d.ts +8 -0
- package/dist/Components/PdfViewer/PdfViewer.d.ts +21 -4
- package/dist/Components/PdfViewer/PdfViewer.js +124 -3
- 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/Search/Search.js +2 -1
- 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/SideBar/SecondaryBar.js +4 -3
- package/dist/Components/SideBar/SideBar.d.ts +1 -1
- package/dist/Components/SideBar/SideBar.js +30 -9
- package/dist/Components/SideBar/SideBarProps.d.ts +32 -0
- package/dist/Components/SideBar/components/MenuItemBox.d.ts +6 -0
- package/dist/Components/SideBar/components/MenuItemBox.js +8 -4
- package/dist/Components/SideBar/components/MenuPopoverContent.js +3 -2
- package/dist/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/Components/SideBar/components/PinnedSection.d.ts +17 -0
- package/dist/Components/SideBar/components/PinnedSection.js +98 -0
- package/dist/Components/SideBar/sidebarFocus.d.ts +23 -0
- package/dist/Components/SideBar/sidebarFocus.js +20 -0
- package/dist/Components/StageProgress/StageProgress.js +2 -2
- package/dist/Components/StageProgress/StageProgressProps.d.ts +2 -0
- package/dist/Components/StageProgress/StepperStage.js +5 -2
- 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/Components/WizardDialog/WizardDialog.d.ts +9 -0
- package/dist/Components/WizardDialog/WizardDialog.js +102 -0
- package/dist/Components/WizardDialog/WizardDialogProps.d.ts +48 -0
- package/dist/Components/WizardDialog/WizardDialogProps.js +2 -0
- package/dist/Components/WizardDialog/useWizardFlow.d.ts +22 -0
- package/dist/Components/WizardDialog/useWizardFlow.js +47 -0
- package/dist/Components/WizardDialog/wizardSteps.d.ts +31 -0
- package/dist/Components/WizardDialog/wizardSteps.js +40 -0
- package/dist/esm/Components/AppSwitcher/AppSwitcher.js +2 -1
- package/dist/esm/Components/AppSwitcher/AppSwitcherProps.js +5 -3
- package/dist/esm/Components/AudioRecorder/AudioRecorder.js +161 -0
- package/dist/esm/Components/AudioRecorder/AudioRecorderProps.js +1 -0
- package/dist/esm/Components/Breadcrumbs/Breadcrumbs.js +35 -12
- 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/Card/Card.js +12 -2
- 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/Editor/Editor.js +48 -3
- package/dist/esm/Components/Editor/EditorFieldBar.js +13 -0
- package/dist/esm/Components/Editor/MakeDynamicDialog.js +20 -0
- package/dist/esm/Components/Editor/editorLabels.js +20 -0
- package/dist/esm/Components/Editor/editorTokenStyles.js +25 -0
- package/dist/esm/Components/Editor/editorTokens.js +121 -0
- package/dist/esm/Components/Editor/useEditorBridge.js +138 -0
- 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/Kbd/Kbd.js +28 -0
- package/dist/esm/Components/Kbd/KbdProps.js +1 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTrigger.js +41 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTriggerProps.js +1 -0
- 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 +413 -0
- package/dist/esm/Components/NavLauncher/NavLauncherProps.js +1 -0
- package/dist/esm/Components/NavLauncher/NewTabLink.js +11 -0
- package/dist/esm/Components/NavLauncher/PinToggle.js +18 -0
- package/dist/esm/Components/NavLauncher/launcherParts.js +187 -0
- package/dist/esm/Components/NavLauncher/match.js +172 -0
- package/dist/esm/Components/NavLauncher/revealStyles.js +15 -0
- package/dist/esm/Components/NavigationBar/NavigationBar.js +3 -3
- package/dist/esm/Components/PageHeader/PageHeader.js +9 -2
- package/dist/esm/Components/PdfViewer/PdfViewer.js +123 -2
- package/dist/esm/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +5 -0
- package/dist/esm/Components/QueryState/QueryStateBoundary.js +10 -4
- package/dist/esm/Components/Search/Search.js +3 -2
- 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/SideBar/SecondaryBar.js +4 -3
- package/dist/esm/Components/SideBar/SideBar.js +31 -10
- package/dist/esm/Components/SideBar/components/MenuItemBox.js +4 -2
- package/dist/esm/Components/SideBar/components/MenuPopoverContent.js +3 -2
- package/dist/esm/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/esm/Components/SideBar/components/PinnedSection.js +92 -0
- package/dist/esm/Components/SideBar/sidebarFocus.js +15 -0
- package/dist/esm/Components/StageProgress/StageProgress.js +2 -2
- package/dist/esm/Components/StageProgress/StepperStage.js +5 -2
- 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/Components/WizardDialog/WizardDialog.js +58 -0
- package/dist/esm/Components/WizardDialog/WizardDialogProps.js +1 -0
- package/dist/esm/Components/WizardDialog/useWizardFlow.js +44 -0
- package/dist/esm/Components/WizardDialog/wizardSteps.js +35 -0
- package/dist/esm/index.js +14 -0
- package/dist/index.d.ts +35 -6
- package/dist/index.js +38 -4
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@chakra-ui/react";
|
|
3
|
+
import { Compass } from "lucide-react";
|
|
4
|
+
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
|
+
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
6
|
+
import { FOCUS_VISIBLE_OVER_STATE, focusVisibleRing } from "../../Theme/chakra/focusRing.styles.js";
|
|
7
|
+
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
8
|
+
import { useMatchMedia } from "../../Hooks/useMatchMedia.js";
|
|
9
|
+
import { detectApple } from "../Kbd/Kbd.js";
|
|
10
|
+
import { formatShortcut } from "../AppSwitcher/AppSwitcherProps.js";
|
|
11
|
+
import ToolTip from "../ToolTip/ToolTip.js";
|
|
12
|
+
const MD_QUERY = "(min-width: 48em)";
|
|
13
|
+
const KEY_NAMES = {
|
|
14
|
+
mod: ["Meta", "Control"],
|
|
15
|
+
cmd: ["Meta"],
|
|
16
|
+
ctrl: ["Control"],
|
|
17
|
+
alt: ["Alt"],
|
|
18
|
+
shift: ["Shift"],
|
|
19
|
+
esc: ["Escape"],
|
|
20
|
+
};
|
|
21
|
+
export const keyShortcutsFor = (shortcut) => {
|
|
22
|
+
const options = shortcut
|
|
23
|
+
.split("+")
|
|
24
|
+
.map((p) => p.trim())
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
.map((p) => { var _a; return (_a = KEY_NAMES[p.toLowerCase()]) !== null && _a !== void 0 ? _a : [p.length === 1 ? p.toUpperCase() : p]; });
|
|
27
|
+
const variants = Math.max(1, ...options.map((o) => o.length));
|
|
28
|
+
const chords = Array.from({ length: variants }, (_, v) => options.map((o) => o[Math.min(v, o.length - 1)]).join("+"));
|
|
29
|
+
return Array.from(new Set(chords)).join(" ");
|
|
30
|
+
};
|
|
31
|
+
const LauncherTrigger = ({ onClick, isOpen, label = "Menu", shortcut = "mod+k", icon: Icon = Compass, display = "chip", "aria-label": ariaLabel, "data-testid": testId, }) => {
|
|
32
|
+
const { colors } = useCustomTheme();
|
|
33
|
+
const showHint = useMatchMedia(MD_QUERY, true);
|
|
34
|
+
const ring = focusVisibleRing(colors);
|
|
35
|
+
const hint = shortcut ? formatShortcut(shortcut, detectApple()) : "";
|
|
36
|
+
if (display === "icon") {
|
|
37
|
+
return (_jsx(ToolTip, { label: hint ? `${label} (${hint})` : label, placement: "bottom", children: _jsx(Box, { as: "button", type: "button", "data-testid": testId, onClick: onClick, "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : label, "aria-keyshortcuts": shortcut ? keyShortcutsFor(shortcut) : undefined, display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0, w: "36px", h: "36px", borderRadius: "10px", borderWidth: "1px", borderColor: colors.primary[100], bg: colors.primary[50], color: colors.accentText, cursor: "pointer", transition: transitionFor(["background-color", "border-color", "box-shadow"]), _hover: { borderColor: colors.primary[300] }, sx: { _focusVisible: ring, [FOCUS_VISIBLE_OVER_STATE]: ring, ...reducedMotionSx() }, children: _jsx(Icon, { size: 17, "aria-hidden": "true" }) }) }));
|
|
38
|
+
}
|
|
39
|
+
return (_jsxs(Box, { as: "button", type: "button", "data-testid": testId, onClick: onClick, "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-label": ariaLabel, "aria-keyshortcuts": shortcut ? keyShortcutsFor(shortcut) : undefined, display: "inline-flex", alignItems: "center", gap: 2, flexShrink: 0, h: "2.25rem", pl: "0.625rem", pr: "0.375rem", borderRadius: "10px", borderWidth: "1px", borderColor: colors.primary[100], bg: colors.primary[50], color: colors.accentText, fontSize: "0.84375rem", fontWeight: 600, lineHeight: 1, cursor: "pointer", transition: transitionFor(["background-color", "border-color", "box-shadow"]), _hover: { borderColor: colors.primary[300] }, sx: { _focusVisible: ring, [FOCUS_VISIBLE_OVER_STATE]: ring, ...reducedMotionSx() }, children: [_jsxs(Box, { as: "span", display: "inline-flex", alignItems: "center", gap: 2, "aria-hidden": ariaLabel ? true : undefined, children: [_jsx(Icon, { size: 17, "aria-hidden": "true" }), _jsx("span", { children: label })] }), hint && showHint && (_jsx(Box, { as: "kbd", "aria-hidden": "true", fontFamily: "inherit", fontSize: "0.6875rem", fontWeight: 600, lineHeight: "normal", px: "6px", py: "2px", borderRadius: "6px", borderWidth: "1px", borderColor: colors.primary[100], bg: colors.surfaceRaised, children: hint }))] }));
|
|
40
|
+
};
|
|
41
|
+
export default LauncherTrigger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Modal as ChakraModal, ModalOverlay, ModalContent, ModalHeader as ChakraModalHeader, ModalCloseButton, ModalBody as ChakraModalBody, ModalFooter as ChakraModalFooter, Flex, Spinner, Text, } from "@chakra-ui/react";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
|
+
import { warnDroppedSlotChildren } from "./warnDroppedSlotChildren.js";
|
|
5
6
|
export const ModalHeader = ({ children }) => {
|
|
6
7
|
return _jsx(_Fragment, { children: children });
|
|
7
8
|
};
|
|
@@ -27,12 +28,13 @@ const findSlot = (children, slot) => {
|
|
|
27
28
|
}
|
|
28
29
|
return undefined;
|
|
29
30
|
};
|
|
30
|
-
export default function Modal({ size, isOpen = false, onClose, overlaybg, overlaybackdropFilter, overlaybackdropInvert, overlaybackdropBlur, isCentered, finalFocusRef, blockScrollOnMount = true, initialFocusRef, closeOnOverlayClick = true, closeOnEsc = true, trapFocus = true, motionPreset = "scale", scrollBehavior = "outside", children, isLoading, title, subtitle, hideCloseButton, contentProps, }) {
|
|
31
|
+
export default function Modal({ size, isOpen = false, onClose, overlaybg, overlaybackdropFilter, overlaybackdropInvert, overlaybackdropBlur, isCentered, finalFocusRef, blockScrollOnMount = true, initialFocusRef, closeOnOverlayClick = true, closeOnEsc = true, trapFocus = true, motionPreset = "scale", scrollBehavior = "outside", children, isLoading, title, subtitle, hideCloseButton, contentProps, portalChildren, }) {
|
|
31
32
|
var _a, _b;
|
|
32
33
|
const { colors } = useCustomTheme();
|
|
33
34
|
const headerSlot = findSlot(children, ModalHeader);
|
|
34
35
|
const bodySlot = findSlot(children, ModalBody);
|
|
35
36
|
const footerSlot = findSlot(children, ModalFooter);
|
|
37
|
+
warnDroppedSlotChildren("Modal", children, [ModalHeader, ModalBody, ModalFooter]);
|
|
36
38
|
const headerContent = headerSlot !== null && headerSlot !== void 0 ? headerSlot : title;
|
|
37
|
-
return (_jsxs(ChakraModal, { isOpen: isOpen, onClose: onClose, size: size, isCentered: isCentered, finalFocusRef: finalFocusRef, blockScrollOnMount: blockScrollOnMount, initialFocusRef: initialFocusRef, closeOnOverlayClick: closeOnOverlayClick, closeOnEsc: closeOnEsc, trapFocus: trapFocus, motionPreset: motionPreset, scrollBehavior: scrollBehavior, children: [_jsx(ModalOverlay, { bg: overlaybg, backdropFilter: overlaybackdropFilter, backdropInvert: overlaybackdropInvert, backdropBlur: overlaybackdropBlur }), _jsxs(ModalContent, { "aria-busy": isLoading || undefined, ...contentProps, children: [(headerContent || subtitle) && (_jsxs(ChakraModalHeader, { ...((_a = headerSlot === null || headerSlot === void 0 ? void 0 : headerSlot.props) !== null && _a !== void 0 ? _a : {}), children: [headerContent, subtitle && (_jsx(Text, { as: "div", mt: 0.5, fontSize: "0.875rem", fontWeight: 400, color: colors.textMuted, children: subtitle }))] })), !hideCloseButton && _jsx(ModalCloseButton, {}), isLoading ? (_jsx(Flex, { role: "status", "aria-label": "Loading", justify: "center", align: "center", py: 16, children: _jsx(Spinner, { thickness: "4px", speed: "0.65s", emptyColor: colors.boxborder[200], color: colors.accentText, size: "xl" }) })) : (_jsxs(_Fragment, { children: [_jsx(ChakraModalBody, { ...((_b = bodySlot === null || bodySlot === void 0 ? void 0 : bodySlot.props) !== null && _b !== void 0 ? _b : {}), children: bodySlot }), footerSlot && (_jsx(ChakraModalFooter, { ...footerSlot.props, children: footerSlot }))] }))] })] }));
|
|
39
|
+
return (_jsxs(ChakraModal, { isOpen: isOpen, onClose: onClose, size: size, isCentered: isCentered, finalFocusRef: finalFocusRef, blockScrollOnMount: blockScrollOnMount, initialFocusRef: initialFocusRef, closeOnOverlayClick: closeOnOverlayClick, closeOnEsc: closeOnEsc, trapFocus: trapFocus, motionPreset: motionPreset, scrollBehavior: scrollBehavior, children: [_jsx(ModalOverlay, { bg: overlaybg, backdropFilter: overlaybackdropFilter, backdropInvert: overlaybackdropInvert, backdropBlur: overlaybackdropBlur }), _jsxs(ModalContent, { "aria-busy": isLoading || undefined, ...contentProps, children: [(headerContent || subtitle) && (_jsxs(ChakraModalHeader, { ...((_a = headerSlot === null || headerSlot === void 0 ? void 0 : headerSlot.props) !== null && _a !== void 0 ? _a : {}), children: [headerContent, subtitle && (_jsx(Text, { as: "div", mt: 0.5, fontSize: "0.875rem", fontWeight: 400, color: colors.textMuted, children: subtitle }))] })), !hideCloseButton && _jsx(ModalCloseButton, {}), isLoading ? (_jsx(Flex, { role: "status", "aria-label": "Loading", justify: "center", align: "center", py: 16, children: _jsx(Spinner, { thickness: "4px", speed: "0.65s", emptyColor: colors.boxborder[200], color: colors.accentText, size: "xl" }) })) : (_jsxs(_Fragment, { children: [_jsx(ChakraModalBody, { ...((_b = bodySlot === null || bodySlot === void 0 ? void 0 : bodySlot.props) !== null && _b !== void 0 ? _b : {}), children: bodySlot }), footerSlot && (_jsx(ChakraModalFooter, { ...footerSlot.props, children: footerSlot }))] })), portalChildren] })] }));
|
|
38
40
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
const warned = new Set();
|
|
3
|
+
const nameOf = (type) => {
|
|
4
|
+
if (typeof type === "string")
|
|
5
|
+
return type;
|
|
6
|
+
const fn = type;
|
|
7
|
+
return (fn === null || fn === void 0 ? void 0 : fn.displayName) || (fn === null || fn === void 0 ? void 0 : fn.name) || "Component";
|
|
8
|
+
};
|
|
9
|
+
const collect = (children, slots, dropped) => {
|
|
10
|
+
for (const child of React.Children.toArray(children)) {
|
|
11
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
12
|
+
if (String(child).trim())
|
|
13
|
+
dropped.set("#text", "text");
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (!React.isValidElement(child))
|
|
17
|
+
continue;
|
|
18
|
+
if (slots.includes(child.type))
|
|
19
|
+
continue;
|
|
20
|
+
if (child.type === React.Fragment) {
|
|
21
|
+
collect(child.props.children, slots, dropped);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
dropped.set(child.type, nameOf(child.type));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const warnDroppedSlotChildren = (owner, children, slots) => {
|
|
28
|
+
if (process.env.NODE_ENV === "production")
|
|
29
|
+
return;
|
|
30
|
+
const dropped = new Map();
|
|
31
|
+
collect(children, slots, dropped);
|
|
32
|
+
dropped.forEach((name, type) => {
|
|
33
|
+
if (warned.has(type))
|
|
34
|
+
return;
|
|
35
|
+
warned.add(type);
|
|
36
|
+
console.warn(`[pixelize-design-library] ${owner}: <${name}> is not a ${owner}Header/${owner}Body/${owner}Footer slot and was dropped. Pass nested dialogs and live regions through the portalChildren prop.`);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Flex, Heading, IconButton, Text } from "@chakra-ui/react";
|
|
3
|
+
import { Compass, Search as SearchIcon, X } from "lucide-react";
|
|
4
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
5
|
+
import { useMatchMedia } from "../../Hooks/useMatchMedia.js";
|
|
6
|
+
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
7
|
+
import { chartMode } from "../../Theme/tokens/builders/chartColorsFromTheme.js";
|
|
8
|
+
import { placeholderInk } from "../../Theme/tokens/builders/placeholderInk.js";
|
|
9
|
+
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
10
|
+
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
11
|
+
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
12
|
+
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
13
|
+
import { assignAppHues } from "../AppSwitcher/AppMark.js";
|
|
14
|
+
import Drawer, { DrawerBody, DrawerFooter, DrawerHeader, } from "../Drawer/Drawer.js";
|
|
15
|
+
import EmptyState from "../EmptyState/EmptyState.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";
|
|
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, WIDE_ROW, } from "./launcherParts.js";
|
|
22
|
+
import { searchLauncherSections } from "./match.js";
|
|
23
|
+
import NewTabLink from "./NewTabLink.js";
|
|
24
|
+
import PinToggle from "./PinToggle.js";
|
|
25
|
+
const NO_APPS = [];
|
|
26
|
+
const MD_QUERY = "(min-width: 48em)";
|
|
27
|
+
const XL_QUERY = "(min-width: 80em)";
|
|
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];
|
|
34
|
+
const DEFAULT_LABELS = {
|
|
35
|
+
title: "Menu",
|
|
36
|
+
searchPlaceholder: "Search menus and screens",
|
|
37
|
+
clearSearch: "Clear search",
|
|
38
|
+
close: "Close menu",
|
|
39
|
+
pinned: "Pinned",
|
|
40
|
+
pinnedEmpty: "Pin the screens you use most. Pins follow your account.",
|
|
41
|
+
frequent: "Frequently visited",
|
|
42
|
+
recent: "Recent",
|
|
43
|
+
screensGroup: "Screens",
|
|
44
|
+
actionsGroup: "Actions",
|
|
45
|
+
pin: (label) => `Pin ${label}`,
|
|
46
|
+
unpin: (label) => `Unpin ${label}`,
|
|
47
|
+
openInNewTab: (label) => `Open ${label} in a new tab`,
|
|
48
|
+
noResults: (query) => `Nothing called “${query}”`,
|
|
49
|
+
noResultsHint: "Try a module name, or another word for it.",
|
|
50
|
+
searching: "Searching…",
|
|
51
|
+
loading: "Loading menu",
|
|
52
|
+
empty: "Nothing to show yet",
|
|
53
|
+
hintMove: "move",
|
|
54
|
+
hintOpen: "open here",
|
|
55
|
+
hintNewTab: "new tab",
|
|
56
|
+
hintPin: "pin",
|
|
57
|
+
hintClose: "close",
|
|
58
|
+
hintOpenMenu: "open",
|
|
59
|
+
apps: "Your apps",
|
|
60
|
+
found: (count) => `${count} found`,
|
|
61
|
+
pinTip: "Pin to quick access",
|
|
62
|
+
unpinTip: "Pinned — click to unpin",
|
|
63
|
+
quickAccess: "Quick access",
|
|
64
|
+
newBadge: "New",
|
|
65
|
+
screens: "screens",
|
|
66
|
+
pinShort: "Pin",
|
|
67
|
+
footerNote: "Pins follow your account",
|
|
68
|
+
suggestionsHint: "Try one of these",
|
|
69
|
+
};
|
|
70
|
+
const visibleSections = (sections) => sections
|
|
71
|
+
.map((section) => ({
|
|
72
|
+
...section,
|
|
73
|
+
modules: section.modules.filter((m) => m.screens.length > 0),
|
|
74
|
+
}))
|
|
75
|
+
.filter((section) => section.modules.length > 0);
|
|
76
|
+
const indexScreens = (sections) => {
|
|
77
|
+
const map = new Map();
|
|
78
|
+
for (const section of sections) {
|
|
79
|
+
for (const module of section.modules) {
|
|
80
|
+
for (const screen of module.screens)
|
|
81
|
+
if (!map.has(screen.id))
|
|
82
|
+
map.set(screen.id, { screen, module });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return map;
|
|
86
|
+
};
|
|
87
|
+
const GRID_COLUMNS = {
|
|
88
|
+
base: "minmax(0, 1fr)",
|
|
89
|
+
md: "repeat(2, minmax(0, 1fr))",
|
|
90
|
+
xl: "repeat(3, minmax(0, 1fr))",
|
|
91
|
+
};
|
|
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 }));
|
|
94
|
+
}
|
|
95
|
+
function Pane({ children }) {
|
|
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 }));
|
|
97
|
+
}
|
|
98
|
+
function Rail({ label, children }) {
|
|
99
|
+
const { colors } = useCustomTheme();
|
|
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 }));
|
|
101
|
+
}
|
|
102
|
+
function SkeletonLayout({ label }) {
|
|
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))) })] }));
|
|
104
|
+
}
|
|
105
|
+
function SearchField({ inputRef, value, onChange, onKeyDown, labels, hint, listboxId, activeId, isExpanded, hasResults, }) {
|
|
106
|
+
const { colors } = useCustomTheme();
|
|
107
|
+
return (_jsxs(Flex, { flex: 1, maxW: "520px", h: "38px", align: "center", gap: "10px", pl: "12px", pr: "8px", borderRadius: "10px", 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: 16, strokeWidth: 2.2, "aria-hidden": true }) }), _jsx(Box, { as: "input", ref: inputRef, value: value, onChange: (event) => onChange(event.target.value), onKeyDown: onKeyDown, placeholder: labels.searchPlaceholder, "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: "34px", border: 0, outline: "none", bg: "transparent", fontSize: "14.5px", color: colors.text[900], _placeholder: { color: placeholderInk(colors), opacity: 1 } }), value ? (_jsx(Box, { as: "button", type: "button", "aria-label": labels.clearSearch, onClick: () => {
|
|
108
|
+
var _a;
|
|
109
|
+
onChange("");
|
|
110
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
111
|
+
}, 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] }));
|
|
112
|
+
}
|
|
113
|
+
function SearchRow({ item, query, isActive, link, labels, optionId, isPinned, canPin, onPin, onOpen, onHover, }) {
|
|
114
|
+
const { colors } = useCustomTheme();
|
|
115
|
+
const isScreen = item.kind === "screen";
|
|
116
|
+
const hasStar = Boolean(item.screenId) && canPin;
|
|
117
|
+
const base = item.badge ? 24 : 0;
|
|
118
|
+
const open = base + (hasStar ? 46 : item.href ? 24 : 0);
|
|
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] }) }));
|
|
135
|
+
}
|
|
136
|
+
/** Left-drawer navigation launcher: browse every module, pins, Frequent, Recent, search and (compact) the suite's apps. */
|
|
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, }) {
|
|
138
|
+
const theme = useCustomTheme();
|
|
139
|
+
const { colors } = theme;
|
|
140
|
+
const inputRef = useRef(null);
|
|
141
|
+
const bodyRef = useRef(null);
|
|
142
|
+
const baseId = useId();
|
|
143
|
+
const isDesktop = useMatchMedia(MD_QUERY, true);
|
|
144
|
+
const isWide = useMatchMedia(XL_QUERY, false);
|
|
145
|
+
const columns = isWide ? 3 : isDesktop ? 2 : 1;
|
|
146
|
+
const [innerQuery, setInnerQuery] = useState("");
|
|
147
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
148
|
+
const labels = useMemo(() => ({ ...DEFAULT_LABELS, ...labelOverrides }), [labelOverrides]);
|
|
149
|
+
const isControlled = controlledQuery !== undefined;
|
|
150
|
+
const query = isControlled ? controlledQuery : innerQuery;
|
|
151
|
+
const setQuery = useCallback((next) => {
|
|
152
|
+
if (!isControlled)
|
|
153
|
+
setInnerQuery(next);
|
|
154
|
+
onQueryChange === null || onQueryChange === void 0 ? void 0 : onQueryChange(next);
|
|
155
|
+
}, [isControlled, onQueryChange]);
|
|
156
|
+
const latest = useRef({ query, setQuery });
|
|
157
|
+
latest.current = { query, setQuery };
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (!isOpen && latest.current.query !== "")
|
|
160
|
+
latest.current.setQuery("");
|
|
161
|
+
}, [isOpen]);
|
|
162
|
+
useEffect(() => setActiveIndex(0), [query]);
|
|
163
|
+
const sections = useMemo(() => visibleSections(rawSections), [rawSections]);
|
|
164
|
+
const byId = useMemo(() => indexScreens(sections), [sections]);
|
|
165
|
+
const pinned = useMemo(() => new Set(pinnedIds), [pinnedIds]);
|
|
166
|
+
const pinnedItems = useMemo(() => pinnedIds.flatMap((id) => { var _a; return (_a = byId.get(id)) !== null && _a !== void 0 ? _a : []; }), [pinnedIds, byId]);
|
|
167
|
+
const frequentItems = useMemo(() => frequentIds.flatMap((id) => { var _a; return (_a = byId.get(id)) !== null && _a !== void 0 ? _a : []; }), [frequentIds, byId]);
|
|
168
|
+
const recentItems = useMemo(() => recentIds.flatMap((id) => { var _a; return (_a = byId.get(id)) !== null && _a !== void 0 ? _a : []; }), [recentIds, byId]);
|
|
169
|
+
const found = useMemo(() => searchLauncherSections({
|
|
170
|
+
query,
|
|
171
|
+
sections,
|
|
172
|
+
actions,
|
|
173
|
+
extraResults,
|
|
174
|
+
actionsLabel: labels.actionsGroup,
|
|
175
|
+
}), [query, sections, actions, extraResults, labels.actionsGroup]);
|
|
176
|
+
const groups = useMemo(() => [
|
|
177
|
+
...found.sections.map((s) => ({
|
|
178
|
+
id: `section:${s.id}`,
|
|
179
|
+
label: s.label,
|
|
180
|
+
meta: labels.found(s.items.length),
|
|
181
|
+
items: s.items,
|
|
182
|
+
})),
|
|
183
|
+
...found.groups,
|
|
184
|
+
], [found, labels]);
|
|
185
|
+
const results = useMemo(() => groups.flatMap((g) => g.items), [groups]);
|
|
186
|
+
const groupStarts = useMemo(() => groups.map((_, i) => groups.slice(0, i).reduce((n, g) => n + g.items.length, 0)), [groups]);
|
|
187
|
+
const isSearchView = query.trim().length > 0;
|
|
188
|
+
const active = Math.min(activeIndex, Math.max(results.length - 1, 0));
|
|
189
|
+
const link = useMemo(() => ({
|
|
190
|
+
linkAs,
|
|
191
|
+
onPlainClick: (event) => {
|
|
192
|
+
if (isPlainClick(event))
|
|
193
|
+
onClose();
|
|
194
|
+
},
|
|
195
|
+
}), [linkAs, onClose]);
|
|
196
|
+
const open = useCallback((item, newTab) => {
|
|
197
|
+
if (item.run) {
|
|
198
|
+
onClose();
|
|
199
|
+
item.run();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (!item.href)
|
|
203
|
+
return;
|
|
204
|
+
if (!newTab)
|
|
205
|
+
onClose();
|
|
206
|
+
onNavigate(item.href, { newTab });
|
|
207
|
+
}, [onClose, onNavigate]);
|
|
208
|
+
const moveFocus = (delta) => {
|
|
209
|
+
var _a, _b, _c;
|
|
210
|
+
const items = Array.from((_b = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(ITEM_SELECTOR)) !== null && _b !== void 0 ? _b : []);
|
|
211
|
+
if (items.length === 0)
|
|
212
|
+
return;
|
|
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
|
+
}
|
|
218
|
+
const next = delta === "first"
|
|
219
|
+
? 0
|
|
220
|
+
: delta === "last"
|
|
221
|
+
? items.length - 1
|
|
222
|
+
: Math.min(items.length - 1, current + delta);
|
|
223
|
+
items[next].focus();
|
|
224
|
+
};
|
|
225
|
+
const onInputKeyDown = (event) => {
|
|
226
|
+
if (!isSearchView) {
|
|
227
|
+
if (event.key === "ArrowDown") {
|
|
228
|
+
event.preventDefault();
|
|
229
|
+
moveFocus("first");
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (results.length === 0)
|
|
234
|
+
return;
|
|
235
|
+
if (event.key === "ArrowDown") {
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
setActiveIndex((active + 1) % results.length);
|
|
238
|
+
}
|
|
239
|
+
else if (event.key === "ArrowUp") {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
setActiveIndex((active - 1 + results.length) % results.length);
|
|
242
|
+
}
|
|
243
|
+
else if (event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
open(results[active], event.metaKey || event.ctrlKey);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
const moveInGrid = (event, cell) => {
|
|
249
|
+
var _a, _b, _c, _d;
|
|
250
|
+
const grid = cell.closest("[data-nav-grid]");
|
|
251
|
+
const cells = Array.from((_a = grid === null || grid === void 0 ? void 0 : grid.querySelectorAll(CELL_SELECTOR)) !== null && _a !== void 0 ? _a : []);
|
|
252
|
+
const index = cells.indexOf(cell);
|
|
253
|
+
const focusCell = (target) => { var _a; return (_a = target === null || target === void 0 ? void 0 : target.querySelector(ITEM_SELECTOR)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
254
|
+
if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
255
|
+
focusCell(cells[index + (event.key === "ArrowRight" ? 1 : -1)]);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const down = event.key === "ArrowDown";
|
|
259
|
+
const columns = Number(grid === null || grid === void 0 ? void 0 : grid.dataset.navColumns);
|
|
260
|
+
const within = cells[index + (down ? columns : -columns)];
|
|
261
|
+
if (within)
|
|
262
|
+
return focusCell(within);
|
|
263
|
+
const hasRowAfter = down &&
|
|
264
|
+
Math.floor(index / columns) < Math.floor((cells.length - 1) / columns);
|
|
265
|
+
if (hasRowAfter)
|
|
266
|
+
return focusCell(cells[cells.length - 1]);
|
|
267
|
+
const grids = Array.from((_c = (_b = bodyRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll("[data-nav-grid]")) !== null && _c !== void 0 ? _c : []);
|
|
268
|
+
const neighbour = grids[grids.indexOf(grid) + (down ? 1 : -1)];
|
|
269
|
+
const neighbourCells = Array.from((_d = neighbour === null || neighbour === void 0 ? void 0 : neighbour.querySelectorAll(CELL_SELECTOR)) !== null && _d !== void 0 ? _d : []);
|
|
270
|
+
if (neighbourCells.length === 0)
|
|
271
|
+
return moveFocus(down ? 1 : -1);
|
|
272
|
+
const column = index % columns;
|
|
273
|
+
const row = down ? 0 : Math.floor((neighbourCells.length - 1) / columns);
|
|
274
|
+
focusCell(neighbourCells[Math.min(neighbourCells.length - 1, row * columns + column)]);
|
|
275
|
+
};
|
|
276
|
+
const pinFromKeyboard = (event) => {
|
|
277
|
+
var _a, _b;
|
|
278
|
+
const target = event.target;
|
|
279
|
+
const pinId = target.matches(ITEM_SELECTOR)
|
|
280
|
+
? target.getAttribute("data-pin-id")
|
|
281
|
+
: null;
|
|
282
|
+
if (!pinId || !onTogglePin)
|
|
283
|
+
return false;
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
const before = Array.from((_b = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(ITEM_SELECTOR)) !== null && _b !== void 0 ? _b : []);
|
|
286
|
+
const position = before.indexOf(target);
|
|
287
|
+
onTogglePin(pinId);
|
|
288
|
+
setTimeout(() => {
|
|
289
|
+
var _a, _b, _c;
|
|
290
|
+
if ((_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement))
|
|
291
|
+
return;
|
|
292
|
+
const after = (_b = bodyRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(ITEM_SELECTOR);
|
|
293
|
+
(_c = after === null || after === void 0 ? void 0 : after[Math.min(position, after.length - 1)]) === null || _c === void 0 ? void 0 : _c.focus();
|
|
294
|
+
}, 0);
|
|
295
|
+
return true;
|
|
296
|
+
};
|
|
297
|
+
const onBodyKeyDown = (event) => {
|
|
298
|
+
var _a, _b;
|
|
299
|
+
if (event.target === inputRef.current)
|
|
300
|
+
return;
|
|
301
|
+
const isArrow = event.key.startsWith("Arrow");
|
|
302
|
+
const cell = event.target.closest(CELL_SELECTOR);
|
|
303
|
+
if (isArrow && cell && !event.altKey && !event.metaKey && !event.ctrlKey) {
|
|
304
|
+
event.preventDefault();
|
|
305
|
+
moveInGrid(event, cell);
|
|
306
|
+
}
|
|
307
|
+
else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
308
|
+
event.preventDefault();
|
|
309
|
+
moveFocus(event.key === "ArrowDown" ? 1 : -1);
|
|
310
|
+
}
|
|
311
|
+
else if (event.key === "Home" || event.key === "End") {
|
|
312
|
+
event.preventDefault();
|
|
313
|
+
moveFocus(event.key === "Home" ? "first" : "last");
|
|
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
|
+
}
|
|
320
|
+
else if (event.key.length === 1 &&
|
|
321
|
+
!event.metaKey &&
|
|
322
|
+
!event.ctrlKey &&
|
|
323
|
+
!event.altKey &&
|
|
324
|
+
event.key !== " ") {
|
|
325
|
+
if ((event.key === "p" || event.key === "P") && pinFromKeyboard(event))
|
|
326
|
+
return;
|
|
327
|
+
event.preventDefault();
|
|
328
|
+
setQuery(query + event.key);
|
|
329
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
var _a, _b, _c;
|
|
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" });
|
|
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]);
|
|
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]);
|
|
365
|
+
const hues = useMemo(() => assignAppHues(appList, chartMode(colors)), [appList, colors]);
|
|
366
|
+
const showApps = appList.some((app) => app.id !== currentAppId) &&
|
|
367
|
+
(appsVisibility === "always" || !isDesktop);
|
|
368
|
+
const handleAppSelect = (app, event) => {
|
|
369
|
+
onAppSelect === null || onAppSelect === void 0 ? void 0 : onAppSelect(app, event);
|
|
370
|
+
if (!event.defaultPrevented)
|
|
371
|
+
onClose();
|
|
372
|
+
};
|
|
373
|
+
const appsBlock = showApps ? (_jsx(AppsSection, { apps: appList, hues: hues, currentAppId: currentAppId, heading: labels.apps, onSelect: handleAppSelect })) : null;
|
|
374
|
+
const listboxId = `${baseId}-results`;
|
|
375
|
+
const optionId = (index) => `${baseId}-opt-${index}`;
|
|
376
|
+
const togglePinFor = (id) => onTogglePin ? () => onTogglePin(id) : undefined;
|
|
377
|
+
const hasResults = results.length > 0;
|
|
378
|
+
const trimmed = query.trim();
|
|
379
|
+
const railFrequent = frequentItems
|
|
380
|
+
.filter(({ screen }) => !pinned.has(screen.id))
|
|
381
|
+
.slice(0, frequentLimit);
|
|
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) => {
|
|
384
|
+
const pinId = module.screens[0].id;
|
|
385
|
+
return (_jsx(ModuleRow, { module: module, keyScreens: module.screens
|
|
386
|
+
.filter((s) => s.isKey && s.href !== module.href)
|
|
387
|
+
.slice(0, keyScreenLimit), isPinned: pinned.has(pinId), onTogglePin: togglePinFor(pinId), pinId: pinId, labels: labels, link: link }, module.id));
|
|
388
|
+
}) })] }, section.id))));
|
|
389
|
+
const pickSuggestion = (value) => {
|
|
390
|
+
var _a;
|
|
391
|
+
setQuery(value);
|
|
392
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
393
|
+
};
|
|
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)
|
|
395
|
+
? labels.suggestionsHint
|
|
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] }));
|
|
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) => {
|
|
398
|
+
const index = groupStarts[groupIndex] + itemIndex;
|
|
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));
|
|
400
|
+
}) })] }, group.id))) })) : (noResults);
|
|
401
|
+
const body = isLoading ? (_jsx(SkeletonLayout, { label: labels.loading })) : (_jsxs(_Fragment, { children: [_jsx(Pane, { children: isSearchView ? searchPane : browsePane }), rail] }));
|
|
402
|
+
const pill = resolveFilledSurface(colors.primary, colors);
|
|
403
|
+
return (_jsxs(Drawer, { isOpen: isOpen, onClose: onClose, placement: "left", size: "full", initialFocusRef: inputRef, hideCloseButton: true, contentProps: {
|
|
404
|
+
maxW: { base: "100vw", lg: `min(${maxWidth}, calc(100vw - 56px))` },
|
|
405
|
+
h: { base: "100%", lg: "auto" },
|
|
406
|
+
maxH: "100%",
|
|
407
|
+
bg: colors.surfaceRaised,
|
|
408
|
+
borderBottomRightRadius: { base: 0, lg: "16px" },
|
|
409
|
+
boxShadow: colors.boxShadow.default,
|
|
410
|
+
overflow: "hidden",
|
|
411
|
+
...{ "data-testid": testId },
|
|
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 })] })] }));
|
|
413
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@chakra-ui/react";
|
|
3
|
+
import { ArrowUpRight } from "lucide-react";
|
|
4
|
+
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
5
|
+
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
6
|
+
import { revealStyles } from "./revealStyles.js";
|
|
7
|
+
/** "Open in a new tab" anchor; visible on row hover, focus-within or its own focus only. */
|
|
8
|
+
export default function NewTabLink({ href, label, linkAs = "a", tabIndex }) {
|
|
9
|
+
const { colors } = useCustomTheme();
|
|
10
|
+
return (_jsx(Box, { as: linkAs, href: href, target: "_blank", rel: "noopener noreferrer", "aria-label": label, title: label, tabIndex: tabIndex, display: "inline-flex", alignItems: "center", justifyContent: "center", w: "22px", h: "22px", flexShrink: 0, borderRadius: "md", color: colors.textMuted, opacity: 0, transition: transitionFor(["opacity", "background-color"]), sx: revealStyles(colors), _hover: { bg: colors.backgroundColor.subtle }, children: _jsx(ArrowUpRight, { size: 13, "aria-hidden": true }) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IconButton } from "@chakra-ui/react";
|
|
3
|
+
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
4
|
+
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
|
+
import { revealStyles } from "./revealStyles.js";
|
|
6
|
+
const STAR = "M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01z";
|
|
7
|
+
function Star({ filled, size }) {
|
|
8
|
+
return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: filled ? "currentColor" : "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinejoin: "round", "aria-hidden": true, children: _jsx("path", { d: STAR }) }));
|
|
9
|
+
}
|
|
10
|
+
/** Star toggle: outline when unpinned, filled in the accent when pinned; appears on row hover or focus and never follows the row link. */
|
|
11
|
+
export default function PinToggle({ isPinned, label, onToggle, title, size = 13, tabIndex }) {
|
|
12
|
+
const { colors } = useCustomTheme();
|
|
13
|
+
return (_jsx(IconButton, { "aria-label": label, "aria-pressed": isPinned, title: title !== null && title !== void 0 ? title : label, icon: _jsx(Star, { filled: isPinned, size: size }), variant: "ghost", minW: "22px", w: "22px", h: "22px", borderRadius: "md", tabIndex: tabIndex, color: isPinned ? colors.accentText : colors.textMuted, opacity: 0, transition: transitionFor(["opacity", "background-color"]), sx: revealStyles(colors), onClick: (event) => {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
onToggle();
|
|
17
|
+
} }));
|
|
18
|
+
}
|