@va-scheduling/ui 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -112,6 +112,30 @@ applyInitialSplTheme(() => readMyStoredPreference()); // returns 'light' | 'dark
112
112
 
113
113
  Other exports: `applySplTheme`, `resolveSplTheme`, `getSystemTheme`, `isSplThemePreference`, and the `SplTheme` / `SplThemePreference` types.
114
114
 
115
+ ## Dialogs
116
+
117
+ Built on Radix Themes dialogs, so they inherit its sizing, radius and shadow. They must render inside `SplThemeProvider`'s Radix `Theme` (or create their own root) and style themselves with `--spl-*` tokens. Their CSS is bundled and injected automatically.
118
+
119
+ | Component | Use for |
120
+ | --- | --- |
121
+ | `SplDialog` | Content and form dialogs. Has an X button, a Cancel/primary footer (or a close-only footer), and closes on Escape or outside click. |
122
+ | `SplAlertDialog` | Confirmations that must be answered. No X, no outside-click close, focuses Cancel. Optional `status` icon. |
123
+ | `SplDeleteAlertDialog` | `SplAlertDialog` preset: red trash icon, destructive button, "Please confirm deletion of: **itemName**". |
124
+ | `SplWarningAlertDialog` | `SplAlertDialog` preset: amber warning icon, standard Continue button. |
125
+
126
+ ```tsx
127
+ <SplDeleteAlertDialog
128
+ id="delete-queue"
129
+ title="Delete Queue"
130
+ itemName={queueName}
131
+ isOpen={isOpen}
132
+ onOpenChange={setIsOpen}
133
+ onPrimaryAction={deleteQueue} // a returned promise shows the loading state
134
+ />
135
+ ```
136
+
137
+ Footer buttons get ids `{id}-primary-btn`, `-secondary-btn` and `-tertiary-btn`, and the X is `{id}-close-btn`.
138
+
115
139
  ## Testing (Jest)
116
140
 
117
141
  Jest can't process CSS imports. Map them to a stub:
package/dist/cjs/index.js CHANGED
@@ -2,8 +2,132 @@
2
2
 
3
3
  require('@radix-ui/themes/styles.css');
4
4
  require('@va-scheduling/design-tokens/css');
5
- var React = require('react');
5
+ var reactIcons = require('@radix-ui/react-icons');
6
6
  var themes = require('@radix-ui/themes');
7
+ var React = require('react');
8
+
9
+ function styleInject(css, ref) {
10
+ if ( ref === void 0 ) ref = {};
11
+ var insertAt = ref.insertAt;
12
+
13
+ if (typeof document === 'undefined') { return; }
14
+
15
+ var head = document.head || document.getElementsByTagName('head')[0];
16
+ var style = document.createElement('style');
17
+ style.type = 'text/css';
18
+
19
+ if (insertAt === 'top') {
20
+ if (head.firstChild) {
21
+ head.insertBefore(style, head.firstChild);
22
+ } else {
23
+ head.appendChild(style);
24
+ }
25
+ } else {
26
+ head.appendChild(style);
27
+ }
28
+
29
+ if (style.styleSheet) {
30
+ style.styleSheet.cssText = css;
31
+ } else {
32
+ style.appendChild(document.createTextNode(css));
33
+ }
34
+ }
35
+
36
+ var css_248z = ".splDialog-module_dialog__content__t-Zwr:focus{outline:none}.splDialog-module_dialog__content__t-Zwr.splDialog-module_dialog__content__t-Zwr{font-family:var(--default-font-family);font-size:var(--font-size-2);font-weight:var(--font-weight-regular);line-height:var(--line-height-2)}.splDialog-module_dialog__title__hQwUq.splDialog-module_dialog__title__hQwUq{font-family:var(--default-font-family);font-size:var(--font-size-5);font-weight:var(--font-weight-bold);line-height:var(--heading-line-height-5);margin:0 0 var(--space-4)}.splDialog-module_dialog__description__akkml.splDialog-module_dialog__description__akkml{font-size:var(--font-size-2);line-height:var(--line-height-2);margin:0 0 var(--space-1)}.splDialog-module_dialog__header__4evfq .splDialog-module_dialog__title__hQwUq.splDialog-module_dialog__title__hQwUq{margin:0}.splDialog-module_dialog__header__4evfq{align-items:center;display:flex;gap:12px;margin-bottom:var(--space-3)}.splDialog-module_dialog__statusIcon__xY8Y4{display:inline-flex;margin:0 -2px;position:relative;top:-2px}.splDialog-module_dialog__statusIcon__xY8Y4 svg{height:20px;width:20px}.splDialog-module_dialog__statusIcon--destructive__gZagF{color:var(--spl-colors-error)}.splDialog-module_dialog__statusIcon--warning__53s2a{color:var(--spl-colors-warning)}.splDialog-module_dialog__body__AwXEL{margin-bottom:1rem}.splDialog-module_dialog__footer__nOkmx{display:flex;gap:.5rem;justify-content:flex-end;margin-top:1.5rem}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT{border-radius:100%;box-sizing:border-box;height:32px;margin:0;padding:0;position:absolute;right:8px;top:8px;width:32px}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT svg{height:20px;width:20px}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:active,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:focus,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:hover{background-color:transparent;color:var(--spl-colors-text-default)}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:active,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:hover{background-color:var(--spl-colors-bg-secondary)}.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT{align-items:center;border:none;border-radius:var(--radius-2);box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:var(--default-font-family);font-size:var(--font-size-2);font-weight:var(--font-weight-medium);gap:var(--space-2);height:var(--space-6);justify-content:center;line-height:var(--line-height-2);padding:0 var(--space-3)}.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG,.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG:focus{background-color:var(--spl-colors-button-bg-primary);color:var(--spl-colors-button-text-primary)}.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG:active,.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG:hover{background-color:var(--spl-colors-button-bg-primary-hover-pressed);color:var(--spl-colors-button-text-primary-hover-pressed)}.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az,.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az:active,.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az:focus,.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az:hover{background-color:var(--spl-colors-error);color:var(--spl-colors-base-white)}.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:focus{background-color:var(--spl-colors-button-bg-secondary);box-shadow:inset 0 0 0 1px var(--spl-colors-button-border-secondary);color:var(--spl-colors-button-text-secondary)}.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:active,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:hover{background-color:var(--spl-colors-button-bg-secondary-hover-pressed);box-shadow:inset 0 0 0 1px var(--spl-colors-button-border-secondary);color:var(--spl-colors-button-text-secondary)}.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled,.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled:active,.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled:focus,.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled:hover{background-color:var(--spl-colors-button-bg-primary-disabled);box-shadow:none;color:var(--spl-colors-button-text-primary-disabled);cursor:not-allowed}.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled:active,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled:focus,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled:hover{background-color:var(--spl-colors-button-bg-secondary-disabled);box-shadow:inset 0 0 0 1px var(--spl-colors-button-border-secondary-disabled);color:var(--spl-colors-button-text-secondary-disabled)}";
37
+ var styles = {"dialog__content":"splDialog-module_dialog__content__t-Zwr","dialog__title":"splDialog-module_dialog__title__hQwUq","dialog__description":"splDialog-module_dialog__description__akkml","dialog__header":"splDialog-module_dialog__header__4evfq","dialog__statusIcon":"splDialog-module_dialog__statusIcon__xY8Y4","dialog__statusIcon--destructive":"splDialog-module_dialog__statusIcon--destructive__gZagF","dialog__statusIcon--warning":"splDialog-module_dialog__statusIcon--warning__53s2a","dialog__body":"splDialog-module_dialog__body__AwXEL","dialog__footer":"splDialog-module_dialog__footer__nOkmx","dialog__close":"splDialog-module_dialog__close__RyLWT","button":"splDialog-module_button__8fRnT","button--primary":"splDialog-module_button--primary__n3DCG","button--destructive":"splDialog-module_button--destructive__Ig1Az","button--secondary":"splDialog-module_button--secondary__heKg3"};
38
+ styleInject(css_248z);
39
+
40
+ /**
41
+ * Footer buttons shared by SplDialog and SplAlertDialog.
42
+ * Button ids are `{dialogId}-secondary-btn`, `-tertiary-btn` and `-primary-btn`.
43
+ */
44
+ const SplDialogFooter = ({ dialogId, secondaryLabel, primaryLabel, primaryLoadingLabel, isPrimaryLoading = false, onPrimaryAction, onSecondaryAction, isPrimaryDisabled = false, isSecondaryDisabled = false, primaryVariant = 'default', tertiaryLabel, onTertiaryAction, isTertiaryDisabled = false, wrapSecondary = (button) => button, }) => {
45
+ const [isPending, setIsPending] = React.useState(false);
46
+ const isMounted = React.useRef(true);
47
+ React.useEffect(() => {
48
+ isMounted.current = true;
49
+ return () => { isMounted.current = false; };
50
+ }, []);
51
+ // Cancel is the default secondary label next to a primary button; a close-only footer must opt in via secondaryLabel.
52
+ const secondaryText = secondaryLabel ?? (primaryLabel ? 'Cancel' : undefined);
53
+ if (!primaryLabel && !secondaryText)
54
+ return null;
55
+ const isLoading = isPending || isPrimaryLoading;
56
+ const handlePrimary = async () => {
57
+ setIsPending(true);
58
+ try {
59
+ await onPrimaryAction?.();
60
+ }
61
+ catch {
62
+ // Callers own error handling (e.g. the error store); a rejection only needs to end the loading state.
63
+ }
64
+ finally {
65
+ if (isMounted.current)
66
+ setIsPending(false);
67
+ }
68
+ };
69
+ const secondaryButton = (React.createElement(themes.Button, { type: "button", variant: "outline", className: `${styles.button} ${styles['button--secondary']}`, id: `${dialogId}-secondary-btn`, disabled: isSecondaryDisabled, onClick: onSecondaryAction }, secondaryText));
70
+ return (React.createElement("div", { className: styles.dialog__footer },
71
+ secondaryText && wrapSecondary(secondaryButton),
72
+ tertiaryLabel && onTertiaryAction && (React.createElement(themes.Button, { type: "button", variant: "outline", className: `${styles.button} ${styles['button--secondary']}`, id: `${dialogId}-tertiary-btn`, disabled: isLoading || isTertiaryDisabled, onClick: () => void onTertiaryAction() }, tertiaryLabel)),
73
+ primaryLabel && (React.createElement(themes.Button, { type: "button", id: `${dialogId}-primary-btn`, className: `${styles.button} ${primaryVariant === 'destructive' ? styles['button--destructive'] : styles['button--primary']}`, ...(primaryVariant === 'destructive' ? { color: 'red' } : {}), disabled: isLoading || isPrimaryDisabled, "aria-busy": isLoading, onClick: () => void handlePrimary() },
74
+ isLoading && React.createElement(themes.Spinner, { size: "1" }),
75
+ isLoading && primaryLoadingLabel ? primaryLoadingLabel : primaryLabel))));
76
+ };
77
+
78
+ /**
79
+ * General purpose modal built on Radix Dialog, replacing VaModalWrapper for content and form dialogs.
80
+ * Use SplAlertDialog instead for confirmations that must be answered.
81
+ */
82
+ const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled = false, hasCloseButton = true, contentClassName, size = '3', maxWidth = '544px', onSecondaryAction, ...actions }) => {
83
+ const preventIfDisabled = (event) => {
84
+ if (isDismissDisabled)
85
+ event.preventDefault();
86
+ };
87
+ return (React.createElement(themes.Dialog.Root, { open: isOpen, onOpenChange: onOpenChange },
88
+ React.createElement(themes.Dialog.Content, { id: id, size: size, maxWidth: maxWidth, className: [styles.dialog__content, contentClassName].filter(Boolean).join(' '), onEscapeKeyDown: preventIfDisabled, onInteractOutside: preventIfDisabled, ...(description ? {} : { 'aria-describedby': undefined }) },
89
+ React.createElement(themes.Dialog.Title, { className: styles.dialog__title }, title),
90
+ !isDismissDisabled && hasCloseButton && (React.createElement(themes.Dialog.Close, null,
91
+ React.createElement(themes.IconButton, { type: "button", id: `${id}-close-btn`, variant: "ghost", color: "gray", className: styles.dialog__close, "aria-label": "Close" },
92
+ React.createElement(reactIcons.Cross2Icon, { "aria-hidden": "true" })))),
93
+ description && (React.createElement(themes.Dialog.Description, { className: styles.dialog__description }, description)),
94
+ React.createElement("div", { className: styles.dialog__body }, children),
95
+ footer ?? (React.createElement(SplDialogFooter, { dialogId: id,
96
+ // Cancel always closes the dialog, even when dismissal is disabled; onSecondaryAction is an extra hook, and actions can't override this handler.
97
+ onSecondaryAction: () => {
98
+ onSecondaryAction?.();
99
+ onOpenChange(false);
100
+ }, ...actions })))));
101
+ };
102
+
103
+ /**
104
+ * Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer
105
+ * (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking
106
+ * outside, has no X button, and focuses Cancel first so the safe choice is the default.
107
+ * Cancel closes it through `onOpenChange`. It does not auto-close on accept; the caller closes it
108
+ * through `isOpen` once the action succeeds.
109
+ */
110
+ const SplAlertDialog = ({ id, title, description, isOpen, onOpenChange, children, status, size = '3', maxWidth = '450px', ...actions }) => (React.createElement(themes.AlertDialog.Root, { open: isOpen, onOpenChange: onOpenChange },
111
+ React.createElement(themes.AlertDialog.Content, { id: id, size: size, maxWidth: maxWidth, className: styles.dialog__content },
112
+ React.createElement("div", { className: styles.dialog__header },
113
+ status && (React.createElement("span", { id: `${id}-status-icon`, "aria-hidden": "true", className: `${styles.dialog__statusIcon} ${styles[`dialog__statusIcon--${status}`]}` }, status === 'warning' ? React.createElement(reactIcons.ExclamationTriangleIcon, null) : React.createElement(reactIcons.TrashIcon, null))),
114
+ React.createElement(themes.AlertDialog.Title, { className: styles.dialog__title }, title)),
115
+ React.createElement(themes.AlertDialog.Description, { className: styles.dialog__description }, description),
116
+ children && React.createElement("div", { className: styles.dialog__body }, children),
117
+ React.createElement(SplDialogFooter, { dialogId: id, wrapSecondary: (button) => React.createElement(themes.AlertDialog.Cancel, null, button), ...actions }))));
118
+
119
+ /**
120
+ * Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.
121
+ */
122
+ const SplDeleteAlertDialog = ({ id, itemName, itemNameId = `${id}-item-name`, primaryLabel = 'Delete', primaryLoadingLabel = 'Deleting...', secondaryLabel = 'Cancel', ...rest }) => (React.createElement(SplAlertDialog, { id: id, status: "destructive", primaryVariant: "destructive", primaryLabel: primaryLabel, primaryLoadingLabel: primaryLoadingLabel, secondaryLabel: secondaryLabel, description: React.createElement(React.Fragment, null,
123
+ "Please confirm deletion of: ",
124
+ React.createElement("strong", { id: itemNameId }, itemName)), ...rest }));
125
+
126
+ /**
127
+ * Warning confirmation (e.g. sensitive record access): SplAlertDialog with the amber warning icon
128
+ * and the standard primary button.
129
+ */
130
+ const SplWarningAlertDialog = ({ primaryLabel = 'Continue', secondaryLabel = 'Cancel', ...rest }) => (React.createElement(SplAlertDialog, { status: "warning", primaryLabel: primaryLabel, secondaryLabel: secondaryLabel, ...rest }));
7
131
 
