@va-scheduling/ui 0.2.0 → 0.2.1
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 +73 -1
- package/dist/cjs/index.css +1 -0
- package/dist/cjs/index.js +10 -33
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/spl-dialog/SplDialog.d.ts +1 -1
- package/dist/esm/index.css +1 -0
- package/dist/esm/index.js +10 -33
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/spl-dialog/SplDialog.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +10 -2
- package/dist/cjs/types/components/spl-dialog/modalIds.d.ts +0 -4
- package/dist/esm/types/components/spl-dialog/modalIds.d.ts +0 -4
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ Other exports: `applySplTheme`, `resolveSplTheme`, `getSystemTheme`, `isSplTheme
|
|
|
114
114
|
|
|
115
115
|
## Dialogs
|
|
116
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
|
|
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 ships as `index.css` beside each JS entry and loads with the package entry, so there are no runtime `<style>` tags (safe under a strict CSP and SSR).
|
|
118
118
|
|
|
119
119
|
| Component | Use for |
|
|
120
120
|
| --- | --- |
|
|
@@ -136,6 +136,78 @@ Built on Radix Themes dialogs, so they inherit its sizing, radius and shadow. Th
|
|
|
136
136
|
|
|
137
137
|
Footer buttons get ids `{id}-primary-btn`, `-secondary-btn` and `-tertiary-btn`, and the X is `{id}-close-btn`.
|
|
138
138
|
|
|
139
|
+
### Content dialog (`SplDialog`)
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { SplDialog } from "@va-scheduling/ui";
|
|
143
|
+
|
|
144
|
+
<SplDialog
|
|
145
|
+
id="edit-queue"
|
|
146
|
+
title="Edit Queue"
|
|
147
|
+
description="Change the queue name." // optional, announced by screen readers
|
|
148
|
+
isOpen={isOpen}
|
|
149
|
+
onOpenChange={setIsOpen}
|
|
150
|
+
primaryLabel="Save"
|
|
151
|
+
primaryLoadingLabel="Saving..."
|
|
152
|
+
onPrimaryAction={saveQueue}
|
|
153
|
+
>
|
|
154
|
+
<QueueForm />
|
|
155
|
+
</SplDialog>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
- **Close-only footer:** pass `secondaryLabel="Close"` and no `primaryLabel`.
|
|
159
|
+
- **Custom footer:** pass `footer={<MyButtons />}` to replace the built-in one (for example, when a form owns its submit button).
|
|
160
|
+
- **No dismissal:** `isDismissDisabled` blocks Escape and outside click and hides the X. Cancel still closes the dialog; use `isSecondaryDisabled` to prevent that while saving.
|
|
161
|
+
- **X button:** `hasCloseButton={false}` hides it; Escape and outside click still close the dialog.
|
|
162
|
+
- **Width override:** `contentClassName` adds a class to the content panel.
|
|
163
|
+
|
|
164
|
+
### Confirmation dialogs
|
|
165
|
+
|
|
166
|
+
`SplAlertDialog` requires `description` and `primaryLabel`. It cannot be dismissed by outside click, has no X, and focuses Cancel first.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
<SplAlertDialog
|
|
170
|
+
id="discard-changes"
|
|
171
|
+
title="Discard changes?"
|
|
172
|
+
description="Your unsaved changes will be lost."
|
|
173
|
+
status="warning" // optional: 'warning' | 'destructive'
|
|
174
|
+
isOpen={isOpen}
|
|
175
|
+
onOpenChange={setIsOpen}
|
|
176
|
+
primaryLabel="Discard"
|
|
177
|
+
primaryVariant="destructive"
|
|
178
|
+
onPrimaryAction={discard}
|
|
179
|
+
/>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Extra content (for example an error message) can be passed as `children` and renders below the description.
|
|
183
|
+
|
|
184
|
+
The presets fill in sensible defaults:
|
|
185
|
+
|
|
186
|
+
| Preset | Required | Defaults |
|
|
187
|
+
| --- | --- | --- |
|
|
188
|
+
| `SplDeleteAlertDialog` | `itemName` | `primaryLabel="Delete"`, `primaryLoadingLabel="Deleting..."`, `secondaryLabel="Cancel"`; the item name element has id `{id}-item-name` (override with `itemNameId`) |
|
|
189
|
+
| `SplWarningAlertDialog` | `description` | `primaryLabel="Continue"`, `secondaryLabel="Cancel"` |
|
|
190
|
+
|
|
191
|
+
### Shared props
|
|
192
|
+
|
|
193
|
+
| Prop | Description |
|
|
194
|
+
| --- | --- |
|
|
195
|
+
| `id` | Required. Set on the dialog content; footer button ids derive from it. |
|
|
196
|
+
| `title` | Required. |
|
|
197
|
+
| `isOpen`, `onOpenChange` | Required. You own the open state. |
|
|
198
|
+
| `primaryLabel`, `primaryLoadingLabel` | Accept button text, and its text while loading. |
|
|
199
|
+
| `secondaryLabel` | Cancel/close button text. Defaults to "Cancel" when a primary button is shown. |
|
|
200
|
+
| `tertiaryLabel`, `onTertiaryAction` | Optional extra button between secondary and primary. |
|
|
201
|
+
| `onPrimaryAction` | Called on accept. A returned promise shows the loading state until it settles; rejections are swallowed, so handle errors yourself. |
|
|
202
|
+
| `onSecondaryAction` | Called on cancel. The dialog also closes through `onOpenChange(false)`. |
|
|
203
|
+
| `isPrimaryLoading` | Force the loading state when it is driven by a store or parent. |
|
|
204
|
+
| `isPrimaryDisabled`, `isSecondaryDisabled`, `isTertiaryDisabled` | Disable the respective button. |
|
|
205
|
+
| `primaryVariant` | `'default'` or `'destructive'`. |
|
|
206
|
+
| `size` | `'1'`–`'4'` Radix padding preset. Default `'3'`. |
|
|
207
|
+
| `maxWidth` | Any CSS length. Default `544px` (`450px` for alert dialogs). |
|
|
208
|
+
|
|
209
|
+
Accepting does not close a dialog automatically. Close it from your `onPrimaryAction` (or in response to it succeeding) by setting `isOpen` to `false`.
|
|
210
|
+
|
|
139
211
|
## Testing (Jest)
|
|
140
212
|
|
|
141
213
|
Jest can't process CSS imports. Map them to a stub:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.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)}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require("./index.css");
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
require('@radix-ui/themes/styles.css');
|
|
@@ -6,36 +7,7 @@ var reactIcons = require('@radix-ui/react-icons');
|
|
|
6
7
|
var themes = require('@radix-ui/themes');
|
|
7
8
|
var React = require('react');
|
|
8
9
|
|
|
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
10
|
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
11
|
|
|
40
12
|
/**
|
|
41
13
|
* Footer buttons shared by SplDialog and SplAlertDialog.
|
|
@@ -66,7 +38,7 @@ const SplDialogFooter = ({ dialogId, secondaryLabel, primaryLabel, primaryLoadin
|
|
|
66
38
|
setIsPending(false);
|
|
67
39
|
}
|
|
68
40
|
};
|
|
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));
|
|
41
|
+
const secondaryButton = (React.createElement(themes.Button, { type: "button", variant: "outline", className: `${styles.button} ${styles['button--secondary']}`, id: `${dialogId}-secondary-btn`, disabled: isLoading || isSecondaryDisabled, onClick: onSecondaryAction }, secondaryText));
|
|
70
42
|
return (React.createElement("div", { className: styles.dialog__footer },
|
|
71
43
|
secondaryText && wrapSecondary(secondaryButton),
|
|
72
44
|
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)),
|
|
@@ -76,7 +48,7 @@ const SplDialogFooter = ({ dialogId, secondaryLabel, primaryLabel, primaryLoadin
|
|
|
76
48
|
};
|
|
77
49
|
|
|
78
50
|
/**
|
|
79
|
-
* General purpose modal built on Radix Dialog
|
|
51
|
+
* General purpose modal built on Radix Dialog for content and form dialogs.
|
|
80
52
|
* Use SplAlertDialog instead for confirmations that must be answered.
|
|
81
53
|
*/
|
|
82
54
|
const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled = false, hasCloseButton = true, contentClassName, size = '3', maxWidth = '544px', onSecondaryAction, ...actions }) => {
|
|
@@ -100,6 +72,11 @@ const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, foo
|
|
|
100
72
|
}, ...actions })))));
|
|
101
73
|
};
|
|
102
74
|
|
|
75
|
+
const statusIconClass = {
|
|
76
|
+
destructive: styles['dialog__statusIcon--destructive'],
|
|
77
|
+
warning: styles['dialog__statusIcon--warning'],
|
|
78
|
+
};
|
|
79
|
+
const wrapInCancel = (button) => React.createElement(themes.AlertDialog.Cancel, null, button);
|
|
103
80
|
/**
|
|
104
81
|
* Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer
|
|
105
82
|
* (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking
|
|
@@ -110,11 +87,11 @@ const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, foo
|
|
|
110
87
|
const SplAlertDialog = ({ id, title, description, isOpen, onOpenChange, children, status, size = '3', maxWidth = '450px', ...actions }) => (React.createElement(themes.AlertDialog.Root, { open: isOpen, onOpenChange: onOpenChange },
|
|
111
88
|
React.createElement(themes.AlertDialog.Content, { id: id, size: size, maxWidth: maxWidth, className: styles.dialog__content },
|
|
112
89
|
React.createElement("div", { className: styles.dialog__header },
|
|
113
|
-
status && (React.createElement("span", { id: `${id}-status-icon`, "aria-hidden": "true", className: `${styles.dialog__statusIcon} ${
|
|
90
|
+
status && (React.createElement("span", { id: `${id}-status-icon`, "aria-hidden": "true", className: `${styles.dialog__statusIcon} ${statusIconClass[status]}` }, status === 'warning' ? React.createElement(reactIcons.ExclamationTriangleIcon, null) : React.createElement(reactIcons.TrashIcon, null))),
|
|
114
91
|
React.createElement(themes.AlertDialog.Title, { className: styles.dialog__title }, title)),
|
|
115
92
|
React.createElement(themes.AlertDialog.Description, { className: styles.dialog__description }, description),
|
|
116
93
|
children && React.createElement("div", { className: styles.dialog__body }, children),
|
|
117
|
-
React.createElement(SplDialogFooter, { dialogId: id, wrapSecondary:
|
|
94
|
+
React.createElement(SplDialogFooter, { dialogId: id, wrapSecondary: wrapInCancel, ...actions }))));
|
|
118
95
|
|
|
119
96
|
/**
|
|
120
97
|
* Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,K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E,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,CAAC,CAC9D;IAED,QACE,oBAAC,eAAe,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA;AACpC,QAAA,KAAA,CAAA,aAAA,CAACC,YAAK,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
|
+
{"version":3,"file":"index.js","sources":["../../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":["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={isLoading || 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 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\nconst statusIconClass = {\r\n destructive: styles['dialog__statusIcon--destructive'],\r\n warning: styles['dialog__statusIcon--warning'],\r\n};\r\n\r\nconst wrapInCancel = (button: ReactNode) => <AlertDialog.Cancel>{button}</AlertDialog.Cancel>;\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} ${statusIconClass[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={wrapInCancel}\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":";;;;;;;;;;;AAkCA;;;AAGG;AACH,MAAM,eAAe,GAAG,CAAC,EACvB,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GAAG,KAAK,EACxB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAAG,KAAK,EACzB,mBAAmB,GAAG,KAAK,EAC3B,cAAc,GAAG,SAAS,EAC1B,aAAa,EACb,gBAAgB,EAChB,kBAAkB,GAAG,KAAK,EAC1B,aAAa,GAAG,CAAC,MAAM,KAAK,MAAM,GACb,KAAI;IACzB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;AACjD,IAAA,MAAM,SAAS,GAAGC,YAAM,CAAC,IAAI,CAAC;IAE9BC,eAAS,CAAC,MAAK;AACb,QAAA,SAAS,CAAC,OAAO,GAAG,IAAI;QACxB,OAAO,MAAK,EAAG,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC,EAAE,EAAE,CAAC;;AAGN,IAAA,MAAM,aAAa,GAAG,cAAc,KAAK,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC7E,IAAA,IAAI,CAAC,YAAY,IAAI,CAAC,aAAa;AAAE,QAAA,OAAO,IAAI;AAEhD,IAAA,MAAM,SAAS,GAAG,SAAS,IAAI,gBAAgB;AAE/C,IAAA,MAAM,aAAa,GAAG,YAAW;QAC/B,YAAY,CAAC,IAAI,CAAC;AAClB,QAAA,IAAI;YACF,MAAM,eAAe,IAAI;QAC3B;AAAE,QAA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B,OAAO;QACL,UAAU;QACV,KAAK;AACL,QAAA,aAAa,EAAE,CAAC,IAAwB,KAAI;AAC1C,YAAA,IAAI,oBAAoB,KAAK,SAAS,EAAE;gBACtC,qBAAqB,CAAC,IAAI,CAAC;YAC7B;AACA,YAAA,kBAAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;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,CAACC,YAAK,EAAA,EAAC,UAAU,EAAC,SAAS,EAAC,SAAS,EAAC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAA,EAC/D,QAAQ,CACH,CACiB;AAE/B;;;;;;;;;;;;"}
|
|
@@ -20,7 +20,7 @@ export type SplDialogProps = SplDialogActionsProps & SplDialogSizeProps & {
|
|
|
20
20
|
contentClassName?: string;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* General purpose modal built on Radix Dialog
|
|
23
|
+
* General purpose modal built on Radix Dialog for content and form dialogs.
|
|
24
24
|
* Use SplAlertDialog instead for confirmations that must be answered.
|
|
25
25
|
*/
|
|
26
26
|
declare const SplDialog: ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled, hasCloseButton, contentClassName, size, maxWidth, onSecondaryAction, ...actions }: SplDialogProps) => React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.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)}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,39 +1,11 @@
|
|
|
1
|
+
import "./index.css";
|
|
1
2
|
import '@radix-ui/themes/styles.css';
|
|
2
3
|
import '@va-scheduling/design-tokens/css';
|
|
3
4
|
import { Cross2Icon, ExclamationTriangleIcon, TrashIcon } from '@radix-ui/react-icons';
|
|
4
5
|
import { Button, Spinner, Dialog, IconButton, AlertDialog, Theme } from '@radix-ui/themes';
|
|
5
6
|
import React, { useState, useRef, useEffect, createContext, useLayoutEffect, useMemo, useContext } from 'react';
|
|
6
7
|
|
|
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
8
|
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
9
|
|
|
38
10
|
/**
|
|
39
11
|
* Footer buttons shared by SplDialog and SplAlertDialog.
|
|
@@ -64,7 +36,7 @@ const SplDialogFooter = ({ dialogId, secondaryLabel, primaryLabel, primaryLoadin
|
|
|
64
36
|
setIsPending(false);
|
|
65
37
|
}
|
|
66
38
|
};
|
|
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));
|
|
39
|
+
const secondaryButton = (React.createElement(Button, { type: "button", variant: "outline", className: `${styles.button} ${styles['button--secondary']}`, id: `${dialogId}-secondary-btn`, disabled: isLoading || isSecondaryDisabled, onClick: onSecondaryAction }, secondaryText));
|
|
68
40
|
return (React.createElement("div", { className: styles.dialog__footer },
|
|
69
41
|
secondaryText && wrapSecondary(secondaryButton),
|
|
70
42
|
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)),
|
|
@@ -74,7 +46,7 @@ const SplDialogFooter = ({ dialogId, secondaryLabel, primaryLabel, primaryLoadin
|
|
|
74
46
|
};
|
|
75
47
|
|
|
76
48
|
/**
|
|
77
|
-
* General purpose modal built on Radix Dialog
|
|
49
|
+
* General purpose modal built on Radix Dialog for content and form dialogs.
|
|
78
50
|
* Use SplAlertDialog instead for confirmations that must be answered.
|
|
79
51
|
*/
|
|
80
52
|
const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled = false, hasCloseButton = true, contentClassName, size = '3', maxWidth = '544px', onSecondaryAction, ...actions }) => {
|
|
@@ -98,6 +70,11 @@ const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, foo
|
|
|
98
70
|
}, ...actions })))));
|
|
99
71
|
};
|
|
100
72
|
|
|
73
|
+
const statusIconClass = {
|
|
74
|
+
destructive: styles['dialog__statusIcon--destructive'],
|
|
75
|
+
warning: styles['dialog__statusIcon--warning'],
|
|
76
|
+
};
|
|
77
|
+
const wrapInCancel = (button) => React.createElement(AlertDialog.Cancel, null, button);
|
|
101
78
|
/**
|
|
102
79
|
* Confirmation dialog built on Radix AlertDialog, for interruptions that need an explicit answer
|
|
103
80
|
* (delete confirmations, unsaved changes, etc.). Unlike SplDialog it cannot be dismissed by clicking
|
|
@@ -108,11 +85,11 @@ const SplDialog = ({ id, title, description, isOpen, onOpenChange, children, foo
|
|
|
108
85
|
const SplAlertDialog = ({ id, title, description, isOpen, onOpenChange, children, status, size = '3', maxWidth = '450px', ...actions }) => (React.createElement(AlertDialog.Root, { open: isOpen, onOpenChange: onOpenChange },
|
|
109
86
|
React.createElement(AlertDialog.Content, { id: id, size: size, maxWidth: maxWidth, className: styles.dialog__content },
|
|
110
87
|
React.createElement("div", { className: styles.dialog__header },
|
|
111
|
-
status && (React.createElement("span", { id: `${id}-status-icon`, "aria-hidden": "true", className: `${styles.dialog__statusIcon} ${
|
|
88
|
+
status && (React.createElement("span", { id: `${id}-status-icon`, "aria-hidden": "true", className: `${styles.dialog__statusIcon} ${statusIconClass[status]}` }, status === 'warning' ? React.createElement(ExclamationTriangleIcon, null) : React.createElement(TrashIcon, null))),
|
|
112
89
|
React.createElement(AlertDialog.Title, { className: styles.dialog__title }, title)),
|
|
113
90
|
React.createElement(AlertDialog.Description, { className: styles.dialog__description }, description),
|
|
114
91
|
children && React.createElement("div", { className: styles.dialog__body }, children),
|
|
115
|
-
React.createElement(SplDialogFooter, { dialogId: id, wrapSecondary:
|
|
92
|
+
React.createElement(SplDialogFooter, { dialogId: id, wrapSecondary: wrapInCancel, ...actions }))));
|
|
116
93
|
|
|
117
94
|
/**
|
|
118
95
|
* Delete confirmation: SplAlertDialog with the red trash icon and destructive primary button.
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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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A,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC;QACvD,MAAM,YAAY,GAAG,MAAM,cAAc,CAAC,cAAc,EAAE,CAAC;;QAG3D,cAAc,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACpD,UAAU,CAAC,gBAAgB,GAAG,QAAQ,EAAE,YAAY,CAAC;AACrD,QAAA,OAAO,MAAM,UAAU,CAAC,mBAAmB,GAAG,QAAQ,EAAE,YAAY,CAAC;AACvE,IAAA,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;AAEhB,IAAA,MAAM,KAAK,GAAa,UAAU,KAAK,QAAQ,GAAG,WAAW,GAAG,UAAU;IAE1E,eAAe,CAAC,MAAK;QACnB,aAAa,CAAC,KAAK,CAAC;AACtB,IAAA,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAEX,IAAA,MAAM,KAAK,GAAG,OAAO,CACnB,OAAO;QACL,UAAU;QACV,KAAK;AACL,QAAA,aAAa,EAAE,CAAC,IAAwB,KAAI;AAC1C,YAAA,IAAI,oBAAoB,KAAK,SAAS,EAAE;gBACtC,qBAAqB,CAAC,IAAI,CAAC;YAC7B;AACA,YAAA,kBAAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;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;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../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":["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={isLoading || 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 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\nconst statusIconClass = {\r\n destructive: styles['dialog__statusIcon--destructive'],\r\n warning: styles['dialog__statusIcon--warning'],\r\n};\r\n\r\nconst wrapInCancel = (button: ReactNode) => <AlertDialog.Cancel>{button}</AlertDialog.Cancel>;\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} ${statusIconClass[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={wrapInCancel}\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":";;;;;;;;;AAkCA;;;AAGG;AACH,MAAM,eAAe,GAAG,CAAC,EACvB,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GAAG,KAAK,EACxB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAAG,KAAK,EACzB,mBAAmB,GAAG,KAAK,EAC3B,cAAc,GAAG,SAAS,EAC1B,aAAa,EACb,gBAAgB,EAChB,kBAAkB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ogProps = SplDialogActionsProps & SplDialogSizeProps & {
|
|
|
20
20
|
contentClassName?: string;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* General purpose modal built on Radix Dialog
|
|
23
|
+
* General purpose modal built on Radix Dialog for content and form dialogs.
|
|
24
24
|
* Use SplAlertDialog instead for confirmations that must be answered.
|
|
25
25
|
*/
|
|
26
26
|
declare const SplDialog: ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled, hasCloseButton, contentClassName, size, maxWidth, onSecondaryAction, ...actions }: SplDialogProps) => React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ type SplDialogProps = SplDialogActionsProps & SplDialogSizeProps & {
|
|
|
51
51
|
contentClassName?: string;
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
* General purpose modal built on Radix Dialog
|
|
54
|
+
* General purpose modal built on Radix Dialog for content and form dialogs.
|
|
55
55
|
* Use SplAlertDialog instead for confirmations that must be answered.
|
|
56
56
|
*/
|
|
57
57
|
declare const SplDialog: ({ id, title, description, isOpen, onOpenChange, children, footer, isDismissDisabled, hasCloseButton, contentClassName, size, maxWidth, onSecondaryAction, ...actions }: SplDialogProps) => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@va-scheduling/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A simple template for a custom React component library",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"rollup": "rollup -c",
|
|
7
|
+
"test": "vitest run",
|
|
7
8
|
"prepublishOnly": "rollup -c"
|
|
8
9
|
},
|
|
9
10
|
"author": "Sean Afram",
|
|
@@ -12,13 +13,20 @@
|
|
|
12
13
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
13
14
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
14
15
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
16
|
+
"@testing-library/dom": "^10.4.2",
|
|
17
|
+
"@testing-library/jest-dom": "^8.0.0",
|
|
18
|
+
"@testing-library/react": "^16.3.3",
|
|
19
|
+
"@testing-library/user-event": "^14.6.13",
|
|
15
20
|
"@types/react": "^18.3.5",
|
|
21
|
+
"@types/react-dom": "^18.3.7",
|
|
22
|
+
"jsdom": "^29.1.1",
|
|
16
23
|
"react": "^18.3.1",
|
|
17
24
|
"react-dom": "^18.3.1",
|
|
18
25
|
"rollup": "^4.21.2",
|
|
19
26
|
"rollup-plugin-dts": "^6.1.1",
|
|
20
27
|
"rollup-plugin-postcss": "^4.0.2",
|
|
21
|
-
"typescript": "^5.6.2"
|
|
28
|
+
"typescript": "^5.6.2",
|
|
29
|
+
"vitest": "^5.1.2"
|
|
22
30
|
},
|
|
23
31
|
"main": "dist/cjs/index.js",
|
|
24
32
|
"module": "dist/esm/index.js",
|