pixelize-design-library 2.4.2-beta.57 → 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 (152) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/COMPONENT-GOTCHAS.md +88 -2
  3. package/DESIGN-GUIDE.md +27 -4
  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/Commerce/commerceTypes.d.ts +5 -0
  14. package/dist/Components/Editor/Editor.js +50 -2
  15. package/dist/Components/Editor/EditorFieldBar.d.ts +15 -0
  16. package/dist/Components/Editor/EditorFieldBar.js +19 -0
  17. package/dist/Components/Editor/EditorProps.d.ts +74 -1
  18. package/dist/Components/Editor/MakeDynamicDialog.d.ts +12 -0
  19. package/dist/Components/Editor/MakeDynamicDialog.js +59 -0
  20. package/dist/Components/Editor/editorLabels.d.ts +4 -0
  21. package/dist/Components/Editor/editorLabels.js +24 -0
  22. package/dist/Components/Editor/editorTokenStyles.d.ts +28 -0
  23. package/dist/Components/Editor/editorTokenStyles.js +30 -0
  24. package/dist/Components/Editor/editorTokens.d.ts +26 -0
  25. package/dist/Components/Editor/editorTokens.js +134 -0
  26. package/dist/Components/Editor/useEditorBridge.d.ts +40 -0
  27. package/dist/Components/Editor/useEditorBridge.js +141 -0
  28. package/dist/Components/Kbd/Kbd.d.ts +6 -0
  29. package/dist/Components/Kbd/Kbd.js +33 -0
  30. package/dist/Components/Kbd/KbdProps.d.ts +17 -0
  31. package/dist/Components/Kbd/KbdProps.js +2 -0
  32. package/dist/Components/LauncherTrigger/LauncherTrigger.d.ts +4 -0
  33. package/dist/Components/LauncherTrigger/LauncherTrigger.js +41 -0
  34. package/dist/Components/LauncherTrigger/LauncherTriggerProps.d.ts +16 -0
  35. package/dist/Components/LauncherTrigger/LauncherTriggerProps.js +2 -0
  36. package/dist/Components/MediaGallery/MediaGallery.js +1 -1
  37. package/dist/Components/NavLauncher/NavLauncher.d.ts +3 -0
  38. package/dist/Components/NavLauncher/NavLauncher.js +395 -0
  39. package/dist/Components/NavLauncher/NavLauncherProps.d.ts +187 -0
  40. package/dist/Components/NavLauncher/NavLauncherProps.js +2 -0
  41. package/dist/Components/NavLauncher/NewTabLink.d.ts +3 -0
  42. package/dist/Components/NavLauncher/NewTabLink.js +14 -0
  43. package/dist/Components/NavLauncher/PinToggle.d.ts +3 -0
  44. package/dist/Components/NavLauncher/PinToggle.js +21 -0
  45. package/dist/Components/NavLauncher/launcherParts.d.ts +93 -0
  46. package/dist/Components/NavLauncher/launcherParts.js +130 -0
  47. package/dist/Components/NavLauncher/match.d.ts +53 -0
  48. package/dist/Components/NavLauncher/match.js +178 -0
  49. package/dist/Components/NavLauncher/revealStyles.d.ts +4 -0
  50. package/dist/Components/NavLauncher/revealStyles.js +19 -0
  51. package/dist/Components/NavigationBar/NavigationBar.d.ts +1 -1
  52. package/dist/Components/NavigationBar/NavigationBar.js +2 -2
  53. package/dist/Components/NavigationBar/NavigationBarProps.d.ts +2 -0
  54. package/dist/Components/PageHeader/PageHeader.d.ts +1 -1
  55. package/dist/Components/PageHeader/PageHeader.js +9 -2
  56. package/dist/Components/PageHeader/PageHeaderProps.d.ts +8 -0
  57. package/dist/Components/PdfViewer/PdfViewer.d.ts +21 -4
  58. package/dist/Components/PdfViewer/PdfViewer.js +124 -3
  59. package/dist/Components/ProductCard/ProductCard.js +8 -3
  60. package/dist/Components/ProductCard/ProductCardMedia.js +3 -3
  61. package/dist/Components/ProductCard/QuickAddSheet.js +2 -2
  62. package/dist/Components/ProductCard/cardMetrics.d.ts +1 -0
  63. package/dist/Components/ProductCard/cardMetrics.js +3 -2
  64. package/dist/Components/ProductDetails/ProductDetails.d.ts +1 -1
  65. package/dist/Components/ProductDetails/ProductDetails.js +6 -5
  66. package/dist/Components/ProductDetails/ProductDetailsProps.d.ts +2 -0
  67. package/dist/Components/Search/Search.js +2 -1
  68. package/dist/Components/SideBar/SecondaryBar.js +4 -3
  69. package/dist/Components/SideBar/SideBar.d.ts +1 -1
  70. package/dist/Components/SideBar/SideBar.js +30 -9
  71. package/dist/Components/SideBar/SideBarProps.d.ts +32 -0
  72. package/dist/Components/SideBar/components/MenuItemBox.d.ts +6 -0
  73. package/dist/Components/SideBar/components/MenuItemBox.js +8 -4
  74. package/dist/Components/SideBar/components/MenuPopoverContent.js +3 -2
  75. package/dist/Components/SideBar/components/OtherApps.js +2 -1
  76. package/dist/Components/SideBar/components/PinnedSection.d.ts +17 -0
  77. package/dist/Components/SideBar/components/PinnedSection.js +98 -0
  78. package/dist/Components/SideBar/sidebarFocus.d.ts +23 -0
  79. package/dist/Components/SideBar/sidebarFocus.js +20 -0
  80. package/dist/Components/StageProgress/StageProgress.js +2 -2
  81. package/dist/Components/StageProgress/StageProgressProps.d.ts +2 -0
  82. package/dist/Components/StageProgress/StepperStage.js +5 -2
  83. package/dist/Components/WizardDialog/WizardDialog.d.ts +9 -0
  84. package/dist/Components/WizardDialog/WizardDialog.js +102 -0
  85. package/dist/Components/WizardDialog/WizardDialogProps.d.ts +48 -0
  86. package/dist/Components/WizardDialog/WizardDialogProps.js +2 -0
  87. package/dist/Components/WizardDialog/useWizardFlow.d.ts +22 -0
  88. package/dist/Components/WizardDialog/useWizardFlow.js +47 -0
  89. package/dist/Components/WizardDialog/wizardSteps.d.ts +31 -0
  90. package/dist/Components/WizardDialog/wizardSteps.js +40 -0
  91. package/dist/Hooks/useMatchMedia.d.ts +2 -0
  92. package/dist/Hooks/useMatchMedia.js +36 -0
  93. package/dist/Theme/chakra/motion.js +2 -16
  94. package/dist/Utils/price.js +11 -6
  95. package/dist/esm/Components/AppSwitcher/AppSwitcher.js +2 -1
  96. package/dist/esm/Components/AppSwitcher/AppSwitcherProps.js +5 -3
  97. package/dist/esm/Components/Breadcrumbs/Breadcrumbs.js +35 -12
  98. package/dist/esm/Components/Card/Card.js +12 -2
  99. package/dist/esm/Components/Editor/Editor.js +48 -3
  100. package/dist/esm/Components/Editor/EditorFieldBar.js +13 -0
  101. package/dist/esm/Components/Editor/MakeDynamicDialog.js +20 -0
  102. package/dist/esm/Components/Editor/editorLabels.js +20 -0
  103. package/dist/esm/Components/Editor/editorTokenStyles.js +25 -0
  104. package/dist/esm/Components/Editor/editorTokens.js +121 -0
  105. package/dist/esm/Components/Editor/useEditorBridge.js +138 -0
  106. package/dist/esm/Components/Kbd/Kbd.js +28 -0
  107. package/dist/esm/Components/Kbd/KbdProps.js +1 -0
  108. package/dist/esm/Components/LauncherTrigger/LauncherTrigger.js +37 -0
  109. package/dist/esm/Components/LauncherTrigger/LauncherTriggerProps.js +1 -0
  110. package/dist/esm/Components/MediaGallery/MediaGallery.js +1 -1
  111. package/dist/esm/Components/NavLauncher/NavLauncher.js +356 -0
  112. package/dist/esm/Components/NavLauncher/NavLauncherProps.js +1 -0
  113. package/dist/esm/Components/NavLauncher/NewTabLink.js +11 -0
  114. package/dist/esm/Components/NavLauncher/PinToggle.js +18 -0
  115. package/dist/esm/Components/NavLauncher/launcherParts.js +110 -0
  116. package/dist/esm/Components/NavLauncher/match.js +172 -0
  117. package/dist/esm/Components/NavLauncher/revealStyles.js +15 -0
  118. package/dist/esm/Components/NavigationBar/NavigationBar.js +3 -3
  119. package/dist/esm/Components/PageHeader/PageHeader.js +9 -2
  120. package/dist/esm/Components/PdfViewer/PdfViewer.js +123 -2
  121. package/dist/esm/Components/ProductCard/ProductCard.js +9 -4
  122. package/dist/esm/Components/ProductCard/ProductCardMedia.js +3 -3
  123. package/dist/esm/Components/ProductCard/QuickAddSheet.js +2 -2
  124. package/dist/esm/Components/ProductCard/cardMetrics.js +2 -1
  125. package/dist/esm/Components/ProductDetails/ProductDetails.js +6 -5
  126. package/dist/esm/Components/Search/Search.js +3 -2
  127. package/dist/esm/Components/SideBar/SecondaryBar.js +4 -3
  128. package/dist/esm/Components/SideBar/SideBar.js +31 -10
  129. package/dist/esm/Components/SideBar/components/MenuItemBox.js +4 -2
  130. package/dist/esm/Components/SideBar/components/MenuPopoverContent.js +3 -2
  131. package/dist/esm/Components/SideBar/components/OtherApps.js +2 -1
  132. package/dist/esm/Components/SideBar/components/PinnedSection.js +92 -0
  133. package/dist/esm/Components/SideBar/sidebarFocus.js +15 -0
  134. package/dist/esm/Components/StageProgress/StageProgress.js +2 -2
  135. package/dist/esm/Components/StageProgress/StepperStage.js +5 -2
  136. package/dist/esm/Components/WizardDialog/WizardDialog.js +58 -0
  137. package/dist/esm/Components/WizardDialog/WizardDialogProps.js +1 -0
  138. package/dist/esm/Components/WizardDialog/useWizardFlow.js +44 -0
  139. package/dist/esm/Components/WizardDialog/wizardSteps.js +35 -0
  140. package/dist/esm/Hooks/useMatchMedia.js +32 -0
  141. package/dist/esm/Theme/chakra/motion.js +2 -16
  142. package/dist/esm/Utils/price.js +11 -6
  143. package/dist/esm/index.js +7 -0
  144. package/dist/index.d.ts +19 -4
  145. package/dist/index.js +21 -1
  146. package/package.json +1 -1
  147. package/dist/Components/MediaGallery/useMatchMedia.d.ts +0 -2
  148. package/dist/Components/MediaGallery/useMatchMedia.js +0 -20
  149. package/dist/Components/ProductCard/useMinWidth.d.ts +0 -2
  150. package/dist/Components/ProductCard/useMinWidth.js +0 -20
  151. package/dist/esm/Components/MediaGallery/useMatchMedia.js +0 -16
  152. package/dist/esm/Components/ProductCard/useMinWidth.js +0 -16
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ /** `matches` for a media query, sharing one listener per query; `fallback` where matchMedia is missing (SSR, jsdom). */
2
+ export declare const useMatchMedia: (query: string, fallback?: boolean) => boolean;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMatchMedia = void 0;
4
+ const react_1 = require("react");
5
+ const entries = new Map();
6
+ const supported = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
7
+ const subscriberFor = (query) => (notify) => {
8
+ if (!supported())
9
+ return () => undefined;
10
+ let entry = entries.get(query);
11
+ if (!entry) {
12
+ const list = window.matchMedia(query);
13
+ const created = { list, listeners: new Set(), onChange: () => created.listeners.forEach((fn) => fn()) };
14
+ list.addEventListener("change", created.onChange);
15
+ entries.set(query, created);
16
+ entry = created;
17
+ }
18
+ entry.listeners.add(notify);
19
+ return () => {
20
+ const current = entries.get(query);
21
+ if (!current)
22
+ return;
23
+ current.listeners.delete(notify);
24
+ if (current.listeners.size === 0) {
25
+ current.list.removeEventListener("change", current.onChange);
26
+ entries.delete(query);
27
+ }
28
+ };
29
+ };
30
+ /** `matches` for a media query, sharing one listener per query; `fallback` where matchMedia is missing (SSR, jsdom). */
31
+ const useMatchMedia = (query, fallback = false) => {
32
+ const subscribe = (0, react_1.useMemo)(() => subscriberFor(query), [query]);
33
+ const read = () => { var _a, _b; return (_b = (_a = entries.get(query)) === null || _a === void 0 ? void 0 : _a.list.matches) !== null && _b !== void 0 ? _b : (supported() ? window.matchMedia(query).matches : fallback); };
34
+ return (0, react_1.useSyncExternalStore)(subscribe, read, () => fallback);
35
+ };
36
+ exports.useMatchMedia = useMatchMedia;
@@ -1,24 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reducedMotionSx = exports.usePrefersReducedMotion = exports.REDUCED_MOTION_QUERY = void 0;
4
- const react_1 = require("react");
4
+ const useMatchMedia_1 = require("../../Hooks/useMatchMedia");
5
5
  exports.REDUCED_MOTION_QUERY = "@media (prefers-reduced-motion: reduce)";
