@sereno-ds/ui 0.29.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/feedback/Dialog.js
CHANGED
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { X } from "lucide-react";
|
|
6
6
|
import { sx } from "../_internal/style.js";
|
|
7
|
+
import { Typography } from "../core/Typography.js";
|
|
7
8
|
const SIZE_W = { sm: 440, md: 600, lg: 800, xl: 1e3 };
|
|
8
9
|
const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
9
10
|
function focusableIn(el) {
|
|
@@ -164,33 +165,8 @@ function Header({ title, description, children }) {
|
|
|
164
165
|
}),
|
|
165
166
|
children: [
|
|
166
167
|
/* @__PURE__ */ jsxs("div", { id: titleId, style: sx({ flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: "var(--space-2)" }), children: [
|
|
167
|
-
title && /* @__PURE__ */ jsx(
|
|
168
|
-
|
|
169
|
-
{
|
|
170
|
-
style: sx({
|
|
171
|
-
fontFamily: "var(--font-display)",
|
|
172
|
-
fontSize: "var(--text-xl)",
|
|
173
|
-
fontWeight: "var(--weight-bold)",
|
|
174
|
-
letterSpacing: "var(--tracking-tight)",
|
|
175
|
-
color: "var(--text-primary)",
|
|
176
|
-
margin: 0
|
|
177
|
-
}),
|
|
178
|
-
children: title
|
|
179
|
-
}
|
|
180
|
-
),
|
|
181
|
-
description && /* @__PURE__ */ jsx(
|
|
182
|
-
"p",
|
|
183
|
-
{
|
|
184
|
-
style: sx({
|
|
185
|
-
fontFamily: "var(--font-body)",
|
|
186
|
-
fontSize: "var(--text-base)",
|
|
187
|
-
lineHeight: "var(--leading-normal)",
|
|
188
|
-
color: "var(--text-secondary)",
|
|
189
|
-
margin: 0
|
|
190
|
-
}),
|
|
191
|
-
children: description
|
|
192
|
-
}
|
|
193
|
-
),
|
|
168
|
+
title && /* @__PURE__ */ jsx(Typography, { as: "h3", variant: "h2", style: { letterSpacing: "var(--tracking-tight)" }, children: title }),
|
|
169
|
+
description && /* @__PURE__ */ jsx(Typography, { variant: "body", color: "secondary", children: description }),
|
|
194
170
|
extra
|
|
195
171
|
] }),
|
|
196
172
|
closeEl
|
|
@@ -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 — 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\n// Cheap, dependency-free focusable check — matches what most hand-rolled\n// focus traps use. No visibility filtering: nothing inside a Dialog is ever\n// conditionally hidden today, and jsdom doesn't compute layout (offsetParent\n// is always null there), so a visibility check would be untestable dead\n// weight rather than a real safeguard.\nconst FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\nfunction focusableIn(el: HTMLElement): HTMLElement[] {\n return Array.from(el.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR));\n}\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, bind Escape to close, trap Tab inside the\n // panel, and restore focus to whatever had it before opening once closed.\n // `onClose` / `dismissible` are read through refs so the effect only\n // 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 const panelRef = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n if (!open) return;\n const previouslyFocused = document.activeElement as HTMLElement | null;\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') {\n if (dismissibleRef.current) onCloseRef.current?.();\n return;\n }\n if (e.key !== 'Tab') return;\n const panel = panelRef.current;\n if (!panel) return;\n const focusables = focusableIn(panel);\n // No focusable content (a bare Dialog.Body with plain text): keep\n // focus pinned on the panel itself rather than leaking to the page.\n if (focusables.length === 0) {\n e.preventDefault();\n return;\n }\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\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 // The trigger may itself have unmounted (e.g. a row it lived in was\n // removed) — focus() on a detached element is a silent no-op, not a\n // throw, so no need to guard beyond the null check.\n previouslyFocused?.focus();\n };\n }, [open]);\n\n // Pull focus into the dialog when it opens.\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":";AA4MM,SAyBI,KAzBJ;AA1MN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,UAAU;AAuEnB,MAAM,SAAS,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAK;AAOrD,MAAM,qBAAqB;AAC3B,SAAS,YAAY,IAAgC;AACnD,SAAO,MAAM,KAAK,GAAG,iBAA8B,kBAAkB,CAAC;AACxE;AAEA,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,OAAO;AAAA,EACP,WAAW;AAAA,EACX,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAgB;AACd,QAAM,QAAQ,YAAY;AAC1B,QAAM,OAAO,YAAY;AACzB,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zC,WAAW,WAAW,WAAW;AAAA,MACnC,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;AAEA,SAAS,QAAQ;AACf,QAAM,EAAE,SAAS,KAAK,IAAI,iBAAiB,OAAO;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAU;AAAA,MACV,cAAW;AAAA,MACX,SAAS;AAAA,MACT,OAAO,GAAG;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,OAAO,OAAO,KAAK;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":[]}
|
|
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';\nimport { Typography } from '../core/Typography';\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\n// Cheap, dependency-free focusable check — matches what most hand-rolled\n// focus traps use. No visibility filtering: nothing inside a Dialog is ever\n// conditionally hidden today, and jsdom doesn't compute layout (offsetParent\n// is always null there), so a visibility check would be untestable dead\n// weight rather than a real safeguard.\nconst FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\nfunction focusableIn(el: HTMLElement): HTMLElement[] {\n return Array.from(el.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR));\n}\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, bind Escape to close, trap Tab inside the\n // panel, and restore focus to whatever had it before opening once closed.\n // `onClose` / `dismissible` are read through refs so the effect only\n // 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 const panelRef = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n if (!open) return;\n const previouslyFocused = document.activeElement as HTMLElement | null;\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') {\n if (dismissibleRef.current) onCloseRef.current?.();\n return;\n }\n if (e.key !== 'Tab') return;\n const panel = panelRef.current;\n if (!panel) return;\n const focusables = focusableIn(panel);\n // No focusable content (a bare Dialog.Body with plain text): keep\n // focus pinned on the panel itself rather than leaking to the page.\n if (focusables.length === 0) {\n e.preventDefault();\n return;\n }\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\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 // The trigger may itself have unmounted (e.g. a row it lived in was\n // removed) — focus() on a detached element is a silent no-op, not a\n // throw, so no need to guard beyond the null check.\n previouslyFocused?.focus();\n };\n }, [open]);\n\n // Pull focus into the dialog when it opens.\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 <Typography as=\"h3\" variant=\"h2\" style={{ letterSpacing: 'var(--tracking-tight)' }}>\n {title}\n </Typography>\n )}\n {description && (\n <Typography variant=\"body\" color=\"secondary\">\n {description}\n </Typography>\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":";AA6MM,SAyBI,KAzBJ;AA3MN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAuE3B,MAAM,SAAS,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAK;AAOrD,MAAM,qBAAqB;AAC3B,SAAS,YAAY,IAAgC;AACnD,SAAO,MAAM,KAAK,GAAG,iBAA8B,kBAAkB,CAAC;AACxE;AAEA,MAAM,gBAAgB,MAAM,cAAyC,IAAI;AAEzE,SAAS,iBAAiB,WAAuC;AAC/D,QAAM,MAAM,MAAM,WAAW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U;AAAA,QACV,SAAS,WAAW,MAAM,KAAK,GAAG,IAAI,GAAG;AAAA,QACzC,WAAW,WAAW,WAAW;AAAA,MACnC,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;AAEA,SAAS,QAAQ;AACf,QAAM,EAAE,SAAS,KAAK,IAAI,iBAAiB,OAAO;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAU;AAAA,MACV,cAAW;AAAA,MACX,SAAS;AAAA,MACT,OAAO,GAAG;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,OAAO,OAAO,KAAK;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":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { sx } from "../_internal/style.js";
|
|
4
|
+
import { Typography } from "../core/Typography.js";
|
|
4
5
|
function EmptyState({ icon, title, description, action, compact = false, style, ...rest }) {
|
|
5
6
|
return /* @__PURE__ */ jsxs(
|
|
6
7
|
"div",
|
|
@@ -33,32 +34,8 @@ function EmptyState({ icon, title, description, action, compact = false, style,
|
|
|
33
34
|
children: icon
|
|
34
35
|
}
|
|
35
36
|
),
|
|
36
|
-
/* @__PURE__ */ jsx(
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
style: sx({
|
|
40
|
-
fontFamily: "var(--font-display)",
|
|
41
|
-
fontSize: "var(--text-lg)",
|
|
42
|
-
fontWeight: "var(--weight-bold)",
|
|
43
|
-
letterSpacing: "var(--tracking-tight)",
|
|
44
|
-
color: "var(--text-primary)"
|
|
45
|
-
}),
|
|
46
|
-
children: title
|
|
47
|
-
}
|
|
48
|
-
),
|
|
49
|
-
description && /* @__PURE__ */ jsx(
|
|
50
|
-
"span",
|
|
51
|
-
{
|
|
52
|
-
style: sx({
|
|
53
|
-
fontFamily: "var(--font-body)",
|
|
54
|
-
fontSize: "var(--text-sm)",
|
|
55
|
-
color: "var(--text-secondary)",
|
|
56
|
-
lineHeight: "var(--leading-normal)",
|
|
57
|
-
maxWidth: 340
|
|
58
|
-
}),
|
|
59
|
-
children: description
|
|
60
|
-
}
|
|
61
|
-
),
|
|
37
|
+
/* @__PURE__ */ jsx(Typography, { as: "span", variant: "h1", style: { fontSize: "var(--text-lg)" }, children: title }),
|
|
38
|
+
description && /* @__PURE__ */ jsx(Typography, { as: "span", variant: "bodySm", style: { maxWidth: 340 }, children: description }),
|
|
62
39
|
action && /* @__PURE__ */ jsx("div", { style: sx({ marginTop: "var(--space-2)" }), children: action })
|
|
63
40
|
]
|
|
64
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/EmptyState.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Friendly placeholder for empty agendas, client lists and search results. */\nexport interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {\n icon?: React.ReactNode;\n title: string;\n description?: string;\n action?: React.ReactNode;\n compact?: boolean;\n}\n\nexport function EmptyState({ icon, title, description, action, compact = false, style, ...rest }: EmptyStateProps) {\n return (\n <div\n {...rest}\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n textAlign: 'center',\n gap: 'var(--space-3)',\n padding: compact ? 'var(--space-6)' : 'var(--space-9) var(--space-6)',\n ...style,\n })}\n >\n {icon && (\n <span\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: 52,\n height: 52,\n borderRadius: 'var(--radius-xl)',\n background: 'var(--bg-brand-soft)',\n color: 'var(--text-brand)',\n marginBottom: 2,\n })}\n >\n {icon}\n </span>\n )}\n <span\
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/EmptyState.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { Typography } from '../core/Typography';\n\n/** Friendly placeholder for empty agendas, client lists and search results. */\nexport interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {\n icon?: React.ReactNode;\n title: string;\n description?: string;\n action?: React.ReactNode;\n compact?: boolean;\n}\n\nexport function EmptyState({ icon, title, description, action, compact = false, style, ...rest }: EmptyStateProps) {\n return (\n <div\n {...rest}\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n textAlign: 'center',\n gap: 'var(--space-3)',\n padding: compact ? 'var(--space-6)' : 'var(--space-9) var(--space-6)',\n ...style,\n })}\n >\n {icon && (\n <span\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: 52,\n height: 52,\n borderRadius: 'var(--radius-xl)',\n background: 'var(--bg-brand-soft)',\n color: 'var(--text-brand)',\n marginBottom: 2,\n })}\n >\n {icon}\n </span>\n )}\n <Typography as=\"span\" variant=\"h1\" style={{ fontSize: 'var(--text-lg)' }}>\n {title}\n </Typography>\n {description && (\n <Typography as=\"span\" variant=\"bodySm\" style={{ maxWidth: 340 }}>\n {description}\n </Typography>\n )}\n {action && <div style={sx({ marginTop: 'var(--space-2)' })}>{action}</div>}\n </div>\n );\n}"],"mappings":";AAiBI,SAaI,KAbJ;AAdJ,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAWpB,SAAS,WAAW,EAAE,MAAM,OAAO,aAAa,QAAQ,UAAU,OAAO,OAAO,GAAG,KAAK,GAAoB;AACjH,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,KAAK;AAAA,QACL,SAAS,UAAU,mBAAmB;AAAA,QACtC,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,gBACC;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,GAAG;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,cAAc;AAAA,YAChB,CAAC;AAAA,YAEA;AAAA;AAAA,QACH;AAAA,QAEF,oBAAC,cAAW,IAAG,QAAO,SAAQ,MAAK,OAAO,EAAE,UAAU,iBAAiB,GACpE,iBACH;AAAA,QACC,eACC,oBAAC,cAAW,IAAG,QAAO,SAAQ,UAAS,OAAO,EAAE,UAAU,IAAI,GAC3D,uBACH;AAAA,QAED,UAAU,oBAAC,SAAI,OAAO,GAAG,EAAE,WAAW,iBAAiB,CAAC,GAAI,kBAAO;AAAA;AAAA;AAAA,EACtE;AAEJ;","names":[]}
|