8
132
  const DEFAULT_SPL_THEME = "light";
9
133
  const DARK_SCHEME_QUERY = "(prefers-color-scheme: dark)";
@@ -95,7 +219,11 @@ const SplThemeProvider = ({ children, preference: controlledPreference, defaultP
95
219
  React.createElement(themes.Theme, { appearance: "inherit", grayColor: "slate", hasBackground: false }, children)));
96
220
  };
97
221
 
222
+ exports.SplAlertDialog = SplAlertDialog;
223
+ exports.SplDeleteAlertDialog = SplDeleteAlertDialog;
224
+ exports.SplDialog = SplDialog;
98
225
  exports.SplThemeProvider = SplThemeProvider;
226
+ exports.SplWarningAlertDialog = SplWarningAlertDialog;
99
227
  exports.applyInitialSplTheme = applyInitialSplTheme;
100
228
  exports.applySplTheme = applySplTheme;
101
229
  exports.getSystemTheme = getSystemTheme;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/theme/themeUtils.ts","../../src/components/spl-theme-provider/SplThemeProvider.tsx"],"sourcesContent":["export type SplTheme = \"light\" | \"dark\";\r\nexport type SplThemePreference = SplTheme | \"system\";\r\n\r\nexport const DEFAULT_SPL_THEME: SplTheme = \"light\";\r\nexport const DARK_SCHEME_QUERY = \"(prefers-color-scheme: dark)\";\r\n\r\nexport function isSplThemePreference(value: unknown): value is SplThemePreference {\r\n return value === \"light\" || value === \"dark\" || value === \"system\";\r\n}\r\n\r\nexport function themeFromMatches(matches: boolean): SplTheme {\r\n return matches ? \"dark\" : \"light\";\r\n}\r\n\r\n/** OS/browser color scheme, falling back to light when matchMedia is unavailable. */\r\nexport function getSystemTheme(): SplTheme {\r\n try {\r\n return themeFromMatches(Boolean(window.matchMedia?.(DARK_SCHEME_QUERY)?.matches));\r\n } catch {\r\n return DEFAULT_SPL_THEME;\r\n }\r\n}\r\n\r\nexport function resolveSplTheme(preference: SplThemePreference): SplTheme {\r\n return preference === \"system\" ? getSystemTheme() : preference;\r\n}\r\n\r\n/**\r\n * Applies a theme to the root element: [data-theme] for app styles and the `dark` class that\r\n * @va-scheduling/design-tokens and the Radix dark scales key off of. `color-scheme` is not set.\r\n */\r\nexport function applySplTheme(theme: SplTheme, root: HTMLElement = document.documentElement) {\r\n const safeTheme: SplTheme = theme === \"dark\" ? \"dark\" : DEFAULT_SPL_THEME;\r\n root.setAttribute(\"data-theme\", safeTheme);\r\n root.classList.toggle(\"dark\", safeTheme === \"dark\");\r\n}\r\n\r\n/**\r\n * Applies the stored theme before React renders, to avoid a flash. The app supplies how to read its\r\n * stored preference, since storage differs between apps.\r\n */\r\nexport function applyInitialSplTheme(\r\n readPreference: () => SplThemePreference | undefined = () => undefined,\r\n) {\r\n let preference: SplThemePreference | undefined;\r\n try {\r\n preference = readPreference();\r\n } catch {\r\n preference = undefined;\r\n }\r\n applySplTheme(resolveSplTheme(isSplThemePreference(preference) ? preference : DEFAULT_SPL_THEME));\r\n}\r\n","import React, {\r\n createContext,\r\n useContext,\r\n useEffect,\r\n useLayoutEffect,\r\n useMemo,\r\n useState,\r\n} from \"react\";\r\nimport { Theme } from \"@radix-ui/themes\";\r\nimport {\r\n applySplTheme,\r\n DARK_SCHEME_QUERY,\r\n DEFAULT_SPL_THEME,\r\n getSystemTheme,\r\n SplTheme,\r\n SplThemePreference,\r\n themeFromMatches,\r\n} from \"../../theme/themeUtils\";\r\n\r\nexport interface SplThemeContextValue {\r\n /** The stored preference: 'light', 'dark', or 'system' (follow the OS/browser). */\r\n preference: SplThemePreference;\r\n /** The theme currently applied to the root element. */\r\n theme: SplTheme;\r\n setPreference: (preference: SplThemePreference) => void;\r\n}\r\n\r\nexport interface SplThemeProviderProps {\r\n children?: React.ReactNode;\r\n /** Controlled preference. When set, the app owns storage and must update it in onPreferenceChange. */\r\n preference?: SplThemePreference;\r\n /** Initial preference when uncontrolled. Defaults to light. */\r\n defaultPreference?: SplThemePreference;\r\n onPreferenceChange?: (preference: SplThemePreference) => void;\r\n}\r\n\r\nconst SplThemeContext = createContext<SplThemeContextValue | undefined>(undefined);\r\n\r\nexport function useSplTheme(): SplThemeContextValue {\r\n const context = useContext(SplThemeContext);\r\n if (context === undefined) {\r\n throw new Error(\"useSplTheme must be used within SplThemeProvider\");\r\n }\r\n return context;\r\n}\r\n\r\n/**\r\n * Applies the light/dark theme to the root element and wraps children in a Radix <Theme>\r\n * (appearance=\"inherit\" follows the .dark class; grayColor=\"slate\" matches the design-tokens base scale).\r\n * The OS/browser scheme is only followed, with live updates, when the preference is 'system'.\r\n */\r\nconst SplThemeProvider = ({\r\n children,\r\n preference: controlledPreference,\r\n defaultPreference = DEFAULT_SPL_THEME,\r\n onPreferenceChange,\r\n}: SplThemeProviderProps) => {\r\n const [internalPreference, setInternalPreference] = useState<SplThemePreference>(defaultPreference);\r\n const preference = controlledPreference ?? internalPreference;\r\n const [systemTheme, setSystemTheme] = useState<SplTheme>(getSystemTheme);\r\n\r\n useEffect(() => {\r\n if (preference !== \"system\" || typeof window.matchMedia !== \"function\") {\r\n return undefined;\r\n }\r\n\r\n const mediaQuery = window.matchMedia(DARK_SCHEME_QUERY);\r\n const handleChange = () => setSystemTheme(getSystemTheme());\r\n\r\n // systemTheme goes stale while an explicit preference is set (no listener), so resync here\r\n setSystemTheme(themeFromMatches(mediaQuery.matches));\r\n mediaQuery.addEventListener?.(\"change\", handleChange);\r\n return () => mediaQuery.removeEventListener?.(\"change\", handleChange);\r\n }, [preference]);\r\n\r\n const theme: SplTheme = preference === \"system\" ? systemTheme : preference;\r\n\r\n useLayoutEffect(() => {\r\n applySplTheme(theme);\r\n }, [theme]);\r\n\r\n const value = useMemo<SplThemeContextValue>(\r\n () => ({\r\n preference,\r\n theme,\r\n setPreference: (next: SplThemePreference) => {\r\n if (controlledPreference === undefined) {\r\n setInternalPreference(next);\r\n }\r\n onPreferenceChange?.(next);\r\n },\r\n }),\r\n [preference, theme, controlledPreference, onPreferenceChange],\r\n );\r\n\r\n return (\r\n <SplThemeContext.Provider value={value}>\r\n <Theme appearance=\"inherit\" grayColor=\"slate\" hasBackground={false}>\r\n {children}\r\n </Theme>\r\n </SplThemeContext.Provider>\r\n );\r\n};\r\n\r\nexport default SplThemeProvider;\r\n"],"names":["createContext","useContext","useState","useEffect","useLayoutEffect","useMemo","Theme"],"mappings":";;;;;;;AAGO,MAAM,iBAAiB,GAAa,OAAO;AAC3C,MAAM,iBAAiB,GAAG,8BAA8B;AAEzD,SAAU,oBAAoB,CAAC,KAAc,EAAA;IACjD,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ;AACpE;AAEM,SAAU,gBAAgB,CAAC,OAAgB,EAAA;IAC/C,OAAO,OAAO,GAAG,MAAM,GAAG,OAAO;AACnC;AAEA;SACgB,cAAc,GAAA;AAC5B,IAAA,IAAI;AACF,QAAA,OAAO,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC;IACnF;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,iBAAiB;IAC1B;AACF;AAEM,SAAU,eAAe,CAAC,UAA8B,EAAA;AAC5D,IAAA,OAAO,UAAU,KAAK,QAAQ,GAAG,cAA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,CACH,CACiB;AAE/B;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../node_modules/style-inject/dist/style-inject.es.js","../../src/components/spl-dialog/SplDialogFooter.tsx","../../src/components/spl-dialog/SplDialog.tsx","../../src/components/spl-dialog/SplAlertDialog.tsx","../../src/components/spl-dialog/SplDeleteAlertDialog.tsx","../../src/components/spl-dialog/SplWarningAlertDialog.tsx","../../src/theme/themeUtils.ts","../../src/components/spl-theme-provider/SplThemeProvider.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { Button, Spinner } from '@radix-ui/themes';\r\nimport React, { ReactNode, useEffect, useRef, useState } from 'react';\r\n\r\nimport styles from './splDialog.module.css';\r\n\r\nexport type SplDialogActionsProps = {\r\n /** Text for the cancel/close button. Defaults to \"Cancel\" when a primary button is shown. Provide it alone (e.g. \"Close\") for a close-only footer. */\r\n secondaryLabel?: string;\r\n /** Text for the accept button. */\r\n primaryLabel?: string;\r\n /** Text for the accept button while it is loading. */\r\n primaryLoadingLabel?: string;\r\n /** Forces the primary button into its loading state, for loading driven by a store or parent. Loading from `onPrimaryAction` promises is tracked automatically. */\r\n isPrimaryLoading?: boolean;\r\n /** Called on accept. If it returns a promise the primary button shows a loading state until it settles. */\r\n onPrimaryAction?: () => void | Promise<void>;\r\n /** Called on cancel. The dialog also closes through `onOpenChange`. */\r\n onSecondaryAction?: () => void;\r\n isPrimaryDisabled?: boolean;\r\n isSecondaryDisabled?: boolean;\r\n /** Visual treatment of the primary button. `destructive` is for deletions. */\r\n primaryVariant?: 'default' | 'destructive';\r\n /** Optional extra button between secondary and primary. */\r\n tertiaryLabel?: string;\r\n onTertiaryAction?: () => void | Promise<void>;\r\n isTertiaryDisabled?: boolean;\r\n};\r\n\r\ntype SplDialogFooterProps = SplDialogActionsProps & {\r\n dialogId: string;\r\n /** Wraps the secondary button so Radix primitives (e.g. AlertDialog.Cancel) can own it. */\r\n wrapSecondary?: (button: ReactNode) => ReactNode;\r\n};\r\n\r\n/**\r\n * Footer buttons shared by SplDialog and SplAlertDialog.\r\n * Button ids are `{dialogId}-secondary-btn`, `-tertiary-btn` and `-primary-btn`.\r\n */\r\nconst SplDialogFooter = ({\r\n dialogId,\r\n secondaryLabel,\r\n primaryLabel,\r\n primaryLoadingLabel,\r\n isPrimaryLoading = false,\r\n onPrimaryAction,\r\n onSecondaryAction,\r\n isPrimaryDisabled = false,\r\n isSecondaryDisabled = false,\r\n primaryVariant = 'default',\r\n tertiaryLabel,\r\n onTertiaryAction,\r\n isTertiaryDisabled = false,\r\n wrapSecondary = (button) => button,\r\n}: SplDialogFooterProps) => {\r\n const [isPending, setIsPending] = useState(false);\r\n const isMounted = useRef(true);\r\n\r\n useEffect(() => {\r\n isMounted.current = true;\r\n return () => { isMounted.current = false; };\r\n }, []);\r\n\r\n // Cancel is the default secondary label next to a primary button; a close-only footer must opt in via secondaryLabel.\r\n const secondaryText = secondaryLabel ?? (primaryLabel ? 'Cancel' : undefined);\r\n if (!primaryLabel && !secondaryText) return null;\r\n\r\n const isLoading = isPending || isPrimaryLoading;\r\n\r\n const handlePrimary = async () => {\r\n setIsPending(true);\r\n try {\r\n await onPrimaryAction?.();\r\n } catch {\r\n // Callers own error handling (e.g. the error store); a rejection only needs to end the loading state.\r\n } finally {\r\n if (isMounted.current) setIsPending(false);\r\n }\r\n };\r\n\r\n const secondaryButton = (\r\n <Button\r\n type=\"button\"\r\n variant=\"outline\"\r\n className={`${styles.button} ${styles['button--secondary']}`}\r\n id={`${dialogId}-secondary-btn`}\r\n disabled={isSecondaryDisabled}\r\n onClick={onSecondaryAction}\r\n >\r\n {secondaryText}\r\n </Button>\r\n );\r\n\r\n return (\r\n <div className={styles.dialog__footer}>\r\n {secondaryText && wrapSecondary(secondaryButton)}\r\n {tertiaryLabel && onTertiaryAction && (\r\n <Button\r\n type=\"button\"\r\n variant=\"outline\"\r\n className={`${styles.button} ${styles['button--secondary']}`}\r\n id={`${dialogId}-tertiary-btn`}\r\n disabled={isLoading || isTertiaryDisabled}\r\n onClick={() => void onTertiaryAction()}\r\n >\r\n {tertiaryLabel}\r\n </Button>\r\n )}\r\n {primaryLabel && (\r\n <Button\r\n type=\"button\"\r\n id={`${dialogId}-primary-btn`}\r\n className={`${styles.button} ${primaryVariant === 'destructive' ? styles['button--destructive'] : styles['button--primary']}`}\r\n {...(primaryVariant === 'destructive' ? { color: 'red' as const } : {})}\r\n disabled={isLoading || isPrimaryDisabled}\r\n aria-busy={isLoading}\r\n onClick={() => void handlePrimary()}\r\n >\r\n {/* Radix's `loading` prop hides the label; render the spinner beside it instead. */}\r\n {isLoading && <Spinner size=\"1\" />}\r\n {isLoading && primaryLoadingLabel ? primaryLoadingLabel : primaryLabel}\r\n </Button>\r\n )}\r\n </div>\r\n );\r\n};\r\n\r\nexport default SplDialogFooter;\r\n","import { Cross2Icon } from '@radix-ui/react-icons';\r\nimport { Dialog, IconButton } from '@radix-ui/themes';\r\nimport React, { ReactNode } from 'react';\r\n\r\nimport SplDialogFooter, { SplDialogActionsProps } from './SplDialogFooter';\r\nimport { SplDialogSizeProps } from './splDialogSize';\r\nimport styles from './splDialog.module.css';\r\n\r\nexport type SplDialogProps = SplDialogActionsProps & SplDialogSizeProps & {\r\n /** Unique id; the content element gets this id and footer buttons derive theirs from it. */\r\n id: string;\r\n title: string;\r\n /** Optional description announced by screen readers. */\r\n description?: string;\r\n isOpen: boolean;\r\n onOpenChange: (isOpen: boolean) => void;\r\n children: ReactNode;\r\n /** Replace the built-in footer entirely (e.g. for forms that own their buttons). */\r\n footer?: ReactNode;\r\n /** Prevent closing via Escape, overlay click, or the X button. */\r\n isDismissDisabled?: boolean;\r\n /** Show the X button in the corner. Defaults to true; Escape and overlay click still close the dialog when false. */\r\n hasCloseButton?: boolean;\r\n /** Extra class on the content panel, for width overrides. */\r\n contentClassName?: string;\r\n};\r\n\r\n/**\r\n * General purpose modal built on Radix Dialog, replacing VaModalWrapper for content and form dialogs.\r\n * Use SplAlertDialog instead for confirmations that must be answered.\r\n */\r\nconst SplDialog = ({\r\n id,\r\n title,\r\n description,\r\n isOpen,\r\n onOpenChange,\r\n children,\r\n footer,\r\n isDismissDisabled = false,\r\n hasCloseButton = true,\r\n contentClassName,\r\n size = '3',\r\n maxWidth = '544px',\r\n onSecondaryAction,\r\n ...actions\r\n}: SplDialogProps) => {\r\n const preventIfDisabled = (event: Event) => {\r\n if (isDismissDisabled) event.preventDefault();\r\n };\r\n\r\n return (\r\n <Dialog.Root open={isOpen} onOpenChange={onOpenChange}>\r\n <Dialog.Content\r\n id={id}\r\n size={size}\r\n maxWidth={maxWidth}\r\n className={[styles.dialog__content, contentClassName].filter(Boolean).join(' ')}\r\n onEscapeKeyDown={preventIfDisabled}\r\n onInteractOutside={preventIfDisabled}\r\n {...(description ? {} : { 'aria-describedby': undefined })}\r\n >\r\n <Dialog.Title className={styles.dialog__title}>{title}</Dialog.Title>\r\n {!isDismissDisabled && hasCloseButton && (\r\n <Dialog.Close>\r\n <IconButton\r\n type=\"button\"\r\n id={`${id}-close-btn`}\r\n variant=\"ghost\"\r\n color=\"gray\"\r\n className={styles.dialog__close}\r\n aria-label=\"Close\"\r\n >\r\n <Cross2Icon aria-hidden=\"true\" />\r\n </IconButton>\r\n </Dialog.Close>\r\n )}\r\n {description && (\r\n <Dialog.Description className={styles.dialog__description}>{description}</Dialog.Description>\r\n )}\r\n <div className={styles.dialog__body}>{children}</div>\r\n {footer ?? (\r\n <SplDialogFooter\r\n dialogId={id}\r\n // Cancel always closes the dialog, even when dismissal is disabled; onSecondaryAction is an extra hook, and actions can't override this handler.\r\n onSecondaryAction={() => {\r\n onSecondaryAction?.();\r\n onOpenChange(false);\r\n }}\r\n {...actions}\r\n />\r\n )}\r\n </Dialog.Content>\r\n </Dialog.Root>\r\n );\r\n};\r\n\r\nexport default SplDialog;\r\n","import { ExclamationTriangleIcon, TrashIcon } from '@radix-ui/react-icons';\r\nimport { AlertDialog } from '@radix-ui/themes';\r\nimport React, { ReactNode } from 'react';\r\n\r\nimport SplDialogFooter, { SplDialogActionsProps } from './SplDialogFooter';\r\nimport { SplDialogSizeProps } from './splDialogSize';\r\nimport styles from './splDialog.module.css';\r\n\r\nexport type SplAlertDialogProps = Omit<SplDialogActionsProps, 'primaryLabel'> & SplDialogSizeProps & {\r\n /** Unique id; the content element gets this id and footer buttons derive theirs from it. */\r\n id: string;\r\n title: string;\r\n /** Required: alert dialogs must tell the user what they are confirming. May include inline markup. */\r\n description: ReactNode;\r\n isOpen: boolean;\r\n onOpenChange: (isOpen: boolean) => void;\r\n /** Required: an alert dialog always has an accept action. */\r\n primaryLabel: string;\r\n /** Optional extra content below the description (e.g. an error alert). */\r\n children?: ReactNode;\r\n /** Shows a leading icon before the title: a red trash can for 'destructive', an amber triangle for 'warning'. */\r\n status?: 'destructive' | 'warning';\r\n};\r\n\r\n/**\r\n * Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer\r\n * (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking\r\n * outside, has no X button, and focuses Cancel first so the safe choice is the default.\r\n * Cancel closes it through `onOpenChange`. It does not auto-close on accept; the caller closes it\r\n * through `isOpen` once the action succeeds.\r\n */\r\nconst SplAlertDialog = ({\r\n id,\r\n title,\r\n description,\r\n isOpen,\r\n onOpenChange,\r\n children,\r\n status,\r\n size = '3',\r\n maxWidth = '450px',\r\n ...actions\r\n}: SplAlertDialogProps) => (\r\n <AlertDialog.Root open={isOpen} onOpenChange={onOpenChange}>\r\n <AlertDialog.Content\r\n id={id}\r\n size={size}\r\n maxWidth={maxWidth}\r\n className={styles.dialog__content}\r\n >\r\n <div className={styles.dialog__header}>\r\n {status && (\r\n <span\r\n id={`${id}-status-icon`}\r\n aria-hidden=\"true\"\r\n className={`${styles.dialog__statusIcon} ${styles[`dialog__statusIcon--${status}`]}`}\r\n >\r\n {status === 'warning' ? <ExclamationTriangleIcon /> : <TrashIcon />}\r\n </span>\r\n )}\r\n <AlertDialog.Title className={styles.dialog__title}>{title}</AlertDialog.Title>\r\n </div>\r\n <AlertDialog.Description className={styles.dialog__description}>\r\n {description}\r\n </AlertDialog.Description>\r\n {children && <div className={styles.dialog__body}>{children}</div>}\r\n <SplDialogFooter\r\n dialogId={id}\r\n wrapSecondary={(button) => <AlertDialog.Cancel>{button}</AlertDialog.Cancel>}\r\n {...actions}\r\n />\r\n </AlertDialog.Content>\r\n </AlertDialog.Root>\r\n);\r\n\r\nexport default SplAlertDialog;\r\n","import React from 'react';\r\n\r\nimport SplAlertDialog, { SplAlertDialogProps } from './SplAlertDialog';\r\n\r\nexport type SplDeleteAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'description' | 'primaryLabel'> & {\r\n /** Name of the item being deleted, shown in bold after \"Please confirm deletion of:\". */\r\n itemName: string;\r\n /** Id for the bold item name element. Defaults to `{id}-item-name`. */\r\n itemNameId?: string;\r\n /** Defaults to \"Delete\". */\r\n primaryLabel?: string;\r\n};\r\n\r\n/**\r\n * Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.\r\n */\r\nconst SplDeleteAlertDialog = ({\r\n id,\r\n itemName,\r\n itemNameId = `${id}-item-name`,\r\n primaryLabel = 'Delete',\r\n primaryLoadingLabel = 'Deleting...',\r\n secondaryLabel = 'Cancel',\r\n ...rest\r\n}: SplDeleteAlertDialogProps) => (\r\n <SplAlertDialog\r\n id={id}\r\n status=\"destructive\"\r\n primaryVariant=\"destructive\"\r\n primaryLabel={primaryLabel}\r\n primaryLoadingLabel={primaryLoadingLabel}\r\n secondaryLabel={secondaryLabel}\r\n description={\r\n <>\r\n Please confirm deletion of: <strong id={itemNameId}>{itemName}</strong>\r\n </>\r\n }\r\n {...rest}\r\n />\r\n);\r\n\r\nexport default SplDeleteAlertDialog;\r\n","import React from 'react';\r\n\r\nimport SplAlertDialog, { SplAlertDialogProps } from './SplAlertDialog';\r\n\r\nexport type SplWarningAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'primaryLabel'> & {\r\n /** Defaults to \"Continue\". */\r\n primaryLabel?: string;\r\n};\r\n\r\n/**\r\n * Warning confirmation (e.g. sensitive record access): SplAlertDialog with the amber warning icon\r\n * and the standard primary button.\r\n */\r\nconst SplWarningAlertDialog = ({\r\n primaryLabel = 'Continue',\r\n secondaryLabel = 'Cancel',\r\n ...rest\r\n}: SplWarningAlertDialogProps) => (\r\n <SplAlertDialog status=\"warning\" primaryLabel={primaryLabel} secondaryLabel={secondaryLabel} {...rest} />\r\n);\r\n\r\nexport default SplWarningAlertDialog;\r\n","export type SplTheme = \"light\" | \"dark\";\r\nexport type SplThemePreference = SplTheme | \"system\";\r\n\r\nexport const DEFAULT_SPL_THEME: SplTheme = \"light\";\r\nexport const DARK_SCHEME_QUERY = \"(prefers-color-scheme: dark)\";\r\n\r\nexport function isSplThemePreference(value: unknown): value is SplThemePreference {\r\n return value === \"light\" || value === \"dark\" || value === \"system\";\r\n}\r\n\r\nexport function themeFromMatches(matches: boolean): SplTheme {\r\n return matches ? \"dark\" : \"light\";\r\n}\r\n\r\n/** OS/browser color scheme, falling back to light when matchMedia is unavailable. */\r\nexport function getSystemTheme(): SplTheme {\r\n try {\r\n return themeFromMatches(Boolean(window.matchMedia?.(DARK_SCHEME_QUERY)?.matches));\r\n } catch {\r\n return DEFAULT_SPL_THEME;\r\n }\r\n}\r\n\r\nexport function resolveSplTheme(preference: SplThemePreference): SplTheme {\r\n return preference === \"system\" ? getSystemTheme() : preference;\r\n}\r\n\r\n/**\r\n * Applies a theme to the root element: [data-theme] for app styles and the `dark` class that\r\n * @va-scheduling/design-tokens and the Radix dark scales key off of. `color-scheme` is not set.\r\n */\r\nexport function applySplTheme(theme: SplTheme, root: HTMLElement = document.documentElement) {\r\n const safeTheme: SplTheme = theme === \"dark\" ? \"dark\" : DEFAULT_SPL_THEME;\r\n root.setAttribute(\"data-theme\", safeTheme);\r\n root.classList.toggle(\"dark\", safeTheme === \"dark\");\r\n}\r\n\r\n/**\r\n * Applies the stored theme before React renders, to avoid a flash. The app supplies how to read its\r\n * stored preference, since storage differs between apps.\r\n */\r\nexport function applyInitialSplTheme(\r\n readPreference: () => SplThemePreference | undefined = () => undefined,\r\n) {\r\n let preference: SplThemePreference | undefined;\r\n try {\r\n preference = readPreference();\r\n } catch {\r\n preference = undefined;\r\n }\r\n applySplTheme(resolveSplTheme(isSplThemePreference(preference) ? preference : DEFAULT_SPL_THEME));\r\n}\r\n","import React, {\r\n createContext,\r\n useContext,\r\n useEffect,\r\n useLayoutEffect,\r\n useMemo,\r\n useState,\r\n} from \"react\";\r\nimport { Theme } from \"@radix-ui/themes\";\r\nimport {\r\n applySplTheme,\r\n DARK_SCHEME_QUERY,\r\n DEFAULT_SPL_THEME,\r\n getSystemTheme,\r\n SplTheme,\r\n SplThemePreference,\r\n themeFromMatches,\r\n} from \"../../theme/themeUtils\";\r\n\r\nexport interface SplThemeContextValue {\r\n /** The stored preference: 'light', 'dark', or 'system' (follow the OS/browser). */\r\n preference: SplThemePreference;\r\n /** The theme currently applied to the root element. */\r\n theme: SplTheme;\r\n setPreference: (preference: SplThemePreference) => void;\r\n}\r\n\r\nexport interface SplThemeProviderProps {\r\n children?: React.ReactNode;\r\n /** Controlled preference. When set, the app owns storage and must update it in onPreferenceChange. */\r\n preference?: SplThemePreference;\r\n /** Initial preference when uncontrolled. Defaults to light. */\r\n defaultPreference?: SplThemePreference;\r\n onPreferenceChange?: (preference: SplThemePreference) => void;\r\n}\r\n\r\nconst SplThemeContext = createContext<SplThemeContextValue | undefined>(undefined);\r\n\r\nexport function useSplTheme(): SplThemeContextValue {\r\n const context = useContext(SplThemeContext);\r\n if (context === undefined) {\r\n throw new Error(\"useSplTheme must be used within SplThemeProvider\");\r\n }\r\n return context;\r\n}\r\n\r\n/**\r\n * Applies the light/dark theme to the root element and wraps children in a Radix <Theme>\r\n * (appearance=\"inherit\" follows the .dark class; grayColor=\"slate\" matches the design-tokens base scale).\r\n * The OS/browser scheme is only followed, with live updates, when the preference is 'system'.\r\n */\r\nconst SplThemeProvider = ({\r\n children,\r\n preference: controlledPreference,\r\n defaultPreference = DEFAULT_SPL_THEME,\r\n onPreferenceChange,\r\n}: SplThemeProviderProps) => {\r\n const [internalPreference, setInternalPreference] = useState<SplThemePreference>(defaultPreference);\r\n const preference = controlledPreference ?? internalPreference;\r\n const [systemTheme, setSystemTheme] = useState<SplTheme>(getSystemTheme);\r\n\r\n useEffect(() => {\r\n if (preference !== \"system\" || typeof window.matchMedia !== \"function\") {\r\n return undefined;\r\n }\r\n\r\n const mediaQuery = window.matchMedia(DARK_SCHEME_QUERY);\r\n const handleChange = () => setSystemTheme(getSystemTheme());\r\n\r\n // systemTheme goes stale while an explicit preference is set (no listener), so resync here\r\n setSystemTheme(themeFromMatches(mediaQuery.matches));\r\n mediaQuery.addEventListener?.(\"change\", handleChange);\r\n return () => mediaQuery.removeEventListener?.(\"change\", handleChange);\r\n }, [preference]);\r\n\r\n const theme: SplTheme = preference === \"system\" ? systemTheme : preference;\r\n\r\n useLayoutEffect(() => {\r\n applySplTheme(theme);\r\n }, [theme]);\r\n\r\n const value = useMemo<SplThemeContextValue>(\r\n () => ({\r\n preference,\r\n theme,\r\n setPreference: (next: SplThemePreference) => {\r\n if (controlledPreference === undefined) {\r\n setInternalPreference(next);\r\n }\r\n onPreferenceChange?.(next);\r\n },\r\n }),\r\n [preference, theme, controlledPreference, onPreferenceChange],\r\n );\r\n\r\n return (\r\n <SplThemeContext.Provider value={value}>\r\n <Theme appearance=\"inherit\" grayColor=\"slate\" hasBackground={false}>\r\n {children}\r\n </Theme>\r\n </SplThemeContext.Provider>\r\n );\r\n};\r\n\r\nexport default SplThemeProvider;\r\n"],"names":["useState","useRef","useEffect","Button","Spinner","Dialog","IconButton","Cross2Icon","AlertDialog","ExclamationTriangleIcon","TrashIcon","createContext","useContext","useLayoutEffect","useMemo","Theme"],"mappings":";;;;;;;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,CAAC;;AAEzD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;AAC/C,IAAI,CAAC,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC7B,IAAI;AACJ,EAAE,CAAC,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC3B,EAAE;;AAEF,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG;AAClC,EAAE,CAAC,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC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,EAAC,SAAS,EAAC,SAAS,EAAC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAA,EAC/D,QAAQ,CACH,CACiB;AAE/B;;;;;;;;;;;;","x_google_ignoreList":[0]}
