@sereno-ds/ui 0.41.2 → 0.41.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/_internal/useIsoLayoutEffect.d.ts +1 -1
  2. package/dist/_internal/useOutsidePress.d.ts +15 -0
  3. package/dist/_internal/useOutsidePress.js +20 -0
  4. package/dist/_internal/useOutsidePress.js.map +1 -0
  5. package/dist/core/Menu.js +2 -10
  6. package/dist/core/Menu.js.map +1 -1
  7. package/dist/forms/Autocomplete.js +2 -11
  8. package/dist/forms/Autocomplete.js.map +1 -1
  9. package/dist/forms/AvatarUpload.js +3 -258
  10. package/dist/forms/AvatarUpload.js.map +1 -1
  11. package/dist/forms/DatePicker.js +3 -11
  12. package/dist/forms/DatePicker.js.map +1 -1
  13. package/dist/forms/Select.js +2 -10
  14. package/dist/forms/Select.js.map +1 -1
  15. package/dist/forms/_internal/AvatarCaptureDialog.d.ts +28 -0
  16. package/dist/forms/_internal/AvatarCaptureDialog.js +127 -0
  17. package/dist/forms/_internal/AvatarCaptureDialog.js.map +1 -0
  18. package/dist/forms/_internal/CalendarGrid.js +6 -11
  19. package/dist/forms/_internal/CalendarGrid.js.map +1 -1
  20. package/dist/forms/_internal/useCamera.d.ts +12 -0
  21. package/dist/forms/_internal/useCamera.js +58 -0
  22. package/dist/forms/_internal/useCamera.js.map +1 -0
  23. package/dist/forms/_internal/useCropper.d.ts +27 -0
  24. package/dist/forms/_internal/useCropper.js +92 -0
  25. package/dist/forms/_internal/useCropper.js.map +1 -0
  26. package/dist/index.d.ts +2 -1
  27. package/dist/navigation/SidebarNav.d.ts +3 -43
  28. package/dist/navigation/SidebarNav.js +4 -415
  29. package/dist/navigation/SidebarNav.js.map +1 -1
  30. package/dist/navigation/_internal/SidebarNavItems.d.ts +46 -0
  31. package/dist/navigation/_internal/SidebarNavItems.js +299 -0
  32. package/dist/navigation/_internal/SidebarNavItems.js.map +1 -0
  33. package/dist/navigation/_internal/SidebarSubmenuPopover.d.ts +13 -0
  34. package/dist/navigation/_internal/SidebarSubmenuPopover.js +129 -0
  35. package/dist/navigation/_internal/SidebarSubmenuPopover.js.map +1 -0
  36. package/dist/navigation/_internal/sidebarNavContext.d.ts +24 -0
  37. package/dist/navigation/_internal/sidebarNavContext.js +14 -0
  38. package/dist/navigation/_internal/sidebarNavContext.js.map +1 -0
  39. package/package.json +1 -1
@@ -7,6 +7,7 @@ import { sx } from "../_internal/style.js";
7
7
  import { acquireScrollLock } from "../_internal/scrollLock.js";
8
8
  import { useCoarsePointer } from "../_internal/useCoarsePointer.js";
9
9
  import { useMenuPlacement } from "../_internal/useMenuPlacement.js";
10
+ import { useOutsidePress } from "../_internal/useOutsidePress.js";
10
11
  import { useRevealActive } from "../_internal/useRevealActive.js";
