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,187 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Flex, Heading, Text } from "@chakra-ui/react";
|
|
3
|
+
import { Lock, Star } from "lucide-react";
|
|
4
|
+
import { Fragment, } from "react";
|
|
5
|
+
import { FOCUS_VISIBLE_OVER_STATE, focusVisibleStyles, } from "../../Theme/chakra/focusRing.styles.js";
|
|
6
|
+
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
7
|
+
import { AA_NON_TEXT, liftToContrast, } from "../../Theme/tokens/builders/outlineRung.js";
|
|
8
|
+
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
9
|
+
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
10
|
+
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
11
|
+
import OverflowToolTip from "../ToolTip/OverflowToolTip.js";
|
|
12
|
+
import AppMark from "../AppSwitcher/AppMark.js";
|
|
13
|
+
import { highlightSegments } from "./match.js";
|
|
14
|
+
import NewTabLink from "./NewTabLink.js";
|
|
15
|
+
import PinToggle from "./PinToggle.js";
|
|
16
|
+
import { revealStyles } from "./revealStyles.js";
|
|
17
|
+
export const ITEM_SELECTOR = "[data-launcher-item]";
|
|
18
|
+
export const isPlainClick = (event) => event.button === 0 &&
|
|
19
|
+
!event.metaKey &&
|
|
20
|
+
!event.ctrlKey &&
|
|
21
|
+
!event.shiftKey &&
|
|
22
|
+
!event.altKey;
|
|
23
|
+
const ROW_FOCUS = "data-row-focus";
|
|
24
|
+
const ROW_PR = "--row-pr";
|
|
25
|
+
const REVEALED = "[data-group]:hover &, [data-group]:focus-within &, [data-group][data-reveal=true] &";
|
|
26
|
+
const NARROW_ROW = "@container launcher-row (max-width: 219px)";
|
|
27
|
+
export const WIDE_ROW = "@container launcher-row (min-width: 300px)";
|
|
28
|
+
export const ROW_CONTAINER = {
|
|
29
|
+
containerType: "inline-size",
|
|
30
|
+
containerName: "launcher-row",
|
|
31
|
+
};
|
|
32
|
+
export const activeRowStyle = (colors) => {
|
|
33
|
+
const fill = listRowBackgrounds(colors).active;
|
|
34
|
+
const edge = liftToContrast(liftToContrast(colors.primary[500], fill, AA_NON_TEXT), colors.surfaceRaised, AA_NON_TEXT);
|
|
35
|
+
return { edge, fill };
|
|
36
|
+
};
|
|
37
|
+
export const activeRowSurface = (colors) => {
|
|
38
|
+
const { edge, fill } = activeRowStyle(colors);
|
|
39
|
+
return {
|
|
40
|
+
backgroundColor: fill,
|
|
41
|
+
boxShadow: `inset 0 0 0 1px ${edge}`,
|
|
42
|
+
outline: "2px solid transparent",
|
|
43
|
+
outlineOffset: "-2px",
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const titleInset = (base, open, chip = 0) => ({
|
|
47
|
+
paddingRight: `var(${ROW_PR})`,
|
|
48
|
+
[ROW_PR]: `${base}px`,
|
|
49
|
+
[REVEALED]: { [ROW_PR]: `${open}px` },
|
|
50
|
+
...(chip
|
|
51
|
+
? {
|
|
52
|
+
[WIDE_ROW]: {
|
|
53
|
+
"[data-group][data-reveal=true] &": { [ROW_PR]: `${open + chip}px` },
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
[NARROW_ROW]: { [REVEALED]: { [ROW_PR]: `${base}px` } },
|
|
58
|
+
});
|
|
59
|
+
const markRowFocus = (event, isOn) => { var _a; return (_a = event.currentTarget.closest("[data-group]")) === null || _a === void 0 ? void 0 : _a.toggleAttribute(ROW_FOCUS, isOn); };
|
|
60
|
+
export const useRowFocus = (isBordered = false) => {
|
|
61
|
+
const { colors } = useCustomTheme();
|
|
62
|
+
const { edge, fill } = activeRowStyle(colors);
|
|
63
|
+
const lit = isBordered
|
|
64
|
+
? { backgroundColor: fill, borderColor: edge }
|
|
65
|
+
: activeRowSurface(colors);
|
|
66
|
+
return {
|
|
67
|
+
sx: { [`&[${ROW_FOCUS}]`]: lit },
|
|
68
|
+
primary: {
|
|
69
|
+
onFocus: (event) => markRowFocus(event, event.currentTarget.matches(":focus-visible")),
|
|
70
|
+
onBlur: (event) => markRowFocus(event, false),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export const stretchedLink = (radius) => ({
|
|
75
|
+
outline: "none",
|
|
76
|
+
_after: {
|
|
77
|
+
content: '""',
|
|
78
|
+
position: "absolute",
|
|
79
|
+
inset: 0,
|
|
80
|
+
borderRadius: radius,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
export const useRowHover = () => {
|
|
84
|
+
const { colors } = useCustomTheme();
|
|
85
|
+
const hover = listRowBackgrounds(colors).active;
|
|
86
|
+
return { bg: hover, _hover: { bg: hover }, _focusWithin: { bg: hover } };
|
|
87
|
+
};
|
|
88
|
+
export function CountBadge({ value, size = "row" }) {
|
|
89
|
+
const { colors } = useCustomTheme();
|
|
90
|
+
if (value === undefined || value === 0 || value === "")
|
|
91
|
+
return null;
|
|
92
|
+
const fill = resolveFilledSurface(colors.primary, colors);
|
|
93
|
+
const isRow = size === "row";
|
|
94
|
+
return (_jsx(Box, { as: "span", flexShrink: 0, minW: isRow ? "20px" : undefined, h: isRow ? "18px" : "17px", px: "6px", mr: isRow ? "2px" : 0, borderRadius: "full", bg: fill.fill, color: fill.color, fontSize: isRow ? "10.5px" : "10px", fontWeight: 700, display: "inline-flex", alignItems: "center", justifyContent: "center", sx: { fontVariantNumeric: "tabular-nums" }, children: value }));
|
|
95
|
+
}
|
|
96
|
+
export function NewTag({ label }) {
|
|
97
|
+
const { colors } = useCustomTheme();
|
|
98
|
+
return (_jsx(Box, { as: "span", flexShrink: 0, fontSize: "10px", fontWeight: 600, letterSpacing: "0.02em", color: colors.accentText, opacity: 0.85, children: label }));
|
|
99
|
+
}
|
|
100
|
+
export function SectionHeader({ label, meta, isDecorative = false, isRail = false, hasCount = true, }) {
|
|
101
|
+
const { colors } = useCustomTheme();
|
|
102
|
+
return (_jsxs(Flex, { align: "baseline", gap: "6px", px: isRail ? "4px" : "8px", pb: "5px", mb: hasCount ? 0 : "2px", borderBottomWidth: "1px", borderColor: colors.boxborder[200], "aria-hidden": isDecorative || undefined, children: [_jsx(Heading, { as: isDecorative ? "div" : "h2", m: 0, fontSize: "12.5px", fontWeight: 600, letterSpacing: "-0.003em", color: colors.text[900], children: label }), meta ? (_jsx(Text, { as: "span", fontSize: "11.5px", color: colors.textMuted, sx: { fontVariantNumeric: "tabular-nums" }, children: meta })) : null] }));
|
|
103
|
+
}
|
|
104
|
+
export function RowIcon({ icon: Icon, size, stroke = 1.75, mt }) {
|
|
105
|
+
const { colors } = useCustomTheme();
|
|
106
|
+
if (!Icon)
|
|
107
|
+
return null;
|
|
108
|
+
return (_jsx(Box, { as: "span", color: colors.textMuted, display: "inline-flex", flexShrink: 0, mt: mt, transition: transitionFor(["color"]), _groupHover: { color: colors.accentText }, _groupFocusWithin: { color: colors.accentText }, sx: { "[data-reveal=true] &": { color: colors.accentText } }, children: _jsx(Icon, { size: size, strokeWidth: stroke, "aria-hidden": true }) }));
|
|
109
|
+
}
|
|
110
|
+
export function Highlight({ text, query }) {
|
|
111
|
+
const { colors } = useCustomTheme();
|
|
112
|
+
return (_jsx(_Fragment, { children: highlightSegments(text, query).map((segment, i) => segment.isMatch ? (_jsx(Box, { as: "mark", bg: "transparent", color: "inherit", fontWeight: 650, textDecoration: "underline", textDecorationColor: colors.primary.opacity[48], textDecorationThickness: "1.5px", textUnderlineOffset: "2px", children: segment.text }, i)) : (_jsx(Fragment, { children: segment.text }, i))) }));
|
|
113
|
+
}
|
|
114
|
+
export function RowActions({ children }) {
|
|
115
|
+
const { colors } = useCustomTheme();
|
|
116
|
+
const revealed = REVEALED.replace(/ &/g, " > &");
|
|
117
|
+
return (_jsx(Flex, { sx: {
|
|
118
|
+
[NARROW_ROW]: {
|
|
119
|
+
[revealed]: {
|
|
120
|
+
backgroundColor: activeRowStyle(colors).fill,
|
|
121
|
+
borderRadius: "6px",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
}, position: "absolute", top: "7px", right: "4px", h: "19px", align: "center", gap: "2px", zIndex: 1, children: children }));
|
|
125
|
+
}
|
|
126
|
+
export function RowTip({ text }) {
|
|
127
|
+
const { colors } = useCustomTheme();
|
|
128
|
+
return (_jsx(Box, { role: "tooltip", position: "absolute", right: "20px", top: "-26px", zIndex: 2, px: "8px", py: "3px", borderRadius: "6px", fontSize: "11px", fontWeight: 600, whiteSpace: "nowrap", bg: colors.text[900], color: colors.surfaceRaised, visibility: "hidden", pointerEvents: "none", _groupHover: { visibility: "visible" }, children: text }));
|
|
129
|
+
}
|
|
130
|
+
export function ModuleRow({ module, keyScreens, isPinned, onTogglePin, pinId, labels, link, }) {
|
|
131
|
+
const { colors } = useCustomTheme();
|
|
132
|
+
const hover = useRowHover();
|
|
133
|
+
const focus = useRowFocus();
|
|
134
|
+
const ring = focusVisibleStyles(colors);
|
|
135
|
+
const base = typeof module.badge === "number" || module.badge ? 24 : 0;
|
|
136
|
+
const open = base + (onTogglePin ? 46 : 24);
|
|
137
|
+
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "flex-start", gap: "10px", minH: "34px", pl: "8px", pr: "4px", pt: "7px", pb: "5px", borderRadius: "8px", transition: transitionFor(["background-color"]), _hover: hover._hover, _focusWithin: hover._focusWithin, sx: { ...focus.sx, ...ROW_CONTAINER }, children: [_jsx(RowIcon, { icon: module.icon, size: 16, mt: "2px" }), _jsxs(Flex, { direction: "column", flex: 1, minW: 0, children: [_jsxs(Flex, { align: "center", gap: "6px", h: "19px", minW: 0, sx: titleInset(base, open), children: [_jsx(OverflowToolTip, { label: module.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: module.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": onTogglePin ? pinId : undefined, onClick: link.onPlainClick, minW: 0, fontSize: "13.5px", fontWeight: 500, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("8px"), children: module.label }) }), module.isNew ? _jsx(NewTag, { label: labels.newBadge }) : null] }), keyScreens.length ? (_jsx(OverflowToolTip, { label: keyScreens.map((screen) => screen.label).join(" · "), placement: "bottom-start", children: _jsx(Box, { role: "group", "aria-label": `${module.label} ${labels.screens}`, position: "relative", zIndex: 1, w: "fit-content", maxW: "100%", fontSize: "11.5px", lineHeight: "15px", color: colors.textMuted, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", children: keyScreens.map((screen, i) => (_jsxs(Fragment, { children: [i > 0 ? (_jsx(Box, { as: "span", "aria-hidden": true, mx: "5px", opacity: 0.7, children: "\u00B7" })) : null, _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, onClick: link.onPlainClick, color: "inherit", borderRadius: "sm", position: "relative", zIndex: 1, _hover: {
|
|
138
|
+
textDecoration: "underline",
|
|
139
|
+
textUnderlineOffset: "2px",
|
|
140
|
+
}, sx: ring, children: screen.label })] }, screen.id))) }) })) : null] }), _jsxs(RowActions, { children: [_jsx(CountBadge, { value: module.badge }), onTogglePin ? (_jsx(PinToggle, { isPinned: isPinned, label: isPinned ? labels.unpin(module.label) : labels.pin(module.label), title: "", onToggle: onTogglePin })) : null, _jsx(NewTabLink, { href: module.href, label: labels.openInNewTab(module.label), linkAs: link.linkAs })] }), onTogglePin ? (_jsx(RowTip, { text: isPinned ? labels.unpinTip : labels.pinTip })) : null] }));
|
|
141
|
+
}
|
|
142
|
+
export function RailRow({ screen, module, link, isStrong = false, trailing, pinId, }) {
|
|
143
|
+
var _a;
|
|
144
|
+
const { colors } = useCustomTheme();
|
|
145
|
+
const hover = useRowHover();
|
|
146
|
+
const focus = useRowFocus();
|
|
147
|
+
return (_jsxs(Flex, { "data-group": true, position: "relative", align: "center", gap: "10px", h: "32px", pl: "8px", pr: "4px", borderRadius: "8px", transition: transitionFor(["background-color"]), _hover: hover._hover, _focusWithin: hover._focusWithin, sx: focus.sx, children: [_jsx(RowIcon, { icon: (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon, size: 15 }), _jsx(OverflowToolTip, { label: screen.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": pinId, onClick: link.onPlainClick, flex: 1, minW: 0, fontSize: "13px", fontWeight: isStrong ? 500 : 400, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("8px"), children: screen.label }) }), _jsx(Flex, { position: "relative", zIndex: 1, align: "center", gap: "2px", children: trailing })] }));
|
|
148
|
+
}
|
|
149
|
+
export function PinTextButton({ label, text, onToggle }) {
|
|
150
|
+
const { colors } = useCustomTheme();
|
|
151
|
+
return (_jsxs(Box, { as: "button", type: "button", "aria-label": label, flexShrink: 0, h: "22px", px: "7px", display: "inline-flex", alignItems: "center", gap: "4px", borderRadius: "6px", borderWidth: "1px", borderColor: colors.boxborder[200], bg: colors.surfaceRaised, color: colors.text[700], fontSize: "11px", fontWeight: 600, cursor: "pointer", opacity: 0, transition: transitionFor(["opacity", "background-color"]), sx: { ...revealStyles(colors), "@media (hover: none)": { opacity: 1 } }, onClick: (event) => {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
event.stopPropagation();
|
|
154
|
+
onToggle();
|
|
155
|
+
}, children: [_jsx(Star, { size: 11, strokeWidth: 2, "aria-hidden": true }), text] }));
|
|
156
|
+
}
|
|
157
|
+
export function PinnedTile({ screen, module, link, labels, onTogglePin, }) {
|
|
158
|
+
var _a;
|
|
159
|
+
const { colors } = useCustomTheme();
|
|
160
|
+
const Icon = (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon;
|
|
161
|
+
const focus = useRowFocus(true);
|
|
162
|
+
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "center", gap: "8px", h: "36px", pl: "9px", pr: "4px", borderRadius: "9px", borderWidth: "1px", borderColor: colors.boxborder[200], bg: colors.surfaceRaised, transition: transitionFor(["border-color", "background-color"]), _hover: { borderColor: colors.gray[300] }, sx: focus.sx, children: [Icon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, color: colors.accentText, children: _jsx(Icon, { size: 15, strokeWidth: 1.8, "aria-hidden": true }) })) : null, _jsx(OverflowToolTip, { label: screen.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": onTogglePin ? screen.id : undefined, onClick: link.onPlainClick, flex: 1, minW: 0, fontSize: "13px", fontWeight: 500, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("9px"), children: screen.label }) }), _jsx(CountBadge, { value: screen.badge, size: "tile" }), onTogglePin ? (_jsx(Box, { position: "relative", zIndex: 1, flexShrink: 0, w: "0", overflow: "hidden", transition: transitionFor(["width"]), _groupHover: { w: "22px" }, _groupFocusWithin: { w: "22px" }, children: _jsx(PinToggle, { isPinned: true, size: 12, label: labels.unpin(screen.label), title: labels.unpinTip, onToggle: onTogglePin }) })) : null] }));
|
|
163
|
+
}
|
|
164
|
+
export function AppsSection({ apps, hues, currentAppId, heading, onSelect, }) {
|
|
165
|
+
const { colors } = useCustomTheme();
|
|
166
|
+
const rows = listRowBackgrounds(colors);
|
|
167
|
+
const rowRing = activeRowSurface(colors);
|
|
168
|
+
return (_jsxs(Box, { children: [_jsx(SectionHeader, { label: heading, isRail: true, hasCount: false }), _jsx(Box, { as: "ul", listStyleType: "none", m: 0, p: 0, "aria-label": heading, children: apps.map((app, index) => {
|
|
169
|
+
var _a;
|
|
170
|
+
const isCurrent = app.id === currentAppId;
|
|
171
|
+
const interactive = !isCurrent && !app.locked;
|
|
172
|
+
return (_jsx(Box, { as: "li", children: _jsxs(Flex, { as: interactive ? "a" : "div", ...(interactive
|
|
173
|
+
? {
|
|
174
|
+
href: app.url,
|
|
175
|
+
target: "_blank",
|
|
176
|
+
rel: "noopener noreferrer",
|
|
177
|
+
"data-launcher-item": true,
|
|
178
|
+
onClick: (event) => onSelect(app, event),
|
|
179
|
+
}
|
|
180
|
+
: {}), "aria-current": isCurrent ? "true" : undefined, title: app.locked
|
|
181
|
+
? ((_a = app.lockedReason) !== null && _a !== void 0 ? _a : `${app.name} is not available on your plan`)
|
|
182
|
+
: undefined, "data-app-locked": app.locked ? "true" : undefined, "aria-disabled": app.locked ? "true" : undefined, align: "center", gap: 3, minH: "44px", px: 2, py: 1, borderRadius: "8px", textDecoration: "none", cursor: interactive ? "pointer" : "default", bg: isCurrent ? rows.selected : "transparent", transition: transitionFor(["background-color"]), _hover: interactive ? { bg: rows.active } : undefined, sx: {
|
|
183
|
+
_focusVisible: rowRing,
|
|
184
|
+
[FOCUS_VISIBLE_OVER_STATE]: rowRing,
|
|
185
|
+
}, children: [_jsx(AppMark, { app: app, hue: hues[index], boxSize: "28px", iconSize: 15, muted: app.locked }), _jsx(OverflowToolTip, { label: app.name, placement: "top-start", children: _jsx(Text, { flex: 1, minW: 0, fontSize: "sm", fontWeight: "medium", noOfLines: 1, color: app.locked ? colors.textMuted : colors.text[900], children: app.name }) }), app.locked ? (_jsx(Box, { as: Lock, size: 14, color: colors.textMuted, flexShrink: 0, "aria-hidden": true })) : null] }) }, app.id || app.name));
|
|
186
|
+
}) })] }));
|
|
187
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const normalize = (text) => text.toLocaleLowerCase().normalize("NFKD");
|
|
2
|
+
function score(label, haystack, tokens) {
|
|
3
|
+
if (!tokens.every((t) => haystack.includes(t)))
|
|
4
|
+
return null;
|
|
5
|
+
const l = normalize(label);
|
|
6
|
+
const q = tokens.join(" ");
|
|
7
|
+
if (l === q)
|
|
8
|
+
return 0;
|
|
9
|
+
if (l.startsWith(q))
|
|
10
|
+
return 1;
|
|
11
|
+
if (l.split(/\s+/).some((w) => w.startsWith(tokens[0])))
|
|
12
|
+
return 2;
|
|
13
|
+
return l.includes(tokens[0]) ? 3 : 4;
|
|
14
|
+
}
|
|
15
|
+
function rank(rows, text, tokens) {
|
|
16
|
+
return rows
|
|
17
|
+
.map((row, index) => ({
|
|
18
|
+
row,
|
|
19
|
+
index,
|
|
20
|
+
s: score(row.label, normalize(text(row)), tokens),
|
|
21
|
+
}))
|
|
22
|
+
.filter((r) => r.s !== null)
|
|
23
|
+
.sort((a, b) => a.s - b.s || a.index - b.index)
|
|
24
|
+
.map((r) => r.row);
|
|
25
|
+
}
|
|
26
|
+
export function flattenScreens(sections) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const section of sections) {
|
|
31
|
+
for (const module of section.modules) {
|
|
32
|
+
for (const screen of module.screens) {
|
|
33
|
+
if (seen.has(screen.id))
|
|
34
|
+
continue;
|
|
35
|
+
seen.add(screen.id);
|
|
36
|
+
out.push({
|
|
37
|
+
id: `screen:${screen.id}`,
|
|
38
|
+
screenId: screen.id,
|
|
39
|
+
label: screen.label,
|
|
40
|
+
context: screen.label === module.label ? section.label : module.label,
|
|
41
|
+
icon: (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon,
|
|
42
|
+
badge: screen.badge,
|
|
43
|
+
href: screen.href,
|
|
44
|
+
keywords: [module.label, ...((_b = module.keywords) !== null && _b !== void 0 ? _b : []), ...((_c = screen.keywords) !== null && _c !== void 0 ? _c : [])].join(" "),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
export function searchLauncher(input) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
const tokens = normalize(input.query).split(/\s+/).filter(Boolean);
|
|
54
|
+
if (tokens.length === 0)
|
|
55
|
+
return [];
|
|
56
|
+
const screens = flattenScreens(input.sections);
|
|
57
|
+
const actions = rank(((_a = input.actions) !== null && _a !== void 0 ? _a : []).map((a) => ({ ...a, id: `action:${a.id}` })), (a) => { var _a, _b; return `${a.label} ${(_a = a.context) !== null && _a !== void 0 ? _a : ""} ${(_b = a.keywords) !== null && _b !== void 0 ? _b : ""}`; }, tokens);
|
|
58
|
+
const groups = [
|
|
59
|
+
{ id: "actions", label: input.actionsLabel, items: actions },
|
|
60
|
+
{
|
|
61
|
+
id: "screens",
|
|
62
|
+
label: input.screensLabel,
|
|
63
|
+
items: rank(screens, (s) => { var _a; return `${s.label} ${(_a = s.context) !== null && _a !== void 0 ? _a : ""} ${s.keywords}`; }, tokens),
|
|
64
|
+
},
|
|
65
|
+
...((_b = input.extraResults) !== null && _b !== void 0 ? _b : []).map((g) => ({
|
|
66
|
+
id: g.id,
|
|
67
|
+
label: g.label,
|
|
68
|
+
items: g.items.map((i) => ({ ...i, id: `${g.id}:${i.id}` })),
|
|
69
|
+
})),
|
|
70
|
+
];
|
|
71
|
+
return groups.filter((g) => g.items.length > 0);
|
|
72
|
+
}
|
|
73
|
+
function matchNameOrKeyword(label, keywords, tokens) {
|
|
74
|
+
const name = normalize(label);
|
|
75
|
+
if (tokens.every((t) => name.includes(t)))
|
|
76
|
+
return {};
|
|
77
|
+
const terms = keywords.map(normalize);
|
|
78
|
+
const all = `${name} ${terms.join(" ")}`;
|
|
79
|
+
if (!tokens.every((t) => all.includes(t)))
|
|
80
|
+
return null;
|
|
81
|
+
const hit = keywords.find((_, i) => tokens.some((t) => terms[i].includes(t)));
|
|
82
|
+
return { keyword: hit !== null && hit !== void 0 ? hit : keywords[0] };
|
|
83
|
+
}
|
|
84
|
+
/** Search that keeps the sections: per section, matching modules, each followed by its matching screens. */
|
|
85
|
+
export function searchLauncherSections(input) {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f;
|
|
87
|
+
const tokens = normalize(input.query).split(/\s+/).filter(Boolean);
|
|
88
|
+
if (tokens.length === 0)
|
|
89
|
+
return { sections: [], groups: [] };
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
const sections = [];
|
|
92
|
+
for (const section of input.sections) {
|
|
93
|
+
const items = [];
|
|
94
|
+
for (const module of section.modules) {
|
|
95
|
+
const moduleHit = matchNameOrKeyword(module.label, (_a = module.keywords) !== null && _a !== void 0 ? _a : [], tokens);
|
|
96
|
+
if (moduleHit) {
|
|
97
|
+
items.push({
|
|
98
|
+
id: `module:${module.id}`,
|
|
99
|
+
kind: "module",
|
|
100
|
+
label: module.label,
|
|
101
|
+
keywordHint: moduleHit.keyword,
|
|
102
|
+
icon: module.icon,
|
|
103
|
+
badge: module.badge,
|
|
104
|
+
isNew: module.isNew,
|
|
105
|
+
href: module.href,
|
|
106
|
+
screenId: (_b = module.screens[0]) === null || _b === void 0 ? void 0 : _b.id,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
for (const screen of module.screens) {
|
|
110
|
+
if (screen.label === module.label || seen.has(screen.id))
|
|
111
|
+
continue;
|
|
112
|
+
if (!matchNameOrKeyword(screen.label, (_c = screen.keywords) !== null && _c !== void 0 ? _c : [], tokens))
|
|
113
|
+
continue;
|
|
114
|
+
seen.add(screen.id);
|
|
115
|
+
items.push({
|
|
116
|
+
id: `screen:${screen.id}`,
|
|
117
|
+
kind: "screen",
|
|
118
|
+
label: screen.label,
|
|
119
|
+
context: module.label,
|
|
120
|
+
icon: (_d = screen.icon) !== null && _d !== void 0 ? _d : module.icon,
|
|
121
|
+
badge: screen.badge,
|
|
122
|
+
href: screen.href,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (items.length > 0)
|
|
127
|
+
sections.push({ id: section.id, label: section.label, items });
|
|
128
|
+
}
|
|
129
|
+
const actions = rank(((_e = input.actions) !== null && _e !== void 0 ? _e : []).map((a) => ({ ...a, id: `action:${a.id}` })), (a) => { var _a, _b; return `${a.label} ${(_a = a.context) !== null && _a !== void 0 ? _a : ""} ${(_b = a.keywords) !== null && _b !== void 0 ? _b : ""}`; }, tokens);
|
|
130
|
+
const groups = [
|
|
131
|
+
{ id: "actions", label: input.actionsLabel, items: actions },
|
|
132
|
+
...((_f = input.extraResults) !== null && _f !== void 0 ? _f : []).map((g) => ({
|
|
133
|
+
id: g.id,
|
|
134
|
+
label: g.label,
|
|
135
|
+
items: g.items.map((i) => ({ ...i, id: `${g.id}:${i.id}` })),
|
|
136
|
+
})),
|
|
137
|
+
].filter((g) => g.items.length > 0);
|
|
138
|
+
return { sections, groups };
|
|
139
|
+
}
|
|
140
|
+
/** Splits `text` so every case-insensitive occurrence of a query token is its own matched segment. */
|
|
141
|
+
export function highlightSegments(text, query) {
|
|
142
|
+
const lower = text.toLocaleLowerCase();
|
|
143
|
+
const tokens = query.toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
144
|
+
if (tokens.length === 0 || lower.length !== text.length)
|
|
145
|
+
return [{ text, isMatch: false }];
|
|
146
|
+
const ranges = [];
|
|
147
|
+
for (const token of tokens) {
|
|
148
|
+
for (let at = lower.indexOf(token); at !== -1; at = lower.indexOf(token, at + token.length)) {
|
|
149
|
+
ranges.push([at, at + token.length]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
ranges.sort((a, b) => a[0] - b[0]);
|
|
153
|
+
const merged = [];
|
|
154
|
+
for (const range of ranges) {
|
|
155
|
+
const last = merged[merged.length - 1];
|
|
156
|
+
if (last && range[0] <= last[1])
|
|
157
|
+
last[1] = Math.max(last[1], range[1]);
|
|
158
|
+
else
|
|
159
|
+
merged.push([...range]);
|
|
160
|
+
}
|
|
161
|
+
const out = [];
|
|
162
|
+
let cursor = 0;
|
|
163
|
+
for (const [start, end] of merged) {
|
|
164
|
+
if (start > cursor)
|
|
165
|
+
out.push({ text: text.slice(cursor, start), isMatch: false });
|
|
166
|
+
out.push({ text: text.slice(start, end), isMatch: true });
|
|
167
|
+
cursor = end;
|
|
168
|
+
}
|
|
169
|
+
if (cursor < text.length)
|
|
170
|
+
out.push({ text: text.slice(cursor), isMatch: false });
|
|
171
|
+
return out.length ? out : [{ text, isMatch: false }];
|
|
172
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
2
|
+
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
3
|
+
/** Shows a row affordance on row hover, row focus-within or its own keyboard focus, and always on touch. */
|
|
4
|
+
export const revealStyles = (colors) => {
|
|
5
|
+
const ring = focusVisibleStyles(colors);
|
|
6
|
+
return {
|
|
7
|
+
...ring,
|
|
8
|
+
_focusVisible: { ...ring._focusVisible, opacity: 1 },
|
|
9
|
+
_groupHover: { opacity: 1 },
|
|
10
|
+
_groupFocusWithin: { opacity: 1 },
|
|
11
|
+
"[data-reveal=true] &": { opacity: 1 },
|
|
12
|
+
"@media (hover: none)": { opacity: 1 },
|
|
13
|
+
...reducedMotionSx(),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Button, Flex, Menu, MenuButton, MenuDivider, MenuItem, MenuList, Stack, Text, } from "@chakra-ui/react";
|
|
3
3
|
import Avatar from "../Avatar/Avatar.js";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
@@ -10,7 +10,7 @@ import PersonChip from "../PersonChip/PersonChip.js";
|
|
|
10
10
|
import { CircleArrowLeft, LogOut, PanelLeftClose, PanelRightClose, } from "lucide-react";
|
|
11
11
|
// Roomy enough to hover without aiming: the glyph is only 1.25rem.
|
|
12
12
|
const SIDEBAR_TOGGLE_HIT = "2.5rem";
|
|
13
|
-
export default function NavBar({ userAvathar, userName, userRole, navMenu, moreIcon, handleNavOnClick, handleLogout, logoutText, navigationBarText, sideBarToggole, onSideBarToggole, forceSideBarToggle = false, onSideBarPeek, }) {
|
|
13
|
+
export default function NavBar({ userAvathar, userName, userRole, navMenu, moreIcon, handleNavOnClick, handleLogout, logoutText, navigationBarText, sideBarToggole, onSideBarToggole, forceSideBarToggle = false, onSideBarPeek, leading, }) {
|
|
14
14
|
const theme = useCustomTheme();
|
|
15
15
|
const rowBackgrounds = listRowBackgrounds(theme.colors);
|
|
16
16
|
const menuHoverBg = rowBackgrounds.active;
|
|
@@ -46,7 +46,7 @@ export default function NavBar({ userAvathar, userName, userRole, navMenu, moreI
|
|
|
46
46
|
_focus: { bg: menuHoverBg },
|
|
47
47
|
_active: { bg: rowBackgrounds.selectedActive },
|
|
48
48
|
};
|
|
49
|
-
return (_jsx(Box, { bg: theme.colors.backgroundColor.light, px: 4, borderBottom: "1px solid", borderColor: theme.colors.boxborder[200], children: _jsxs(Flex, { h: 16, alignItems: "center", justifyContent: "space-between", children: [_jsxs(Box, { display: "flex", gap: 1.5, alignItems: "center", children: [_jsx(Box, { as: "button", type: "button", onClick: () => onSideBarToggole === null || onSideBarToggole === void 0 ? void 0 : onSideBarToggole(), onMouseEnter: onSideBarPeek, onFocus: onSideBarPeek, "aria-label": sideBarToggole ? "Close navigation menu" : "Open navigation menu", "aria-expanded": !!sideBarToggole, ...iconButtonStyle, display: forceSideBarToggle ? "flex" : { base: "flex", lg: "none" }, w: SIDEBAR_TOGGLE_HIT, h: SIDEBAR_TOGGLE_HIT, children: sideBarToggole ? (_jsx(PanelLeftClose, { size: "1.25rem" })) : (_jsx(PanelRightClose, { size: "1.25rem" })) }), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) && (_jsx(Box, { ...iconButtonStyle, as: "button", type: "button", "aria-label": "Go back", display: "flex", onClick: () => { var _a; return (_a = navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) === null || _a === void 0 ? void 0 : _a.call(navigationBarText); }, children: _jsx(CircleArrowLeft, { size: "1.25rem", color: theme.colors.text[500] }) })), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text) && (_jsx(Text, { color: accentTextOnCanvas(theme.colors.secondary, theme.colors.backgroundColor.light), fontSize: "1.25rem", fontWeight: 600, fontFamily: "open-sans, sans-serif", letterSpacing: "-0.013rem", children: navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text }))] }), _jsx(Flex, { minW: 0, flexShrink: 1, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 4, minW: 0, children: [moreIcon && (_jsx(Box, { display: "flex", alignItems: "center", minW: 0, children: moreIcon })), _jsxs(Menu, { children: [_jsx(MenuButton, { as: Button, rounded: "full", variant: "link", cursor: "pointer", minW: 0, flexShrink: 0, children: _jsx(Avatar, { size: "sm", name: userName, src: userAvathar }) }), _jsx(MenuList, { alignItems: "center", zIndex: 5, p: 0, py: "0.375rem",
|
|
49
|
+
return (_jsx(Box, { bg: theme.colors.backgroundColor.light, px: 4, borderBottom: "1px solid", borderColor: theme.colors.boxborder[200], children: _jsxs(Flex, { h: 16, alignItems: "center", justifyContent: "space-between", children: [_jsxs(Box, { display: "flex", gap: 1.5, alignItems: "center", children: [_jsx(Box, { as: "button", type: "button", onClick: () => onSideBarToggole === null || onSideBarToggole === void 0 ? void 0 : onSideBarToggole(), onMouseEnter: onSideBarPeek, onFocus: onSideBarPeek, "aria-label": sideBarToggole ? "Close navigation menu" : "Open navigation menu", "aria-expanded": !!sideBarToggole, ...iconButtonStyle, display: forceSideBarToggle ? "flex" : { base: "flex", lg: "none" }, w: SIDEBAR_TOGGLE_HIT, h: SIDEBAR_TOGGLE_HIT, children: sideBarToggole ? (_jsx(PanelLeftClose, { size: "1.25rem" })) : (_jsx(PanelRightClose, { size: "1.25rem" })) }), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) && (_jsx(Box, { ...iconButtonStyle, as: "button", type: "button", "aria-label": "Go back", display: "flex", onClick: () => { var _a; return (_a = navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) === null || _a === void 0 ? void 0 : _a.call(navigationBarText); }, children: _jsx(CircleArrowLeft, { size: "1.25rem", color: theme.colors.text[500] }) })), leading && (_jsxs(_Fragment, { children: [leading, _jsx(Box, { as: "span", "aria-hidden": "true", mx: 2, w: "1px", h: "1.625rem", bg: theme.colors.boxborder[200] })] })), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text) && (_jsx(Text, { color: accentTextOnCanvas(theme.colors.secondary, theme.colors.backgroundColor.light), fontSize: "1.25rem", fontWeight: 600, fontFamily: "open-sans, sans-serif", letterSpacing: "-0.013rem", children: navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text }))] }), _jsx(Flex, { minW: 0, flexShrink: 1, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 4, minW: 0, children: [moreIcon && (_jsx(Box, { display: "flex", alignItems: "center", minW: 0, children: moreIcon })), _jsxs(Menu, { children: [_jsx(MenuButton, { as: Button, rounded: "full", variant: "link", cursor: "pointer", minW: 0, flexShrink: 0, children: _jsx(Avatar, { size: "sm", name: userName, src: userAvathar }) }), _jsx(MenuList, { alignItems: "center", zIndex: 5, p: 0, py: "0.375rem",
|
|
50
50
|
// Without a cap one long title stretches the whole dropdown; titles truncate instead.
|
|
51
51
|
maxW: "18rem", bg: theme.colors.surfaceRaised,
|
|
52
52
|
// NOTE: Chakra's MenuItem inherits --menu-bg hardcoded to #fff via dead _dark — set it or items stay white.
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Flex, Heading, Text } from "@chakra-ui/react";
|
|
3
3
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
4
|
+
const TITLE_STYLES = {
|
|
5
|
+
md: { fontSize: "lg", fontWeight: 600, letterSpacing: "-0.01em" },
|
|
6
|
+
lg: { fontSize: "2xl", fontWeight: 700, letterSpacing: "-0.02em", lineHeight: 1.2 },
|
|
7
|
+
xl: { fontSize: { base: "2xl", md: "3xl" }, fontWeight: 700, letterSpacing: "-0.025em", lineHeight: 1.2 },
|
|
8
|
+
};
|
|
4
9
|
/** Page header: h1 title, muted subtitle, right-aligned actions that wrap under on narrow screens. */
|
|
5
|
-
const PageHeader = ({ title, subtitle, actions, breadcrumbs, leading, titleAddon, meta, tabs, "data-testid": testId, }) => {
|
|
10
|
+
const PageHeader = ({ title, subtitle, actions, breadcrumbs, leading, titleAddon, meta, tabs, titleSize = "md", actionsLayout = "auto", "data-testid": testId, }) => {
|
|
6
11
|
const { colors } = useCustomTheme();
|
|
7
|
-
|
|
12
|
+
const wraps = actionsLayout === "auto";
|
|
13
|
+
const stacked = actionsLayout === "stacked";
|
|
14
|
+
return (_jsxs(Flex, { direction: "column", gap: 3, "data-testid": testId, children: [breadcrumbs && (_jsx(Box, { fontSize: "sm", color: colors.textMuted, sx: { "[aria-current=page]": { color: colors.text[800] } }, children: breadcrumbs })), _jsxs(Flex, { justify: "space-between", align: stacked ? "flex-start" : { base: "flex-start", md: "center" }, direction: stacked ? "column" : { base: "column", md: "row" }, wrap: wraps ? "wrap" : "nowrap", gap: 3, children: [_jsxs(Flex, { gap: 3, align: "center", minW: 0, flex: wraps ? { base: "0 1 auto", md: "1 1 16rem" } : undefined, children: [leading && _jsx(Box, { flexShrink: 0, children: leading }), _jsxs(Box, { minW: 0, children: [_jsxs(Flex, { align: "center", gap: 2, wrap: "wrap", children: [_jsx(Heading, { as: "h1", ...TITLE_STYLES[titleSize], color: colors.header[900], children: title }), titleAddon] }), subtitle && (_jsx(Text, { mt: 0.5, fontSize: "sm", color: colors.textMuted, children: subtitle })), meta && (_jsx(Flex, { mt: 1, columnGap: 4, rowGap: 1, wrap: "wrap", align: "center", fontSize: "xs", color: colors.textMuted, children: meta }))] })] }), actions && (_jsx(Flex, { gap: 2, wrap: "wrap", align: "center", flexShrink: wraps ? undefined : 0, children: actions }))] }), tabs && _jsx(Box, { children: tabs })] }));
|
|
8
15
|
};
|
|
9
16
|
export default PageHeader;
|
|
@@ -1,16 +1,137 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
3
|
import { Box, Flex, Text } from "@chakra-ui/react";
|
|
3
4
|
import { Download, ExternalLink, FileText } from "lucide-react";
|
|
4
5
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
6
|
import { accentTextOnCanvas } from "../../Theme/tokens/builders/accentText.js";
|
|
6
7
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
|
+
import Button from "../Button/Button.js";
|
|
9
|
+
import Skeletons from "../Skeletons/Skeletons.js";
|
|
7
10
|
import ToolTip from "../ToolTip/ToolTip.js";
|
|
11
|
+
const DEFAULT_LABELS = {
|
|
12
|
+
open: "Open in new tab",
|
|
13
|
+
download: "Download",
|
|
14
|
+
unsupported: "This browser can't display PDFs inline. Open or download the file instead.",
|
|
15
|
+
failed: "The document could not be loaded.",
|
|
16
|
+
};
|
|
17
|
+
const canEmbedPdf = () => typeof navigator === "undefined" || navigator.pdfViewerEnabled !== false;
|
|
18
|
+
const asPdf = (blob) => (blob.type ? blob : new Blob([blob], { type: "application/pdf" }));
|
|
8
19
|
/** Always-inline PDF embed panel (never a modal) — for a modal previewer of images/video/other too, use FilePreview. */
|
|
9
|
-
const PdfViewer = ({ pdfUrl, fileName = "Document.pdf", height = "480px", showToolbar = true, borderRadius = "xl", }) => {
|
|
20
|
+
const PdfViewer = ({ pdfUrl, getBlob, fileName = "Document.pdf", height = "480px", showToolbar = true, borderRadius = "xl", fallback, onLoad, onError, labels, "data-testid": testId, }) => {
|
|
10
21
|
const theme = useCustomTheme();
|
|
22
|
+
const text = { ...DEFAULT_LABELS, ...labels };
|
|
11
23
|
const toolbarSurface = theme.colors.background[50];
|
|
12
24
|
const iconHoverInk = accentTextOnCanvas(theme.colors.primary, toolbarSurface);
|
|
13
25
|
const iconHoverBg = listRowBackgrounds(theme.colors).active;
|
|
14
|
-
|
|
26
|
+
const supported = canEmbedPdf();
|
|
27
|
+
const isBlobMode = Boolean(getBlob);
|
|
28
|
+
const getBlobRef = useRef(getBlob);
|
|
29
|
+
const onLoadRef = useRef(onLoad);
|
|
30
|
+
const onErrorRef = useRef(onError);
|
|
31
|
+
getBlobRef.current = getBlob;
|
|
32
|
+
onLoadRef.current = onLoad;
|
|
33
|
+
onErrorRef.current = onError;
|
|
34
|
+
const [status, setStatus] = useState(isBlobMode && supported ? "loading" : "idle");
|
|
35
|
+
const [objectUrl, setObjectUrl] = useState(null);
|
|
36
|
+
const tempUrls = useRef([]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (!isBlobMode || !supported)
|
|
40
|
+
return undefined;
|
|
41
|
+
let cancelled = false;
|
|
42
|
+
let created = null;
|
|
43
|
+
setStatus("loading");
|
|
44
|
+
setObjectUrl(null);
|
|
45
|
+
(_a = getBlobRef.current) === null || _a === void 0 ? void 0 : _a.call(getBlobRef).then((blob) => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (cancelled)
|
|
48
|
+
return;
|
|
49
|
+
created = URL.createObjectURL(asPdf(blob));
|
|
50
|
+
setObjectUrl(created);
|
|
51
|
+
setStatus("ready");
|
|
52
|
+
(_a = onLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(onLoadRef);
|
|
53
|
+
}, (error) => {
|
|
54
|
+
var _a;
|
|
55
|
+
if (cancelled)
|
|
56
|
+
return;
|
|
57
|
+
setStatus("error");
|
|
58
|
+
(_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error);
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
cancelled = true;
|
|
62
|
+
if (created)
|
|
63
|
+
URL.revokeObjectURL(created);
|
|
64
|
+
};
|
|
65
|
+
}, [isBlobMode, supported]);
|
|
66
|
+
useEffect(() => () => {
|
|
67
|
+
tempUrls.current.forEach((url) => URL.revokeObjectURL(url));
|
|
68
|
+
tempUrls.current = [];
|
|
69
|
+
}, []);
|
|
70
|
+
const makeTempUrl = useCallback((blob) => {
|
|
71
|
+
const url = URL.createObjectURL(asPdf(blob));
|
|
72
|
+
tempUrls.current.push(url);
|
|
73
|
+
return url;
|
|
74
|
+
}, []);
|
|
75
|
+
const openBlob = () => {
|
|
76
|
+
var _a;
|
|
77
|
+
if (objectUrl) {
|
|
78
|
+
window.open(objectUrl, "_blank", "noopener");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const tab = window.open("", "_blank");
|
|
82
|
+
(_a = getBlobRef.current) === null || _a === void 0 ? void 0 : _a.call(getBlobRef).then((blob) => {
|
|
83
|
+
const url = makeTempUrl(blob);
|
|
84
|
+
if (tab)
|
|
85
|
+
tab.location.href = url;
|
|
86
|
+
else
|
|
87
|
+
window.location.assign(url);
|
|
88
|
+
}, (error) => {
|
|
89
|
+
var _a;
|
|
90
|
+
tab === null || tab === void 0 ? void 0 : tab.close();
|
|
91
|
+
(_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const downloadBlob = () => {
|
|
95
|
+
var _a;
|
|
96
|
+
(_a = getBlobRef.current) === null || _a === void 0 ? void 0 : _a.call(getBlobRef).then((blob) => {
|
|
97
|
+
const link = document.createElement("a");
|
|
98
|
+
link.href = makeTempUrl(blob);
|
|
99
|
+
link.download = fileName;
|
|
100
|
+
document.body.appendChild(link);
|
|
101
|
+
link.click();
|
|
102
|
+
link.remove();
|
|
103
|
+
}, (error) => { var _a; return (_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error); });
|
|
104
|
+
};
|
|
105
|
+
const toolbarLabel = (kind) => {
|
|
106
|
+
if (labels === null || labels === void 0 ? void 0 : labels[kind])
|
|
107
|
+
return `${labels[kind]} ${fileName}`;
|
|
108
|
+
return kind === "open" ? `Open ${fileName} in a new tab` : `Download ${fileName}`;
|
|
109
|
+
};
|
|
110
|
+
const actionStyle = {
|
|
111
|
+
p: 2,
|
|
112
|
+
borderRadius: "lg",
|
|
113
|
+
color: theme.colors.gray[600],
|
|
114
|
+
_hover: { bg: iconHoverBg, color: iconHoverInk },
|
|
115
|
+
};
|
|
116
|
+
const openAction = isBlobMode ? (_jsx(Box, { as: "button", type: "button", onClick: openBlob, "aria-label": toolbarLabel("open"), ...actionStyle, children: _jsx(ExternalLink, { size: 16, "aria-hidden": "true" }) })) : (_jsx(Box, { as: "a", href: pdfUrl, target: "_blank", rel: "noopener noreferrer", "aria-label": toolbarLabel("open"), ...actionStyle, children: _jsx(ExternalLink, { size: 16, "aria-hidden": "true" }) }));
|
|
117
|
+
const downloadAction = isBlobMode && !objectUrl ? (_jsx(Box, { as: "button", type: "button", onClick: downloadBlob, "aria-label": toolbarLabel("download"), ...actionStyle, children: _jsx(Download, { size: 16, "aria-hidden": "true" }) })) : (_jsx(Box, { as: "a", href: objectUrl !== null && objectUrl !== void 0 ? objectUrl : pdfUrl, download: fileName, "aria-label": toolbarLabel("download"), ...actionStyle, children: _jsx(Download, { size: 16, "aria-hidden": "true" }) }));
|
|
118
|
+
const showFallback = !supported || status === "error";
|
|
119
|
+
const isLoading = isBlobMode && supported && status === "loading";
|
|
120
|
+
const renderFallback = () => {
|
|
121
|
+
if (fallback !== undefined)
|
|
122
|
+
return fallback;
|
|
123
|
+
return (_jsxs(Flex, { direction: "column", align: "flex-start", gap: 3, p: 4, "data-testid": "pdf-fallback", children: [_jsx(Text, { role: "status", fontSize: "sm", color: theme.colors.textMuted, children: supported ? text.failed : text.unsupported }), !showToolbar && (_jsxs(Flex, { gap: 2, wrap: "wrap", children: [_jsx(Button, { variant: "outline", colorScheme: "gray", leftIcon: _jsx(ExternalLink, { size: 16, "aria-hidden": "true" }), label: text.open, onClick: isBlobMode ? openBlob : () => window.open(pdfUrl, "_blank", "noopener"), "data-testid": "pdf-open" }), _jsx(Button, { variant: "outline", colorScheme: "gray", leftIcon: _jsx(Download, { size: 16, "aria-hidden": "true" }), label: text.download, onClick: isBlobMode ? downloadBlob : directDownload(pdfUrl, fileName), "data-testid": "pdf-download" })] }))] }));
|
|
124
|
+
};
|
|
125
|
+
return (_jsxs(Box, { border: "1px solid", borderColor: theme.colors.gray[200], borderRadius: borderRadius, overflow: "hidden", bg: theme.colors.background[50], "data-testid": testId, children: [showToolbar && (_jsxs(Flex, { align: "center", justify: "space-between", px: 4, py: 2.5, borderBottom: "1px solid", borderColor: theme.colors.gray[100], bg: theme.colors.background[50], children: [_jsxs(Flex, { align: "center", gap: 2, minW: 0, children: [_jsx(FileText, { size: 18, color: theme.colors.accentText, "aria-hidden": "true" }), _jsx(Text, { fontSize: "sm", fontWeight: 500, color: theme.colors.gray[700], overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", children: fileName })] }), _jsxs(Flex, { align: "center", gap: 1, children: [_jsx(ToolTip, { label: text.open, placement: "top", children: openAction }), _jsx(ToolTip, { label: text.download, placement: "top", children: downloadAction })] })] })), showFallback ? (renderFallback()) : isLoading ? (_jsx(Box, { "aria-busy": "true", "data-testid": "pdf-loading", children: _jsx(Skeletons, { type: "skeleton", height: height, width: "100%", borderRadius: "0" }) })) : (_jsx(Box, { as: "embed", src: objectUrl !== null && objectUrl !== void 0 ? objectUrl : pdfUrl, type: "application/pdf", title: fileName, onLoad: isBlobMode ? undefined : () => { var _a; return (_a = onLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(onLoadRef); }, width: "100%", height: height, display: "block" }))] }));
|
|
126
|
+
};
|
|
127
|
+
const directDownload = (url, fileName) => () => {
|
|
128
|
+
if (!url)
|
|
129
|
+
return;
|
|
130
|
+
const link = document.createElement("a");
|
|
131
|
+
link.href = url;
|
|
132
|
+
link.download = fileName;
|
|
133
|
+
document.body.appendChild(link);
|
|
134
|
+
link.click();
|
|
135
|
+
link.remove();
|
|
15
136
|
};
|
|
16
137
|
export default PdfViewer;
|
|
@@ -10,6 +10,11 @@ import { hexToRgb } from "../../Theme/tokens/builders/color.js";
|
|
|
10
10
|
export default function ProfilePhotoViewer({ photoUrl, onPhotoChange, imageWidth = "100px", imageAlt = "Profile Photo", imageObjectFit = "cover", imageBorderRadius = "full", editIconSize = "sm", editIconPositionRight = "0px", editIconPositionBottom = "0px", isRound = true, boxStyle, isEditable = false, isView = false, style, handleIsView, fallbackText, revealOnHover = true, }) {
|
|
11
11
|
var _a, _b, _c, _d, _e;
|
|
12
12
|
const [photo, setPhoto] = useState(photoUrl);
|
|
13
|
+
const [syncedUrl, setSyncedUrl] = useState(photoUrl);
|
|
14
|
+
if (photoUrl !== syncedUrl) {
|
|
15
|
+
setSyncedUrl(photoUrl);
|
|
16
|
+
setPhoto(photoUrl);
|
|
17
|
+
}
|
|
13
18
|
const fileInputRef = useRef(null);
|
|
14
19
|
const theme = useCustomTheme();
|
|
15
20
|
const c = theme.colors;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Flex, VisuallyHidden } from "@chakra-ui/react";
|
|
2
|
+
import { Box, Flex, VisuallyHidden } from "@chakra-ui/react";
|
|
3
|
+
import { Lock } from "lucide-react";
|
|
3
4
|
import EmptyState from "../EmptyState/EmptyState.js";
|
|
4
5
|
import Skeletons from "../Skeletons/Skeletons.js";
|
|
5
6
|
import ErrorState from "./ErrorState.js";
|
|
6
7
|
const DefaultLoading = () => (_jsxs(Flex, { role: "status", direction: "column", gap: 4, w: "100%", py: 2, children: [_jsx(VisuallyHidden, { children: "Loading" }), _jsx(Skeletons, { type: "skeleton", height: 4, width: "40%" }), Array.from({ length: 4 }, (_, i) => (_jsxs(Flex, { direction: "column", gap: 2, children: [_jsx(Skeletons, { type: "skeleton", height: 2.5, width: "100%" }), _jsx(Skeletons, { type: "skeleton", height: 2.5, width: "70%" })] }, i)))] }));
|
|
7
8
|
const hasError = (error) => error !== undefined && error !== null && error !== false;
|
|
8
|
-
/** Renders one of loading / error / empty / children for a content region; agnostic of the fetching library. */
|
|
9
|
-
const QueryStateBoundary = ({ isLoading = false, error, isEmpty = false, loadingFallback, emptyFallback, empty, errorTitle, errorDescription, onRetry, isRetrying, minH = "24rem", children, }) => {
|
|
10
|
-
|
|
9
|
+
/** Renders one of loading / forbidden / error / empty / children for a content region; agnostic of the fetching library. */
|
|
10
|
+
const QueryStateBoundary = ({ isLoading = false, isForbidden = false, forbidden, hasData = false, error, isEmpty = false, loadingFallback, emptyFallback, empty, errorTitle, errorDescription, onRetry, isRetrying, minH = "24rem", children, }) => {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
if (isLoading && !hasData)
|
|
11
13
|
return _jsx(_Fragment, { children: loadingFallback !== null && loadingFallback !== void 0 ? loadingFallback : _jsx(DefaultLoading, {}) });
|
|
14
|
+
const forbiddenNow = typeof isForbidden === "function" ? hasError(error) && isForbidden(error) : isForbidden;
|
|
15
|
+
if (forbiddenNow) {
|
|
16
|
+
return (_jsx(Box, { role: "status", w: "100%", children: _jsx(EmptyState, { colorScheme: "gray", icon: (_a = forbidden === null || forbidden === void 0 ? void 0 : forbidden.icon) !== null && _a !== void 0 ? _a : Lock, title: (_b = forbidden === null || forbidden === void 0 ? void 0 : forbidden.title) !== null && _b !== void 0 ? _b : "You don't have access", description: (_c = forbidden === null || forbidden === void 0 ? void 0 : forbidden.description) !== null && _c !== void 0 ? _c : "Ask an administrator to give you access to view this.", action: forbidden === null || forbidden === void 0 ? void 0 : forbidden.action, minH: minH }) }));
|
|
17
|
+
}
|
|
12
18
|
if (hasError(error)) {
|
|
13
19
|
const description = typeof errorDescription === "function" ? errorDescription(error) : errorDescription;
|
|
14
20
|
return (_jsx(ErrorState, { title: errorTitle, description: description, onRetry: onRetry, isRetrying: isRetrying, minH: minH }));
|