@@ -1,2 +1,4 @@
1
+ export { SplDialog, SplAlertDialog, SplDeleteAlertDialog, SplWarningAlertDialog, } from "./spl-dialog";
2
+ export type { SplDialogProps, SplAlertDialogProps, SplDeleteAlertDialogProps, SplWarningAlertDialogProps, SplDialogActionsProps, SplDialogSize, SplDialogSizeProps, } from "./spl-dialog";
1
3
  export { default as SplThemeProvider, useSplTheme } from "./spl-theme-provider";
2
4
  export type { SplThemeProviderProps, SplThemeContextValue } from "./spl-theme-provider";
@@ -0,0 +1,27 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { SplDialogActionsProps } from './SplDialogFooter';
3
+ import { SplDialogSizeProps } from './splDialogSize';
4
+ export type SplAlertDialogProps = Omit<SplDialogActionsProps, 'primaryLabel'> & SplDialogSizeProps & {
5
+ /** Unique id; the content element gets this id and footer buttons derive theirs from it. */
6
+ id: string;
7
+ title: string;
8
+ /** Required: alert dialogs must tell the user what they are confirming. May include inline markup. */
9
+ description: ReactNode;
10
+ isOpen: boolean;
11
+ onOpenChange: (isOpen: boolean) => void;
12
+ /** Required: an alert dialog always has an accept action. */
13
+ primaryLabel: string;
14
+ /** Optional extra content below the description (e.g. an error alert). */
15
+ children?: ReactNode;
16
+ /** Shows a leading icon before the title: a red trash can for 'destructive', an amber triangle for 'warning'. */
17
+ status?: 'destructive' | 'warning';
18
+ };
19
+ /**
20
+ * Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer
21
+ * (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking
22
+ * outside, has no X button, and focuses Cancel first so the safe choice is the default.
23
+ * Cancel closes it through `onOpenChange`. It does not auto-close on accept; the caller closes it
24
+ * through `isOpen` once the action succeeds.
25
+ */
26
+ declare const SplAlertDialog: ({ id, title, description, isOpen, onOpenChange, children, status, size, maxWidth, ...actions }: SplAlertDialogProps) => React.JSX.Element;
27
+ export default SplAlertDialog;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { SplAlertDialogProps } from './SplAlertDialog';
3
+ export type SplDeleteAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'description' | 'primaryLabel'> & {
4
+ /** Name of the item being deleted, shown in bold after "Please confirm deletion of:". */
5
+ itemName: string;
6
+ /** Id for the bold item name element. Defaults to `{id}-item-name`. */
7
+ itemNameId?: string;
8
+ /** Defaults to "Delete". */
9
+ primaryLabel?: string;
10
+ };
11
+ /**
12
+ * Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.
13
+ */
14
+ declare const SplDeleteAlertDialog: ({ id, itemName, itemNameId, primaryLabel, primaryLoadingLabel, secondaryLabel, ...rest }: SplDeleteAlertDialogProps) => React.JSX.Element;
15
+ export default SplDeleteAlertDialog;
@@ -0,0 +1,27 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { SplDialogActionsProps } from './SplDialogFooter';
3
+ import { SplDialogSizeProps } from './splDialogSize';
4
+ export type SplDialogProps = SplDialogActionsProps & SplDialogSizeProps & {
5
+ /** Unique id; the content element gets this id and footer buttons derive theirs from it. */
6
+ id: string;
7
+ title: string;
8
+ /** Optional description announced by screen readers. */
9
+ description?: string;
10
+ isOpen: boolean;
11
+ onOpenChange: (isOpen: boolean) => void;
12
+ children: ReactNode;
13
+ /** Replace the built-in footer entirely (e.g. for forms that own their buttons). */
14
+ footer?: ReactNode;
15
+ /** Prevent closing via Escape, overlay click, or the X button. */
16
+ isDismissDisabled?: boolean;
17
+ /** Show the X button in the corner. Defaults to true; Escape and overlay click still close the dialog when false. */
18
+ hasCloseButton?: boolean;
19
+ /** Extra class on the content panel, for width overrides. */
20
+ contentClassName?: string;
21
+ };
22
+ /**
23
+ * General purpose modal built on Radix Dialog, replacing VaModalWrapper for content and form dialogs.
24
+ * Use SplAlertDialog instead for confirmations that must be answered.
25
+ */
26
+ declare const SplDialog: ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled, hasCloseButton, contentClassName, size, maxWidth, onSecondaryAction, ...actions }: SplDialogProps) => React.JSX.Element;
27
+ export default SplDialog;
@@ -0,0 +1,34 @@
1
+ import React, { ReactNode } from 'react';
2
+ export type SplDialogActionsProps = {
3
+ /** Text for the cancel/close button. Defaults to "Cancel" when a primary button is shown. Provide it alone (e.g. "Close") for a close-only footer. */
4
+ secondaryLabel?: string;
5
+ /** Text for the accept button. */
6
+ primaryLabel?: string;
7
+ /** Text for the accept button while it is loading. */
8
+ primaryLoadingLabel?: string;
9
+ /** Forces the primary button into its loading state, for loading driven by a store or parent. Loading from `onPrimaryAction` promises is tracked automatically. */
10
+ isPrimaryLoading?: boolean;
11
+ /** Called on accept. If it returns a promise the primary button shows a loading state until it settles. */
12
+ onPrimaryAction?: () => void | Promise<void>;
13
+ /** Called on cancel. The dialog also closes through `onOpenChange`. */
14
+ onSecondaryAction?: () => void;
15
+ isPrimaryDisabled?: boolean;
16
+ isSecondaryDisabled?: boolean;
17
+ /** Visual treatment of the primary button. `destructive` is for deletions. */
18
+ primaryVariant?: 'default' | 'destructive';
19
+ /** Optional extra button between secondary and primary. */
20
+ tertiaryLabel?: string;
21
+ onTertiaryAction?: () => void | Promise<void>;
22
+ isTertiaryDisabled?: boolean;
23
+ };
24
+ type SplDialogFooterProps = SplDialogActionsProps & {
25
+ dialogId: string;
26
+ /** Wraps the secondary button so Radix primitives (e.g. AlertDialog.Cancel) can own it. */
27
+ wrapSecondary?: (button: ReactNode) => ReactNode;
28
+ };
29
+ /**
30
+ * Footer buttons shared by SplDialog and SplAlertDialog.
31
+ * Button ids are `{dialogId}-secondary-btn`, `-tertiary-btn` and `-primary-btn`.
32
+ */
33
+ declare const SplDialogFooter: ({ dialogId, secondaryLabel, primaryLabel, primaryLoadingLabel, isPrimaryLoading, onPrimaryAction, onSecondaryAction, isPrimaryDisabled, isSecondaryDisabled, primaryVariant, tertiaryLabel, onTertiaryAction, isTertiaryDisabled, wrapSecondary, }: SplDialogFooterProps) => React.JSX.Element | null;
34
+ export default SplDialogFooter;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { SplAlertDialogProps } from './SplAlertDialog';
3
+ export type SplWarningAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'primaryLabel'> & {
4
+ /** Defaults to "Continue". */
5
+ primaryLabel?: string;
6
+ };
7
+ /**
8
+ * Warning confirmation (e.g. sensitive record access): SplAlertDialog with the amber warning icon
9
+ * and the standard primary button.
10
+ */
11
+ declare const SplWarningAlertDialog: ({ primaryLabel, secondaryLabel, ...rest }: SplWarningAlertDialogProps) => React.JSX.Element;
12
+ export default SplWarningAlertDialog;
@@ -0,0 +1,10 @@
1
+ export { default as SplDialog } from "./SplDialog";
2
+ export type { SplDialogProps } from "./SplDialog";
3
+ export { default as SplAlertDialog } from "./SplAlertDialog";
4
+ export type { SplAlertDialogProps } from "./SplAlertDialog";
5
+ export { default as SplDeleteAlertDialog } from "./SplDeleteAlertDialog";
6
+ export type { SplDeleteAlertDialogProps } from "./SplDeleteAlertDialog";
7
+ export { default as SplWarningAlertDialog } from "./SplWarningAlertDialog";
8
+ export type { SplWarningAlertDialogProps } from "./SplWarningAlertDialog";
9
+ export type { SplDialogActionsProps } from "./SplDialogFooter";
10
+ export type { SplDialogSize, SplDialogSizeProps } from "./splDialogSize";
@@ -0,0 +1,4 @@
1
+ type ModalButtonKind = 'primary' | 'secondary' | 'tertiary';
2
+ /** Id for a dialog footer button, e.g. `delete-clinic-list-container-primary-btn`. */
3
+ export declare const getModalButtonId: (modalId: string, kind: ModalButtonKind) => string;
4
+ export {};
@@ -0,0 +1,8 @@
1
+ /** Same size scale as Radix Themes dialogs: 1 = 12px padding, 2 = 16px, 3 = 24px (default), 4 = 32px. */
2
+ export type SplDialogSize = '1' | '2' | '3' | '4';
3
+ export type SplDialogSizeProps = {
4
+ /** Padding and corner radius preset, applied by Radix Themes. Defaults to '3'. */
5
+ size?: SplDialogSize;
6
+ /** Maximum width as any CSS length (e.g. `'450px'`, `'50rem'`). Defaults to 544px (450px for alert dialogs). */
7
+ maxWidth?: string;
8
+ };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,131 @@
1
1
  import '@radix-ui/themes/styles.css';