11
12
  import { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from "../_internal/MenuOption.js";
12
13
  import { Field } from "../_internal/Field.js";
@@ -59,16 +60,7 @@ function CustomSelect({
59
60
  }
60
61
  return from;
61
62
  };
62
- React.useEffect(() => {
63
- if (!open || coarse) return;
64
- const onDown = (e) => {
65
- const target = e.target;
66
- if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return;
67
- setOpen(false);
68
- };
69
- document.addEventListener("pointerdown", onDown, true);
70
- return () => document.removeEventListener("pointerdown", onDown, true);
71
- }, [open, coarse]);
63
+ useOutsidePress(open && !coarse, [triggerRef, panelRef], () => setOpen(false));
72
64
  React.useEffect(() => {
73
65
  if (!open || !coarse) return;
74
66
  return acquireScrollLock();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { acquireScrollLock } from '../_internal/scrollLock';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/**\n * Single-choice select - a hand-rolled listbox (token-styled, full keyboard\n * support) so it looks and behaves the same in every browser. On a mouse it's\n * an anchored dropdown; on touch it opens as a bottom sheet with finger-sized\n * rows.\n *\n * Value contract: `value` / `defaultValue` + `onValueChange(value)` - a plain\n * string, not a DOM event.\n */\nexport interface SelectProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n options?: SelectOption[];\n /** Shown in muted text on the trigger when nothing is selected. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value. */\n value?: string;\n /** Uncontrolled initial value. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Form field name - mirrored to a hidden input so the value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the trigger. Only needed when there's no visible\n * `label` (e.g. a compact row where the context is already clear visually,\n * a day name next to a \"start time\" / \"end time\" pair): `Field` only\n * renders a `<label>` when `label` is set, so without either the trigger\n * has no accessible name at all. Takes precedence over `label` if both are\n * set - don't pass both.\n */\n 'aria-label'?: string;\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\n// ── Custom listbox ──────────────────────────────────────────────────────────\nfunction CustomSelect({\n rid,\n label,\n ariaLabel,\n options,\n value,\n placeholder,\n size,\n error,\n disabled,\n coarse,\n fieldAria,\n onCommit,\n}: {\n rid: string;\n /** The field label - shown as the sheet header on touch so the picker has context. */\n label?: string;\n /** Falls back to `label` when there's no visible one at all. */\n ariaLabel?: string;\n options: SelectOption[];\n value: string;\n placeholder?: string;\n size: NonNullable<SelectProps['size']>;\n error: boolean;\n disabled?: boolean;\n /** Touch: open as a bottom sheet with finger-sized rows instead of a dropdown. */\n coarse: boolean;\n /** `aria-invalid` / `aria-describedby` tying the trigger to the field's hint / error line. */\n fieldAria: ReturnType<typeof fieldA11y>;\n onCommit: (v: string) => void;\n}) {\n const listboxId = `${rid}-listbox`;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const panelRef = React.useRef<HTMLUListElement>(null);\n const typeahead = React.useRef<{ str: string; timer: number }>({ str: '', timer: 0 });\n // A <label htmlFor> forwards a fully-trusted click to this button (detail:1),\n // indistinguishable from a direct one - but its *pointerdown* landed on the\n // label, not here. So only toggle when the press actually started on the box.\n const pressedAt = React.useRef(0);\n\n const [open, setOpen] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(-1);\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 // Where the dropdown sits (inline under the field, or portalled to the body inside a Dialog): see\n // `useMenuPlacement`. The touch sheet needs no anchoring.\n const place = useMenuPlacement({\n open,\n disabled: coarse,\n anchorRef: triggerRef,\n panelRef,\n itemCount: options.length,\n onDismiss: () => setOpen(false),\n });\n\n const selectedIndex = options.findIndex((o) => o.value === value);\n const selected = selectedIndex >= 0 ? options[selectedIndex] : undefined;\n\n const firstEnabled = () => options.findIndex((o) => !o.disabled);\n const lastEnabled = () => {\n for (let i = options.length - 1; i >= 0; i--) if (!options[i].disabled) return i;\n return -1;\n };\n const nextEnabled = (from: number, dir: 1 | -1) => {\n let i = from;\n for (let step = 0; step < options.length; step++) {\n i += dir;\n if (i < 0 || i >= options.length) return from;\n if (!options[i].disabled) return i;\n }\n return from;\n };\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n React.useEffect(() => {\n if (!open || coarse) return;\n const onDown = (e: PointerEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n setOpen(false);\n };\n document.addEventListener('pointerdown', onDown, true);\n return () => document.removeEventListener('pointerdown', onDown, true);\n }, [open, coarse]);\n\n // The touch sheet is a modal surface - lock the page scroll behind it. Through the shared lock,\n // so a Select inside a Dialog (two held at once) frees the page whichever lets go first.\n React.useEffect(() => {\n if (!open || !coarse) return;\n return acquireScrollLock();\n }, [open, coarse]);\n\n // Keep the active option in view, the first time the list opens too (SS-568): see `useRevealActive`.\n useRevealActive(open, activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null, place);\n\n const openMenu = () => {\n if (disabled) return;\n setActiveIndex(selectedIndex >= 0 ? selectedIndex : firstEnabled());\n setOpen(true);\n };\n const closeMenu = (refocus = true) => {\n setOpen(false);\n if (refocus) triggerRef.current?.focus({ preventScroll: true });\n };\n const choose = (i: number) => {\n const o = options[i];\n if (!o || o.disabled) return;\n onCommit(o.value);\n closeMenu();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? -1 : i, 1));\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? options.length : i, -1));\n return;\n case 'Home':\n if (open) {\n e.preventDefault();\n setActiveIndex(firstEnabled());\n }\n return;\n case 'End':\n if (open) {\n e.preventDefault();\n setActiveIndex(lastEnabled());\n }\n return;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!open) return openMenu();\n choose(activeIndex);\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n closeMenu();\n }\n return;\n case 'Tab':\n if (open) setOpen(false);\n return;\n default:\n if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {\n const ta = typeahead.current;\n ta.str += e.key.toLowerCase();\n window.clearTimeout(ta.timer);\n ta.timer = window.setTimeout(() => (ta.str = ''), 500);\n const match = options.findIndex((o) => !o.disabled && o.label.toLowerCase().startsWith(ta.str));\n if (match >= 0) {\n if (!open) openMenu();\n setActiveIndex(match);\n }\n }\n }\n };\n\n const hasValue = !!selected;\n const rowPadY = menuRowPadY(coarse, size);\n\n const listStyleBase: React.CSSProperties = { ...menuSurfaceStyle(size), ...menuListStyle };\n const optionRows = options.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === value}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n />\n ));\n\n return (\n <div style={sx({ position: 'relative', width: '100%' })}>\n <button\n ref={triggerRef}\n type=\"button\"\n id={rid}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n aria-disabled={disabled || undefined}\n disabled={disabled}\n onPointerDown={() => {\n pressedAt.current = Date.now();\n }}\n onMouseDown={(e) => {\n // Take focus without the browser scrolling us into view.\n e.preventDefault();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n onClick={() => {\n // Only toggle when the press started on this button - a click forwarded\n // from the field <label>, or synthesised by the keyboard, never set\n // pressedAt (keyboard is handled in onKeyDown).\n if (Date.now() - pressedAt.current > 500) return;\n pressedAt.current = 0;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={onKeyDown}\n style={fieldBoxStyle(size, error, open, !!disabled)}\n >\n <span\n style={sx({\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: hasValue ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {hasValue ? selected!.label : placeholder ?? 'Select…'}\n </span>\n <span\n aria-hidden=\"true\"\n style={sx({\n display: 'flex',\n flex: '0 0 auto',\n color: 'var(--text-muted)',\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </span>\n </button>\n\n {open && mounted && coarse &&\n createPortal(\n <div\n role=\"presentation\"\n onClick={() => closeMenu()}\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1100,\n display: 'flex',\n alignItems: 'flex-end',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-standard)',\n })}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={sx({\n width: '100%',\n maxHeight: '70dvh',\n display: 'flex',\n flexDirection: 'column',\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-sheet) var(--radius-sheet) 0 0',\n boxShadow: 'var(--shadow-sheet)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n animation: 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)',\n })}\n >\n {label && (\n <div\n style={sx({\n flex: '0 0 auto',\n padding: 'var(--space-3) var(--space-4)',\n borderBottom: 'var(--border-width-hairline) solid var(--border-subtle)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n color: 'var(--text-primary)',\n })}\n >\n {label}\n </div>\n )}\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={label}\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n flex: '1 1 auto',\n minHeight: 0,\n border: 'none',\n borderRadius: 0,\n boxShadow: 'none',\n background: 'transparent',\n padding: 'var(--space-2)',\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {optionRows}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n {open && !coarse && place && place.strategy === 'inline' && (\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n maxHeight: place.maxH,\n zIndex: 100,\n })}\n >\n {optionRows}\n </ul>\n )}\n {open && !coarse && mounted && place && place.strategy === 'fixed' &&\n createPortal(\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n maxHeight: place.maxH,\n zIndex: 1100,\n })}\n >\n {optionRows}\n </ul>,\n document.body,\n )}\n </div>\n );\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the selected\n * value (rendered only when `name` is set - pass it, as `register()` does).\n * Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain\n * `{...register(name)}` spread still won't validate on change: this hidden\n * input never dispatches a native `input`/`change` event, and `onValueChange`\n * hands back a plain string, not a `ChangeEvent` - wire it through\n * `Controller`, or call the registered `onChange` yourself from\n * `onValueChange`.\n */\nexport const Select = React.forwardRef<HTMLInputElement, SelectProps>(function Select({\n label,\n hint,\n error,\n required,\n options = [],\n placeholder,\n size = 'md',\n disabled,\n value: valueProp,\n defaultValue,\n onValueChange,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n}: SelectProps, ref) {\n const reactId = React.useId();\n const rid = id || reactId;\n const isControlled = valueProp !== undefined;\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? '');\n const value = isControlled ? valueProp! : internalValue;\n const coarse = useCoarsePointer();\n\n const commit = React.useCallback(\n (v: string) => {\n if (!isControlled) setInternalValue(v);\n onValueChange?.(v);\n },\n [isControlled, onValueChange],\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <CustomSelect\n rid={rid}\n label={label}\n ariaLabel={ariaLabel}\n options={options}\n value={value}\n placeholder={placeholder}\n size={size}\n error={!!error}\n disabled={disabled}\n coarse={coarse}\n fieldAria={fieldA11y(rid, { hint, error, required })}\n onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AAiPI,cAgBE,YAhBF;AA/OJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,YAAY,eAAe,aAAa,wBAAwB;AACzE,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAoD9B,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAiBG;AACD,QAAM,YAAY,GAAG,GAAG;AACxB,QAAM,aAAa,MAAM,OAA0B,IAAI;AACvD,QAAM,WAAW,MAAM,OAAyB,IAAI;AACpD,QAAM,YAAY,MAAM,OAAuC,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC;AAIpF,QAAM,YAAY,MAAM,OAAO,CAAC;AAEhC,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAS,EAAE;AACvD,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAS,KAAK;AAElD,QAAM,UAAU,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAG1C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BAAgB,EAAE;AAC3E,QAAM,QAAQ,eAAe,YAAa;AAC1C,QAAM,SAAS,iBAAiB;AAEhC,QAAM,SAAS,MAAM;AAAA,IACnB,CAAC,MAAc;AACb,UAAI,CAAC,aAAc,kBAAiB,CAAC;AACrC,sBAAgB,CAAC;AAAA,IACnB;AAAA,IACA,CAAC,cAAc,aAAa;AAAA,EAC9B;AAEA,SACE,qBAAC,SAAM,OAAc,MAAY,OAAc,UAAoB,iBAAe,MAAC,SAAS,KAAK,OAAO,gBAAgB,qBACtH;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,CAAC,CAAC;AAAA,QACT;AAAA,QACA;AAAA,QACA,WAAW,UAAU,KAAK,EAAE,MAAM,OAAO,SAAS,CAAC;AAAA,QACnD,UAAU;AAAA;AAAA,IACZ;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAc;AAAA,KACpE;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["Select"]}
1
+ {"version":3,"sources":["../../src/forms/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { acquireScrollLock } from '../_internal/scrollLock';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/**\n * Single-choice select - a hand-rolled listbox (token-styled, full keyboard\n * support) so it looks and behaves the same in every browser. On a mouse it's\n * an anchored dropdown; on touch it opens as a bottom sheet with finger-sized\n * rows.\n *\n * Value contract: `value` / `defaultValue` + `onValueChange(value)` - a plain\n * string, not a DOM event.\n */\nexport interface SelectProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n options?: SelectOption[];\n /** Shown in muted text on the trigger when nothing is selected. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value. */\n value?: string;\n /** Uncontrolled initial value. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Form field name - mirrored to a hidden input so the value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the trigger. Only needed when there's no visible\n * `label` (e.g. a compact row where the context is already clear visually,\n * a day name next to a \"start time\" / \"end time\" pair): `Field` only\n * renders a `<label>` when `label` is set, so without either the trigger\n * has no accessible name at all. Takes precedence over `label` if both are\n * set - don't pass both.\n */\n 'aria-label'?: string;\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\n// ── Custom listbox ──────────────────────────────────────────────────────────\nfunction CustomSelect({\n rid,\n label,\n ariaLabel,\n options,\n value,\n placeholder,\n size,\n error,\n disabled,\n coarse,\n fieldAria,\n onCommit,\n}: {\n rid: string;\n /** The field label - shown as the sheet header on touch so the picker has context. */\n label?: string;\n /** Falls back to `label` when there's no visible one at all. */\n ariaLabel?: string;\n options: SelectOption[];\n value: string;\n placeholder?: string;\n size: NonNullable<SelectProps['size']>;\n error: boolean;\n disabled?: boolean;\n /** Touch: open as a bottom sheet with finger-sized rows instead of a dropdown. */\n coarse: boolean;\n /** `aria-invalid` / `aria-describedby` tying the trigger to the field's hint / error line. */\n fieldAria: ReturnType<typeof fieldA11y>;\n onCommit: (v: string) => void;\n}) {\n const listboxId = `${rid}-listbox`;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const panelRef = React.useRef<HTMLUListElement>(null);\n const typeahead = React.useRef<{ str: string; timer: number }>({ str: '', timer: 0 });\n // A <label htmlFor> forwards a fully-trusted click to this button (detail:1),\n // indistinguishable from a direct one - but its *pointerdown* landed on the\n // label, not here. So only toggle when the press actually started on the box.\n const pressedAt = React.useRef(0);\n\n const [open, setOpen] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(-1);\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 // Where the dropdown sits (inline under the field, or portalled to the body inside a Dialog): see\n // `useMenuPlacement`. The touch sheet needs no anchoring.\n const place = useMenuPlacement({\n open,\n disabled: coarse,\n anchorRef: triggerRef,\n panelRef,\n itemCount: options.length,\n onDismiss: () => setOpen(false),\n });\n\n const selectedIndex = options.findIndex((o) => o.value === value);\n const selected = selectedIndex >= 0 ? options[selectedIndex] : undefined;\n\n const firstEnabled = () => options.findIndex((o) => !o.disabled);\n const lastEnabled = () => {\n for (let i = options.length - 1; i >= 0; i--) if (!options[i].disabled) return i;\n return -1;\n };\n const nextEnabled = (from: number, dir: 1 | -1) => {\n let i = from;\n for (let step = 0; step < options.length; step++) {\n i += dir;\n if (i < 0 || i >= options.length) return from;\n if (!options[i].disabled) return i;\n }\n return from;\n };\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n useOutsidePress(open && !coarse, [triggerRef, panelRef], () => setOpen(false));\n\n // The touch sheet is a modal surface - lock the page scroll behind it. Through the shared lock,\n // so a Select inside a Dialog (two held at once) frees the page whichever lets go first.\n React.useEffect(() => {\n if (!open || !coarse) return;\n return acquireScrollLock();\n }, [open, coarse]);\n\n // Keep the active option in view, the first time the list opens too (SS-568): see `useRevealActive`.\n useRevealActive(open, activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null, place);\n\n const openMenu = () => {\n if (disabled) return;\n setActiveIndex(selectedIndex >= 0 ? selectedIndex : firstEnabled());\n setOpen(true);\n };\n const closeMenu = (refocus = true) => {\n setOpen(false);\n if (refocus) triggerRef.current?.focus({ preventScroll: true });\n };\n const choose = (i: number) => {\n const o = options[i];\n if (!o || o.disabled) return;\n onCommit(o.value);\n closeMenu();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? -1 : i, 1));\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? options.length : i, -1));\n return;\n case 'Home':\n if (open) {\n e.preventDefault();\n setActiveIndex(firstEnabled());\n }\n return;\n case 'End':\n if (open) {\n e.preventDefault();\n setActiveIndex(lastEnabled());\n }\n return;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!open) return openMenu();\n choose(activeIndex);\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n closeMenu();\n }\n return;\n case 'Tab':\n if (open) setOpen(false);\n return;\n default:\n if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {\n const ta = typeahead.current;\n ta.str += e.key.toLowerCase();\n window.clearTimeout(ta.timer);\n ta.timer = window.setTimeout(() => (ta.str = ''), 500);\n const match = options.findIndex((o) => !o.disabled && o.label.toLowerCase().startsWith(ta.str));\n if (match >= 0) {\n if (!open) openMenu();\n setActiveIndex(match);\n }\n }\n }\n };\n\n const hasValue = !!selected;\n const rowPadY = menuRowPadY(coarse, size);\n\n const listStyleBase: React.CSSProperties = { ...menuSurfaceStyle(size), ...menuListStyle };\n const optionRows = options.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === value}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n />\n ));\n\n return (\n <div style={sx({ position: 'relative', width: '100%' })}>\n <button\n ref={triggerRef}\n type=\"button\"\n id={rid}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n aria-disabled={disabled || undefined}\n disabled={disabled}\n onPointerDown={() => {\n pressedAt.current = Date.now();\n }}\n onMouseDown={(e) => {\n // Take focus without the browser scrolling us into view.\n e.preventDefault();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n onClick={() => {\n // Only toggle when the press started on this button - a click forwarded\n // from the field <label>, or synthesised by the keyboard, never set\n // pressedAt (keyboard is handled in onKeyDown).\n if (Date.now() - pressedAt.current > 500) return;\n pressedAt.current = 0;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={onKeyDown}\n style={fieldBoxStyle(size, error, open, !!disabled)}\n >\n <span\n style={sx({\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: hasValue ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {hasValue ? selected!.label : placeholder ?? 'Select…'}\n </span>\n <span\n aria-hidden=\"true\"\n style={sx({\n display: 'flex',\n flex: '0 0 auto',\n color: 'var(--text-muted)',\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </span>\n </button>\n\n {open && mounted && coarse &&\n createPortal(\n <div\n role=\"presentation\"\n onClick={() => closeMenu()}\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1100,\n display: 'flex',\n alignItems: 'flex-end',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-standard)',\n })}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={sx({\n width: '100%',\n maxHeight: '70dvh',\n display: 'flex',\n flexDirection: 'column',\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-sheet) var(--radius-sheet) 0 0',\n boxShadow: 'var(--shadow-sheet)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n animation: 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)',\n })}\n >\n {label && (\n <div\n style={sx({\n flex: '0 0 auto',\n padding: 'var(--space-3) var(--space-4)',\n borderBottom: 'var(--border-width-hairline) solid var(--border-subtle)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n color: 'var(--text-primary)',\n })}\n >\n {label}\n </div>\n )}\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={label}\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n flex: '1 1 auto',\n minHeight: 0,\n border: 'none',\n borderRadius: 0,\n boxShadow: 'none',\n background: 'transparent',\n padding: 'var(--space-2)',\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {optionRows}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n {open && !coarse && place && place.strategy === 'inline' && (\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n maxHeight: place.maxH,\n zIndex: 100,\n })}\n >\n {optionRows}\n </ul>\n )}\n {open && !coarse && mounted && place && place.strategy === 'fixed' &&\n createPortal(\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n maxHeight: place.maxH,\n zIndex: 1100,\n })}\n >\n {optionRows}\n </ul>,\n document.body,\n )}\n </div>\n );\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the selected\n * value (rendered only when `name` is set - pass it, as `register()` does).\n * Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain\n * `{...register(name)}` spread still won't validate on change: this hidden\n * input never dispatches a native `input`/`change` event, and `onValueChange`\n * hands back a plain string, not a `ChangeEvent` - wire it through\n * `Controller`, or call the registered `onChange` yourself from\n * `onValueChange`.\n */\nexport const Select = React.forwardRef<HTMLInputElement, SelectProps>(function Select({\n label,\n hint,\n error,\n required,\n options = [],\n placeholder,\n size = 'md',\n disabled,\n value: valueProp,\n defaultValue,\n onValueChange,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n}: SelectProps, ref) {\n const reactId = React.useId();\n const rid = id || reactId;\n const isControlled = valueProp !== undefined;\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? '');\n const value = isControlled ? valueProp! : internalValue;\n const coarse = useCoarsePointer();\n\n const commit = React.useCallback(\n (v: string) => {\n if (!isControlled) setInternalValue(v);\n onValueChange?.(v);\n },\n [isControlled, onValueChange],\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <CustomSelect\n rid={rid}\n label={label}\n ariaLabel={ariaLabel}\n options={options}\n value={value}\n placeholder={placeholder}\n size={size}\n error={!!error}\n disabled={disabled}\n coarse={coarse}\n fieldAria={fieldA11y(rid, { hint, error, required })}\n onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AAyOI,cAgBE,YAhBF;AAvOJ,YAAY,WAAW;AACvB,SAAS,oB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;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["Select"]}
@@ -0,0 +1,28 @@
1
+ import * as React from 'react';
2
+ import { AvatarUploadLabels } from '../AvatarUpload.js';
3
+
4
+ /** Which step of the photo flow the dialog is on. */
5
+ type Step = 'camera' | 'crop';
6
+ /**
7
+ * The one dialog for the whole photo flow: the live camera, then the crop (and back, on
8
+ * Retake). It stays mounted across the steps and only its header text, stage and buttons
9
+ * swap, so the panel does not close and reopen (no second pop-in, no scroll-lock or focus
10
+ * hand-off) and it keeps one size. `Dialog.Header` / `Body` / `Footer` are direct children
11
+ * on purpose: `Dialog` reads them off its children to pad the body and label itself, which
12
+ * a wrapper component per step would hide from it.
13
+ */
14
+ declare function CaptureDialog({ step, src, outputSize, labels, onClose, onCameraShot, onCameraError, onSave, onRetake, }: {
15
+ step: Step;
16
+ /** The photo being cropped; only set on the crop step. */
17
+ src: string | null;
18
+ outputSize: number;
19
+ labels: AvatarUploadLabels;
20
+ onClose: () => void;
21
+ onCameraShot: (b: Blob) => void;
22
+ onCameraError: () => void;
23
+ onSave: (b: Blob) => void;
24
+ /** Only set for a shot taken with the camera; shows the "Retake" button. */
25
+ onRetake?: () => void;
26
+ }): React.JSX.Element;
27
+
28
+ export { CaptureDialog, type Step };
@@ -0,0 +1,127 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Camera, Check, RotateCcw, X, ZoomIn, ZoomOut } from "lucide-react";
5
+ import { sx } from "../../_internal/style.js";
6
+ import { Dialog } from "../../feedback/Dialog.js";
7
+ import { Button } from "../../core/Button.js";
8
+ import { useCamera } from "./useCamera.js";
9
+ import { useCropper } from "./useCropper.js";
10
+ const MODAL_WIDTH = 440;
11
+ const ZOOM_ROW_HEIGHT = 24;
12
+ function CropStage({ children, onPointerDown, onPointerMove, onPointerUp, onWheel, stageRef }) {
13
+ return /* @__PURE__ */ jsxs(
14
+ "div",
15
+ {
16
+ ref: stageRef,
17
+ onPointerDown,
18
+ onPointerMove,
19
+ onPointerUp,
20
+ onPointerCancel: onPointerUp,
21
+ onWheel,
22
+ style: sx({
23
+ position: "relative",
24
+ width: "100%",
25
+ aspectRatio: "1",
26
+ overflow: "hidden",
27
+ borderRadius: "var(--radius-lg)",
28
+ background: "var(--bg-sunken)",
29
+ cursor: onPointerDown ? "grab" : "default",
30
+ touchAction: "none"
31
+ }),
32
+ children: [
33
+ children,
34
+ /* @__PURE__ */ jsx(
35
+ "span",
36
+ {
37
+ style: sx({
38
+ position: "absolute",
39
+ inset: 0,
40
+ pointerEvents: "none",
41
+ borderRadius: "999px",
42
+ boxShadow: "0 0 0 9999px color-mix(in srgb, var(--bg-overlay) 80%, transparent)",
43
+ outline: "1px solid rgba(255, 255, 255, 0.9)",
44
+ outlineOffset: -1
45
+ })
46
+ }
47
+ )
48
+ ]
49
+ }
50
+ );
51
+ }
52
+ function CaptureDialog({
53
+ step,
54
+ src,
55
+ outputSize,
56
+ labels,
57
+ onClose,
58
+ onCameraShot,
59
+ onCameraError,
60
+ onSave,
61
+ onRetake
62
+ }) {
63
+ const isCamera = step === "camera";
64
+ const camera = useCamera(isCamera, onCameraError);
65
+ const crop = useCropper(src, outputSize);
66
+ const [contentEl, setContentEl] = React.useState(null);
67
+ React.useEffect(() => {
68
+ contentEl?.closest('[role="dialog"]')?.focus();
69
+ }, [step, contentEl]);
70
+ return /* @__PURE__ */ jsxs(Dialog, { width: MODAL_WIDTH, onClose, children: [
71
+ /* @__PURE__ */ jsx(Dialog.Header, { title: isCamera ? labels.cameraTitle : labels.cropTitle, description: isCamera ? labels.cameraHint : labels.cropHint }),
72
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs("div", { ref: setContentEl, children: [
73
+ 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(
74
+ CropStage,
75
+ {
76
+ stageRef: crop.setStageEl,
77
+ onPointerDown: crop.onPointerDown,
78
+ onPointerMove: crop.onPointerMove,
79
+ onPointerUp: crop.onPointerUp,
80
+ onWheel: (e) => crop.setZoomAt(crop.zoom - e.deltaY * 2e-3),
81
+ children: src && // eslint-disable-next-line @next/next/no-img-element
82
+ /* @__PURE__ */ jsx(
83
+ "img",
84
+ {
85
+ ref: crop.setImgEl,
86
+ src,
87
+ alt: "",
88
+ draggable: false,
89
+ onLoad: (e) => crop.onImgLoad(e.currentTarget),
90
+ style: sx({ position: "absolute", left: crop.offset.x, top: crop.offset.y, width: crop.dispW, height: crop.dispH, maxWidth: "none", userSelect: "none", pointerEvents: "none" })
91
+ }
92
+ )
93
+ },
94
+ "crop"
95
+ ),
96
+ /* @__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: [
97
+ /* @__PURE__ */ jsx(ZoomOut, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } }),
98
+ /* @__PURE__ */ jsx(
99
+ "input",
100
+ {
101
+ type: "range",
102
+ min: 1,
103
+ max: 3,
104
+ step: 0.01,
105
+ value: crop.zoom,
106
+ onChange: (e) => crop.setZoomAt(Number(e.target.value)),
107
+ "aria-label": labels.zoom,
108
+ style: sx({ flex: 1, accentColor: "var(--interactive-primary)" })
109
+ }
110
+ ),
111
+ /* @__PURE__ */ jsx(ZoomIn, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } })
112
+ ] }) })
113
+ ] }) }),
114
+ /* @__PURE__ */ jsx(Dialog.Footer, { fill: !isCamera && Boolean(onRetake), children: isCamera ? /* @__PURE__ */ jsxs(React.Fragment, { children: [
115
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 }), onClick: onClose, children: labels.cancel }),
116
+ /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Camera, { size: 16, strokeWidth: 2 }), onClick: () => camera.shoot(onCameraShot), disabled: !camera.ready, children: labels.capture })
117
+ ] }, "camera") : /* @__PURE__ */ jsxs(React.Fragment, { children: [
118
+ onRetake && /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(RotateCcw, { size: 16, strokeWidth: 2 }), onClick: onRetake, children: labels.retake }),
119
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 }), onClick: onClose, children: labels.cancel }),
120
+ /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Check, { size: 16, strokeWidth: 2.5 }), onClick: () => crop.save(onSave), children: labels.save })
121
+ ] }, "crop") })
122
+ ] });
123
+ }
124
+ export {
125
+ CaptureDialog
126
+ };
127
+ //# sourceMappingURL=AvatarCaptureDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/forms/_internal/AvatarCaptureDialog.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Camera, Check, RotateCcw, X, ZoomIn, ZoomOut } from 'lucide-react';\nimport { sx } from '../../_internal/style';\nimport { Dialog } from '../../feedback/Dialog';\nimport { Button } from '../../core/Button';\nimport type { AvatarUploadLabels } from '../AvatarUpload';\nimport { useCamera } from './useCamera';\nimport { useCropper } from './useCropper';\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. */\nexport type Step = 'camera' | 'crop';\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 */\nexport function 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":";AAgDI,SAsHU,UAnGR,KAnBF;AA9CJ,YAAY,WAAW;AACvB,SAAS,QAAQ,OAAO,WAAW,GAAG,QAAQ,eAAe;AAC7D,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,cAAc;AAEvB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAa3B,MAAM,cAAc;AAGpB,MAAM,kBAAkB;AAaxB,SAAS,UAAU,EAAE,UAAU,eAAe,eAAe,aAAa,SAAS,SAAS,GAQzF;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,MACA,OAAO,GAAG;AAAA,QACR,UAAU;AAAA,QACV,OAAO;AAAA,QACP,aAAa;AAAA,QACb,UAAU;AAAA,QACV,cAAc;AAAA,QACd,YAAY;AAAA,QACZ,QAAQ,gBAAgB,SAAS;AAAA,QACjC,aAAa;AAAA,MACf,CAAC;AAAA,MAEA;AAAA;AAAA,QACD;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,GAAG;AAAA,cACR,UAAU;AAAA,cACV,OAAO;AAAA,cACP,eAAe;AAAA,cACf,cAAc;AAAA,cACd,WAAW;AAAA,cACX,SAAS;AAAA,cACT,eAAe;AAAA,YACjB,CAAC;AAAA;AAAA,QACH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,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":[]}
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
5
5
  import { sx } from "../../_internal/style.js";
