pixelize-design-library 2.4.2-beta.58 → 2.4.2-beta.59

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/COMPONENT-GOTCHAS.md +88 -2
  3. package/DESIGN-GUIDE.md +26 -3
  4. package/dist/Components/AppSwitcher/AppSwitcher.js +5 -1
  5. package/dist/Components/AppSwitcher/AppSwitcherProps.d.ts +2 -0
  6. package/dist/Components/AppSwitcher/AppSwitcherProps.js +7 -4
  7. package/dist/Components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  8. package/dist/Components/Breadcrumbs/Breadcrumbs.js +33 -10
  9. package/dist/Components/Breadcrumbs/BreadcrumbsProps.d.ts +16 -2
  10. package/dist/Components/Card/Card.d.ts +3 -1
  11. package/dist/Components/Card/Card.js +12 -2
  12. package/dist/Components/Card/CardProps.d.ts +5 -1
  13. package/dist/Components/Editor/Editor.js +50 -2
  14. package/dist/Components/Editor/EditorFieldBar.d.ts +15 -0
  15. package/dist/Components/Editor/EditorFieldBar.js +19 -0
  16. package/dist/Components/Editor/EditorProps.d.ts +74 -1
  17. package/dist/Components/Editor/MakeDynamicDialog.d.ts +12 -0
  18. package/dist/Components/Editor/MakeDynamicDialog.js +59 -0
  19. package/dist/Components/Editor/editorLabels.d.ts +4 -0
  20. package/dist/Components/Editor/editorLabels.js +24 -0
  21. package/dist/Components/Editor/editorTokenStyles.d.ts +28 -0
  22. package/dist/Components/Editor/editorTokenStyles.js +30 -0
  23. package/dist/Components/Editor/editorTokens.d.ts +26 -0
  24. package/dist/Components/Editor/editorTokens.js +134 -0
  25. package/dist/Components/Editor/useEditorBridge.d.ts +40 -0
  26. package/dist/Components/Editor/useEditorBridge.js +141 -0
  27. package/dist/Components/Kbd/Kbd.d.ts +6 -0
  28. package/dist/Components/Kbd/Kbd.js +33 -0
  29. package/dist/Components/Kbd/KbdProps.d.ts +17 -0
  30. package/dist/Components/Kbd/KbdProps.js +2 -0
  31. package/dist/Components/LauncherTrigger/LauncherTrigger.d.ts +4 -0
  32. package/dist/Components/LauncherTrigger/LauncherTrigger.js +41 -0
  33. package/dist/Components/LauncherTrigger/LauncherTriggerProps.d.ts +16 -0
  34. package/dist/Components/LauncherTrigger/LauncherTriggerProps.js +2 -0
  35. package/dist/Components/NavLauncher/NavLauncher.d.ts +3 -0
  36. package/dist/Components/NavLauncher/NavLauncher.js +395 -0
  37. package/dist/Components/NavLauncher/NavLauncherProps.d.ts +187 -0
  38. package/dist/Components/NavLauncher/NavLauncherProps.js +2 -0
  39. package/dist/Components/NavLauncher/NewTabLink.d.ts +3 -0
  40. package/dist/Components/NavLauncher/NewTabLink.js +14 -0
  41. package/dist/Components/NavLauncher/PinToggle.d.ts +3 -0
  42. package/dist/Components/NavLauncher/PinToggle.js +21 -0
  43. package/dist/Components/NavLauncher/launcherParts.d.ts +93 -0
  44. package/dist/Components/NavLauncher/launcherParts.js +130 -0
  45. package/dist/Components/NavLauncher/match.d.ts +53 -0
  46. package/dist/Components/NavLauncher/match.js +178 -0
  47. package/dist/Components/NavLauncher/revealStyles.d.ts +4 -0
  48. package/dist/Components/NavLauncher/revealStyles.js +19 -0
  49. package/dist/Components/NavigationBar/NavigationBar.d.ts +1 -1
  50. package/dist/Components/NavigationBar/NavigationBar.js +2 -2
  51. package/dist/Components/NavigationBar/NavigationBarProps.d.ts +2 -0
  52. package/dist/Components/PageHeader/PageHeader.d.ts +1 -1
  53. package/dist/Components/PageHeader/PageHeader.js +9 -2
  54. package/dist/Components/PageHeader/PageHeaderProps.d.ts +8 -0
  55. package/dist/Components/PdfViewer/PdfViewer.d.ts +21 -4
  56. package/dist/Components/PdfViewer/PdfViewer.js +124 -3
  57. package/dist/Components/Search/Search.js +2 -1
  58. package/dist/Components/SideBar/SecondaryBar.js +4 -3
  59. package/dist/Components/SideBar/SideBar.d.ts +1 -1
  60. package/dist/Components/SideBar/SideBar.js +30 -9
  61. package/dist/Components/SideBar/SideBarProps.d.ts +32 -0
  62. package/dist/Components/SideBar/components/MenuItemBox.d.ts +6 -0
  63. package/dist/Components/SideBar/components/MenuItemBox.js +8 -4
  64. package/dist/Components/SideBar/components/MenuPopoverContent.js +3 -2
  65. package/dist/Components/SideBar/components/OtherApps.js +2 -1
  66. package/dist/Components/SideBar/components/PinnedSection.d.ts +17 -0
  67. package/dist/Components/SideBar/components/PinnedSection.js +98 -0
  68. package/dist/Components/SideBar/sidebarFocus.d.ts +23 -0
  69. package/dist/Components/SideBar/sidebarFocus.js +20 -0
  70. package/dist/Components/StageProgress/StageProgress.js +2 -2
  71. package/dist/Components/StageProgress/StageProgressProps.d.ts +2 -0
  72. package/dist/Components/StageProgress/StepperStage.js +5 -2
  73. package/dist/Components/WizardDialog/WizardDialog.d.ts +9 -0
  74. package/dist/Components/WizardDialog/WizardDialog.js +102 -0
  75. package/dist/Components/WizardDialog/WizardDialogProps.d.ts +48 -0
  76. package/dist/Components/WizardDialog/WizardDialogProps.js +2 -0
  77. package/dist/Components/WizardDialog/useWizardFlow.d.ts +22 -0
  78. package/dist/Components/WizardDialog/useWizardFlow.js +47 -0
  79. package/dist/Components/WizardDialog/wizardSteps.d.ts +31 -0
  80. package/dist/Components/WizardDialog/wizardSteps.js +40 -0
  81. package/dist/esm/Components/AppSwitcher/AppSwitcher.js +2 -1
  82. package/dist/esm/Components/AppSwitcher/AppSwitcherProps.js +5 -3
  83. package/dist/esm/Components/Breadcrumbs/Breadcrumbs.js +35 -12
  84. package/dist/esm/Components/Card/Card.js +12 -2
  85. package/dist/esm/Components/Editor/Editor.js +48 -3
  86. package/dist/esm/Components/Editor/EditorFieldBar.js +13 -0
  87. package/dist/esm/Components/Editor/MakeDynamicDialog.js +20 -0
  88. package/dist/esm/Components/Editor/editorLabels.js +20 -0
  89. package/dist/esm/Components/Editor/editorTokenStyles.js +25 -0
  90. package/dist/esm/Components/Editor/editorTokens.js +121 -0
  91. package/dist/esm/Components/Editor/useEditorBridge.js +138 -0
  92. package/dist/esm/Components/Kbd/Kbd.js +28 -0
  93. package/dist/esm/Components/Kbd/KbdProps.js +1 -0
  94. package/dist/esm/Components/LauncherTrigger/LauncherTrigger.js +37 -0
  95. package/dist/esm/Components/LauncherTrigger/LauncherTriggerProps.js +1 -0
  96. package/dist/esm/Components/NavLauncher/NavLauncher.js +356 -0
  97. package/dist/esm/Components/NavLauncher/NavLauncherProps.js +1 -0
  98. package/dist/esm/Components/NavLauncher/NewTabLink.js +11 -0
  99. package/dist/esm/Components/NavLauncher/PinToggle.js +18 -0
  100. package/dist/esm/Components/NavLauncher/launcherParts.js +110 -0
  101. package/dist/esm/Components/NavLauncher/match.js +172 -0
  102. package/dist/esm/Components/NavLauncher/revealStyles.js +15 -0
  103. package/dist/esm/Components/NavigationBar/NavigationBar.js +3 -3
  104. package/dist/esm/Components/PageHeader/PageHeader.js +9 -2
  105. package/dist/esm/Components/PdfViewer/PdfViewer.js +123 -2
  106. package/dist/esm/Components/Search/Search.js +3 -2
  107. package/dist/esm/Components/SideBar/SecondaryBar.js +4 -3
  108. package/dist/esm/Components/SideBar/SideBar.js +31 -10
  109. package/dist/esm/Components/SideBar/components/MenuItemBox.js +4 -2
  110. package/dist/esm/Components/SideBar/components/MenuPopoverContent.js +3 -2
  111. package/dist/esm/Components/SideBar/components/OtherApps.js +2 -1
  112. package/dist/esm/Components/SideBar/components/PinnedSection.js +92 -0
  113. package/dist/esm/Components/SideBar/sidebarFocus.js +15 -0
  114. package/dist/esm/Components/StageProgress/StageProgress.js +2 -2
  115. package/dist/esm/Components/StageProgress/StepperStage.js +5 -2
  116. package/dist/esm/Components/WizardDialog/WizardDialog.js +58 -0
  117. package/dist/esm/Components/WizardDialog/WizardDialogProps.js +1 -0
  118. package/dist/esm/Components/WizardDialog/useWizardFlow.js +44 -0
  119. package/dist/esm/Components/WizardDialog/wizardSteps.js +35 -0
  120. package/dist/esm/index.js +7 -0
  121. package/dist/index.d.ts +19 -4
  122. package/dist/index.js +21 -1
  123. package/package.json +1 -1
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const react_1 = require("@chakra-ui/react");
5
5
  const useCustomTheme_1 = require("../../../Theme/useCustomTheme");
