pixelize-design-library 2.4.2-beta.59 → 2.4.2-beta.61
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 +110 -13
- package/COMPONENT-GOTCHAS.md +159 -21
- package/DESIGN-GUIDE.md +26 -7
- package/dist/Components/AudioRecorder/AudioRecorder.d.ts +8 -0
- package/dist/Components/AudioRecorder/AudioRecorder.js +169 -0
- package/dist/Components/AudioRecorder/AudioRecorderProps.d.ts +20 -0
- package/dist/Components/AudioRecorder/AudioRecorderProps.js +2 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBar.d.ts +3 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBar.js +43 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBarProps.d.ts +35 -0
- package/dist/Components/BulkSelectionBar/BulkSelectionBarProps.js +2 -0
- package/dist/Components/BulkSelectionBar/index.d.ts +2 -0
- package/dist/Components/BulkSelectionBar/index.js +8 -0
- package/dist/Components/CalendarGrid/CalendarGrid.d.ts +3 -0
- package/dist/Components/CalendarGrid/CalendarGrid.js +173 -0
- package/dist/Components/CalendarGrid/CalendarGridProps.d.ts +54 -0
- package/dist/Components/CalendarGrid/CalendarGridProps.js +2 -0
- package/dist/Components/CalendarGrid/calendarMath.d.ts +49 -0
- package/dist/Components/CalendarGrid/calendarMath.js +178 -0
- package/dist/Components/CircularProgress/CircularProgress.d.ts +4 -0
- package/dist/Components/CircularProgress/CircularProgress.js +39 -0
- package/dist/Components/CircularProgress/CircularProgressProps.d.ts +22 -0
- package/dist/Components/CircularProgress/CircularProgressProps.js +2 -0
- package/dist/Components/CircularProgress/arc.d.ts +12 -0
- package/dist/Components/CircularProgress/arc.js +16 -0
- package/dist/Components/Common/fieldStyles.d.ts +1 -0
- package/dist/Components/Common/fieldStyles.js +2 -1
- package/dist/Components/Drawer/Drawer.d.ts +1 -1
- package/dist/Components/Drawer/Drawer.js +4 -2
- package/dist/Components/Drawer/DrawerProps.d.ts +3 -1
- package/dist/Components/EmptyState/EmptyState.js +2 -1
- package/dist/Components/EmptyState/EmptyStateProps.d.ts +2 -2
- package/dist/Components/FormDrawer/FormDrawer.d.ts +2 -0
- package/dist/Components/FormDrawer/FormDrawer.js +97 -0
- package/dist/Components/FormDrawer/FormDrawerProps.d.ts +55 -0
- package/dist/Components/FormDrawer/FormDrawerProps.js +2 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.d.ts +1 -1
- package/dist/Components/LauncherTrigger/LauncherTrigger.js +8 -1
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.d.ts +2 -0
- package/dist/Components/Modal/Modal.d.ts +1 -1
- package/dist/Components/Modal/Modal.js +4 -2
- package/dist/Components/Modal/ModalProps.d.ts +3 -1
- package/dist/Components/Modal/warnDroppedSlotChildren.d.ts +2 -0
- package/dist/Components/Modal/warnDroppedSlotChildren.js +45 -0
- package/dist/Components/NavLauncher/LauncherTabs.d.ts +18 -0
- package/dist/Components/NavLauncher/LauncherTabs.js +64 -0
- package/dist/Components/NavLauncher/NavLauncher.d.ts +1 -1
- package/dist/Components/NavLauncher/NavLauncher.js +268 -61
- package/dist/Components/NavLauncher/NavLauncherProps.d.ts +29 -10
- package/dist/Components/NavLauncher/NewTabLink.d.ts +2 -2
- package/dist/Components/NavLauncher/NewTabLink.js +7 -3
- package/dist/Components/NavLauncher/launcherParts.d.ts +64 -2
- package/dist/Components/NavLauncher/launcherParts.js +103 -13
- package/dist/Components/NavLauncher/resultNavigation.d.ts +3 -0
- package/dist/Components/NavLauncher/resultNavigation.js +65 -0
- package/dist/Components/NavLauncher/revealStyles.d.ts +1 -1
- package/dist/Components/NavLauncher/revealStyles.js +2 -2
- package/dist/Components/NavigationBar/NavigationBar.js +2 -1
- package/dist/Components/NavigationBar/NavigationBarProps.d.ts +1 -0
- package/dist/Components/OrgSwitcher/OrgSwitcher.js +18 -6
- package/dist/Components/OrgSwitcher/OrgSwitcherProps.d.ts +4 -0
- package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +5 -0
- package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewerProps.d.ts +1 -1
- package/dist/Components/QueryState/QueryStateBoundary.d.ts +2 -2
- package/dist/Components/QueryState/QueryStateBoundary.js +9 -3
- package/dist/Components/QueryState/QueryStateProps.d.ts +19 -2
- package/dist/Components/SectionRail/SectionRail.d.ts +3 -0
- package/dist/Components/SectionRail/SectionRail.js +49 -0
- package/dist/Components/SectionRail/SectionRailProps.d.ts +23 -0
- package/dist/Components/SectionRail/SectionRailProps.js +2 -0
- package/dist/Components/SectionRail/index.d.ts +2 -0
- package/dist/Components/SectionRail/index.js +8 -0
- package/dist/Components/SegmentedControl/SegmentedControl.js +9 -14
- package/dist/Components/SegmentedControl/segmentedInk.d.ts +0 -2
- package/dist/Components/SegmentedControl/segmentedInk.js +1 -5
- package/dist/Components/StatCard/StatCard.d.ts +1 -1
- package/dist/Components/StatCard/StatCard.js +6 -2
- package/dist/Components/StatCard/StatCardProps.d.ts +3 -0
- package/dist/Components/StatusTag/StatusTag.d.ts +4 -0
- package/dist/Components/StatusTag/StatusTag.js +24 -0
- package/dist/Components/StatusTag/StatusTagProps.d.ts +20 -0
- package/dist/Components/StatusTag/StatusTagProps.js +2 -0
- package/dist/Components/Table/Table.d.ts +1 -1
- package/dist/Components/Table/Table.js +6 -2
- package/dist/Components/Table/TableProps.d.ts +20 -0
- package/dist/Components/Table/components/TableBody.d.ts +1 -1
- package/dist/Components/Table/components/TableBody.js +43 -18
- package/dist/Components/Table/components/TableHeader.d.ts +1 -1
- package/dist/Components/Table/components/TableHeader.js +7 -5
- package/dist/Components/Table/components/rowDetail.d.ts +32 -0
- package/dist/Components/Table/components/rowDetail.js +20 -0
- package/dist/Components/Table/hooks/useRowExpansion.d.ts +7 -0
- package/dist/Components/Table/hooks/useRowExpansion.js +27 -0
- package/dist/Components/Tabs/Tabs.d.ts +1 -1
- package/dist/Components/Tabs/Tabs.js +15 -2
- package/dist/Components/Tabs/TabsProps.d.ts +6 -2
- package/dist/Components/Tabs/components/Tab.js +4 -33
- package/dist/Components/Tabs/components/TabLinkList.d.ts +7 -0
- package/dist/Components/Tabs/components/TabLinkList.js +34 -0
- package/dist/Components/Tabs/useTabAppearance.d.ts +17 -0
- package/dist/Components/Tabs/useTabAppearance.js +67 -0
- package/dist/Components/Tag/Tag.js +11 -1
- package/dist/Components/Tag/TagProps.d.ts +4 -0
- package/dist/Components/Tag/tagDot.d.ts +3 -0
- package/dist/Components/Tag/tagDot.js +21 -0
- package/dist/esm/Components/AudioRecorder/AudioRecorder.js +161 -0
- package/dist/esm/Components/AudioRecorder/AudioRecorderProps.js +1 -0
- package/dist/esm/Components/BulkSelectionBar/BulkSelectionBar.js +38 -0
- package/dist/esm/Components/BulkSelectionBar/BulkSelectionBarProps.js +1 -0
- package/dist/esm/Components/BulkSelectionBar/index.js +1 -0
- package/dist/esm/Components/CalendarGrid/CalendarGrid.js +168 -0
- package/dist/esm/Components/CalendarGrid/CalendarGridProps.js +1 -0
- package/dist/esm/Components/CalendarGrid/calendarMath.js +155 -0
- package/dist/esm/Components/CircularProgress/CircularProgress.js +37 -0
- package/dist/esm/Components/CircularProgress/CircularProgressProps.js +1 -0
- package/dist/esm/Components/CircularProgress/arc.js +11 -0
- package/dist/esm/Components/Common/fieldStyles.js +2 -1
- package/dist/esm/Components/Drawer/Drawer.js +4 -2
- package/dist/esm/Components/EmptyState/EmptyState.js +2 -1
- package/dist/esm/Components/FormDrawer/FormDrawer.js +58 -0
- package/dist/esm/Components/FormDrawer/FormDrawerProps.js +1 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTrigger.js +5 -1
- package/dist/esm/Components/Modal/Modal.js +4 -2
- package/dist/esm/Components/Modal/warnDroppedSlotChildren.js +38 -0
- package/dist/esm/Components/NavLauncher/LauncherTabs.js +58 -0
- package/dist/esm/Components/NavLauncher/NavLauncher.js +270 -63
- package/dist/esm/Components/NavLauncher/NewTabLink.js +4 -3
- package/dist/esm/Components/NavLauncher/launcherParts.js +98 -14
- package/dist/esm/Components/NavLauncher/resultNavigation.js +61 -0
- package/dist/esm/Components/NavLauncher/revealStyles.js +2 -2
- package/dist/esm/Components/NavigationBar/NavigationBar.js +2 -1
- package/dist/esm/Components/OrgSwitcher/OrgSwitcher.js +16 -7
- package/dist/esm/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +5 -0
- package/dist/esm/Components/QueryState/QueryStateBoundary.js +10 -4
- package/dist/esm/Components/SectionRail/SectionRail.js +44 -0
- package/dist/esm/Components/SectionRail/SectionRailProps.js +1 -0
- package/dist/esm/Components/SectionRail/index.js +1 -0
- package/dist/esm/Components/SegmentedControl/SegmentedControl.js +11 -16
- package/dist/esm/Components/SegmentedControl/segmentedInk.js +0 -3
- package/dist/esm/Components/StatCard/StatCard.js +6 -2
- package/dist/esm/Components/StatusTag/StatusTag.js +19 -0
- package/dist/esm/Components/StatusTag/StatusTagProps.js +1 -0
- package/dist/esm/Components/Table/Table.js +7 -3
- package/dist/esm/Components/Table/components/TableBody.js +43 -18
- package/dist/esm/Components/Table/components/TableHeader.js +7 -5
- package/dist/esm/Components/Table/components/rowDetail.js +14 -0
- package/dist/esm/Components/Table/hooks/useRowExpansion.js +23 -0
- package/dist/esm/Components/Tabs/Tabs.js +15 -2
- package/dist/esm/Components/Tabs/components/Tab.js +4 -33
- package/dist/esm/Components/Tabs/components/TabLinkList.js +29 -0
- package/dist/esm/Components/Tabs/useTabAppearance.js +63 -0
- package/dist/esm/Components/Tag/Tag.js +12 -2
- package/dist/esm/Components/Tag/tagDot.js +17 -0
- package/dist/esm/index.js +7 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +18 -4
- package/package.json +1 -1
|
@@ -1,23 +1,88 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Flex, Heading, Text } from "@chakra-ui/react";
|
|
3
3
|
import { Lock, Star } from "lucide-react";
|
|
4
|
-
import { Fragment, } from "react";
|
|
5
|
-
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
4
|
+
import { createContext, Fragment, useContext, } from "react";
|
|
5
|
+
import { FOCUS_VISIBLE_OVER_STATE, focusVisibleStyles, } from "../../Theme/chakra/focusRing.styles.js";
|
|
6
6
|
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
7
|
+
import { AA_NON_TEXT, liftToContrast, } from "../../Theme/tokens/builders/outlineRung.js";
|
|
7
8
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
9
|
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
9
10
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
11
|
+
import OverflowToolTip from "../ToolTip/OverflowToolTip.js";
|
|
10
12
|
import AppMark from "../AppSwitcher/AppMark.js";
|
|
11
13
|
import { highlightSegments } from "./match.js";
|
|
12
14
|
import NewTabLink from "./NewTabLink.js";
|
|
13
15
|
import PinToggle from "./PinToggle.js";
|
|
14
16
|
import { revealStyles } from "./revealStyles.js";
|
|
15
17
|
export const ITEM_SELECTOR = "[data-launcher-item]";
|
|
18
|
+
const TouchDensityContext = createContext(false);
|
|
19
|
+
export const TouchDensity = TouchDensityContext.Provider;
|
|
20
|
+
export const useTouchDensity = () => useContext(TouchDensityContext);
|
|
16
21
|
export const isPlainClick = (event) => event.button === 0 &&
|
|
17
22
|
!event.metaKey &&
|
|
18
23
|
!event.ctrlKey &&
|
|
19
24
|
!event.shiftKey &&
|
|
20
25
|
!event.altKey;
|
|
26
|
+
const ROW_FOCUS = "data-row-focus";
|
|
27
|
+
const ROW_PR = "--row-pr";
|
|
28
|
+
const REVEALED = "[data-group]:hover &, [data-group]:focus-within &, [data-group][data-reveal=true] &";
|
|
29
|
+
const NARROW_ROW = "@container launcher-row (max-width: 219px)";
|
|
30
|
+
export const WIDE_ROW = "@container launcher-row (min-width: 300px)";
|
|
31
|
+
export const ROW_CONTAINER = {
|
|
32
|
+
containerType: "inline-size",
|
|
33
|
+
containerName: "launcher-row",
|
|
34
|
+
};
|
|
35
|
+
export const activeRowStyle = (colors) => {
|
|
36
|
+
const fill = listRowBackgrounds(colors).active;
|
|
37
|
+
const edge = liftToContrast(liftToContrast(colors.primary[500], fill, AA_NON_TEXT), colors.surfaceRaised, AA_NON_TEXT);
|
|
38
|
+
return { edge, fill };
|
|
39
|
+
};
|
|
40
|
+
export const activeRowSurface = (colors) => {
|
|
41
|
+
const { edge, fill } = activeRowStyle(colors);
|
|
42
|
+
return {
|
|
43
|
+
backgroundColor: fill,
|
|
44
|
+
boxShadow: `inset 0 0 0 1px ${edge}`,
|
|
45
|
+
outline: "2px solid transparent",
|
|
46
|
+
outlineOffset: "-2px",
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export const titleInset = (base, open, chip = 0) => ({
|
|
50
|
+
paddingRight: `var(${ROW_PR})`,
|
|
51
|
+
[ROW_PR]: `${base}px`,
|
|
52
|
+
[REVEALED]: { [ROW_PR]: `${open}px` },
|
|
53
|
+
...(chip
|
|
54
|
+
? {
|
|
55
|
+
[WIDE_ROW]: {
|
|
56
|
+
"[data-group][data-reveal=true] &": { [ROW_PR]: `${open + chip}px` },
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
: {}),
|
|
60
|
+
[NARROW_ROW]: { [REVEALED]: { [ROW_PR]: `${base}px` } },
|
|
61
|
+
});
|
|
62
|
+
const markRowFocus = (event, isOn) => { var _a; return (_a = event.currentTarget.closest("[data-group]")) === null || _a === void 0 ? void 0 : _a.toggleAttribute(ROW_FOCUS, isOn); };
|
|
63
|
+
export const useRowFocus = (isBordered = false) => {
|
|
64
|
+
const { colors } = useCustomTheme();
|
|
65
|
+
const { edge, fill } = activeRowStyle(colors);
|
|
66
|
+
const lit = isBordered
|
|
67
|
+
? { backgroundColor: fill, borderColor: edge }
|
|
68
|
+
: activeRowSurface(colors);
|
|
69
|
+
return {
|
|
70
|
+
sx: { [`&[${ROW_FOCUS}]`]: lit },
|
|
71
|
+
primary: {
|
|
72
|
+
onFocus: (event) => markRowFocus(event, event.currentTarget.matches(":focus-visible")),
|
|
73
|
+
onBlur: (event) => markRowFocus(event, false),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export const stretchedLink = (radius) => ({
|
|
78
|
+
outline: "none",
|
|
79
|
+
_after: {
|
|
80
|
+
content: '""',
|
|
81
|
+
position: "absolute",
|
|
82
|
+
inset: 0,
|
|
83
|
+
borderRadius: radius,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
21
86
|
export const useRowHover = () => {
|
|
22
87
|
const { colors } = useCustomTheme();
|
|
23
88
|
const hover = listRowBackgrounds(colors).active;
|
|
@@ -47,10 +112,20 @@ export function RowIcon({ icon: Icon, size, stroke = 1.75, mt }) {
|
|
|
47
112
|
}
|
|
48
113
|
export function Highlight({ text, query }) {
|
|
49
114
|
const { colors } = useCustomTheme();
|
|
50
|
-
return (_jsx(_Fragment, { children: highlightSegments(text, query).map((segment, i) => segment.isMatch ? (_jsx(Box, { as: "mark", bg:
|
|
115
|
+
return (_jsx(_Fragment, { children: highlightSegments(text, query).map((segment, i) => segment.isMatch ? (_jsx(Box, { as: "mark", bg: "transparent", color: "inherit", fontWeight: 650, textDecoration: "underline", textDecorationColor: colors.primary.opacity[48], textDecorationThickness: "1.5px", textUnderlineOffset: "2px", children: segment.text }, i)) : (_jsx(Fragment, { children: segment.text }, i))) }));
|
|
51
116
|
}
|
|
52
117
|
export function RowActions({ children }) {
|
|
53
|
-
|
|
118
|
+
const { colors } = useCustomTheme();
|
|
119
|
+
const isTouch = useTouchDensity();
|
|
120
|
+
const revealed = REVEALED.replace(/ &/g, " > &");
|
|
121
|
+
return (_jsx(Flex, { sx: {
|
|
122
|
+
[NARROW_ROW]: {
|
|
123
|
+
[revealed]: {
|
|
124
|
+
backgroundColor: activeRowStyle(colors).fill,
|
|
125
|
+
borderRadius: "6px",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}, position: "absolute", top: isTouch ? "12px" : "7px", right: "4px", h: "19px", align: "center", gap: "2px", zIndex: 1, children: children }));
|
|
54
129
|
}
|
|
55
130
|
export function RowTip({ text }) {
|
|
56
131
|
const { colors } = useCustomTheme();
|
|
@@ -59,19 +134,23 @@ export function RowTip({ text }) {
|
|
|
59
134
|
export function ModuleRow({ module, keyScreens, isPinned, onTogglePin, pinId, labels, link, }) {
|
|
60
135
|
const { colors } = useCustomTheme();
|
|
61
136
|
const hover = useRowHover();
|
|
137
|
+
const focus = useRowFocus();
|
|
62
138
|
const ring = focusVisibleStyles(colors);
|
|
139
|
+
const isTouch = useTouchDensity();
|
|
63
140
|
const base = typeof module.badge === "number" || module.badge ? 24 : 0;
|
|
64
141
|
const open = base + (onTogglePin ? 46 : 24);
|
|
65
|
-
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "flex-start", gap: "10px", minH: "34px", pl: "8px", pr: "4px", pt: "7px", pb: "5px", borderRadius: "8px", transition: transitionFor(["background-color"]), _hover: hover._hover, _focusWithin: hover._focusWithin, children: [_jsx(RowIcon, { icon: module.icon, size: 16, mt: "2px" }), _jsxs(Flex, { direction: "column", flex: 1, minW: 0, children: [_jsxs(Flex, { align: "center", gap: "6px", h: "19px", minW: 0,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
142
|
+
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "flex-start", gap: "10px", minH: isTouch ? "44px" : "34px", pl: "8px", pr: "4px", pt: isTouch ? "12px" : "7px", pb: isTouch ? "8px" : "5px", borderRadius: "8px", transition: transitionFor(["background-color"]), _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: {
|
|
143
|
+
textDecoration: "underline",
|
|
144
|
+
textUnderlineOffset: "2px",
|
|
145
|
+
}, 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), tip: labels.newTabTip, linkAs: link.linkAs })] }), onTogglePin ? (_jsx(RowTip, { text: isPinned ? labels.unpinTip : labels.pinTip })) : null] }));
|
|
69
146
|
}
|
|
70
147
|
export function RailRow({ screen, module, link, isStrong = false, trailing, pinId, }) {
|
|
71
148
|
var _a;
|
|
72
149
|
const { colors } = useCustomTheme();
|
|
73
150
|
const hover = useRowHover();
|
|
74
|
-
|
|
151
|
+
const focus = useRowFocus();
|
|
152
|
+
const isTouch = useTouchDensity();
|
|
153
|
+
return (_jsxs(Flex, { "data-group": true, position: "relative", align: "center", gap: "10px", h: isTouch ? "44px" : "32px", pl: "8px", pr: "4px", borderRadius: "8px", transition: transitionFor(["background-color"]), _hover: hover._hover, _focusWithin: hover._focusWithin, sx: focus.sx, children: [_jsx(RowIcon, { icon: (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon, size: 15 }), _jsx(OverflowToolTip, { label: screen.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": pinId, onClick: link.onPlainClick, flex: 1, minW: 0, fontSize: "13px", fontWeight: isStrong ? 500 : 400, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("8px"), children: screen.label }) }), _jsx(Flex, { position: "relative", zIndex: 1, align: "center", gap: "2px", children: trailing })] }));
|
|
75
154
|
}
|
|
76
155
|
export function PinTextButton({ label, text, onToggle }) {
|
|
77
156
|
const { colors } = useCustomTheme();
|
|
@@ -85,13 +164,15 @@ export function PinnedTile({ screen, module, link, labels, onTogglePin, }) {
|
|
|
85
164
|
var _a;
|
|
86
165
|
const { colors } = useCustomTheme();
|
|
87
166
|
const Icon = (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon;
|
|
88
|
-
|
|
167
|
+
const focus = useRowFocus(true);
|
|
168
|
+
const isTouch = useTouchDensity();
|
|
169
|
+
return (_jsxs(Flex, { "data-group": true, "data-nav-cell": true, position: "relative", align: "center", gap: "8px", h: isTouch ? "44px" : "36px", pl: "9px", pr: "4px", borderRadius: "9px", borderWidth: "1px", borderColor: colors.boxborder[200], bg: colors.surfaceRaised, transition: transitionFor(["border-color", "background-color"]), _hover: { borderColor: colors.gray[300] }, sx: focus.sx, children: [Icon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, color: colors.accentText, children: _jsx(Icon, { size: 15, strokeWidth: 1.8, "aria-hidden": true }) })) : null, _jsx(OverflowToolTip, { label: screen.label, placement: "top-start", children: _jsx(Box, { as: link.linkAs, href: screen.href, "data-launcher-item": true, ...focus.primary, "data-pin-id": onTogglePin ? screen.id : undefined, onClick: link.onPlainClick, flex: 1, minW: 0, fontSize: "13px", fontWeight: 500, color: colors.text[900], noOfLines: 1, borderRadius: "sm", sx: stretchedLink("9px"), children: screen.label }) }), _jsx(CountBadge, { value: screen.badge, size: "tile" }), onTogglePin ? (_jsx(Box, { position: "relative", zIndex: 1, flexShrink: 0, w: "0", overflow: "hidden", transition: transitionFor(["width"]), _groupHover: { w: "22px" }, _groupFocusWithin: { w: "22px" }, children: _jsx(PinToggle, { isPinned: true, size: 12, label: labels.unpin(screen.label), title: labels.unpinTip, onToggle: onTogglePin }) })) : null] }));
|
|
89
170
|
}
|
|
90
|
-
export function AppsSection({ apps, hues, currentAppId, heading, onSelect, }) {
|
|
171
|
+
export function AppsSection({ apps, hues, currentAppId, heading, hideHeading = false, onSelect, }) {
|
|
91
172
|
const { colors } = useCustomTheme();
|
|
92
173
|
const rows = listRowBackgrounds(colors);
|
|
93
|
-
const
|
|
94
|
-
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) => {
|
|
174
|
+
const rowRing = activeRowSurface(colors);
|
|
175
|
+
return (_jsxs(Box, { children: [hideHeading ? null : _jsx(SectionHeader, { label: heading, isRail: true, hasCount: false }), _jsx(Box, { as: "ul", listStyleType: "none", m: 0, p: 0, "aria-label": heading, children: apps.map((app, index) => {
|
|
95
176
|
var _a;
|
|
96
177
|
const isCurrent = app.id === currentAppId;
|
|
97
178
|
const interactive = !isCurrent && !app.locked;
|
|
@@ -105,6 +186,9 @@ export function AppsSection({ apps, hues, currentAppId, heading, onSelect, }) {
|
|
|
105
186
|
}
|
|
106
187
|
: {}), "aria-current": isCurrent ? "true" : undefined, title: app.locked
|
|
107
188
|
? ((_a = app.lockedReason) !== null && _a !== void 0 ? _a : `${app.name} is not available on your plan`)
|
|
108
|
-
: undefined, "data-app-locked": app.locked ? "true" : undefined, align: "center", gap: 3, minH: "44px", px: 2, py: 1, borderRadius: "8px", textDecoration: "none", cursor: interactive ? "pointer" : "default", bg: isCurrent ? rows.selected : "transparent", transition: transitionFor(["background-color"]), _hover: interactive ? { bg: rows.active } : undefined, sx:
|
|
189
|
+
: 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: {
|
|
190
|
+
_focusVisible: rowRing,
|
|
191
|
+
[FOCUS_VISIBLE_OVER_STATE]: rowRing,
|
|
192
|
+
}, children: [_jsx(AppMark, { app: app, hue: hues[index], boxSize: "28px", iconSize: 15, muted: app.locked }), _jsx(OverflowToolTip, { label: app.name, placement: "top-start", children: _jsx(Text, { flex: 1, minW: 0, fontSize: "sm", fontWeight: "medium", noOfLines: 1, color: app.locked ? colors.textMuted : colors.text[900], children: app.name }) }), app.locked ? (_jsx(Box, { as: Lock, size: 14, color: colors.textMuted, flexShrink: 0, "aria-hidden": true })) : null] }) }, app.id || app.name));
|
|
109
193
|
}) })] }));
|
|
110
194
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const locate = (sizes, index) => {
|
|
2
|
+
let start = 0;
|
|
3
|
+
for (let group = 0; group < sizes.length; group += 1) {
|
|
4
|
+
if (index < start + sizes[group])
|
|
5
|
+
return { group, pos: index - start, start };
|
|
6
|
+
start += sizes[group];
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
group: sizes.length - 1,
|
|
10
|
+
pos: 0,
|
|
11
|
+
start: start - sizes[sizes.length - 1],
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const startOf = (sizes, group) => sizes.slice(0, group).reduce((sum, size) => sum + size, 0);
|
|
15
|
+
const stepVertical = (sizes, columns, index, down, wrap) => {
|
|
16
|
+
const { group, pos, start } = locate(sizes, index);
|
|
17
|
+
const size = sizes[group];
|
|
18
|
+
const column = pos % columns;
|
|
19
|
+
if (down) {
|
|
20
|
+
if (pos + columns < size)
|
|
21
|
+
return index + columns;
|
|
22
|
+
if (Math.floor(pos / columns) < Math.floor((size - 1) / columns))
|
|
23
|
+
return start + size - 1;
|
|
24
|
+
const next = group + 1 < sizes.length ? group + 1 : wrap ? 0 : -1;
|
|
25
|
+
if (next < 0)
|
|
26
|
+
return index;
|
|
27
|
+
return startOf(sizes, next) + Math.min(column, sizes[next] - 1);
|
|
28
|
+
}
|
|
29
|
+
if (pos - columns >= 0)
|
|
30
|
+
return index - columns;
|
|
31
|
+
const prev = group > 0 ? group - 1 : wrap ? sizes.length - 1 : -1;
|
|
32
|
+
if (prev < 0)
|
|
33
|
+
return index;
|
|
34
|
+
const lastRow = Math.floor((sizes[prev] - 1) / columns);
|
|
35
|
+
return (startOf(sizes, prev) + Math.min(sizes[prev] - 1, lastRow * columns + column));
|
|
36
|
+
};
|
|
37
|
+
/** Next flat result index for a key, following the visual grid: rows by `columns` inside a group, reading order across columns. */
|
|
38
|
+
export const moveResult = (sizes, columns, index, key, pageRows = 1) => {
|
|
39
|
+
const total = sizes.reduce((sum, size) => sum + size, 0);
|
|
40
|
+
if (total === 0)
|
|
41
|
+
return 0;
|
|
42
|
+
switch (key) {
|
|
43
|
+
case "ArrowDown":
|
|
44
|
+
case "ArrowUp":
|
|
45
|
+
return stepVertical(sizes, columns, index, key === "ArrowDown", true);
|
|
46
|
+
case "ArrowRight":
|
|
47
|
+
return Math.min(total - 1, index + 1);
|
|
48
|
+
case "ArrowLeft":
|
|
49
|
+
return Math.max(0, index - 1);
|
|
50
|
+
case "Home":
|
|
51
|
+
return 0;
|
|
52
|
+
case "End":
|
|
53
|
+
return total - 1;
|
|
54
|
+
default: {
|
|
55
|
+
let next = index;
|
|
56
|
+
for (let i = 0; i < pageRows; i += 1)
|
|
57
|
+
next = stepVertical(sizes, columns, next, key === "PageDown", false);
|
|
58
|
+
return next;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
2
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. */
|
|
3
|
+
/** Shows a row affordance on row hover, row focus-within or its own keyboard focus, and always on touch, where it also grows to a 32px hit area. */
|
|
4
4
|
export const revealStyles = (colors) => {
|
|
5
5
|
const ring = focusVisibleStyles(colors);
|
|
6
6
|
return {
|
|
@@ -9,7 +9,7 @@ export const revealStyles = (colors) => {
|
|
|
9
9
|
_groupHover: { opacity: 1 },
|
|
10
10
|
_groupFocusWithin: { opacity: 1 },
|
|
11
11
|
"[data-reveal=true] &": { opacity: 1 },
|
|
12
|
-
"@media (hover: none)": { opacity: 1 },
|
|
12
|
+
"@media (hover: none)": { opacity: 1, minWidth: "32px", width: "32px", height: "32px" },
|
|
13
13
|
...reducedMotionSx(),
|
|
14
14
|
};
|
|
15
15
|
};
|
|
@@ -6,6 +6,7 @@ import { accentTextOnCanvas, isDarkCanvas } from "../../Theme/tokens/builders/ac
|
|
|
6
6
|
import { resolveHoverTint } from "../../Theme/tokens/builders/outlineRung.js";
|
|
7
7
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
8
|
import { resolveStatusTone } from "../../Theme/tokens/builders/statusTone.js";
|
|
9
|
+
import ToolTip from "../ToolTip/ToolTip.js";
|
|
9
10
|
import PersonChip from "../PersonChip/PersonChip.js";
|
|
10
11
|
import { CircleArrowLeft, LogOut, PanelLeftClose, PanelRightClose, } from "lucide-react";
|
|
11
12
|
// Roomy enough to hover without aiming: the glyph is only 1.25rem.
|
|
@@ -46,7 +47,7 @@ export default function NavBar({ userAvathar, userName, userRole, navMenu, moreI
|
|
|
46
47
|
_focus: { bg: menuHoverBg },
|
|
47
48
|
_active: { bg: rowBackgrounds.selectedActive },
|
|
48
49
|
};
|
|
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
|
+
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", gap: 2, children: [_jsxs(Box, { display: "flex", gap: 1.5, alignItems: "center", flex: "1 1 0%", 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, flexShrink: 0, 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", flexShrink: 0, 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", flexShrink: 0, bg: theme.colors.boxborder[200] })] })), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text) && (_jsx(ToolTip, { label: typeof navigationBarText.text === "string" ? navigationBarText.text : "", overflowOnly: true, placement: "bottom", children: _jsx(Text, { flex: "1 1 0%", w: 0, minW: 0, isTruncated: true, 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, sx: { "& > *": { 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
51
|
// Without a cap one long title stretches the whole dropdown; titles truncate instead.
|
|
51
52
|
maxW: "18rem", bg: theme.colors.surfaceRaised,
|
|
52
53
|
// NOTE: Chakra's MenuItem inherits --menu-bg hardcoded to #fff via dead _dark — set it or items stay white.
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Box, Flex, Image, Input, InputGroup, InputLeftElement, Popover, PopoverBody, PopoverContent, PopoverTrigger, Spinner, Text, useDisclosure, } from "@chakra-ui/react";
|
|
4
|
-
import { Building2, Check, ChevronsUpDown, Search } from "lucide-react";
|
|
4
|
+
import { Building2, Check, ChevronDown, ChevronsUpDown, Search } from "lucide-react";
|
|
5
5
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
6
6
|
import { accentTextOnCanvas, onFilled } from "../../Theme/tokens/builders/accentText.js";
|
|
7
7
|
import { chartMode } from "../../Theme/tokens/builders/chartColorsFromTheme.js";
|
|
8
8
|
import { resolveHoverTint } from "../../Theme/tokens/builders/outlineRung.js";
|
|
9
9
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
10
10
|
import { useExclusiveOverlay } from "../../Hooks/useExclusiveOverlay.js";
|
|
11
|
+
import { useMatchMedia } from "../../Hooks/useMatchMedia.js";
|
|
12
|
+
import ToolTip from "../ToolTip/ToolTip.js";
|
|
11
13
|
import { avatarColor, orgInitial, } from "./OrgSwitcherProps.js";
|
|
12
14
|
const sizeMap = {
|
|
13
|
-
sm: { h: "32px", avatar: "22px", font: "0.8rem", sub: "0.65rem", px: 2 },
|
|
14
|
-
md: { h: "40px", avatar: "28px", font: "0.9rem", sub: "0.7rem", px: 3 },
|
|
15
|
-
lg: { h: "48px", avatar: "34px", font: "1rem", sub: "0.78rem", px: 4 },
|
|
15
|
+
sm: { h: "32px", avatarH: "32px", avatar: "22px", font: "0.8rem", sub: "0.65rem", px: 2 },
|
|
16
|
+
md: { h: "40px", avatarH: "36px", avatar: "28px", font: "0.9rem", sub: "0.7rem", px: 3 },
|
|
17
|
+
lg: { h: "48px", avatarH: "48px", avatar: "34px", font: "1rem", sub: "0.78rem", px: 4 },
|
|
16
18
|
};
|
|
19
|
+
const MD_QUERY = "(min-width: 48em)";
|
|
17
20
|
const Avatar = ({ org, boxSize, fontSize, }) => {
|
|
18
21
|
const { colors } = useCustomTheme();
|
|
19
22
|
if (org.logoUrl) {
|
|
@@ -22,9 +25,11 @@ const Avatar = ({ org, boxSize, fontSize, }) => {
|
|
|
22
25
|
const fill = avatarColor(org.name, chartMode(colors));
|
|
23
26
|
return (_jsx(Flex, { align: "center", justify: "center", boxSize: boxSize, borderRadius: "lg", flexShrink: 0, bg: fill, color: onFilled(fill, colors.white, colors.black), fontSize: fontSize, fontWeight: 700, children: orgInitial(org.name) }));
|
|
24
27
|
};
|
|
25
|
-
const OrgSwitcher = ({ organizations, value, onChange, isLoading = false, isSearchable, searchThreshold = 6, triggerVariant = "ghost", size = "md", maxWidth = "200px", menuMinWidth = "280px", placeholder = "Select organization", ariaLabel = "Switch organization", showRole = true, }) => {
|
|
26
|
-
var _a;
|
|
28
|
+
const OrgSwitcher = ({ organizations, value, onChange, isLoading = false, isSearchable, searchThreshold = 6, triggerVariant = "ghost", size = "md", maxWidth = "200px", menuMinWidth = "280px", placeholder = "Select organization", ariaLabel = "Switch organization", showRole = true, display = "full", }) => {
|
|
29
|
+
var _a, _b;
|
|
27
30
|
const theme = useCustomTheme();
|
|
31
|
+
const isMd = useMatchMedia(MD_QUERY, true);
|
|
32
|
+
const avatarOnly = display === "avatar" || (display === "auto" && !isMd);
|
|
28
33
|
const rowBackgrounds = useMemo(() => listRowBackgrounds(theme.colors), [theme.colors]);
|
|
29
34
|
const s = sizeMap[size];
|
|
30
35
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
@@ -85,10 +90,14 @@ const OrgSwitcher = ({ organizations, value, onChange, isLoading = false, isSear
|
|
|
85
90
|
if (org.id !== value)
|
|
86
91
|
onChange(org.id, org);
|
|
87
92
|
};
|
|
93
|
+
const avatarNode = selected ? (_jsx(Avatar, { org: selected, boxSize: s.avatar, fontSize: s.sub })) : (_jsx(Flex, { align: "center", justify: "center", boxSize: s.avatar, borderRadius: "lg", bg: theme.colors.gray[100], color: accentTextOnCanvas(theme.colors.gray, theme.colors.gray[100]), flexShrink: 0, children: _jsx(Building2, { size: 14 }) }));
|
|
94
|
+
const labelGap = s.px === 2 ? 8 : 10;
|
|
95
|
+
const squeezedWidth = `calc(${s.px * 8 + labelGap * 2 + 16}px + ${s.avatar})`;
|
|
96
|
+
const trigger = (_jsxs(Flex, { as: "button", type: "button", "aria-label": avatarOnly && selected ? `${ariaLabel}, ${selected.name}` : ariaLabel, align: "center", justify: avatarOnly ? "center" : undefined, gap: avatarOnly ? "4px" : `${labelGap}px`, h: avatarOnly ? s.avatarH : s.h, px: avatarOnly ? "6px" : s.px, minW: avatarOnly ? undefined : squeezedWidth, flexShrink: avatarOnly ? 0 : 1, borderRadius: "lg", cursor: isLoading ? "default" : "pointer", opacity: isLoading ? 0.6 : 1, pointerEvents: isLoading ? "none" : "auto", transition: "background 0.15s ease", _hover: { bg: triggerVariant === "ghost" ? triggerHoverBg : undefined }, ...triggerStyles, children: [avatarNode, !avatarOnly && (_jsx(Text, { fontSize: s.font, fontWeight: 600, color: theme.colors.gray[700], maxW: maxWidth, minW: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", textAlign: "left", children: (_a = selected === null || selected === void 0 ? void 0 : selected.name) !== null && _a !== void 0 ? _a : placeholder })), isLoading ? (_jsx(Spinner, { size: "xs", thickness: "1.5px", color: theme.colors.accentText, flexShrink: 0 })) : avatarOnly ? (_jsx(Box, { as: ChevronDown, size: 12, color: theme.colors.textMuted, flexShrink: 0, "aria-hidden": "true" })) : (_jsx(Box, { as: ChevronsUpDown, size: 16, color: theme.colors.textMuted, flexShrink: 0 }))] }));
|
|
88
97
|
return (_jsxs(Popover, { isOpen: isOpen, onOpen: handlePopoverOpen, onClose: () => {
|
|
89
98
|
onClose();
|
|
90
99
|
setQuery("");
|
|
91
|
-
}, placement: "bottom-start", initialFocusRef: showSearch ? searchRef : firstOptionRef, isLazy: true, children: [_jsx(
|
|
100
|
+
}, placement: "bottom-start", initialFocusRef: showSearch ? searchRef : firstOptionRef, isLazy: true, children: [avatarOnly ? (_jsx(ToolTip, { label: (_b = selected === null || selected === void 0 ? void 0 : selected.name) !== null && _b !== void 0 ? _b : placeholder, placement: "bottom", isDisabled: isOpen, children: _jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, children: _jsx(PopoverTrigger, { children: trigger }) }) })) : (_jsx(PopoverTrigger, { children: trigger })), _jsx(PopoverContent, { minW: menuMinWidth, maxW: "calc(100vw - 32px)", w: "auto",
|
|
92
101
|
// NOTE: Chakra's --popper-bg is hardcoded white via dead _dark — without an explicit bg the panel stayed white.
|
|
93
102
|
bg: theme.colors.surfaceRaised, borderRadius: "xl", overflow: "hidden", boxShadow: `0 10px 30px ${theme.colors.boxShadow.default}`, _focus: { outline: "none", boxShadow: `0 10px 30px ${theme.colors.boxShadow.default}` }, children: _jsxs(PopoverBody, { p: 0, children: [showSearch && (_jsx(Box, { p: 2, borderBottom: "1px solid", borderColor: theme.colors.gray[100], children: _jsxs(InputGroup, { size: "sm", children: [_jsx(InputLeftElement, { pointerEvents: "none", children: _jsx(Search, { size: 15, color: theme.colors.textMuted }) }), _jsx(Input, { ref: searchRef, placeholder: "Search organizations", value: query, onChange: (e) => setQuery(e.target.value), onKeyDown: (e) => {
|
|
94
103
|
if (e.key === "ArrowDown" && filtered.length > 0) {
|
|
@@ -10,6 +10,11 @@ import { hexToRgb } from "../../Theme/tokens/builders/color.js";
|
|
|
10
10
|
export default function ProfilePhotoViewer({ photoUrl, onPhotoChange, imageWidth = "100px", imageAlt = "Profile Photo", imageObjectFit = "cover", imageBorderRadius = "full", editIconSize = "sm", editIconPositionRight = "0px", editIconPositionBottom = "0px", isRound = true, boxStyle, isEditable = false, isView = false, style, handleIsView, fallbackText, revealOnHover = true, }) {
|
|
11
11
|
var _a, _b, _c, _d, _e;
|
|
12
12
|
const [photo, setPhoto] = useState(photoUrl);
|
|
13
|
+
const [syncedUrl, setSyncedUrl] = useState(photoUrl);
|
|
14
|
+
if (photoUrl !== syncedUrl) {
|
|
15
|
+
setSyncedUrl(photoUrl);
|
|
16
|
+
setPhoto(photoUrl);
|
|
17
|
+
}
|
|
13
18
|
const fileInputRef = useRef(null);
|
|
14
19
|
const theme = useCustomTheme();
|
|
15
20
|
const c = theme.colors;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Flex, VisuallyHidden } from "@chakra-ui/react";
|
|
2
|
+
import { Box, Flex, VisuallyHidden } from "@chakra-ui/react";
|
|
3
|
+
import { Lock } from "lucide-react";
|
|
3
4
|
import EmptyState from "../EmptyState/EmptyState.js";
|
|
4
5
|
import Skeletons from "../Skeletons/Skeletons.js";
|
|
5
6
|
import ErrorState from "./ErrorState.js";
|
|
6
7
|
const DefaultLoading = () => (_jsxs(Flex, { role: "status", direction: "column", gap: 4, w: "100%", py: 2, children: [_jsx(VisuallyHidden, { children: "Loading" }), _jsx(Skeletons, { type: "skeleton", height: 4, width: "40%" }), Array.from({ length: 4 }, (_, i) => (_jsxs(Flex, { direction: "column", gap: 2, children: [_jsx(Skeletons, { type: "skeleton", height: 2.5, width: "100%" }), _jsx(Skeletons, { type: "skeleton", height: 2.5, width: "70%" })] }, i)))] }));
|
|
7
8
|
const hasError = (error) => error !== undefined && error !== null && error !== false;
|
|
8
|
-
/** Renders one of loading / error / empty / children for a content region; agnostic of the fetching library. */
|
|
9
|
-
const QueryStateBoundary = ({ isLoading = false, error, isEmpty = false, loadingFallback, emptyFallback, empty, errorTitle, errorDescription, onRetry, isRetrying, minH = "24rem", children, }) => {
|
|
10
|
-
|
|
9
|
+
/** Renders one of loading / forbidden / error / empty / children for a content region; agnostic of the fetching library. */
|
|
10
|
+
const QueryStateBoundary = ({ isLoading = false, isForbidden = false, forbidden, hasData = false, error, isEmpty = false, loadingFallback, emptyFallback, empty, errorTitle, errorDescription, onRetry, isRetrying, minH = "24rem", children, }) => {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
if (isLoading && !hasData)
|
|
11
13
|
return _jsx(_Fragment, { children: loadingFallback !== null && loadingFallback !== void 0 ? loadingFallback : _jsx(DefaultLoading, {}) });
|
|
14
|
+
const forbiddenNow = typeof isForbidden === "function" ? hasError(error) && isForbidden(error) : isForbidden;
|
|
15
|
+
if (forbiddenNow) {
|
|
16
|
+
return (_jsx(Box, { role: "status", w: "100%", children: _jsx(EmptyState, { colorScheme: "gray", icon: (_a = forbidden === null || forbidden === void 0 ? void 0 : forbidden.icon) !== null && _a !== void 0 ? _a : Lock, title: (_b = forbidden === null || forbidden === void 0 ? void 0 : forbidden.title) !== null && _b !== void 0 ? _b : "You don't have access", description: (_c = forbidden === null || forbidden === void 0 ? void 0 : forbidden.description) !== null && _c !== void 0 ? _c : "Ask an administrator to give you access to view this.", action: forbidden === null || forbidden === void 0 ? void 0 : forbidden.action, minH: minH }) }));
|
|
17
|
+
}
|
|
12
18
|
if (hasError(error)) {
|
|
13
19
|
const description = typeof errorDescription === "function" ? errorDescription(error) : errorDescription;
|
|
14
20
|
return (_jsx(ErrorState, { title: errorTitle, description: description, onRetry: onRetry, isRetrying: isRetrying, minH: minH }));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Box, Flex, Text, VisuallyHidden, useTheme } from "@chakra-ui/react";
|
|
4
|
+
import Select from "../Select/Select.js";
|
|
5
|
+
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
6
|
+
import { focusVisibleRing } from "../../Theme/chakra/focusRing.styles.js";
|
|
7
|
+
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
|
+
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
9
|
+
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
10
|
+
const FALLBACK_BREAKPOINTS = { sm: "30em", md: "48em", lg: "62em" };
|
|
11
|
+
const matchesMinWidth = (query) => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : true;
|
|
12
|
+
const useMinWidth = (minWidth) => {
|
|
13
|
+
const query = `(min-width: ${minWidth})`;
|
|
14
|
+
const [matches, setMatches] = useState(() => matchesMinWidth(query));
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
var _a;
|
|
17
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function")
|
|
18
|
+
return undefined;
|
|
19
|
+
const list = window.matchMedia(query);
|
|
20
|
+
const update = () => setMatches(list.matches);
|
|
21
|
+
update();
|
|
22
|
+
(_a = list.addEventListener) === null || _a === void 0 ? void 0 : _a.call(list, "change", update);
|
|
23
|
+
return () => { var _a; return (_a = list.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(list, "change", update); };
|
|
24
|
+
}, [query]);
|
|
25
|
+
return matches;
|
|
26
|
+
};
|
|
27
|
+
const SectionRail = ({ sections, activeId, onSelect, "aria-label": ariaLabel, dirtyHint, collapseBelow = "md", }) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const { colors } = useCustomTheme();
|
|
30
|
+
const { breakpoints } = useTheme();
|
|
31
|
+
const isRail = useMinWidth((_a = breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints[collapseBelow]) !== null && _a !== void 0 ? _a : FALLBACK_BREAKPOINTS[collapseBelow]);
|
|
32
|
+
const rows = listRowBackgrounds(colors);
|
|
33
|
+
if (!isRail) {
|
|
34
|
+
return (_jsx(Select, { "aria-label": ariaLabel, width: "100%", value: activeId, options: sections.map((section) => ({
|
|
35
|
+
id: section.id,
|
|
36
|
+
label: section.isDirty ? `${section.label} (${dirtyHint})` : section.label,
|
|
37
|
+
})), onChange: (option) => option && onSelect(String(option.id)) }));
|
|
38
|
+
}
|
|
39
|
+
return (_jsx(Flex, { as: "nav", "aria-label": ariaLabel, direction: "column", gap: "2px", children: sections.map((section) => {
|
|
40
|
+
const isActive = section.id === activeId;
|
|
41
|
+
return (_jsxs(Flex, { as: "button", type: "button", align: "center", gap: 2, minH: "2rem", px: 3, py: 1.5, borderRadius: "md", fontSize: "sm", fontWeight: isActive ? 600 : 500, textAlign: "left", "aria-current": isActive ? "true" : undefined, bg: isActive ? rows.selected : "transparent", color: isActive ? colors.accentText : colors.text[800], transition: transitionFor(["background-color", "color"]), _hover: { bg: isActive ? rows.selectedActive : rows.active }, _focusVisible: focusVisibleRing(colors), sx: reducedMotionSx(), onClick: () => onSelect(section.id), children: [section.icon ? (_jsx(Box, { as: "span", "aria-hidden": true, display: "inline-flex", flexShrink: 0, children: section.icon })) : null, _jsx(Text, { as: "span", noOfLines: 1, flex: "1", minW: 0, children: section.label }), section.isDirty ? (_jsxs(_Fragment, { children: [_jsx(Box, { as: "span", "aria-hidden": true, boxSize: "6px", borderRadius: "full", flexShrink: 0, bg: colors.semanticText.warning }), _jsx(VisuallyHidden, { children: dirtyHint })] })) : null] }, section.id));
|
|
42
|
+
}) }));
|
|
43
|
+
};
|
|
44
|
+
export default SectionRail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SectionRail } from "./SectionRail.js";
|
|
@@ -5,13 +5,13 @@ import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
|
5
5
|
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
6
6
|
import { BUTTON_SIZES } from "../../Theme/tokens/primitives/controlSizes.js";
|
|
7
7
|
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
8
|
-
import { FOCUS_VISIBLE_OVER_STATE } from "../../Theme/chakra/focusRing.styles.js";
|
|
8
|
+
import { FOCUS_VISIBLE_OVER_STATE, focusRingShadow, focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
9
9
|
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
10
10
|
import { AA_NORMAL_TEXT } from "../../Theme/tokens/builders/accentText.js";
|
|
11
11
|
import { liftToContrast } from "../../Theme/tokens/builders/outlineRung.js";
|
|
12
12
|
import Tag from "../Tag/Tag.js";
|
|
13
13
|
import { useSlidingPill } from "./useSlidingPill.js";
|
|
14
|
-
import {
|
|
14
|
+
import { segmentedPlateEdge, segmentedRestInk, segmentedSelectedSurface, segmentedTrackSurface, } from "./segmentedInk.js";
|
|
15
15
|
const TRACK_PADDING = "0.125rem";
|
|
16
16
|
const UNDERLINE_WIDTH = "0.0625rem";
|
|
17
17
|
const SLIDE = transitionFor(["transform", "width"], "base");
|
|
@@ -37,18 +37,17 @@ export default function SegmentedControl({ options, value, onChange, size = "sm"
|
|
|
37
37
|
const segmentH = `calc(${control.height} - ${isUnderlineSlide ? UNDERLINE_WIDTH : `2 * ${TRACK_PADDING}`})`;
|
|
38
38
|
// Concentric: an inset child keeping the parent's radius bulges at the corners.
|
|
39
39
|
const innerRadius = isUnderlineSlide ? "none" : `calc(${radii.lg} - ${TRACK_PADDING})`;
|
|
40
|
-
const focusShadow = segmentedFocusShadow(colors, trackSurface);
|
|
41
40
|
// Inset, never a border: a border consumes the content box and the absolute pill stops centring.
|
|
42
41
|
const plateEdge = isBrandSlide
|
|
43
42
|
? `inset 0 0 0 1px ${segmentedPlateEdge(colors, surface)}`
|
|
44
43
|
: undefined;
|
|
45
|
-
//
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
44
|
+
// underlineSlide has no track chrome to carry the ring, so there the segment wears Button's own.
|
|
45
|
+
const noRing = { outline: "2px solid transparent", outlineOffset: "2px" };
|
|
46
|
+
const segmentFocus = isUnderlineSlide
|
|
47
|
+
? focusVisibleStyles(colors)
|
|
48
|
+
: { _focusVisible: noRing, [FOCUS_VISIBLE_OVER_STATE]: noRing };
|
|
49
|
+
const ring = focusRingShadow(colors);
|
|
50
|
+
const trackFocusShadow = plateEdge ? `${plateEdge}, ${ring}` : ring;
|
|
52
51
|
const [showFocus, setShowFocus] = useState(false);
|
|
53
52
|
const selectedIndex = options.findIndex((o) => o.value === value);
|
|
54
53
|
const enabled = options.reduce((acc, o, i) => (o.isDisabled ? acc : [...acc, i]), []);
|
|
@@ -90,7 +89,7 @@ export default function SegmentedControl({ options, value, onChange, size = "sm"
|
|
|
90
89
|
selectAt(enabled[enabled.length - 1]);
|
|
91
90
|
}
|
|
92
91
|
};
|
|
93
|
-
return (_jsxs(Flex, { ref: trackRef, role: "radiogroup", "aria-label": ariaLabel, "aria-orientation": isVertical ? "vertical" : undefined, onKeyDown: handleKeyDown, onFocus: (event) => setShowFocus(event.target.matches(":focus-visible")), onBlur: () => setShowFocus(false), boxShadow: showFocus && !isUnderlineSlide ?
|
|
92
|
+
return (_jsxs(Flex, { ref: trackRef, role: "radiogroup", "aria-label": ariaLabel, "aria-orientation": isVertical ? "vertical" : undefined, onKeyDown: handleKeyDown, onFocus: (event) => setShowFocus(event.target.matches(":focus-visible")), onBlur: () => setShowFocus(false), boxShadow: showFocus && !isUnderlineSlide ? trackFocusShadow : plateEdge, position: "relative", display: "inline-flex", flexDirection: isVertical ? "column" : "row", align: isVertical ? "stretch" : "center", gap: isUnderlineSlide ? "0" : TRACK_PADDING, p: isUnderlineSlide ? "0" : TRACK_PADDING, h: isVertical ? "fit-content" : control.height, boxSizing: "border-box", borderRadius: isUnderlineSlide ? "none" : "lg", borderBottom: isUnderlineSlide && !isVertical ? `${UNDERLINE_WIDTH} solid ${colors.boxborder[200]}` : undefined, borderLeft: isUnderlineSlide && isVertical ? `${UNDERLINE_WIDTH} solid ${colors.boxborder[200]}` : undefined, bg: isUnderlineSlide ? "transparent" : trackSurface, w: isFullWidth ? "100%" : "fit-content", minW: "max-content", children: [isBrandSlide && pill && (_jsx(Box, { "aria-hidden": "true", position: "absolute", top: isVertical ? 0 : TRACK_PADDING, left: isVertical ? TRACK_PADDING : 0, right: isVertical ? TRACK_PADDING : undefined, h: segmentH, w: isVertical ? undefined : `${pill.width}px`, borderRadius: innerRadius, bg: brandFill.fill, boxShadow: `0 0.125rem 0.5rem ${colors.boxShadow.primary}`, transform: isVertical ? `translateY(${pill.top}px)` : `translateX(${pill.left}px)`, transition: SLIDE, sx: reducedMotionSx() })), isUnderlineSlide && pill && (_jsx(Box, { "aria-hidden": "true", position: "absolute", bottom: isVertical ? undefined : "-0.0625rem", left: isVertical ? "-0.0625rem" : 0, top: isVertical ? 0 : undefined, h: isVertical ? segmentH : "0.125rem", w: isVertical ? "0.125rem" : `${pill.width}px`, borderRadius: "full", bg: colors.primary[500], transform: isVertical ? `translateY(${pill.top}px)` : `translateX(${pill.left}px)`, transition: SLIDE, sx: reducedMotionSx() })), options.map((option, index) => {
|
|
94
93
|
const isSelected = option.value === value;
|
|
95
94
|
const showShortLabel = isCompact && !!option.shortLabel;
|
|
96
95
|
const displayLabel = showShortLabel ? option.shortLabel : option.label;
|
|
@@ -110,10 +109,6 @@ export default function SegmentedControl({ options, value, onChange, size = "sm"
|
|
|
110
109
|
: restInk
|
|
111
110
|
: isSelected
|
|
112
111
|
? selectedInk
|
|
113
|
-
: restInk, fontSize: control.fontSize, fontWeight: isSelected ? 600 : 500, whiteSpace: "nowrap", opacity: option.isDisabled ? 0.5 : 1, cursor: option.isDisabled ? "not-allowed" : "pointer", transition: transitionFor(["color"]), _hover: option.isDisabled || isSelected ? undefined : { color: hoverInk }, sx: {
|
|
114
|
-
_focusVisible: segmentFocus,
|
|
115
|
-
[FOCUS_VISIBLE_OVER_STATE]: segmentFocus,
|
|
116
|
-
...reducedMotionSx(),
|
|
117
|
-
}, children: [option.icon, displayLabel, option.count != null && (_jsx(Tag, { label: formatCount(option.count), size: COUNT_TAG_SIZE[size], variant: "subtle", colorScheme: "gray" }))] }, option.value));
|
|
112
|
+
: restInk, fontSize: control.fontSize, fontWeight: isSelected ? 600 : 500, whiteSpace: "nowrap", opacity: option.isDisabled ? 0.5 : 1, cursor: option.isDisabled ? "not-allowed" : "pointer", transition: transitionFor(["color"]), _hover: option.isDisabled || isSelected ? undefined : { color: hoverInk }, sx: { ...segmentFocus, ...reducedMotionSx() }, children: [option.icon, displayLabel, option.count != null && (_jsx(Tag, { label: formatCount(option.count), size: COUNT_TAG_SIZE[size], variant: "subtle", colorScheme: "gray" }))] }, option.value));
|
|
118
113
|
})] }));
|
|
119
114
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { focusGlowShadow } from "../../Theme/chakra/focusRing.styles.js";
|
|
2
1
|
import { AA_NON_TEXT, liftToContrast } from "../../Theme/tokens/builders/outlineRung.js";
|
|
3
2
|
import { AA_NORMAL_TEXT } from "../../Theme/tokens/builders/accentText.js";
|
|
4
3
|
/** The surface a segment's label really sits on. */
|
|
@@ -15,8 +14,6 @@ export const segmentedTrackSurface = (variant, colors, surface) => {
|
|
|
15
14
|
export const segmentedSelectedSurface = (variant, colors, trackSurface) => (variant === "default" ? colors.backgroundColor.light : trackSurface);
|
|
16
15
|
/** Unselected label ink, lifted to AA against the track it is drawn on. */
|
|
17
16
|
export const segmentedRestInk = (colors, trackSurface) => liftToContrast(colors.text[600], trackSurface, AA_NORMAL_TEXT);
|
|
18
|
-
/** A radiogroup is one tab stop, so the group wears the ring: a brand hairline plus the field bloom. */
|
|
19
|
-
export const segmentedFocusShadow = (colors, trackSurface) => `inset 0 0 0 1px ${liftToContrast(colors.primary[500], trackSurface, AA_NON_TEXT)}, ${focusGlowShadow(colors)}`;
|
|
20
17
|
/** The plate can match its backdrop's lightness, so its edge carries the boundary.
|
|
21
18
|
* Drawn inset by the caller: a real border consumes the content box and decentres the sliding pill. */
|
|
22
19
|
export const segmentedPlateEdge = (colors, surface) => liftToContrast(colors.boxborder[500], surface !== null && surface !== void 0 ? surface : colors.backgroundColor.main, AA_NON_TEXT);
|
|
@@ -2,13 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box, Flex, Text, VisuallyHidden } from "@chakra-ui/react";
|
|
3
3
|
import { ArrowDownRight, ArrowUpRight } from "lucide-react";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
|
+
import { resolveSoftTone, toneScale } from "../../Theme/tokens/builders/tone.js";
|
|
5
6
|
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
6
7
|
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
7
8
|
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
8
9
|
import Skeletons from "../Skeletons/Skeletons.js";
|
|
9
10
|
const StatCardSkeleton = ({ hasIcon }) => (_jsxs(Flex, { direction: "column", gap: 3, children: [_jsxs(Flex, { align: "center", gap: 2, children: [hasIcon && _jsx(Skeletons, { type: "skeleton", height: 8, width: 8 }), _jsx(Skeletons, { type: "skeleton", height: 3, width: "40%" })] }), _jsx(Skeletons, { type: "skeleton", height: 7, width: "55%" }), _jsx(Skeletons, { type: "skeleton", height: 3, width: "45%" })] }));
|
|
10
11
|
/** KPI tile: tinted icon chip, label, 2xl tabular value, delta coloured by whether the change is good. */
|
|
11
|
-
const StatCard = ({ label, value, delta, trend, goodDirection = "up", hint, sparkline, footer, icon: Icon, isLoading = false, onClick, "aria-label": ariaLabel, "data-testid": testId, }) => {
|
|
12
|
+
const StatCard = ({ label, value, delta, trend, goodDirection = "up", hint, sparkline, footer, icon: Icon, iconTone, isLoading = false, onClick, "aria-label": ariaLabel, "data-testid": testId, }) => {
|
|
12
13
|
const { colors } = useCustomTheme();
|
|
13
14
|
const isInteractive = !!onClick && !isLoading;
|
|
14
15
|
const deltaColor = trend
|
|
@@ -17,6 +18,9 @@ const StatCard = ({ label, value, delta, trend, goodDirection = "up", hint, spar
|
|
|
17
18
|
: colors.semanticText.error
|
|
18
19
|
: colors.textMuted;
|
|
19
20
|
const DeltaIcon = trend === "down" ? ArrowDownRight : ArrowUpRight;
|
|
21
|
+
const chip = iconTone
|
|
22
|
+
? resolveSoftTone(colors, toneScale(colors, iconTone), colors.background[50])
|
|
23
|
+
: { bg: colors.primary.opacity[8], fg: colors.accentText };
|
|
20
24
|
const surface = {
|
|
21
25
|
display: "block",
|
|
22
26
|
w: "100%",
|
|
@@ -28,7 +32,7 @@ const StatCard = ({ label, value, delta, trend, goodDirection = "up", hint, spar
|
|
|
28
32
|
px: 5,
|
|
29
33
|
py: 4,
|
|
30
34
|
};
|
|
31
|
-
const content = isLoading ? (_jsx(StatCardSkeleton, { hasIcon: !!Icon })) : (_jsxs(Flex, { as: "span", direction: "column", gap: 3, children: [_jsxs(Flex, { as: "span", align: "center", gap: 2, children: [Icon && (_jsx(Flex, { as: "span", boxSize: 8, flexShrink: 0, align: "center", justify: "center", borderRadius: "lg", bg:
|
|
35
|
+
const content = isLoading ? (_jsx(StatCardSkeleton, { hasIcon: !!Icon })) : (_jsxs(Flex, { as: "span", direction: "column", gap: 3, children: [_jsxs(Flex, { as: "span", align: "center", gap: 2, children: [Icon && (_jsx(Flex, { as: "span", boxSize: 8, flexShrink: 0, align: "center", justify: "center", borderRadius: "lg", bg: chip.bg, color: chip.fg, "data-icon-tone": iconTone, children: _jsx(Icon, { size: 16, "aria-hidden": true }) })), _jsx(Text, { as: "span", fontSize: "xs", fontWeight: 500, color: colors.textMuted, children: label })] }), _jsxs(Flex, { as: "span", align: "center", justify: "space-between", gap: 3, children: [_jsx(Text, { as: "span", display: "block", fontSize: "2xl", fontWeight: 700, letterSpacing: "-0.02em", lineHeight: "short", color: colors.header[900], sx: { fontVariantNumeric: "tabular-nums" }, children: value }), sparkline && (_jsx(Flex, { as: "span", align: "center", justify: "center", flexShrink: 0, h: 8, minW: 16, maxW: 24, overflow: "hidden", "data-testid": "stat-sparkline", children: sparkline }))] }), (delta !== undefined || hint) && (_jsxs(Flex, { as: "span", align: "center", gap: 1.5, wrap: "wrap", children: [delta !== undefined && (_jsxs(Flex, { as: "span", align: "center", gap: 0.5, color: deltaColor, "data-testid": "stat-delta", children: [trend && _jsx(DeltaIcon, { size: 14, "aria-hidden": true }), trend && _jsx(VisuallyHidden, { children: trend === "up" ? "Up" : "Down" }), _jsx(Text, { as: "span", fontSize: "xs", fontWeight: 600, sx: { fontVariantNumeric: "tabular-nums" }, children: delta })] })), hint && (_jsx(Text, { as: "span", fontSize: "xs", color: colors.textMuted, children: hint }))] })), footer && (_jsx(Box, { as: "span", pt: 3, borderTopWidth: "1px", borderColor: colors.boxborder[200], "data-testid": "stat-footer", children: footer }))] }));
|
|
32
36
|
if (!isInteractive) {
|
|
33
37
|
return (_jsx(Box, { ...surface, "aria-busy": isLoading || undefined, "data-testid": testId, children: content }));
|
|
34
38
|
}
|