@sereno-ds/ui 0.36.0 → 0.36.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.
@@ -55,11 +55,19 @@ interface DialogBodyProps {
55
55
  interface DialogFooterProps {
56
56
  /** Action buttons, right-aligned. */
57
57
  children?: React.ReactNode;
58
+ /**
59
+ * Let the buttons share the row and grow to fill it, and each line if they wrap, instead
60
+ * of hugging the right edge at their natural width. For a footer with three actions or
61
+ * long (translated) labels, where a plain wrap leaves the last button, usually the
62
+ * primary one, alone, small and pushed right on a second line. Off by default, so no
63
+ * existing dialog changes.
64
+ */
65
+ fill?: boolean;
58
66
  }
59
67
  declare function DialogRoot({ open, children, onClose, variant, size, dividers, dismissible, width, style, ...rest }: DialogProps): React.ReactPortal | null;
60
68
  declare function Header({ title, description, children }: DialogHeaderProps): React.JSX.Element;
61
69
  declare function Body({ children }: DialogBodyProps): React.JSX.Element;
62
- declare function Footer({ children }: DialogFooterProps): React.JSX.Element;
70
+ declare function Footer({ children, fill }: DialogFooterProps): React.JSX.Element;
63
71
  declare function Close(): React.JSX.Element;
64
72
  declare const Dialog: typeof DialogRoot & {
65
73
  Header: typeof Header;
@@ -190,13 +190,15 @@ function Body({ children }) {
190
190
  }
191
191
  );
192
192
  }