2
2
  import '@va-scheduling/design-tokens/css';
3
- import React, { createContext, useState, useEffect, useLayoutEffect, useMemo, useContext } from 'react';
4
- import { Theme } from '@radix-ui/themes';
3
+ import { Cross2Icon, ExclamationTriangleIcon, TrashIcon } from '@radix-ui/react-icons';
4
+ import { Button, Spinner, Dialog, IconButton, AlertDialog, Theme } from '@radix-ui/themes';
5
+ import React, { useState, useRef, useEffect, createContext, useLayoutEffect, useMemo, useContext } from 'react';
6
+
7
+ function styleInject(css, ref) {
8
+ if ( ref === void 0 ) ref = {};
9
+ var insertAt = ref.insertAt;
10
+
11
+ if (typeof document === 'undefined') { return; }
12
+
13
+ var head = document.head || document.getElementsByTagName('head')[0];
14
+ var style = document.createElement('style');
15
+ style.type = 'text/css';
16
+
17
+ if (insertAt === 'top') {
18
+ if (head.firstChild) {
19
+ head.insertBefore(style, head.firstChild);
20
+ } else {
21
+ head.appendChild(style);
22
+ }
23
+ } else {
24
+ head.appendChild(style);
25
+ }
26
+
27
+ if (style.styleSheet) {
28
+ style.styleSheet.cssText = css;
29
+ } else {
30
+ style.appendChild(document.createTextNode(css));
31
+ }
32
+ }
33
+
34
+ var css_248z = ".splDialog-module_dialog__content__t-Zwr:focus{outline:none}.splDialog-module_dialog__content__t-Zwr.splDialog-module_dialog__content__t-Zwr{font-family:var(--default-font-family);font-size:var(--font-size-2);font-weight:var(--font-weight-regular);line-height:var(--line-height-2)}.splDialog-module_dialog__title__hQwUq.splDialog-module_dialog__title__hQwUq{font-family:var(--default-font-family);font-size:var(--font-size-5);font-weight:var(--font-weight-bold);line-height:var(--heading-line-height-5);margin:0 0 var(--space-4)}.splDialog-module_dialog__description__akkml.splDialog-module_dialog__description__akkml{font-size:var(--font-size-2);line-height:var(--line-height-2);margin:0 0 var(--space-1)}.splDialog-module_dialog__header__4evfq .splDialog-module_dialog__title__hQwUq.splDialog-module_dialog__title__hQwUq{margin:0}.splDialog-module_dialog__header__4evfq{align-items:center;display:flex;gap:12px;margin-bottom:var(--space-3)}.splDialog-module_dialog__statusIcon__xY8Y4{display:inline-flex;margin:0 -2px;position:relative;top:-2px}.splDialog-module_dialog__statusIcon__xY8Y4 svg{height:20px;width:20px}.splDialog-module_dialog__statusIcon--destructive__gZagF{color:var(--spl-colors-error)}.splDialog-module_dialog__statusIcon--warning__53s2a{color:var(--spl-colors-warning)}.splDialog-module_dialog__body__AwXEL{margin-bottom:1rem}.splDialog-module_dialog__footer__nOkmx{display:flex;gap:.5rem;justify-content:flex-end;margin-top:1.5rem}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT{border-radius:100%;box-sizing:border-box;height:32px;margin:0;padding:0;position:absolute;right:8px;top:8px;width:32px}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT svg{height:20px;width:20px}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:active,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:focus,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:hover{background-color:transparent;color:var(--spl-colors-text-default)}.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:active,.splDialog-module_dialog__close__RyLWT.splDialog-module_dialog__close__RyLWT:hover{background-color:var(--spl-colors-bg-secondary)}.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT{align-items:center;border:none;border-radius:var(--radius-2);box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:var(--default-font-family);font-size:var(--font-size-2);font-weight:var(--font-weight-medium);gap:var(--space-2);height:var(--space-6);justify-content:center;line-height:var(--line-height-2);padding:0 var(--space-3)}.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG,.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG:focus{background-color:var(--spl-colors-button-bg-primary);color:var(--spl-colors-button-text-primary)}.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG:active,.splDialog-module_button--primary__n3DCG.splDialog-module_button--primary__n3DCG:hover{background-color:var(--spl-colors-button-bg-primary-hover-pressed);color:var(--spl-colors-button-text-primary-hover-pressed)}.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az,.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az:active,.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az:focus,.splDialog-module_button--destructive__Ig1Az.splDialog-module_button--destructive__Ig1Az:hover{background-color:var(--spl-colors-error);color:var(--spl-colors-base-white)}.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:focus{background-color:var(--spl-colors-button-bg-secondary);box-shadow:inset 0 0 0 1px var(--spl-colors-button-border-secondary);color:var(--spl-colors-button-text-secondary)}.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:active,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:hover{background-color:var(--spl-colors-button-bg-secondary-hover-pressed);box-shadow:inset 0 0 0 1px var(--spl-colors-button-border-secondary);color:var(--spl-colors-button-text-secondary)}.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled,.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled:active,.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled:focus,.splDialog-module_button__8fRnT.splDialog-module_button__8fRnT:disabled:hover{background-color:var(--spl-colors-button-bg-primary-disabled);box-shadow:none;color:var(--spl-colors-button-text-primary-disabled);cursor:not-allowed}.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled:active,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled:focus,.splDialog-module_button--secondary__heKg3.splDialog-module_button--secondary__heKg3:disabled:hover{background-color:var(--spl-colors-button-bg-secondary-disabled);box-shadow:inset 0 0 0 1px var(--spl-colors-button-border-secondary-disabled);color:var(--spl-colors-button-text-secondary-disabled)}";
35
+ var styles = {"dialog__content":"splDialog-module_dialog__content__t-Zwr","dialog__title":"splDialog-module_dialog__title__hQwUq","dialog__description":"splDialog-module_dialog__description__akkml","dialog__header":"splDialog-module_dialog__header__4evfq","dialog__statusIcon":"splDialog-module_dialog__statusIcon__xY8Y4","dialog__statusIcon--destructive":"splDialog-module_dialog__statusIcon--destructive__gZagF","dialog__statusIcon--warning":"splDialog-module_dialog__statusIcon--warning__53s2a","dialog__body":"splDialog-module_dialog__body__AwXEL","dialog__footer":"splDialog-module_dialog__footer__nOkmx","dialog__close":"splDialog-module_dialog__close__RyLWT","button":"splDialog-module_button__8fRnT","button--primary":"splDialog-module_button--primary__n3DCG","button--destructive":"splDialog-module_button--destructive__Ig1Az","button--secondary":"splDialog-module_button--secondary__heKg3"};
36
+ styleInject(css_248z);
37
+
38
+ /**
39
+ * Footer buttons shared by SplDialog and SplAlertDialog.
40
+ * Button ids are `{dialogId}-secondary-btn`, `-tertiary-btn` and `-primary-btn`.
41
+ */
42
+ const SplDialogFooter = ({ dialogId, secondaryLabel, primaryLabel, primaryLoadingLabel, isPrimaryLoading = false, onPrimaryAction, onSecondaryAction, isPrimaryDisabled = false, isSecondaryDisabled = false, primaryVariant = 'default', tertiaryLabel, onTertiaryAction, isTertiaryDisabled = false, wrapSecondary = (button) => button, }) => {
43
+ const [isPending, setIsPending] = useState(false);
44
+ const isMounted = useRef(true);
45
+ useEffect(() => {
46
+ isMounted.current = true;
47
+ return () => { isMounted.current = false; };
48
+ }, []);
49
+ // Cancel is the default secondary label next to a primary button; a close-only footer must opt in via secondaryLabel.
50
+ const secondaryText = secondaryLabel ?? (primaryLabel ? 'Cancel' : undefined);
51
+ if (!primaryLabel && !secondaryText)
52
+ return null;
53
+ const isLoading = isPending || isPrimaryLoading;
54
+ const handlePrimary = async () => {
55
+ setIsPending(true);
56
+ try {
57
+ await onPrimaryAction?.();
58
+ }
59
+ catch {
60
+ // Callers own error handling (e.g. the error store); a rejection only needs to end the loading state.
61
+ }
62
+ finally {
63
+ if (isMounted.current)
64
+ setIsPending(false);
65
+ }
66
+ };
67
+ const secondaryButton = (React.createElement(Button, { type: "button", variant: "outline", className: `${styles.button} ${styles['button--secondary']}`, id: `${dialogId}-secondary-btn`, disabled: isSecondaryDisabled, onClick: onSecondaryAction }, secondaryText));
68
+ return (React.createElement("div", { className: styles.dialog__footer },
69
+ secondaryText && wrapSecondary(secondaryButton),
70
+ tertiaryLabel && onTertiaryAction && (React.createElement(Button, { type: "button", variant: "outline", className: `${styles.button} ${styles['button--secondary']}`, id: `${dialogId}-tertiary-btn`, disabled: isLoading || isTertiaryDisabled, onClick: () => void onTertiaryAction() }, tertiaryLabel)),
71
+ primaryLabel && (React.createElement(Button, { type: "button", id: `${dialogId}-primary-btn`, className: `${styles.button} ${primaryVariant === 'destructive' ? styles['button--destructive'] : styles['button--primary']}`, ...(primaryVariant === 'destructive' ? { color: 'red' } : {}), disabled: isLoading || isPrimaryDisabled, "aria-busy": isLoading, onClick: () => void handlePrimary() },
72
+ isLoading && React.createElement(Spinner, { size: "1" }),
73
+ isLoading && primaryLoadingLabel ? primaryLoadingLabel : primaryLabel))));
74
+ };
75
+
76
+ /**
77
+ * General purpose modal built on Radix Dialog, replacing VaModalWrapper for content and form dialogs.
78
+ * Use SplAlertDialog instead for confirmations that must be answered.
79
+ */
80
+ const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled = false, hasCloseButton = true, contentClassName, size = '3', maxWidth = '544px', onSecondaryAction, ...actions }) => {
81
+ const preventIfDisabled = (event) => {
82
+ if (isDismissDisabled)
83
+ event.preventDefault();
84
+ };
85
+ return (React.createElement(Dialog.Root, { open: isOpen, onOpenChange: onOpenChange },
86
+ React.createElement(Dialog.Content, { id: id, size: size, maxWidth: maxWidth, className: [styles.dialog__content, contentClassName].filter(Boolean).join(' '), onEscapeKeyDown: preventIfDisabled, onInteractOutside: preventIfDisabled, ...(description ? {} : { 'aria-describedby': undefined }) },
87
+ React.createElement(Dialog.Title, { className: styles.dialog__title }, title),
88
+ !isDismissDisabled && hasCloseButton && (React.createElement(Dialog.Close, null,
89
+ React.createElement(IconButton, { type: "button", id: `${id}-close-btn`, variant: "ghost", color: "gray", className: styles.dialog__close, "aria-label": "Close" },
90
+ React.createElement(Cross2Icon, { "aria-hidden": "true" })))),
91
+ description && (React.createElement(Dialog.Description, { className: styles.dialog__description }, description)),
92
+ React.createElement("div", { className: styles.dialog__body }, children),
93
+ footer ?? (React.createElement(SplDialogFooter, { dialogId: id,
94
+ // Cancel always closes the dialog, even when dismissal is disabled; onSecondaryAction is an extra hook, and actions can't override this handler.
95
+ onSecondaryAction: () => {
96
+ onSecondaryAction?.();
97
+ onOpenChange(false);
98
+ }, ...actions })))));
99
+ };
100
+
101
+ /**
102
+ * Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer
103
+ * (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking
104
+ * outside, has no X button, and focuses Cancel first so the safe choice is the default.
105
+ * Cancel closes it through `onOpenChange`. It does not auto-close on accept; the caller closes it
106
+ * through `isOpen` once the action succeeds.
107
+ */
108
+ const SplAlertDialog = ({ id, title, description, isOpen, onOpenChange, children, status, size = '3', maxWidth = '450px', ...actions }) => (React.createElement(AlertDialog.Root, { open: isOpen, onOpenChange: onOpenChange },
109
+ React.createElement(AlertDialog.Content, { id: id, size: size, maxWidth: maxWidth, className: styles.dialog__content },
110
+ React.createElement("div", { className: styles.dialog__header },
111
+ status && (React.createElement("span", { id: `${id}-status-icon`, "aria-hidden": "true", className: `${styles.dialog__statusIcon} ${styles[`dialog__statusIcon--${status}`]}` }, status === 'warning' ? React.createElement(ExclamationTriangleIcon, null) : React.createElement(TrashIcon, null))),
112
+ React.createElement(AlertDialog.Title, { className: styles.dialog__title }, title)),
113
+ React.createElement(AlertDialog.Description, { className: styles.dialog__description }, description),
114
+ children && React.createElement("div", { className: styles.dialog__body }, children),
115
+ React.createElement(SplDialogFooter, { dialogId: id, wrapSecondary: (button) => React.createElement(AlertDialog.Cancel, null, button), ...actions }))));
116
+
117
+ /**
118
+ * Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.
119
+ */
120
+ const SplDeleteAlertDialog = ({ id, itemName, itemNameId = `${id}-item-name`, primaryLabel = 'Delete', primaryLoadingLabel = 'Deleting...', secondaryLabel = 'Cancel', ...rest }) => (React.createElement(SplAlertDialog, { id: id, status: "destructive", primaryVariant: "destructive", primaryLabel: primaryLabel, primaryLoadingLabel: primaryLoadingLabel, secondaryLabel: secondaryLabel, description: React.createElement(React.Fragment, null,
121
+ "Please confirm deletion of: ",
122
+ React.createElement("strong", { id: itemNameId }, itemName)), ...rest }));
123
+
124
+ /**
125
+ * Warning confirmation (e.g. sensitive record access): SplAlertDialog with the amber warning icon
126
+ * and the standard primary button.
127
+ */
128
+ const SplWarningAlertDialog = ({ primaryLabel = 'Continue', secondaryLabel = 'Cancel', ...rest }) => (React.createElement(SplAlertDialog, { status: "warning", primaryLabel: primaryLabel, secondaryLabel: secondaryLabel, ...rest }));
5
129
 
