pixelize-design-library 2.4.2-beta.63 → 2.4.2-beta.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +130 -8
- package/COMPONENT-GOTCHAS.md +63 -7
- package/DESIGN-GUIDE.md +8 -3
- package/dist/Components/Button/Button.styles.js +7 -2
- package/dist/Components/CopyButton/CopyButton.d.ts +3 -1
- package/dist/Components/CopyButton/CopyButton.js +2 -2
- package/dist/Components/Drawer/Drawer.d.ts +1 -1
- package/dist/Components/Drawer/Drawer.js +6 -2
- package/dist/Components/Drawer/DrawerProps.d.ts +4 -0
- package/dist/Components/Dropdown/DropDown.js +2 -9
- package/dist/Components/FilePreview/FilePreview.js +2 -1
- package/dist/Components/FileUploader/FileUploader.js +4 -0
- package/dist/Components/FileUploader/FileUploaderProps.d.ts +1 -1
- package/dist/Components/FormDrawer/FormDrawer.d.ts +1 -1
- package/dist/Components/FormDrawer/FormDrawer.js +3 -3
- package/dist/Components/FormDrawer/FormDrawerProps.d.ts +2 -0
- package/dist/Components/Input/TextInput.styles.js +10 -6
- package/dist/Components/KanbanBoard/KanbanBoard.js +6 -5
- package/dist/Components/Modal/dialogNaming.d.ts +8 -0
- package/dist/Components/Modal/dialogNaming.js +21 -0
- package/dist/Components/NavLauncher/LauncherTabs.js +2 -2
- package/dist/Components/NavLauncher/NavLauncher.d.ts +1 -1
- package/dist/Components/NavLauncher/NavLauncher.js +257 -47
- package/dist/Components/NavLauncher/NavLauncherProps.d.ts +79 -3
- package/dist/Components/NavLauncher/ScopeBar.d.ts +14 -0
- package/dist/Components/NavLauncher/ScopeBar.js +137 -0
- package/dist/Components/NavLauncher/engine/distance.d.ts +4 -0
- package/dist/Components/NavLauncher/engine/distance.js +41 -0
- package/dist/Components/NavLauncher/engine/engine.d.ts +84 -0
- package/dist/Components/NavLauncher/engine/engine.js +471 -0
- package/dist/Components/NavLauncher/engine/fold.d.ts +15 -0
- package/dist/Components/NavLauncher/engine/fold.js +83 -0
- package/dist/Components/NavLauncher/engine/index.d.ts +21 -0
- package/dist/Components/NavLauncher/engine/index.js +17 -0
- package/dist/Components/NavLauncher/launcherParts.d.ts +2 -0
- package/dist/Components/NavLauncher/launcherParts.js +11 -7
- package/dist/Components/NavLauncher/match.d.ts +13 -2
- package/dist/Components/NavLauncher/match.js +26 -12
- package/dist/Components/NavLauncher/searchLayout.d.ts +60 -0
- package/dist/Components/NavLauncher/searchLayout.js +108 -0
- package/dist/Components/NavLauncher/spotlight.d.ts +39 -0
- package/dist/Components/NavLauncher/spotlight.js +202 -0
- package/dist/Components/NavLauncher/spotlightParts.d.ts +49 -0
- package/dist/Components/NavLauncher/spotlightParts.js +108 -0
- package/dist/Components/NavigationBar/NavigationBar.js +2 -1
- package/dist/Components/OrgSwitcher/OrgSwitcher.js +2 -4
- package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +6 -5
- package/dist/Components/ScrollToTop/ScrollToTop.js +4 -3
- package/dist/Components/SearchSelect/SearchSelect.js +4 -16
- package/dist/Components/Select/SelectPopup.js +1 -3
- package/dist/Components/Select/optionRowInk.d.ts +12 -0
- package/dist/Components/Select/optionRowInk.js +10 -1
- package/dist/Components/SelectSearch/SelectSearch.js +1 -10
- package/dist/Components/Table/Table.js +3 -2
- package/dist/Components/Table/TableProps.d.ts +1 -1
- package/dist/Components/Table/components/TableBody.js +9 -1
- package/dist/Components/Table/components/TableHeader.js +9 -2
- package/dist/Components/Table/components/TableLoading.d.ts +4 -1
- package/dist/Components/Table/components/TableLoading.js +13 -6
- package/dist/Components/Table/filters/CompactSelect.js +1 -10
- package/dist/Components/Table/variants/TableVariantContext.d.ts +1 -1
- package/dist/Components/Table/variants/TableVariantContext.js +3 -3
- package/dist/Components/WizardDialog/WizardDialog.d.ts +1 -1
- package/dist/Components/WizardDialog/WizardDialog.js +15 -3
- package/dist/Components/WizardDialog/WizardDialogProps.d.ts +5 -3
- package/dist/Components/WorkspaceWindow/WorkspaceTrayPreview.js +4 -0
- package/dist/Components/WorkspaceWindow/WorkspaceWindow.d.ts +2 -2
- package/dist/Components/WorkspaceWindow/WorkspaceWindow.js +26 -18
- package/dist/Components/WorkspaceWindow/WorkspaceWindowProps.d.ts +38 -8
- package/dist/Theme/chakra/Menu.styles.d.ts +8 -0
- package/dist/Theme/chakra/Menu.styles.js +7 -0
- package/dist/Theme/chakra/componentStyles.d.ts +8 -0
- package/dist/Theme/chakra/componentStyles.js +2 -2
- package/dist/Theme/chakra/ringShadow.d.ts +3 -0
- package/dist/Theme/chakra/ringShadow.js +7 -0
- package/dist/Theme/tokens/builders/accentText.d.ts +2 -0
- package/dist/Theme/tokens/builders/accentText.js +7 -1
- package/dist/Theme/tokens/builders/buildDarkPalette.d.ts +1 -1
- package/dist/Theme/tokens/builders/buildDarkPalette.js +5 -5
- package/dist/Theme/tokens/builders/filledSurface.d.ts +5 -1
- package/dist/Theme/tokens/builders/filledSurface.js +17 -4
- package/dist/Theme/tokens/builders/planeStep.d.ts +1 -0
- package/dist/Theme/tokens/builders/planeStep.js +5 -4
- package/dist/Utils/table.js +2 -2
- package/dist/esm/Components/Button/Button.styles.js +8 -3
- package/dist/esm/Components/CopyButton/CopyButton.js +2 -2
- package/dist/esm/Components/Drawer/Drawer.js +6 -2
- package/dist/esm/Components/Dropdown/DropDown.js +2 -9
- package/dist/esm/Components/FilePreview/FilePreview.js +3 -2
- package/dist/esm/Components/FileUploader/FileUploader.js +4 -0
- package/dist/esm/Components/FormDrawer/FormDrawer.js +3 -3
- package/dist/esm/Components/Input/TextInput.styles.js +10 -6
- package/dist/esm/Components/KanbanBoard/KanbanBoard.js +6 -5
- package/dist/esm/Components/Modal/dialogNaming.js +18 -0
- package/dist/esm/Components/NavLauncher/LauncherTabs.js +2 -2
- package/dist/esm/Components/NavLauncher/NavLauncher.js +259 -49
- package/dist/esm/Components/NavLauncher/ScopeBar.js +134 -0
- package/dist/esm/Components/NavLauncher/engine/distance.js +37 -0
- package/dist/esm/Components/NavLauncher/engine/engine.js +458 -0
- package/dist/esm/Components/NavLauncher/engine/fold.js +74 -0
- package/dist/esm/Components/NavLauncher/engine/index.js +14 -0
- package/dist/esm/Components/NavLauncher/launcherParts.js +10 -6
- package/dist/esm/Components/NavLauncher/match.js +25 -12
- package/dist/esm/Components/NavLauncher/searchLayout.js +100 -0
- package/dist/esm/Components/NavLauncher/spotlight.js +194 -0
- package/dist/esm/Components/NavLauncher/spotlightParts.js +95 -0
- package/dist/esm/Components/NavigationBar/NavigationBar.js +2 -1
- package/dist/esm/Components/OrgSwitcher/OrgSwitcher.js +2 -4
- package/dist/esm/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +7 -6
- package/dist/esm/Components/ScrollToTop/ScrollToTop.js +5 -4
- package/dist/esm/Components/SearchSelect/SearchSelect.js +6 -18
- package/dist/esm/Components/Select/SelectPopup.js +2 -4
- package/dist/esm/Components/Select/optionRowInk.js +7 -0
- package/dist/esm/Components/SelectSearch/SelectSearch.js +2 -11
- package/dist/esm/Components/Table/Table.js +4 -3
- package/dist/esm/Components/Table/components/TableBody.js +10 -2
- package/dist/esm/Components/Table/components/TableHeader.js +10 -3
- package/dist/esm/Components/Table/components/TableLoading.js +10 -6
- package/dist/esm/Components/Table/filters/CompactSelect.js +2 -11
- package/dist/esm/Components/Table/variants/TableVariantContext.js +3 -3
- package/dist/esm/Components/WizardDialog/WizardDialog.js +15 -3
- package/dist/esm/Components/WorkspaceWindow/WorkspaceTrayPreview.js +4 -0
- package/dist/esm/Components/WorkspaceWindow/WorkspaceWindow.js +28 -20
- package/dist/esm/Theme/chakra/Menu.styles.js +7 -0
- package/dist/esm/Theme/chakra/componentStyles.js +2 -2
- package/dist/esm/Theme/chakra/ringShadow.js +3 -0
- package/dist/esm/Theme/tokens/builders/accentText.js +5 -0
- package/dist/esm/Theme/tokens/builders/buildDarkPalette.js +5 -5
- package/dist/esm/Theme/tokens/builders/filledSurface.js +18 -5
- package/dist/esm/Theme/tokens/builders/planeStep.js +3 -3
- package/dist/esm/Utils/table.js +2 -2
- package/dist/esm/index.js +6 -5
- package/dist/index.d.ts +10 -8
- package/dist/index.js +14 -6
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { Box, Button, Flex, Menu, MenuButton, MenuDivider, MenuItem, MenuList, S
|
|
|
3
3
|
import Avatar from "../Avatar/Avatar.js";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
5
|
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
6
|
+
import { ruleOn } from "../../Theme/tokens/builders/planeStep.js";
|
|
6
7
|
import { accentTextOnCanvas, isDarkCanvas } from "../../Theme/tokens/builders/accentText.js";
|
|
7
8
|
import { resolveHoverTint } from "../../Theme/tokens/builders/outlineRung.js";
|
|
8
9
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
@@ -48,7 +49,7 @@ export default function NavBar({ userAvathar, userName, userRole, navMenu, moreI
|
|
|
48
49
|
_focus: { bg: menuHoverBg },
|
|
49
50
|
_active: { bg: rowBackgrounds.selectedActive },
|
|
50
51
|
};
|
|
51
|
-
return (_jsx(Box, { bg: theme.colors.backgroundColor.light, px: 4, borderBottom: "1px solid", borderColor: theme.colors.
|
|
52
|
+
return (_jsx(Box, { bg: theme.colors.backgroundColor.light, px: 4, borderBottom: "1px solid", borderColor: ruleOn(theme.colors, theme.colors.backgroundColor.light), 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: ruleOn(theme.colors, theme.colors.backgroundColor.light) })] })), (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: "xl", 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",
|
|
52
53
|
// Without a cap one long title stretches the whole dropdown; titles truncate instead.
|
|
53
54
|
maxW: "18rem", bg: theme.colors.surfaceRaised,
|
|
54
55
|
// NOTE: Chakra's MenuItem inherits --menu-bg hardcoded to #fff via dead _dark — set it or items stay white.
|
|
@@ -7,6 +7,7 @@ import { accentTextOnCanvas, onFilled } from "../../Theme/tokens/builders/accent
|
|
|
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
|
+
import { optionRowCursorSx } from "../Select/optionRowInk.js";
|
|
10
11
|
import { useExclusiveOverlay } from "../../Hooks/useExclusiveOverlay.js";
|
|
11
12
|
import { useMatchMedia } from "../../Hooks/useMatchMedia.js";
|
|
12
13
|
import ToolTip from "../ToolTip/ToolTip.js";
|
|
@@ -106,14 +107,11 @@ const OrgSwitcher = ({ organizations, value, onChange, isLoading = false, isSear
|
|
|
106
107
|
}
|
|
107
108
|
}, borderRadius: "lg" })] }) })), _jsxs(Box, { role: "listbox", "aria-label": "Organizations", maxH: "320px", overflowY: "auto", py: 1, onKeyDown: handleListKeyDown, children: [filtered.map((org, idx) => {
|
|
108
109
|
const isActive = org.id === value;
|
|
109
|
-
const rowHoverBg = isActive
|
|
110
|
-
? rowBackgrounds.selectedActive
|
|
111
|
-
: rowBackgrounds.active;
|
|
112
110
|
return (_jsxs(Flex, { as: "button", type: "button", role: "option", "aria-selected": isActive, ref: (el) => {
|
|
113
111
|
optionRefs.current[idx] = el;
|
|
114
112
|
if (idx === 0)
|
|
115
113
|
firstOptionRef.current = el;
|
|
116
|
-
}, tabIndex: idx === activeIndex ? 0 : -1, align: "center", gap: "10px", w: "100%", textAlign: "left", border: "none", fontFamily: "inherit", px: 3, py: 2, cursor: "pointer", bg:
|
|
114
|
+
}, tabIndex: idx === activeIndex ? 0 : -1, align: "center", gap: "10px", w: "100%", textAlign: "left", border: "none", fontFamily: "inherit", px: 3, py: 2, cursor: "pointer", bg: "transparent", transition: "background 0.12s ease", ...optionRowCursorSx(rowBackgrounds), onClick: () => handleSelect(org), children: [_jsx(Avatar, { org: org, boxSize: s.avatar, fontSize: s.sub }), _jsxs(Box, { flex: "1", minW: 0, children: [_jsx(Text, { fontSize: s.font, fontWeight: isActive ? 600 : 500, color: theme.colors.text[900], overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", children: org.name }), showRole && org.role && (_jsx(Text, { fontSize: s.sub, color: theme.colors.text[500], overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", children: org.role }))] }), isActive && (_jsx(Box, { as: Check, size: 16, color: theme.colors.accentText, flexShrink: 0 }))] }, org.id));
|
|
117
115
|
}), filtered.length === 0 && (_jsx(Text, { fontSize: "sm", color: theme.colors.textMuted, textAlign: "center", py: 6, children: "No organizations found" }))] })] }) })] }));
|
|
118
116
|
};
|
|
119
117
|
export default OrgSwitcher;
|
|
@@ -6,7 +6,7 @@ import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
|
6
6
|
import { BORDER_WIDTHS } from "../../Theme/tokens/primitives/borderWidths.js";
|
|
7
7
|
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
8
8
|
import { accentTextOnCanvas } from "../../Theme/tokens/builders/accentText.js";
|
|
9
|
-
import {
|
|
9
|
+
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
10
10
|
import { hexToRgb } from "../../Theme/tokens/builders/color.js";
|
|
11
11
|
const RING_TRANSITION = transitionFor(["box-shadow"], "base");
|
|
12
12
|
const FADE_TRANSITION = transitionFor(["opacity"], "base");
|
|
@@ -23,6 +23,7 @@ export default function ProfilePhotoViewer({ photoUrl, onPhotoChange, imageWidth
|
|
|
23
23
|
const fileInputRef = useRef(null);
|
|
24
24
|
const theme = useCustomTheme();
|
|
25
25
|
const c = theme.colors;
|
|
26
|
+
const editFill = resolveFilledSurface(c.primary, c);
|
|
26
27
|
const handlePhotoChange = (event) => {
|
|
27
28
|
var _a;
|
|
28
29
|
if (!isEditable)
|
|
@@ -72,14 +73,14 @@ export default function ProfilePhotoViewer({ photoUrl, onPhotoChange, imageWidth
|
|
|
72
73
|
"&:hover .ppv-media": {
|
|
73
74
|
boxShadow: `0 0 0 0.1875rem ${c.primary.opacity[24]}`,
|
|
74
75
|
},
|
|
75
|
-
}, children: [_jsx(Box, { className: "ppv-media", borderRadius: imageBorderRadius, transition: RING_TRANSITION, children: renderMedia() }), hasActions && (_jsxs(_Fragment, { children: [_jsx(Box, { className: "ppv-overlay", position: "absolute", inset: 0, borderRadius: imageBorderRadius, bg: hoverScrim(0.3), opacity: 0, transition: FADE_TRANSITION, pointerEvents: "none" }), _jsxs(HStack, { className: "ppv-actions", position: "absolute", right: editIconPositionRight, bottom: editIconPositionBottom, transform: "translate(-15%, -15%)", spacing: 1.5, opacity: revealOnHover ? 0 : 1, transition: FADE_TRANSITION, children: [isEditable && (_jsx(Tooltip, { label: "Edit", "aria-label": "Edit", hasArrow: true, children: _jsx(IconButton, { icon: _jsx(SquarePen, { size: 14 }), isRound: isRound, size: editIconSize, onClick: handleClick, "aria-label": "Edit photo", bg:
|
|
76
|
-
bg:
|
|
77
|
-
color:
|
|
76
|
+
}, children: [_jsx(Box, { className: "ppv-media", borderRadius: imageBorderRadius, transition: RING_TRANSITION, children: renderMedia() }), hasActions && (_jsxs(_Fragment, { children: [_jsx(Box, { className: "ppv-overlay", position: "absolute", inset: 0, borderRadius: imageBorderRadius, bg: hoverScrim(0.3), opacity: 0, transition: FADE_TRANSITION, pointerEvents: "none" }), _jsxs(HStack, { className: "ppv-actions", position: "absolute", right: editIconPositionRight, bottom: editIconPositionBottom, transform: "translate(-15%, -15%)", spacing: 1.5, opacity: revealOnHover ? 0 : 1, transition: FADE_TRANSITION, children: [isEditable && (_jsx(Tooltip, { label: "Edit", "aria-label": "Edit", hasArrow: true, children: _jsx(IconButton, { icon: _jsx(SquarePen, { size: 14 }), isRound: isRound, size: editIconSize, onClick: handleClick, "aria-label": "Edit photo", bg: editFill.fill, color: editFill.color, border: `0.125rem solid ${c.background[50]}`, boxShadow: (_b = theme.shadows) === null || _b === void 0 ? void 0 : _b.md, style: style, transition: ACTION_TRANSITION, _hover: {
|
|
77
|
+
bg: editFill.hoverFill,
|
|
78
|
+
color: editFill.hoverColor,
|
|
78
79
|
transform: "scale(1.1)",
|
|
79
80
|
boxShadow: (_c = theme.shadows) === null || _c === void 0 ? void 0 : _c.lg,
|
|
80
81
|
}, _active: {
|
|
81
|
-
bg:
|
|
82
|
-
color:
|
|
82
|
+
bg: editFill.activeFill,
|
|
83
|
+
color: editFill.activeColor,
|
|
83
84
|
} }) })), isView && (_jsx(Tooltip, { label: "View", "aria-label": "View", hasArrow: true, children: _jsx(IconButton, { icon: _jsx(Eye, { size: 14 }), isRound: isRound, size: editIconSize, onClick: handleIsView, "aria-label": "View photo", bg: c.background[50], color: c.text[700], border: `${BORDER_WIDTHS.hairline} solid ${border}`, boxShadow: (_d = theme.shadows) === null || _d === void 0 ? void 0 : _d.md, style: style, transition: ACTION_TRANSITION, _hover: {
|
|
84
85
|
bg: c.gray[50],
|
|
85
86
|
color: accentTextOnCanvas(c.primary, c.gray[50]),
|
|
@@ -5,7 +5,7 @@ import { ChevronUp } from "lucide-react";
|
|
|
5
5
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
6
6
|
import ToolTip from "../ToolTip/ToolTip.js";
|
|
7
7
|
import { rafThrottle } from "../../Utils/rafThrottle.js";
|
|
8
|
-
import {
|
|
8
|
+
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
9
9
|
import { transitionFor } from "../../Theme/tokens/primitives/index.js";
|
|
10
10
|
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
11
11
|
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
@@ -14,6 +14,7 @@ const ScrollToTop = ({ children, tooltipLabel = "Scroll to top", threshold = 300
|
|
|
14
14
|
const [visible, setVisible] = useState(false);
|
|
15
15
|
const anchorRef = useRef(null);
|
|
16
16
|
const theme = useCustomTheme();
|
|
17
|
+
const fill = resolveFilledSurface(theme.colors.primary, theme.colors);
|
|
17
18
|
const getScroller = () => {
|
|
18
19
|
var _a, _b;
|
|
19
20
|
if (useWindow)
|
|
@@ -62,9 +63,9 @@ const ScrollToTop = ({ children, tooltipLabel = "Scroll to top", threshold = 300
|
|
|
62
63
|
};
|
|
63
64
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
65
|
}, [useWindow, threshold]);
|
|
65
|
-
return (_jsxs(Box, { ref: anchorRef, position: "relative", children: [children, _jsx(ToolTip, { label: tooltipLabel, placement: "left", children: _jsx(Box, { as: "button", type: "button", onClick: scrollToTop, "aria-label": tooltipLabel, border: "none", position: "fixed", bottom: bottom, right: right, zIndex: 1000, display: "flex", alignItems: "center", justifyContent: "center", boxSize: "44px", borderRadius: "full", cursor: "pointer", bg:
|
|
66
|
-
bg:
|
|
67
|
-
color:
|
|
66
|
+
return (_jsxs(Box, { ref: anchorRef, position: "relative", children: [children, _jsx(ToolTip, { label: tooltipLabel, placement: "left", children: _jsx(Box, { as: "button", type: "button", onClick: scrollToTop, "aria-label": tooltipLabel, border: "none", position: "fixed", bottom: bottom, right: right, zIndex: 1000, display: "flex", alignItems: "center", justifyContent: "center", boxSize: "44px", borderRadius: "full", cursor: "pointer", bg: fill.fill, color: fill.color, boxShadow: "md", opacity: visible ? 1 : 0, transform: visible ? "translateY(0) scale(1)" : "translateY(16px) scale(0.85)", pointerEvents: visible ? "auto" : "none", transition: transitionFor(["opacity", "transform", "box-shadow", "background-color", "color"], "base"), _hover: {
|
|
67
|
+
bg: fill.hoverFill,
|
|
68
|
+
color: fill.hoverColor,
|
|
68
69
|
transform: "translateY(-2px) scale(1.05)",
|
|
69
70
|
boxShadow: "lg",
|
|
70
71
|
}, _active: { transform: "scale(0.95)" }, sx: { ...focusVisibleStyles(theme.colors), ...reducedMotionSx({ transform: "none" }) }, children: _jsx(ChevronUp, { size: 24, strokeWidth: 2.5 }) }) })] }));
|
|
@@ -7,8 +7,8 @@ import Tag from "../Tag/Tag.js";
|
|
|
7
7
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
8
8
|
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
9
9
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
10
|
-
import { optionRowSpec } from "../../Theme/tokens/primitives/optionRowSizes.js";
|
|
11
|
-
import { optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
10
|
+
import { OPTION_ROW_RADIUS, optionRowSpec } from "../../Theme/tokens/primitives/optionRowSizes.js";
|
|
11
|
+
import { optionRowCursorSx, optionRowFill, optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
12
12
|
import { useExclusiveOverlay } from "../../Hooks/useExclusiveOverlay.js";
|
|
13
13
|
import FieldMessage from "../Common/FieldMessage.js";
|
|
14
14
|
import { useFieldIds } from "../Common/useFieldIds.js";
|
|
@@ -41,17 +41,9 @@ const normalizeMultiValue = (val) => {
|
|
|
41
41
|
const DECORATIVE_CHECKBOX_SX = { pointerEvents: "none", "& input": { visibility: "hidden" } };
|
|
42
42
|
const OptionRow = React.memo(function OptionRow({ option, index, optionId, isSelected, isActive, isMultiple, spec, colors, rowBackgrounds, checkboxSize, onSelect, onActivate, }) {
|
|
43
43
|
const singleSelected = isSelected && !isMultiple;
|
|
44
|
-
return (_jsxs(Box, { id: optionId, "data-index": index, role: "option", "aria-selected": isSelected, py: spec.py, px: spec.px, minH: spec.minH, cursor: "pointer", bg:
|
|
45
|
-
? isActive
|
|
46
|
-
? rowBackgrounds.selectedActive
|
|
47
|
-
: rowBackgrounds.selected
|
|
48
|
-
: isActive
|
|
49
|
-
? rowBackgrounds.active
|
|
50
|
-
: "transparent", _hover: {
|
|
51
|
-
bg: isSelected ? rowBackgrounds.selectedActive : rowBackgrounds.active,
|
|
52
|
-
}, onClick: () => onSelect(option), onMouseEnter: () => onActivate(index), display: "flex", alignItems: "center", gap: spec.gap, color: optionRowInk(colors, singleSelected),
|
|
44
|
+
return (_jsxs(Box, { id: optionId, "data-index": index, role: "option", "aria-selected": isSelected, mx: spec.mx, py: spec.py, px: spec.px, minH: spec.minH, borderRadius: OPTION_ROW_RADIUS, cursor: "pointer", bg: optionRowFill(rowBackgrounds, isActive), onClick: () => onSelect(option), onMouseEnter: () => onActivate(index), display: "flex", alignItems: "center", gap: spec.gap, color: optionRowInk(colors, singleSelected),
|
|
53
45
|
// `view` is consumer JSX with no size of its own; it inherited the 16px body font.
|
|
54
|
-
fontSize: spec.fontSize, fontWeight: optionRowWeight(singleSelected),
|
|
46
|
+
fontSize: spec.fontSize, fontWeight: optionRowWeight(singleSelected), children: [isMultiple && (_jsx(Checkbox, { isChecked: isSelected, sx: DECORATIVE_CHECKBOX_SX, size: checkboxSize })), option.view ? (_jsx(_Fragment, { children: option.view })) : (_jsx(Text, { flex: 1, minW: 0, isTruncated: true, children: option.label })), singleSelected && (_jsx(Box, { as: Check, size: spec.iconSize, color: colors.accentText, flexShrink: 0 }))] }));
|
|
55
47
|
});
|
|
56
48
|
/** Full-featured combobox: search, chips, select-all, paginated infinite scroll — not DOM-virtualized despite the `virtualization` prop. */
|
|
57
49
|
/** Prefer `Select` with `native={false}` for new work — not yet a drop-in; see select-absorption-spec.md. */
|
|
@@ -618,11 +610,7 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
618
610
|
}, children: [_jsxs(Box, { minW: "4.5rem", cursor: "pointer", display: "flex", justifyContent: "space-between", alignItems: "center", gap: 1, width: insideSelect.width, height: insideSelectBoxHeight, pl: "0.5rem", pr: "0.375rem", children: [insideLabel ? (_jsx(SelectTruncatedLabel, { label: insideLabel, maxWidth: insideSelect.width || "6rem", fontSize: s.fieldFontSize })) : (_jsx(Text, { fontSize: s.fieldFontSize, fontWeight: 500, color: theme.colors.textMuted, isTruncated: true, maxW: insideSelect.width || "6rem", children: insidePlaceholder })), _jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, color: customSelectOpen ? theme.colors.accentText : theme.colors.textMuted, transition: CHEVRON_TRANSITION, transform: customSelectOpen ? "rotate(180deg)" : "rotate(0deg)", children: _jsx(ChevronDown, { size: s.chevronSize }) })] }), customSelectOpen && (_jsx(Portal, { children: _jsx(Box, { ref: setInsideSelectMenuRef, id: insideSelectPortalId, role: "listbox", "aria-label": insidePlaceholder, onKeyDown: handleInsideMenuKeyDown, onFocus: stopFocusBubbling, onBlur: stopFocusBubbling, position: "fixed", style: { top: `${customSelectPos.top}px`, left: `${customSelectPos.left}px` }, zIndex: zIndices.popoverNested, bg: theme.colors.surfaceRaised, border: `${BORDER_WIDTHS.hairline} solid`, borderColor: theme.colors.boxborder[200], borderRadius: "xl", boxShadow: theme.shadows.lg, minW: `${customSelectPos.width}px`, maxW: "20rem", py: 1, overflow: "hidden", children: (_c = insideSelect.option) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
619
611
|
var _a;
|
|
620
612
|
const selected = ((_a = insideSelect.value) === null || _a === void 0 ? void 0 : _a.id) === item.id;
|
|
621
|
-
return (_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: spec.gap, minH: spec.minH, py: spec.py, px: spec.px, fontSize: spec.fontSize, fontWeight: optionRowWeight(selected), color: optionRowInk(theme.colors, selected), bg:
|
|
622
|
-
bg: selected
|
|
623
|
-
? rowBackgrounds.selectedActive
|
|
624
|
-
: rowBackgrounds.active,
|
|
625
|
-
}, cursor: "pointer", role: "option", "aria-selected": selected, tabIndex: -1, _focusVisible: insideFocusRing, onClick: (e) => {
|
|
613
|
+
return (_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: spec.gap, minH: spec.minH, py: spec.py, px: spec.px, fontSize: spec.fontSize, fontWeight: optionRowWeight(selected), color: optionRowInk(theme.colors, selected), bg: "transparent", ...optionRowCursorSx(rowBackgrounds), cursor: "pointer", role: "option", "aria-selected": selected, tabIndex: -1, _focusVisible: insideFocusRing, onClick: (e) => {
|
|
626
614
|
e.stopPropagation();
|
|
627
615
|
handleCustomSelect(item);
|
|
628
616
|
}, children: [_jsx(Text, { isTruncated: true, children: item.label }), selected && (_jsx(Check, { size: spec.iconSize, color: theme.colors.accentText }))] }, item.id));
|
|
@@ -661,6 +649,6 @@ const SearchSelect = ({ id, label, options, onChange, onSelect, onSearch, isOpti
|
|
|
661
649
|
top: `${dropdownPos.top}px`,
|
|
662
650
|
left: `${dropdownPos.left}px`,
|
|
663
651
|
width: `${dropdownPos.width}px`,
|
|
664
|
-
}, zIndex: zIndices.popover, maxH: "20rem", borderWidth: 1, borderColor: theme.colors.boxborder[200], borderRadius: "xl", overflow: "hidden", bg: theme.colors.surfaceRaised, boxShadow: theme.shadows.lg, display: "flex", flexDirection: "column", children: [hasSelectAllRow && (_jsxs(Box, { id: selectAllId, role: "option", "aria-selected": allFilteredSelected, bg: activeIndex === SELECT_ALL_ROW ? rowBackgrounds.active : undefined, py: spec.py, px: spec.px, minH: spec.minH, cursor: "pointer", onClick: handleSelectAll, display: "flex", alignItems: "center", gap: spec.gap, color: theme.colors.text[700], borderBottom: `${BORDER_WIDTHS.hairline} solid ${raisedRule(theme.colors)}`, children: [_jsx(Checkbox, { isChecked: allFilteredSelected, sx: DECORATIVE_CHECKBOX_SX, size: s.checkboxSize }), _jsx(Text, { fontSize: spec.fontSize, children: allFilteredSelected ? "Unselect All" : "Select All" })] })), _jsx(Box, { ref: optionsListRef, flex: "1", overflowY: "auto", onScroll: handleScroll, maxH: "15rem", borderBottom: `${BORDER_WIDTHS.hairline} solid`, borderColor: raisedRule(theme.colors), children: isOptionLoading && filteredOptions.length === 0 ? (_jsxs(Box, { py: spec.py, px: spec.px, display: "flex", alignItems: "center", gap: spec.gap, minH: spec.minH, color: theme.colors.textMuted, children: [_jsx(Spinner, { size: s.spinnerSize }), _jsx(Text, { fontSize: spec.fontSize, children: loadingText })] })) : !isOptionLoading && filteredOptions.length === 0 ? (_jsx(Text, { p: 3, fontSize: spec.fontSize, color: theme.colors.textMuted, children: "No results found" })) : (_jsxs(_Fragment, { children: [filteredOptions.map((option, index) => (_jsx(OptionRow, { option: option, index: index, optionId: getOptionId(index), isSelected: isSelected(option.id), isActive: index === activeIndex, isMultiple: isMultiple, spec: spec, colors: theme.colors, rowBackgrounds: rowBackgrounds, checkboxSize: s.checkboxSize, onSelect: selectOption, onActivate: setActiveIndex }, option.id))), ((pagination === null || pagination === void 0 ? void 0 : pagination.scrollLoading) || (isOptionLoading && filteredOptions.length > 0)) && (_jsxs(Box, { py: spec.py, px: spec.px, display: "flex", alignItems: "center", justifyContent: "center", gap: spec.gap, minH: spec.minH, color: theme.colors.textMuted, children: [_jsx(Spinner, { size: s.spinnerSize }), _jsx(Text, { fontSize: spec.fontSize, children: loadingText })] }))] })) }), (addNew === null || addNew === void 0 ? void 0 : addNew.enabled) && (_jsxs(Box, { id: addNewId, role: "option", "aria-selected": false, py: spec.py, px: spec.px, borderTop: `${BORDER_WIDTHS.hairline} solid`, borderColor: raisedRule(theme.colors), bg: activeIndex === ADD_NEW_ROW ? rowBackgrounds.active : theme.colors.surfaceRaised, display: "flex", alignItems: "center", gap: spec.gap, color: theme.colors.accentText, fontWeight: 500, minH: spec.minH, cursor: "pointer", onClick: addNew.onClick, _hover: { bg: rowBackgrounds.active }, children: [addNew.icon || _jsx(Plus, { size: s.addNewIconSize }), _jsx(Text, { fontSize: spec.fontSize, children: addNew.text || "Add New" })] }))] }) })), _jsx(FieldMessage, { error: error, errorMessage: errorMessage, helperText: helperText, helperId: ids.helperId, errorId: ids.errorId })] }));
|
|
652
|
+
}, zIndex: zIndices.popover, maxH: "20rem", borderWidth: 1, borderColor: theme.colors.boxborder[200], borderRadius: "xl", overflow: "hidden", bg: theme.colors.surfaceRaised, boxShadow: theme.shadows.lg, display: "flex", flexDirection: "column", children: [hasSelectAllRow && (_jsxs(Box, { id: selectAllId, role: "option", "aria-selected": allFilteredSelected, bg: activeIndex === SELECT_ALL_ROW ? rowBackgrounds.active : undefined, py: spec.py, px: spec.px, minH: spec.minH, cursor: "pointer", onClick: handleSelectAll, display: "flex", alignItems: "center", gap: spec.gap, color: theme.colors.text[700], borderBottom: `${BORDER_WIDTHS.hairline} solid ${raisedRule(theme.colors)}`, children: [_jsx(Checkbox, { isChecked: allFilteredSelected, sx: DECORATIVE_CHECKBOX_SX, size: s.checkboxSize }), _jsx(Text, { fontSize: spec.fontSize, children: allFilteredSelected ? "Unselect All" : "Select All" })] })), _jsx(Box, { ref: optionsListRef, flex: "1", overflowY: "auto", onScroll: handleScroll, maxH: "15rem", py: 1, borderBottom: `${BORDER_WIDTHS.hairline} solid`, borderColor: raisedRule(theme.colors), children: isOptionLoading && filteredOptions.length === 0 ? (_jsxs(Box, { py: spec.py, px: spec.px, display: "flex", alignItems: "center", gap: spec.gap, minH: spec.minH, color: theme.colors.textMuted, children: [_jsx(Spinner, { size: s.spinnerSize }), _jsx(Text, { fontSize: spec.fontSize, children: loadingText })] })) : !isOptionLoading && filteredOptions.length === 0 ? (_jsx(Text, { p: 3, fontSize: spec.fontSize, color: theme.colors.textMuted, children: "No results found" })) : (_jsxs(_Fragment, { children: [filteredOptions.map((option, index) => (_jsx(OptionRow, { option: option, index: index, optionId: getOptionId(index), isSelected: isSelected(option.id), isActive: index === activeIndex, isMultiple: isMultiple, spec: spec, colors: theme.colors, rowBackgrounds: rowBackgrounds, checkboxSize: s.checkboxSize, onSelect: selectOption, onActivate: setActiveIndex }, option.id))), ((pagination === null || pagination === void 0 ? void 0 : pagination.scrollLoading) || (isOptionLoading && filteredOptions.length > 0)) && (_jsxs(Box, { py: spec.py, px: spec.px, display: "flex", alignItems: "center", justifyContent: "center", gap: spec.gap, minH: spec.minH, color: theme.colors.textMuted, children: [_jsx(Spinner, { size: s.spinnerSize }), _jsx(Text, { fontSize: spec.fontSize, children: loadingText })] }))] })) }), (addNew === null || addNew === void 0 ? void 0 : addNew.enabled) && (_jsxs(Box, { id: addNewId, role: "option", "aria-selected": false, py: spec.py, px: spec.px, borderTop: `${BORDER_WIDTHS.hairline} solid`, borderColor: raisedRule(theme.colors), bg: activeIndex === ADD_NEW_ROW ? rowBackgrounds.active : theme.colors.surfaceRaised, display: "flex", alignItems: "center", gap: spec.gap, color: theme.colors.accentText, fontWeight: 500, minH: spec.minH, cursor: "pointer", onClick: addNew.onClick, _hover: { bg: rowBackgrounds.active }, children: [addNew.icon || _jsx(Plus, { size: s.addNewIconSize }), _jsx(Text, { fontSize: spec.fontSize, children: addNew.text || "Add New" })] }))] }) })), _jsx(FieldMessage, { error: error, errorMessage: errorMessage, helperText: helperText, helperId: ids.helperId, errorId: ids.errorId })] }));
|
|
665
653
|
};
|
|
666
654
|
export default SearchSelect;
|
|
@@ -6,7 +6,7 @@ import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
|
6
6
|
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
7
7
|
import { focusGlowShadow } from "../../Theme/chakra/focusRing.styles.js";
|
|
8
8
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
9
|
-
import { optionRowDescriptionInk, optionRowInk, optionRowWeight } from "./optionRowInk.js";
|
|
9
|
+
import { optionRowDescriptionInk, optionRowFill, optionRowInk, optionRowWeight } from "./optionRowInk.js";
|
|
10
10
|
import { optionRowSpec } from "../../Theme/tokens/primitives/optionRowSizes.js";
|
|
11
11
|
import { scrollbarStyles } from "../../Theme/tokens/builders/scrollbar.js";
|
|
12
12
|
import { CONTROL_SIZES, DEFAULT_CONTROL_SIZE } from "../../Theme/tokens/primitives/controlSizes.js";
|
|
@@ -36,9 +36,7 @@ const parseRemToPx = (value, fallbackPx) => {
|
|
|
36
36
|
};
|
|
37
37
|
const OptionRow = React.memo(function OptionRow({ option, index, listboxId, isSelected, isActive, isMulti, theme, backgrounds, spec, renderOption, onSelect, onActivate, }) {
|
|
38
38
|
const isSingleSelected = isSelected && !isMulti;
|
|
39
|
-
|
|
40
|
-
const restBg = isActive ? backgrounds.active : "transparent";
|
|
41
|
-
return (_jsxs(Box, { id: optionDomId(listboxId, option.id), "data-index": index, role: "option", "aria-selected": isSelected, "aria-disabled": option.isDisabled, onMouseEnter: () => onActivate(index), onClick: () => onSelect(option), mx: spec.mx, px: spec.px, py: spec.py, minH: spec.minH, borderRadius: "md", cursor: option.isDisabled ? "not-allowed" : "pointer", opacity: option.isDisabled ? 0.4 : 1, display: "flex", alignItems: "center", gap: spec.gap, fontSize: spec.fontSize, fontWeight: optionRowWeight(isSingleSelected), color: optionRowInk(theme.colors, isSingleSelected), bg: isSingleSelected ? selectedBg : restBg, transition: ROW_TRANSITION, sx: reducedMotionSx(), children: [isMulti ? (_jsx(Checkbox, { id: `${optionDomId(listboxId, option.id)}-checkbox`, isChecked: isSelected, isDisabled: option.isDisabled, pointerEvents: "none", tabIndex: -1, sx: DECORATIVE_CHECKBOX_SX })) : null, renderOption ? (_jsx(Box, { flex: 1, minW: 0, children: renderOption(option, { isSelected, isActive }) })) : (_jsxs(_Fragment, { children: [option.icon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, children: option.icon })) : null, _jsxs(Box, { flex: 1, minW: 0, isTruncated: true, children: [_jsx(Box, { as: "span", isTruncated: true, children: option.label }), option.description ? (_jsx(Box, { as: "span", display: "block", fontSize: spec.descriptionFontSize, color: optionRowDescriptionInk(theme.colors), isTruncated: true, children: option.description })) : null] })] })), isSingleSelected ? (_jsx(Box, { as: Check, size: spec.iconSize, color: theme.colors.accentText, flexShrink: 0 })) : null] }));
|
|
39
|
+
return (_jsxs(Box, { id: optionDomId(listboxId, option.id), "data-index": index, role: "option", "aria-selected": isSelected, "aria-disabled": option.isDisabled, onMouseEnter: () => onActivate(index), onClick: () => onSelect(option), mx: spec.mx, px: spec.px, py: spec.py, minH: spec.minH, borderRadius: "md", cursor: option.isDisabled ? "not-allowed" : "pointer", opacity: option.isDisabled ? 0.4 : 1, display: "flex", alignItems: "center", gap: spec.gap, fontSize: spec.fontSize, fontWeight: optionRowWeight(isSingleSelected), color: optionRowInk(theme.colors, isSingleSelected), bg: optionRowFill(backgrounds, isActive), transition: ROW_TRANSITION, sx: reducedMotionSx(), children: [isMulti ? (_jsx(Checkbox, { id: `${optionDomId(listboxId, option.id)}-checkbox`, isChecked: isSelected, isDisabled: option.isDisabled, pointerEvents: "none", tabIndex: -1, sx: DECORATIVE_CHECKBOX_SX })) : null, renderOption ? (_jsx(Box, { flex: 1, minW: 0, children: renderOption(option, { isSelected, isActive }) })) : (_jsxs(_Fragment, { children: [option.icon ? (_jsx(Box, { as: "span", display: "inline-flex", flexShrink: 0, children: option.icon })) : null, _jsxs(Box, { flex: 1, minW: 0, isTruncated: true, children: [_jsx(Box, { as: "span", isTruncated: true, children: option.label }), option.description ? (_jsx(Box, { as: "span", display: "block", fontSize: spec.descriptionFontSize, color: optionRowDescriptionInk(theme.colors), isTruncated: true, children: option.description })) : null] })] })), isSingleSelected ? (_jsx(Box, { as: Check, size: spec.iconSize, color: theme.colors.accentText, flexShrink: 0 })) : null] }));
|
|
42
40
|
});
|
|
43
41
|
const buildGroupedRows = (options) => {
|
|
44
42
|
const rows = [];
|
|
@@ -5,6 +5,13 @@ import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
|
5
5
|
export const optionRowInk = (colors, isSingleSelected) => isSingleSelected ? colors.text[900] : colors.text[700];
|
|
6
6
|
// A 12px sub-line reached only 4.00:1 on the hovered selected row in dark.
|
|
7
7
|
export const optionRowDescriptionInk = (colors) => liftToContrast(colors.textMuted, listRowBackgrounds(colors).selectedActive, AA_NORMAL_TEXT);
|
|
8
|
+
/** The one fill an option row paints: the cursor's (hover or keyboard). Selection never fills a row. */
|
|
9
|
+
export const optionRowFill = (rows, isActive) => isActive ? rows.active : "transparent";
|
|
10
|
+
/** Fill for rows that take real DOM focus (roving tabindex) — `:hover` and `:focus` are the cursor. */
|
|
11
|
+
export const optionRowCursorSx = (rows) => ({
|
|
12
|
+
_hover: { bg: rows.active },
|
|
13
|
+
_focus: { bg: rows.active },
|
|
14
|
+
});
|
|
8
15
|
export const OPTION_ROW_REST_WEIGHT = 400;
|
|
9
16
|
// NOTE: 600 beside a tinted fill and a check read as three signals for one state.
|
|
10
17
|
export const OPTION_ROW_SELECTED_WEIGHT = 500;
|
|
@@ -14,7 +14,7 @@ import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
|
14
14
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
15
15
|
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
16
16
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
17
|
-
import { optionRowDescriptionInk, optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
17
|
+
import { optionRowCursorSx, optionRowDescriptionInk, optionRowInk, optionRowWeight } from "../Select/optionRowInk.js";
|
|
18
18
|
import { useExclusiveOverlay } from "../../Hooks/useExclusiveOverlay.js";
|
|
19
19
|
import { PlusIcon, Check } from "lucide-react";
|
|
20
20
|
const ROW_TRANSITION = transitionFor(["background-color"]);
|
|
@@ -30,18 +30,9 @@ const RenderOptions = ({ isOptionLoading, filteredOptions, loadingText, handleOp
|
|
|
30
30
|
const selected = isOptionSelected(option);
|
|
31
31
|
const isSingleSelected = selected && !isMultipleSelect;
|
|
32
32
|
const isActive = index === activeIndex;
|
|
33
|
-
const rowBg = selected
|
|
34
|
-
? isActive
|
|
35
|
-
? rowBackgrounds.selectedActive
|
|
36
|
-
: rowBackgrounds.selected
|
|
37
|
-
: isActive
|
|
38
|
-
? rowBackgrounds.active
|
|
39
|
-
: "transparent";
|
|
40
33
|
return (_jsxs(Box, { as: "button", type: "button", ref: (el) => {
|
|
41
34
|
optionRefs.current[index] = el;
|
|
42
|
-
}, role: "option", "aria-selected": selected, tabIndex: isActive ? 0 : -1, w: `calc(100% - 2 * ${spec.mx})`, minH: spec.minH, textAlign: "left", border: "none", fontFamily: "inherit", bg:
|
|
43
|
-
bg: selected ? rowBackgrounds.selectedActive : rowBackgrounds.active,
|
|
44
|
-
}, onClick: () => handleOptionClick(option), onKeyDown: (e) => {
|
|
35
|
+
}, role: "option", "aria-selected": selected, tabIndex: isActive ? 0 : -1, w: `calc(100% - 2 * ${spec.mx})`, minH: spec.minH, textAlign: "left", border: "none", fontFamily: "inherit", bg: "transparent", mx: spec.mx, px: spec.px, py: spec.py, borderRadius: OPTION_ROW_RADIUS, fontSize: spec.fontSize, cursor: "pointer", color: optionRowInk(theme.colors, isSingleSelected), fontWeight: optionRowWeight(isSingleSelected), transition: ROW_TRANSITION, sx: reducedMotionSx(), ...optionRowCursorSx(rowBackgrounds), onClick: () => handleOptionClick(option), onKeyDown: (e) => {
|
|
45
36
|
if (e.key === "Enter" || e.key === " ") {
|
|
46
37
|
e.preventDefault();
|
|
47
38
|
handleOptionClick(option);
|
|
@@ -8,7 +8,7 @@ import { TABLE_VARIANTS } from "./variants/index.js";
|
|
|
8
8
|
import { TableVariantProvider } from "./variants/TableVariantContext.js";
|
|
9
9
|
import { isDarkCanvas } from "../../Theme/tokens/builders/accentText.js";
|
|
10
10
|
import { cardRule } from "../../Theme/tokens/builders/planeStep.js";
|
|
11
|
-
import {
|
|
11
|
+
import { resolveFilledSurface } from "../../Theme/tokens/builders/filledSurface.js";
|
|
12
12
|
import Pagination from "./components/Pagination.js";
|
|
13
13
|
import TableHeader from "./components/TableHeader.js";
|
|
14
14
|
import TableBody from "./components/TableBody.js";
|
|
@@ -43,11 +43,12 @@ export default function Table({ data, columns, onSelection, isLoading, isCheckbo
|
|
|
43
43
|
name: "",
|
|
44
44
|
page: "",
|
|
45
45
|
orgId: "",
|
|
46
|
-
}, paginationMode = "client", infiniteScroll = false, hasMore, isLoadingMore = false, groupLoadMore = false, loadMoreText = "Load more", loadMorePosition = "top", loadMoreChunkSize, noOfRowsPerPage = 50, totalRecords = 0, onPagination, isTableSettings = false, headerActions, onGlobalSearch, onNoOfRowsPerPageChange, paginationSelectOptions, tableMaxHeight, minVisibleRows, maxVisibleRows, autoFitViewport, tableSettings, filterSidebar, loadingSkeletonRows, defaultVisibleColumns, density = "normal", variant = "
|
|
46
|
+
}, paginationMode = "client", infiniteScroll = false, hasMore, isLoadingMore = false, groupLoadMore = false, loadMoreText = "Load more", loadMorePosition = "top", loadMoreChunkSize, noOfRowsPerPage = 50, totalRecords = 0, onPagination, isTableSettings = false, headerActions, onGlobalSearch, onNoOfRowsPerPageChange, paginationSelectOptions, tableMaxHeight, minVisibleRows, maxVisibleRows, autoFitViewport, tableSettings, filterSidebar, loadingSkeletonRows, defaultVisibleColumns, density = "normal", variant = "studio", stripe = false, renderRowDetail, expandedRows, onExpandedRowsChange, groupColors, onAddItem, emptyState, onRefresh, isGlobalSearch = true, }) {
|
|
47
47
|
var _a, _b, _c, _d, _e;
|
|
48
48
|
const theme = useCustomTheme();
|
|
49
49
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
50
50
|
const clearFiltersTone = useMemo(() => resolveFilledSurface(theme.colors.semantic.error, theme.colors), [theme.colors]);
|
|
51
|
+
const clearBadge = useMemo(() => resolveFilledSurface(theme.colors.primary, theme.colors), [theme.colors]);
|
|
51
52
|
const variantTokens = useMemo(() => TABLE_VARIANTS[variant](theme.colors, isDarkCanvas(theme.colors.backgroundColor.main)), [variant, theme.colors]);
|
|
52
53
|
const [columnsSearch, setColumnsSearch] = useState({});
|
|
53
54
|
const detailIdPrefix = useId();
|
|
@@ -391,7 +392,7 @@ export default function Table({ data, columns, onSelection, isLoading, isCheckbo
|
|
|
391
392
|
? isFilterModalOpen
|
|
392
393
|
: !!(filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.isFilterSidebar), display: "inline-flex", alignItems: "center", justifyContent: "center", p: 0, bg: "transparent", border: "none", borderRadius: "md", cursor: "pointer", onClick: filterMode === "modal" ? onFilterModalOpen : filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.filterSidebarToggle, _hover: {
|
|
393
394
|
color: theme.colors.accentText,
|
|
394
|
-
}, sx: focusVisibleStyles(theme.colors), children: _jsx(Icon, { as: Filter, transform: "scaleX(-1)", boxSize: 4, color: sidebarActiveCount > 0 ? theme.colors.accentText : theme.colors.text[500] }) }), sidebarActiveCount > 0 && (_jsx(Box, { as: "button", type: "button", "aria-label": "Clear filters", position: "absolute", top: "-6px", right: "-10px", bg:
|
|
395
|
+
}, sx: focusVisibleStyles(theme.colors), children: _jsx(Icon, { as: Filter, transform: "scaleX(-1)", boxSize: 4, color: sidebarActiveCount > 0 ? theme.colors.accentText : theme.colors.text[500] }) }), sidebarActiveCount > 0 && (_jsx(Box, { as: "button", type: "button", "aria-label": "Clear filters", position: "absolute", top: "-6px", right: "-10px", bg: clearBadge.fill, color: clearBadge.color, border: "none", borderRadius: "full", p: "1px", cursor: "pointer", onClick: (e) => {
|
|
395
396
|
var _a;
|
|
396
397
|
e.stopPropagation();
|
|
397
398
|
if (filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.onClearAllHandler) {
|
|
@@ -4,7 +4,7 @@ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useSta
|
|
|
4
4
|
import { flushSync } from "react-dom";
|
|
5
5
|
import { normalizeTableCellValue, buildTablePalette, pickTableColor } from "../../../Utils/table.js";
|
|
6
6
|
import { useCustomTheme } from "../../../Theme/useCustomTheme.js";
|
|
7
|
-
import { TableBodyLoading } from "./TableLoading.js";
|
|
7
|
+
import { LOADING_PLACEHOLDER_COLUMNS, TableBodyLoading } from "./TableLoading.js";
|
|
8
8
|
import TableActions from "./TableActions.js";
|
|
9
9
|
import { ChevronDown, ChevronRight } from "lucide-react";
|
|
10
10
|
import CheckBox from "../../Checkbox/Checkbox.js";
|
|
@@ -384,7 +384,15 @@ const TableBody = ({ data, isCheckbox, columns, startRow, rowsPerPage, columnWid
|
|
|
384
384
|
});
|
|
385
385
|
}, [data]);
|
|
386
386
|
if (isLoading && data.length === 0) {
|
|
387
|
-
|
|
387
|
+
const dataColumns = columns.filter((o) => !o.isHidden).length;
|
|
388
|
+
const cells = [
|
|
389
|
+
...(isContent ? ["blank"] : []),
|
|
390
|
+
...(isCheckbox ? ["checkbox"] : []),
|
|
391
|
+
...(rowDetail ? ["blank"] : []),
|
|
392
|
+
...Array.from({ length: dataColumns || LOADING_PLACEHOLDER_COLUMNS }, () => "bar"),
|
|
393
|
+
...(isLink ? ["blank"] : []),
|
|
394
|
+
];
|
|
395
|
+
return (_jsx(TableBodyLoading, { noOfColumns: cells.length, cells: cells, borderColor: variant.row.ruleColor, rowsCount: typeof loadingSkeletonRows === "number" ? loadingSkeletonRows : 4, rowHeight: rowHeight }));
|
|
388
396
|
}
|
|
389
397
|
if (!isLoading && data.length === 0) {
|
|
390
398
|
return (_jsx(Tr, { backgroundColor: theme.colors.background[50], children: _jsx(Td, { colSpan: totalVisibleColumns, p: 0, border: "none", children: _jsx(TableEmpty, { emptyState: emptyState }) }) }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Spinner, Th, Tr } from "@chakra-ui/react";
|
|
3
3
|
import { memo, useState } from "react";
|
|
4
4
|
import { calculateLeftOffset } from "../../../Utils/table.js";
|
|
@@ -8,16 +8,19 @@ import TableFilters from "../filters/TableFilters.js";
|
|
|
8
8
|
import { columnLabelText } from "../columnLabel.js";
|
|
9
9
|
import { ChevronDown, ChevronsUpDown, ChevronUp } from "lucide-react";
|
|
10
10
|
import CheckBox from "../../Checkbox/Checkbox.js";
|
|
11
|
+
import Skeletons from "../../Skeletons/Skeletons.js";
|
|
11
12
|
import { useTableVariant } from "../variants/TableVariantContext.js";
|
|
12
13
|
import { transitionFor } from "../../../Theme/tokens/primitives/motion.js";
|
|
14
|
+
import { BORDER_WIDTHS } from "../../../Theme/tokens/primitives/borderWidths.js";
|
|
13
15
|
import { reducedMotionSx } from "../../../Theme/chakra/motion.js";
|
|
14
16
|
import { focusVisibleRing } from "../../../Theme/chakra/focusRing.styles.js";
|
|
15
17
|
import { DETAIL_SLOT_PX, RowDetailHeaderCell } from "./rowDetail.js";
|
|
18
|
+
import { LOADING_PLACEHOLDER_COLUMNS } from "./TableLoading.js";
|
|
16
19
|
const LABEL_JUSTIFY = { start: "space-between", center: "center", end: "flex-start" };
|
|
17
20
|
const TableHeader = ({ columns, isCheckbox, handleSort, headerRefs, columnWidths, slotRef, slotWidth, columnsSort, freezedTextColor, noBorders, handleCheckbox, checked, isLoading, isContent, isLink, hasDetail = false, isActionFreeze, setColumnsSearch, columnsSearch, isSelecting, }) => {
|
|
18
21
|
const [openFilterId, setOpenFilterId] = useState(null);
|
|
19
22
|
const variant = useTableVariant();
|
|
20
|
-
return (_jsxs(Tr, { pr: 0, "aria-rowindex": 1, children: [isContent && _jsx(ContentSpacerCell, { noBorders: noBorders }), isCheckbox && (_jsx(SelectAllCell, { slotRef: slotRef, freezedTextColor: freezedTextColor, noBorders: noBorders, isSelecting: isSelecting, isLoading: isLoading, checked: checked, handleCheckbox: handleCheckbox })), hasDetail && (_jsx(RowDetailHeaderCell, { left: isCheckbox ? slotWidth : 0, bg: variant.header.bg, ruleColor: variant.header.ruleColor, noBorders: noBorders })), columns.map((header, index) => {
|
|
23
|
+
return (_jsxs(Tr, { pr: 0, "aria-rowindex": 1, children: [isContent && _jsx(ContentSpacerCell, { noBorders: noBorders }), isCheckbox && (_jsx(SelectAllCell, { slotRef: slotRef, freezedTextColor: freezedTextColor, noBorders: noBorders, isSelecting: isSelecting, isLoading: isLoading, checked: checked, handleCheckbox: handleCheckbox })), hasDetail && (_jsx(RowDetailHeaderCell, { left: isCheckbox ? slotWidth : 0, bg: variant.header.bg, ruleColor: variant.header.ruleColor, noBorders: noBorders })), isLoading && !columns.some((header) => !(header === null || header === void 0 ? void 0 : header.isHidden)) && (_jsx(LoadingHeaderCells, { noBorders: noBorders })), columns.map((header, index) => {
|
|
21
24
|
if (header === null || header === void 0 ? void 0 : header.isHidden)
|
|
22
25
|
return null;
|
|
23
26
|
return (_jsx(ColumnHeader, { header: header, index: index, columnWidths: columnWidths, slotWidth: slotWidth, detailWidth: hasDetail ? DETAIL_SLOT_PX : 0, handleSort: handleSort, isCheckbox: isCheckbox, noBorders: noBorders, columnsSort: columnsSort, headerRefs: headerRefs, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch, openFilterId: openFilterId, setOpenFilterId: setOpenFilterId }, columnLabelText(header)));
|
|
@@ -27,8 +30,12 @@ export default memo(TableHeader);
|
|
|
27
30
|
const SelectAllCell = memo(({ slotRef, freezedTextColor, noBorders, isSelecting, isLoading, checked, handleCheckbox, }) => {
|
|
28
31
|
const theme = useCustomTheme();
|
|
29
32
|
const variant = useTableVariant();
|
|
30
|
-
return (_jsx(Th, { ref: slotRef, scope: "col", w: variant.slot.width, minW: variant.slot.width, px: variant.slot.centered ? 0 : undefined, textAlign: variant.slot.centered ? "center" : undefined, fontSize: 14, fontWeight: 600, color: freezedTextColor, textTransform: "capitalize", backgroundColor: variant.header.bg, position: "sticky", className: `columns sticky-columns`, left: "0px", zIndex: 9, borderBottom: noBorders ? "none" : `0.063rem solid ${variant.header.ruleColor}`, children: _jsx(Box, { display: "flex", alignItems: "center", justifyContent: "center", children: isSelecting ? (_jsx(Spinner, { size: "sm", color: theme.colors.accentText })) : (_jsx(CheckBox, { "aria-label": "Select all rows", variant: "outline", onChange: () => handleCheckbox(0), isChecked: isLoading ? false : checked === true, isIndeterminate: checked === "indeterminate" })) }) }));
|
|
33
|
+
return (_jsx(Th, { ref: slotRef, scope: "col", w: variant.slot.width, minW: variant.slot.width, px: variant.slot.centered ? 0 : undefined, textAlign: variant.slot.centered ? "center" : undefined, fontSize: 14, fontWeight: 600, color: freezedTextColor, textTransform: "capitalize", backgroundColor: variant.header.bg, position: "sticky", className: `columns sticky-columns`, left: "0px", zIndex: 9, borderBottom: noBorders ? "none" : `0.063rem solid ${variant.header.ruleColor}`, children: _jsx(Box, { display: "flex", alignItems: "center", justifyContent: "center", children: isSelecting ? (_jsx(Spinner, { size: "sm", color: theme.colors.accentText })) : (_jsx(CheckBox, { "aria-label": "Select all rows", variant: "outline", onChange: () => handleCheckbox(0), isChecked: isLoading ? false : checked === true, isDisabled: isLoading, isIndeterminate: checked === "indeterminate" })) }) }));
|
|
31
34
|
});
|
|
35
|
+
const LoadingHeaderCells = ({ noBorders }) => {
|
|
36
|
+
const variant = useTableVariant();
|
|
37
|
+
return (_jsx(_Fragment, { children: Array.from({ length: LOADING_PLACEHOLDER_COLUMNS }, (_, i) => (_jsx(Th, { scope: "col", "aria-hidden": "true", px: 3, backgroundColor: variant.header.bg, borderBottom: noBorders ? "none" : `${BORDER_WIDTHS.hairline} solid ${variant.header.ruleColor}`, children: _jsx(Skeletons, { type: "skeleton", height: "0.75rem", width: i % 2 ? "50%" : "70%", borderRadius: "full" }) }, i))) }));
|
|
38
|
+
};
|
|
32
39
|
const ContentSpacerCell = memo(({ noBorders }) => {
|
|
33
40
|
const variant = useTableVariant();
|
|
34
41
|
return (_jsx(Th, { scope: "col", w: 6, minW: "35px", p: 0, backgroundColor: variant.header.bg, borderBottom: noBorders ? "none" : `0.063rem solid ${variant.header.ruleColor}`, position: "sticky", className: `columns sticky-columns`, left: "0px", zIndex: 1 }));
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Box,
|
|
2
|
+
import { Box, SkeletonText, Table, Tbody, Td, Th, Thead, Tr, } from "@chakra-ui/react";
|
|
3
|
+
import Skeletons from "../../Skeletons/Skeletons.js";
|
|
4
|
+
import { BORDER_WIDTHS } from "../../../Theme/tokens/primitives/borderWidths.js";
|
|
5
|
+
const CHECKBOX_PLACEHOLDER_STYLE = { display: "inline-block", verticalAlign: "middle" };
|
|
3
6
|
const TableLoading = () => {
|
|
4
|
-
return (_jsx(Box, { overflowX: "auto", p: 4, children: _jsxs(Table, { variant: "simple", width: "full", children: [_jsx(Thead, { children: _jsxs(Tr, { children: [_jsx(Th, { p: 2, children: _jsx(
|
|
7
|
+
return (_jsx(Box, { overflowX: "auto", p: 4, children: _jsxs(Table, { variant: "simple", width: "full", children: [_jsx(Thead, { children: _jsxs(Tr, { children: [_jsx(Th, { p: 2, children: _jsx(Skeletons, { type: "skeleton", height: "20px" }) }), _jsx(Th, { p: 2, children: _jsx(Skeletons, { type: "skeleton", height: "20px" }) }), _jsx(Th, { p: 2, children: _jsx(Skeletons, { type: "skeleton", height: "20px" }) }), _jsx(Th, { p: 2, children: _jsx(Skeletons, { type: "skeleton", height: "20px" }) })] }) }), _jsx(Tbody, { children: Array.from({ length: 5 }).map((_, rowIndex) => (_jsxs(Tr, { children: [_jsx(Td, { p: 2, children: _jsx(SkeletonText, { noOfLines: 1, skeletonHeight: "2" }) }), _jsx(Td, { p: 2, children: _jsx(SkeletonText, { noOfLines: 1, skeletonHeight: "2" }) }), _jsx(Td, { p: 2, children: _jsx(SkeletonText, { noOfLines: 1, skeletonHeight: "2" }) }), _jsx(Td, { p: 2, children: _jsx(SkeletonText, { noOfLines: 1, skeletonHeight: "2" }) })] }, rowIndex))) })] }) }));
|
|
5
8
|
};
|
|
6
9
|
export default TableLoading;
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
export const LOADING_PLACEHOLDER_COLUMNS = 4;
|
|
11
|
+
const BAR_WIDTHS = ["72%", "58%", "84%", "46%", "66%", "78%"];
|
|
12
|
+
export const TableBodyLoading = ({ noOfColumns, cells, borderColor, rowsCount = 4, rowHeight = 45, }) => {
|
|
13
|
+
const layout = cells !== null && cells !== void 0 ? cells : Array.from({ length: noOfColumns }, () => "bar");
|
|
14
|
+
return (_jsx(_Fragment, { children: Array.from({ length: rowsCount }).map((_, row) => (_jsx(Tr, { "aria-hidden": "true", children: layout.map((kind, col) => (_jsxs(Td, { px: kind === "checkbox" ? 0 : 3, py: 0, height: `${rowHeight}px`, boxSizing: "border-box", border: "none", borderBottom: `${BORDER_WIDTHS.hairline} solid ${borderColor}`, textAlign: kind === "checkbox" ? "center" : undefined, children: [kind === "checkbox" && (_jsx(Skeletons, { type: "skeleton", height: "1rem", width: "1rem", borderRadius: "sm", style: CHECKBOX_PLACEHOLDER_STYLE })), kind === "bar" && (_jsx(Skeletons, { type: "skeleton", height: "0.75rem", width: BAR_WIDTHS[(row * 3 + col) % BAR_WIDTHS.length], borderRadius: "full" }))] }, col))) }, row))) }));
|
|
11
15
|
};
|
|
@@ -6,7 +6,7 @@ import { useCustomTheme } from "../../../Theme/useCustomTheme.js";
|
|
|
6
6
|
import { raisedRule } from "../../../Theme/tokens/builders/surfaceRaised.js";
|
|
7
7
|
import { listRowBackgrounds } from "../../../Theme/tokens/builders/rowStates.js";
|
|
8
8
|
import { optionRowSpec, OPTION_ROW_RADIUS } from "../../../Theme/tokens/primitives/optionRowSizes.js";
|
|
9
|
-
import { optionRowInk, optionRowWeight } from "../../Select/optionRowInk.js";
|
|
9
|
+
import { optionRowCursorSx, optionRowInk, optionRowWeight } from "../../Select/optionRowInk.js";
|
|
10
10
|
import { useExclusiveOverlay } from "../../../Hooks/useExclusiveOverlay.js";
|
|
11
11
|
const CompactSelect = ({ options, value, placeholder = "Select", height = "22px", onSelect, size = "xs" }) => {
|
|
12
12
|
const theme = useCustomTheme();
|
|
@@ -58,18 +58,9 @@ const CompactSelect = ({ options, value, placeholder = "Select", height = "22px"
|
|
|
58
58
|
}, sx: { fontSize: "0.75rem", height: "22px" } }), _jsxs(Box, { role: "listbox", "aria-label": placeholder, maxH: "12rem", overflowY: "auto", borderTop: "1px solid", borderColor: raisedRule(theme.colors), onKeyDown: handleListKeyDown, children: [filtered.map((opt, i) => {
|
|
59
59
|
const selected = (value === null || value === void 0 ? void 0 : value.id) === opt.id;
|
|
60
60
|
const isActive = i === activeIndex;
|
|
61
|
-
const rowBg = selected
|
|
62
|
-
? isActive
|
|
63
|
-
? rowBackgrounds.selectedActive
|
|
64
|
-
: rowBackgrounds.selected
|
|
65
|
-
: isActive
|
|
66
|
-
? rowBackgrounds.active
|
|
67
|
-
: theme.colors.transparent;
|
|
68
61
|
return (_jsxs(Box, { as: "button", type: "button", role: "option", "aria-selected": selected, tabIndex: isActive ? 0 : -1, ref: (el) => {
|
|
69
62
|
optionRefs.current[i] = el;
|
|
70
|
-
}, w: `calc(100% - 2 * ${spec.mx})`, minH: spec.minH, textAlign: "left", border: "none", fontFamily: "inherit", display: "flex", alignItems: "center", gap: spec.gap, mx: spec.mx, px: spec.px, py: spec.py, borderRadius: OPTION_ROW_RADIUS, cursor: "pointer", color: optionRowInk(theme.colors, selected), fontSize: spec.fontSize, fontWeight: optionRowWeight(selected),
|
|
71
|
-
bg: selected ? rowBackgrounds.selectedActive : rowBackgrounds.active,
|
|
72
|
-
}, bg: rowBg, onClick: () => {
|
|
63
|
+
}, w: `calc(100% - 2 * ${spec.mx})`, minH: spec.minH, textAlign: "left", border: "none", fontFamily: "inherit", display: "flex", alignItems: "center", gap: spec.gap, mx: spec.mx, px: spec.px, py: spec.py, borderRadius: OPTION_ROW_RADIUS, cursor: "pointer", color: optionRowInk(theme.colors, selected), fontSize: spec.fontSize, fontWeight: optionRowWeight(selected), bg: "transparent", ...optionRowCursorSx(rowBackgrounds), onClick: () => {
|
|
73
64
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(opt);
|
|
74
65
|
setIsOpen(false);
|
|
75
66
|
setQuery("");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo } from "react";
|
|
2
2
|
import { useCustomTheme } from "../../../Theme/useCustomTheme.js";
|
|
3
3
|
import { isDarkCanvas } from "../../../Theme/tokens/builders/accentText.js";
|
|
4
|
-
import {
|
|
4
|
+
import { studioPreset } from "./studio.js";
|
|
5
5
|
const TableVariantContext = createContext(null);
|
|
6
6
|
export const TableVariantProvider = TableVariantContext.Provider;
|
|
7
|
-
/** No provider means the
|
|
7
|
+
/** No provider means the default variant — studio, the same preset `Table` falls back to. */
|
|
8
8
|
export function useTableVariant() {
|
|
9
9
|
const provided = useContext(TableVariantContext);
|
|
10
10
|
const theme = useCustomTheme();
|
|
11
11
|
const isDark = isDarkCanvas(theme.colors.backgroundColor.main);
|
|
12
|
-
return useMemo(() => provided !== null && provided !== void 0 ? provided :
|
|
12
|
+
return useMemo(() => provided !== null && provided !== void 0 ? provided : studioPreset(theme.colors, isDark), [provided, theme.colors, isDark]);
|
|
13
13
|
}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useId, useRef } from "react";
|
|
3
3
|
import { Alert, AlertDescription, AlertIcon, AlertTitle, Box, Flex, Heading, ListItem, Text, UnorderedList, } from "@chakra-ui/react";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
|
+
import { raisedRule } from "../../Theme/tokens/builders/surfaceRaised.js";
|
|
5
6
|
import Modal, { ModalBody, ModalFooter } from "../Modal/Modal.js";
|
|
6
7
|
import Button from "../Button/Button.js";
|
|
7
8
|
import StageProgress from "../StageProgress/StageProgress.js";
|
|
@@ -44,15 +45,26 @@ const WizardFooter = ({ flow, labels, isFinishing, finishDisabled, finishBlocked
|
|
|
44
45
|
const reason = finishDisabled && !isFinishing ? finishBlockedReason : undefined;
|
|
45
46
|
return (_jsxs(Flex, { w: "100%", justify: "space-between", gap: 2, wrap: "wrap", children: [onCancel ? (_jsx(Button, { variant: "ghost", colorScheme: "gray", label: labels.cancel, onClick: onCancel, isDisabled: isFinishing, "data-testid": "wizard-cancel" })) : (_jsx("span", {})), _jsxs(Flex, { gap: 2, align: reason ? "center" : undefined, children: [!flow.isFirst ? (_jsx(Button, { variant: "outline", colorScheme: "gray", label: labels.back, onClick: flow.back, isDisabled: isFinishing, "data-testid": "wizard-back" })) : null, flow.isLast && reason ? (_jsx(Text, { id: reasonId, fontSize: "xs", color: colors.textMuted, "data-testid": "wizard-finish-reason", children: reason })) : null, flow.isLast ? (_jsx(Button, { variant: "solid", colorScheme: "primary", label: labels.finish, onClick: flow.finish, isLoading: isFinishing, isDisabled: finishDisabled, "aria-describedby": reason ? reasonId : undefined, loadingText: labels.finish, "data-testid": "wizard-finish" })) : (_jsx(Button, { variant: "solid", colorScheme: "primary", label: labels.next, onClick: flow.next, "data-testid": "wizard-next" }))] })] }));
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
const WizardInlineFrame = ({ title, subtitle, testId, footer, children }) => {
|
|
49
|
+
const { colors } = useCustomTheme();
|
|
50
|
+
return (_jsxs(Flex, { direction: "column", gap: 4, "data-testid": testId, children: [_jsxs(Box, { children: [_jsx(Heading, { as: "h2", fontSize: "md", fontWeight: 600, color: colors.header[900], children: title }), subtitle ? (_jsx(Text, { mt: 0.5, fontSize: "sm", color: colors.textMuted, children: subtitle })) : null] }), children, _jsx(Box, { position: "sticky", bottom: 0, pt: 3, borderTopWidth: "1px", borderColor: raisedRule(colors), bg: colors.surfaceRaised, children: footer })] }));
|
|
51
|
+
};
|
|
52
|
+
/** Wizard that owns step state: validated Continue, locked future steps, error summary, review on the last step. A Modal by default; `chrome="inline"` draws it in place. */
|
|
53
|
+
export const WizardDialog = ({ isOpen, onClose, title, subtitle, steps, onFinish, isFinishing = false, finishDisabled = false, finishBlockedReason, stepId, onStepChange, size = "3xl", chrome = "modal", labels, "data-testid": testId, }) => {
|
|
49
54
|
const flow = useWizardFlow({ steps, stepId, onStepChange, onFinish, resetWhen: !isOpen });
|
|
50
55
|
const resolved = { ...DEFAULT_LABELS, ...labels };
|
|
51
56
|
const guardedClose = () => {
|
|
52
57
|
if (!isFinishing)
|
|
53
58
|
onClose();
|
|
54
59
|
};
|
|
55
|
-
|
|
60
|
+
const body = (_jsx(WizardBody, { flow: flow, steps: steps, labels: resolved, testId: testId !== null && testId !== void 0 ? testId : "wizard-dialog" }));
|
|
61
|
+
const footer = (_jsx(WizardFooter, { flow: flow, labels: resolved, isFinishing: isFinishing, finishDisabled: finishDisabled, finishBlockedReason: finishBlockedReason, onCancel: guardedClose }));
|
|
62
|
+
if (chrome === "inline") {
|
|
63
|
+
if (!isOpen)
|
|
64
|
+
return null;
|
|
65
|
+
return (_jsx(WizardInlineFrame, { title: title, subtitle: subtitle, testId: testId ? `${testId}-inline` : "wizard-inline", footer: footer, children: body }));
|
|
66
|
+
}
|
|
67
|
+
return (_jsxs(Modal, { isOpen: isOpen, onClose: guardedClose, size: size, isCentered: true, scrollBehavior: "inside", title: title, subtitle: subtitle, closeOnOverlayClick: false, closeOnEsc: !isFinishing, hideCloseButton: isFinishing, children: [_jsx(ModalBody, { children: body }), _jsx(ModalFooter, { children: footer })] }));
|
|
56
68
|
};
|
|
57
69
|
/** The same wizard inline, for a full-page flow rather than a modal. */
|
|
58
70
|
export const Wizard = ({ steps, onFinish, isFinishing = false, finishDisabled = false, finishBlockedReason, stepId, onStepChange, labels, onCancel, "data-testid": testId, }) => {
|
|
@@ -15,7 +15,11 @@ export default function WorkspaceTrayPreview({ children, preview, enabled = true
|
|
|
15
15
|
const [open, setOpen] = useState(false);
|
|
16
16
|
const openTimer = useRef(null);
|
|
17
17
|
const closeTimer = useRef(null);
|
|
18
|
+
const openRef = useRef(false);
|
|
18
19
|
const setOpenState = useCallback((next) => {
|
|
20
|
+
if (openRef.current === next)
|
|
21
|
+
return;
|
|
22
|
+
openRef.current = next;
|
|
19
23
|
setOpen(next);
|
|
20
24
|
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(next);
|
|
21
25
|
}, [onOpenChange]);
|