193
- function Footer({ children }) {
193
+ function Footer({ children, fill = false }) {
194
194
  const { dividers } = useDialogContext("Footer");
195
195
  const pad = "var(--space-5)";
196
196
  const hairline = "var(--border-width-hairline) solid var(--border-default)";
197
197
  return /* @__PURE__ */ jsx(
198
198
  "div",
199
199
  {
200
+ className: "sereno-dialog-footer",
201
+ "data-fill": fill || void 0,
200
202
  style: sx({
201
203
  flex: "0 0 auto",
202
204
  display: "flex",
@@ -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';\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,WA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AY,KAAK,GAAG,IAAI,YAAY,mBAAmB,GAAG,KAAK;AAAA,MAC3F,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;AAEA,SAAS,OAAO,EAAE,SAAS,GAAsB;AAC/C,QAAM,EAAE,SAAS,IAAI,iBAAiB,QAAQ;AAC9C,QAAM,MAAM;AACZ,QAAM,WAAW;AACjB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,GAAG;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,KAAK;AAAA,QACL,gBAAgB;AAAA,QAChB,UAAU;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
+ {"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 * Let the buttons share the row and grow to fill it, and each line if they wrap, instead\n * of hugging the right edge at their natural width. For a footer with three actions or\n * long (translated) labels, where a plain wrap leaves the last button, usually the\n * primary one, alone, small and pushed right on a second line. Off by default, so no\n * existing dialog changes.\n */\n fill?: boolean;\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, fill = false }: 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 // `fill` (see styles.css) makes each child `flex: 1 1 auto`. It can't be inline: it's on the children.\n className=\"sereno-dialog-footer\"\n data-fill={fill || undefined}\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":";AAqNM,SAyBI,KAzBJ;AAnNN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,UAAU;AACnB,SAAS,kBAAkB;AA+E3B,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,QAAM,MAAM,MAAM,MAAM;AACxB,QAAM,UAAU,GAAG,GAAG;AAGtB,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAS,KAAK;AAElD,QAAM,UAAU,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAM1C,QAAM,aAAa,MAAM,OAAO,OAAO;AACvC,QAAM,iBAAiB,MAAM,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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,5 +1,5 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { createPortal } from "react-dom";
5
5
  import { Camera, Check, ImagePlus, Pencil, RotateCcw, Trash2, X, ZoomIn, ZoomOut } from "lucide-react";
@@ -114,7 +114,8 @@ const AvatarUpload = React.forwardRef(function AvatarUpload2({
114
114
  window.removeEventListener("resize", close);
115
115
  };
116
116
  }, [menuOpen]);
117
- const modalUp = Boolean(cropSrc) || cameraOpen;
117
+ const step = cropSrc ? "crop" : allowCamera && cameraOpen ? "camera" : null;
118
+ const modalUp = step !== null;
118
119
  React.useEffect(() => {
119
120
  if (!modalUp) return;
120
121
  const root = document.documentElement;
@@ -309,25 +310,19 @@ const AvatarUpload = React.forwardRef(function AvatarUpload2({
309
310
  ),
310
311
  document.body
311
312
  ),
312
- allowCamera && cameraOpen && /* @__PURE__ */ jsx(
313
- CameraModal,
314
- {
315
- labels: t,
316
- onClose: () => setCameraOpen(false),
317
- onCapture: onCameraShot,
318
- onError: () => {
319
- setCameraOpen(false);
320
- setRejected(t.cameraError);
321
- }
322
- }
323
- ),
324
- cropSrc && /* @__PURE__ */ jsx(
325
- CropModal,
313
+ step && /* @__PURE__ */ jsx(
314
+ CaptureDialog,
326
315
  {
316
+ step,
327
317
  src: cropSrc,
328
318
  outputSize,
329
319
  labels: t,
330
- onClose: onCropCancel,
320
+ onClose: step === "camera" ? () => setCameraOpen(false) : onCropCancel,
321
+ onCameraShot,
322
+ onCameraError: () => {
323
+ setCameraOpen(false);
324
+ setRejected(t.cameraError);
325
+ },
331
326
  onSave: onCropSave,
332
327
  onRetake: cropFromCamera ? onRetake : void 0
333
328
  }
@@ -369,6 +364,8 @@ function MenuItem({ icon, label, onClick, danger }) {
369
364
  );
370
365
  }
371
366
  const DEFAULT_STAGE = 280;
367
+ const MODAL_WIDTH = 440;
368
+ const ZOOM_ROW_HEIGHT = 24;
372
369
  function CropStage({ children, onPointerDown, onPointerMove, onPointerUp, onWheel, stageRef }) {
373
370
  return /* @__PURE__ */ jsxs(
374
371
  "div",
@@ -409,15 +406,61 @@ function CropStage({ children, onPointerDown, onPointerMove, onPointerUp, onWhee
409
406
  }
410
407
  );
411
408
  }
412
- function CropModal({
413
- src,
414
- outputSize,
415
- labels,
416
- onClose,
417
- onSave,
418
- onRetake
419
- }) {
420
- const imgRef = React.useRef(null);
409
+ function useCamera(active, onError) {
410
+ const videoRef = React.useRef(null);
411
+ const streamRef = React.useRef(null);
412
+ const [ready, setReady] = React.useState(false);
413
+ const onErrorRef = React.useRef(onError);
414
+ React.useEffect(() => {
415
+ onErrorRef.current = onError;
416
+ });
417
+ React.useEffect(() => {
418
+ if (!active) return;
419
+ let cancelled = false;
420
+ let started = null;
421
+ const md = typeof navigator !== "undefined" ? navigator.mediaDevices : void 0;
422
+ if (!md?.getUserMedia) {
423
+ onErrorRef.current();
424
+ return;
425
+ }
426
+ md.getUserMedia({ video: { facingMode: "user", width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false }).then((s) => {
427
+ if (cancelled) {
428
+ s.getTracks().forEach((tr) => tr.stop());
429
+ return;
430
+ }
431
+ started = s;
432
+ streamRef.current = s;
433
+ if (videoRef.current) videoRef.current.srcObject = s;
434
+ setReady(true);
435
+ }).catch(() => onErrorRef.current());
436
+ return () => {
437
+ cancelled = true;
438
+ started?.getTracks().forEach((tr) => tr.stop());
439
+ streamRef.current = null;
440
+ setReady(false);
441
+ };
442
+ }, [active]);
443
+ const attachVideo = React.useCallback((el) => {
444
+ videoRef.current = el;
445
+ if (el && streamRef.current) el.srcObject = streamRef.current;
446
+ }, []);
447
+ const shoot = (onShot) => {
448
+ const v = videoRef.current;
449
+ if (!v || !v.videoWidth) return;
450
+ const s = Math.min(v.videoWidth, v.videoHeight);
451
+ const canvas = document.createElement("canvas");
452
+ canvas.width = canvas.height = s;
453
+ const ctx = canvas.getContext("2d");
454
+ if (!ctx) return;
455
+ ctx.translate(s, 0);
456
+ ctx.scale(-1, 1);
457
+ ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);
458
+ canvas.toBlob((b) => b && onShot(b), "image/jpeg", 0.9);
459
+ };
460
+ return { attachVideo, ready, shoot };
461
+ }
462
+ function useCropper(src, outputSize) {
463
+ const [imgEl, setImgEl] = React.useState(null);
421
464
  const [stageEl, setStageEl] = React.useState(null);
422
465
  const [V, setV] = React.useState(DEFAULT_STAGE);
423
466
  const prevV = React.useRef(V);
@@ -425,6 +468,13 @@ function CropModal({
425
468
  const [zoom, setZoom] = React.useState(1);
426
469
  const [offset, setOffset] = React.useState({ x: 0, y: 0 });
427
470
  const drag = React.useRef(null);
471
+ const [seenSrc, setSeenSrc] = React.useState(src);
472
+ if (src !== seenSrc) {
473
+ setSeenSrc(src);
474
+ setNat(null);
475
+ setZoom(1);
476
+ setOffset({ x: 0, y: 0 });
477
+ }
428
478
  React.useEffect(() => {
429
479
  if (!stageEl) return;
430
480
  const ro = new ResizeObserver((entries) => {
@@ -449,9 +499,7 @@ function CropModal({
449
499
  }),
450
500
  [V, dispW, dispH]
451
501
  );
452
- const onImgLoad = () => {
453
- const el = imgRef.current;
454
- if (!el) return;
502
+ const onImgLoad = (el) => {
455
503
  const w = el.naturalWidth;
456
504
  const h = el.naturalHeight;
457
505
  setNat({ w, h });
@@ -485,107 +533,88 @@ function CropModal({
485
533
  const onPointerUp = () => {
486
534
  drag.current = null;
487
535
  };
488
- const save = () => {
489
- const el = imgRef.current;
490
- if (!el || !nat) return;
536
+ const save = (onSave) => {
537
+ if (!imgEl || !nat) return;
491
538
  const canvas = document.createElement("canvas");
492
539
  canvas.width = canvas.height = outputSize;
493
540
  const ctx = canvas.getContext("2d");
494
541
  if (!ctx) return;
495
542
  const sSize = V / scale;
496
- ctx.drawImage(el, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);
543
+ ctx.drawImage(imgEl, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);
497
544
  canvas.toBlob((b) => b && onSave(b), "image/jpeg", 0.85);
498
545
  };
499
- return (
500
- // Wider than the default 352 (CameraModal's own dialog): three real Buttons in the
501
- // footer (Retake included) need the room, and `Dialog` already caps at `min(100%, …)`
502
- // for narrow viewports (see feedback/Dialog.tsx), so this needs no mobile-specific
503
- // handling of its own, it just shrinks like every other Dialog width already does.
504
- /* @__PURE__ */ jsxs(Dialog, { width: 400, onClose, children: [
505
- /* @__PURE__ */ jsx(Dialog.Header, { title: labels.cropTitle, description: labels.cropHint }),
506
- /* @__PURE__ */ jsxs(Dialog.Body, { children: [
507
- /* @__PURE__ */ jsx(CropStage, { stageRef: setStageEl, onPointerDown, onPointerMove, onPointerUp, onWheel: (e) => setZoomAt(zoom - e.deltaY * 2e-3), children: /* @__PURE__ */ jsx(
508
- "img",
509
- {
510
- ref: imgRef,
511
- src,
512
- alt: "",
513
- draggable: false,
514
- onLoad: onImgLoad,
515
- style: sx({ position: "absolute", left: offset.x, top: offset.y, width: dispW, height: dispH, maxWidth: "none", userSelect: "none", pointerEvents: "none" })
516
- }
517
- ) }),
518
- /* @__PURE__ */ jsxs("div", { style: sx({ display: "flex", alignItems: "center", gap: "var(--space-3)", marginTop: "var(--space-4)", color: "var(--text-muted)" }), children: [
519
- /* @__PURE__ */ jsx(ZoomOut, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } }),
546
+ return { setImgEl, setStageEl, zoom, setZoomAt, offset, dispW, dispH, onImgLoad, onPointerDown, onPointerMove, onPointerUp, save };
547
+ }
548
+ function CaptureDialog({
549
+ step,
550
+ src,
551
+ outputSize,
552
+ labels,
553
+ onClose,
554
+ onCameraShot,
555
+ onCameraError,
556
+ onSave,
557
+ onRetake
558
+ }) {
559
+ const isCamera = step === "camera";
560
+ const camera = useCamera(isCamera, onCameraError);
561
+ const crop = useCropper(src, outputSize);
562
+ const [contentEl, setContentEl] = React.useState(null);
563
+ React.useEffect(() => {
564
+ contentEl?.closest('[role="dialog"]')?.focus();
565
+ }, [step, contentEl]);
566
+ return /* @__PURE__ */ jsxs(Dialog, { width: MODAL_WIDTH, onClose, children: [
567
+ /* @__PURE__ */ jsx(Dialog.Header, { title: isCamera ? labels.cameraTitle : labels.cropTitle, description: isCamera ? labels.cameraHint : labels.cropHint }),
568
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs("div", { ref: setContentEl, children: [
569
+ isCamera ? /* @__PURE__ */ jsx(CropStage, { children: /* @__PURE__ */ jsx("video", { ref: camera.attachVideo, autoPlay: true, playsInline: true, muted: true, style: sx({ width: "100%", height: "100%", objectFit: "cover", transform: "scaleX(-1)" }) }) }, "camera") : /* @__PURE__ */ jsx(
570
+ CropStage,
571
+ {
572
+ stageRef: crop.setStageEl,
573
+ onPointerDown: crop.onPointerDown,
574
+ onPointerMove: crop.onPointerMove,
575
+ onPointerUp: crop.onPointerUp,
576
+ onWheel: (e) => crop.setZoomAt(crop.zoom - e.deltaY * 2e-3),
577
+ children: src && // eslint-disable-next-line @next/next/no-img-element
520
578
  /* @__PURE__ */ jsx(
521
- "input",
579
+ "img",
522
580
  {
523
- type: "range",
524
- min: 1,
525
- max: 3,
526
- step: 0.01,
527
- value: zoom,
528
- onChange: (e) => setZoomAt(Number(e.target.value)),
529
- "aria-label": labels.zoom,
530
- style: sx({ flex: 1, accentColor: "var(--interactive-primary)" })
581
+ ref: crop.setImgEl,
582
+ src,
583
+ alt: "",
584
+ draggable: false,
585
+ onLoad: (e) => crop.onImgLoad(e.currentTarget),
586
+ style: sx({ position: "absolute", left: crop.offset.x, top: crop.offset.y, width: crop.dispW, height: crop.dispH, maxWidth: "none", userSelect: "none", pointerEvents: "none" })
531
587
  }
532
- ),
533
- /* @__PURE__ */ jsx(ZoomIn, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } })
534
- ] })
535
- ] }),
536
- /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
537
- onRetake && /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(RotateCcw, { size: 16, strokeWidth: 2 }), onClick: onRetake, children: labels.retake }),
538
- /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 }), onClick: onClose, children: labels.cancel }),
539
- /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Check, { size: 16, strokeWidth: 2.5 }), onClick: save, children: labels.save })
540
- ] })
541
- ] })
542
- );
543
- }
544
- function CameraModal({ labels, onCapture, onClose, onError }) {
545
- const videoRef = React.useRef(null);
546
- const streamRef = React.useRef(null);
547
- const [ready, setReady] = React.useState(false);
548
- React.useEffect(() => {
549
- let cancelled = false;
550
- const md = typeof navigator !== "undefined" ? navigator.mediaDevices : void 0;
551
- if (!md?.getUserMedia) {
552
- onError();
553
- return;
554
- }
555
- md.getUserMedia({ video: { facingMode: "user", width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false }).then((stream) => {
556
- if (cancelled) {
557
- stream.getTracks().forEach((tr) => tr.stop());
558
- return;
559
- }
560
- streamRef.current = stream;
561
- if (videoRef.current) videoRef.current.srcObject = stream;
562
- setReady(true);
563
- }).catch(onError);
564
- return () => {
565
- cancelled = true;
566
- streamRef.current?.getTracks().forEach((tr) => tr.stop());
567
- };
568
- }, [onError]);
569
- const shoot = () => {
570
- const v = videoRef.current;
571
- if (!v || !v.videoWidth) return;
572
- const s = Math.min(v.videoWidth, v.videoHeight);
573
- const canvas = document.createElement("canvas");
574
- canvas.width = canvas.height = s;
575
- const ctx = canvas.getContext("2d");
576
- if (!ctx) return;
577
- ctx.translate(s, 0);
578
- ctx.scale(-1, 1);
579
- ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);
580
- canvas.toBlob((b) => b && onCapture(b), "image/jpeg", 0.9);
581
- };
582
- return /* @__PURE__ */ jsxs(Dialog, { width: 352, onClose, children: [
583
- /* @__PURE__ */ jsx(Dialog.Header, { title: labels.cameraTitle, description: labels.cameraHint }),
584
- /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsx(CropStage, { children: /* @__PURE__ */ jsx("video", { ref: videoRef, autoPlay: true, playsInline: true, muted: true, style: sx({ width: "100%", height: "100%", objectFit: "cover", transform: "scaleX(-1)" }) }) }) }),
585
- /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
588
+ )
589
+ },
590
+ "crop"
591
+ ),
592
+ /* @__PURE__ */ jsx("div", { style: sx({ display: "flex", alignItems: "center", gap: "var(--space-3)", marginTop: "var(--space-4)", minHeight: ZOOM_ROW_HEIGHT, color: "var(--text-muted)" }), children: !isCamera && /* @__PURE__ */ jsxs(Fragment, { children: [
593
+ /* @__PURE__ */ jsx(ZoomOut, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } }),
594
+ /* @__PURE__ */ jsx(
595
+ "input",
596
+ {
597
+ type: "range",
598
+ min: 1,
599
+ max: 3,
600
+ step: 0.01,
601
+ value: crop.zoom,
602
+ onChange: (e) => crop.setZoomAt(Number(e.target.value)),
603
+ "aria-label": labels.zoom,
604
+ style: sx({ flex: 1, accentColor: "var(--interactive-primary)" })
605
+ }
606
+ ),
607
+ /* @__PURE__ */ jsx(ZoomIn, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } })
608
+ ] }) })
609
+ ] }) }),
610
+ /* @__PURE__ */ jsx(Dialog.Footer, { fill: !isCamera && Boolean(onRetake), children: isCamera ? /* @__PURE__ */ jsxs(React.Fragment, { children: [
611
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 }), onClick: onClose, children: labels.cancel }),
612
+ /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Camera, { size: 16, strokeWidth: 2 }), onClick: () => camera.shoot(onCameraShot), disabled: !camera.ready, children: labels.capture })
613
+ ] }, "camera") : /* @__PURE__ */ jsxs(React.Fragment, { children: [
614
+ onRetake && /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(RotateCcw, { size: 16, strokeWidth: 2 }), onClick: onRetake, children: labels.retake }),
586
615
  /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 }), onClick: onClose, children: labels.cancel }),
