@sereno-ds/ui 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,6 +95,53 @@ export function Example() {
95
95
  }
96
96
  ```
97
97
 
98
+ ## Compound components
99
+
100
+ `Table`, `Tabs`, `SidebarNav`, `BottomNav`, `Stepper`, `Dialog` and `TopBar` are
101
+ the root plus dot-notated sub-parts — compose them like JSX, not a config
102
+ object/array:
103
+
104
+ ```tsx
105
+ import { Tabs } from '@sereno-ds/ui';
106
+
107
+ <Tabs value={tab} onChange={setTab} variant="pill">
108
+ <Tabs.List>
109
+ <Tabs.Tab value="today" count={5}>Today</Tabs.Tab>
110
+ <Tabs.Tab value="week" count={23}>Week</Tabs.Tab>
111
+ </Tabs.List>
112
+ <Tabs.Panel value="today">…</Tabs.Panel>
113
+ <Tabs.Panel value="week">…</Tabs.Panel>
114
+ </Tabs>;
115
+ ```
116
+
117
+ ```tsx
118
+ import { Dialog, Button } from '@sereno-ds/ui';
119
+
120
+ <Dialog open={open} onClose={close}>
121
+ <Dialog.Header title="Cancel booking?" description="This can't be undone.">
122
+ <Dialog.Close />
123
+ </Dialog.Header>
124
+ <Dialog.Body>…</Dialog.Body>
125
+ <Dialog.Footer>
126
+ <Button variant="ghost" onClick={close}>Back</Button>
127
+ <Button variant="error" onClick={confirm}>Cancel booking</Button>
128
+ </Dialog.Footer>
129
+ </Dialog>;
130
+ ```
131
+
132
+ - Only the root is exported — `Dialog.Header`, `Tabs.Tab`, etc. resolve to
133
+ `undefined` if imported from a Server Component. Everything compound needs
134
+ `'use client'` somewhere above it in the tree.
135
+ - Sub-parts outside their root throw at render (`` <Tabs.Tab> must be
136
+ rendered inside <Tabs>. ``) instead of failing silently.
137
+ - `Header` / `Footer` (`Dialog`), `List` / `Panel` (`Tabs`), `Section`
138
+ (`SidebarNav`) are optional — render only the sub-parts a given screen
139
+ needs.
140
+ - `Select` and `DateTimePicker` are hand-rolled but **not** compound — each
141
+ option / day is plain data (`options`, `times`), not JSX a consumer
142
+ composes. See each component's own JSDoc, or the showcase's Props tab, for
143
+ the rest of the sub-parts per component.
144
+
98
145
  ## Contract
99
146
 
100
147
  - **Tokens are required.** Components read only CSS custom properties (`--bg-*`, `--text-*`, `--border-*`, `--radius-*`, `--space-*`, `--font-*`, …). They live in `@sereno-ds/tokens`; without it, everything renders unstyled.
@@ -1,17 +1,31 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  /**
4
- * Modal (desktop), bottom sheet (mobile) or full-screen. Portalled to `<body>`
5
- * and fixed to the viewport, so no ancestor's `overflow`/`transform`/positioning
6
- * can trap it. While open it locks page scroll and closes on `Escape`. Host needs
7
- * the `sereno-pop` / `sereno-slide-up` keyframes (see globals.css).
4
+ * Modal (desktop), bottom sheet (mobile) or full-screen — a **compound
5
+ * component**. Portalled to `<body>` and fixed to the viewport, so no
6
+ * ancestor's `overflow`/`transform`/positioning can trap it. While open it
7
+ * locks page scroll and closes on `Escape`. Host needs the `sereno-pop` /
8
+ * `sereno-slide-up` keyframes (see globals.css).
9
+ *
10
+ * ```tsx
11
+ * <Dialog open={open} onClose={close} footer={false}>
12
+ * <Dialog.Header title="Cancel booking?" description="…">
13
+ * <Dialog.Close />
14
+ * </Dialog.Header>
15
+ * <Dialog.Body>…</Dialog.Body>
16
+ * <Dialog.Footer>
17
+ * <Button variant="ghost" onClick={close}>Back</Button>
18
+ * <Button variant="error" onClick={confirm}>Cancel booking</Button>
19
+ * </Dialog.Footer>
20
+ * </Dialog>
21
+ * ```
22
+ *
23
+ * `Dialog.Header` / `Dialog.Footer` are both optional — a dialog can be just
24
+ * a `Dialog.Body`. `Dialog.Close` goes wherever you put it (typically inside
25
+ * `Dialog.Header`); nothing renders a close button unless you add one.
8
26
  */
9
27
  interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
10
28
  open?: boolean;
11
- title?: string;
12
- description?: string;
13
- /** Action buttons, right-aligned. */
14
- footer?: React.ReactNode;
15
29
  onClose?: () => void;
16
30
  /** `sheet` slides up from the bottom (mobile default); `fullscreen` fills the viewport. */
17
31
  variant?: 'center' | 'sheet' | 'fullscreen';
@@ -19,18 +33,39 @@ interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
19
33
  size?: 'sm' | 'md' | 'lg' | 'xl';
20
34
  /** Hairline rules between header / body / footer, MUI-style. The body scrolls on its own. */
21
35
  dividers?: boolean;
22
- /** Show an ✕ in the header. Defaults to `true` for `fullscreen`, `false` otherwise. Needs `onClose`. */
23
- showClose?: boolean;
24
36
  /**
25
37
  * When `false`, a scrim click and `Escape` no longer close the dialog — only
26
- * the header ✕, a footer action, or `open={false}` do. Use it for a choice the
27
- * user must make explicitly. Defaults to `true`.
38
+ * `Dialog.Close`, a footer action, or `open={false}` do. Use it for a choice
39
+ * the user must make explicitly. Defaults to `true`.
28
40
  */
29
41
  dismissible?: boolean;
30
42
  /** Explicit pixel width — overrides `size`. */
31
43
  width?: number;
32
44
  children?: React.ReactNode;
33
45
  }
34
- declare function Dialog({ open, title, description, children, footer, onClose, variant, size, dividers, showClose, dismissible, width, style, ...rest }: DialogProps): React.ReactPortal | null;
46
+ interface DialogHeaderProps {
47
+ title?: string;
48
+ description?: string;
49
+ /** Extra content below the description — or the whole header, if you skip `title`/`description`. Put `Dialog.Close` here. */
50
+ children?: React.ReactNode;
51
+ }
52
+ interface DialogBodyProps {
53
+ children?: React.ReactNode;
54
+ }
55
+ interface DialogFooterProps {
56
+ /** Action buttons, right-aligned. */
57
+ children?: React.ReactNode;
58
+ }
59
+ declare function DialogRoot({ open, children, onClose, variant, size, dividers, dismissible, width, style, ...rest }: DialogProps): React.ReactPortal | null;
60
+ declare function Header({ title, description, children }: DialogHeaderProps): React.JSX.Element;
61
+ declare function Body({ children }: DialogBodyProps): React.JSX.Element;
62
+ declare function Footer({ children }: DialogFooterProps): React.JSX.Element;
63
+ declare function Close(): React.JSX.Element;
64
+ declare const Dialog: typeof DialogRoot & {
65
+ Header: typeof Header;
66
+ Body: typeof Body;
67
+ Footer: typeof Footer;
68
+ Close: typeof Close;
69
+ };
35
70
 
36
- export { Dialog, type DialogProps };
71
+ export { Dialog, type DialogBodyProps, type DialogFooterProps, type DialogHeaderProps, type DialogProps };
@@ -5,17 +5,19 @@ import { createPortal } from "react-dom";
5
5
  import { X } from "lucide-react";
6
6
  import { sx } from "../_internal/style";
7
7
  const SIZE_W = { sm: 440, md: 600, lg: 800, xl: 1e3 };
8
- function Dialog({
8
+ const DialogContext = React.createContext(null);
9
+ function useDialogContext(component) {
10
+ const ctx = React.useContext(DialogContext);
11
+ if (!ctx) throw new Error(`<Dialog.${component}> must be rendered inside <Dialog>.`);
12
+ return ctx;
13
+ }
14
+ function DialogRoot({
9
15
  open = true,
10
- title,
11
- description,
12
16
  children,
13
- footer,
14
17
  onClose,
15
18
  variant = "center",
16
19
  size = "sm",
17
20
  dividers = false,
18
- showClose,
19
21
  dismissible = true,
20
22
  width,
21
23
  style,
@@ -23,9 +25,8 @@ function Dialog({
23
25
  }) {
24
26
  const sheet = variant === "sheet";
25
27
  const full = variant === "fullscreen";
26
- const showX = (showClose ?? full) && !!onClose;
27
28
  const rid = React.useId();
28
- const titleId = title ? `${rid}-title` : void 0;
29
+ const titleId = `${rid}-title`;
29
30
  const [mounted, setMounted] = React.useState(false);
30
31
  React.useEffect(() => setMounted(true), []);
31
32
  const onCloseRef = React.useRef(onClose);
@@ -55,9 +56,10 @@ function Dialog({
55
56
  if (open && mounted) panelRef.current?.focus();
56
57
  }, [open, mounted]);
57
58
  if (!open || !mounted) return null;
58
- const pad = "var(--space-5)";
59
- const hairline = "var(--border-width-hairline) solid var(--border-default)";
60
- const hasHeader = !!(title || description || showX);
59
+ const items = React.Children.toArray(children);
60
+ const hasHeader = items.some((c) => React.isValidElement(c) && c.type === Header);
61
+ const hasFooter = items.some((c) => React.isValidElement(c) && c.type === Footer);
62
+ const ctx = { titleId, onClose, full, dividers, hasHeader, hasFooter };
61
63
  return createPortal(
62
64
  /* @__PURE__ */ jsx(
63
65
  "div",
@@ -80,8 +82,7 @@ function Dialog({
80
82
  ref: panelRef,
81
83
  role: "dialog",
82
84
  "aria-modal": "true",
83
- "aria-labelledby": titleId,
84
- "aria-label": titleId ? void 0 : title,
85
+ "aria-labelledby": hasHeader ? titleId : void 0,
85
86
  tabIndex: -1,
86
87
  onClick: (e) => e.stopPropagation(),
87
88
  ...rest,
@@ -95,7 +96,7 @@ function Dialog({
95
96
  outline: "none",
96
97
  background: "var(--bg-surface)",
97
98
  borderRadius: full ? 0 : sheet ? "var(--radius-sheet) var(--radius-sheet) 0 0" : "var(--radius-lg)",
98
- border: full ? "none" : hairline,
99
+ border: full ? "none" : "var(--border-width-hairline) solid var(--border-default)",
99
100
  boxShadow: full ? "none" : sheet ? "var(--shadow-sheet)" : "var(--shadow-lg)",
100
101
  animation: sheet ? "sereno-slide-up var(--duration-sheet) var(--ease-gentle)" : "sereno-pop var(--duration-normal) var(--ease-out)",
101
102
  ...style
@@ -108,102 +109,7 @@ function Dialog({
108
109
  style: sx({ width: 36, height: 4, borderRadius: "999px", background: "var(--border-strong)", alignSelf: "center", marginTop: "var(--space-2)", flex: "0 0 auto" })
109
110
  }
110
111
  ),
111
- hasHeader && /* @__PURE__ */ jsxs(
112
- "div",
113
- {
114
- style: sx({
115
- flex: "0 0 auto",
116
- display: "flex",
117
- alignItems: "flex-start",
118
- gap: "var(--space-3)",
119
- padding: dividers ? pad : `${pad} ${pad} var(--space-3)`,
120
- borderBottom: dividers ? hairline : void 0
121
- }),
122
- children: [
123
- /* @__PURE__ */ jsxs("div", { style: sx({ flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: "var(--space-2)" }), children: [
124
- title && /* @__PURE__ */ jsx(
125
- "h3",
126
- {
127
- id: titleId,
128
- style: sx({
129
- fontFamily: "var(--font-display)",
130
- fontSize: "var(--text-xl)",
131
- fontWeight: "var(--weight-bold)",
132
- letterSpacing: "var(--tracking-tight)",
133
- color: "var(--text-primary)",
134
- margin: 0
135
- }),
136
- children: title
137
- }
138
- ),
139
- description && /* @__PURE__ */ jsx(
140
- "p",
141
- {
142
- style: sx({
143
- fontFamily: "var(--font-body)",
144
- fontSize: "var(--text-base)",
145
- lineHeight: "var(--leading-normal)",
146
- color: "var(--text-secondary)",
147
- margin: 0
148
- }),
149
- children: description
150
- }
151
- )
152
- ] }),
153
- showX && /* @__PURE__ */ jsx(
154
- "button",
155
- {
156
- type: "button",
157
- className: "sereno-dialog-close",
158
- "aria-label": "Fechar",
159
- onClick: onClose,
160
- style: sx({
161
- flex: "0 0 auto",
162
- display: "inline-flex",
163
- alignItems: "center",
164
- justifyContent: "center",
165
- width: full ? 40 : 34,
166
- height: full ? 40 : 34,
167
- margin: full ? 0 : "-3px -5px 0 0",
168
- border: "none",
169
- borderRadius: "var(--radius-md)",
170
- background: full ? "var(--bg-subtle)" : "transparent",
171
- color: "var(--text-secondary)",
172
- cursor: "pointer"
173
- }),
174
- children: /* @__PURE__ */ jsx(X, { size: full ? 22 : 18, strokeWidth: 2 })
175
- }
176
- )
177
- ]
178
- }
179
- ),
180
- /* @__PURE__ */ jsx(
181
- "div",
182
- {
183
- style: sx({
184
- flex: full ? "1 1 auto" : "0 1 auto",
185
- minHeight: 0,
186
- overflowY: "auto",
187
- padding: dividers ? pad : hasHeader ? `0 ${pad} ${footer ? "var(--space-3)" : pad}` : pad
188
- }),
189
- children
190
- }
191
- ),
192
- footer && /* @__PURE__ */ jsx(
193
- "div",
194
- {
195
- style: sx({
196
- flex: "0 0 auto",
197
- display: "flex",
198
- gap: "var(--space-3)",
199
- justifyContent: "flex-end",
200
- flexWrap: "wrap",
201
- padding: dividers ? pad : `0 ${pad} ${pad}`,
202
- borderTop: dividers ? hairline : void 0
203
- }),
204
- children: footer
205
- }
206
- )
112
+ /* @__PURE__ */ jsx(DialogContext.Provider, { value: ctx, children })
207
113
  ]
208
114
  }
209
115
  )
@@ -212,6 +118,124 @@ function Dialog({
212
118
  document.body
213
119
  );
214
120
  }
121
+ function Header({ title, description, children }) {
122
+ const { titleId, dividers } = useDialogContext("Header");
123
+ const pad = "var(--space-5)";
124
+ const hairline = "var(--border-width-hairline) solid var(--border-default)";
125
+ const items = React.Children.toArray(children);
126
+ const closeEl = items.find((c) => React.isValidElement(c) && c.type === Close);
127
+ const extra = items.filter((c) => c !== closeEl);
128
+ return /* @__PURE__ */ jsxs(
129
+ "div",
130
+ {
131
+ style: sx({
132
+ flex: "0 0 auto",
133
+ display: "flex",
134
+ alignItems: "flex-start",
135
+ gap: "var(--space-3)",
136
+ padding: dividers ? pad : `${pad} ${pad} var(--space-3)`,
137
+ borderBottom: dividers ? hairline : void 0
138
+ }),
139
+ children: [
140
+ /* @__PURE__ */ jsxs("div", { id: titleId, style: sx({ flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: "var(--space-2)" }), children: [
141
+ title && /* @__PURE__ */ jsx(
142
+ "h3",
143
+ {
144
+ style: sx({
145
+ fontFamily: "var(--font-display)",
146
+ fontSize: "var(--text-xl)",
147
+ fontWeight: "var(--weight-bold)",
148
+ letterSpacing: "var(--tracking-tight)",
149
+ color: "var(--text-primary)",
150
+ margin: 0
151
+ }),
152
+ children: title
153
+ }
154
+ ),
155
+ description && /* @__PURE__ */ jsx(
156
+ "p",
157
+ {
158
+ style: sx({
159
+ fontFamily: "var(--font-body)",
160
+ fontSize: "var(--text-base)",
161
+ lineHeight: "var(--leading-normal)",
162
+ color: "var(--text-secondary)",
163
+ margin: 0
164
+ }),
165
+ children: description
166
+ }
167
+ ),
168
+ extra
169
+ ] }),
170
+ closeEl
171
+ ]
172
+ }
173
+ );
174
+ }
175
+ function Body({ children }) {
176
+ const { dividers, hasHeader, hasFooter, full } = useDialogContext("Body");
177
+ const pad = "var(--space-5)";
178
+ return /* @__PURE__ */ jsx(
179
+ "div",
180
+ {
181
+ style: sx({
182
+ flex: full ? "1 1 auto" : "0 1 auto",
183
+ minHeight: 0,
184
+ overflowY: "auto",
185
+ padding: dividers ? pad : hasHeader ? `0 ${pad} ${hasFooter ? "var(--space-3)" : pad}` : pad
186
+ }),
187
+ children
188
+ }
189
+ );
190
+ }
191
+ function Footer({ children }) {
192
+ const { dividers } = useDialogContext("Footer");
193
+ const pad = "var(--space-5)";
194
+ const hairline = "var(--border-width-hairline) solid var(--border-default)";
195
+ return /* @__PURE__ */ jsx(
196
+ "div",
197
+ {
198
+ style: sx({
199
+ flex: "0 0 auto",
200
+ display: "flex",
201
+ gap: "var(--space-3)",
202
+ justifyContent: "flex-end",
203
+ flexWrap: "wrap",
204
+ padding: dividers ? pad : `0 ${pad} ${pad}`,
205
+ borderTop: dividers ? hairline : void 0
206
+ }),
207
+ children
208
+ }
209
+ );
210
+ }
211
+ function Close() {
212
+ const { onClose, full } = useDialogContext("Close");
213
+ return /* @__PURE__ */ jsx(
214
+ "button",
215
+ {
216
+ type: "button",
217
+ className: "sereno-dialog-close",
218
+ "aria-label": "Fechar",
219
+ onClick: onClose,
220
+ style: sx({
221
+ flex: "0 0 auto",
222
+ display: "inline-flex",
223
+ alignItems: "center",
224
+ justifyContent: "center",
225
+ width: full ? 40 : 34,
226
+ height: full ? 40 : 34,
227
+ margin: full ? 0 : "-3px -5px 0 0",
228
+ border: "none",
229
+ borderRadius: "var(--radius-md)",
230
+ background: full ? "var(--bg-subtle)" : "transparent",
231
+ color: "var(--text-secondary)",
232
+ cursor: "pointer"
233
+ }),
234
+ children: /* @__PURE__ */ jsx(X, { size: full ? 22 : 18, strokeWidth: 2 })
235
+ }
236
+ );
237
+ }
238
+ const Dialog = Object.assign(DialogRoot, { Header, Body, Footer, Close });
215
239
  export {
216
240
  Dialog
217
241
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/Dialog.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { X } from 'lucide-react';\nimport { sx } from '../_internal/style';\n\n/**\n * Modal (desktop), bottom sheet (mobile) or full-screen. Portalled to `<body>`\n * and fixed to the viewport, so no ancestor's `overflow`/`transform`/positioning\n * can trap it. While open it locks page scroll and closes on `Escape`. Host needs\n * the `sereno-pop` / `sereno-slide-up` keyframes (see globals.css).\n */\nexport interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n title?: string;\n description?: string;\n /** Action buttons, right-aligned. */\n footer?: React.ReactNode;\n onClose?: () => void;\n /** `sheet` slides up from the bottom (mobile default); `fullscreen` fills the viewport. */\n variant?: 'center' | 'sheet' | 'fullscreen';\n /** Max width of the centered modal. Ignored for `sheet` / `fullscreen`. */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n /** Hairline rules between header / body / footer, MUI-style. The body scrolls on its own. */\n dividers?: boolean;\n /** Show an ✕ in the header. Defaults to `true` for `fullscreen`, `false` otherwise. Needs `onClose`. */\n showClose?: boolean;\n /**\n * When `false`, a scrim click and `Escape` no longer close the dialog — only\n * the header ✕, a footer action, or `open={false}` do. Use it for a choice the\n * user must make explicitly. Defaults to `true`.\n */\n dismissible?: boolean;\n /** Explicit pixel width — overrides `size`. */\n width?: number;\n children?: React.ReactNode;\n}\n\nconst SIZE_W = { sm: 440, md: 600, lg: 800, xl: 1000 } as const;\n\nexport function Dialog({\n open = true,\n title,\n description,\n children,\n footer,\n onClose,\n variant = 'center',\n size = 'sm',\n dividers = false,\n showClose,\n dismissible = true,\n width,\n style,\n ...rest\n}: DialogProps) {\n const sheet = variant === 'sheet';\n const full = variant === 'fullscreen';\n const showX = (showClose ?? full) && !!onClose;\n const rid = React.useId();\n const titleId = title ? `${rid}-title` : undefined;\n\n // Portal target is client-only.\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n\n // While open: lock page scroll and bind Escape to close. `onClose` / `dismissible`\n // are read through refs so the lock effect only re-runs when `open` flips.\n const onCloseRef = React.useRef(onClose);\n const dismissibleRef = React.useRef(dismissible);\n React.useEffect(() => {\n onCloseRef.current = onClose;\n dismissibleRef.current = dismissible;\n });\n React.useEffect(() => {\n if (!open) return;\n const root = document.documentElement;\n const prev = { h: root.style.overflow, b: document.body.style.overflow };\n root.style.overflow = 'hidden';\n document.body.style.overflow = 'hidden';\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && dismissibleRef.current) onCloseRef.current?.();\n };\n document.addEventListener('keydown', onKey);\n return () => {\n root.style.overflow = prev.h;\n document.body.style.overflow = prev.b;\n document.removeEventListener('keydown', onKey);\n };\n }, [open]);\n\n // Pull focus into the dialog when it opens.\n const panelRef = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n if (open && mounted) panelRef.current?.focus();\n }, [open, mounted]);\n\n if (!open || !mounted) return null;\n\n const pad = 'var(--space-5)';\n const hairline = 'var(--border-width-hairline) solid var(--border-default)';\n const hasHeader = !!(title || description || showX);\n\n return createPortal(\n <div\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1000,\n display: 'flex',\n alignItems: sheet ? 'flex-end' : 'center',\n justifyContent: 'center',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n padding: sheet || full ? 0 : 'var(--space-5)',\n })}\n onClick={dismissible ? onClose : undefined}\n >\n <div\n ref={panelRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-label={titleId ? undefined : title}\n tabIndex={-1}\n onClick={(e) => e.stopPropagation()}\n {...rest}\n style={sx({\n width: full || sheet ? '100%' : 'min(100%,' + (width ?? SIZE_W[size]) + 'px)',\n height: full ? '100%' : undefined,\n maxHeight: full ? undefined : sheet ? '90dvh' : 'calc(100dvh - var(--space-6))',\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n outline: 'none',\n background: 'var(--bg-surface)',\n borderRadius: full ? 0 : sheet ? 'var(--radius-sheet) var(--radius-sheet) 0 0' : 'var(--radius-lg)',\n border: full ? 'none' : hairline,\n boxShadow: full ? 'none' : sheet ? 'var(--shadow-sheet)' : 'var(--shadow-lg)',\n animation: sheet ? 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)' : 'sereno-pop var(--duration-normal) var(--ease-out)',\n ...style,\n })}\n >\n {sheet && (\n <span\n aria-hidden\n style={sx({ width: 36, height: 4, borderRadius: '999px', background: 'var(--border-strong)', alignSelf: 'center', marginTop: 'var(--space-2)', flex: '0 0 auto' })}\n />\n )}\n\n {hasHeader && (\n <div\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'flex-start',\n gap: 'var(--space-3)',\n padding: dividers ? pad : `${pad} ${pad} var(--space-3)`,\n borderBottom: dividers ? hairline : undefined,\n })}\n >\n <div style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 'var(--space-2)' })}>\n {title && (\n <h3\n id={titleId}\n style={sx({\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-xl)',\n fontWeight: 'var(--weight-bold)',\n letterSpacing: 'var(--tracking-tight)',\n color: 'var(--text-primary)',\n margin: 0,\n })}\n >\n {title}\n </h3>\n )}\n {description && (\n <p\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n lineHeight: 'var(--leading-normal)',\n color: 'var(--text-secondary)',\n margin: 0,\n })}\n >\n {description}\n </p>\n )}\n </div>\n {showX && (\n <button\n type=\"button\"\n className=\"sereno-dialog-close\"\n aria-label=\"Fechar\"\n onClick={onClose}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: full ? 40 : 34,\n height: full ? 40 : 34,\n margin: full ? 0 : '-3px -5px 0 0',\n border: 'none',\n borderRadius: 'var(--radius-md)',\n background: full ? 'var(--bg-subtle)' : 'transparent',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <X size={full ? 22 : 18} strokeWidth={2} />\n </button>\n )}\n </div>\n )}\n\n <div\n style={sx({\n flex: full ? '1 1 auto' : '0 1 auto',\n minHeight: 0,\n overflowY: 'auto',\n padding: dividers\n ? pad\n : hasHeader\n ? `0 ${pad} ${footer ? 'var(--space-3)' : pad}`\n : pad,\n })}\n >\n {children}\n </div>\n\n {footer && (\n <div\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n gap: 'var(--space-3)',\n justifyContent: 'flex-end',\n flexWrap: 'wrap',\n padding: dividers ? pad : `0 ${pad} ${pad}`,\n borderTop: dividers ? hairline : undefined,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";AAkJU,cAiBE,YAjBF;AAhJV,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,UAAU;AAkCnB,MAAM,SAAS,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAK;AAE9C,SAAS,OAAO;AAAA,EACrB,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,WAAW;AAAA,EACX;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAgB;AACd,QAAM,QAAQ,YAAY;AAC1B,QAAM,OAAO,YAAY;AACzB,QAAM,SAAS,aAAa,SAAS,CAAC,CAAC;AACvC,QAAM,MAAM,MAAM,MAAM;AACxB,QAAM,UAAU,QAAQ,GAAG,GAAG,WAAW;AAGzC,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAS,KAAK;AAElD,QAAM,UAAU,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAI1C,QAAM,aAAa,MAAM,OAAO,OAAO;AACvC,QAAM,iBAAiB,MAAM,OAAO,WAAW;AAC/C,QAAM,UAAU,MAAM;AACpB,eAAW,UAAU;AACrB,mBAAe,UAAU;AAAA,EAC3B,CAAC;AACD,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,KAAM;AACX,UAAM,OAAO,SAAS;AACtB,UAAM,OAAO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;AAAA,kBACnC,CAAC;AAAA,kBAEA;AAAA;AAAA,cACH;AAAA;AAAA;AAAA,QAEJ;AAAA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/Dialog.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { X } from 'lucide-react';\nimport { sx } from '../_internal/style';\n\n/**\n * Modal (desktop), bottom sheet (mobile) or full-screen — a **compound\n * component**. Portalled to `<body>` and fixed to the viewport, so no\n * ancestor's `overflow`/`transform`/positioning can trap it. While open it\n * locks page scroll and closes on `Escape`. Host needs the `sereno-pop` /\n * `sereno-slide-up` keyframes (see globals.css).\n *\n * ```tsx\n * <Dialog open={open} onClose={close} footer={false}>\n * <Dialog.Header title=\"Cancel booking?\" description=\"…\">\n * <Dialog.Close />\n * </Dialog.Header>\n * <Dialog.Body>…</Dialog.Body>\n * <Dialog.Footer>\n * <Button variant=\"ghost\" onClick={close}>Back</Button>\n * <Button variant=\"error\" onClick={confirm}>Cancel booking</Button>\n * </Dialog.Footer>\n * </Dialog>\n * ```\n *\n * `Dialog.Header` / `Dialog.Footer` are both optional — a dialog can be just\n * a `Dialog.Body`. `Dialog.Close` goes wherever you put it (typically inside\n * `Dialog.Header`); nothing renders a close button unless you add one.\n */\nexport interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n onClose?: () => void;\n /** `sheet` slides up from the bottom (mobile default); `fullscreen` fills the viewport. */\n variant?: 'center' | 'sheet' | 'fullscreen';\n /** Max width of the centered modal. Ignored for `sheet` / `fullscreen`. */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n /** Hairline rules between header / body / footer, MUI-style. The body scrolls on its own. */\n dividers?: boolean;\n /**\n * When `false`, a scrim click and `Escape` no longer close the dialog — only\n * `Dialog.Close`, a footer action, or `open={false}` do. Use it for a choice\n * the user must make explicitly. Defaults to `true`.\n */\n dismissible?: boolean;\n /** Explicit pixel width — overrides `size`. */\n width?: number;\n children?: React.ReactNode;\n}\n\nexport interface DialogHeaderProps {\n title?: string;\n description?: string;\n /** Extra content below the description — or the whole header, if you skip `title`/`description`. Put `Dialog.Close` here. */\n children?: React.ReactNode;\n}\n\nexport interface DialogBodyProps {\n children?: React.ReactNode;\n}\n\nexport interface DialogFooterProps {\n /** Action buttons, right-aligned. */\n children?: React.ReactNode;\n}\n\ninterface DialogContextValue {\n titleId: string;\n onClose?: () => void;\n full: boolean;\n dividers: boolean;\n hasHeader: boolean;\n hasFooter: boolean;\n}\n\nconst SIZE_W = { sm: 440, md: 600, lg: 800, xl: 1000 } as const;\n\nconst DialogContext = React.createContext<DialogContextValue | null>(null);\n\nfunction useDialogContext(component: string): DialogContextValue {\n const ctx = React.useContext(DialogContext);\n if (!ctx) throw new Error(`<Dialog.${component}> must be rendered inside <Dialog>.`);\n return ctx;\n}\n\nfunction DialogRoot({\n open = true,\n children,\n onClose,\n variant = 'center',\n size = 'sm',\n dividers = false,\n dismissible = true,\n width,\n style,\n ...rest\n}: DialogProps) {\n const sheet = variant === 'sheet';\n const full = variant === 'fullscreen';\n const rid = React.useId();\n const titleId = `${rid}-title`;\n\n // Portal target is client-only.\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n\n // While open: lock page scroll and bind Escape to close. `onClose` / `dismissible`\n // are read through refs so the lock effect only re-runs when `open` flips.\n const onCloseRef = React.useRef(onClose);\n const dismissibleRef = React.useRef(dismissible);\n React.useEffect(() => {\n onCloseRef.current = onClose;\n dismissibleRef.current = dismissible;\n });\n React.useEffect(() => {\n if (!open) return;\n const root = document.documentElement;\n const prev = { h: root.style.overflow, b: document.body.style.overflow };\n root.style.overflow = 'hidden';\n document.body.style.overflow = 'hidden';\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && dismissibleRef.current) onCloseRef.current?.();\n };\n document.addEventListener('keydown', onKey);\n return () => {\n root.style.overflow = prev.h;\n document.body.style.overflow = prev.b;\n document.removeEventListener('keydown', onKey);\n };\n }, [open]);\n\n // Pull focus into the dialog when it opens.\n const panelRef = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n if (open && mounted) panelRef.current?.focus();\n }, [open, mounted]);\n\n if (!open || !mounted) return null;\n\n // Body/Footer padding depends on whether a Header/Footer is actually\n // present — read straight off the children, the same technique\n // SidebarNav.Item / Stepper use for data they need before render.\n const items = React.Children.toArray(children);\n const hasHeader = items.some((c) => React.isValidElement(c) && c.type === Header);\n const hasFooter = items.some((c) => React.isValidElement(c) && c.type === Footer);\n\n const ctx: DialogContextValue = { titleId, onClose, full, dividers, hasHeader, hasFooter };\n\n return createPortal(\n <div\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1000,\n display: 'flex',\n alignItems: sheet ? 'flex-end' : 'center',\n justifyContent: 'center',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n padding: sheet || full ? 0 : 'var(--space-5)',\n })}\n onClick={dismissible ? onClose : undefined}\n >\n <div\n ref={panelRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={hasHeader ? titleId : undefined}\n tabIndex={-1}\n onClick={(e) => e.stopPropagation()}\n {...rest}\n style={sx({\n width: full || sheet ? '100%' : 'min(100%,' + (width ?? SIZE_W[size]) + 'px)',\n height: full ? '100%' : undefined,\n maxHeight: full ? undefined : sheet ? '90dvh' : 'calc(100dvh - var(--space-6))',\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n outline: 'none',\n background: 'var(--bg-surface)',\n borderRadius: full ? 0 : sheet ? 'var(--radius-sheet) var(--radius-sheet) 0 0' : 'var(--radius-lg)',\n border: full ? 'none' : 'var(--border-width-hairline) solid var(--border-default)',\n boxShadow: full ? 'none' : sheet ? 'var(--shadow-sheet)' : 'var(--shadow-lg)',\n animation: sheet ? 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)' : 'sereno-pop var(--duration-normal) var(--ease-out)',\n ...style,\n })}\n >\n {sheet && (\n <span\n aria-hidden\n style={sx({ width: 36, height: 4, borderRadius: '999px', background: 'var(--border-strong)', alignSelf: 'center', marginTop: 'var(--space-2)', flex: '0 0 auto' })}\n />\n )}\n <DialogContext.Provider value={ctx}>{children}</DialogContext.Provider>\n </div>\n </div>,\n document.body,\n );\n}\n\nfunction Header({ title, description, children }: DialogHeaderProps) {\n const { titleId, dividers } = useDialogContext('Header');\n const pad = 'var(--space-5)';\n const hairline = 'var(--border-width-hairline) solid var(--border-default)';\n\n const items = React.Children.toArray(children);\n const closeEl = items.find((c) => React.isValidElement(c) && c.type === Close);\n const extra = items.filter((c) => c !== closeEl);\n\n return (\n <div\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'flex-start',\n gap: 'var(--space-3)',\n padding: dividers ? pad : `${pad} ${pad} var(--space-3)`,\n borderBottom: dividers ? hairline : undefined,\n })}\n >\n <div id={titleId} style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 'var(--space-2)' })}>\n {title && (\n <h3\n style={sx({\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-xl)',\n fontWeight: 'var(--weight-bold)',\n letterSpacing: 'var(--tracking-tight)',\n color: 'var(--text-primary)',\n margin: 0,\n })}\n >\n {title}\n </h3>\n )}\n {description && (\n <p\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n lineHeight: 'var(--leading-normal)',\n color: 'var(--text-secondary)',\n margin: 0,\n })}\n >\n {description}\n </p>\n )}\n {extra}\n </div>\n {closeEl}\n </div>\n );\n}\n\nfunction Body({ children }: DialogBodyProps) {\n const { dividers, hasHeader, hasFooter, full } = useDialogContext('Body');\n const pad = 'var(--space-5)';\n return (\n <div\n style={sx({\n flex: full ? '1 1 auto' : '0 1 auto',\n minHeight: 0,\n overflowY: 'auto',\n padding: dividers ? pad : hasHeader ? `0 ${pad} ${hasFooter ? 'var(--space-3)' : pad}` : pad,\n })}\n >\n {children}\n </div>\n );\n}\n\nfunction Footer({ children }: DialogFooterProps) {\n const { dividers } = useDialogContext('Footer');\n const pad = 'var(--space-5)';\n const hairline = 'var(--border-width-hairline) solid var(--border-default)';\n return (\n <div\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n gap: 'var(--space-3)',\n justifyContent: 'flex-end',\n flexWrap: 'wrap',\n padding: dividers ? pad : `0 ${pad} ${pad}`,\n borderTop: dividers ? hairline : undefined,\n })}\n >\n {children}\n </div>\n );\n}\n\nfunction Close() {\n const { onClose, full } = useDialogContext('Close');\n return (\n <button\n type=\"button\"\n className=\"sereno-dialog-close\"\n aria-label=\"Fechar\"\n onClick={onClose}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: full ? 40 : 34,\n height: full ? 40 : 34,\n margin: full ? 0 : '-3px -5px 0 0',\n border: 'none',\n borderRadius: 'var(--radius-md)',\n background: full ? 'var(--bg-subtle)' : 'transparent',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <X size={full ? 22 : 18} strokeWidth={2} />\n </button>\n );\n}\n\nexport const Dialog = Object.assign(DialogRoot, { Header, Body, Footer, Close });\n"],"mappings":";AAqKM,SAyBI,KAzBJ;AAnKN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,UAAU;AAuEnB,MAAM,SAAS,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAK;AAErD,MAAM,gBAAgB,MAAM,cAAyC,IAAI;AAEzE,SAAS,iBAAiB,WAAuC;AAC/D,QAAM,MAAM,MAAM,WAAW,aAAa;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,WAAW,SAAS,qCAAqC;AACnF,SAAO;AACT;AAEA,SAAS,WAAW;AAAA,EAClB,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV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;AAAA,QACnB,QAAQ,OAAO,KAAK;AAAA,QACpB,QAAQ,OAAO,IAAI;AAAA,QACnB,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,YAAY,OAAO,qBAAqB;AAAA,QACxC,OAAO;AAAA,QACP,QAAQ;AAAA,MACV,CAAC;AAAA,MAED,8BAAC,KAAE,MAAM,OAAO,KAAK,IAAI,aAAa,GAAG;AAAA;AAAA,EAC3C;AAEJ;AAEO,MAAM,SAAS,OAAO,OAAO,YAAY,EAAE,QAAQ,MAAM,QAAQ,MAAM,CAAC;","names":[]}
@@ -134,7 +134,12 @@ function ToastProvider({ children, position = "bottom-right", max = 3, duration
134
134
  // Every toast is full-width of the viewport, so the stack edges line up on
135
135
  // any side; `alignItems` only matters if a toast were ever narrower.
136
136
  alignItems: "stretch",
137
- ...side === "center" ? { left: "50%", transform: "translateX(-50%)" } : { [side]: 0 }
137
+ // An *outer* offset on top of the padding above, not just the padding
138
+ // itself — macOS Safari's overlay scrollbar floats over the page rather
139
+ // than reducing its width, so a left/right edge flush at 0 can end up
140
+ // with the scrollbar painted right where the padding was supposed to be
141
+ // the toast's only clearance from the edge.
142
+ ...side === "center" ? { left: "50%", transform: "translateX(-50%)" } : { [side]: "var(--space-2)" }
138
143
  });
