@senvenli/react 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/action/fab.d.ts +7 -0
  2. package/dist/action/fab.js +22 -3
  3. package/dist/action/fab.js.map +1 -1
  4. package/dist/collection/data-table.d.ts +1 -1
  5. package/dist/collection/data-table.js +2 -2
  6. package/dist/collection/data-table.js.map +1 -1
  7. package/dist/collection/table.d.ts +7 -2
  8. package/dist/collection/table.js +17 -7
  9. package/dist/collection/table.js.map +1 -1
  10. package/dist/i18n.d.ts +8 -0
  11. package/dist/i18n.js +18 -1
  12. package/dist/i18n.js.map +1 -1
  13. package/dist/navigation/index.d.ts +2 -2
  14. package/dist/navigation/index.js +1 -1
  15. package/dist/navigation/index.js.map +1 -1
  16. package/dist/navigation/sidebar.d.ts +18 -0
  17. package/dist/navigation/sidebar.js +26 -2
  18. package/dist/navigation/sidebar.js.map +1 -1
  19. package/dist/overlay/floating.js +4 -1
  20. package/dist/overlay/floating.js.map +1 -1
  21. package/dist/overlay/index.d.ts +2 -0
  22. package/dist/overlay/index.js +2 -1
  23. package/dist/overlay/index.js.map +1 -1
  24. package/dist/overlay/tour.d.ts +88 -0
  25. package/dist/overlay/tour.js +302 -0
  26. package/dist/overlay/tour.js.map +1 -0
  27. package/package.json +2 -2
  28. package/dist/action/files.d.ts +0 -70
  29. package/dist/action/files.js +0 -156
  30. package/dist/action/files.js.map +0 -1
  31. package/dist/action/theme-toggle.d.ts +0 -43
  32. package/dist/action/theme-toggle.js +0 -259
  33. package/dist/action/theme-toggle.js.map +0 -1
  34. package/dist/display/image-crop.d.ts +0 -106
  35. package/dist/display/image-crop.js +0 -117
  36. package/dist/display/image-crop.js.map +0 -1
  37. package/dist/display/image-cropper.d.ts +0 -68
  38. package/dist/display/image-cropper.js +0 -284
  39. package/dist/display/image-cropper.js.map +0 -1
  40. package/dist/display/lozenge.d.ts +0 -30
  41. package/dist/display/lozenge.js +0 -55
  42. package/dist/display/lozenge.js.map +0 -1
  43. package/dist/display/scroll-area.d.ts +0 -29
  44. package/dist/display/scroll-area.js +0 -95
  45. package/dist/display/scroll-area.js.map +0 -1
  46. package/dist/feedback/cooldown.d.ts +0 -17
  47. package/dist/feedback/cooldown.js +0 -59
  48. package/dist/feedback/cooldown.js.map +0 -1
  49. package/dist/feedback/status-dot.d.ts +0 -23
  50. package/dist/feedback/status-dot.js +0 -37
  51. package/dist/feedback/status-dot.js.map +0 -1
  52. package/dist/form/input-otp.d.ts +0 -35
  53. package/dist/form/input-otp.js +0 -83
  54. package/dist/form/input-otp.js.map +0 -1
  55. package/dist/layout/auth-form-layout.d.ts +0 -71
  56. package/dist/layout/auth-form-layout.js +0 -61
  57. package/dist/layout/auth-form-layout.js.map +0 -1
  58. package/dist/layout/auth-layout.d.ts +0 -59
  59. package/dist/layout/auth-layout.js +0 -26
  60. package/dist/layout/auth-layout.js.map +0 -1
  61. package/dist/layout/pressable.d.ts +0 -40
  62. package/dist/layout/pressable.js +0 -65
  63. package/dist/layout/pressable.js.map +0 -1
  64. package/dist/layout/reset-sent-card.d.ts +0 -39
  65. package/dist/layout/reset-sent-card.js +0 -22
  66. package/dist/layout/reset-sent-card.js.map +0 -1
  67. package/dist/navigation/dock.d.ts +0 -27
  68. package/dist/navigation/dock.js +0 -47
  69. package/dist/navigation/dock.js.map +0 -1
  70. package/dist/navigation/footer.d.ts +0 -43
  71. package/dist/navigation/footer.js +0 -43
  72. package/dist/navigation/footer.js.map +0 -1
  73. package/dist/navigation/language-names.d.ts +0 -19
  74. package/dist/navigation/language-names.js +0 -79
  75. package/dist/navigation/language-names.js.map +0 -1
  76. package/dist/navigation/language-switcher.d.ts +0 -55
  77. package/dist/navigation/language-switcher.js +0 -53
  78. package/dist/navigation/language-switcher.js.map +0 -1
  79. package/dist/navigation/panel-header.d.ts +0 -37
  80. package/dist/navigation/panel-header.js +0 -50
  81. package/dist/navigation/panel-header.js.map +0 -1
  82. package/dist/navigation/toolbar.d.ts +0 -37
  83. package/dist/navigation/toolbar.js +0 -334
  84. package/dist/navigation/toolbar.js.map +0 -1
  85. package/dist/overlay/command-palette.d.ts +0 -53
  86. package/dist/overlay/command-palette.js +0 -130
  87. package/dist/overlay/command-palette.js.map +0 -1
  88. package/dist/overlay/overlay.d.ts +0 -299
  89. package/dist/overlay/overlay.js +0 -558
  90. package/dist/overlay/overlay.js.map +0 -1
  91. package/dist/selection/radio-card.d.ts +0 -31
  92. package/dist/selection/radio-card.js +0 -29
  93. package/dist/selection/radio-card.js.map +0 -1