6
130
  const DEFAULT_SPL_THEME = "light";
7
131
  const DARK_SCHEME_QUERY = "(prefers-color-scheme: dark)";
@@ -93,5 +217,5 @@ const SplThemeProvider = ({ children, preference: controlledPreference, defaultP
93
217
  React.createElement(Theme, { appearance: "inherit", grayColor: "slate", hasBackground: false }, children)));
94
218
  };
95
219
 
96
- export { SplThemeProvider, applyInitialSplTheme, applySplTheme, getSystemTheme, isSplThemePreference, resolveSplTheme, useSplTheme };
220
+ export { SplAlertDialog, SplDeleteAlertDialog, SplDialog, SplThemeProvider, SplWarningAlertDialog, applyInitialSplTheme, applySplTheme, getSystemTheme, isSplThemePreference, resolveSplTheme, useSplTheme };
97
221
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/theme/themeUtils.ts","../../src/components/spl-theme-provider/SplThemeProvider.tsx"],"sourcesContent":["export type SplTheme = \"light\" | \"dark\";\r\nexport type SplThemePreference = SplTheme | \"system\";\r\n\r\nexport const DEFAULT_SPL_THEME: SplTheme = \"light\";\r\nexport const DARK_SCHEME_QUERY = \"(prefers-color-scheme: dark)\";\r\n\r\nexport function isSplThemePreference(value: unknown): value is SplThemePreference {\r\n return value === \"light\" || value === \"dark\" || value === \"system\";\r\n}\r\n\r\nexport function themeFromMatches(matches: boolean): SplTheme {\r\n return matches ? \"dark\" : \"light\";\r\n}\r\n\r\n/** OS/browser color scheme, falling back to light when matchMedia is unavailable. */\r\nexport function getSystemTheme(): SplTheme {\r\n try {\r\n return themeFromMatches(Boolean(window.matchMedia?.(DARK_SCHEME_QUERY)?.matches));\r\n } catch {\r\n return DEFAULT_SPL_THEME;\r\n }\r\n}\r\n\r\nexport function resolveSplTheme(preference: SplThemePreference): SplTheme {\r\n return preference === \"system\" ? getSystemTheme() : preference;\r\n}\r\n\r\n/**\r\n * Applies a theme to the root element: [data-theme] for app styles and the `dark` class that\r\n * @va-scheduling/design-tokens and the Radix dark scales key off of. `color-scheme` is not set.\r\n */\r\nexport function applySplTheme(theme: SplTheme, root: HTMLElement = document.documentElement) {\r\n const safeTheme: SplTheme = theme === \"dark\" ? \"dark\" : DEFAULT_SPL_THEME;\r\n root.setAttribute(\"data-theme\", safeTheme);\r\n root.classList.toggle(\"dark\", safeTheme === \"dark\");\r\n}\r\n\r\n/**\r\n * Applies the stored theme before React renders, to avoid a flash. The app supplies how to read its\r\n * stored preference, since storage differs between apps.\r\n */\r\nexport function applyInitialSplTheme(\r\n readPreference: () => SplThemePreference | undefined = () => undefined,\r\n) {\r\n let preference: SplThemePreference | undefined;\r\n try {\r\n preference = readPreference();\r\n } catch {\r\n preference = undefined;\r\n }\r\n applySplTheme(resolveSplTheme(isSplThemePreference(preference) ? preference : DEFAULT_SPL_THEME));\r\n}\r\n","import React, {\r\n createContext,\r\n useContext,\r\n useEffect,\r\n useLayoutEffect,\r\n useMemo,\r\n useState,\r\n} from \"react\";\r\nimport { Theme } from \"@radix-ui/themes\";\r\nimport {\r\n applySplTheme,\r\n DARK_SCHEME_QUERY,\r\n DEFAULT_SPL_THEME,\r\n getSystemTheme,\r\n SplTheme,\r\n SplThemePreference,\r\n themeFromMatches,\r\n} from \"../../theme/themeUtils\";\r\n\r\nexport interface SplThemeContextValue {\r\n /** The stored preference: 'light', 'dark', or 'system' (follow the OS/browser). */\r\n preference: SplThemePreference;\r\n /** The theme currently applied to the root element. */\r\n theme: SplTheme;\r\n setPreference: (preference: SplThemePreference) => void;\r\n}\r\n\r\nexport interface SplThemeProviderProps {\r\n children?: React.ReactNode;\r\n /** Controlled preference. When set, the app owns storage and must update it in onPreferenceChange. */\r\n preference?: SplThemePreference;\r\n /** Initial preference when uncontrolled. Defaults to light. */\r\n defaultPreference?: SplThemePreference;\r\n onPreferenceChange?: (preference: SplThemePreference) => void;\r\n}\r\n\r\nconst SplThemeContext = createContext<SplThemeContextValue | undefined>(undefined);\r\n\r\nexport function useSplTheme(): SplThemeContextValue {\r\n const context = useContext(SplThemeContext);\r\n if (context === undefined) {\r\n throw new Error(\"useSplTheme must be used within SplThemeProvider\");\r\n }\r\n return context;\r\n}\r\n\r\n/**\r\n * Applies the light/dark theme to the root element and wraps children in a Radix <Theme>\r\n * (appearance=\"inherit\" follows the .dark class; grayColor=\"slate\" matches the design-tokens base scale).\r\n * The OS/browser scheme is only followed, with live updates, when the preference is 'system'.\r\n */\r\nconst SplThemeProvider = ({\r\n children,\r\n preference: controlledPreference,\r\n defaultPreference = DEFAULT_SPL_THEME,\r\n onPreferenceChange,\r\n}: SplThemeProviderProps) => {\r\n const [internalPreference, setInternalPreference] = useState<SplThemePreference>(defaultPreference);\r\n const preference = controlledPreference ?? internalPreference;\r\n const [systemTheme, setSystemTheme] = useState<SplTheme>(getSystemTheme);\r\n\r\n useEffect(() => {\r\n if (preference !== \"system\" || typeof window.matchMedia !== \"function\") {\r\n return undefined;\r\n }\r\n\r\n const mediaQuery = window.matchMedia(DARK_SCHEME_QUERY);\r\n const handleChange = () => setSystemTheme(getSystemTheme());\r\n\r\n // systemTheme goes stale while an explicit preference is set (no listener), so resync here\r\n setSystemTheme(themeFromMatches(mediaQuery.matches));\r\n mediaQuery.addEventListener?.(\"change\", handleChange);\r\n return () => mediaQuery.removeEventListener?.(\"change\", handleChange);\r\n }, [preference]);\r\n\r\n const theme: SplTheme = preference === \"system\" ? systemTheme : preference;\r\n\r\n useLayoutEffect(() => {\r\n applySplTheme(theme);\r\n }, [theme]);\r\n\r\n const value = useMemo<SplThemeContextValue>(\r\n () => ({\r\n preference,\r\n theme,\r\n setPreference: (next: SplThemePreference) => {\r\n if (controlledPreference === undefined) {\r\n setInternalPreference(next);\r\n }\r\n onPreferenceChange?.(next);\r\n },\r\n }),\r\n [preference, theme, controlledPreference, onPreferenceChange],\r\n );\r\n\r\n return (\r\n <SplThemeContext.Provider value={value}>\r\n <Theme appearance=\"inherit\" grayColor=\"slate\" hasBackground={false}>\r\n {children}\r\n </Theme>\r\n </SplThemeContext.Provider>\r\n );\r\n};\r\n\r\nexport default SplThemeProvider;\r\n"],"names":[],"mappings":";;;;;AAGO,MAAM,iBAAiB,GAAa,OAAO;AAC3C,MAAM,iBAAiB,GAAG,8BAA8B;AAEzD,SAAU,oBAAoB,CAAC,KAAc,EAAA;IACjD,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ;AACpE;AAEM,SAAU,gBAAgB,CAAC,OAAgB,EAAA;IAC/C,OAAO,OAAO,GAAG,MAAM,GAAG,OAA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KACF,CAAC,EACF,CAAC,UAAU,EAAE,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,CAAC,CAC9D;IAED,QACE,oBAAC,eAAe,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA;AACpC,QAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,UAAU,EAAC,SAAS,EAAC,SAAS,EAAC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAA,EAC/D,QAAQ,CACH,CACiB;AAE/B;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../node_modules/style-inject/dist/style-inject.es.js","../../src/components/spl-dialog/SplDialogFooter.tsx","../../src/components/spl-dialog/SplDialog.tsx","../../src/components/spl-dialog/SplAlertDialog.tsx","../../src/components/spl-dialog/SplDeleteAlertDialog.tsx","../../src/components/spl-dialog/SplWarningAlertDialog.tsx","../../src/theme/themeUtils.ts","../../src/components/spl-theme-provider/SplThemeProvider.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import { Button, Spinner } from '@radix-ui/themes';\r\nimport React, { ReactNode, useEffect, useRef, useState } from 'react';\r\n\r\nimport styles from './splDialog.module.css';\r\n\r\nexport type SplDialogActionsProps = {\r\n /** Text for the cancel/close button. Defaults to \"Cancel\" when a primary button is shown. Provide it alone (e.g. \"Close\") for a close-only footer. */\r\n secondaryLabel?: string;\r\n /** Text for the accept button. */\r\n primaryLabel?: string;\r\n /** Text for the accept button while it is loading. */\r\n primaryLoadingLabel?: string;\r\n /** Forces the primary button into its loading state, for loading driven by a store or parent. Loading from `onPrimaryAction` promises is tracked automatically. */\r\n isPrimaryLoading?: boolean;\r\n /** Called on accept. If it returns a promise the primary button shows a loading state until it settles. */\r\n onPrimaryAction?: () => void | Promise<void>;\r\n /** Called on cancel. The dialog also closes through `onOpenChange`. */\r\n onSecondaryAction?: () => void;\r\n isPrimaryDisabled?: boolean;\r\n isSecondaryDisabled?: boolean;\r\n /** Visual treatment of the primary button. `destructive` is for deletions. */\r\n primaryVariant?: 'default' | 'destructive';\r\n /** Optional extra button between secondary and primary. */\r\n tertiaryLabel?: string;\r\n onTertiaryAction?: () => void | Promise<void>;\r\n isTertiaryDisabled?: boolean;\r\n};\r\n\r\ntype SplDialogFooterProps = SplDialogActionsProps & {\r\n dialogId: string;\r\n /** Wraps the secondary button so Radix primitives (e.g. AlertDialog.Cancel) can own it. */\r\n wrapSecondary?: (button: ReactNode) => ReactNode;\r\n};\r\n\r\n/**\r\n * Footer buttons shared by SplDialog and SplAlertDialog.\r\n * Button ids are `{dialogId}-secondary-btn`, `-tertiary-btn` and `-primary-btn`.\r\n */\r\nconst SplDialogFooter = ({\r\n dialogId,\r\n secondaryLabel,\r\n primaryLabel,\r\n primaryLoadingLabel,\r\n isPrimaryLoading = false,\r\n onPrimaryAction,\r\n onSecondaryAction,\r\n isPrimaryDisabled = false,\r\n isSecondaryDisabled = false,\r\n primaryVariant = 'default',\r\n tertiaryLabel,\r\n onTertiaryAction,\r\n isTertiaryDisabled = false,\r\n wrapSecondary = (button) => button,\r\n}: SplDialogFooterProps) => {\r\n const [isPending, setIsPending] = useState(false);\r\n const isMounted = useRef(true);\r\n\r\n useEffect(() => {\r\n isMounted.current = true;\r\n return () => { isMounted.current = false; };\r\n }, []);\r\n\r\n // Cancel is the default secondary label next to a primary button; a close-only footer must opt in via secondaryLabel.\r\n const secondaryText = secondaryLabel ?? (primaryLabel ? 'Cancel' : undefined);\r\n if (!primaryLabel && !secondaryText) return null;\r\n\r\n const isLoading = isPending || isPrimaryLoading;\r\n\r\n const handlePrimary = async () => {\r\n setIsPending(true);\r\n try {\r\n await onPrimaryAction?.();\r\n } catch {\r\n // Callers own error handling (e.g. the error store); a rejection only needs to end the loading state.\r\n } finally {\r\n if (isMounted.current) setIsPending(false);\r\n }\r\n };\r\n\r\n const secondaryButton = (\r\n <Button\r\n type=\"button\"\r\n variant=\"outline\"\r\n className={`${styles.button} ${styles['button--secondary']}`}\r\n id={`${dialogId}-secondary-btn`}\r\n disabled={isSecondaryDisabled}\r\n onClick={onSecondaryAction}\r\n >\r\n {secondaryText}\r\n </Button>\r\n );\r\n\r\n return (\r\n <div className={styles.dialog__footer}>\r\n {secondaryText && wrapSecondary(secondaryButton)}\r\n {tertiaryLabel && onTertiaryAction && (\r\n <Button\r\n type=\"button\"\r\n variant=\"outline\"\r\n className={`${styles.button} ${styles['button--secondary']}`}\r\n id={`${dialogId}-tertiary-btn`}\r\n disabled={isLoading || isTertiaryDisabled}\r\n onClick={() => void onTertiaryAction()}\r\n >\r\n {tertiaryLabel}\r\n </Button>\r\n )}\r\n {primaryLabel && (\r\n <Button\r\n type=\"button\"\r\n id={`${dialogId}-primary-btn`}\r\n className={`${styles.button} ${primaryVariant === 'destructive' ? styles['button--destructive'] : styles['button--primary']}`}\r\n {...(primaryVariant === 'destructive' ? { color: 'red' as const } : {})}\r\n disabled={isLoading || isPrimaryDisabled}\r\n aria-busy={isLoading}\r\n onClick={() => void handlePrimary()}\r\n >\r\n {/* Radix's `loading` prop hides the label; render the spinner beside it instead. */}\r\n {isLoading && <Spinner size=\"1\" />}\r\n {isLoading && primaryLoadingLabel ? primaryLoadingLabel : primaryLabel}\r\n </Button>\r\n )}\r\n </div>\r\n );\r\n};\r\n\r\nexport default SplDialogFooter;\r\n","import { Cross2Icon } from '@radix-ui/react-icons';\r\nimport { Dialog, IconButton } from '@radix-ui/themes';\r\nimport React, { ReactNode } from 'react';\r\n\r\nimport SplDialogFooter, { SplDialogActionsProps } from './SplDialogFooter';\r\nimport { SplDialogSizeProps } from './splDialogSize';\r\nimport styles from './splDialog.module.css';\r\n\r\nexport type SplDialogProps = SplDialogActionsProps & SplDialogSizeProps & {\r\n /** Unique id; the content element gets this id and footer buttons derive theirs from it. */\r\n id: string;\r\n title: string;\r\n /** Optional description announced by screen readers. */\r\n description?: string;\r\n isOpen: boolean;\r\n onOpenChange: (isOpen: boolean) => void;\r\n children: ReactNode;\r\n /** Replace the built-in footer entirely (e.g. for forms that own their buttons). */\r\n footer?: ReactNode;\r\n /** Prevent closing via Escape, overlay click, or the X button. */\r\n isDismissDisabled?: boolean;\r\n /** Show the X button in the corner. Defaults to true; Escape and overlay click still close the dialog when false. */\r\n hasCloseButton?: boolean;\r\n /** Extra class on the content panel, for width overrides. */\r\n contentClassName?: string;\r\n};\r\n\r\n/**\r\n * General purpose modal built on Radix Dialog, replacing VaModalWrapper for content and form dialogs.\r\n * Use SplAlertDialog instead for confirmations that must be answered.\r\n */\r\nconst SplDialog = ({\r\n id,\r\n title,\r\n description,\r\n isOpen,\r\n onOpenChange,\r\n children,\r\n footer,\r\n isDismissDisabled = false,\r\n hasCloseButton = true,\r\n contentClassName,\r\n size = '3',\r\n maxWidth = '544px',\r\n onSecondaryAction,\r\n ...actions\r\n}: SplDialogProps) => {\r\n const preventIfDisabled = (event: Event) => {\r\n if (isDismissDisabled) event.preventDefault();\r\n };\r\n\r\n return (\r\n <Dialog.Root open={isOpen} onOpenChange={onOpenChange}>\r\n <Dialog.Content\r\n id={id}\r\n size={size}\r\n maxWidth={maxWidth}\r\n className={[styles.dialog__content, contentClassName].filter(Boolean).join(' ')}\r\n onEscapeKeyDown={preventIfDisabled}\r\n onInteractOutside={preventIfDisabled}\r\n {...(description ? {} : { 'aria-describedby': undefined })}\r\n >\r\n <Dialog.Title className={styles.dialog__title}>{title}</Dialog.Title>\r\n {!isDismissDisabled && hasCloseButton && (\r\n <Dialog.Close>\r\n <IconButton\r\n type=\"button\"\r\n id={`${id}-close-btn`}\r\n variant=\"ghost\"\r\n color=\"gray\"\r\n className={styles.dialog__close}\r\n aria-label=\"Close\"\r\n >\r\n <Cross2Icon aria-hidden=\"true\" />\r\n </IconButton>\r\n </Dialog.Close>\r\n )}\r\n {description && (\r\n <Dialog.Description className={styles.dialog__description}>{description}</Dialog.Description>\r\n )}\r\n <div className={styles.dialog__body}>{children}</div>\r\n {footer ?? (\r\n <SplDialogFooter\r\n dialogId={id}\r\n // Cancel always closes the dialog, even when dismissal is disabled; onSecondaryAction is an extra hook, and actions can't override this handler.\r\n onSecondaryAction={() => {\r\n onSecondaryAction?.();\r\n onOpenChange(false);\r\n }}\r\n {...actions}\r\n />\r\n )}\r\n </Dialog.Content>\r\n </Dialog.Root>\r\n );\r\n};\r\n\r\nexport default SplDialog;\r\n","import { ExclamationTriangleIcon, TrashIcon } from '@radix-ui/react-icons';\r\nimport { AlertDialog } from '@radix-ui/themes';\r\nimport React, { ReactNode } from 'react';\r\n\r\nimport SplDialogFooter, { SplDialogActionsProps } from './SplDialogFooter';\r\nimport { SplDialogSizeProps } from './splDialogSize';\r\nimport styles from './splDialog.module.css';\r\n\r\nexport type SplAlertDialogProps = Omit<SplDialogActionsProps, 'primaryLabel'> & SplDialogSizeProps & {\r\n /** Unique id; the content element gets this id and footer buttons derive theirs from it. */\r\n id: string;\r\n title: string;\r\n /** Required: alert dialogs must tell the user what they are confirming. May include inline markup. */\r\n description: ReactNode;\r\n isOpen: boolean;\r\n onOpenChange: (isOpen: boolean) => void;\r\n /** Required: an alert dialog always has an accept action. */\r\n primaryLabel: string;\r\n /** Optional extra content below the description (e.g. an error alert). */\r\n children?: ReactNode;\r\n /** Shows a leading icon before the title: a red trash can for 'destructive', an amber triangle for 'warning'. */\r\n status?: 'destructive' | 'warning';\r\n};\r\n\r\n/**\r\n * Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer\r\n * (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking\r\n * outside, has no X button, and focuses Cancel first so the safe choice is the default.\r\n * Cancel closes it through `onOpenChange`. It does not auto-close on accept; the caller closes it\r\n * through `isOpen` once the action succeeds.\r\n */\r\nconst SplAlertDialog = ({\r\n id,\r\n title,\r\n description,\r\n isOpen,\r\n onOpenChange,\r\n children,\r\n status,\r\n size = '3',\r\n maxWidth = '450px',\r\n ...actions\r\n}: SplAlertDialogProps) => (\r\n <AlertDialog.Root open={isOpen} onOpenChange={onOpenChange}>\r\n <AlertDialog.Content\r\n id={id}\r\n size={size}\r\n maxWidth={maxWidth}\r\n className={styles.dialog__content}\r\n >\r\n <div className={styles.dialog__header}>\r\n {status && (\r\n <span\r\n id={`${id}-status-icon`}\r\n aria-hidden=\"true\"\r\n className={`${styles.dialog__statusIcon} ${styles[`dialog__statusIcon--${status}`]}`}\r\n >\r\n {status === 'warning' ? <ExclamationTriangleIcon /> : <TrashIcon />}\r\n </span>\r\n )}\r\n <AlertDialog.Title className={styles.dialog__title}>{title}</AlertDialog.Title>\r\n </div>\r\n <AlertDialog.Description className={styles.dialog__description}>\r\n {description}\r\n </AlertDialog.Description>\r\n {children && <div className={styles.dialog__body}>{children}</div>}\r\n <SplDialogFooter\r\n dialogId={id}\r\n wrapSecondary={(button) => <AlertDialog.Cancel>{button}</AlertDialog.Cancel>}\r\n {...actions}\r\n />\r\n </AlertDialog.Content>\r\n </AlertDialog.Root>\r\n);\r\n\r\nexport default SplAlertDialog;\r\n","import React from 'react';\r\n\r\nimport SplAlertDialog, { SplAlertDialogProps } from './SplAlertDialog';\r\n\r\nexport type SplDeleteAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'description' | 'primaryLabel'> & {\r\n /** Name of the item being deleted, shown in bold after \"Please confirm deletion of:\". */\r\n itemName: string;\r\n /** Id for the bold item name element. Defaults to `{id}-item-name`. */\r\n itemNameId?: string;\r\n /** Defaults to \"Delete\". */\r\n primaryLabel?: string;\r\n};\r\n\r\n/**\r\n * Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.\r\n */\r\nconst SplDeleteAlertDialog = ({\r\n id,\r\n itemName,\r\n itemNameId = `${id}-item-name`,\r\n primaryLabel = 'Delete',\r\n primaryLoadingLabel = 'Deleting...',\r\n secondaryLabel = 'Cancel',\r\n ...rest\r\n}: SplDeleteAlertDialogProps) => (\r\n <SplAlertDialog\r\n id={id}\r\n status=\"destructive\"\r\n primaryVariant=\"destructive\"\r\n primaryLabel={primaryLabel}\r\n primaryLoadingLabel={primaryLoadingLabel}\r\n secondaryLabel={secondaryLabel}\r\n description={\r\n <>\r\n Please confirm deletion of: <strong id={itemNameId}>{itemName}</strong>\r\n </>\r\n }\r\n {...rest}\r\n />\r\n);\r\n\r\nexport default SplDeleteAlertDialog;\r\n","import React from 'react';\r\n\r\nimport SplAlertDialog, { SplAlertDialogProps } from './SplAlertDialog';\r\n\r\nexport type SplWarningAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'primaryLabel'> & {\r\n /** Defaults to \"Continue\". */\r\n primaryLabel?: string;\r\n};\r\n\r\n/**\r\n * Warning confirmation (e.g. sensitive record access): SplAlertDialog with the amber warning icon\r\n * and the standard primary button.\r\n */\r\nconst SplWarningAlertDialog = ({\r\n primaryLabel = 'Continue',\r\n secondaryLabel = 'Cancel',\r\n ...rest\r\n}: SplWarningAlertDialogProps) => (\r\n <SplAlertDialog status=\"warning\" primaryLabel={primaryLabel} secondaryLabel={secondaryLabel} {...rest} />\r\n);\r\n\r\nexport default SplWarningAlertDialog;\r\n","export type SplTheme = \"light\" | \"dark\";\r\nexport type SplThemePreference = SplTheme | \"system\";\r\n\r\nexport const DEFAULT_SPL_THEME: SplTheme = \"light\";\r\nexport const DARK_SCHEME_QUERY = \"(prefers-color-scheme: dark)\";\r\n\r\nexport function isSplThemePreference(value: unknown): value is SplThemePreference {\r\n return value === \"light\" || value === \"dark\" || value === \"system\";\r\n}\r\n\r\nexport function themeFromMatches(matches: boolean): SplTheme {\r\n return matches ? \"dark\" : \"light\";\r\n}\r\n\r\n/** OS/browser color scheme, falling back to light when matchMedia is unavailable. */\r\nexport function getSystemTheme(): SplTheme {\r\n try {\r\n return themeFromMatches(Boolean(window.matchMedia?.(DARK_SCHEME_QUERY)?.matches));\r\n } catch {\r\n return DEFAULT_SPL_THEME;\r\n }\r\n}\r\n\r\nexport function resolveSplTheme(preference: SplThemePreference): SplTheme {\r\n return preference === \"system\" ? getSystemTheme() : preference;\r\n}\r\n\r\n/**\r\n * Applies a theme to the root element: [data-theme] for app styles and the `dark` class that\r\n * @va-scheduling/design-tokens and the Radix dark scales key off of. `color-scheme` is not set.\r\n */\r\nexport function applySplTheme(theme: SplTheme, root: HTMLElement = document.documentElement) {\r\n const safeTheme: SplTheme = theme === \"dark\" ? \"dark\" : DEFAULT_SPL_THEME;\r\n root.setAttribute(\"data-theme\", safeTheme);\r\n root.classList.toggle(\"dark\", safeTheme === \"dark\");\r\n}\r\n\r\n/**\r\n * Applies the stored theme before React renders, to avoid a flash. The app supplies how to read its\r\n * stored preference, since storage differs between apps.\r\n */\r\nexport function applyInitialSplTheme(\r\n readPreference: () => SplThemePreference | undefined = () => undefined,\r\n) {\r\n let preference: SplThemePreference | undefined;\r\n try {\r\n preference = readPreference();\r\n } catch {\r\n preference = undefined;\r\n }\r\n applySplTheme(resolveSplTheme(isSplThemePreference(preference) ? preference : DEFAULT_SPL_THEME));\r\n}\r\n","import React, {\r\n createContext,\r\n useContext,\r\n useEffect,\r\n useLayoutEffect,\r\n useMemo,\r\n useState,\r\n} from \"react\";\r\nimport { Theme } from \"@radix-ui/themes\";\r\nimport {\r\n applySplTheme,\r\n DARK_SCHEME_QUERY,\r\n DEFAULT_SPL_THEME,\r\n getSystemTheme,\r\n SplTheme,\r\n SplThemePreference,\r\n themeFromMatches,\r\n} from \"../../theme/themeUtils\";\r\n\r\nexport interface SplThemeContextValue {\r\n /** The stored preference: 'light', 'dark', or 'system' (follow the OS/browser). */\r\n preference: SplThemePreference;\r\n /** The theme currently applied to the root element. */\r\n theme: SplTheme;\r\n setPreference: (preference: SplThemePreference) => void;\r\n}\r\n\r\nexport interface SplThemeProviderProps {\r\n children?: React.ReactNode;\r\n /** Controlled preference. When set, the app owns storage and must update it in onPreferenceChange. */\r\n preference?: SplThemePreference;\r\n /** Initial preference when uncontrolled. Defaults to light. */\r\n defaultPreference?: SplThemePreference;\r\n onPreferenceChange?: (preference: SplThemePreference) => void;\r\n}\r\n\r\nconst SplThemeContext = createContext<SplThemeContextValue | undefined>(undefined);\r\n\r\nexport function useSplTheme(): SplThemeContextValue {\r\n const context = useContext(SplThemeContext);\r\n if (context === undefined) {\r\n throw new Error(\"useSplTheme must be used within SplThemeProvider\");\r\n }\r\n return context;\r\n}\r\n\r\n/**\r\n * Applies the light/dark theme to the root element and wraps children in a Radix <Theme>\r\n * (appearance=\"inherit\" follows the .dark class; grayColor=\"slate\" matches the design-tokens base scale).\r\n * The OS/browser scheme is only followed, with live updates, when the preference is 'system'.\r\n */\r\nconst SplThemeProvider = ({\r\n children,\r\n preference: controlledPreference,\r\n defaultPreference = DEFAULT_SPL_THEME,\r\n onPreferenceChange,\r\n}: SplThemeProviderProps) => {\r\n const [internalPreference, setInternalPreference] = useState<SplThemePreference>(defaultPreference);\r\n const preference = controlledPreference ?? internalPreference;\r\n const [systemTheme, setSystemTheme] = useState<SplTheme>(getSystemTheme);\r\n\r\n useEffect(() => {\r\n if (preference !== \"system\" || typeof window.matchMedia !== \"function\") {\r\n return undefined;\r\n }\r\n\r\n const mediaQuery = window.matchMedia(DARK_SCHEME_QUERY);\r\n const handleChange = () => setSystemTheme(getSystemTheme());\r\n\r\n // systemTheme goes stale while an explicit preference is set (no listener), so resync here\r\n setSystemTheme(themeFromMatches(mediaQuery.matches));\r\n mediaQuery.addEventListener?.(\"change\", handleChange);\r\n return () => mediaQuery.removeEventListener?.(\"change\", handleChange);\r\n }, [preference]);\r\n\r\n const theme: SplTheme = preference === \"system\" ? systemTheme : preference;\r\n\r\n useLayoutEffect(() => {\r\n applySplTheme(theme);\r\n }, [theme]);\r\n\r\n const value = useMemo<SplThemeContextValue>(\r\n () => ({\r\n preference,\r\n theme,\r\n setPreference: (next: SplThemePreference) => {\r\n if (controlledPreference === undefined) {\r\n setInternalPreference(next);\r\n }\r\n onPreferenceChange?.(next);\r\n },\r\n }),\r\n [preference, theme, controlledPreference, onPreferenceChange],\r\n );\r\n\r\n return (\r\n <SplThemeContext.Provider value={value}>\r\n <Theme appearance=\"inherit\" grayColor=\"slate\" hasBackground={false}>\r\n {children}\r\n </Theme>\r\n </SplThemeContext.Provider>\r\n );\r\n};\r\n\r\nexport default SplThemeProvider;\r\n"],"names":[],"mappings":";;;;;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,CAAC;;AAEzD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;AAC/C,IAAI,CAAC,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC7B,IAAI;AACJ,EAAE,CAAC,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC3B,EAAE;;AAEF,EAAE,IAAI,KAAK,CAA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B,CAAC,CAC9D;IAED,QACE,oBAAC,eAAe,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA;AACpC,QAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,UAAU,EAAC,SAAS,EAAC,SAAS,EAAC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAA,EAC/D,QAAQ,CACH,CACiB;AAE/B;;","x_google_ignoreList":[0]}
@@ -1,2 +1,4 @@
1
+ export { SplDialog, SplAlertDialog, SplDeleteAlertDialog, SplWarningAlertDialog, } from "./spl-dialog";
2
+ export type { SplDialogProps, SplAlertDialogProps, SplDeleteAlertDialogProps, SplWarningAlertDialogProps, SplDialogActionsProps, SplDialogSize, SplDialogSizeProps, } from "./spl-dialog";
1
3
  export { default as SplThemeProvider, useSplTheme } from "./spl-theme-provider";