6
6
  import { srOnlyStyle } from "../../_internal/srOnly.js";
7
+ import { useOutsidePress } from "../../_internal/useOutsidePress.js";
7
8
  import { IconButton } from "../../core/IconButton.js";
8
9
  import { calendarRange, clampIndex, isDayOutside, yearWindowStart } from "./calendarRange.js";
9
10
  import { dotFor, dotStyle, TODAY_RING } from "./calendarDots.js";
@@ -95,20 +96,14 @@ function CalendarGrid({
95
96
  }
96
97
  onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);
97
98
  }, [viewIndex]);
99
+ useOutsidePress(open, [rootRef], () => {
100
+ setOpen(false);
101
+ setPicker("month");
102
+ });
98
103
  React.useEffect(() => {
99
104
  if (!open) return;
100
- const onDown = (e) => {
101
- if (rootRef.current && !rootRef.current.contains(e.target)) {
102
- setOpen(false);
103
- setPicker("month");
104
- }
105
- };
106
- document.addEventListener("pointerdown", onDown, true);
107
105
  const id = requestAnimationFrame(() => popRef.current?.focus());
108
- return () => {
109
- document.removeEventListener("pointerdown", onDown, true);
110
- cancelAnimationFrame(id);
111
- };
106
+ return () => cancelAnimationFrame(id);
112
107
  }, [open]);