6
6
  const MEDIA = "(prefers-reduced-motion: reduce)";
7
- // NOTE: jsdom has no matchMedia; Chakra's hook throws there and breaks consumer test suites.
8
- const hasMatchMedia = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
9
- const readPreference = () => hasMatchMedia() && window.matchMedia(MEDIA).matches;
10
- const usePrefersReducedMotion = () => {
11
- const [reduced, setReduced] = (0, react_1.useState)(readPreference);
12
- (0, react_1.useEffect)(() => {
13
- if (!hasMatchMedia())
14
- return;
15
- const query = window.matchMedia(MEDIA);
16
- const onChange = () => setReduced(query.matches);
17
- query.addEventListener("change", onChange);
18
- return () => query.removeEventListener("change", onChange);
19
- }, []);
20
- return reduced;
21
- };
7
+ const usePrefersReducedMotion = () => (0, useMatchMedia_1.useMatchMedia)(MEDIA, false);
22
8
  exports.usePrefersReducedMotion = usePrefersReducedMotion;
23
9
  /** Spread into `sx`: drops transitions and animations when the user asks for less motion. */
24
10
  const reducedMotionSx = (overrides = {}) => ({
@@ -7,15 +7,20 @@ exports.discountAmount = discountAmount;
7
7
  exports.unitPrice = unitPrice;
8
8
  exports.DEFAULT_CURRENCY = "INR";
9
9
  exports.DEFAULT_LOCALE = "en-IN";
10
+ const formatters = new Map();
11
+ const formatterFor = (locale, currency, minimum, maximum) => {
12
+ const key = `${locale}|${currency}|${minimum}|${maximum}`;
13
+ let formatter = formatters.get(key);
14
+ if (!formatter) {
15
+ formatter = new Intl.NumberFormat(locale, { style: "currency", currency, minimumFractionDigits: minimum, maximumFractionDigits: maximum });
16
+ formatters.set(key, formatter);
17
+ }
18
+ return formatter;
19
+ };
10
20
  function formatPrice(value, options = {}) {
11
21
  const { currency = exports.DEFAULT_CURRENCY, locale = exports.DEFAULT_LOCALE, maximumFractionDigits } = options;
12
22
  const whole = Number.isInteger(value);
13
- return new Intl.NumberFormat(locale, {
14
- style: "currency",
15
- currency,
16
- minimumFractionDigits: whole ? 0 : 2,
17
- maximumFractionDigits: maximumFractionDigits !== null && maximumFractionDigits !== void 0 ? maximumFractionDigits : (whole ? 0 : 2),
18
- }).format(value);
23
+ return formatterFor(locale, currency, whole ? 0 : 2, maximumFractionDigits !== null && maximumFractionDigits !== void 0 ? maximumFractionDigits : (whole ? 0 : 2)).format(value);
19
24
  }
20
25
  function discountPercent(price, mrp) {
21
26
  if (mrp === undefined || mrp <= price || mrp <= 0)
@@ -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.
@@ -1,19 +1,42 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Box, Breadcrumb, BreadcrumbItem, BreadcrumbLink, useTheme } from "@chakra-ui/react";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Menu, MenuButton, MenuItem, MenuList, useTheme, } from "@chakra-ui/react";
3
3
  import { useCustomTheme } from "../../Theme/useCustomTheme.js";
4
+ import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
4
5
  import { breadcrumbInk } from "./breadcrumbInk.js";
5
- export default function Breadcrumbs({ spacing, separator, fontWeight, fontSize, isCurrentPage, handleClick, items, }) {
6
+ const DEFAULT_MAX_ITEMS = 3;
7
+ const MIN_MAX_ITEMS = 2;
8
+ const OVERFLOW_SX = {
9
+ nowrap: undefined,
10
+ wrap: { "& ol": { flexWrap: "wrap", rowGap: "4px" }, "& li": { maxWidth: "100%" } },
11
+ truncate: { "& ol": { flexWrap: "nowrap" }, "& li": { minWidth: 0 } },
12
+ };
13
+ const collapse = (entries, maxItems) => {
14
+ const keep = Math.max(MIN_MAX_ITEMS, Math.floor(maxItems));
15
+ if (entries.length <= keep)
16
+ return { head: entries, hidden: [], tail: [] };
17
+ return { head: entries.slice(0, 1), hidden: entries.slice(1, entries.length - (keep - 1)), tail: entries.slice(entries.length - (keep - 1)) };
18
+ };
19
+ export default function Breadcrumbs({ spacing, separator, fontWeight, fontSize, isCurrentPage, handleClick, items, overflow = "nowrap", maxItems = DEFAULT_MAX_ITEMS, labels, "data-testid": testId, }) {
6
20
  const theme = useTheme();
7
21
  const { colors } = useCustomTheme();
8
22
  const ink = breadcrumbInk(colors);
9
23
  const effectiveSeparator = separator !== null && separator !== void 0 ? separator : (_jsx(Box, { as: "span", color: ink.separator, children: "/" }));
10
- return (_jsx(Breadcrumb, { spacing: spacing, separator: effectiveSeparator, fontWeight: fontWeight, fontSize: fontSize, fontFamily: theme.fonts.body, children: items.map((item, index) => {
11
- const isLast = isCurrentPage && index === items.length - 1;
12
- return (_jsx(BreadcrumbItem, { isCurrentPage: isLast, children: _jsx(BreadcrumbLink, { href: item.path, color: isLast ? ink.current : ink.link, fontWeight: isLast ? 600 : fontWeight, sx: {
13
- "&:hover, &:active": { textDecoration: "none", color: isLast ? ink.current : ink.linkHover },
14
- }, onClick: (event) => {
15
- event.preventDefault();
16
- handleClick(item.path);
17
- }, children: item.label }) }, index));
18
- }) }));
24
+ const clip = overflow !== "nowrap";
25
+ const clipProps = clip ? { noOfLines: 1 } : {};
26
+ const renderCrumb = ({ crumb, index }) => {
27
+ const isLast = Boolean(isCurrentPage) && index === items.length - 1;
28
+ const color = isLast ? ink.current : ink.link;
29
+ const common = { ...clipProps, title: clip ? crumb.label : undefined, color, fontWeight: isLast ? 600 : fontWeight };
30
+ return (_jsx(BreadcrumbItem, { isCurrentPage: isLast, children: crumb.path === undefined ? (_jsx(Box, { as: "span", "aria-current": isLast ? "page" : undefined, ...common, children: crumb.label })) : (_jsx(BreadcrumbLink, { href: crumb.path, ...common, sx: { "&:hover, &:active": { textDecoration: "none", color: isLast ? ink.current : ink.linkHover } }, onClick: (event) => {
31
+ event.preventDefault();
32
+ handleClick(crumb.path);
33
+ }, children: crumb.label })) }, index));
34
+ };
35
+ const renderMenu = (hidden) => {
36
+ var _a;
37
+ return (_jsx(BreadcrumbItem, { sx: { flexShrink: 0 }, children: _jsxs(Menu, { isLazy: true, placement: "bottom-start", children: [_jsx(MenuButton, { type: "button", "aria-label": ((_a = labels === null || labels === void 0 ? void 0 : labels.showMore) !== null && _a !== void 0 ? _a : ((n) => `Show ${n} more`))(hidden.length), color: ink.link, borderRadius: "md", px: 1, _hover: { color: ink.linkHover }, sx: focusVisibleStyles(colors), children: "\u2026" }), _jsx(MenuList, { children: hidden.map(({ crumb, index }) => (_jsx(MenuItem, { isDisabled: crumb.path === undefined, onClick: () => crumb.path !== undefined && handleClick(crumb.path), children: crumb.label }, index))) })] }) }, "overflow"));
38
+ };
39
+ const entries = items.map((crumb, index) => ({ crumb, index }));
40
+ const { head, hidden, tail } = overflow === "truncate" ? collapse(entries, maxItems) : { head: entries, hidden: [], tail: [] };
41
+ return (_jsxs(Breadcrumb, { spacing: spacing, separator: effectiveSeparator, fontWeight: fontWeight, fontSize: fontSize, fontFamily: theme.fonts.body, sx: OVERFLOW_SX[overflow], "data-testid": testId, children: [head.map(renderCrumb), hidden.length > 0 && renderMenu(hidden), tail.map(renderCrumb)] }));
19
42
  }
@@ -1,11 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { Card as ChakraCard, CardBody, CardFooter, CardHeader, } from "@chakra-ui/react";
4
- const Card = forwardRef(function Card({ header, footer, children, color, colorScheme, direction = "column", align, justify, bodyProps, ...rest }, ref) {
4
+ const HEADER_PADDING_WHEN_FLUSH = "0.75rem";
5
+ const PADDING_VALUES = {
6
+ none: "0",
7
+ "2xs": "0.375rem",
8
+ xs: "0.75rem",
9
+ sm: "0.75rem 1rem",
10
+ md: "1rem 1.25rem",
11
+ lg: "1.25rem 1.5rem",
12
+ };
13
+ const Card = forwardRef(function Card({ header, footer, children, color, colorScheme, direction = "column", align, justify, bodyProps, padding, ...rest }, ref) {
5
14
  const cardProps = { ...rest };
6
15
  delete cardProps.dividercolor;
7
16
  delete cardProps.dividersize;
8
17
  delete cardProps.dividervariant;
9
- return (_jsxs(ChakraCard, { ref: ref, colorScheme: colorScheme !== null && colorScheme !== void 0 ? colorScheme : color, ...cardProps, children: [header && _jsx(CardHeader, { children: header }), _jsx(CardBody, { display: "flex", flexDirection: direction, alignItems: align, justifyContent: justify, ...bodyProps, children: children }), footer && _jsx(CardFooter, { children: footer })] }));
18
+ const sx = padding ? { "--card-padding": PADDING_VALUES[padding], ...cardProps.sx } : cardProps.sx;
19
+ return (_jsxs(ChakraCard, { ref: ref, colorScheme: colorScheme !== null && colorScheme !== void 0 ? colorScheme : color, ...cardProps, sx: sx, children: [header && (_jsx(CardHeader, { sx: padding === "none" ? { "--card-padding": HEADER_PADDING_WHEN_FLUSH } : undefined, children: header })), _jsx(CardBody, { display: "flex", flexDirection: direction, alignItems: align, justifyContent: justify, ...bodyProps, children: children }), footer && _jsx(CardFooter, { children: footer })] }));
10
20
  });
11
21
  export default Card;
@@ -1,6 +1,16 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { Suspense, useEffect, useMemo, useState } from "react";
3
3
  import { Box } from "@chakra-ui/react";
4
+ import FieldMessage from "../Common/FieldMessage.js";
5
+ import ErrorMessage from "../Common/ErrorMessage.js";
6
+ import { fieldLabelStyles } from "../Common/FormLabel.js";
7
+ import { useFieldIds } from "../Common/useFieldIds.js";
8
+ import EditorFieldBar from "./EditorFieldBar.js";
9
+ import MakeDynamicDialog from "./MakeDynamicDialog.js";
10
+ import { DEFAULT_TOKEN_SYNTAX, fieldOptions } from "./editorTokens.js";
11
+ import { chipStyles } from "./editorTokenStyles.js";
12
+ import { resolveEditorLabels } from "./editorLabels.js";
13
+ import { useEditorBridge } from "./useEditorBridge.js";
4
14
  import { useCustomTheme } from "../../Theme/useCustomTheme.js";
5
15
  import { isDarkCanvas } from "../../Theme/tokens/builders/accentText.js";
6
16
  import { getJoditThemeVars } from "./joditThemeVars.js";
@@ -13,8 +23,25 @@ const JoditEditor = React.lazy(async () => {
13
23
  return { default: ((_a = mod.default) !== null && _a !== void 0 ? _a : mod) };
14
24
  });
15
25
  /** Lazy-loaded Jodit wrapper — a `config.theme` or `config.popupRoot` you pass overrides this library's own dark-mode/popup fix; omit both keys. */
16
- const Editor = React.memo(function Editor({ value, key, config, editorRef, className, onChange, onBlur, }) {
26
+ const Editor = React.memo(function Editor({ value, key, config, editorRef, className, onChange, onBlur, label, isRequired, helperText, error, errorMessage, mergeFields, tokenSyntax = DEFAULT_TOKEN_SYNTAX, showMakeDynamic, toolbarButtons, onUnknownTokens, apiRef, onReady, labels, "data-testid": testId, }) {
17
27
  const theme = useCustomTheme();
28
+ const text = useMemo(() => resolveEditorLabels(labels), [labels]);
29
+ const { joditValue, attachEditor, api, instance, unknown } = useEditorBridge({
30
+ value,
31
+ onChange,
32
+ onBlur,
33
+ mergeFields,
34
+ syntax: tokenSyntax,
35
+ chipLabel: text.fieldChip,
36
+ apiRef,
37
+ onReady,
38
+ onUnknownTokens,
39
+ });
40
+ const hasFields = mergeFields !== undefined;
41
+ const options = useMemo(() => fieldOptions(mergeFields !== null && mergeFields !== void 0 ? mergeFields : [], tokenSyntax),
42
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
+ [JSON.stringify(mergeFields), tokenSyntax.open, tokenSyntax.close]);
44
+ const [dynamicText, setDynamicText] = useState(null);
18
45
  // Jodit portals dialogs/toolbar-dropdown popups (search & replace, image/link properties,
19
46
  // font-size list, ...) to `document.body` by default (`Dialog.destination` /
20
47
  // `getPopupViewRoot`), outside this wrapper's DOM subtree — so the CSS custom properties
@@ -49,6 +76,24 @@ const Editor = React.memo(function Editor({ value, key, config, editorRef, class
49
76
  observer.observe(popupRoot, { childList: true, subtree: true });
50
77
  return () => observer.disconnect();
51
78
  }, [popupRoot]);
52
- return (_jsx(Box, { ref: setPopupRoot, sx: themeVars, children: _jsx(Suspense, { fallback: null, children: _jsx(JoditEditor, { config: stableConfig, value: value, ref: editorRef, className: className, onChange: onChange, onBlur: onBlur }, key) }) }));
79
+ const unknownActive = hasFields && unknown.length > 0 && !(error && errorMessage);
80
+ const ids = useFieldIds(undefined, { error, errorMessage, helperText });
81
+ const describedBy = unknownActive ? ids.errorId : ids.describedBy;
82
+ const invalid = Boolean(error) || unknownActive;
83
+ const isReadOnly = Boolean(stableConfig === null || stableConfig === void 0 ? void 0 : stableConfig.readonly);
84
+ useEffect(() => {
85
+ if (!instance)
86
+ return;
87
+ const el = instance.editor;
88
+ const set = (name, val) => val === undefined ? el.removeAttribute(name) : el.setAttribute(name, val);
89
+ set("role", "textbox");
90
+ set("aria-multiline", "true");
91
+ set("aria-labelledby", label ? ids.labelId : undefined);
92
+ set("aria-describedby", describedBy);
93
+ set("aria-invalid", invalid ? "true" : undefined);
94
+ set("aria-required", isRequired ? "true" : undefined);
95
+ }, [instance, label, ids.labelId, describedBy, invalid, isRequired]);
96
+ const showFieldBar = hasFields || Boolean(toolbarButtons === null || toolbarButtons === void 0 ? void 0 : toolbarButtons.length);
97
+ return (_jsxs(Box, { "data-testid": testId, children: [label && (_jsxs(Box, { as: "label", id: ids.labelId, display: "block", onClick: () => api.focus(), ...fieldLabelStyles(theme.colors), children: [label, isRequired && (_jsx("span", { "aria-hidden": true, style: { color: theme.colors.semanticText.error, marginLeft: "0.125rem" }, children: "*" }))] })), showFieldBar && (_jsx(EditorFieldBar, { options: options, labels: text, api: api, isDisabled: !instance || isReadOnly, showFieldMenu: hasFields, showMakeDynamic: hasFields && (showMakeDynamic !== null && showMakeDynamic !== void 0 ? showMakeDynamic : true), buttons: toolbarButtons !== null && toolbarButtons !== void 0 ? toolbarButtons : [], onMakeDynamic: () => setDynamicText(api.getSelectionText()) })), _jsx(Box, { ref: setPopupRoot, sx: { ...themeVars, ...chipStyles(theme.colors) }, children: _jsx(Suspense, { fallback: null, children: popupRoot && (_jsx(JoditEditor, { config: stableConfig, value: joditValue, ref: editorRef, editorRef: attachEditor, className: className }, key)) }) }), unknownActive ? (_jsx(ErrorMessage, { id: ids.errorId, errorMessage: text.unknownTokens(unknown.join(", ")) })) : (_jsx(FieldMessage, { error: error, errorMessage: errorMessage, helperText: helperText, helperId: ids.helperId, errorId: ids.errorId })), hasFields && (_jsx(MakeDynamicDialog, { selectedText: dynamicText, options: options, labels: text, countFor: api.countOccurrences, onReplace: api.replaceAll, onClose: () => setDynamicText(null) }))] }));
53
98
  });
54
99
  export default Editor;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Flex, Icon } from "@chakra-ui/react";
3
+ import { WandSparkles } from "lucide-react";
4
+ import Button from "../Button/Button.js";
5
+ import Select from "../Select/Select.js";
6
+ export default function EditorFieldBar({ options, labels, api, isDisabled, showFieldMenu, showMakeDynamic, buttons, onMakeDynamic, }) {
7
+ return (_jsxs(Flex, { role: "toolbar", "aria-label": labels.toolbar, gap: 2, wrap: "wrap", align: "center", mb: 2, children: [showFieldMenu && (_jsx(Box, { width: { base: "100%", sm: "16rem" }, children: _jsx(Select, { native: false, "aria-label": labels.insertField, placeholder: labels.insertField, options: options, value: "", noOptionsMessage: labels.noFields, isDisabled: isDisabled, onChange: (option) => {
8
+ if (!option)
9
+ return;
10
+ api.insertField(String(option.id));
11
+ window.setTimeout(api.focus, 0);
12
+ }, "data-testid": "editor-insert-field" }) })), showMakeDynamic && (_jsx(Button, { variant: "outline", colorScheme: "gray", leftIcon: _jsx(WandSparkles, { size: 16, "aria-hidden": true }), label: labels.makeDynamic, onClick: onMakeDynamic, isDisabled: isDisabled, "data-testid": "editor-make-dynamic" })), buttons.map((button) => (_jsx(Button, { variant: "ghost", colorScheme: "gray", leftIcon: button.icon ? _jsx(Icon, { as: button.icon, boxSize: 4, "aria-hidden": true }) : undefined, label: button.label, onClick: () => button.onClick(api), isDisabled: isDisabled || button.isDisabled, "data-testid": `editor-button-${button.id}` }, button.id)))] }));
13
+ }