2
4
  export type { SplThemeProviderProps, SplThemeContextValue } from "./spl-theme-provider";
@@ -0,0 +1,27 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { SplDialogActionsProps } from './SplDialogFooter';
3
+ import { SplDialogSizeProps } from './splDialogSize';
4
+ export type SplAlertDialogProps = Omit<SplDialogActionsProps, 'primaryLabel'> & SplDialogSizeProps & {
5
+ /** Unique id; the content element gets this id and footer buttons derive theirs from it. */
6
+ id: string;
7
+ title: string;
8
+ /** Required: alert dialogs must tell the user what they are confirming. May include inline markup. */
9
+ description: ReactNode;
10
+ isOpen: boolean;
11
+ onOpenChange: (isOpen: boolean) => void;
12
+ /** Required: an alert dialog always has an accept action. */
13
+ primaryLabel: string;
14
+ /** Optional extra content below the description (e.g. an error alert). */
15
+ children?: ReactNode;
16
+ /** Shows a leading icon before the title: a red trash can for 'destructive', an amber triangle for 'warning'. */
17
+ status?: 'destructive' | 'warning';
18
+ };
19
+ /**
20
+ * Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer
21
+ * (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking
22
+ * outside, has no X button, and focuses Cancel first so the safe choice is the default.
23
+ * Cancel closes it through `onOpenChange`. It does not auto-close on accept; the caller closes it
24
+ * through `isOpen` once the action succeeds.
25
+ */
26
+ declare const SplAlertDialog: ({ id, title, description, isOpen, onOpenChange, children, status, size, maxWidth, ...actions }: SplAlertDialogProps) => React.JSX.Element;
27
+ export default SplAlertDialog;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { SplAlertDialogProps } from './SplAlertDialog';
3
+ export type SplDeleteAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'description' | 'primaryLabel'> & {
4
+ /** Name of the item being deleted, shown in bold after "Please confirm deletion of:". */
5
+ itemName: string;
6
+ /** Id for the bold item name element. Defaults to `{id}-item-name`. */
7
+ itemNameId?: string;
8
+ /** Defaults to "Delete". */
9
+ primaryLabel?: string;
10
+ };
11
+ /**
12
+ * Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.
13
+ */
14
+ declare const SplDeleteAlertDialog: ({ id, itemName, itemNameId, primaryLabel, primaryLoadingLabel, secondaryLabel, ...rest }: SplDeleteAlertDialogProps) => React.JSX.Element;
15
+ export default SplDeleteAlertDialog;
@@ -0,0 +1,27 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { SplDialogActionsProps } from './SplDialogFooter';
3
+ import { SplDialogSizeProps } from './splDialogSize';
4
+ export type SplDialogProps = SplDialogActionsProps & SplDialogSizeProps & {
5
+ /** Unique id; the content element gets this id and footer buttons derive theirs from it. */
6
+ id: string;
7
+ title: string;
8
+ /** Optional description announced by screen readers. */
9
+ description?: string;
10
+ isOpen: boolean;
11
+ onOpenChange: (isOpen: boolean) => void;
12
+ children: ReactNode;
13
+ /** Replace the built-in footer entirely (e.g. for forms that own their buttons). */
14
+ footer?: ReactNode;
15
+ /** Prevent closing via Escape, overlay click, or the X button. */
16
+ isDismissDisabled?: boolean;
17
+ /** Show the X button in the corner. Defaults to true; Escape and overlay click still close the dialog when false. */
18
+ hasCloseButton?: boolean;
19
+ /** Extra class on the content panel, for width overrides. */
20
+ contentClassName?: string;
21
+ };
22
+ /**
23
+ * General purpose modal built on Radix Dialog, replacing VaModalWrapper for content and form dialogs.
24
+ * Use SplAlertDialog instead for confirmations that must be answered.
25
+ */
26
+ declare const SplDialog: ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled, hasCloseButton, contentClassName, size, maxWidth, onSecondaryAction, ...actions }: SplDialogProps) => React.JSX.Element;
27
+ export default SplDialog;
@@ -0,0 +1,34 @@
1
+ import React, { ReactNode } from 'react';
2
+ export type SplDialogActionsProps = {
3
+ /** Text for the cancel/close button. Defaults to "Cancel" when a primary button is shown. Provide it alone (e.g. "Close") for a close-only footer. */
4
+ secondaryLabel?: string;
5
+ /** Text for the accept button. */
6
+ primaryLabel?: string;
7
+ /** Text for the accept button while it is loading. */
8
+ primaryLoadingLabel?: string;
9
+ /** Forces the primary button into its loading state, for loading driven by a store or parent. Loading from `onPrimaryAction` promises is tracked automatically. */
10
+ isPrimaryLoading?: boolean;
11
+ /** Called on accept. If it returns a promise the primary button shows a loading state until it settles. */
12
+ onPrimaryAction?: () => void | Promise<void>;
13
+ /** Called on cancel. The dialog also closes through `onOpenChange`. */
14
+ onSecondaryAction?: () => void;
15
+ isPrimaryDisabled?: boolean;
16
+ isSecondaryDisabled?: boolean;
17
+ /** Visual treatment of the primary button. `destructive` is for deletions. */
18
+ primaryVariant?: 'default' | 'destructive';
19
+ /** Optional extra button between secondary and primary. */
20
+ tertiaryLabel?: string;
21
+ onTertiaryAction?: () => void | Promise<void>;
22
+ isTertiaryDisabled?: boolean;
23
+ };
24
+ type SplDialogFooterProps = SplDialogActionsProps & {
25
+ dialogId: string;
26
+ /** Wraps the secondary button so Radix primitives (e.g. AlertDialog.Cancel) can own it. */
27
+ wrapSecondary?: (button: ReactNode) => ReactNode;
28
+ };
29
+ /**
30
+ * Footer buttons shared by SplDialog and SplAlertDialog.
31
+ * Button ids are `{dialogId}-secondary-btn`, `-tertiary-btn` and `-primary-btn`.
32
+ */
33
+ declare const SplDialogFooter: ({ dialogId, secondaryLabel, primaryLabel, primaryLoadingLabel, isPrimaryLoading, onPrimaryAction, onSecondaryAction, isPrimaryDisabled, isSecondaryDisabled, primaryVariant, tertiaryLabel, onTertiaryAction, isTertiaryDisabled, wrapSecondary, }: SplDialogFooterProps) => React.JSX.Element | null;
34
+ export default SplDialogFooter;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { SplAlertDialogProps } from './SplAlertDialog';
3
+ export type SplWarningAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'primaryLabel'> & {
4
+ /** Defaults to "Continue". */
5
+ primaryLabel?: string;
6
+ };
7
+ /**
8
+ * Warning confirmation (e.g. sensitive record access): SplAlertDialog with the amber warning icon
9
+ * and the standard primary button.
10
+ */
11
+ declare const SplWarningAlertDialog: ({ primaryLabel, secondaryLabel, ...rest }: SplWarningAlertDialogProps) => React.JSX.Element;
12
+ export default SplWarningAlertDialog;
@@ -0,0 +1,10 @@
1
+ export { default as SplDialog } from "./SplDialog";
2
+ export type { SplDialogProps } from "./SplDialog";
3
+ export { default as SplAlertDialog } from "./SplAlertDialog";
4
+ export type { SplAlertDialogProps } from "./SplAlertDialog";
5
+ export { default as SplDeleteAlertDialog } from "./SplDeleteAlertDialog";
6
+ export type { SplDeleteAlertDialogProps } from "./SplDeleteAlertDialog";
7
+ export { default as SplWarningAlertDialog } from "./SplWarningAlertDialog";
8
+ export type { SplWarningAlertDialogProps } from "./SplWarningAlertDialog";
9
+ export type { SplDialogActionsProps } from "./SplDialogFooter";
10
+ export type { SplDialogSize, SplDialogSizeProps } from "./splDialogSize";
@@ -0,0 +1,4 @@
1
+ type ModalButtonKind = 'primary' | 'secondary' | 'tertiary';
2
+ /** Id for a dialog footer button, e.g. `delete-clinic-list-container-primary-btn`. */
3
+ export declare const getModalButtonId: (modalId: string, kind: ModalButtonKind) => string;
4
+ export {};
@@ -0,0 +1,8 @@
1
+ /** Same size scale as Radix Themes dialogs: 1 = 12px padding, 2 = 16px, 3 = 24px (default), 4 = 32px. */
2
+ export type SplDialogSize = '1' | '2' | '3' | '4';
3
+ export type SplDialogSizeProps = {
4
+ /** Padding and corner radius preset, applied by Radix Themes. Defaults to '3'. */
5
+ size?: SplDialogSize;
6
+ /** Maximum width as any CSS length (e.g. `'450px'`, `'50rem'`). Defaults to 544px (450px for alert dialogs). */
7
+ maxWidth?: string;
8
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,107 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
+
3
+ type SplDialogActionsProps = {
4
+ /** Text for the cancel/close button. Defaults to "Cancel" when a primary button is shown. Provide it alone (e.g. "Close") for a close-only footer. */
5
+ secondaryLabel?: string;
6
+ /** Text for the accept button. */
7
+ primaryLabel?: string;
8
+ /** Text for the accept button while it is loading. */
9
+ primaryLoadingLabel?: string;
10
+ /** Forces the primary button into its loading state, for loading driven by a store or parent. Loading from `onPrimaryAction` promises is tracked automatically. */
11
+ isPrimaryLoading?: boolean;
12
+ /** Called on accept. If it returns a promise the primary button shows a loading state until it settles. */
13
+ onPrimaryAction?: () => void | Promise<void>;
14
+ /** Called on cancel. The dialog also closes through `onOpenChange`. */
15
+ onSecondaryAction?: () => void;
16
+ isPrimaryDisabled?: boolean;
17
+ isSecondaryDisabled?: boolean;
18
+ /** Visual treatment of the primary button. `destructive` is for deletions. */
19
+ primaryVariant?: 'default' | 'destructive';
20
+ /** Optional extra button between secondary and primary. */
21
+ tertiaryLabel?: string;
22
+ onTertiaryAction?: () => void | Promise<void>;
23
+ isTertiaryDisabled?: boolean;
24
+ };
25
+
26
+ /** Same size scale as Radix Themes dialogs: 1 = 12px padding, 2 = 16px, 3 = 24px (default), 4 = 32px. */
27
+ type SplDialogSize = '1' | '2' | '3' | '4';
28
+ type SplDialogSizeProps = {
29
+ /** Padding and corner radius preset, applied by Radix Themes. Defaults to '3'. */
30
+ size?: SplDialogSize;
31
+ /** Maximum width as any CSS length (e.g. `'450px'`, `'50rem'`). Defaults to 544px (450px for alert dialogs). */
32
+ maxWidth?: string;
33
+ };
34
+
35
+ type SplDialogProps = SplDialogActionsProps & SplDialogSizeProps & {
36
+ /** Unique id; the content element gets this id and footer buttons derive theirs from it. */
37
+ id: string;
38
+ title: string;
39
+ /** Optional description announced by screen readers. */
40
+ description?: string;
41
+ isOpen: boolean;
42
+ onOpenChange: (isOpen: boolean) => void;
43
+ children: ReactNode;
44
+ /** Replace the built-in footer entirely (e.g. for forms that own their buttons). */
45
+ footer?: ReactNode;
46
+ /** Prevent closing via Escape, overlay click, or the X button. */
47
+ isDismissDisabled?: boolean;
48
+ /** Show the X button in the corner. Defaults to true; Escape and overlay click still close the dialog when false. */
49
+ hasCloseButton?: boolean;
50
+ /** Extra class on the content panel, for width overrides. */
51
+ contentClassName?: string;
52
+ };
53
+ /**
54
+ * General purpose modal built on Radix Dialog, replacing VaModalWrapper for content and form dialogs.
55
+ * Use SplAlertDialog instead for confirmations that must be answered.
56
+ */
57
+ declare const SplDialog: ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled, hasCloseButton, contentClassName, size, maxWidth, onSecondaryAction, ...actions }: SplDialogProps) => React.JSX.Element;
58
+
59
+ type SplAlertDialogProps = Omit<SplDialogActionsProps, 'primaryLabel'> & SplDialogSizeProps & {
60
+ /** Unique id; the content element gets this id and footer buttons derive theirs from it. */
61
+ id: string;
62
+ title: string;
63
+ /** Required: alert dialogs must tell the user what they are confirming. May include inline markup. */
64
+ description: ReactNode;
65
+ isOpen: boolean;
66
+ onOpenChange: (isOpen: boolean) => void;
67
+ /** Required: an alert dialog always has an accept action. */
68
+ primaryLabel: string;
69
+ /** Optional extra content below the description (e.g. an error alert). */
70
+ children?: ReactNode;
71
+ /** Shows a leading icon before the title: a red trash can for 'destructive', an amber triangle for 'warning'. */
72
+ status?: 'destructive' | 'warning';
73
+ };
74
+ /**
75
+ * Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer
76
+ * (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking
77
+ * outside, has no X button, and focuses Cancel first so the safe choice is the default.
78
+ * Cancel closes it through `onOpenChange`. It does not auto-close on accept; the caller closes it
79
+ * through `isOpen` once the action succeeds.
80
+ */
81
+ declare const SplAlertDialog: ({ id, title, description, isOpen, onOpenChange, children, status, size, maxWidth, ...actions }: SplAlertDialogProps) => React.JSX.Element;
82
+
83
+ type SplDeleteAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'description' | 'primaryLabel'> & {
84
+ /** Name of the item being deleted, shown in bold after "Please confirm deletion of:". */
85
+ itemName: string;
86
+ /** Id for the bold item name element. Defaults to `{id}-item-name`. */
87
+ itemNameId?: string;
88
+ /** Defaults to "Delete". */
89
+ primaryLabel?: string;
90
+ };
91
+ /**
92
+ * Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.
93
+ */
94
+ declare const SplDeleteAlertDialog: ({ id, itemName, itemNameId, primaryLabel, primaryLoadingLabel, secondaryLabel, ...rest }: SplDeleteAlertDialogProps) => React.JSX.Element;
95
+
96
+ type SplWarningAlertDialogProps = Omit<SplAlertDialogProps, 'status' | 'primaryVariant' | 'primaryLabel'> & {
97
+ /** Defaults to "Continue". */
98
+ primaryLabel?: string;
99
+ };
100
+ /**
101
+ * Warning confirmation (e.g. sensitive record access): SplAlertDialog with the amber warning icon
102
+ * and the standard primary button.
103
+ */
104
+ declare const SplWarningAlertDialog: ({ primaryLabel, secondaryLabel, ...rest }: SplWarningAlertDialogProps) => React.JSX.Element;
2
105
 