@@ -1,558 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import * as React from "react";
4
- import { Dialog as AriaDialog, DialogTrigger as AriaDialogTrigger, Heading, Modal, ModalOverlay, OverlayTriggerStateContext, useLocale, } from "react-aria-components";
5
- import { cn } from "../utils.js";
6
- import { Button } from "../action/button.js";
7
- import { CloseButton } from "../action/close-button.js";
8
- import { IconGlyph } from "../display/icon.js";
9
- import { TextField } from "../form/text-field.js";
10
- import {
11
- // The prop of the same name (AlertDialog's `cancelLabel`) takes the plain name in this file.
12
- cancelLabel as defaultCancelLabel, collapseSheetLabel, discardCloseLabel, expandSheetLabel, keepEditingLabel, typeToConfirmLabel, unsavedBodyLabel, unsavedTitleLabel, } from "../i18n.js";
13
- const DIALOG_WIDTH = {
14
- small: "max-w-110",
15
- medium: "max-w-150",
16
- large: "max-w-200",
17
- xlarge: "max-w-288",
18
- };
19
- const DRAWER_WIDTH = {
20
- small: "w-95",
21
- medium: "w-140",
22
- large: "w-140",
23
- };
24
- /** The scrim: `ds-blanket`, fading in `ds-duration-slow`; still for reduced motion. */
25
- const BLANKET = "fixed inset-0 z-50 bg-ds-blanket transition-opacity duration-(--ds-duration-slow) ease-ds-enter " +
26
- "data-[entering]:opacity-0 data-[exiting]:opacity-0 data-[exiting]:ease-ds-exit motion-reduce:transition-none";
27
- /** Every overlay's inner focus target: React Aria's dialog element, never outlined itself. */
28
- const DIALOG_ELEMENT = "flex min-h-0 flex-1 flex-col outline-hidden";
29
- /**
30
- * The state of the DialogTrigger an overlay belongs to. React Aria's own context is also provided by every
31
- * open modal, so a Dialog nested in a Drawer would bind to the drawer; this one is set by DialogTrigger only
32
- * and cleared inside every overlay.
33
- */
34
- const OwnTriggerContext = React.createContext(null);
35
- function TriggerBridge({ children }) {
36
- const state = React.useContext(OverlayTriggerStateContext);
37
- return _jsx(OwnTriggerContext.Provider, { value: state, children: children });
38
- }
39
- /** True inside an open overlay's contents, where React Aria's trigger context is that overlay's own. */
40
- const InsideOverlayContext = React.createContext(false);
41
- /** Overlay contents: a nested overlay must not see the outer one's trigger. */
42
- export function OverlayContents({ children }) {
43
- return (_jsx(InsideOverlayContext.Provider, { value: true, children: _jsx(OwnTriggerContext.Provider, { value: null, children: children }) }));
44
- }
45
- /**
46
- * The button that opens a Dialog, AlertDialog or Drawer: put it first, the overlay after it. Inside another
47
- * overlay (a Dialog in a Drawer) use this one, not React Aria's own DialogTrigger, which there only sees the
48
- * outer overlay's state.
49
- */
50
- export function DialogTrigger({ children, ...props }) {
51
- return (_jsx(AriaDialogTrigger, { ...props, children: _jsx(TriggerBridge, { children: children }) }));
52
- }
53
- /**
54
- * Open state for an overlay that can sit in a DialogTrigger or stand alone. Inside a trigger the trigger's
55
- * state is used; otherwise `isOpen`/`defaultOpen`. `close` is the one way to close, so `onOpenChange(false)`
56
- * fires once whichever control asked (button, Esc, scrim).
57
- */
58
- function useOverlayOpen({ isOpen, defaultOpen, onOpenChange }) {
59
- const ownTrigger = React.useContext(OwnTriggerContext);
60
- const ariaTrigger = React.useContext(OverlayTriggerStateContext);
61
- const inside = React.useContext(InsideOverlayContext);
62
- // Our DialogTrigger first; React Aria's own DialogTrigger also works, except inside another overlay, where
63
- // that context belongs to the outer overlay.
64
- const trigger = ownTrigger ?? (inside ? null : ariaTrigger);
65
- const [own, setOwn] = React.useState(defaultOpen ?? false);
66
- const open = trigger ? trigger.isOpen : (isOpen ?? own);
67
- const set = (next) => {
68
- if (trigger) {
69
- if (next)
70
- trigger.open();
71
- else
72
- trigger.close();
73
- return;
74
- }
75
- if (isOpen === undefined)
76
- setOwn(next);
77
- onOpenChange?.(next);
78
- };
79
- return { isOpen: open, open: () => set(true), close: () => set(false) };
80
- }
81
- /** The `data-*` entries of a props object, without the DS's own `data-slot`. */
82
- function dataAttributes(source) {
83
- const picked = {};
84
- if (!source)
85
- return picked;
86
- for (const [name, value] of Object.entries(source)) {
87
- if (name.startsWith("data-") && name !== "data-slot")
88
- picked[name] = value;
89
- }
90
- return picked;
91
- }
92
- /**
93
- * Focus on open: the first field of the body, or the secondary action when the primary one destroys
94
- * something. Runs after React Aria's own first-focus, so it wins. A destructive primary with no secondary
95
- * (`secondaryAction={null}` on a full-screen dialog) has no safe button to start on, so focus goes to the first
96
- * field as it does for any other dialog, and to the dialog itself when the body has none. The
97
- * app's `initialFocusRef`, when it holds an element, comes before every rule.
98
- */
99
- function useInitialFocus(body, secondary, safeFirst, initial) {
100
- React.useEffect(() => {
101
- if (initial?.current) {
102
- initial.current.focus();
103
- // An element that cannot take focus (a hidden title, which has no tabIndex; UI#528 review, or a
104
- // container without one) leaves focus where it was, and a focus handler on the ref may move it
105
- // outside: in both cases the dialog's own rule below picks the target instead (UI#529 review).
106
- if (initial.current.contains(document.activeElement))
107
- return;
108
- }
109
- if (safeFirst && secondary.current) {
110
- secondary.current.focus();
111
- return;
112
- }
113
- const field = [...(body.current?.querySelectorAll(FIRST_FIELD) ?? [])].find(isReachableField);
114
- field?.focus();
115
- }, []);
116
- }
117
- /**
118
- * A field the dialog may start on: a text input, a text area, a native select, a combobox, a date or time segment,
119
- * or a Select or MultiSelect's button (it opens a listbox). In document order.
120
- */
121
- const FIRST_FIELD = "input:not([type='hidden']):not([disabled]), textarea:not([disabled]), select:not([disabled]), [role='combobox'], [role='spinbutton'][tabindex], " +
122
- "button[aria-haspopup='listbox']:not([disabled])";
123
- /**
124
- * Not the native fields React Aria keeps for forms and autofill behind a Select (its hidden `<select>` and input),
125
- * which are hidden from assistive tech, marked to take no focus and out of the tab order: the dialog
126
- * started on that `<select>` and not on the Select's button. Anything under `aria-hidden` or `inert`, or with a
127
- * negative tabindex on a native field, is passed over.
128
- */
129
- function isReachableField(element) {
130
- if (element.closest("[aria-hidden='true'], [inert], [data-react-aria-prevent-focus]"))
131
- return false;
132
- if (element.matches("input, textarea, select") && element.tabIndex < 0)
133
- return false;
134
- return true;
135
- }
136
- /** React Aria's FocusScope dispatches this on the element it is about to give focus back to; cancelling it stops that. */
137
- const RESTORE_FOCUS_EVENT = "react-aria-focus-scope-restore";
138
- /**
139
- * `returnFocusRef`: when the dialog's contents unmount (it closed), focus goes to the ref's element
140
- * instead of the opener. React Aria's own return to the opener is cancelled for that one close, so the opener
141
- * never flashes focus (and its focus handlers never run). Focus the app moved elsewhere on purpose is left alone.
142
- * Without the ref, or with it empty, nothing here runs and React Aria returns focus to the opener as before.
143
- */
144
- function useReturnFocus(target) {
145
- const latest = React.useRef(target);
146
- latest.current = target;
147
- // The element focused as the dialog opens is the one React Aria would return to.
148
- const [opener] = React.useState(() => (typeof document === "undefined" ? null : document.activeElement));
149
- // Strict Mode unmounts and remounts effects once in development: that is not a close.
150
- const mounted = React.useRef(false);
151
- React.useLayoutEffect(() => {
152
- mounted.current = true;
153
- return () => {
154
- mounted.current = false;
155
- if (!latest.current)
156
- return;
157
- const ref = latest.current;
158
- const cancel = (event) => {
159
- if (!mounted.current && ref.current && event.target === opener)
160
- event.preventDefault();
161
- };
162
- document.addEventListener(RESTORE_FOCUS_EVENT, cancel, true);
163
- requestAnimationFrame(() => {
164
- document.removeEventListener(RESTORE_FOCUS_EVENT, cancel, true);
165
- if (mounted.current)
166
- return;
167
- const element = ref.current;
168
- const active = document.activeElement;
169
- const unclaimed = !active || active === document.body || active === opener || !active.isConnected;
170
- if (element?.isConnected && unclaimed)
171
- element.focus();
172
- });
173
- };
174
- }, [opener]);
175
- }
176
- /**
177
- * A form-submit primary while pending: React Aria turns the button into `type="button"`, so a click
178
- * no longer submits, but Enter in a form with one field still would (HTML's implicit submission needs no
179
- * button). Every submit of that form is stopped here until the action settles, before React's `onSubmit` sees it.
180
- * The listener sits on `document` (capture) and matches the form by its id when the submit happens, so a form
181
- * remounted with the same id while pending is stopped too; another form still submits. React's capture
182
- * handlers on the form (`onSubmitCapture`) still run while pending: the event is cancelled on `document` but
183
- * stopped only on the form itself, after React's root has seen its capture phase and before its bubble.
184
- */
185
- function useBlockedSubmit(formId, blocked) {
186
- React.useEffect(() => {
187
- if (!formId || !blocked)
188
- return;
189
- const stopAtForm = (event) => event.stopPropagation();
190
- const block = (event) => {
191
- const form = event.target;
192
- if (!(form instanceof HTMLFormElement) || form.id !== formId)
193
- return;
194
- event.preventDefault();
195
- // Added while the event is on its way down, so it runs when the event reaches the form; taken off after this
196
- // dispatch in case something above stopped the event first (a task, so never in the middle of it).
197
- form.addEventListener("submit", stopAtForm, { capture: true, once: true });
198
- setTimeout(() => form.removeEventListener("submit", stopAtForm, { capture: true }), 0);
199
- };
200
- document.addEventListener("submit", block, true);
201
- return () => document.removeEventListener("submit", block, true);
202
- }, [formId, blocked]);
203
- }
204
- const TABBABLE = [
205
- "button:not([disabled])",
206
- "[href]",
207
- "input:not([type='hidden']):not([disabled])",
208
- "select:not([disabled])",
209
- "textarea:not([disabled])",
210
- "[tabindex]:not([tabindex='-1'])",
211
- "[contenteditable]:not([contenteditable='false'])",
212
- "summary",
213
- "audio[controls]",
214
- "video[controls]",
215
- ].join(", ");
216
- /**
217
- * Development only: with the close button hidden and no control a keyboard can reach inside, a
218
- * keyboard user can neither go on nor, without `isDismissable`, leave; even with it (Esc), a touch user on
219
- * `fullscreen` has no press outside. So it warns whenever the close button is hidden and nothing inside is
220
- * tabbable, whatever `isDismissable` says. Checked once it opens.
221
- */
222
- function useStrandedWarning(closeHidden, body) {
223
- React.useEffect(() => {
224
- if (process.env.NODE_ENV === "production" || !closeHidden)
225
- return;
226
- const dialog = body.current?.closest("[data-slot='dialog']");
227
- if (dialog && !dialog.querySelector(TABBABLE)) {
228
- console.warn("Dialog: isCloseButtonHidden leaves no close button, and the dialog has no control a keyboard can reach, so a user may be unable to go on or leave. Give it a primaryAction or a control in the body.");
229
- }
230
- }, [closeHidden]);
231
- }
232
- function DialogFrame({ size, children, role, isDismissable, escapeCloses, isOpen, onClose, describedBy, rootData }) {
233
- return (_jsx(ModalOverlay
234
- // Always controlled here: closing goes through `onClose` only, so it is reported once.
235
- , {
236
- // Always controlled here: closing goes through `onClose` only, so it is reported once.
237
- isOpen: isOpen, onOpenChange: (next) => {
238
- if (!next)
239
- onClose();
240
- }, isDismissable: isDismissable, isKeyboardDismissDisabled: !escapeCloses, "data-slot": "dialog-overlay", className: cn(BLANKET, "grid place-items-center overflow-y-auto p-ds-300 pt-[max(var(--ds-space-300),env(safe-area-inset-top,0px))] pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))]"), children: _jsx(Modal, { "data-slot": "dialog-modal", "data-size": size, className: cn(
241
- // A default max height with the body scrolling inside, so a small screen never pushes the footer away.
242
- "flex max-h-[calc(100dvh-2*var(--ds-space-300))] w-full flex-col overflow-hidden rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", "transition-[opacity,translate] duration-(--ds-duration-slow) ease-ds-enter data-[entering]:translate-y-2 data-[entering]:opacity-0 data-[exiting]:opacity-0 data-[exiting]:ease-ds-exit motion-reduce:transition-none", DIALOG_WIDTH[size]), children: _jsx(AriaDialog, { ...rootData, role: role, "aria-describedby": describedBy, "data-slot": "dialog", className: DIALOG_ELEMENT, children: _jsx(OverlayContents, { children: children }) }) }) }));
243
- }
244
- /**
245
- * The full-screen frame: the modal covers the viewport, edge to edge, at every width. On a phone
246
- * (below 640px, Drawer's query) it is presented as a sheet sliding up from the bottom edge; above, it fades in.
247
- * The side insets (landscape notch) pad the modal; the top and bottom ones pad the header and the footer.
248
- * Small, medium and large never come here: their frame above is unchanged.
249
- */
250
- function FullScreenFrame({ children, isDismissable, isOpen, onClose, describedBy, rootData }) {
251
- const sheet = useNarrow();
252
- return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: (next) => {
253
- if (!next)
254
- onClose();
255
- },
256
- // No scrim to press: a press on something layered above the frame (a toast, a cookie banner) must not
257
- // close it, so outside presses never dismiss; `isDismissable` decides Esc alone.
258
- isDismissable: false, isKeyboardDismissDisabled: !isDismissable, "data-slot": "dialog-overlay", className: BLANKET, children: _jsx(Modal, { "data-slot": "dialog-modal", "data-size": "fullscreen", "data-presentation": sheet ? "sheet" : "fullscreen", className: cn("fixed inset-0 flex flex-col overflow-hidden bg-ds-surface-overlay text-ds-text outline-hidden", "ps-[env(safe-area-inset-left,0px)] pe-[env(safe-area-inset-right,0px)] rtl:ps-[env(safe-area-inset-right,0px)] rtl:pe-[env(safe-area-inset-left,0px)]", "duration-(--ds-duration-slow) ease-ds-enter data-[exiting]:ease-ds-exit motion-reduce:transition-none", sheet
259
- ? "transition-[translate] data-[entering]:translate-y-full data-[exiting]:translate-y-full"
260
- : "transition-opacity data-[entering]:opacity-0 data-[exiting]:opacity-0"), children: _jsx(AriaDialog, { ...rootData, "aria-describedby": describedBy, "data-slot": "dialog", className: DIALOG_ELEMENT, children: _jsx(OverlayContents, { children: children }) }) }) }));
261
- }
262
- /** Pulled into the corner so its icon lines up with the padding, not its 32px hit area. */
263
- function CornerClose({ onPress, slot, data }) {
264
- return (_jsx("span", { "data-slot": `${slot}-wrap`, className: "-me-ds-100 -mt-ds-050 flex", children: _jsx(CloseButton, { ...data, "data-slot": slot, onPress: onPress }) }));
265
- }
266
- /**
267
- * The full-screen parts. Header and footer never shrink and the body is the one scroll container
268
- * between them, so they stay at the top and bottom; the header clears the notch, the footer the home indicator.
269
- */
270
- const FULL_HEADER = "flex shrink-0 items-start justify-between gap-ds-200 border-b border-ds-border px-ds-300 pb-ds-200 pt-[max(var(--ds-space-300),env(safe-area-inset-top,0px))]";
271
- const FULL_BODY = "min-h-0 flex-1 overflow-y-auto overscroll-contain px-ds-300 py-ds-300 text-body text-ds-text-subtle";
272
- const FULL_FOOTER = "flex shrink-0 flex-wrap items-center justify-end gap-ds-100 border-t border-ds-border px-ds-300 pt-ds-200 pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))]";
273
- /** An empty description (`""`, `false`, `true`, `null`) renders nothing, so it is the same as none. */
274
- function hasDescription(description) {
275
- return description != null && typeof description !== "boolean" && description !== "";
276
- }
277
- /** A node that renders something: the `headerStart` test (`null`, `false`, `true`, `""` count as none). */
278
- const isRenderable = hasDescription;
279
- // The full-screen options, each added to the classes above only when used, so a full-screen
280
- // dialog without them renders exactly as before.
281
- /** No footer: the body is the last part, so it clears the home indicator itself (as Drawer's body does). */
282
- const FULL_BODY_NO_FOOTER = "min-h-0 flex-1 overflow-y-auto overscroll-contain px-ds-300 pt-ds-300 pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))] text-body text-ds-text-subtle";
283
- /** `footerLayout="spread"`: the secondary takes the free space after it, so it sits at the start and the primary at the end. */
284
- const FOOTER_SPREAD = "[&>[data-slot=dialog-secondary]]:me-auto";
285
- /** A hidden title is out of flow, so the close button is held at the inline end on its own. */
286
- const HEADER_CLOSE_END = "[&>[data-slot=dialog-close-wrap]]:ms-auto";
287
- /** With `headerStart` the title side takes the room left between the slot and the close button. */
288
- const TITLE_SIDE = "min-w-0 flex-1";
289
- /** Small, medium and large without a footer (`secondaryAction={null}` and no primary): the body takes the footer's bottom padding. */
290
- const BODY = "min-h-0 flex-1 overflow-y-auto px-ds-300 py-ds-200 text-body text-ds-text-subtle";
291
- const BODY_NO_FOOTER = "min-h-0 flex-1 overflow-y-auto px-ds-300 pt-ds-200 pb-ds-300 text-body text-ds-text-subtle";
292
- /**
293
- * The title with `titleRef`: the DS focus ring, a 2px ds-border-focused inset ring, for keyboard focus
294
- * only (`:focus-visible`), as on the drawer grip and the scroll area, so a pointer user never sees one. The browser's
295
- * own outline is hidden; no outline or external ring is hand-written (focus-outline.test.ts, focus-state.test.ts).
296
- * The heading's box reaches 4px past its text on each side (`-mx-ds-050 px-ds-050`), so the ring clears the first and
297
- * last letters while the text stays exactly where it was. Added only with `titleRef`, and only to a visible title: a
298
- * hidden one (`isTitleHidden`) keeps `sr-only` alone, takes no tabIndex and is never a focus target (its margin and
299
- * padding would also partly override `sr-only`'s).
300
- */
301
- const TITLE_FOCUSABLE = "-mx-ds-050 px-ds-050 outline-hidden focus-visible:rounded-ds-small focus-visible:inset-ring-2 focus-visible:inset-ring-ds-border-focused";
302
- function DialogContent({ title, description, descriptionId, children, primaryAction, secondaryAction, close, fullScreen, footerLayout, headerStart, isTitleHidden, isCloseButtonHidden, initialFocusRef, returnFocusRef, partData, titleRef, }) {
303
- const { locale } = useLocale();
304
- const body = React.useRef(null);
305
- const secondary = React.useRef(null);
306
- const destructive = primaryAction?.variant === "danger";
307
- const closeHidden = isCloseButtonHidden === true;
308
- useInitialFocus(body, secondary, destructive, initialFocusRef);
309
- useReturnFocus(returnFocusRef);
310
- useBlockedSubmit(primaryAction?.form, primaryAction?.isPending === true);
311
- useStrandedWarning(closeHidden, body);
312
- // The full-screen options below reach this component only for `fullscreen` (Dialog drops them for the other sizes).
313
- const hasStart = isRenderable(headerStart);
314
- const hasSecondary = secondaryAction !== null;
315
- const hasFooter = hasSecondary || primaryAction != null;
316
- // A hidden title keeps only `sr-only` (its own margin and size would fight it); with a start slot it truncates.
317
- const titleClass = isTitleHidden ? "sr-only" : hasStart ? "m-0 truncate text-heading-medium" : "m-0 text-heading-medium";
318
- // The app's data-* attributes come first in every part, so the DS's own data-slot wins.
319
- // With `titleRef` the heading takes the ref, tabIndex -1 and the focus ring; without it, nothing changes.
320
- // A hidden title takes the ref only: an sr-only heading would show no focus indicator, so it is never a focus target.
321
- const hasTitleRef = titleRef !== undefined && titleRef !== null;
322
- const titleText = hasTitleRef && isTitleHidden ? (_jsx(Heading, { ...partData?.title, ref: titleRef, slot: "title", "data-slot": "dialog-title", className: titleClass, children: title })) : hasTitleRef ? (_jsx(Heading, { ...partData?.title, ref: titleRef, tabIndex: -1, slot: "title", "data-slot": "dialog-title", className: `${titleClass} ${TITLE_FOCUSABLE}`, children: title })) : (_jsx(Heading, { ...partData?.title, slot: "title", "data-slot": "dialog-title", className: titleClass, children: title }));
323
- const headerClass = fullScreen ? FULL_HEADER : "flex items-start justify-between gap-ds-200 px-ds-300 pt-ds-300";
324
- return (_jsxs(_Fragment, { children: [_jsxs("div", { ...partData?.header, "data-slot": "dialog-header", className: isTitleHidden ? `${headerClass} ${HEADER_CLOSE_END}` : headerClass, children: [hasStart && (_jsx("div", { "data-slot": "dialog-header-start", className: "flex shrink-0 items-center", children: headerStart })), hasDescription(description) ? (_jsxs("div", { "data-slot": "dialog-heading", className: hasStart ? `flex flex-col gap-ds-050 ${TITLE_SIDE}` : "flex min-w-0 flex-col gap-ds-050", children: [titleText, _jsx("div", { id: descriptionId, "data-slot": "dialog-description", className: "text-body text-ds-text-subtle", children: description })] })) : hasStart && !isTitleHidden ? (_jsx("div", { "data-slot": "dialog-heading", className: TITLE_SIDE, children: titleText })) : (titleText), !closeHidden && _jsx(CornerClose, { slot: "dialog-close", onPress: close, data: partData?.close })] }), _jsx("div", { ...partData?.body, ref: body, "data-slot": "dialog-body", className: fullScreen ? (hasFooter ? FULL_BODY : FULL_BODY_NO_FOOTER) : hasFooter ? BODY : BODY_NO_FOOTER, children: children }), hasFooter && (_jsxs("div", { ...partData?.footer, "data-slot": "dialog-footer", "data-layout": footerLayout === "spread" ? "spread" : undefined, className: fullScreen ? (footerLayout === "spread" ? `${FULL_FOOTER} ${FOOTER_SPREAD}` : FULL_FOOTER) : "flex flex-wrap items-center justify-end gap-ds-100 px-ds-300 pb-ds-300 pt-ds-100", children: [hasSecondary && (_jsx(Button, { ...dataAttributes(secondaryAction), ref: secondary, variant: "subtle", "data-slot": "dialog-secondary", isDisabled: secondaryAction?.isDisabled, iconBefore: secondaryAction?.iconBefore, iconAfter: secondaryAction?.iconAfter, onPress: () => (secondaryAction?.onPress ? secondaryAction.onPress() : close()), children: secondaryAction?.label ?? defaultCancelLabel(locale) })), primaryAction && (_jsx(Button, { ...dataAttributes(primaryAction), variant: primaryAction.variant ?? "primary", isPending: primaryAction.isPending, isDisabled: primaryAction.isDisabled, iconBefore: primaryAction.iconBefore, iconAfter: primaryAction.iconAfter, onPress: primaryAction.onPress,
325
- // A form-submit action; without `form` the Button stays type="button".
326
- type: primaryAction.form ? "submit" : undefined, form: primaryAction.form, "data-slot": "dialog-primary", children: primaryAction.label }))] }))] }));
327
- }
328
- /**
329
- * Development only: the full-screen options a smaller size was given, which it ignores. Only values that would
330
- * change a full-screen dialog count: `isTitleHidden={false}`, `footerLayout="end"` or an empty
331
- * `headerStart` are the defaults there too, so nothing is lost and nothing is said.
332
- */
333
- function useFullScreenOnlyWarning(size, props) {
334
- const ignored = size === "fullscreen"
335
- ? []
336
- : [
337
- props.footerLayout === "spread" && "footerLayout",
338
- isRenderable(props.headerStart) && "headerStart",
339
- props.isTitleHidden === true && "isTitleHidden",
340
- ].filter((name) => typeof name === "string");
341
- const signature = ignored.join(", ");
342
- // One option named takes the singular ("isTitleHidden only applies … ignores it"), several the plural.
343
- const one = ignored.length === 1;
344
- React.useEffect(() => {
345
- if (process.env.NODE_ENV === "production" || !signature)
346
- return;
347
- console.warn(`Dialog: ${signature} only ${one ? "applies" : "apply"} to size="fullscreen"; size="${size}" ignores ${one ? "it" : "them"}.`);
348
- }, [signature, size, one]);
349
- }
350
- /** A title that names nothing: empty, blank or not text at all (`""`, `" "`, `null`, `false`, `true`). */
351
- function isEmptyTitle(title) {
352
- return title === null || typeof title === "boolean" || (typeof title === "string" && title.trim() === "");
353
- }
354
- /**
355
- * Development only: `isTitleHidden` with an empty title leaves the dialog without a name, since the
356
- * hidden title is what names it. A left-out title (`undefined`) is already a TypeScript error, so only the empty
357
- * values that type-check are said here. Fullscreen only: the other sizes ignore `isTitleHidden` (the fullscreen-only
358
- * warning names it), so their title shows and names the dialog.
359
- */
360
- function useHiddenEmptyTitleWarning(isTitleHidden, title, fullScreen) {
361
- const unnamed = fullScreen && isTitleHidden === true && isEmptyTitle(title);
362
- React.useEffect(() => {
363
- if (process.env.NODE_ENV === "production" || !unnamed)
364
- return;
365
- console.warn("Dialog: isTitleHidden hides the title, but the title is empty, so the dialog has no accessible name. Give it a title; it stays visually hidden.");
366
- }, [unnamed]);
367
- }
368
- /**
369
- * A decision or a short input that must be resolved before the user goes on. Put it inside a DialogTrigger
370
- * after its button, or control it with `isOpen`. Focus moves to the first field (to "Cancel" when the
371
- * primary action is destructive and "Cancel" is there), stays inside, and returns to the trigger on close; Esc closes it.
372
- * `size="fullscreen"` covers the viewport, a sheet on phones, for a long task like a signup; it
373
- * also takes a logo before the title (`headerStart`), a visually hidden title (`isTitleHidden`) and a spread footer
374
- * (`footerLayout`). Every size: a primary action that submits a form
375
- * (`primaryAction.form`), no secondary action (`secondaryAction={null}`; with no primary either, no footer), no
376
- * close button (`isCloseButtonHidden`; a locked view adds `isDismissable={false}`), `data-*` attributes on the
377
- * dialog and its parts (`partData`, the actions' own), and focus hooks (`initialFocusRef`, `returnFocusRef`). A
378
- * focusable title (`titleRef`), which `initialFocusRef` can name to open on it.
379
- */
380
- export function Dialog({ size = "small", isDismissable = true, isOpen, defaultOpen, onOpenChange, footerLayout, headerStart, isTitleHidden, ...content }) {
381
- const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
382
- const descriptionId = React.useId();
383
- // Described only when there is a description; otherwise the dialog's DOM is unchanged.
384
- const describedBy = hasDescription(content.description) ? descriptionId : undefined;
385
- // The app's data-* props go to the dialog element; none given, nothing is added.
386
- const rootData = dataAttributes(content);
387
- useFullScreenOnlyWarning(size, { footerLayout, headerStart, isTitleHidden });
388
- useHiddenEmptyTitleWarning(isTitleHidden, content.title, size === "fullscreen");
389
- if (size === "fullscreen") {
390
- return (_jsx(FullScreenFrame, { isDismissable: isDismissable, isOpen: state.isOpen, onClose: state.close, describedBy: describedBy, rootData: rootData, children: _jsx(DialogContent, { ...content, footerLayout: footerLayout, headerStart: headerStart, isTitleHidden: isTitleHidden, descriptionId: descriptionId, close: state.close, fullScreen: true }) }));
391
- }
392
- return (_jsx(DialogFrame, { size: size, isDismissable: isDismissable, escapeCloses: isDismissable, isOpen: state.isOpen, onClose: state.close, describedBy: describedBy, rootData: rootData, children: _jsx(DialogContent, { ...content, descriptionId: descriptionId, close: state.close }) }));
393
- }
394
- const ALERT_ICON = {
395
- danger: { name: "trash-2", className: "bg-ds-background-danger text-ds-icon-danger" },
396
- warning: { name: "triangle-alert", className: "bg-ds-background-warning text-ds-icon-warning" },
397
- neutral: { name: "info", className: "bg-ds-background-neutral text-ds-icon" },
398
- };
399
- /**
400
- * Only with a custom `cancelLabel`: the cancel button may wrap its text and grow in height, at most
401
- * as wide as the footer, so a long app label never overflows a 320px screen. The default "Cancel" is short and
402
- * keeps the footer's classes unchanged, and so does a blank label (`" "`), which counts as unset. A word breaks only
403
- * when it is too long for a line (`break-words`).
404
- */
405
- const CUSTOM_CANCEL_FOOTER = "[&>[data-slot=alert-dialog-cancel]]:h-auto [&>[data-slot=alert-dialog-cancel]]:min-h-ds-control [&>[data-slot=alert-dialog-cancel]]:max-w-full " +
406
- "[&>[data-slot=alert-dialog-cancel]]:py-ds-075 [&>[data-slot=alert-dialog-cancel]]:whitespace-normal [&>[data-slot=alert-dialog-cancel]]:text-center " +
407
- "[&>[data-slot=alert-dialog-cancel]]:break-words";
408
- const ALERT_FOOTER = "flex flex-wrap items-center justify-end gap-ds-100 px-ds-300 pb-ds-300 pt-ds-200";
409
- function AlertContent({ tone = "danger", title, children, confirmLabel, cancelLabel, onConfirm, requireTypedConfirmation, typedConfirmationLabel, icon, returnFocusRef, isConfirmDisabled, descriptionId, close, pending, setPending, }) {
410
- const { locale } = useLocale();
411
- const cancel = React.useRef(null);
412
- const [typed, setTyped] = React.useState("");
413
- // "Cancel" first: the destructive button never has default focus.
414
- React.useEffect(() => cancel.current?.focus(), []);
415
- // Without the ref nothing runs, so React Aria returns focus to the opener as before.
416
- useReturnFocus(returnFocusRef);
417
- const ready = requireTypedConfirmation === undefined || typed.trim() === requireTypedConfirmation;
418
- const confirm = async () => {
419
- setPending(true);
420
- let done = false;
421
- try {
422
- await onConfirm();
423
- done = true;
424
- }
425
- catch {
426
- // The action failed: the dialog stays open so the user can retry or cancel. Saying what went wrong
427
- // (a Toast, an inline Banner) is the caller's, which knows the error.
428
- }
429
- finally {
430
- setPending(false);
431
- }
432
- if (done)
433
- close();
434
- };
435
- const glyph = ALERT_ICON[tone];
436
- return (_jsxs(_Fragment, { children: [_jsxs("div", { "data-slot": "alert-dialog-header", className: "flex items-start gap-ds-200 px-ds-300 pt-ds-300", children: [_jsx("span", { "data-slot": "alert-dialog-icon", className: cn("grid size-10 shrink-0 place-items-center rounded-ds-full", glyph.className), children: _jsx(IconGlyph, { name: icon ?? glyph.name }) }), _jsxs("div", { "data-slot": "alert-dialog-text", className: "flex min-w-0 flex-col gap-ds-050", children: [_jsx(Heading, { slot: "title", "data-slot": "alert-dialog-title", className: "m-0 text-heading-medium", children: title }), _jsx("div", { id: descriptionId, "data-slot": "alert-dialog-description", className: "text-body text-ds-text-subtle", children: children })] })] }), requireTypedConfirmation !== undefined && (_jsx("div", { "data-slot": "alert-dialog-body", className: "px-ds-300 pt-ds-200", children: _jsx(TextField, { label: typedConfirmationLabel ?? typeToConfirmLabel(locale, requireTypedConfirmation), value: typed, onChange: setTyped, placeholder: requireTypedConfirmation, appearance: "code", autoComplete: "off", isDisabled: pending }) })), _jsxs("div", { "data-slot": "alert-dialog-footer", className: cancelLabel?.trim() ? `${ALERT_FOOTER} ${CUSTOM_CANCEL_FOOTER}` : ALERT_FOOTER, children: [_jsx(Button, { ref: cancel, variant: "subtle", onPress: close, isDisabled: pending, "data-slot": "alert-dialog-cancel", children: cancelLabel?.trim() || defaultCancelLabel(locale) }), _jsx(Button, { variant: tone === "danger" ? "danger" : "primary", isDisabled: !ready || Boolean(isConfirmDisabled), isPending: pending, onPress: confirm, "data-slot": "alert-dialog-confirm", children: confirmLabel })] })] }));
437
- }
438
- /**
439
- * Confirms an action that destroys data, costs money or cannot be undone (role="alertdialog"). Not closed
440
- * by a scrim click; Esc cancels (not while the action runs); "Cancel" (or the app's `cancelLabel`) has the first focus. With
441
- * `requireTypedConfirmation` the action enables only once the text is typed. If the action can be undone,
442
- * skip it and offer "Undo" in a Toast. Opened from a menu whose trigger unmounts, or when the confirmed action
443
- * removes the opener, pass `returnFocusRef` so focus has somewhere to go back to.
444
- */
445
- export function AlertDialog({ isOpen, defaultOpen, onOpenChange, "aria-describedby": ariaDescribedBy, ...content }) {
446
- const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
447
- const descriptionId = React.useId();
448
- const [pending, setPending] = React.useState(false);
449
- const describedBy = ariaDescribedBy?.trim() ? `${descriptionId} ${ariaDescribedBy.trim()}` : descriptionId;
450
- return (
451
- // No scrim click (a stray tap must not answer it); Esc cancels, except while the action is running.
452
- _jsx(DialogFrame, { size: "small", role: "alertdialog", isDismissable: false, escapeCloses: !pending, describedBy: describedBy, isOpen: state.isOpen, onClose: state.close, children: _jsx(AlertContent, { ...content, descriptionId: descriptionId, close: state.close, pending: pending, setPending: setPending }) }));
453
- }
454
- /** Phones (below 640px) get the bottom sheet whatever the placement; decided after mount. */
455
- function useNarrow() {
456
- return React.useSyncExternalStore((notify) => {
457
- if (typeof window.matchMedia !== "function")
458
- return () => { };
459
- const query = window.matchMedia("(max-width: 639px)");
460
- query.addEventListener("change", notify);
461
- return () => query.removeEventListener("change", notify);
462
- }, () => typeof window.matchMedia === "function" && window.matchMedia("(max-width: 639px)").matches, () => false);
463
- }
464
- const DrawerCloseContext = React.createContext(() => { });
465
- /**
466
- * The drawer's close, for its footer or body. By default it asks first with unsaved edits, like the close
467
- * button, Esc and the scrim; after saving call `close({ force: true })`.
468
- */
469
- export function useDrawerClose() {
470
- return React.useContext(DrawerCloseContext);
471
- }
472
- /** Drag distance on the grip that counts as a swipe rather than a tap (px). */
473
- const SWIPE = 40;
474
- /** The sheet's grip: tap toggles half/full; swipe up expands, swipe down collapses (or closes from half). */
475
- function Grip({ expanded, onExpand, onCollapse, onDismiss }) {
476
- const { locale } = useLocale();
477
- const start = React.useRef(null);
478
- const moved = React.useRef(false);
479
- return (_jsx("button", { type: "button", "data-slot": "drawer-grip", "aria-label": expanded ? collapseSheetLabel(locale) : expandSheetLabel(locale), "aria-expanded": expanded, onPointerDown: (event) => {
480
- start.current = event.clientY;
481
- moved.current = false;
482
- // Keep the pointer while it drags past the 24px grip (touch is captured anyway; a mouse is not).
483
- event.currentTarget.setPointerCapture?.(event.pointerId);
484
- }, onPointerUp: (event) => {
485
- if (start.current === null)
486
- return;
487
- const dy = event.clientY - start.current;
488
- start.current = null;
489
- if (Math.abs(dy) < SWIPE)
490
- return;
491
- moved.current = true;
492
- if (dy < 0)
493
- onExpand();
494
- else if (expanded)
495
- onCollapse();
496
- else
497
- onDismiss();
498
- }, onClick: () => {
499
- if (moved.current) {
500
- moved.current = false;
501
- return;
502
- }
503
- if (expanded)
504
- onCollapse();
505
- else
506
- onExpand();
507
- }, className: "mx-auto mt-ds-100 grid h-6 w-full shrink-0 cursor-grab touch-none place-items-center outline-hidden focus-visible:inset-ring-2 focus-visible:inset-ring-ds-border-focused", children: _jsx("span", { "aria-hidden": true, className: "h-1 w-9 rounded-ds-full bg-ds-border-bold" }) }));
508
- }
509
- /** "Unsaved changes": a real nested modal (focus kept inside, the drawer behind it inert, Esc = keep editing). */
510
- function UnsavedPrompt({ isOpen, onKeep, onDiscard }) {
511
- const { locale } = useLocale();
512
- return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: (next) => {
513
- if (!next)
514
- onKeep();
515
- }, isDismissable: true, "data-slot": "drawer-unsaved-overlay", className: cn(BLANKET, "grid place-items-center p-ds-300"), children: _jsx(Modal, { "data-slot": "drawer-unsaved-modal", className: "w-full max-w-90 rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", children: _jsxs(AriaDialog, { role: "alertdialog", "data-slot": "drawer-unsaved", className: "flex flex-col gap-ds-150 p-ds-300 outline-hidden", children: [_jsx(Heading, { slot: "title", "data-slot": "drawer-unsaved-title", className: "m-0 text-heading-small", children: unsavedTitleLabel(locale) }), _jsx("span", { "data-slot": "drawer-unsaved-body", className: "text-body text-ds-text-subtle", children: unsavedBodyLabel(locale) }), _jsxs("div", { "data-slot": "drawer-unsaved-actions", className: "flex flex-wrap justify-end gap-ds-100", children: [_jsx(Button, { variant: "subtle", autoFocus: true, onPress: onKeep, "data-slot": "drawer-keep-editing", children: keepEditingLabel(locale) }), _jsx(Button, { variant: "danger", onPress: onDiscard, "data-slot": "drawer-discard", children: discardCloseLabel(locale) })] })] }) }) }));
516
- }
517
- /**
518
- * A panel over the page to show or edit one record without losing the list behind it: on the inline end
519
- * (380 or 560px, full height), a bottom sheet on phones that snaps between half and full height. Header with
520
- * title, subtitle and status; a scrolling body; a sticky footer; both keep clear of notches and the home
521
- * indicator. With unsaved edits every way of closing asks first. The title names the drawer and the
522
- * subtitle, when there is one, describes it.
523
- */
524
- export function Drawer({ size = "small", placement = "end", isOpen, defaultOpen, onOpenChange, hasUnsavedChanges, title, subtitle, headerActions, children, footer, }) {
525
- const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
526
- const subtitleId = React.useId();
527
- // Described only when there is a subtitle, as Dialog's description; otherwise the drawer's DOM is unchanged.
528
- const describedBy = hasDescription(subtitle) ? subtitleId : undefined;
529
- const narrow = useNarrow();
530
- const bottom = placement === "bottom" || narrow;
531
- const [expanded, setExpanded] = React.useState(false);
532
- // A sheet opens at half height every time. Reset as it opens, not as it closes, so the closing slide does
533
- // not also animate the height down.
534
- const [wasOpen, setWasOpen] = React.useState(state.isOpen);
535
- if (wasOpen !== state.isOpen) {
536
- setWasOpen(state.isOpen);
537
- if (state.isOpen)
538
- setExpanded(false);
539
- }
540
- const [asking, setAsking] = React.useState(false);
541
- // Every close request (button, Esc, scrim, grip swipe, useDrawerClose) comes through here.
542
- const request = () => (hasUnsavedChanges ? setAsking(true) : state.close());
543
- const close = (options) => (options?.force ? state.close() : request());
544
- return (_jsx(ModalOverlay, { isOpen: state.isOpen, onOpenChange: (next) => {
545
- if (!next)
546
- request();
547
- }, isDismissable: true, "data-slot": "drawer-overlay", "data-placement": bottom ? "bottom" : "end", className: BLANKET, children: _jsx(Modal, { "data-slot": "drawer", className: cn("fixed flex flex-col overflow-hidden bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", "transition-[translate,height] duration-(--ds-duration-slow) ease-ds-enter data-[exiting]:ease-ds-exit motion-reduce:transition-none", bottom
548
- ? cn("inset-x-0 bottom-0 rounded-t-ds-xlarge data-[entering]:translate-y-full data-[exiting]:translate-y-full", expanded ? "h-[calc(100dvh-env(safe-area-inset-top,0px)-var(--ds-space-200))]" : "h-[50dvh]")
549
- : cn(
550
- // Clear of a notch at the top and, in landscape, at the inline end.
551
- "inset-y-0 end-0 max-w-full pt-[env(safe-area-inset-top,0px)] pe-[env(safe-area-inset-right,0px)] rtl:pe-[env(safe-area-inset-left,0px)]", "data-[entering]:translate-x-full data-[exiting]:translate-x-full rtl:data-[entering]:-translate-x-full rtl:data-[exiting]:-translate-x-full", DRAWER_WIDTH[size])), children: _jsxs(AriaDialog, { "aria-describedby": describedBy, "data-slot": "drawer-dialog", className: DIALOG_ELEMENT, children: [_jsx(OverlayContents, { children: _jsxs(DrawerCloseContext.Provider, { value: close, children: [bottom && (_jsx(Grip, { expanded: expanded, onExpand: () => setExpanded(true), onCollapse: () => setExpanded(false), onDismiss: request })), _jsxs("div", { "data-slot": "drawer-header", className: "flex items-start justify-between gap-ds-200 border-b border-ds-border px-ds-300 py-ds-200", children: [_jsxs("div", { "data-slot": "drawer-heading", className: "flex min-w-0 flex-col gap-ds-025", children: [_jsx(Heading, { slot: "title", "data-slot": "drawer-title", className: "m-0 text-heading-medium", children: title }), describedBy && _jsx("span", { id: describedBy, "data-slot": "drawer-subtitle", className: "text-body-small text-ds-text-subtle", children: subtitle })] }), _jsxs("div", { "data-slot": "drawer-header-actions", className: "flex shrink-0 items-center gap-ds-100", children: [headerActions, _jsx(CloseButton, { "data-slot": "drawer-close", onPress: request })] })] }), _jsx("div", { "data-slot": "drawer-body", className: cn("min-h-0 flex-1 overflow-y-auto px-ds-300 pt-ds-200 text-body",
552
- // Without a footer the body is the last thing above the home indicator.
553
- footer ? "pb-ds-200" : "pb-[max(var(--ds-space-200),env(safe-area-inset-bottom,0px))]"), children: children }), footer && (_jsx("div", { "data-slot": "drawer-footer", className: "flex flex-wrap items-center justify-end gap-ds-100 border-t border-ds-border px-ds-300 pt-ds-150 pb-[max(var(--ds-space-150),env(safe-area-inset-bottom,0px))]", children: footer }))] }) }), _jsx(UnsavedPrompt, { isOpen: asking, onKeep: () => setAsking(false), onDiscard: () => {
554
- setAsking(false);
555
- state.close();
556
- } })] }) }) }));
557
- }
558
- //# sourceMappingURL=overlay.js.map