139
144
  return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
140
145
  children,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/ToastProvider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Toast, type ToastProps } from './Toast';\nimport { sx } from '../_internal/style';\n\n/**\n * The toast *system* — a portal viewport plus a queue — layered on top of the\n * presentational `Toast`. Wrap the app once:\n *\n * ```tsx\n * <ToastProvider position=\"bottom-right\">\n * <App />\n * </ToastProvider>\n * ```\n *\n * then fire from anywhere under it:\n *\n * ```tsx\n * const { toast, dismiss } = useToast();\n * toast.success('Booking confirmed', { description: 'The client was notified.' });\n * toast('Link copied'); // neutral, title only\n * const id = toast.info('Syncing…', { duration: 0 }); // sticks until dismiss(id)\n * ```\n *\n * Toasts stack (newest nearest the edge), show a countdown bar, auto-dismiss\n * after `duration`, pause that timer (and the bar) while hovered/focused, and\n * cap at `max` — the oldest drops. Needs the `sereno-toast-*` keyframes from\n * `@sereno-ds/ui/styles.css`.\n */\n\ntype Tone = NonNullable<ToastProps['tone']>;\n\nexport interface ToastOptions {\n title: string;\n description?: string;\n tone?: Tone;\n icon?: React.ReactNode;\n /** Inline control on the right — an \"Undo\" / \"View\" `Button variant=\"link\"`. */\n action?: React.ReactNode;\n /** ms until auto-dismiss. `0` (or `Infinity`) keeps it until dismissed. Defaults to the provider's `duration`. */\n duration?: number;\n}\n\n/** `msg` shorthand: a bare string becomes the `title`; an object is the full options. */\nexport type ToastInput = string | ToastOptions;\n\ntype ToneFn = (msg: ToastInput, opts?: Partial<ToastOptions>) => string;\n\nexport interface ToastApi {\n /** `toast('Saved')` or `toast('Saved', { description, action, duration })`. Neutral tone. */\n (msg: ToastInput, opts?: Partial<ToastOptions>): string;\n success: ToneFn;\n error: ToneFn;\n warning: ToneFn;\n info: ToneFn;\n neutral: ToneFn;\n}\n\nexport interface ToastContextValue {\n toast: ToastApi;\n /** `dismiss(id)` removes one; `dismiss()` clears them all. */\n dismiss: (id?: string) => void;\n}\n\nconst ToastContext = React.createContext<ToastContextValue | null>(null);\n\nexport type ToastPosition =\n | 'bottom-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'top-right'\n | 'top-left'\n | 'top-center';\n\nexport interface ToastProviderProps {\n children: React.ReactNode;\n /** Viewport corner. Default `bottom-right`. */\n position?: ToastPosition;\n /** Most toasts on screen at once; the oldest drops when a new one arrives. Default `3`. */\n max?: number;\n /** Default auto-dismiss, in ms. Default `4000`. */\n duration?: number;\n}\n\ninterface Entry extends ToastOptions {\n id: string;\n /** Resolved auto-dismiss (ms) — `opts.duration ?? provider duration`. `0` / `Infinity` = sticky. */\n ms: number;\n leaving?: boolean;\n}\n\nconst EXIT_MS = 180;\nlet seq = 0;\nconst nextId = () => `t${Date.now().toString(36)}-${(seq++).toString(36)}`;\n\nconst norm = (msg: ToastInput): Partial<ToastOptions> => (typeof msg === 'string' ? { title: msg } : msg);\nconst timed = (ms: number) => ms > 0 && Number.isFinite(ms);\n\nexport function ToastProvider({ children, position = 'bottom-right', max = 3, duration = 4000 }: ToastProviderProps) {\n const [entries, setEntries] = React.useState<Entry[]>([]);\n const [pausedIds, setPausedIds] = React.useState<ReadonlySet<string>>(() => new Set());\n\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n\n // Per-toast auto-dismiss timers, so hover/focus can pause and resume them.\n const timers = React.useRef(new Map<string, { handle: ReturnType<typeof setTimeout>; endsAt: number; left: number }>());\n\n const forget = React.useCallback((id: string) => {\n setPausedIds((s) => {\n if (!s.has(id)) return s;\n const n = new Set(s);\n n.delete(id);\n return n;\n });\n }, []);\n\n const drop = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) clearTimeout(t.handle);\n timers.current.delete(id);\n setEntries((list) => list.map((e) => (e.id === id ? { ...e, leaving: true } : e)));\n setTimeout(() => {\n setEntries((list) => list.filter((e) => e.id !== id));\n forget(id);\n }, EXIT_MS);\n },\n [forget],\n );\n\n const arm = React.useCallback(\n (id: string, ms: number) => {\n if (!timed(ms)) return;\n const handle = setTimeout(() => drop(id), ms);\n timers.current.set(id, { handle, endsAt: Date.now() + ms, left: ms });\n },\n [drop],\n );\n\n const pause = React.useCallback((id: string) => {\n const t = timers.current.get(id);\n if (!t) return;\n clearTimeout(t.handle);\n t.left = Math.max(0, t.endsAt - Date.now());\n setPausedIds((s) => (s.has(id) ? s : new Set(s).add(id)));\n }, []);\n\n const resume = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) {\n t.handle = setTimeout(() => drop(id), t.left);\n t.endsAt = Date.now() + t.left;\n }\n forget(id);\n },\n [drop, forget],\n );\n\n const add = React.useCallback(\n (opts: ToastOptions) => {\n const id = nextId();\n const ms = opts.duration ?? duration;\n setEntries((list) => {\n const next: Entry[] = [...list, { ...opts, id, ms }];\n // Cap: hard-drop the oldest that isn't already leaving.\n while (next.filter((e) => !e.leaving).length > max) {\n const victim = next.find((e) => !e.leaving);\n if (!victim) break;\n const vt = timers.current.get(victim.id);\n if (vt) clearTimeout(vt.handle);\n timers.current.delete(victim.id);\n victim.leaving = true;\n setTimeout(() => {\n setEntries((l) => l.filter((e) => e.id !== victim.id));\n forget(victim.id);\n }, EXIT_MS);\n }\n return next;\n });\n arm(id, ms);\n return id;\n },\n [arm, duration, forget, max],\n );\n\n // Tone-specific methods always paint their tone; bare `toast(...)` respects a\n // `tone` in the message / options and otherwise stays neutral.\n const fire = React.useCallback(\n (msg: ToastInput, opts?: Partial<ToastOptions>, tone?: Tone) =>\n add({ title: '', ...norm(msg), ...opts, ...(tone ? { tone } : {}) } as ToastOptions),\n [add],\n );\n\n /* eslint-disable react-hooks/refs -- `fire` transitively reaches the `timers` ref, but only when a\n consumer invokes toast.*() from an event handler — never during render. `useMemo` just keeps\n the callable API object's identity stable. */\n const toast = React.useMemo<ToastApi>(() => {\n const base = (msg: ToastInput, opts?: Partial<ToastOptions>) => fire(msg, opts);\n const make = (tone: Tone): ToneFn => (msg, opts) => fire(msg, opts, tone);\n return Object.assign(base, {\n success: make('success'),\n error: make('error'),\n warning: make('warning'),\n info: make('info'),\n neutral: make('neutral'),\n }) as ToastApi;\n }, [fire]);\n /* eslint-enable react-hooks/refs */\n\n const dismiss = React.useCallback(\n (id?: string) => {\n if (id) {\n drop(id);\n return;\n }\n entries.forEach((e) => !e.leaving && drop(e.id));\n },\n [drop, entries],\n );\n\n const value = React.useMemo<ToastContextValue>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // Clear every pending timer on unmount.\n React.useEffect(() => {\n const map = timers.current;\n return () => map.forEach((t) => clearTimeout(t.handle));\n }, []);\n\n const [edge, side] = position.split('-') as ['top' | 'bottom', 'right' | 'left' | 'center'];\n const viewport = sx({\n position: 'fixed',\n zIndex: 1200,\n display: 'flex',\n // Newest nearest the anchored edge: normal flow for bottom, reversed for top.\n flexDirection: edge === 'bottom' ? 'column' : 'column-reverse',\n gap: 'var(--space-3)',\n width: 'min(420px, calc(100vw - var(--space-8)))',\n maxHeight: '100dvh',\n padding: 'var(--space-4)',\n pointerEvents: 'none',\n [edge]: 0,\n // Every toast is full-width of the viewport, so the stack edges line up on\n // any side; `alignItems` only matters if a toast were ever narrower.\n alignItems: 'stretch',\n ...(side === 'center' ? { left: '50%', transform: 'translateX(-50%)' } : { [side]: 0 }),\n });\n\n return (\n <ToastContext.Provider value={value}>\n {children}\n {mounted &&\n entries.length > 0 &&\n createPortal(\n <div role=\"region\" aria-label=\"Notifications\" style={viewport}>\n {entries.map((e) => (\n <div\n key={e.id}\n className=\"sereno-toast-item\"\n data-edge={edge}\n data-leaving={e.leaving ? 'true' : undefined}\n onMouseEnter={() => pause(e.id)}\n onMouseLeave={() => resume(e.id)}\n onFocusCapture={() => pause(e.id)}\n onBlurCapture={() => resume(e.id)}\n style={sx({ pointerEvents: 'auto', width: '100%' })}\n >\n <Toast\n tone={e.tone}\n title={e.title}\n description={e.description}\n icon={e.icon}\n action={e.action}\n role={e.tone === 'error' ? 'alert' : 'status'}\n onClose={() => drop(e.id)}\n progress={timed(e.ms) && !e.leaving ? { ms: e.ms, paused: pausedIds.has(e.id) } : undefined}\n style={{ width: '100%', maxWidth: 'none' }}\n />\n </div>\n ))}\n </div>,\n document.body,\n )}\n </ToastContext.Provider>\n );\n}\n\nexport function useToast(): ToastContextValue {\n const ctx = React.useContext(ToastContext);\n if (!ctx) throw new Error('useToast() must be called inside <ToastProvider>.');\n return ctx;\n}\n"],"mappings":";AA6PI,SAkBY,KAlBZ;AA3PJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAA8B;AACvC,SAAS,UAAU;AA6Dn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AA,UAC/B,gBAAgB,MAAM,MAAM,EAAE,EAAE;AAAA,UAChC,eAAe,MAAM,OAAO,EAAE,EAAE;AAAA,UAChC,OAAO,GAAG,EAAE,eAAe,QAAQ,OAAO,OAAO,CAAC;AAAA,UAElD;AAAA,YAAC;AAAA;AAAA,cACC,MAAM,EAAE;AAAA,cACR,OAAO,EAAE;AAAA,cACT,aAAa,EAAE;AAAA,cACf,MAAM,EAAE;AAAA,cACR,QAAQ,EAAE;AAAA,cACV,MAAM,EAAE,SAAS,UAAU,UAAU;AAAA,cACrC,SAAS,MAAM,KAAK,EAAE,EAAE;AAAA,cACxB,UAAU,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,QAAQ,UAAU,IAAI,EAAE,EAAE,EAAE,IAAI;AAAA,cAClF,OAAO,EAAE,OAAO,QAAQ,UAAU,OAAO;AAAA;AAAA,UAC3C;AAAA;AAAA,QApBK,EAAE;AAAA,MAqBT,CACD,GACH;AAAA,MACA,SAAS;AAAA,IACX;AAAA,KACJ;AAEJ;AAEO,SAAS,WAA8B;AAC5C,QAAM,MAAM,MAAM,WAAW,YAAY;AACzC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,mDAAmD;AAC7E,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/ToastProvider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Toast, type ToastProps } from './Toast';\nimport { sx } from '../_internal/style';\n\n/**\n * The toast *system* — a portal viewport plus a queue — layered on top of the\n * presentational `Toast`. Wrap the app once:\n *\n * ```tsx\n * <ToastProvider position=\"bottom-right\">\n * <App />\n * </ToastProvider>\n * ```\n *\n * then fire from anywhere under it:\n *\n * ```tsx\n * const { toast, dismiss } = useToast();\n * toast.success('Booking confirmed', { description: 'The client was notified.' });\n * toast('Link copied'); // neutral, title only\n * const id = toast.info('Syncing…', { duration: 0 }); // sticks until dismiss(id)\n * ```\n *\n * Toasts stack (newest nearest the edge), show a countdown bar, auto-dismiss\n * after `duration`, pause that timer (and the bar) while hovered/focused, and\n * cap at `max` — the oldest drops. Needs the `sereno-toast-*` keyframes from\n * `@sereno-ds/ui/styles.css`.\n */\n\ntype Tone = NonNullable<ToastProps['tone']>;\n\nexport interface ToastOptions {\n title: string;\n description?: string;\n tone?: Tone;\n icon?: React.ReactNode;\n /** Inline control on the right — an \"Undo\" / \"View\" `Button variant=\"link\"`. */\n action?: React.ReactNode;\n /** ms until auto-dismiss. `0` (or `Infinity`) keeps it until dismissed. Defaults to the provider's `duration`. */\n duration?: number;\n}\n\n/** `msg` shorthand: a bare string becomes the `title`; an object is the full options. */\nexport type ToastInput = string | ToastOptions;\n\ntype ToneFn = (msg: ToastInput, opts?: Partial<ToastOptions>) => string;\n\nexport interface ToastApi {\n /** `toast('Saved')` or `toast('Saved', { description, action, duration })`. Neutral tone. */\n (msg: ToastInput, opts?: Partial<ToastOptions>): string;\n success: ToneFn;\n error: ToneFn;\n warning: ToneFn;\n info: ToneFn;\n neutral: ToneFn;\n}\n\nexport interface ToastContextValue {\n toast: ToastApi;\n /** `dismiss(id)` removes one; `dismiss()` clears them all. */\n dismiss: (id?: string) => void;\n}\n\nconst ToastContext = React.createContext<ToastContextValue | null>(null);\n\nexport type ToastPosition =\n | 'bottom-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'top-right'\n | 'top-left'\n | 'top-center';\n\nexport interface ToastProviderProps {\n children: React.ReactNode;\n /** Viewport corner. Default `bottom-right`. */\n position?: ToastPosition;\n /** Most toasts on screen at once; the oldest drops when a new one arrives. Default `3`. */\n max?: number;\n /** Default auto-dismiss, in ms. Default `4000`. */\n duration?: number;\n}\n\ninterface Entry extends ToastOptions {\n id: string;\n /** Resolved auto-dismiss (ms) — `opts.duration ?? provider duration`. `0` / `Infinity` = sticky. */\n ms: number;\n leaving?: boolean;\n}\n\nconst EXIT_MS = 180;\nlet seq = 0;\nconst nextId = () => `t${Date.now().toString(36)}-${(seq++).toString(36)}`;\n\nconst norm = (msg: ToastInput): Partial<ToastOptions> => (typeof msg === 'string' ? { title: msg } : msg);\nconst timed = (ms: number) => ms > 0 && Number.isFinite(ms);\n\nexport function ToastProvider({ children, position = 'bottom-right', max = 3, duration = 4000 }: ToastProviderProps) {\n const [entries, setEntries] = React.useState<Entry[]>([]);\n const [pausedIds, setPausedIds] = React.useState<ReadonlySet<string>>(() => new Set());\n\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n\n // Per-toast auto-dismiss timers, so hover/focus can pause and resume them.\n const timers = React.useRef(new Map<string, { handle: ReturnType<typeof setTimeout>; endsAt: number; left: number }>());\n\n const forget = React.useCallback((id: string) => {\n setPausedIds((s) => {\n if (!s.has(id)) return s;\n const n = new Set(s);\n n.delete(id);\n return n;\n });\n }, []);\n\n const drop = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) clearTimeout(t.handle);\n timers.current.delete(id);\n setEntries((list) => list.map((e) => (e.id === id ? { ...e, leaving: true } : e)));\n setTimeout(() => {\n setEntries((list) => list.filter((e) => e.id !== id));\n forget(id);\n }, EXIT_MS);\n },\n [forget],\n );\n\n const arm = React.useCallback(\n (id: string, ms: number) => {\n if (!timed(ms)) return;\n const handle = setTimeout(() => drop(id), ms);\n timers.current.set(id, { handle, endsAt: Date.now() + ms, left: ms });\n },\n [drop],\n );\n\n const pause = React.useCallback((id: string) => {\n const t = timers.current.get(id);\n if (!t) return;\n clearTimeout(t.handle);\n t.left = Math.max(0, t.endsAt - Date.now());\n setPausedIds((s) => (s.has(id) ? s : new Set(s).add(id)));\n }, []);\n\n const resume = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) {\n t.handle = setTimeout(() => drop(id), t.left);\n t.endsAt = Date.now() + t.left;\n }\n forget(id);\n },\n [drop, forget],\n );\n\n const add = React.useCallback(\n (opts: ToastOptions) => {\n const id = nextId();\n const ms = opts.duration ?? duration;\n setEntries((list) => {\n const next: Entry[] = [...list, { ...opts, id, ms }];\n // Cap: hard-drop the oldest that isn't already leaving.\n while (next.filter((e) => !e.leaving).length > max) {\n const victim = next.find((e) => !e.leaving);\n if (!victim) break;\n const vt = timers.current.get(victim.id);\n if (vt) clearTimeout(vt.handle);\n timers.current.delete(victim.id);\n victim.leaving = true;\n setTimeout(() => {\n setEntries((l) => l.filter((e) => e.id !== victim.id));\n forget(victim.id);\n }, EXIT_MS);\n }\n return next;\n });\n arm(id, ms);\n return id;\n },\n [arm, duration, forget, max],\n );\n\n // Tone-specific methods always paint their tone; bare `toast(...)` respects a\n // `tone` in the message / options and otherwise stays neutral.\n const fire = React.useCallback(\n (msg: ToastInput, opts?: Partial<ToastOptions>, tone?: Tone) =>\n add({ title: '', ...norm(msg), ...opts, ...(tone ? { tone } : {}) } as ToastOptions),\n [add],\n );\n\n /* eslint-disable react-hooks/refs -- `fire` transitively reaches the `timers` ref, but only when a\n consumer invokes toast.*() from an event handler — never during render. `useMemo` just keeps\n the callable API object's identity stable. */\n const toast = React.useMemo<ToastApi>(() => {\n const base = (msg: ToastInput, opts?: Partial<ToastOptions>) => fire(msg, opts);\n const make = (tone: Tone): ToneFn => (msg, opts) => fire(msg, opts, tone);\n return Object.assign(base, {\n success: make('success'),\n error: make('error'),\n warning: make('warning'),\n info: make('info'),\n neutral: make('neutral'),\n }) as ToastApi;\n }, [fire]);\n /* eslint-enable react-hooks/refs */\n\n const dismiss = React.useCallback(\n (id?: string) => {\n if (id) {\n drop(id);\n return;\n }\n entries.forEach((e) => !e.leaving && drop(e.id));\n },\n [drop, entries],\n );\n\n const value = React.useMemo<ToastContextValue>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // Clear every pending timer on unmount.\n React.useEffect(() => {\n const map = timers.current;\n return () => map.forEach((t) => clearTimeout(t.handle));\n }, []);\n\n const [edge, side] = position.split('-') as ['top' | 'bottom', 'right' | 'left' | 'center'];\n const viewport = sx({\n position: 'fixed',\n zIndex: 1200,\n display: 'flex',\n // Newest nearest the anchored edge: normal flow for bottom, reversed for top.\n flexDirection: edge === 'bottom' ? 'column' : 'column-reverse',\n gap: 'var(--space-3)',\n width: 'min(420px, calc(100vw - var(--space-8)))',\n maxHeight: '100dvh',\n padding: 'var(--space-4)',\n pointerEvents: 'none',\n [edge]: 0,\n // Every toast is full-width of the viewport, so the stack edges line up on\n // any side; `alignItems` only matters if a toast were ever narrower.\n alignItems: 'stretch',\n // An *outer* offset on top of the padding above, not just the padding\n // itself — macOS Safari's overlay scrollbar floats over the page rather\n // than reducing its width, so a left/right edge flush at 0 can end up\n // with the scrollbar painted right where the padding was supposed to be\n // the toast's only clearance from the edge.\n ...(side === 'center' ? { left: '50%', transform: 'translateX(-50%)' } : { [side]: 'var(--space-2)' }),\n });\n\n return (\n <ToastContext.Provider value={value}>\n {children}\n {mounted &&\n entries.length > 0 &&\n createPortal(\n <div role=\"region\" aria-label=\"Notifications\" style={viewport}>\n {entries.map((e) => (\n <div\n key={e.id}\n className=\"sereno-toast-item\"\n data-edge={edge}\n data-leaving={e.leaving ? 'true' : undefined}\n onMouseEnter={() => pause(e.id)}\n onMouseLeave={() => resume(e.id)}\n onFocusCapture={() => pause(e.id)}\n onBlurCapture={() => resume(e.id)}\n style={sx({ pointerEvents: 'auto', width: '100%' })}\n >\n <Toast\n tone={e.tone}\n title={e.title}\n description={e.description}\n icon={e.icon}\n action={e.action}\n role={e.tone === 'error' ? 'alert' : 'status'}\n onClose={() => drop(e.id)}\n progress={timed(e.ms) && !e.leaving ? { ms: e.ms, paused: pausedIds.has(e.id) } : undefined}\n style={{ width: '100%', maxWidth: 'none' }}\n />\n </div>\n ))}\n </div>,\n document.body,\n )}\n </ToastContext.Provider>\n );\n}\n\nexport function useToast(): ToastContextValue {\n const ctx = React.useContext(ToastContext);\n if (!ctx) throw new Error('useToast() must be called inside <ToastProvider>.');\n return ctx;\n}\n"],"mappings":";AAkQI,SA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