6
+ const sidebarFocus_1 = require("../sidebarFocus");
6
7
  const OtherApps = ({ toggle, otherApps }) => {
7
8
  const theme = (0, useCustomTheme_1.useCustomTheme)();
8
9
  if (!otherApps || otherApps.length === 0)
@@ -12,7 +13,7 @@ const OtherApps = ({ toggle, otherApps }) => {
12
13
  return ((0, jsx_runtime_1.jsx)(react_1.Box, { display: "flex", alignItems: "center", justifyContent: "center", color: theme.colors.sidebar.mutedIcon, fontSize: "15px", flexShrink: 0, children: (_a = app.icon) !== null && _a !== void 0 ? _a : ((0, jsx_runtime_1.jsx)(react_1.Box, { w: "0.5rem", h: "0.5rem", borderRadius: "full", bg: app.color, boxShadow: `0 0 5px ${app.color}`, flexShrink: 0 })) }));
13
14
  };
14
15
  // Grid cell: icon on top, truncated label below (label hidden when collapsed).
15
- const appCell = (app) => ((0, jsx_runtime_1.jsxs)(react_1.Flex, { as: "button", type: "button", direction: "column", align: "center", justify: "center", gap: "3px", px: "2px", py: "6px", borderRadius: "lg", cursor: "pointer", border: "none", bg: "transparent", w: "100%", _hover: { backgroundColor: "whiteAlpha.200" }, transition: "background 0.12s", onClick: app.onClick, children: [appIcon(app), !toggle && ((0, jsx_runtime_1.jsx)(react_1.Text, { fontSize: "9.5px", color: theme.colors.sidebar.mutedLabel, textAlign: "center", maxW: "44px", isTruncated: true, children: app.name }))] }));
16
+ const appCell = (app) => ((0, jsx_runtime_1.jsxs)(react_1.Flex, { as: "button", type: "button", direction: "column", align: "center", justify: "center", gap: "3px", px: "2px", py: "6px", borderRadius: "lg", cursor: "pointer", border: "none", bg: "transparent", w: "100%", _hover: { backgroundColor: "whiteAlpha.200" }, transition: "background 0.12s", sx: (0, sidebarFocus_1.sidebarFocusStyles)(theme.colors), onClick: app.onClick, children: [appIcon(app), !toggle && ((0, jsx_runtime_1.jsx)(react_1.Text, { fontSize: "9.5px", color: theme.colors.sidebar.mutedLabel, textAlign: "center", maxW: "44px", isTruncated: true, children: app.name }))] }));
16
17
  const flyoutBody = (app) => {
17
18
  var _a;
18
19
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_1.Flex, { alignItems: "center", gap: 2, mb: 1, onClick: app.onClick, children: [(_a = app.icon) !== null && _a !== void 0 ? _a : ((0, jsx_runtime_1.jsx)(react_1.Box, { w: "0.5rem", h: "0.5rem", borderRadius: "full", bg: app.color, boxShadow: `0 0 5px ${app.color}`, flexShrink: 0 })), (0, jsx_runtime_1.jsx)(react_1.Text, { fontSize: "sm", fontWeight: 700, color: theme.colors.white, children: app.name })] }), app.description && ((0, jsx_runtime_1.jsx)(react_1.Text, { fontSize: "xs", color: theme.colors.sidebar.mutedLabel, children: app.description }))] }));
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import type { SidebarPinnedItem, SidebarPinnedLabels } from "../SideBarProps";
3
+ export declare const DEFAULT_PINNED_LABEL = "Pinned";
4
+ export declare const DEFAULT_PINNED_LIMIT = 5;
5
+ type PinnedSectionProps = {
6
+ items: SidebarPinnedItem[];
7
+ label?: string;
8
+ limit?: number;
9
+ toggle: boolean;
10
+ overlay: boolean;
11
+ activeId?: string | number | null;
12
+ labels?: SidebarPinnedLabels;
13
+ onItemClick: (item: SidebarPinnedItem) => void;
14
+ onUnpin?: (item: SidebarPinnedItem) => void;
15
+ };
16
+ declare const PinnedSection: React.FC<PinnedSectionProps>;
17
+ export default PinnedSection;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_PINNED_LIMIT = exports.DEFAULT_PINNED_LABEL = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
9
+ const react_2 = require("@chakra-ui/react");
10
+ const lucide_react_1 = require("lucide-react");
11
+ const useCustomTheme_1 = require("../../../Theme/useCustomTheme");
12
+ const sidebarFocus_1 = require("../sidebarFocus");
13
+ const tone_1 = require("../../../Theme/tokens/builders/tone");
14
+ const sidebarAccent_1 = require("../../../Theme/tokens/builders/sidebarAccent");
15
+ const paletteFromTheme_1 = require("../../../Theme/chakra/paletteFromTheme");
16
+ const sidebarAccentColors_1 = require("../sidebarAccentColors");
17
+ const sidebarId_1 = require("../sidebarId");
18
+ const sidebarScale_1 = require("../sidebarScale");
19
+ const ToolTip_1 = __importDefault(require("../../ToolTip/ToolTip"));
20
+ const TextTruncation_1 = __importDefault(require("./TextTruncation"));
21
+ const MenuItemBox_1 = require("./MenuItemBox");
22
+ exports.DEFAULT_PINNED_LABEL = "Pinned";
23
+ exports.DEFAULT_PINNED_LIMIT = 5;
24
+ const DEFAULT_LABELS = {
25
+ showMore: "Show {count} more",
26
+ showLess: "Show less",
27
+ unpin: "Unpin {title}",
28
+ };
29
+ const UNPIN_SIZE = "24px";
30
+ const LADDER = { hover: "whiteAlpha.200", active: "whiteAlpha.300", activeHover: "whiteAlpha.400" };
31
+ const VISUALLY_HIDDEN = {
32
+ position: "absolute",
33
+ width: "1px",
34
+ height: "1px",
35
+ padding: 0,
36
+ margin: "-1px",
37
+ clip: "rect(0, 0, 0, 0)",
38
+ whiteSpace: "nowrap",
39
+ border: 0,
40
+ };
41
+ const readBadge = (badge) => {
42
+ var _a;
43
+ const cfg = typeof badge === "object" && badge !== null ? badge : null;
44
+ const value = (_a = cfg === null || cfg === void 0 ? void 0 : cfg.count) !== null && _a !== void 0 ? _a : (typeof badge !== "object" ? badge : undefined);
45
+ return { cfg, value };
46
+ };
47
+ const PinnedSection = ({ items, label = exports.DEFAULT_PINNED_LABEL, limit = exports.DEFAULT_PINNED_LIMIT, toggle, overlay, activeId, labels, onItemClick, onUnpin, }) => {
48
+ const theme = (0, useCustomTheme_1.useCustomTheme)();
49
+ const activeAccent = (0, sidebarAccentColors_1.getSidebarActiveAccent)(theme.colors);
50
+ const text = { ...DEFAULT_LABELS, ...labels };
51
+ const headingId = `pinned-${(0, sidebarId_1.sanitizeId)((0, react_1.useId)())}`;
52
+ const cap = Math.max(1, limit);
53
+ const rowHeight = overlay ? sidebarScale_1.SIDEBAR_ROW.overlayHeight : sidebarScale_1.SIDEBAR_ROW.height;
54
+ const activeIndex = activeId == null ? -1 : items.findIndex((i) => String(i.id) === String(activeId));
55
+ const [showAll, setShowAll] = (0, react_1.useState)(activeIndex >= cap);
56
+ (0, react_1.useEffect)(() => {
57
+ if (activeIndex >= cap)
58
+ setShowAll(true);
59
+ }, [activeIndex, cap]);
60
+ if (items.length === 0)
61
+ return null;
62
+ const hiddenCount = Math.max(0, items.length - cap);
63
+ const visible = showAll ? items : items.slice(0, cap);
64
+ const badgeSurface = (0, sidebarAccent_1.sidebarRowPeak)(theme.colors.sidebar.background[500]);
65
+ const unpinReplacesBadge = !!onUnpin && !overlay;
66
+ const renderBadge = (badge) => {
67
+ var _a, _b, _c;
68
+ const { cfg, value } = readBadge(badge);
69
+ if (value == null)
70
+ return null;
71
+ const tone = (0, tone_1.resolveSoftTone)(theme.colors, (0, paletteFromTheme_1.scaleFor)(theme.colors, (_a = cfg === null || cfg === void 0 ? void 0 : cfg.color) !== null && _a !== void 0 ? _a : "teal"), badgeSurface);
72
+ return ((0, jsx_runtime_1.jsx)(react_2.Badge, { bg: tone.bg, color: tone.fg, fontSize: "xs", variant: (_b = cfg === null || cfg === void 0 ? void 0 : cfg.variant) !== null && _b !== void 0 ? _b : "subtle", borderRadius: (_c = cfg === null || cfg === void 0 ? void 0 : cfg.radius) !== null && _c !== void 0 ? _c : "full", ...(unpinReplacesBadge
73
+ ? { _groupHover: { opacity: 0 }, _groupFocusWithin: { opacity: 0 } }
74
+ : {}), children: value }));
75
+ };
76
+ const renderRow = (item) => {
77
+ const isActive = activeIndex >= 0 && String(item.id) === String(activeId);
78
+ const anchor = ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "a", href: item.url, "data-group": "", "data-pinned-id": String(item.id), "aria-label": toggle ? item.title : undefined, "aria-current": isActive ? "page" : undefined, display: "flex", alignItems: "center", textAlign: "left", textDecoration: "none", w: "100%", h: rowHeight, borderRadius: "lg", pl: "10px", pr: !toggle && onUnpin ? `calc(10px + ${UNPIN_SIZE})` : "10px", fontWeight: "medium", borderLeft: "2px solid", borderLeftColor: isActive ? theme.colors.sidebar.activeIcon : "transparent", backgroundColor: isActive ? LADDER.active : "transparent", color: theme.colors.sidebar.mutedIcon, _hover: { backgroundColor: isActive ? LADDER.activeHover : LADDER.hover }, cursor: "pointer", transition: "background 0.12s", sx: (0, sidebarFocus_1.sidebarFocusStyles)(theme.colors), onClick: (e) => {
79
+ if (item.url && (0, MenuItemBox_1.isBrowserNavigationGesture)(e))
80
+ return;
81
+ e.preventDefault();
82
+ onItemClick(item);
83
+ }, children: (0, jsx_runtime_1.jsxs)(react_2.Flex, { align: "center", gap: "9px", justify: toggle ? "center" : "space-between", w: "100%", children: [(0, jsx_runtime_1.jsxs)(react_2.Flex, { align: "center", gap: "9px", overflow: "hidden", flex: toggle ? undefined : 1, minW: 0, children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { position: "relative", display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(react_2.Icon, { as: item.icon, fontSize: "md", color: isActive ? activeAccent.icon : theme.colors.sidebar.mutedIcon, _groupHover: isActive ? undefined : { color: theme.colors.white }, transition: "color 0.12s" }), toggle && readBadge(item.badge).value != null && ((0, jsx_runtime_1.jsx)(react_2.Box, { position: "absolute", top: "0", right: "0", w: "0.375rem", h: "0.375rem", borderRadius: "full", bg: theme.colors.sidebar.semanticText.error }))] }), !toggle && ((0, jsx_runtime_1.jsx)(TextTruncation_1.default, { fontSize: sidebarScale_1.SIDEBAR_ROW.fontSize, lineHeight: "1", flex: "1", color: isActive ? activeAccent.label : theme.colors.white, fontWeight: isActive ? 600 : 500, _groupHover: isActive ? undefined : { color: theme.colors.white }, children: item.title }))] }), !toggle && renderBadge(item.badge)] }) }));
84
+ return ((0, jsx_runtime_1.jsxs)(react_2.Box, { as: "li", listStyleType: "none", position: "relative", "data-group": "", children: [toggle ? ((0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: item.title, placement: "right", children: anchor })) : (anchor), onUnpin && !toggle && ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "button", type: "button", "aria-label": text.unpin.replace("{title}", item.title), onClick: () => onUnpin(item), position: "absolute", top: "50%", right: "6px", transform: "translateY(-50%)", w: UNPIN_SIZE, h: UNPIN_SIZE, display: "flex", alignItems: "center", justifyContent: "center", borderRadius: "lg", border: "none", bg: "transparent", cursor: "pointer", color: theme.colors.sidebar.mutedIcon, opacity: overlay ? 1 : 0, _groupHover: { opacity: 1 }, _groupFocusWithin: { opacity: 1 }, _hover: {
85
+ bg: LADDER.active,
86
+ color: theme.colors.white,
87
+ }, transition: "opacity 0.12s, background 0.12s", sx: (0, sidebarFocus_1.sidebarFocusStyles)(theme.colors), children: (0, jsx_runtime_1.jsx)(react_2.Icon, { as: lucide_react_1.PinOff, fontSize: "sm" }) }))] }, String(item.id)));
88
+ };
89
+ const disclosureLabel = showAll
90
+ ? text.showLess
91
+ : text.showMore.replace("{count}", String(hiddenCount));
92
+ const disclosureButton = ((0, jsx_runtime_1.jsxs)(react_2.Box, { as: "button", type: "button", "aria-expanded": showAll, "aria-label": toggle ? disclosureLabel : undefined, onClick: () => setShowAll((v) => !v), display: "flex", alignItems: "center", justifyContent: toggle ? "center" : "flex-start", gap: "9px", w: "100%", h: rowHeight, px: "10px", borderRadius: "lg", border: "none", borderLeft: "2px solid transparent", bg: "transparent", cursor: "pointer", color: theme.colors.sidebar.mutedLabel, fontSize: sidebarScale_1.SIDEBAR_ROW.fontSize, fontWeight: "medium", _hover: {
93
+ backgroundColor: LADDER.hover,
94
+ color: theme.colors.white,
95
+ }, transition: "background 0.12s", sx: (0, sidebarFocus_1.sidebarFocusStyles)(theme.colors), children: [(0, jsx_runtime_1.jsx)(react_2.Icon, { as: showAll ? lucide_react_1.ChevronUp : lucide_react_1.ChevronDown, fontSize: "md", flexShrink: 0 }), !toggle && (0, jsx_runtime_1.jsx)("span", { children: disclosureLabel })] }));
96
+ return ((0, jsx_runtime_1.jsxs)(react_2.Box, { mb: toggle ? "5px" : "3px", "data-testid": "sidebar-pinned", children: [(0, jsx_runtime_1.jsx)(react_2.Box, { id: headingId, as: "h2", px: "10px", pt: overlay ? "6px" : "10px", pb: "3px", fontSize: "9.5px", fontWeight: 600, textTransform: "uppercase", letterSpacing: "0.1em", color: theme.colors.sidebar.mutedLabel, whiteSpace: "nowrap", overflow: "hidden", sx: toggle ? VISUALLY_HIDDEN : undefined, children: label }), (0, jsx_runtime_1.jsxs)(react_2.Box, { as: "ul", "aria-labelledby": headingId, display: "flex", flexDirection: "column", gap: "2px", m: 0, p: 0, children: [visible.map(renderRow), hiddenCount > 0 && ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "li", listStyleType: "none", children: toggle ? ((0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: disclosureLabel, placement: "right", children: disclosureButton })) : (disclosureButton) }))] }), (0, jsx_runtime_1.jsx)(react_2.Box, { h: "1px", bg: theme.colors.sidebar.divider, mx: 2, mt: overlay ? "6px" : "8px", mb: overlay ? "3px" : "5px" })] }));
97
+ };
98
+ exports.default = PinnedSection;
@@ -0,0 +1,23 @@
1
+ import type { PaletteProps } from "../../Theme/tokens/types";
2
+ type RailColors = Pick<PaletteProps, "focusRing" | "sidebar">;
3
+ /** The ring is derived for the canvas; the rail is near-black in both modes, so it is re-settled against the rail. */
4
+ export declare const sidebarFocusRing: (colors: RailColors, surface?: string) => {
5
+ focusRing: {
6
+ ring: string;
7
+ halo: string;
8
+ };
9
+ };
10
+ /** `focusVisibleStyles` for a control sitting on the rail (or on `surface`, e.g. the flyout). */
11
+ export declare const sidebarFocusStyles: (colors: RailColors, surface?: string) => {
12
+ _focusVisible: {
13
+ outline: string;
14
+ outlineOffset: string;
15
+ boxShadow: string;
16
+ };
17
+ "&:hover:focus-visible, &:active:focus-visible, &[data-active]:focus-visible": {
18
+ outline: string;
19
+ outlineOffset: string;
20
+ boxShadow: string;
21
+ };
22
+ };
23
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sidebarFocusStyles = exports.sidebarFocusRing = void 0;
4
+ const focusRing_styles_1 = require("../../Theme/chakra/focusRing.styles");
5
+ const outlineRung_1 = require("../../Theme/tokens/builders/outlineRung");
6
+ const cache = new Map();
7
+ /** The ring is derived for the canvas; the rail is near-black in both modes, so it is re-settled against the rail. */
8
+ const sidebarFocusRing = (colors, surface = colors.sidebar.background[500]) => {
9
+ const key = `${colors.focusRing.ring}|${surface}`;
10
+ let tokens = cache.get(key);
11
+ if (!tokens) {
12
+ tokens = { ring: (0, outlineRung_1.liftToContrast)(colors.focusRing.ring, surface, outlineRung_1.AA_NON_TEXT), halo: surface };
13
+ cache.set(key, tokens);
14
+ }
15
+ return { focusRing: tokens };
16
+ };
17
+ exports.sidebarFocusRing = sidebarFocusRing;
18
+ /** `focusVisibleStyles` for a control sitting on the rail (or on `surface`, e.g. the flyout). */
19
+ const sidebarFocusStyles = (colors, surface) => (0, focusRing_styles_1.focusVisibleStyles)((0, exports.sidebarFocusRing)(colors, surface));
20
+ exports.sidebarFocusStyles = sidebarFocusStyles;
@@ -32,12 +32,12 @@ const StageProgress = ({ stages, variant = "chevron", value, onChange, size = "m
32
32
  return "upcoming";
33
33
  };
34
34
  const total = stages.length;
35
- return ((0, jsx_runtime_1.jsx)(react_1.Box, { display: "flex", alignItems: variant === "stepper" ? "flex-start" : "stretch", gap: gapFor[variant], overflowX: "auto", p: "0.1rem", sx: (0, scrollbar_1.scrollbarStyles)(theme.colors, "overlay"), children: stages.map((stage, index) => {
35
+ return ((0, jsx_runtime_1.jsx)(react_1.Box, { as: variant === "stepper" ? "ol" : undefined, m: variant === "stepper" ? 0 : undefined, listStyleType: variant === "stepper" ? "none" : undefined, display: "flex", alignItems: variant === "stepper" ? "flex-start" : "stretch", gap: gapFor[variant], overflowX: "auto", p: "0.1rem", sx: (0, scrollbar_1.scrollbarStyles)(theme.colors, "overlay"), children: stages.map((stage, index) => {
36
36
  var _a;
37
37
  const state = stateFor(index);
38
38
  const stageDisabled = (_a = stage.isDisabled) !== null && _a !== void 0 ? _a : stage.disabled;
39
39
  if (variant === "stepper") {
40
- return ((0, jsx_runtime_1.jsx)(StepperStage_1.default, { label: stage.label, number: index + 1, state: state, size: size, colorScheme: colorScheme, isReadOnly: isReadOnly, isDisabled: stageDisabled, showCheck: showCheck, isFirst: index === 0, isLast: index === total - 1, leftDone: activeIndex > -1 && index <= activeIndex, rightDone: activeIndex > -1 && index < activeIndex, scrollIntoViewWhenActive: scrollActiveIntoView, onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(stage.id, stage, index) }, stage.id));
40
+ return ((0, jsx_runtime_1.jsx)(StepperStage_1.default, { label: stage.label, number: index + 1, state: state, size: size, colorScheme: colorScheme, isReadOnly: isReadOnly, isDisabled: stageDisabled, showCheck: showCheck, isFirst: index === 0, isLast: index === total - 1, leftDone: activeIndex > -1 && index <= activeIndex, rightDone: activeIndex > -1 && index < activeIndex, scrollIntoViewWhenActive: scrollActiveIntoView, asListItem: true, onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(stage.id, stage, index) }, stage.id));
41
41
  }
42
42
  return ((0, jsx_runtime_1.jsx)(StageItem_1.default, { label: stage.label, index: index, total: total, state: state, variant: variant, size: size, colorScheme: colorScheme, isReadOnly: isReadOnly, isDisabled: stageDisabled, showCheck: showCheck, minWidth: minStageWidth, scrollIntoViewWhenActive: scrollActiveIntoView, tooltipThreshold: tooltipThreshold, onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(stage.id, stage, index) }, stage.id));
43
43
  }) }));
@@ -110,6 +110,8 @@ export interface StepperStageProps {
110
110
  rightDone: boolean;
111
111
  /** Only scrolls when this node's own state is "active" — a no-op otherwise. */
112
112
  scrollIntoViewWhenActive?: boolean;
113
+ /** Wraps the node in an `li` so a parent `ol` is a valid list; StageProgress sets it for variant="stepper". */
114
+ asListItem?: boolean;
113
115
  }
114
116
  /** Color set for one scheme's states, returned by resolveStagePalette (soft/strong/muted + text). */
115
117
  export interface StagePalette {
@@ -13,7 +13,7 @@ const sizeMap = {
13
13
  md: { circle: "30px", font: "0.8rem", label: "0.8rem", icon: 14, minW: "104px" },
14
14
  lg: { circle: "38px", font: "0.95rem", label: "0.9rem", icon: 16, minW: "124px" },
15
15
  };
16
- const StepperStage = ({ label, number, state, size = "md", colorScheme = "primary", onClick, isReadOnly = false, isDisabled, disabled: legacyDisabled = false, showCheck = true, isFirst, isLast, leftDone, rightDone, scrollIntoViewWhenActive = true, }) => {
16
+ const StepperStage = ({ label, number, state, size = "md", colorScheme = "primary", onClick, isReadOnly = false, isDisabled, disabled: legacyDisabled = false, showCheck = true, isFirst, isLast, leftDone, rightDone, scrollIntoViewWhenActive = true, asListItem = false, }) => {
17
17
  const disabled = isDisabled !== null && isDisabled !== void 0 ? isDisabled : legacyDisabled;
18
18
  const theme = (0, useCustomTheme_1.useCustomTheme)();
19
19
  const palette = (0, StageProgressProps_1.resolveStagePalette)(theme, colorScheme);
@@ -35,10 +35,13 @@ const StepperStage = ({ label, number, state, size = "md", colorScheme = "primar
35
35
  const circleColor = filled ? palette.onStrong : palette.mutedText;
36
36
  const circleBorder = filled ? palette.strong : palette.muted;
37
37
  const line = (done, hidden) => ((0, jsx_runtime_1.jsx)(react_2.Box, { flex: "1", height: "2px", bg: done ? palette.strong : palette.muted, visibility: hidden ? "hidden" : "visible", transition: "background 0.18s ease" }));
38
- return ((0, jsx_runtime_1.jsxs)(react_2.Flex, { ref: ref, direction: "column", align: "center", flex: "1", minWidth: s.minW, flexShrink: 0, as: (interactive ? "button" : "div"), type: interactive ? "button" : undefined, "data-group": "", "aria-disabled": disabled ? true : undefined, border: "none", bg: "transparent", cursor: interactive ? "pointer" : "default", opacity: disabled ? 0.55 : 1, onClick: interactive ? onClick : undefined, borderRadius: "lg", sx: interactive ? (0, focusRing_styles_1.focusVisibleStyles)(theme.colors) : undefined, children: [(0, jsx_runtime_1.jsxs)(react_2.Flex, { align: "center", width: "100%", children: [line(leftDone, isFirst), (0, jsx_runtime_1.jsx)(react_2.Flex, { align: "center", justify: "center", boxSize: s.circle, borderRadius: "full", flexShrink: 0, bg: circleBg, color: circleColor, border: "2px solid", borderColor: circleBorder, fontSize: s.font, fontWeight: 600, transition: (0, primitives_1.transitionFor)(["background-color", "border-color", "color", "box-shadow"]), "aria-current": state === "active" ? "step" : undefined, sx: state === "active"
38
+ const node = ((0, jsx_runtime_1.jsxs)(react_2.Flex, { ref: ref, direction: "column", align: "center", flex: "1", minWidth: s.minW, flexShrink: 0, as: (interactive ? "button" : "div"), type: interactive ? "button" : undefined, "data-group": "", "aria-disabled": disabled ? true : undefined, border: "none", bg: "transparent", cursor: interactive ? "pointer" : "default", opacity: disabled ? 0.55 : 1, onClick: interactive ? onClick : undefined, borderRadius: "lg", sx: interactive ? (0, focusRing_styles_1.focusVisibleStyles)(theme.colors) : undefined, children: [(0, jsx_runtime_1.jsxs)(react_2.Flex, { align: "center", width: "100%", children: [line(leftDone, isFirst), (0, jsx_runtime_1.jsx)(react_2.Flex, { align: "center", justify: "center", boxSize: s.circle, borderRadius: "full", flexShrink: 0, bg: circleBg, color: circleColor, border: "2px solid", borderColor: circleBorder, fontSize: s.font, fontWeight: 600, transition: (0, primitives_1.transitionFor)(["background-color", "border-color", "color", "box-shadow"]), "aria-current": state === "active" ? "step" : undefined, sx: state === "active"
39
39
  ? { boxShadow: `0 0 0 4px ${palette.soft}` }
40
40
  : undefined, _groupHover: interactive
41
41
  ? { borderColor: palette.strong, bg: palette.strong, color: palette.onStrong }
42
42
  : undefined, children: showCheck && state === "completed" ? (0, jsx_runtime_1.jsx)(lucide_react_1.Check, { size: s.icon }) : number }), line(rightDone, isLast)] }), (0, jsx_runtime_1.jsx)(react_2.Text, { mt: 2, px: 1, borderRadius: "sm", fontSize: s.label, fontWeight: state === "active" ? 600 : 500, color: state === "upcoming" ? palette.mutedText : palette.softText, textAlign: "center", noOfLines: 2, transition: "background 0.18s ease, color 0.18s ease", _groupHover: interactive ? { bg: palette.strong, color: palette.onStrong } : undefined, children: label })] }));
43
+ if (!asListItem)
44
+ return node;
45
+ return ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "li", display: "flex", flex: "1", minWidth: s.minW, flexShrink: 0, listStyleType: "none", children: node }));
43
46
  };
44
47
  exports.default = StepperStage;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import type { WizardDialogProps, WizardProps } from "./WizardDialogProps";
3
+ export { wizardTransition, firstInvalidStep, INITIAL_WIZARD_STATE } from "./wizardSteps";
4
+ export type { WizardAction, WizardState, StepValidator } from "./wizardSteps";
5
+ /** Modal wizard that owns step state: validated Continue, locked future steps, error summary, review on the last step. */
6
+ export declare const WizardDialog: React.FC<WizardDialogProps>;
7
+ /** The same wizard inline, for a full-page flow rather than a modal. */
8
+ export declare const Wizard: React.FC<WizardProps>;
9
+ export default WizardDialog;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Wizard = exports.WizardDialog = exports.INITIAL_WIZARD_STATE = exports.firstInvalidStep = exports.wizardTransition = void 0;
40
+ const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const react_1 = require("react");
42
+ const react_2 = require("@chakra-ui/react");
43
+ const useCustomTheme_1 = require("../../Theme/useCustomTheme");
44
+ const Modal_1 = __importStar(require("../Modal/Modal"));
45
+ const Button_1 = __importDefault(require("../Button/Button"));
46
+ const StageProgress_1 = __importDefault(require("../StageProgress/StageProgress"));
47
+ const DescriptionList_1 = __importDefault(require("../DescriptionList/DescriptionList"));
48
+ const useWizardFlow_1 = require("./useWizardFlow");
49
+ var wizardSteps_1 = require("./wizardSteps");
50
+ Object.defineProperty(exports, "wizardTransition", { enumerable: true, get: function () { return wizardSteps_1.wizardTransition; } });
51
+ Object.defineProperty(exports, "firstInvalidStep", { enumerable: true, get: function () { return wizardSteps_1.firstInvalidStep; } });
52
+ Object.defineProperty(exports, "INITIAL_WIZARD_STATE", { enumerable: true, get: function () { return wizardSteps_1.INITIAL_WIZARD_STATE; } });
53
+ const DEFAULT_LABELS = {
54
+ back: "Back",
55
+ next: "Continue",
56
+ finish: "Finish",
57
+ cancel: "Cancel",
58
+ stepOf: (current, total) => `Step ${current} of ${total}`,
59
+ fixErrors: "Fix the following to continue",
60
+ review: "Review",
61
+ };
62
+ const WizardBody = ({ flow, steps, labels, testId }) => {
63
+ const { colors } = (0, useCustomTheme_1.useCustomTheme)();
64
+ const headingRef = (0, react_1.useRef)(null);
65
+ const previousStep = (0, react_1.useRef)(flow.step.id);
66
+ const reviewed = steps.filter((candidate) => candidate.summary !== undefined);
67
+ (0, react_1.useEffect)(() => {
68
+ var _a;
69
+ if (previousStep.current === flow.step.id)
70
+ return;
71
+ previousStep.current = flow.step.id;
72
+ (_a = headingRef.current) === null || _a === void 0 ? void 0 : _a.focus();
73
+ }, [flow.step.id]);
74
+ return ((0, jsx_runtime_1.jsxs)(react_2.Flex, { direction: "column", gap: 5, "data-testid": testId, "data-step": flow.step.id, children: [(0, jsx_runtime_1.jsx)(StageProgress_1.default, { variant: "stepper", size: "sm", showCheck: true, stages: steps.map((candidate, index) => ({
75
+ id: candidate.id,
76
+ label: candidate.label,
77
+ isDisabled: index > flow.furthest,
78
+ })), value: flow.step.id, onChange: (_id, _stage, index) => flow.goto(index) }), (0, jsx_runtime_1.jsxs)(react_2.Box, { children: [(0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: "xs", color: colors.textMuted, children: labels.stepOf(flow.index + 1, steps.length) }), (0, jsx_runtime_1.jsx)(react_2.Heading, { ref: headingRef, tabIndex: -1, as: "h3", fontSize: "md", fontWeight: 600, color: colors.header[900], _focus: { outline: "none" }, children: flow.step.label })] }), flow.errors.length ? ((0, jsx_runtime_1.jsxs)(react_2.Alert, { status: "error", variant: "subtle", borderRadius: "md", alignItems: "flex-start", role: "alert", "data-testid": "wizard-errors", children: [(0, jsx_runtime_1.jsx)(react_2.AlertIcon, {}), (0, jsx_runtime_1.jsxs)(react_2.Box, { children: [(0, jsx_runtime_1.jsx)(react_2.AlertTitle, { fontSize: "sm", children: labels.fixErrors }), (0, jsx_runtime_1.jsx)(react_2.AlertDescription, { fontSize: "sm", children: (0, jsx_runtime_1.jsx)(react_2.UnorderedList, { mt: 1, children: flow.errors.map((message) => ((0, jsx_runtime_1.jsx)(react_2.ListItem, { children: message }, message))) }) })] })] })) : null, (0, jsx_runtime_1.jsx)(react_2.Box, { children: flow.step.content }), flow.isLast && reviewed.length ? ((0, jsx_runtime_1.jsxs)(react_2.Box, { "data-testid": "wizard-review", children: [(0, jsx_runtime_1.jsx)(react_2.Heading, { as: "h4", fontSize: "sm", fontWeight: 600, mb: 2, color: colors.header[900], children: labels.review }), (0, jsx_runtime_1.jsx)(DescriptionList_1.default, { layout: "inline", columns: { base: 1 }, items: reviewed.map((candidate) => ({
79
+ label: candidate.label,
80
+ value: candidate.summary,
81
+ })) })] })) : null] }));
82
+ };
83
+ const WizardFooter = ({ flow, labels, isFinishing, onCancel }) => ((0, jsx_runtime_1.jsxs)(react_2.Flex, { w: "100%", justify: "space-between", gap: 2, wrap: "wrap", children: [onCancel ? ((0, jsx_runtime_1.jsx)(Button_1.default, { variant: "ghost", colorScheme: "gray", label: labels.cancel, onClick: onCancel, isDisabled: isFinishing, "data-testid": "wizard-cancel" })) : ((0, jsx_runtime_1.jsx)("span", {})), (0, jsx_runtime_1.jsxs)(react_2.Flex, { gap: 2, children: [!flow.isFirst ? ((0, jsx_runtime_1.jsx)(Button_1.default, { variant: "outline", colorScheme: "gray", label: labels.back, onClick: flow.back, isDisabled: isFinishing, "data-testid": "wizard-back" })) : null, flow.isLast ? ((0, jsx_runtime_1.jsx)(Button_1.default, { variant: "solid", colorScheme: "primary", label: labels.finish, onClick: flow.finish, isLoading: isFinishing, loadingText: labels.finish, "data-testid": "wizard-finish" })) : ((0, jsx_runtime_1.jsx)(Button_1.default, { variant: "solid", colorScheme: "primary", label: labels.next, onClick: flow.next, "data-testid": "wizard-next" }))] })] }));
84
+ /** Modal wizard that owns step state: validated Continue, locked future steps, error summary, review on the last step. */
85
+ const WizardDialog = ({ isOpen, onClose, title, subtitle, steps, onFinish, isFinishing = false, stepId, onStepChange, size = "3xl", labels, "data-testid": testId, }) => {
86
+ const flow = (0, useWizardFlow_1.useWizardFlow)({ steps, stepId, onStepChange, onFinish, resetWhen: !isOpen });
87
+ const resolved = { ...DEFAULT_LABELS, ...labels };
88
+ const guardedClose = () => {
89
+ if (!isFinishing)
90
+ onClose();
91
+ };
92
+ return ((0, jsx_runtime_1.jsxs)(Modal_1.default, { isOpen: isOpen, onClose: guardedClose, size: size, isCentered: true, scrollBehavior: "inside", title: title, subtitle: subtitle, closeOnOverlayClick: false, closeOnEsc: !isFinishing, hideCloseButton: isFinishing, children: [(0, jsx_runtime_1.jsx)(Modal_1.ModalBody, { children: (0, jsx_runtime_1.jsx)(WizardBody, { flow: flow, steps: steps, labels: resolved, testId: testId !== null && testId !== void 0 ? testId : "wizard-dialog" }) }), (0, jsx_runtime_1.jsx)(Modal_1.ModalFooter, { children: (0, jsx_runtime_1.jsx)(WizardFooter, { flow: flow, labels: resolved, isFinishing: isFinishing, onCancel: guardedClose }) })] }));
93
+ };
94
+ exports.WizardDialog = WizardDialog;
95
+ /** The same wizard inline, for a full-page flow rather than a modal. */
96
+ const Wizard = ({ steps, onFinish, isFinishing = false, stepId, onStepChange, labels, onCancel, "data-testid": testId, }) => {
97
+ const flow = (0, useWizardFlow_1.useWizardFlow)({ steps, stepId, onStepChange, onFinish });
98
+ const resolved = { ...DEFAULT_LABELS, ...labels };
99
+ return ((0, jsx_runtime_1.jsxs)(react_2.Flex, { direction: "column", gap: 6, children: [(0, jsx_runtime_1.jsx)(WizardBody, { flow: flow, steps: steps, labels: resolved, testId: testId !== null && testId !== void 0 ? testId : "wizard" }), (0, jsx_runtime_1.jsx)(WizardFooter, { flow: flow, labels: resolved, isFinishing: isFinishing, onCancel: onCancel })] }));
100
+ };
101
+ exports.Wizard = Wizard;
102
+ exports.default = exports.WizardDialog;
@@ -0,0 +1,48 @@
1
+ import type { ReactNode } from "react";
2
+ /** One step of a wizard: its stepper label, body, validation and review summary. */
3
+ export type WizardStep = {
4
+ id: string;
5
+ /** Stepper label and the heading shown above the step content. */
6
+ label: string;
7
+ content: ReactNode;
8
+ /** Messages that block leaving this step; [] = valid. Must be pure (runs in the reducer). */
9
+ validate?: () => string[];
10
+ /** One line shown in the review on the last step; steps without it are not reviewed. */
11
+ summary?: ReactNode;
12
+ };
13
+ /** Visible strings; every key falls back to its English default. */
14
+ export type WizardLabels = Partial<{
15
+ back: string;
16
+ next: string;
17
+ finish: string;
18
+ cancel: string;
19
+ stepOf: (current: number, total: number) => string;
20
+ fixErrors: string;
21
+ review: string;
22
+ }>;
23
+ /** Props for the modal wizard: Modal + stepper + per-step validation + review on the last step. */
24
+ export interface WizardDialogProps {
25
+ isOpen: boolean;
26
+ /** Ignored while `isFinishing`. */
27
+ onClose: () => void;
28
+ title: string;
29
+ subtitle?: string;
30
+ steps: WizardStep[];
31
+ /** Called after every step re-validates; a failing step is jumped to with its errors. */
32
+ onFinish: () => void;
33
+ /** Shows the Finish spinner and disables close, Esc, Back and Cancel. */
34
+ isFinishing?: boolean;
35
+ /** Controlled step; omit for uncontrolled (resets to the first step on close). */
36
+ stepId?: string;
37
+ /** Fires whenever the visible step changes, controlled or not. */
38
+ onStepChange?: (stepId: string) => void;
39
+ /** Modal width; default "3xl". */
40
+ size?: "lg" | "xl" | "2xl" | "3xl" | "4xl";
41
+ labels?: WizardLabels;
42
+ "data-testid"?: string;
43
+ }
44
+ /** Same flow inline (a page section, not a modal) — for full-page wizards. */
45
+ export interface WizardProps extends Omit<WizardDialogProps, "isOpen" | "onClose" | "title" | "subtitle" | "size"> {
46
+ /** Renders a Cancel button in the footer when provided. */
47
+ onCancel?: () => void;
48
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ import type { WizardStep } from "./WizardDialogProps";
2
+ type FlowOptions = {
3
+ steps: WizardStep[];
4
+ stepId?: string;
5
+ onStepChange?: (stepId: string) => void;
6
+ onFinish: () => void;
7
+ resetWhen?: boolean;
8
+ };
9
+ export declare function useWizardFlow({ steps, stepId, onStepChange, onFinish, resetWhen }: FlowOptions): {
10
+ index: number;
11
+ furthest: number;
12
+ errors: string[];
13
+ step: WizardStep;
14
+ isFirst: boolean;
15
+ isLast: boolean;
16
+ next: () => void;
17
+ back: () => void;
18
+ goto: (target: number) => void;
19
+ finish: () => void;
20
+ };
21
+ export type WizardFlow = ReturnType<typeof useWizardFlow>;
22
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWizardFlow = useWizardFlow;
4
+ const react_1 = require("react");
5
+ const wizardSteps_1 = require("./wizardSteps");
6
+ function useWizardFlow({ steps, stepId, onStepChange, onFinish, resetWhen }) {
7
+ const [state, setState] = (0, react_1.useState)(wizardSteps_1.INITIAL_WIZARD_STATE);
8
+ const validators = steps.map((step) => step.validate);
9
+ const controlledIndex = stepId === undefined ? -1 : steps.findIndex((s) => s.id === stepId);
10
+ const isControlled = stepId !== undefined;
11
+ const index = Math.min(isControlled ? Math.max(controlledIndex, 0) : state.index, Math.max(steps.length - 1, 0));
12
+ const furthest = Math.max(state.furthest, index);
13
+ (0, react_1.useEffect)(() => {
14
+ if (resetWhen)
15
+ setState(wizardSteps_1.INITIAL_WIZARD_STATE);
16
+ }, [resetWhen]);
17
+ const dispatch = (0, react_1.useCallback)((action) => {
18
+ const base = { ...state, index, furthest };
19
+ const next = (0, wizardSteps_1.wizardTransition)(base, action, validators);
20
+ setState(next);
21
+ if (next.index !== index)
22
+ onStepChange === null || onStepChange === void 0 ? void 0 : onStepChange(steps[next.index].id);
23
+ },
24
+ // eslint-disable-next-line react-hooks/exhaustive-deps
25
+ [state, index, furthest, steps, onStepChange]);
26
+ const finish = (0, react_1.useCallback)(() => {
27
+ const invalid = (0, wizardSteps_1.firstInvalidStep)(validators);
28
+ if (invalid) {
29
+ dispatch({ type: "fail", ...invalid });
30
+ return;
31
+ }
32
+ onFinish();
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ }, [dispatch, steps, onFinish]);
35
+ return {
36
+ index,
37
+ furthest,
38
+ errors: state.errors,
39
+ step: steps[index],
40
+ isFirst: index === 0,
41
+ isLast: index === steps.length - 1,
42
+ next: () => dispatch({ type: "next" }),
43
+ back: () => dispatch({ type: "back" }),
44
+ goto: (target) => dispatch({ type: "goto", index: target }),
45
+ finish,
46
+ };
47
+ }
@@ -0,0 +1,31 @@
1
+ export type StepValidator = () => string[];
2
+ /** Reducer state: current step, the furthest validly reached step, and the blocking messages. */
3
+ export type WizardState = {
4
+ index: number;
5
+ /** Furthest step the user has validly reached; stages beyond it stay locked. */
6
+ furthest: number;
7
+ errors: string[];
8
+ };
9
+ /** Actions `wizardTransition` understands. */
10
+ export type WizardAction = {
11
+ type: "next";
12
+ } | {
13
+ type: "back";
14
+ } | {
15
+ type: "goto";
16
+ index: number;
17
+ } | {
18
+ type: "fail";
19
+ index: number;
20
+ errors: string[];
21
+ } | {
22
+ type: "reset";
23
+ };
24
+ export declare const INITIAL_WIZARD_STATE: WizardState;
25
+ /** Pure step reducer: `next` validates the current step, `goto` only reaches steps up to `furthest`. */
26
+ export declare function wizardTransition(state: WizardState, action: WizardAction, validators: (StepValidator | undefined)[]): WizardState;
27
+ /** First step whose validator reports errors, or null when every step is valid. */
28
+ export declare function firstInvalidStep(validators: (StepValidator | undefined)[]): {
29
+ index: number;
30
+ errors: string[];
31
+ } | null;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INITIAL_WIZARD_STATE = void 0;
4
+ exports.wizardTransition = wizardTransition;
5
+ exports.firstInvalidStep = firstInvalidStep;
6
+ exports.INITIAL_WIZARD_STATE = { index: 0, furthest: 0, errors: [] };
7
+ /** Pure step reducer: `next` validates the current step, `goto` only reaches steps up to `furthest`. */
8
+ function wizardTransition(state, action, validators) {
9
+ var _a, _b;
10
+ const last = validators.length - 1;
11
+ switch (action.type) {
12
+ case "next": {
13
+ const errors = (_b = (_a = validators[state.index]) === null || _a === void 0 ? void 0 : _a.call(validators)) !== null && _b !== void 0 ? _b : [];
14
+ if (errors.length)
15
+ return { ...state, errors };
16
+ const index = Math.min(state.index + 1, last);
17
+ return { index, furthest: Math.max(state.furthest, index), errors: [] };
18
+ }
19
+ case "back":
20
+ return { ...state, index: Math.max(state.index - 1, 0), errors: [] };
21
+ case "goto":
22
+ if (action.index < 0 || action.index > state.furthest)
23
+ return state;
24
+ return { ...state, index: action.index, errors: [] };
25
+ case "fail":
26
+ return { ...state, index: action.index, errors: action.errors };
27
+ case "reset":
28
+ return exports.INITIAL_WIZARD_STATE;
29
+ }
30
+ }
31
+ /** First step whose validator reports errors, or null when every step is valid. */
32
+ function firstInvalidStep(validators) {
33
+ var _a, _b;
34
+ for (let index = 0; index < validators.length; index += 1) {
35
+ const errors = (_b = (_a = validators[index]) === null || _a === void 0 ? void 0 : _a.call(validators)) !== null && _b !== void 0 ? _b : [];
36
+ if (errors.length)
37
+ return { index, errors };
38
+ }
39
+ return null;
40
+ }
@@ -8,6 +8,7 @@ import { AA_NORMAL_TEXT } from "../../Theme/tokens/builders/accentText.js";
8
8
  import { liftToContrast, neutralStep, ruleInk, AA_NON_TEXT, CHROME_RULE, MIN_PERCEPTIBLE_STEP, } 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 Kbd from "../Kbd/Kbd.js";
11
12
  import AppMark, { assignAppHues } from "./AppMark.js";
12
13
  import { filterApps, formatShortcut, } from "./AppSwitcherProps.js";
13
14
  import { useAppSwitcherShortcut } from "./useAppSwitcherShortcut.js";
@@ -190,7 +191,7 @@ const AppSwitcher = ({ apps, currentAppId, onSelect, onOpenChange, isSearchable,
190
191
  return;
191
192
  }
192
193
  handlePanelKeyDown(e);
193
- }, children: _jsx(Grip, { size: s.icon + 1 }) }) }), _jsx(PopoverContent, { w: width, maxW: "calc(100vw - 1.5rem)", textAlign: "start", onKeyDown: handlePanelKeyDown, 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: [_jsxs(Flex, { align: "center", gap: 2, px: 3, pt: 3, pb: showSearch ? 2 : 1, children: [_jsx(Text, { fontSize: "0.6875rem", fontWeight: 600, letterSpacing: "0.08em", textTransform: "uppercase", color: theme.colors.textMuted, children: HEADING }), _jsx(Box, { flex: "1" }), hint && (_jsx(Text, { as: "kbd", fontSize: "0.6875rem", fontFamily: "inherit", color: theme.colors.textMuted, border: "1px solid", borderRadius: "full", px: 1.5, py: 0.5, children: hint }))] }), showSearch && (_jsx(Box, { px: 3, pb: 2, children: _jsxs(InputGroup, { size: "sm", children: [_jsx(InputLeftElement, { pointerEvents: "none", children: _jsx(Search, { size: 15, color: theme.colors.textMuted }) }), _jsx(Input, { ref: searchRef, value: query, onChange: (e) => setQuery(e.target.value), placeholder: "Search apps", borderRadius: "lg", "aria-label": "Search apps", onKeyDown: (e) => {
194
+ }, children: _jsx(Grip, { size: s.icon + 1 }) }) }), _jsx(PopoverContent, { w: width, maxW: "calc(100vw - 1.5rem)", textAlign: "start", onKeyDown: handlePanelKeyDown, 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: [_jsxs(Flex, { align: "center", gap: 2, px: 3, pt: 3, pb: showSearch ? 2 : 1, children: [_jsx(Text, { fontSize: "0.6875rem", fontWeight: 600, letterSpacing: "0.08em", textTransform: "uppercase", color: theme.colors.textMuted, children: HEADING }), _jsx(Box, { flex: "1" }), hint && _jsx(Kbd, { size: "xs", children: hint })] }), showSearch && (_jsx(Box, { px: 3, pb: 2, children: _jsxs(InputGroup, { size: "sm", children: [_jsx(InputLeftElement, { pointerEvents: "none", children: _jsx(Search, { size: 15, color: theme.colors.textMuted }) }), _jsx(Input, { ref: searchRef, value: query, onChange: (e) => setQuery(e.target.value), placeholder: "Search apps", borderRadius: "lg", "aria-label": "Search apps", onKeyDown: (e) => {
194
195
  if (e.key === "ArrowDown" && visible.length > 0) {
195
196
  e.preventDefault();
196
197
  focusItem(0);
@@ -42,12 +42,14 @@ export const matchesShortcut = (event, shortcut, isApple = typeof navigator !==
42
42
  };
43
43
  const APPLE_SYMBOLS = { mod: "⌘", cmd: "⌘", meta: "⌘", ctrl: "⌃", shift: "⇧", alt: "⌥" };
44
44
  const OTHER_LABELS = { mod: "Ctrl", cmd: "Win", meta: "Win", ctrl: "Ctrl", shift: "Shift", alt: "Alt" };
45
- export const formatShortcut = (shortcut, isApple = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform)) => {
45
+ const isAppleNow = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
46
+ /** One label per key in a chord, so a named key such as `enter` stays a single cap. */
47
+ export const shortcutKeys = (shortcut, isApple = isAppleNow()) => {
46
48
  const parts = shortcut.toLowerCase().split("+").map((p) => p.trim()).filter(Boolean);
47
49
  const table = isApple ? APPLE_SYMBOLS : OTHER_LABELS;
48
- const rendered = parts.map((p, i) => { var _a; return i === parts.length - 1 ? p.toUpperCase() : ((_a = table[p]) !== null && _a !== void 0 ? _a : p.toUpperCase()); });
49
- return isApple ? rendered.join("") : rendered.join("+");
50
+ return parts.map((p, i) => { var _a; return (i === parts.length - 1 ? p.toUpperCase() : ((_a = table[p]) !== null && _a !== void 0 ? _a : p.toUpperCase())); });
50
51
  };
52
+ export const formatShortcut = (shortcut, isApple = isAppleNow()) => shortcutKeys(shortcut, isApple).join(isApple ? "" : "+");
51
53
  /**
52
54
  * Derives every app's origin from the host the consumer is already served on, so one deployment
53
55
  * variable keeps dev, test and prod in step. An app may still carry its own `url`, which wins.