587
- /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Camera, { size: 16, strokeWidth: 2 }), onClick: shoot, disabled: !ready, children: labels.capture })
588
- ] })
616
+ /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Check, { size: 16, strokeWidth: 2.5 }), onClick: () => crop.save(onSave), children: labels.save })
617
+ ] }, "crop") })
589
618
  ] });
590
619
  }
591
620
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/AvatarUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Camera, Check, ImagePlus, Pencil, RotateCcw, Trash2, X, ZoomIn, ZoomOut } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { Dialog } from '../feedback/Dialog';\nimport { Button } from '../core/Button';\n\n/**\n * Profile-photo picker: an avatar disc with a camera button. Pick from the\n * library (or the camera on touch), frame the face in a circular crop, and it\n * hands back a **cropped, downscaled** `File` (JPEG). For attachments / documents\n * / multiple files use `FileUpload` instead.\n *\n * Client-side only downscales and re-encodes; it does not decode HEIC (no\n * browser but Safari can) — that is a server-side job. HEIC picks are rejected\n * with a message.\n */\n/** User-facing strings — English by default; pass overrides for another locale. */\nexport interface AvatarUploadLabels {\n trigger: string;\n upload: string;\n takePhoto: string;\n remove: string;\n cropTitle: string;\n cropHint: string;\n cameraTitle: string;\n cameraHint: string;\n capture: string;\n /** On the crop step, only shown for a shot taken with the camera; reopens it directly. */\n retake: string;\n cancel: string;\n save: string;\n zoom: string;\n heicError: string;\n notImage: string;\n tooLarge: (mb: number) => string;\n unreadable: string;\n cameraError: string;\n}\n\nconst EN: AvatarUploadLabels = {\n trigger: 'Change photo',\n upload: 'Upload a photo',\n takePhoto: 'Take a photo',\n remove: 'Remove photo',\n cropTitle: 'Adjust the photo',\n cropHint: 'Drag to reposition · scroll to zoom.',\n cameraTitle: 'Take a photo',\n cameraHint: 'Line your face up with the circle.',\n capture: 'Capture',\n retake: 'Retake',\n cancel: 'Cancel',\n save: 'Save',\n zoom: 'Zoom',\n heicError: \"That format (HEIC) won't open in the browser — upload a JPG or PNG.\",\n notImage: 'Choose an image file.',\n tooLarge: (mb) => `The image is over ${mb} MB.`,\n unreadable: \"Couldn't read that image. Try a JPG or PNG.\",\n cameraError: \"Couldn't open the camera — upload a photo from your library instead.\",\n};\n\nexport interface AvatarUploadProps {\n /** Full name — drives the initials fallback and the alt text. */\n name?: string;\n /** Current photo: a `File` (freshly cropped) or an existing URL string. */\n value?: File | string | null;\n onChange?: (file: File | null) => void;\n /** Disc diameter in px. */\n size?: number;\n /** Exported square size in px — the crop is drawn to this. */\n outputSize?: number;\n /** Reject picks larger than this (before crop). */\n maxSizeMB?: number;\n /** Override the English UI strings (menu, crop dialog, messages). */\n labels?: Partial<AvatarUploadLabels>;\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /**\n * Whether to allow taking a photo via camera (default true).\n * Set to `false` when picking an organization or brand logo, where taking a\n * live selfie/photo makes no sense.\n */\n allowCamera?: boolean;\n}\n\nfunction initials(name: string): string {\n return (name || '')\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((w) => w[0] || '')\n .join('')\n .toUpperCase();\n}\n\nconst isHeic = (f: File) => /image\\/heic|image\\/heif/i.test(f.type) || /\\.(heic|heif)$/i.test(f.name);\n\nexport const AvatarUpload = React.forwardRef<HTMLInputElement, AvatarUploadProps>(function AvatarUpload(\n {\n name = '',\n value,\n onChange,\n size = 96,\n outputSize = 512,\n maxSizeMB = 8,\n labels: labelsProp,\n label,\n hint,\n error,\n required,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n allowCamera = true,\n },\n forwardedRef,\n) {\n const t = React.useMemo<AvatarUploadLabels>(() => ({ ...EN, ...labelsProp }), [labelsProp]);\n const autoId = React.useId();\n const rid = id || autoId;\n const libRef = React.useRef<HTMLInputElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n const [menuOpen, setMenuOpen] = React.useState(false);\n const [menuPos, setMenuPos] = React.useState<{ top: number; left: number } | null>(null);\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [cropSrc, setCropSrc] = React.useState<string | null>(null);\n // Whether the photo now in the crop step came from the camera. Only then does the crop\n // modal offer \"Retake\" (a library pick already has its own way to change: cancel and pick\n // another file from the system's own dialog).\n const [cropFromCamera, setCropFromCamera] = React.useState(false);\n const [cameraOpen, setCameraOpen] = React.useState(false);\n const [internal, setInternal] = React.useState<File | null>(null);\n\n const current = value !== undefined ? value : internal;\n\n // Preview URL for the current photo.\n const [preview, setPreview] = React.useState<string | null>(typeof current === 'string' ? current : null);\n React.useEffect(() => {\n if (current instanceof File) {\n const u = URL.createObjectURL(current);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an object URL\n setPreview(u);\n return () => URL.revokeObjectURL(u);\n }\n setPreview(typeof current === 'string' ? current : null);\n }, [current]);\n\n const itemCount = (allowCamera ? 1 : 0) + 1 + (current ? 1 : 0);\n\n const toggleMenu = () => {\n if (!allowCamera && !current) {\n libRef.current?.click();\n return;\n }\n if (menuOpen) {\n setMenuOpen(false);\n return;\n }\n const r = triggerRef.current?.getBoundingClientRect();\n if (r) {\n const h = itemCount * 40 + 8;\n const flipUp = r.bottom + 6 + h > window.innerHeight - 8;\n setMenuPos({\n top: flipUp ? Math.max(8, r.top - 6 - h) : r.bottom + 6,\n left: Math.max(8, Math.min(r.left, window.innerWidth - 208)),\n });\n }\n setMenuOpen(true);\n };\n\n // Close the menu on outside click / Escape / scroll — it is portalled to <body>.\n React.useEffect(() => {\n if (!menuOpen) return;\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || menuRef.current?.contains(target)) return;\n setMenuOpen(false);\n };\n const close = () => setMenuOpen(false);\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();\n document.addEventListener('mousedown', onDown);\n document.addEventListener('keydown', onKey);\n window.addEventListener('scroll', close, true);\n window.addEventListener('resize', close);\n return () => {\n document.removeEventListener('mousedown', onDown);\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('scroll', close, true);\n window.removeEventListener('resize', close);\n };\n }, [menuOpen]);\n\n // Dialog doesn't lock scroll or bind Escape — do it here while a modal is up.\n const modalUp = Boolean(cropSrc) || cameraOpen;\n React.useEffect(() => {\n if (!modalUp) 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') return;\n setCameraOpen(false);\n setCropSrc((s) => {\n if (s) URL.revokeObjectURL(s);\n return null;\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 };\n }, [modalUp]);\n\n const pick = (files: FileList | null) => {\n const f = files?.[0];\n if (!f) return;\n if (isHeic(f)) {\n setRejected(t.heicError);\n return;\n }\n if (!f.type.startsWith('image/')) {\n setRejected(t.notImage);\n return;\n }\n if (f.size > maxSizeMB * 1048576) {\n setRejected(t.tooLarge(maxSizeMB));\n return;\n }\n const url = URL.createObjectURL(f);\n const probe = new Image();\n probe.onload = () => {\n setRejected(null);\n setCropFromCamera(false);\n setCropSrc(url);\n };\n probe.onerror = () => {\n URL.revokeObjectURL(url);\n setRejected(t.unreadable);\n };\n probe.src = url;\n };\n\n const commit = (file: File | null) => {\n if (value === undefined) setInternal(file);\n onChange?.(file);\n };\n\n const onCropSave = (blob: Blob) => {\n const file = new File([blob], 'avatar.jpg', { type: 'image/jpeg' });\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n commit(file);\n };\n const onCropCancel = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n };\n\n const onCameraShot = (blob: Blob) => {\n setCameraOpen(false);\n setRejected(null);\n setCropFromCamera(true);\n setCropSrc(URL.createObjectURL(blob));\n };\n\n // Straight back to the live camera, no menu in between: the crop modal's \"Retake\".\n const onRetake = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n setCameraOpen(true);\n };\n\n const cameraBtn = Math.max(30, Math.round(size * 0.34));\n\n return (\n <Field label={label} hint={hint} error={error || rejected || undefined} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input ref={mergeRefs(libRef, forwardedRef)} id={rid} type=\"file\" accept=\"image/*\" disabled={disabled} onChange={(e) => pick(e.target.files)} style={{ display: 'none' }} />\n\n <div style={sx({ position: 'relative', width: size, height: size, flex: '0 0 auto', opacity: disabled ? 0.6 : 1 })}>\n <span\n style={sx({\n width: size,\n height: size,\n borderRadius: '999px',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: preview ? 'var(--bg-subtle)' : 'color-mix(in srgb, var(--brand-500) 22%, var(--bg-surface))',\n border: '1px solid ' + (preview ? 'var(--border-subtle)' : 'color-mix(in srgb, var(--brand-500) 30%, transparent)'),\n color: 'var(--text-brand)',\n fontFamily: 'var(--font-display)',\n fontWeight: 'var(--weight-bold)',\n fontSize: Math.round(size * 0.34),\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {preview ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={preview} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n initials(name) || <ImagePlus size={Math.round(size * 0.3)} strokeWidth={1.75} />\n )}\n </span>\n\n {!disabled && (\n <button\n ref={triggerRef}\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={t.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n onClick={toggleMenu}\n style={sx({\n position: 'absolute',\n right: -2,\n bottom: -2,\n width: cameraBtn,\n height: cameraBtn,\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-sm)',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <Pencil size={Math.round(cameraBtn * 0.46)} strokeWidth={1.75} />\n </button>\n )}\n\n </div>\n\n {menuOpen &&\n menuPos &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n style={sx({\n position: 'fixed',\n top: menuPos.top,\n left: menuPos.left,\n minWidth: 200,\n zIndex: 1000,\n padding: 'var(--space-1)',\n borderRadius: 'var(--radius-md)',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-lg)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n <MenuItem\n icon={<ImagePlus size={16} strokeWidth={1.75} />}\n label={t.upload}\n onClick={() => {\n setMenuOpen(false);\n libRef.current?.click();\n }}\n />\n {allowCamera && (\n <MenuItem\n icon={<Camera size={16} strokeWidth={1.75} />}\n label={t.takePhoto}\n onClick={() => {\n setMenuOpen(false);\n setRejected(null);\n setCameraOpen(true);\n }}\n />\n )}\n {current && (\n <MenuItem\n icon={<Trash2 size={16} strokeWidth={1.75} />}\n label={t.remove}\n danger\n onClick={() => {\n setMenuOpen(false);\n commit(null);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n\n {allowCamera && cameraOpen && (\n <CameraModal\n labels={t}\n onClose={() => setCameraOpen(false)}\n onCapture={onCameraShot}\n onError={() => {\n setCameraOpen(false);\n setRejected(t.cameraError);\n }}\n />\n )}\n\n {cropSrc && (\n <CropModal\n src={cropSrc}\n outputSize={outputSize}\n labels={t}\n onClose={onCropCancel}\n onSave={onCropSave}\n onRetake={cropFromCamera ? onRetake : undefined}\n />\n )}\n </Field>\n );\n});\n\nAvatarUpload.displayName = 'AvatarUpload';\n\nfunction MenuItem({ icon, label, onClick, danger }: { icon: React.ReactNode; label: string; onClick: () => void; danger?: boolean }) {\n const [hover, setHover] = React.useState(false);\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={onClick}\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n minHeight: 40,\n padding: '0 var(--space-3)',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: hover ? 'var(--bg-subtle)' : 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: danger ? 'var(--interactive-error)' : 'var(--text-primary)',\n textAlign: 'left',\n })}\n >\n {icon}\n {label}\n </button>\n );\n}\n\nconst DEFAULT_STAGE = 280; // crop stage's assumed size (px) before its own ResizeObserver measures it\n\n/**\n * The square viewport + circular guide, shared by the crop and camera modals.\n * `width: 100%` + `aspectRatio: 1`, not a fixed pixel box: it spans exactly the same\n * width as `Dialog.Header`'s title and `Dialog.Footer`'s buttons (both just block-level\n * or flex content inside the same padded `Dialog.Body`), instead of a fixed size\n * centered with margins of its own that didn't match theirs (SS-322 follow-up, the\n * stage read as misaligned from the rest of the dialog). Also needs no separate\n * mobile-width handling of its own: whatever width the dialog ends up at (already\n * responsive, see `feedback/Dialog.tsx`), the stage fills it exactly, staying square\n * via `aspectRatio`.\n */\nfunction CropStage({ children, onPointerDown, onPointerMove, onPointerUp, onWheel, stageRef }: {\n children: React.ReactNode;\n onPointerDown?: (e: React.PointerEvent) => void;\n onPointerMove?: (e: React.PointerEvent) => void;\n onPointerUp?: (e: React.PointerEvent) => void;\n onWheel?: (e: React.WheelEvent) => void;\n /** `CropModal` reads the live rendered size off this to drive the crop math (`V`). */\n stageRef?: React.Ref<HTMLDivElement>;\n}) {\n return (\n <div\n ref={stageRef}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onWheel={onWheel}\n style={sx({\n position: 'relative',\n width: '100%',\n aspectRatio: '1',\n overflow: 'hidden',\n borderRadius: 'var(--radius-lg)',\n background: 'var(--bg-sunken)',\n cursor: onPointerDown ? 'grab' : 'default',\n touchAction: 'none',\n })}\n >\n {children}\n <span\n style={sx({\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: '999px',\n boxShadow: '0 0 0 9999px color-mix(in srgb, var(--bg-overlay) 80%, transparent)',\n outline: '1px solid rgba(255, 255, 255, 0.9)',\n outlineOffset: -1,\n })}\n />\n </div>\n );\n}\n\nfunction CropModal({\n src,\n outputSize,\n labels,\n onClose,\n onSave,\n onRetake,\n}: {\n src: string;\n outputSize: number;\n labels: AvatarUploadLabels;\n onClose: () => void;\n onSave: (b: Blob) => void;\n /** Only set for a shot taken with the camera; shows the \"Retake\" button. */\n onRetake?: () => void;\n}) {\n const imgRef = React.useRef<HTMLImageElement>(null);\n // A *callback* ref (kept as state), not a plain `useRef` + a `[]`-effect: `Dialog` renders\n // its children only from the render *after* its own `mounted` flips true (SSR-safe portal),\n // so on the stage's very first mount a `useEffect(..., [])` reading `stageRef.current` at\n // that point would still see `null` and, with no deps to fire again on, never retry, so `V`\n // would then stay stuck at the `DEFAULT_STAGE` guess forever (this exact bug, caught live:\n // the displayed image stayed 280px inside a stage CSS had already sized at ~344px, a gray\n // gap on two edges). The callback fires the moment React actually attaches the node.\n const [stageEl, setStageEl] = React.useState<HTMLDivElement | null>(null);\n // The stage's own live rendered size (it's `width: 100%` of the dialog body now, not a\n // fixed px box), read via ResizeObserver. `DEFAULT_STAGE` is only the guess for the very\n // first paint, before the observer's first callback lands.\n const [V, setV] = React.useState(DEFAULT_STAGE);\n const prevV = React.useRef(V);\n const [nat, setNat] = React.useState<{ w: number; h: number } | null>(null);\n const [zoom, setZoom] = React.useState(1);\n const [offset, setOffset] = React.useState({ x: 0, y: 0 });\n const drag = React.useRef<{ x: number; y: number } | null>(null);\n\n React.useEffect(() => {\n if (!stageEl) return;\n const ro = new ResizeObserver((entries) => {\n const w = Math.round(entries[0]?.contentRect.width ?? 0);\n if (!w || w === prevV.current) return;\n // A live resize while the dialog is open (a phone rotated, a window resized) or the\n // very first real measurement replacing `DEFAULT_STAGE`: rescale the pan offset by\n // the same factor as the viewport itself, so the framed crop doesn't jump. `scale`\n // (see below) is linear in `V`, so multiplying the offset by `newV / oldV` keeps\n // the same fraction of the image framed.\n const factor = w / prevV.current;\n prevV.current = w;\n setV(w);\n setOffset((o) => ({ x: o.x * factor, y: o.y * factor }));\n });\n ro.observe(stageEl);\n return () => ro.disconnect();\n }, [stageEl]);\n\n const scaleMin = nat ? V / Math.min(nat.w, nat.h) : 1;\n const scale = scaleMin * zoom;\n const dispW = nat ? nat.w * scale : V;\n const dispH = nat ? nat.h * scale : V;\n\n const clamp = React.useCallback(\n (o: { x: number; y: number }) => ({\n x: Math.min(0, Math.max(V - dispW, o.x)),\n y: Math.min(0, Math.max(V - dispH, o.y)),\n }),\n [V, dispW, dispH],\n );\n\n const onImgLoad = () => {\n const el = imgRef.current;\n if (!el) return;\n const w = el.naturalWidth;\n const h = el.naturalHeight;\n setNat({ w, h });\n const s = V / Math.min(w, h);\n setOffset({ x: (V - w * s) / 2, y: (V - h * s) / 2 });\n };\n\n const setZoomAt = (nextZoom: number) => {\n const z = Math.min(3, Math.max(1, nextZoom));\n setZoom((prevZ) => {\n const oldScale = scaleMin * prevZ;\n const newScale = scaleMin * z;\n setOffset((o) => {\n const imgX = (V / 2 - o.x) / oldScale;\n const imgY = (V / 2 - o.y) / oldScale;\n return clamp({ x: V / 2 - imgX * newScale, y: V / 2 - imgY * newScale });\n });\n return z;\n });\n };\n\n const onPointerDown = (e: React.PointerEvent) => {\n (e.target as HTMLElement).setPointerCapture(e.pointerId);\n drag.current = { x: e.clientX, y: e.clientY };\n };\n const onPointerMove = (e: React.PointerEvent) => {\n if (!drag.current) return;\n const dx = e.clientX - drag.current.x;\n const dy = e.clientY - drag.current.y;\n drag.current = { x: e.clientX, y: e.clientY };\n setOffset((o) => clamp({ x: o.x + dx, y: o.y + dy }));\n };\n const onPointerUp = () => {\n drag.current = null;\n };\n\n const save = () => {\n const el = imgRef.current;\n if (!el || !nat) return;\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = outputSize;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n const sSize = V / scale;\n ctx.drawImage(el, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);\n canvas.toBlob((b) => b && onSave(b), 'image/jpeg', 0.85);\n };\n\n return (\n // Wider than the default 352 (CameraModal's own dialog): three real Buttons in the\n // footer (Retake included) need the room, and `Dialog` already caps at `min(100%, …)`\n // for narrow viewports (see feedback/Dialog.tsx), so this needs no mobile-specific\n // handling of its own, it just shrinks like every other Dialog width already does.\n <Dialog width={400} onClose={onClose}>\n <Dialog.Header title={labels.cropTitle} description={labels.cropHint} />\n <Dialog.Body>\n <CropStage stageRef={setStageEl} onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} onWheel={(e) => setZoomAt(zoom - e.deltaY * 0.002)}>\n {/* eslint-disable-next-line @next/next/no-img-element */}\n <img\n ref={imgRef}\n src={src}\n alt=\"\"\n draggable={false}\n onLoad={onImgLoad}\n style={sx({ position: 'absolute', left: offset.x, top: offset.y, width: dispW, height: dispH, maxWidth: 'none', userSelect: 'none', pointerEvents: 'none' })}\n />\n </CropStage>\n\n <div style={sx({ display: 'flex', alignItems: 'center', gap: 'var(--space-3)', marginTop: 'var(--space-4)', color: 'var(--text-muted)' })}>\n <ZoomOut size={16} strokeWidth={1.75} style={{ flex: '0 0 auto' }} />\n <input\n type=\"range\"\n min={1}\n max={3}\n step={0.01}\n value={zoom}\n onChange={(e) => setZoomAt(Number(e.target.value))}\n aria-label={labels.zoom}\n style={sx({ flex: 1, accentColor: 'var(--interactive-primary)' })}\n />\n <ZoomIn size={16} strokeWidth={1.75} style={{ flex: '0 0 auto' }} />\n </div>\n </Dialog.Body>\n <Dialog.Footer>\n {onRetake && (\n <Button variant=\"secondary\" iconLeft={<RotateCcw size={16} strokeWidth={2} />} onClick={onRetake}>\n {labels.retake}\n </Button>\n )}\n <Button variant=\"secondary\" iconLeft={<X size={16} strokeWidth={2} />} onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button iconLeft={<Check size={16} strokeWidth={2.5} />} onClick={save}>\n {labels.save}\n </Button>\n </Dialog.Footer>\n </Dialog>\n );\n}\n\n/** Live camera capture via getUserMedia — falls back through `onError`. */\nfunction CameraModal({ labels, onCapture, onClose, onError }: { labels: AvatarUploadLabels; onCapture: (b: Blob) => void; onClose: () => void; onError: () => void }) {\n const videoRef = React.useRef<HTMLVideoElement>(null);\n const streamRef = React.useRef<MediaStream | null>(null);\n const [ready, setReady] = React.useState(false);\n\n React.useEffect(() => {\n let cancelled = false;\n const md = typeof navigator !== 'undefined' ? navigator.mediaDevices : undefined;\n if (!md?.getUserMedia) {\n onError();\n return;\n }\n md.getUserMedia({ video: { facingMode: 'user', width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false })\n .then((stream) => {\n if (cancelled) {\n stream.getTracks().forEach((tr) => tr.stop());\n return;\n }\n streamRef.current = stream;\n if (videoRef.current) videoRef.current.srcObject = stream;\n setReady(true);\n })\n .catch(onError);\n return () => {\n cancelled = true;\n streamRef.current?.getTracks().forEach((tr) => tr.stop());\n };\n }, [onError]);\n\n const shoot = () => {\n const v = videoRef.current;\n if (!v || !v.videoWidth) return;\n const s = Math.min(v.videoWidth, v.videoHeight);\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = s;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n ctx.translate(s, 0);\n ctx.scale(-1, 1);\n ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);\n canvas.toBlob((b) => b && onCapture(b), 'image/jpeg', 0.9);\n };\n\n return (\n <Dialog width={352} onClose={onClose}>\n <Dialog.Header title={labels.cameraTitle} description={labels.cameraHint} />\n <Dialog.Body>\n <CropStage>\n <video ref={videoRef} autoPlay playsInline muted style={sx({ width: '100%', height: '100%', objectFit: 'cover', transform: 'scaleX(-1)' })} />\n </CropStage>\n </Dialog.Body>\n <Dialog.Footer>\n <Button variant=\"secondary\" iconLeft={<X size={16} strokeWidth={2} />} onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button iconLeft={<Camera size={16} strokeWidth={2} />} onClick={shoot} disabled={!ready}>\n {labels.capture}\n </Button>\n </Dialog.Footer>\n </Dialog>\n );\n}\n"],"mappings":";AAsSM,cAEA,YAFA;AApSN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,OAAO,WAAW,QAAQ,WAAW,QAAQ,GAAG,QAAQ,eAAe;AACxF,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,cA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AAS,OAAO,UAAU,CAAC,OAChF,iBAAO,SACV;AAAA,OACF;AAAA,KACF;AAEJ;","names":["AvatarUpload"]}
1
+ {"version":3,"sources":["../../src/forms/AvatarUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Camera, Check, ImagePlus, Pencil, RotateCcw, Trash2, X, ZoomIn, ZoomOut } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { Dialog } from '../feedback/Dialog';\nimport { Button } from '../core/Button';\n\n/**\n * Profile-photo picker: an avatar disc with a camera button. Pick from the\n * library (or the camera on touch), frame the face in a circular crop, and it\n * hands back a **cropped, downscaled** `File` (JPEG). For attachments / documents\n * / multiple files use `FileUpload` instead.\n *\n * Client-side only downscales and re-encodes; it does not decode HEIC (no\n * browser but Safari can) — that is a server-side job. HEIC picks are rejected\n * with a message.\n */\n/** User-facing strings — English by default; pass overrides for another locale. */\nexport interface AvatarUploadLabels {\n trigger: string;\n upload: string;\n takePhoto: string;\n remove: string;\n cropTitle: string;\n cropHint: string;\n cameraTitle: string;\n cameraHint: string;\n capture: string;\n /** On the crop step, only shown for a shot taken with the camera; reopens it directly. */\n retake: string;\n cancel: string;\n save: string;\n zoom: string;\n heicError: string;\n notImage: string;\n tooLarge: (mb: number) => string;\n unreadable: string;\n cameraError: string;\n}\n\nconst EN: AvatarUploadLabels = {\n trigger: 'Change photo',\n upload: 'Upload a photo',\n takePhoto: 'Take a photo',\n remove: 'Remove photo',\n cropTitle: 'Adjust the photo',\n cropHint: 'Drag to reposition · scroll to zoom.',\n cameraTitle: 'Take a photo',\n cameraHint: 'Line your face up with the circle.',\n capture: 'Capture',\n retake: 'Retake',\n cancel: 'Cancel',\n save: 'Save',\n zoom: 'Zoom',\n heicError: \"That format (HEIC) won't open in the browser — upload a JPG or PNG.\",\n notImage: 'Choose an image file.',\n tooLarge: (mb) => `The image is over ${mb} MB.`,\n unreadable: \"Couldn't read that image. Try a JPG or PNG.\",\n cameraError: \"Couldn't open the camera — upload a photo from your library instead.\",\n};\n\nexport interface AvatarUploadProps {\n /** Full name — drives the initials fallback and the alt text. */\n name?: string;\n /** Current photo: a `File` (freshly cropped) or an existing URL string. */\n value?: File | string | null;\n onChange?: (file: File | null) => void;\n /** Disc diameter in px. */\n size?: number;\n /** Exported square size in px — the crop is drawn to this. */\n outputSize?: number;\n /** Reject picks larger than this (before crop). */\n maxSizeMB?: number;\n /** Override the English UI strings (menu, crop dialog, messages). */\n labels?: Partial<AvatarUploadLabels>;\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /**\n * Whether to allow taking a photo via camera (default true).\n * Set to `false` when picking an organization or brand logo, where taking a\n * live selfie/photo makes no sense.\n */\n allowCamera?: boolean;\n}\n\nfunction initials(name: string): string {\n return (name || '')\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((w) => w[0] || '')\n .join('')\n .toUpperCase();\n}\n\nconst isHeic = (f: File) => /image\\/heic|image\\/heif/i.test(f.type) || /\\.(heic|heif)$/i.test(f.name);\n\nexport const AvatarUpload = React.forwardRef<HTMLInputElement, AvatarUploadProps>(function AvatarUpload(\n {\n name = '',\n value,\n onChange,\n size = 96,\n outputSize = 512,\n maxSizeMB = 8,\n labels: labelsProp,\n label,\n hint,\n error,\n required,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n allowCamera = true,\n },\n forwardedRef,\n) {\n const t = React.useMemo<AvatarUploadLabels>(() => ({ ...EN, ...labelsProp }), [labelsProp]);\n const autoId = React.useId();\n const rid = id || autoId;\n const libRef = React.useRef<HTMLInputElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n const [menuOpen, setMenuOpen] = React.useState(false);\n const [menuPos, setMenuPos] = React.useState<{ top: number; left: number } | null>(null);\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [cropSrc, setCropSrc] = React.useState<string | null>(null);\n // Whether the photo now in the crop step came from the camera. Only then does the crop\n // modal offer \"Retake\" (a library pick already has its own way to change: cancel and pick\n // another file from the system's own dialog).\n const [cropFromCamera, setCropFromCamera] = React.useState(false);\n const [cameraOpen, setCameraOpen] = React.useState(false);\n const [internal, setInternal] = React.useState<File | null>(null);\n\n const current = value !== undefined ? value : internal;\n\n // Preview URL for the current photo.\n const [preview, setPreview] = React.useState<string | null>(typeof current === 'string' ? current : null);\n React.useEffect(() => {\n if (current instanceof File) {\n const u = URL.createObjectURL(current);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an object URL\n setPreview(u);\n return () => URL.revokeObjectURL(u);\n }\n setPreview(typeof current === 'string' ? current : null);\n }, [current]);\n\n const itemCount = (allowCamera ? 1 : 0) + 1 + (current ? 1 : 0);\n\n const toggleMenu = () => {\n if (!allowCamera && !current) {\n libRef.current?.click();\n return;\n }\n if (menuOpen) {\n setMenuOpen(false);\n return;\n }\n const r = triggerRef.current?.getBoundingClientRect();\n if (r) {\n const h = itemCount * 40 + 8;\n const flipUp = r.bottom + 6 + h > window.innerHeight - 8;\n setMenuPos({\n top: flipUp ? Math.max(8, r.top - 6 - h) : r.bottom + 6,\n left: Math.max(8, Math.min(r.left, window.innerWidth - 208)),\n });\n }\n setMenuOpen(true);\n };\n\n // Close the menu on outside click / Escape / scroll — it is portalled to <body>.\n React.useEffect(() => {\n if (!menuOpen) return;\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || menuRef.current?.contains(target)) return;\n setMenuOpen(false);\n };\n const close = () => setMenuOpen(false);\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();\n document.addEventListener('mousedown', onDown);\n document.addEventListener('keydown', onKey);\n window.addEventListener('scroll', close, true);\n window.addEventListener('resize', close);\n return () => {\n document.removeEventListener('mousedown', onDown);\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('scroll', close, true);\n window.removeEventListener('resize', close);\n };\n }, [menuOpen]);\n\n // Dialog doesn't lock scroll or bind Escape — do it here while a modal is up.\n // One dialog for the flow, on whichever step is current: the crop once there is a photo,\n // else the live camera. A shot or a Retake flips both at once, so the step just changes.\n const step: Step | null = cropSrc ? 'crop' : allowCamera && cameraOpen ? 'camera' : null;\n const modalUp = step !== null;\n React.useEffect(() => {\n if (!modalUp) 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') return;\n setCameraOpen(false);\n setCropSrc((s) => {\n if (s) URL.revokeObjectURL(s);\n return null;\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 };\n }, [modalUp]);\n\n const pick = (files: FileList | null) => {\n const f = files?.[0];\n if (!f) return;\n if (isHeic(f)) {\n setRejected(t.heicError);\n return;\n }\n if (!f.type.startsWith('image/')) {\n setRejected(t.notImage);\n return;\n }\n if (f.size > maxSizeMB * 1048576) {\n setRejected(t.tooLarge(maxSizeMB));\n return;\n }\n const url = URL.createObjectURL(f);\n const probe = new Image();\n probe.onload = () => {\n setRejected(null);\n setCropFromCamera(false);\n setCropSrc(url);\n };\n probe.onerror = () => {\n URL.revokeObjectURL(url);\n setRejected(t.unreadable);\n };\n probe.src = url;\n };\n\n const commit = (file: File | null) => {\n if (value === undefined) setInternal(file);\n onChange?.(file);\n };\n\n const onCropSave = (blob: Blob) => {\n const file = new File([blob], 'avatar.jpg', { type: 'image/jpeg' });\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n commit(file);\n };\n const onCropCancel = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n };\n\n const onCameraShot = (blob: Blob) => {\n setCameraOpen(false);\n setRejected(null);\n setCropFromCamera(true);\n setCropSrc(URL.createObjectURL(blob));\n };\n\n // Straight back to the live camera, no menu in between: the crop modal's \"Retake\".\n const onRetake = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n setCameraOpen(true);\n };\n\n const cameraBtn = Math.max(30, Math.round(size * 0.34));\n\n return (\n <Field label={label} hint={hint} error={error || rejected || undefined} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input ref={mergeRefs(libRef, forwardedRef)} id={rid} type=\"file\" accept=\"image/*\" disabled={disabled} onChange={(e) => pick(e.target.files)} style={{ display: 'none' }} />\n\n <div style={sx({ position: 'relative', width: size, height: size, flex: '0 0 auto', opacity: disabled ? 0.6 : 1 })}>\n <span\n style={sx({\n width: size,\n height: size,\n borderRadius: '999px',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: preview ? 'var(--bg-subtle)' : 'color-mix(in srgb, var(--brand-500) 22%, var(--bg-surface))',\n border: '1px solid ' + (preview ? 'var(--border-subtle)' : 'color-mix(in srgb, var(--brand-500) 30%, transparent)'),\n color: 'var(--text-brand)',\n fontFamily: 'var(--font-display)',\n fontWeight: 'var(--weight-bold)',\n fontSize: Math.round(size * 0.34),\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {preview ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={preview} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n initials(name) || <ImagePlus size={Math.round(size * 0.3)} strokeWidth={1.75} />\n )}\n </span>\n\n {!disabled && (\n <button\n ref={triggerRef}\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={t.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n onClick={toggleMenu}\n style={sx({\n position: 'absolute',\n right: -2,\n bottom: -2,\n width: cameraBtn,\n height: cameraBtn,\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-sm)',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <Pencil size={Math.round(cameraBtn * 0.46)} strokeWidth={1.75} />\n </button>\n )}\n\n </div>\n\n {menuOpen &&\n menuPos &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n style={sx({\n position: 'fixed',\n top: menuPos.top,\n left: menuPos.left,\n minWidth: 200,\n zIndex: 1000,\n padding: 'var(--space-1)',\n borderRadius: 'var(--radius-md)',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-lg)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n <MenuItem\n icon={<ImagePlus size={16} strokeWidth={1.75} />}\n label={t.upload}\n onClick={() => {\n setMenuOpen(false);\n libRef.current?.click();\n }}\n />\n {allowCamera && (\n <MenuItem\n icon={<Camera size={16} strokeWidth={1.75} />}\n label={t.takePhoto}\n onClick={() => {\n setMenuOpen(false);\n setRejected(null);\n setCameraOpen(true);\n }}\n />\n )}\n {current && (\n <MenuItem\n icon={<Trash2 size={16} strokeWidth={1.75} />}\n label={t.remove}\n danger\n onClick={() => {\n setMenuOpen(false);\n commit(null);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n\n {step && (\n <CaptureDialog\n step={step}\n src={cropSrc}\n outputSize={outputSize}\n labels={t}\n onClose={step === 'camera' ? () => setCameraOpen(false) : onCropCancel}\n onCameraShot={onCameraShot}\n onCameraError={() => {\n setCameraOpen(false);\n setRejected(t.cameraError);\n }}\n onSave={onCropSave}\n onRetake={cropFromCamera ? onRetake : undefined}\n />\n )}\n </Field>\n );\n});\n\nAvatarUpload.displayName = 'AvatarUpload';\n\nfunction MenuItem({ icon, label, onClick, danger }: { icon: React.ReactNode; label: string; onClick: () => void; danger?: boolean }) {\n const [hover, setHover] = React.useState(false);\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={onClick}\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n minHeight: 40,\n padding: '0 var(--space-3)',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: hover ? 'var(--bg-subtle)' : 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: danger ? 'var(--interactive-error)' : 'var(--text-primary)',\n textAlign: 'left',\n })}\n >\n {icon}\n {label}\n </button>\n );\n}\n\nconst DEFAULT_STAGE = 280; // crop stage's assumed size (px) before its own ResizeObserver measures it\n\n/**\n * Width of the camera and crop dialogs. They are two steps of one flow (a shot goes straight\n * to the crop), so they share it: a dialog that changed size between the steps would jump.\n * Wider than `Dialog`'s default 352: with Retake the crop footer has three real Buttons, and\n * in Portuguese (\"Tirar outra\", \"Cancelar\", \"Gravar\") they add up to 384px, more than the\n * 358px of content a 400px dialog leaves. 440 gives 398px, so they fit on one line with ~14px\n * to spare. `Dialog` already caps at `min(100%, ...)` for narrow viewports (see\n * feedback/Dialog.tsx), so a phone just gets a narrower dialog. Widening only moves the limit\n * though: the crop footer's `fill` is what keeps a longer language, or that phone, from\n * stranding the primary button.\n */\nconst MODAL_WIDTH = 440;\n\n/** Height reserved for the zoom row, so the camera step (which has none) is as tall as the crop step. */\nconst ZOOM_ROW_HEIGHT = 24;\n\n/**\n * The square viewport + circular guide, shared by the crop and camera modals.\n * `width: 100%` + `aspectRatio: 1`, not a fixed pixel box: it spans exactly the same\n * width as `Dialog.Header`'s title and `Dialog.Footer`'s buttons (both just block-level\n * or flex content inside the same padded `Dialog.Body`), instead of a fixed size\n * centered with margins of its own that didn't match theirs (SS-322 follow-up, the\n * stage read as misaligned from the rest of the dialog). Also needs no separate\n * mobile-width handling of its own: whatever width the dialog ends up at (already\n * responsive, see `feedback/Dialog.tsx`), the stage fills it exactly, staying square\n * via `aspectRatio`.\n */\nfunction CropStage({ children, onPointerDown, onPointerMove, onPointerUp, onWheel, stageRef }: {\n children: React.ReactNode;\n onPointerDown?: (e: React.PointerEvent) => void;\n onPointerMove?: (e: React.PointerEvent) => void;\n onPointerUp?: (e: React.PointerEvent) => void;\n onWheel?: (e: React.WheelEvent) => void;\n /** `useCropper` reads the live rendered size off this to drive the crop math (`V`). */\n stageRef?: React.Ref<HTMLDivElement>;\n}) {\n return (\n <div\n ref={stageRef}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onWheel={onWheel}\n style={sx({\n position: 'relative',\n width: '100%',\n aspectRatio: '1',\n overflow: 'hidden',\n borderRadius: 'var(--radius-lg)',\n background: 'var(--bg-sunken)',\n cursor: onPointerDown ? 'grab' : 'default',\n touchAction: 'none',\n })}\n >\n {children}\n <span\n style={sx({\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: '999px',\n boxShadow: '0 0 0 9999px color-mix(in srgb, var(--bg-overlay) 80%, transparent)',\n outline: '1px solid rgba(255, 255, 255, 0.9)',\n outlineOffset: -1,\n })}\n />\n </div>\n );\n}\n\n/** Which step of the photo flow the dialog is on. */\ntype Step = 'camera' | 'crop';\n\n/**\n * Live camera via `getUserMedia`, while `active`. A failure (no API, permission denied)\n * goes through `onError`. `ready` turns true once the stream is flowing; going inactive\n * stops the tracks, so the camera light goes off as soon as the dialog leaves this step.\n */\nfunction useCamera(active: boolean, onError: () => void) {\n const videoRef = React.useRef<HTMLVideoElement | null>(null);\n const streamRef = React.useRef<MediaStream | null>(null);\n const [ready, setReady] = React.useState(false);\n // Read through a ref so a new `onError` closure each render does not restart the camera.\n const onErrorRef = React.useRef(onError);\n React.useEffect(() => {\n onErrorRef.current = onError;\n });\n\n React.useEffect(() => {\n if (!active) return;\n let cancelled = false;\n let started: MediaStream | null = null;\n const md = typeof navigator !== 'undefined' ? navigator.mediaDevices : undefined;\n if (!md?.getUserMedia) {\n onErrorRef.current();\n return;\n }\n md.getUserMedia({ video: { facingMode: 'user', width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false })\n .then((s) => {\n if (cancelled) {\n s.getTracks().forEach((tr) => tr.stop());\n return;\n }\n started = s;\n streamRef.current = s;\n if (videoRef.current) videoRef.current.srcObject = s;\n setReady(true);\n })\n .catch(() => onErrorRef.current());\n return () => {\n cancelled = true;\n started?.getTracks().forEach((tr) => tr.stop());\n streamRef.current = null;\n setReady(false);\n };\n }, [active]);\n\n // The `<video>` may mount after the stream arrives (`Dialog` renders its children a render\n // late) or the other way round, so wire them up whichever comes last: here for the element,\n // above for the stream.\n const attachVideo = React.useCallback((el: HTMLVideoElement | null) => {\n videoRef.current = el;\n if (el && streamRef.current) el.srcObject = streamRef.current;\n }, []);\n\n /** Grabs the centred square of the current frame, mirrored like the preview, as a JPEG. */\n const shoot = (onShot: (b: Blob) => void) => {\n const v = videoRef.current;\n if (!v || !v.videoWidth) return;\n const s = Math.min(v.videoWidth, v.videoHeight);\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = s;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n ctx.translate(s, 0);\n ctx.scale(-1, 1);\n ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);\n canvas.toBlob((b) => b && onShot(b), 'image/jpeg', 0.9);\n };\n\n return { attachVideo, ready, shoot };\n}\n\n/**\n * The crop state and math for one picked photo (`src`): pan, zoom, the stage's live size,\n * and the export. It lives above the dialog, not inside the crop step, so the header, body\n * and footer of a single `Dialog` can all read it while the camera step swaps in and out.\n * Everything resets when `src` changes, so a retaken photo starts centred at 1x.\n */\nfunction useCropper(src: string | null, outputSize: number) {\n const [imgEl, setImgEl] = React.useState<HTMLImageElement | null>(null);\n // A *callback* ref (kept as state), not a plain `useRef` + a `[]`-effect: `Dialog` renders\n // its children only from the render *after* its own `mounted` flips true (SSR-safe portal),\n // so on the stage's very first mount a `useEffect(..., [])` reading `stageRef.current` at\n // that point would still see `null` and, with no deps to fire again on, never retry, so `V`\n // would then stay stuck at the `DEFAULT_STAGE` guess forever (this exact bug, caught live:\n // the displayed image stayed 280px inside a stage CSS had already sized at ~344px, a gray\n // gap on two edges). The callback fires the moment React actually attaches the node.\n const [stageEl, setStageEl] = React.useState<HTMLDivElement | null>(null);\n // The stage's own live rendered size (it's `width: 100%` of the dialog body now, not a\n // fixed px box), read via ResizeObserver. `DEFAULT_STAGE` is only the guess for the very\n // first paint, before the observer's first callback lands.\n const [V, setV] = React.useState(DEFAULT_STAGE);\n const prevV = React.useRef(V);\n const [nat, setNat] = React.useState<{ w: number; h: number } | null>(null);\n const [zoom, setZoom] = React.useState(1);\n const [offset, setOffset] = React.useState({ x: 0, y: 0 });\n const drag = React.useRef<{ x: number; y: number } | null>(null);\n\n // A new photo starts from scratch. Adjusting state while rendering (rather than in an\n // effect) means the stale pan / zoom is never painted against the new image.\n const [seenSrc, setSeenSrc] = React.useState(src);\n if (src !== seenSrc) {\n setSeenSrc(src);\n setNat(null);\n setZoom(1);\n setOffset({ x: 0, y: 0 });\n }\n\n React.useEffect(() => {\n if (!stageEl) return;\n const ro = new ResizeObserver((entries) => {\n const w = Math.round(entries[0]?.contentRect.width ?? 0);\n if (!w || w === prevV.current) return;\n // A live resize while the dialog is open (a phone rotated, a window resized) or the\n // very first real measurement replacing `DEFAULT_STAGE`: rescale the pan offset by\n // the same factor as the viewport itself, so the framed crop doesn't jump. `scale`\n // (see below) is linear in `V`, so multiplying the offset by `newV / oldV` keeps\n // the same fraction of the image framed.\n const factor = w / prevV.current;\n prevV.current = w;\n setV(w);\n setOffset((o) => ({ x: o.x * factor, y: o.y * factor }));\n });\n ro.observe(stageEl);\n return () => ro.disconnect();\n }, [stageEl]);\n\n const scaleMin = nat ? V / Math.min(nat.w, nat.h) : 1;\n const scale = scaleMin * zoom;\n const dispW = nat ? nat.w * scale : V;\n const dispH = nat ? nat.h * scale : V;\n\n const clamp = React.useCallback(\n (o: { x: number; y: number }) => ({\n x: Math.min(0, Math.max(V - dispW, o.x)),\n y: Math.min(0, Math.max(V - dispH, o.y)),\n }),\n [V, dispW, dispH],\n );\n\n const onImgLoad = (el: HTMLImageElement) => {\n const w = el.naturalWidth;\n const h = el.naturalHeight;\n setNat({ w, h });\n const s = V / Math.min(w, h);\n setOffset({ x: (V - w * s) / 2, y: (V - h * s) / 2 });\n };\n\n const setZoomAt = (nextZoom: number) => {\n const z = Math.min(3, Math.max(1, nextZoom));\n setZoom((prevZ) => {\n const oldScale = scaleMin * prevZ;\n const newScale = scaleMin * z;\n setOffset((o) => {\n const imgX = (V / 2 - o.x) / oldScale;\n const imgY = (V / 2 - o.y) / oldScale;\n return clamp({ x: V / 2 - imgX * newScale, y: V / 2 - imgY * newScale });\n });\n return z;\n });\n };\n\n const onPointerDown = (e: React.PointerEvent) => {\n (e.target as HTMLElement).setPointerCapture(e.pointerId);\n drag.current = { x: e.clientX, y: e.clientY };\n };\n const onPointerMove = (e: React.PointerEvent) => {\n if (!drag.current) return;\n const dx = e.clientX - drag.current.x;\n const dy = e.clientY - drag.current.y;\n drag.current = { x: e.clientX, y: e.clientY };\n setOffset((o) => clamp({ x: o.x + dx, y: o.y + dy }));\n };\n const onPointerUp = () => {\n drag.current = null;\n };\n\n const save = (onSave: (b: Blob) => void) => {\n if (!imgEl || !nat) return;\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = outputSize;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n const sSize = V / scale;\n ctx.drawImage(imgEl, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);\n canvas.toBlob((b) => b && onSave(b), 'image/jpeg', 0.85);\n };\n\n return { setImgEl, setStageEl, zoom, setZoomAt, offset, dispW, dispH, onImgLoad, onPointerDown, onPointerMove, onPointerUp, save };\n}\n\n/**\n * The one dialog for the whole photo flow: the live camera, then the crop (and back, on\n * Retake). It stays mounted across the steps and only its header text, stage and buttons\n * swap, so the panel does not close and reopen (no second pop-in, no scroll-lock or focus\n * hand-off) and it keeps one size. `Dialog.Header` / `Body` / `Footer` are direct children\n * on purpose: `Dialog` reads them off its children to pad the body and label itself, which\n * a wrapper component per step would hide from it.\n */\nfunction CaptureDialog({\n step,\n src,\n outputSize,\n labels,\n onClose,\n onCameraShot,\n onCameraError,\n onSave,\n onRetake,\n}: {\n step: Step;\n /** The photo being cropped; only set on the crop step. */\n src: string | null;\n outputSize: number;\n labels: AvatarUploadLabels;\n onClose: () => void;\n onCameraShot: (b: Blob) => void;\n onCameraError: () => void;\n onSave: (b: Blob) => void;\n /** Only set for a shot taken with the camera; shows the \"Retake\" button. */\n onRetake?: () => void;\n}) {\n const isCamera = step === 'camera';\n const camera = useCamera(isCamera, onCameraError);\n const crop = useCropper(src, outputSize);\n\n // The step's buttons unmount with it, and with them the focused one: without this, focus\n // would fall to the page behind the dialog and Tab would leave the trap. `Dialog` only\n // pulls focus in when it opens, so do it again on every step change.\n const [contentEl, setContentEl] = React.useState<HTMLDivElement | null>(null);\n React.useEffect(() => {\n contentEl?.closest<HTMLElement>('[role=\"dialog\"]')?.focus();\n }, [step, contentEl]);\n\n /* eslint-disable react-hooks/refs -- `useCamera` / `useCropper` return event handlers that reach a\n ref (`videoRef`, the drag origin), so the lint marks every property read off them; but those\n refs are only touched when a handler runs from an event, never during this render. */\n return (\n <Dialog width={MODAL_WIDTH} onClose={onClose}>\n <Dialog.Header title={isCamera ? labels.cameraTitle : labels.cropTitle} description={isCamera ? labels.cameraHint : labels.cropHint} />\n <Dialog.Body>\n <div ref={setContentEl}>\n {isCamera ? (\n <CropStage key=\"camera\">\n <video ref={camera.attachVideo} autoPlay playsInline muted style={sx({ width: '100%', height: '100%', objectFit: 'cover', transform: 'scaleX(-1)' })} />\n </CropStage>\n ) : (\n <CropStage\n key=\"crop\"\n stageRef={crop.setStageEl}\n onPointerDown={crop.onPointerDown}\n onPointerMove={crop.onPointerMove}\n onPointerUp={crop.onPointerUp}\n onWheel={(e) => crop.setZoomAt(crop.zoom - e.deltaY * 0.002)}\n >\n {src && (\n // eslint-disable-next-line @next/next/no-img-element\n <img\n ref={crop.setImgEl}\n src={src}\n alt=\"\"\n draggable={false}\n onLoad={(e) => crop.onImgLoad(e.currentTarget)}\n style={sx({ position: 'absolute', left: crop.offset.x, top: crop.offset.y, width: crop.dispW, height: crop.dispH, maxWidth: 'none', userSelect: 'none', pointerEvents: 'none' })}\n />\n )}\n </CropStage>\n )}\n\n {/* The zoom row is only there on the crop step, but the camera step keeps its room, so the dialog is the same height on both. */}\n <div style={sx({ display: 'flex', alignItems: 'center', gap: 'var(--space-3)', marginTop: 'var(--space-4)', minHeight: ZOOM_ROW_HEIGHT, color: 'var(--text-muted)' })}>\n {!isCamera && (\n <>\n <ZoomOut size={16} strokeWidth={1.75} style={{ flex: '0 0 auto' }} />\n <input\n type=\"range\"\n min={1}\n max={3}\n step={0.01}\n value={crop.zoom}\n onChange={(e) => crop.setZoomAt(Number(e.target.value))}\n aria-label={labels.zoom}\n style={sx({ flex: 1, accentColor: 'var(--interactive-primary)' })}\n />\n <ZoomIn size={16} strokeWidth={1.75} style={{ flex: '0 0 auto' }} />\n </>\n )}\n </div>\n </div>\n </Dialog.Body>\n {/* Three actions (crop after a camera shot, with Retake) share the row and each line they wrap onto; two stay right-aligned, as before. */}\n <Dialog.Footer fill={!isCamera && Boolean(onRetake)}>\n {isCamera ? (\n <React.Fragment key=\"camera\">\n <Button variant=\"secondary\" iconLeft={<X size={16} strokeWidth={2} />} onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button iconLeft={<Camera size={16} strokeWidth={2} />} onClick={() => camera.shoot(onCameraShot)} disabled={!camera.ready}>\n {labels.capture}\n </Button>\n </React.Fragment>\n ) : (\n <React.Fragment key=\"crop\">\n {onRetake && (\n <Button variant=\"secondary\" iconLeft={<RotateCcw size={16} strokeWidth={2} />} onClick={onRetake}>\n {labels.retake}\n </Button>\n )}\n <Button variant=\"secondary\" iconLeft={<X size={16} strokeWidth={2} />} onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button iconLeft={<Check size={16} strokeWidth={2.5} />} onClick={() => crop.save(onSave)}>\n {labels.save}\n </Button>\n </React.Fragment>\n )}\n </Dialog.Footer>\n </Dialog>\n );\n /* eslint-enable react-hooks/refs */\n}\n"],"mappings":";AAySM,SAogBQ,UApgBR,KAEA,YAFA;AAvSN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,OAAO,WAAW,QAAQ,WAAW,QAAQ,GAAG,QAAQ,eAAe;AACxF,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,cAAc;AAmCvB,MAAM,KAAyB;AAAA,EAC7B,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU,CAAC,OAAO,qBAAqB,EAAE;AAAA,EACzC,YAAY;AAAA,EACZ,aAAa;AACf;AAkCA,SAAS,SAAS,MAAsB;AACtC,UAAQ,QAAQ,IACb,KAAK,EACL,MAAM,KAAK,EACX,MAAM,GAAG,CAAC,EACV,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EACrB,KAAK,EAAE,EACP,YAAY;AACjB;AAEA,MAAM,SAAS,CAAC,MAAY,2BAA2B,KAAK,EAAE,IAAI,KAAK,kBAAkB,KAAK,EAAE,IAAI;AAE7F,MAAM,eAAe,MAAM,WAAgD,SAASA,cACzF;AAAA,EACE,OAAO;AAAA,EACP;AAAA,EACA;AAA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AC,UAAO,UAAU,oBAAC,UAAO,MAAM,IAAI,aAAa,GAAG,GAAI,SAAS,MAAM,OAAO,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,OAClH,iBAAO,SACV;AAAA,SANkB,QAOpB,IAEA,qBAAC,MAAM,UAAN,EACE;AAAA,kBACC,oBAAC,UAAO,SAAQ,aAAY,UAAU,oBAAC,aAAU,MAAM,IAAI,aAAa,GAAG,GAAI,SAAS,UACrF,iBAAO,QACV;AAAA,MAEF,oBAAC,UAAO,SAAQ,aAAY,UAAU,oBAAC,KAAE,MAAM,IAAI,aAAa,GAAG,GAAI,SAAS,SAC7E,iBAAO,QACV;AAAA,MACA,oBAAC,UAAO,UAAU,oBAAC,SAAM,MAAM,IAAI,aAAa,KAAK,GAAI,SAAS,MAAM,KAAK,KAAK,MAAM,GACrF,iBAAO,MACV;AAAA,SAXkB,MAYpB,GAEJ;AAAA,KACF;AAGJ;","names":["AvatarUpload"]}
package/dist/styles.css CHANGED
@@ -231,6 +231,9 @@
231
231
  Header ✕ button — hover/focus states that can't be inline. */
232
232
  .sereno-dialog-close:hover { background: var(--interactive-ghost-hover); color: var(--text-primary); }
233
233
  .sereno-dialog-close:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
234
+ /* Footer `fill`: every action shares each line and grows to fill it, so a wrap never leaves one
235
+ small button alone at the right. It targets the footer's children, hence not inline. */
236
+ .sereno-dialog-footer[data-fill] > * { flex: 1 1 auto; }
234
237
 
235
238
  /* ── Dismiss ✕ (Alert / Toast) ─────────────────────────────────────────────
236
239
  Ghost icon button on a tinted surface — tint the hover from currentColor so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sereno-ds/ui",
3
- "version": "0.36.0",
3
+ "version": "0.36.1",
4
4
  "description": "Sereno Design System — React primitives (token-driven, inline styles, no UI base lib).",
5
5
  "license": "MIT",
6
6
  "author": "Sereno",