113
108
  const closePopover = React.useCallback(() => {
114
109
  setOpen(false);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/_internal/CalendarGrid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';\nimport { sx } from '../../_internal/style';\nimport { srOnlyStyle } from '../../_internal/srOnly';\nimport { IconButton } from '../../core/IconButton';\nimport { calendarRange, clampIndex, isDayOutside, yearWindowStart } from './calendarRange';\nimport { dotFor, dotStyle, TODAY_RING, type CalendarDayContext, type CalendarDayDots } from './calendarDots';\n\n/**\n * The month calendar body - header (‹ / › month nav + a month/year jump\n * popover) and the day grid with roving-tabindex keyboard navigation\n * (SS-228). Shared by `DateTimePicker` (rendered inline, with an optional\n * time-slot list under it) and `DatePicker` (rendered inside its own\n * trigger+popover shell) - extracted so neither has to duplicate the\n * keyboard-grid math (SS-243). See `DateTimePicker`'s own doc comment for\n * the full behavior description; this component owns exactly the same\n * state and logic it always has, just without the outer card chrome or\n * the time-slot section, neither of which any of this depends on.\n */\nexport interface CalendarGridProps {\n year?: number;\n month?: number;\n selectedDate?: number;\n unavailable?: number[];\n /**\n * Earliest date, ISO \"YYYY-MM-DD\". The calendar cannot be navigated to an earlier month or\n * year (the previous-month arrow disables, PageUp and the arrow keys stop at the edge, and\n * the month / year popover disables what is out of range), and every earlier day is struck\n * through, with no need to list it in `unavailable`. A value that is not a valid date is ignored.\n */\n min?: string;\n /** Latest date, ISO \"YYYY-MM-DD\". The mirror image of `min`. */\n max?: string;\n onSelectDate?: (day: number) => void;\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number. The second argument says what the calendar knows about the\n * day (selected, today, unavailable), so the content can follow it without redoing the logic.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /** The days that get a dot under their number (see `CalendarDayDots`). Shares the slot under the number with `renderDay`. */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot that has no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n /**\n * Day cells are perfect squares (`aspect-ratio`) instead of a fixed pixel\n * height - `DatePicker` (SS-243) opts into this since its popover can be\n * narrower than `DateTimePicker`'s own card, where a fixed height was\n * already tuned and shipped. Ignored when `renderDay` or `dayDots` is set -\n * that case always needs the extra fixed height for its own content.\n */\n squareCells?: boolean;\n /**\n * Drop wholly-blank trailing rows instead of always padding to 6 (SS-243)\n * `DateTimePicker` needs the fixed 6 rows so its *always-visible* card\n * never jumps height as you navigate months; `DatePicker`'s popover opens\n * and closes anyway, so a variable height per month reads better than a\n * dead empty row (e.g. a 30-day month starting on Sunday only needs 5).\n */\n trimEmptyRows?: boolean;\n /**\n * The product itself (Sereno's real booking app) always renders pt-BR -\n * this only exists so the docs showcase can demo an English-speaking\n * consumer without forking the component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\nconst I18N = {\n 'pt-BR': {\n dow: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],\n months: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'],\n monthsShort: ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'],\n prevMonth: 'Mês anterior',\n nextMonth: 'Próximo mês',\n prevYear: 'Ano anterior',\n prevYears: 'Anos anteriores',\n nextYear: 'Próximo ano',\n nextYears: 'Próximos anos',\n pickerLabel: 'Escolher mês e ano',\n marked: 'com marcador',\n },\n en: {\n dow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n prevMonth: 'Previous month',\n nextMonth: 'Next month',\n prevYear: 'Previous year',\n prevYears: 'Previous years',\n nextYear: 'Next year',\n nextYears: 'Next years',\n pickerLabel: 'Choose month and year',\n marked: 'marked',\n },\n} as const;\n\nfunction daysIn(y: number, m: number): number {\n return new Date(y, m + 1, 0).getDate();\n}\n\nexport function CalendarGrid({\n year,\n month,\n selectedDate,\n unavailable = [],\n min,\n max,\n onSelectDate,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n squareCells = false,\n trimEmptyRows = false,\n locale = 'pt-BR',\n}: CalendarGridProps) {\n const t = I18N[locale];\n const now = React.useMemo(() => new Date(), []);\n // One integer for the visible month - `year*12 + month`. Keeps ‹ / › arithmetic\n // (and rapid clicks) correct across year boundaries with no Date() juggling.\n // `year` / `month` are the *initial* view; the component then owns it. A\n // consumer that needs to reset the view (DatePicker, on reopen) remounts\n // this component instead - see its own comment.\n const range = React.useMemo(() => calendarRange(min, max), [min, max]);\n // `year` / `month` outside `min` .. `max` start on the nearest month inside it.\n const requestedIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());\n const initialIndex = clampIndex(requestedIndex, range);\n const [viewIndex, setViewIndex] = React.useState(initialIndex);\n // `min` / `max` can change after mount (a \"today\" that moves on, a bound that depends on a\n // choice made elsewhere): keep the visible month inside them. Adjusted while rendering, not in\n // an effect, so a month outside the range is never painted, not even for a frame.\n if (viewIndex !== clampIndex(viewIndex, range)) setViewIndex(clampIndex(viewIndex, range));\n const viewYear = Math.floor(viewIndex / 12);\n const viewMonth = viewIndex % 12;\n // `selectedDate` is only a day number, so remember which month that pick was\n // made in - the highlight shows only there, never on the same day of another\n // month you navigate to.\n const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);\n const [open, setOpen] = React.useState(false);\n const [picker, setPicker] = React.useState<'month' | 'year'>('month');\n // Unbounded, the block is `year - 5` exactly as it always was; with a range it is based on the month\n // actually shown (the one the range moved it to).\n const bounded = Number.isFinite(range.minIndex) || Number.isFinite(range.maxIndex);\n const [yearBase, setYearBase] = React.useState(() => yearWindowStart(bounded ? Math.floor(initialIndex / 12) : (year ?? now.getFullYear()), range));\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const titleRef = React.useRef<HTMLButtonElement>(null);\n const popRef = React.useRef<HTMLDivElement>(null);\n const gridRef = React.useRef<HTMLDivElement>(null);\n\n // Roving tabindex for the day grid: only one cell is ever in the Tab\n // order (below), so Tab enters/leaves the whole grid in one stop instead\n // of one per day. `activeDay` is the day-of-month that cell represents -\n // clamped to the visible month's length at render (below), since it\n // persists across a month change (‹ / › or an arrow-key crossing) where\n // the same day number may no longer exist (e.g. the 31st, into February).\n const [activeDay, setActiveDay] = React.useState(() => {\n if (selectedDate) return selectedDate;\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n let day = todayIndex === initialIndex ? now.getDate() : 1;\n // On the first / last month of the range, start on a day that can be picked, not a struck one.\n if (range.min && initialIndex === range.minIndex) day = Math.max(day, range.min.day);\n if (range.max && initialIndex === range.maxIndex) day = Math.min(day, range.max.day);\n return day;\n });\n // Set right before a keyboard move changes activeDay/viewIndex; consumed\n // by the layout effect below to focus the new cell once it's in the DOM -\n // never on an unrelated render (a prop change, a re-render from the\n // parent) or the initial mount.\n const shouldFocusDayRef = React.useRef(false);\n\n // Notify on navigation - never on mount, always with the settled value.\n const onMonthChangeRef = React.useRef(onMonthChange);\n React.useEffect(() => {\n onMonthChangeRef.current = onMonthChange;\n });\n // The one time it does fire on mount: the month asked for was outside `min` .. `max` and was\n // moved inside it. A consumer that tracks the month (`DatePicker` does, to build the picked\n // date) must not be left believing in the one it asked for.\n const adjustedAtMount = React.useRef(requestedIndex !== initialIndex);\n const didMount = React.useRef(false);\n React.useEffect(() => {\n if (!didMount.current) {\n didMount.current = true;\n if (adjustedAtMount.current) onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n return;\n }\n onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n }, [viewIndex]);\n\n // close on outside pointer; move focus into the popover on open\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n setPicker('month');\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n const id = requestAnimationFrame(() => popRef.current?.focus());\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n cancelAnimationFrame(id);\n };\n }, [open]);\n\n const closePopover = React.useCallback(() => {\n setOpen(false);\n setPicker('month');\n titleRef.current?.focus();\n }, []);\n const toggleOpen = React.useCallback(() => {\n setOpen((v) => {\n if (v) setPicker('month');\n return !v;\n });\n }, []);\n\n const first = new Date(viewYear, viewMonth, 1).getDay();\n const total = daysIn(viewYear, viewMonth);\n // Always 6 rows (42 cells) so the calendar's height never shifts between\n // months - trailing blanks pad it out and carry the cell height too.\n const cells: (number | null)[] = [...Array(first).fill(null), ...Array.from({ length: total }, (_, i) => i + 1)];\n while (cells.length < 42) cells.push(null);\n if (trimEmptyRows) {\n while (cells.length > 7 && cells.slice(-7).every((c) => c === null)) cells.length -= 7;\n }\n // A plain day cell is a perfect square via aspect-ratio when `squareCells`\n // is set - its height then tracks the grid's actual column width (SS-243:\n // DatePicker's popover can be narrower than DateTimePicker's own card)\n // instead of a fixed guess that only looks square at one particular width.\n // `renderDay` needs literal extra height for its own content underneath\n // the day number regardless, so that case always keeps a fixed height.\n const hasSlot = !!renderDay || dayDots !== undefined;\n const cellSizing: React.CSSProperties = hasSlot ? { height: 48 } : squareCells ? { aspectRatio: '1' } : { height: 38 };\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n const years = Array.from({ length: 12 }, (_, i) => yearBase + i);\n const rovingDay = Math.min(Math.max(1, activeDay), total);\n\n // Arrow keys move the roving cursor by real calendar days - crossing into\n // the adjacent month's grid when they overflow the visible one, rather\n // than stopping dead at the edge. Home/End stay within the current week\n // row; PageUp/PageDown step the month (reusing the same ‹ / › state\n // change, so onMonthChange fires identically either way).\n const onGridKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n let delta = 0;\n switch (e.key) {\n case 'ArrowRight':\n delta = 1;\n break;\n case 'ArrowLeft':\n delta = -1;\n break;\n case 'ArrowDown':\n delta = 7;\n break;\n case 'ArrowUp':\n delta = -7;\n break;\n case 'Home': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.max(1, row * 7 - first + 1));\n return;\n }\n case 'End': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.min(total, row * 7 + 7 - first));\n return;\n }\n case 'PageUp':\n e.preventDefault();\n // At the first month nothing moves, and the focus flag stays down so it cannot go off later.\n if (viewIndex - 1 < range.minIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i - 1, range));\n return;\n case 'PageDown':\n e.preventDefault();\n if (viewIndex + 1 > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i + 1, range));\n return;\n default:\n return;\n }\n e.preventDefault();\n const next = new Date(viewYear, viewMonth, rovingDay + delta);\n const nextViewIndex = next.getFullYear() * 12 + next.getMonth();\n // An arrow that would cross into a month outside `min` .. `max` is refused: the cursor stays put.\n if (nextViewIndex < range.minIndex || nextViewIndex > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);\n setActiveDay(next.getDate());\n };\n\n // Runs after the grid above (keyed on viewIndex, so a month change remounts\n // it) has committed the DOM for the new activeDay/viewIndex - only then\n // does the target cell actually exist to focus.\n React.useLayoutEffect(() => {\n if (!shouldFocusDayRef.current) return;\n shouldFocusDayRef.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(`[data-day=\"${rovingDay}\"]`)?.focus();\n }, [viewIndex, rovingDay]);\n\n const canPrevMonth = viewIndex > range.minIndex;\n const canNextMonth = viewIndex < range.maxIndex;\n // One month with the header arrows, never outside the range. A press that lands on the first /\n // last month is about to disable the very button that has focus, and a disabled button drops\n // focus to the page: so the title button takes it first.\n const goMonth = (dir: 1 | -1) => {\n const next = clampIndex(viewIndex + dir, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir, range));\n if (clampIndex(next + dir, range) === next) titleRef.current?.focus();\n };\n // The popover's year arrows. In the month view they move the visible month by a year (clamped);\n // in the year view they page a block of 12 years. Same focus hand-off, to the popover itself.\n const canPrevYear = picker === 'month' ? viewYear > range.minYear : yearBase > range.minYear;\n const canNextYear = picker === 'month' ? viewYear < range.maxYear : yearBase + 12 <= range.maxYear;\n const goYear = (dir: 1 | -1) => {\n if (picker === 'month') {\n const next = clampIndex(viewIndex + dir * 12, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir * 12, range));\n const nextYear = Math.floor(next / 12);\n if (dir < 0 ? nextYear <= range.minYear : nextYear >= range.maxYear) popRef.current?.focus();\n } else {\n const next = yearBase + dir * 12;\n setYearBase((b) => b + dir * 12);\n if (dir < 0 ? next <= range.minYear : next + 12 > range.maxYear) popRef.current?.focus();\n }\n };\n\n return (\n <div ref={rootRef}>\n <div\n style={sx({\n position: 'relative',\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n gap: 'var(--space-1)',\n marginBottom: 'var(--space-3)',\n })}\n >\n <IconButton label={t.prevMonth} size=\"sm\" disabled={!canPrevMonth} onClick={() => goMonth(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n <button\n ref={titleRef}\n type=\"button\"\n className=\"sereno-dtp-title\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={toggleOpen}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n textTransform: 'capitalize',\n })}\n >\n {t.months[viewMonth]} {viewYear}\n <ChevronDown size={15} strokeWidth={2} style={{ opacity: 0.6 }} />\n </button>\n\n <IconButton label={t.nextMonth} size=\"sm\" disabled={!canNextMonth} onClick={() => goMonth(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n\n {open && (\n <div\n ref={popRef}\n role=\"dialog\"\n aria-label={t.pickerLabel}\n tabIndex={-1}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n closePopover();\n }\n }}\n className=\"sereno-dtp-pop\"\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: '50%',\n transform: 'translateX(-50%)',\n zIndex: 20,\n width: 248,\n maxWidth: 'calc(100vw - 24px)',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <div\n style={sx({\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n marginBottom: 'var(--space-2)',\n })}\n >\n <IconButton label={picker === 'month' ? t.prevYear : t.prevYears} size=\"sm\" disabled={!canPrevYear} onClick={() => goYear(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n {picker === 'month' ? (\n <button\n type=\"button\"\n className=\"sereno-dtp-title\"\n onClick={() => {\n setYearBase(yearWindowStart(viewYear, range));\n setPicker('year');\n }}\n style={sx({\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n })}\n >\n {viewYear}\n </button>\n ) : (\n <span\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n })}\n >\n {years[0]}–{years[11]}\n </span>\n )}\n\n <IconButton label={picker === 'month' ? t.nextYear : t.nextYears} size=\"sm\" disabled={!canNextYear} onClick={() => goYear(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n </div>\n\n <div className=\"sereno-dtp-grid\" style={sx({ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--space-1)' })}>\n {picker === 'month'\n ? t.monthsShort.map((mo, i) => (\n <button\n key={mo}\n type=\"button\"\n data-current={i === viewMonth || undefined}\n aria-current={i === viewMonth ? 'true' : undefined}\n disabled={viewYear * 12 + i < range.minIndex || viewYear * 12 + i > range.maxIndex}\n onClick={() => {\n setViewIndex(clampIndex(viewYear * 12 + i, range));\n closePopover();\n }}\n >\n {mo}\n </button>\n ))\n : years.map((y) => (\n <button\n key={y}\n type=\"button\"\n data-current={y === viewYear || undefined}\n aria-current={y === viewYear ? 'true' : undefined}\n disabled={y < range.minYear || y > range.maxYear}\n onClick={() => {\n // Picking the first / last year with a month earlier / later than the range\n // allows lands on the nearest month inside it.\n setViewIndex(clampIndex(y * 12 + viewMonth, range));\n setPicker('month');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)', marginBottom: 'var(--space-1)' })}>\n {t.dow.map((d, i) => (\n <span\n key={i}\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-muted)',\n letterSpacing: 'var(--tracking-caps)',\n })}\n >\n {d}\n </span>\n ))}\n </div>\n {/* keyed on the month so cells remount cleanly - no bg transition when a\n slot morphs from one day to another on navigation. */}\n <div\n key={viewIndex}\n ref={gridRef}\n onKeyDown={onGridKeyDown}\n className=\"sereno-dtp-days\"\n style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)' })}\n >\n {cells.map((d, i) => {\n // Blank cells still take the row height so the 6-row grid can't collapse.\n if (d === null) return <span key={i} aria-hidden style={cellSizing} />;\n const off = unavailable.includes(d) || isDayOutside(range, viewIndex, d);\n const sel = selectedDate === d && viewIndex === selectionIndex;\n const today = viewIndex === todayIndex && d === now.getDate();\n const extra = renderDay?.(d, { selected: sel, today, unavailable: off });\n const dot = dotFor(dayDots, d);\n return (\n <button\n key={i}\n type=\"button\"\n data-day={d}\n // Not the native `disabled` - an unavailable day stays a real,\n // focusable stop on the roving cursor (aria-disabled only) so\n // arrow-key navigation can still land on it and the user can\n // tell it exists, matching the WAI-ARIA date-grid pattern. A\n // truly `disabled` button can't receive focus at all, which\n // would make the roving tabindex below silently break.\n aria-disabled={off || undefined}\n aria-current={today ? 'date' : undefined}\n tabIndex={d === rovingDay ? 0 : -1}\n aria-pressed={sel}\n onClick={() => {\n if (off) return;\n setSelectionIndex(viewIndex);\n // Keep the roving cursor in sync with a mouse pick too - a\n // click already moves real DOM focus onto this button\n // natively, so without this the *next* arrow press would\n // jump from wherever the keyboard cursor was left instead\n // of from the day the user can see is focused/selected.\n setActiveDay(d);\n onSelectDate?.(d);\n }}\n style={sx({\n ...cellSizing,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 1,\n borderRadius: 'var(--radius-sm)',\n border: 'none',\n padding: 0,\n cursor: off ? 'not-allowed' : 'pointer',\n background: sel ? 'var(--interactive-primary)' : 'transparent',\n color: sel ? 'var(--interactive-primary-fg)' : off ? 'var(--text-disabled)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: sel ? 'var(--weight-bold)' : 'var(--weight-medium)',\n textDecoration: off ? 'line-through' : 'none',\n // Today is told apart by a thin inset ring (also `aria-current` above). Not when it\n // is the selected day: the primary fill already says which day it is.\n boxShadow: today && !sel ? TODAY_RING : undefined,\n transition: 'var(--transition-control)',\n // Not inline outline:none - that would always beat the\n // .sereno-dtp-days:focus-visible rule below no matter what\n // it says (inline style always outranks a class selector).\n // Suppressed as a class rule instead, same specificity as\n // the :focus-visible override that re-enables it.\n })}\n >\n <span>{d}</span>\n {hasSlot ? (\n <span style={sx({ display: 'flex', gap: 4, minHeight: 12, lineHeight: 1 })}>\n {extra}\n {dot ? <span aria-hidden style={sx({ ...dotStyle(dot.tone, { selected: sel, unavailable: off }), alignSelf: 'center' })} /> : null}\n </span>\n ) : null}\n {dot ? <span style={srOnlyStyle}>{dot.label ?? dayDotLabel ?? t.marked}</span> : null}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";AAkWU,cAGF,YAHE;AAhWV,YAAY,WAAW;AACvB,SAAS,aAAa,aAAa,oBAAoB;AACvD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,eAAe,YAAY,cAAc,uBAAuB;AACzE,SAAS,QAAQ,UAAU,kBAAiE;AA8D5F,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,IACvC,QAAQ,CAAC,WAAW,aAAa,YAAS,SAAS,QAAQ,SAAS,SAAS,UAAU,YAAY,WAAW,YAAY,UAAU;AAAA,IACpI,aAAa,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,IAChG,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,aAAa;AAAA,IACb,QAAQ;AAAA,EACV;AAAA,EACA,IAAI;AAAA,IACF,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,IACvC,QAAQ,CAAC,WAAW,YAAY,SAAS,SAAS,OAAO,QAAQ,QAAQ,UAAU,aAAa,WAAW,YAAY,UAAU;AAAA,IAC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9EI;AAAA,IA+EP;AAAA,KACF;AAEJ;","names":["todayIndex"]}
1
+ {"version":3,"sources":["../../../src/forms/_internal/CalendarGrid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';\nimport { sx } from '../../_internal/style';\nimport { srOnlyStyle } from '../../_internal/srOnly';\nimport { useOutsidePress } from '../../_internal/useOutsidePress';\nimport { IconButton } from '../../core/IconButton';\nimport { calendarRange, clampIndex, isDayOutside, yearWindowStart } from './calendarRange';\nimport { dotFor, dotStyle, TODAY_RING, type CalendarDayContext, type CalendarDayDots } from './calendarDots';\n\n/**\n * The month calendar body - header (‹ / › month nav + a month/year jump\n * popover) and the day grid with roving-tabindex keyboard navigation\n * (SS-228). Shared by `DateTimePicker` (rendered inline, with an optional\n * time-slot list under it) and `DatePicker` (rendered inside its own\n * trigger+popover shell) - extracted so neither has to duplicate the\n * keyboard-grid math (SS-243). See `DateTimePicker`'s own doc comment for\n * the full behavior description; this component owns exactly the same\n * state and logic it always has, just without the outer card chrome or\n * the time-slot section, neither of which any of this depends on.\n */\nexport interface CalendarGridProps {\n year?: number;\n month?: number;\n selectedDate?: number;\n unavailable?: number[];\n /**\n * Earliest date, ISO \"YYYY-MM-DD\". The calendar cannot be navigated to an earlier month or\n * year (the previous-month arrow disables, PageUp and the arrow keys stop at the edge, and\n * the month / year popover disables what is out of range), and every earlier day is struck\n * through, with no need to list it in `unavailable`. A value that is not a valid date is ignored.\n */\n min?: string;\n /** Latest date, ISO \"YYYY-MM-DD\". The mirror image of `min`. */\n max?: string;\n onSelectDate?: (day: number) => void;\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number. The second argument says what the calendar knows about the\n * day (selected, today, unavailable), so the content can follow it without redoing the logic.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /** The days that get a dot under their number (see `CalendarDayDots`). Shares the slot under the number with `renderDay`. */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot that has no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n /**\n * Day cells are perfect squares (`aspect-ratio`) instead of a fixed pixel\n * height - `DatePicker` (SS-243) opts into this since its popover can be\n * narrower than `DateTimePicker`'s own card, where a fixed height was\n * already tuned and shipped. Ignored when `renderDay` or `dayDots` is set -\n * that case always needs the extra fixed height for its own content.\n */\n squareCells?: boolean;\n /**\n * Drop wholly-blank trailing rows instead of always padding to 6 (SS-243)\n * `DateTimePicker` needs the fixed 6 rows so its *always-visible* card\n * never jumps height as you navigate months; `DatePicker`'s popover opens\n * and closes anyway, so a variable height per month reads better than a\n * dead empty row (e.g. a 30-day month starting on Sunday only needs 5).\n */\n trimEmptyRows?: boolean;\n /**\n * The product itself (Sereno's real booking app) always renders pt-BR -\n * this only exists so the docs showcase can demo an English-speaking\n * consumer without forking the component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\nconst I18N = {\n 'pt-BR': {\n dow: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],\n months: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'],\n monthsShort: ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'],\n prevMonth: 'Mês anterior',\n nextMonth: 'Próximo mês',\n prevYear: 'Ano anterior',\n prevYears: 'Anos anteriores',\n nextYear: 'Próximo ano',\n nextYears: 'Próximos anos',\n pickerLabel: 'Escolher mês e ano',\n marked: 'com marcador',\n },\n en: {\n dow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n prevMonth: 'Previous month',\n nextMonth: 'Next month',\n prevYear: 'Previous year',\n prevYears: 'Previous years',\n nextYear: 'Next year',\n nextYears: 'Next years',\n pickerLabel: 'Choose month and year',\n marked: 'marked',\n },\n} as const;\n\nfunction daysIn(y: number, m: number): number {\n return new Date(y, m + 1, 0).getDate();\n}\n\nexport function CalendarGrid({\n year,\n month,\n selectedDate,\n unavailable = [],\n min,\n max,\n onSelectDate,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n squareCells = false,\n trimEmptyRows = false,\n locale = 'pt-BR',\n}: CalendarGridProps) {\n const t = I18N[locale];\n const now = React.useMemo(() => new Date(), []);\n // One integer for the visible month - `year*12 + month`. Keeps ‹ / › arithmetic\n // (and rapid clicks) correct across year boundaries with no Date() juggling.\n // `year` / `month` are the *initial* view; the component then owns it. A\n // consumer that needs to reset the view (DatePicker, on reopen) remounts\n // this component instead - see its own comment.\n const range = React.useMemo(() => calendarRange(min, max), [min, max]);\n // `year` / `month` outside `min` .. `max` start on the nearest month inside it.\n const requestedIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());\n const initialIndex = clampIndex(requestedIndex, range);\n const [viewIndex, setViewIndex] = React.useState(initialIndex);\n // `min` / `max` can change after mount (a \"today\" that moves on, a bound that depends on a\n // choice made elsewhere): keep the visible month inside them. Adjusted while rendering, not in\n // an effect, so a month outside the range is never painted, not even for a frame.\n if (viewIndex !== clampIndex(viewIndex, range)) setViewIndex(clampIndex(viewIndex, range));\n const viewYear = Math.floor(viewIndex / 12);\n const viewMonth = viewIndex % 12;\n // `selectedDate` is only a day number, so remember which month that pick was\n // made in - the highlight shows only there, never on the same day of another\n // month you navigate to.\n const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);\n const [open, setOpen] = React.useState(false);\n const [picker, setPicker] = React.useState<'month' | 'year'>('month');\n // Unbounded, the block is `year - 5` exactly as it always was; with a range it is based on the month\n // actually shown (the one the range moved it to).\n const bounded = Number.isFinite(range.minIndex) || Number.isFinite(range.maxIndex);\n const [yearBase, setYearBase] = React.useState(() => yearWindowStart(bounded ? Math.floor(initialIndex / 12) : (year ?? now.getFullYear()), range));\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const titleRef = React.useRef<HTMLButtonElement>(null);\n const popRef = React.useRef<HTMLDivElement>(null);\n const gridRef = React.useRef<HTMLDivElement>(null);\n\n // Roving tabindex for the day grid: only one cell is ever in the Tab\n // order (below), so Tab enters/leaves the whole grid in one stop instead\n // of one per day. `activeDay` is the day-of-month that cell represents -\n // clamped to the visible month's length at render (below), since it\n // persists across a month change (‹ / › or an arrow-key crossing) where\n // the same day number may no longer exist (e.g. the 31st, into February).\n const [activeDay, setActiveDay] = React.useState(() => {\n if (selectedDate) return selectedDate;\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n let day = todayIndex === initialIndex ? now.getDate() : 1;\n // On the first / last month of the range, start on a day that can be picked, not a struck one.\n if (range.min && initialIndex === range.minIndex) day = Math.max(day, range.min.day);\n if (range.max && initialIndex === range.maxIndex) day = Math.min(day, range.max.day);\n return day;\n });\n // Set right before a keyboard move changes activeDay/viewIndex; consumed\n // by the layout effect below to focus the new cell once it's in the DOM -\n // never on an unrelated render (a prop change, a re-render from the\n // parent) or the initial mount.\n const shouldFocusDayRef = React.useRef(false);\n\n // Notify on navigation - never on mount, always with the settled value.\n const onMonthChangeRef = React.useRef(onMonthChange);\n React.useEffect(() => {\n onMonthChangeRef.current = onMonthChange;\n });\n // The one time it does fire on mount: the month asked for was outside `min` .. `max` and was\n // moved inside it. A consumer that tracks the month (`DatePicker` does, to build the picked\n // date) must not be left believing in the one it asked for.\n const adjustedAtMount = React.useRef(requestedIndex !== initialIndex);\n const didMount = React.useRef(false);\n React.useEffect(() => {\n if (!didMount.current) {\n didMount.current = true;\n if (adjustedAtMount.current) onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n return;\n }\n onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n }, [viewIndex]);\n\n // close on outside pointer; move focus into the popover on open\n useOutsidePress(open, [rootRef], () => {\n setOpen(false);\n setPicker('month');\n });\n React.useEffect(() => {\n if (!open) return;\n const id = requestAnimationFrame(() => popRef.current?.focus());\n return () => cancelAnimationFrame(id);\n }, [open]);\n\n const closePopover = React.useCallback(() => {\n setOpen(false);\n setPicker('month');\n titleRef.current?.focus();\n }, []);\n const toggleOpen = React.useCallback(() => {\n setOpen((v) => {\n if (v) setPicker('month');\n return !v;\n });\n }, []);\n\n const first = new Date(viewYear, viewMonth, 1).getDay();\n const total = daysIn(viewYear, viewMonth);\n // Always 6 rows (42 cells) so the calendar's height never shifts between\n // months - trailing blanks pad it out and carry the cell height too.\n const cells: (number | null)[] = [...Array(first).fill(null), ...Array.from({ length: total }, (_, i) => i + 1)];\n while (cells.length < 42) cells.push(null);\n if (trimEmptyRows) {\n while (cells.length > 7 && cells.slice(-7).every((c) => c === null)) cells.length -= 7;\n }\n // A plain day cell is a perfect square via aspect-ratio when `squareCells`\n // is set - its height then tracks the grid's actual column width (SS-243:\n // DatePicker's popover can be narrower than DateTimePicker's own card)\n // instead of a fixed guess that only looks square at one particular width.\n // `renderDay` needs literal extra height for its own content underneath\n // the day number regardless, so that case always keeps a fixed height.\n const hasSlot = !!renderDay || dayDots !== undefined;\n const cellSizing: React.CSSProperties = hasSlot ? { height: 48 } : squareCells ? { aspectRatio: '1' } : { height: 38 };\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n const years = Array.from({ length: 12 }, (_, i) => yearBase + i);\n const rovingDay = Math.min(Math.max(1, activeDay), total);\n\n // Arrow keys move the roving cursor by real calendar days - crossing into\n // the adjacent month's grid when they overflow the visible one, rather\n // than stopping dead at the edge. Home/End stay within the current week\n // row; PageUp/PageDown step the month (reusing the same ‹ / › state\n // change, so onMonthChange fires identically either way).\n const onGridKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n let delta = 0;\n switch (e.key) {\n case 'ArrowRight':\n delta = 1;\n break;\n case 'ArrowLeft':\n delta = -1;\n break;\n case 'ArrowDown':\n delta = 7;\n break;\n case 'ArrowUp':\n delta = -7;\n break;\n case 'Home': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.max(1, row * 7 - first + 1));\n return;\n }\n case 'End': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.min(total, row * 7 + 7 - first));\n return;\n }\n case 'PageUp':\n e.preventDefault();\n // At the first month nothing moves, and the focus flag stays down so it cannot go off later.\n if (viewIndex - 1 < range.minIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i - 1, range));\n return;\n case 'PageDown':\n e.preventDefault();\n if (viewIndex + 1 > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i + 1, range));\n return;\n default:\n return;\n }\n e.preventDefault();\n const next = new Date(viewYear, viewMonth, rovingDay + delta);\n const nextViewIndex = next.getFullYear() * 12 + next.getMonth();\n // An arrow that would cross into a month outside `min` .. `max` is refused: the cursor stays put.\n if (nextViewIndex < range.minIndex || nextViewIndex > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);\n setActiveDay(next.getDate());\n };\n\n // Runs after the grid above (keyed on viewIndex, so a month change remounts\n // it) has committed the DOM for the new activeDay/viewIndex - only then\n // does the target cell actually exist to focus.\n React.useLayoutEffect(() => {\n if (!shouldFocusDayRef.current) return;\n shouldFocusDayRef.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(`[data-day=\"${rovingDay}\"]`)?.focus();\n }, [viewIndex, rovingDay]);\n\n const canPrevMonth = viewIndex > range.minIndex;\n const canNextMonth = viewIndex < range.maxIndex;\n // One month with the header arrows, never outside the range. A press that lands on the first /\n // last month is about to disable the very button that has focus, and a disabled button drops\n // focus to the page: so the title button takes it first.\n const goMonth = (dir: 1 | -1) => {\n const next = clampIndex(viewIndex + dir, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir, range));\n if (clampIndex(next + dir, range) === next) titleRef.current?.focus();\n };\n // The popover's year arrows. In the month view they move the visible month by a year (clamped);\n // in the year view they page a block of 12 years. Same focus hand-off, to the popover itself.\n const canPrevYear = picker === 'month' ? viewYear > range.minYear : yearBase > range.minYear;\n const canNextYear = picker === 'month' ? viewYear < range.maxYear : yearBase + 12 <= range.maxYear;\n const goYear = (dir: 1 | -1) => {\n if (picker === 'month') {\n const next = clampIndex(viewIndex + dir * 12, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir * 12, range));\n const nextYear = Math.floor(next / 12);\n if (dir < 0 ? nextYear <= range.minYear : nextYear >= range.maxYear) popRef.current?.focus();\n } else {\n const next = yearBase + dir * 12;\n setYearBase((b) => b + dir * 12);\n if (dir < 0 ? next <= range.minYear : next + 12 > range.maxYear) popRef.current?.focus();\n }\n };\n\n return (\n <div ref={rootRef}>\n <div\n style={sx({\n position: 'relative',\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n gap: 'var(--space-1)',\n marginBottom: 'var(--space-3)',\n })}\n >\n <IconButton label={t.prevMonth} size=\"sm\" disabled={!canPrevMonth} onClick={() => goMonth(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n <button\n ref={titleRef}\n type=\"button\"\n className=\"sereno-dtp-title\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={toggleOpen}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n textTransform: 'capitalize',\n })}\n >\n {t.months[viewMonth]} {viewYear}\n <ChevronDown size={15} strokeWidth={2} style={{ opacity: 0.6 }} />\n </button>\n\n <IconButton label={t.nextMonth} size=\"sm\" disabled={!canNextMonth} onClick={() => goMonth(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n\n {open && (\n <div\n ref={popRef}\n role=\"dialog\"\n aria-label={t.pickerLabel}\n tabIndex={-1}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n closePopover();\n }\n }}\n className=\"sereno-dtp-pop\"\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: '50%',\n transform: 'translateX(-50%)',\n zIndex: 20,\n width: 248,\n maxWidth: 'calc(100vw - 24px)',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <div\n style={sx({\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n marginBottom: 'var(--space-2)',\n })}\n >\n <IconButton label={picker === 'month' ? t.prevYear : t.prevYears} size=\"sm\" disabled={!canPrevYear} onClick={() => goYear(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n {picker === 'month' ? (\n <button\n type=\"button\"\n className=\"sereno-dtp-title\"\n onClick={() => {\n setYearBase(yearWindowStart(viewYear, range));\n setPicker('year');\n }}\n style={sx({\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n })}\n >\n {viewYear}\n </button>\n ) : (\n <span\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n })}\n >\n {years[0]}–{years[11]}\n </span>\n )}\n\n <IconButton label={picker === 'month' ? t.nextYear : t.nextYears} size=\"sm\" disabled={!canNextYear} onClick={() => goYear(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n </div>\n\n <div className=\"sereno-dtp-grid\" style={sx({ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--space-1)' })}>\n {picker === 'month'\n ? t.monthsShort.map((mo, i) => (\n <button\n key={mo}\n type=\"button\"\n data-current={i === viewMonth || undefined}\n aria-current={i === viewMonth ? 'true' : undefined}\n disabled={viewYear * 12 + i < range.minIndex || viewYear * 12 + i > range.maxIndex}\n onClick={() => {\n setViewIndex(clampIndex(viewYear * 12 + i, range));\n closePopover();\n }}\n >\n {mo}\n </button>\n ))\n : years.map((y) => (\n <button\n key={y}\n type=\"button\"\n data-current={y === viewYear || undefined}\n aria-current={y === viewYear ? 'true' : undefined}\n disabled={y < range.minYear || y > range.maxYear}\n onClick={() => {\n // Picking the first / last year with a month earlier / later than the range\n // allows lands on the nearest month inside it.\n setViewIndex(clampIndex(y * 12 + viewMonth, range));\n setPicker('month');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)', marginBottom: 'var(--space-1)' })}>\n {t.dow.map((d, i) => (\n <span\n key={i}\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-muted)',\n letterSpacing: 'var(--tracking-caps)',\n })}\n >\n {d}\n </span>\n ))}\n </div>\n {/* keyed on the month so cells remount cleanly - no bg transition when a\n slot morphs from one day to another on navigation. */}\n <div\n key={viewIndex}\n ref={gridRef}\n onKeyDown={onGridKeyDown}\n className=\"sereno-dtp-days\"\n style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)' })}\n >\n {cells.map((d, i) => {\n // Blank cells still take the row height so the 6-row grid can't collapse.\n if (d === null) return <span key={i} aria-hidden style={cellSizing} />;\n const off = unavailable.includes(d) || isDayOutside(range, viewIndex, d);\n const sel = selectedDate === d && viewIndex === selectionIndex;\n const today = viewIndex === todayIndex && d === now.getDate();\n const extra = renderDay?.(d, { selected: sel, today, unavailable: off });\n const dot = dotFor(dayDots, d);\n return (\n <button\n key={i}\n type=\"button\"\n data-day={d}\n // Not the native `disabled` - an unavailable day stays a real,\n // focusable stop on the roving cursor (aria-disabled only) so\n // arrow-key navigation can still land on it and the user can\n // tell it exists, matching the WAI-ARIA date-grid pattern. A\n // truly `disabled` button can't receive focus at all, which\n // would make the roving tabindex below silently break.\n aria-disabled={off || undefined}\n aria-current={today ? 'date' : undefined}\n tabIndex={d === rovingDay ? 0 : -1}\n aria-pressed={sel}\n onClick={() => {\n if (off) return;\n setSelectionIndex(viewIndex);\n // Keep the roving cursor in sync with a mouse pick too - a\n // click already moves real DOM focus onto this button\n // natively, so without this the *next* arrow press would\n // jump from wherever the keyboard cursor was left instead\n // of from the day the user can see is focused/selected.\n setActiveDay(d);\n onSelectDate?.(d);\n }}\n style={sx({\n ...cellSizing,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 1,\n borderRadius: 'var(--radius-sm)',\n border: 'none',\n padding: 0,\n cursor: off ? 'not-allowed' : 'pointer',\n background: sel ? 'var(--interactive-primary)' : 'transparent',\n color: sel ? 'var(--interactive-primary-fg)' : off ? 'var(--text-disabled)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: sel ? 'var(--weight-bold)' : 'var(--weight-medium)',\n textDecoration: off ? 'line-through' : 'none',\n // Today is told apart by a thin inset ring (also `aria-current` above). Not when it\n // is the selected day: the primary fill already says which day it is.\n boxShadow: today && !sel ? TODAY_RING : undefined,\n transition: 'var(--transition-control)',\n // Not inline outline:none - that would always beat the\n // .sereno-dtp-days:focus-visible rule below no matter what\n // it says (inline style always outranks a class selector).\n // Suppressed as a class rule instead, same specificity as\n // the :focus-visible override that re-enables it.\n })}\n >\n <span>{d}</span>\n {hasSlot ? (\n <span style={sx({ display: 'flex', gap: 4, minHeight: 12, lineHeight: 1 })}>\n {extra}\n {dot ? <span aria-hidden style={sx({ ...dotStyle(dot.tone, { selected: sel, unavailable: off }), alignSelf: 'center' })} /> : null}\n </span>\n ) : null}\n {dot ? <span style={srOnlyStyle}>{dot.label ?? dayDotLabel ?? t.marked}</span> : null}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";AA6VU,cAGF,YAHE;AA3VV,YAAY,WAAW;AACvB,SAAS,aAAa,aAAa,oBAAoB;AACvD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,eAAe,YAAY,cAAc,uBAAuB;AACzE,SAAS,QAAQ,UAAU,kBAAiE;AA8D5F,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,IACvC,QAAQ,CAAC,WAAW,aAAa,YAAS,SAAS,QAAQ,SAAS,SAAS,UAAU,YAAY,WAAW,YAAY,UAAU;AAAA,IACpI,aAAa,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,IAChG,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,aAAa;AAAA,IACb,QAAQ;AAAA,EACV;AAAA,EACA,IAAI;AAAA,IACF,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,IACvC,QAAQ,CAAC,WAAW,YAAY,SAAS,SAAS,OAAO,QAAQ,QAAQ,UAAU,aAAa,WAAW,YAAY,UA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kCAAkB,SAAS;AAM3B,6BAAa,CAAC;AACd,+BAAe,CAAC;AAAA,cAClB;AAAA,cACA,OAAO,GAAG;AAAA,gBACR,GAAG;AAAA,gBACH,SAAS;AAAA,gBACT,eAAe;AAAA,gBACf,YAAY;AAAA,gBACZ,gBAAgB;AAAA,gBAChB,KAAK;AAAA,gBACL,cAAc;AAAA,gBACd,QAAQ;AAAA,gBACR,SAAS;AAAA,gBACT,QAAQ,MAAM,gBAAgB;AAAA,gBAC9B,YAAY,MAAM,+BAA+B;AAAA,gBACjD,OAAO,MAAM,kCAAkC,MAAM,yBAAyB;AAAA,gBAC9E,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,YAAY,MAAM,uBAAuB;AAAA,gBACzC,gBAAgB,MAAM,iBAAiB;AAAA;AAAA;AAAA,gBAGvC,WAAW,SAAS,CAAC,MAAM,aAAa;AAAA,gBACxC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAMd,CAAC;AAAA,cAED;AAAA,oCAAC,UAAM,aAAE;AAAA,gBACR,UACC,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,KAAK,GAAG,WAAW,IAAI,YAAY,EAAE,CAAC,GACtE;AAAA;AAAA,kBACA,MAAM,oBAAC,UAAK,eAAW,MAAC,OAAO,GAAG,EAAE,GAAG,SAAS,IAAI,MAAM,EAAE,UAAU,KAAK,aAAa,IAAI,CAAC,GAAG,WAAW,SAAS,CAAC,GAAG,IAAK;AAAA,mBAChI,IACE;AAAA,gBACH,MAAM,oBAAC,UAAK,OAAO,aAAc,cAAI,SAAS,eAAe,EAAE,QAAO,IAAU;AAAA;AAAA;AAAA,YA3D5E;AAAA,UA4DP;AAAA,QAEJ,CAAC;AAAA;AAAA,MA9EI;AAAA,IA+EP;AAAA,KACF;AAEJ;","names":["todayIndex"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Live camera via `getUserMedia`, while `active`. A failure (no API, permission denied)
3
+ * goes through `onError`. `ready` turns true once the stream is flowing; going inactive
4
+ * stops the tracks, so the camera light goes off as soon as the dialog leaves this step.
5
+ */
6
+ declare function useCamera(active: boolean, onError: () => void): {
7
+ attachVideo: (el: HTMLVideoElement | null) => void;
8
+ ready: boolean;
9
+ shoot: (onShot: (b: Blob) => void) => void;
10
+ };
11
+
12
+ export { useCamera };