3
106
  type SplTheme = "light" | "dark";
4
107
  type SplThemePreference = SplTheme | "system";
@@ -40,4 +143,4 @@ declare function useSplTheme(): SplThemeContextValue;
40
143
  */
41
144
  declare const SplThemeProvider: ({ children, preference: controlledPreference, defaultPreference, onPreferenceChange, }: SplThemeProviderProps) => React.JSX.Element;
42
145
 
43
- export { type SplTheme, type SplThemeContextValue, type SplThemePreference, SplThemeProvider, type SplThemeProviderProps, applyInitialSplTheme, applySplTheme, getSystemTheme, isSplThemePreference, resolveSplTheme, useSplTheme };
146
+ export { SplAlertDialog, type SplAlertDialogProps, SplDeleteAlertDialog, type SplDeleteAlertDialogProps, SplDialog, type SplDialogActionsProps, type SplDialogProps, type SplDialogSize, type SplDialogSizeProps, type SplTheme, type SplThemeContextValue, type SplThemePreference, SplThemeProvider, type SplThemeProviderProps, SplWarningAlertDialog, type SplWarningAlertDialogProps, applyInitialSplTheme, applySplTheme, getSystemTheme, isSplThemePreference, resolveSplTheme, useSplTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@va-scheduling/ui",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A simple template for a custom React component library",
5
5
  "scripts": {
6
6
  "rollup": "rollup -c",
@@ -17,6 +17,7 @@
17
17
  "react-dom": "^18.3.1",
18
18
  "rollup": "^4.21.2",
19
19
  "rollup-plugin-dts": "^6.1.1",
20
+ "rollup-plugin-postcss": "^4.0.2",
20
21
  "typescript": "^5.6.2"
21
22
  },
22
23
  "main": "dist/cjs/index.js",
@@ -41,6 +42,7 @@
41
42
  "access": "public"
42
43
  },
43
44
  "dependencies": {
45
+ "@radix-ui/react-icons": "^1.3.2",
44
46
  "@radix-ui/themes": "^3.3.0",
45
47
  "@va-scheduling/design-tokens": "^0.7.0",
46
48
  "tslib": "^2.7.0"