@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
@@ -1,14 +1,13 @@
1
1
  "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { createPortal } from "react-dom";
5
- import { Camera, Check, ImagePlus, Pencil, RotateCcw, Trash2, X, ZoomIn, ZoomOut } from "lucide-react";
5
+ import { Camera, ImagePlus, Pencil, Trash2 } from "lucide-react";
6
6
  import { sx } from "../_internal/style.js";
7
7
  import { Field } from "../_internal/Field.js";
8
8
  import { fieldA11y } from "../_internal/fieldA11y.js";
9
9
  import { mergeRefs } from "../_internal/mergeRefs.js";
10
- import { Dialog } from "../feedback/Dialog.js";
11
- import { Button } from "../core/Button.js";
10
+ import { CaptureDialog } from "./_internal/AvatarCaptureDialog.js";
12
11
  const EN = {
13
12
  trigger: "Change photo",
14
13
  upload: "Upload a photo",
@@ -345,260 +344,6 @@ function MenuItem({ icon, label, onClick, danger }) {
345
344
  }
346
345
  );
347
346
  }
348
- const DEFAULT_STAGE = 280;
349
- const MODAL_WIDTH = 440;
350
- const ZOOM_ROW_HEIGHT = 24;
351
- function CropStage({ children, onPointerDown, onPointerMove, onPointerUp, onWheel, stageRef }) {
352
- return /* @__PURE__ */ jsxs(
353
- "div",
354
- {
355
- ref: stageRef,
356
- onPointerDown,
357
- onPointerMove,
358
- onPointerUp,
359
- onPointerCancel: onPointerUp,
360
- onWheel,
361
- style: sx({
362
- position: "relative",
363
- width: "100%",
364
- aspectRatio: "1",
365
- overflow: "hidden",
366
- borderRadius: "var(--radius-lg)",
367
- background: "var(--bg-sunken)",
368
- cursor: onPointerDown ? "grab" : "default",
369
- touchAction: "none"
370
- }),
371
- children: [
372
- children,
373
- /* @__PURE__ */ jsx(
374
- "span",
375
- {
376
- style: sx({
377
- position: "absolute",
378
- inset: 0,
379
- pointerEvents: "none",
380
- borderRadius: "999px",
381
- boxShadow: "0 0 0 9999px color-mix(in srgb, var(--bg-overlay) 80%, transparent)",
382
- outline: "1px solid rgba(255, 255, 255, 0.9)",
383
- outlineOffset: -1
384
- })
385
- }
386
- )
387
- ]
388
- }
389
- );
390
- }
391
- function useCamera(active, onError) {
392
- const videoRef = React.useRef(null);
393
- const streamRef = React.useRef(null);
394
- const [ready, setReady] = React.useState(false);
395
- const onErrorRef = React.useRef(onError);
396
- React.useEffect(() => {
397
- onErrorRef.current = onError;
398
- });
399
- React.useEffect(() => {
400
- if (!active) return;
401
- let cancelled = false;
402
- let started = null;
403
- const md = typeof navigator !== "undefined" ? navigator.mediaDevices : void 0;
404
- if (!md?.getUserMedia) {
405
- onErrorRef.current();
406
- return;
407
- }
408
- md.getUserMedia({ video: { facingMode: "user", width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false }).then((s) => {
409
- if (cancelled) {
410
- s.getTracks().forEach((tr) => tr.stop());
411
- return;
412
- }
413
- started = s;
414
- streamRef.current = s;
415
- if (videoRef.current) videoRef.current.srcObject = s;
416
- setReady(true);
417
- }).catch(() => onErrorRef.current());
418
- return () => {
419
- cancelled = true;
420
- started?.getTracks().forEach((tr) => tr.stop());
421
- streamRef.current = null;
422
- setReady(false);
423
- };
424
- }, [active]);
425
- const attachVideo = React.useCallback((el) => {
426
- videoRef.current = el;
427
- if (el && streamRef.current) el.srcObject = streamRef.current;
428
- }, []);
429
- const shoot = (onShot) => {
430
- const v = videoRef.current;
431
- if (!v || !v.videoWidth) return;
432
- const s = Math.min(v.videoWidth, v.videoHeight);
433
- const canvas = document.createElement("canvas");
434
- canvas.width = canvas.height = s;
435
- const ctx = canvas.getContext("2d");
436
- if (!ctx) return;
437
- ctx.translate(s, 0);
438
- ctx.scale(-1, 1);
439
- ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);
440
- canvas.toBlob((b) => b && onShot(b), "image/jpeg", 0.9);
441
- };
442
- return { attachVideo, ready, shoot };
443
- }
444
- function useCropper(src, outputSize) {
445
- const [imgEl, setImgEl] = React.useState(null);
446
- const [stageEl, setStageEl] = React.useState(null);
447
- const [V, setV] = React.useState(DEFAULT_STAGE);
448
- const prevV = React.useRef(V);
449
- const [nat, setNat] = React.useState(null);
450
- const [zoom, setZoom] = React.useState(1);
451
- const [offset, setOffset] = React.useState({ x: 0, y: 0 });
452
- const drag = React.useRef(null);
453
- const [seenSrc, setSeenSrc] = React.useState(src);
454
- if (src !== seenSrc) {
455
- setSeenSrc(src);
456
- setNat(null);
457
- setZoom(1);
458
- setOffset({ x: 0, y: 0 });
459
- }
460
- React.useEffect(() => {
461
- if (!stageEl) return;
462
- const ro = new ResizeObserver((entries) => {
463
- const w = Math.round(entries[0]?.contentRect.width ?? 0);
464
- if (!w || w === prevV.current) return;
465
- const factor = w / prevV.current;
466
- prevV.current = w;
467
- setV(w);
468
- setOffset((o) => ({ x: o.x * factor, y: o.y * factor }));
469
- });
470
- ro.observe(stageEl);
471
- return () => ro.disconnect();
472
- }, [stageEl]);
473
- const scaleMin = nat ? V / Math.min(nat.w, nat.h) : 1;
474
- const scale = scaleMin * zoom;
475
- const dispW = nat ? nat.w * scale : V;
476
- const dispH = nat ? nat.h * scale : V;
477
- const clamp = React.useCallback(
478
- (o) => ({
479
- x: Math.min(0, Math.max(V - dispW, o.x)),
480
- y: Math.min(0, Math.max(V - dispH, o.y))
481
- }),
482
- [V, dispW, dispH]
483
- );
484
- const onImgLoad = (el) => {
485
- const w = el.naturalWidth;
486
- const h = el.naturalHeight;
487
- setNat({ w, h });
488
- const s = V / Math.min(w, h);
489
- setOffset({ x: (V - w * s) / 2, y: (V - h * s) / 2 });
490
- };
491
- const setZoomAt = (nextZoom) => {
492
- const z = Math.min(3, Math.max(1, nextZoom));
493
- setZoom((prevZ) => {
494
- const oldScale = scaleMin * prevZ;
495
- const newScale = scaleMin * z;
496
- setOffset((o) => {
497
- const imgX = (V / 2 - o.x) / oldScale;
498
- const imgY = (V / 2 - o.y) / oldScale;
499
- return clamp({ x: V / 2 - imgX * newScale, y: V / 2 - imgY * newScale });
500
- });
501
- return z;
502
- });
503
- };
504
- const onPointerDown = (e) => {
505
- e.target.setPointerCapture(e.pointerId);
506
- drag.current = { x: e.clientX, y: e.clientY };
507
- };
508
- const onPointerMove = (e) => {
509
- if (!drag.current) return;
510
- const dx = e.clientX - drag.current.x;
511
- const dy = e.clientY - drag.current.y;
512
- drag.current = { x: e.clientX, y: e.clientY };
513
- setOffset((o) => clamp({ x: o.x + dx, y: o.y + dy }));
514
- };
515
- const onPointerUp = () => {
516
- drag.current = null;
517
- };
518
- const save = (onSave) => {
519
- if (!imgEl || !nat) return;
520
- const canvas = document.createElement("canvas");
521
- canvas.width = canvas.height = outputSize;
522
- const ctx = canvas.getContext("2d");
523
- if (!ctx) return;
524
- const sSize = V / scale;
525
- ctx.drawImage(imgEl, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);
526
- canvas.toBlob((b) => b && onSave(b), "image/jpeg", 0.85);
527
- };
528
- return { setImgEl, setStageEl, zoom, setZoomAt, offset, dispW, dispH, onImgLoad, onPointerDown, onPointerMove, onPointerUp, save };
529
- }
530
- function CaptureDialog({
531
- step,
532
- src,
533
- outputSize,
534
- labels,
535
- onClose,
536
- onCameraShot,
537
- onCameraError,
538
- onSave,
539
- onRetake
540
- }) {
541
- const isCamera = step === "camera";
542
- const camera = useCamera(isCamera, onCameraError);
543
- const crop = useCropper(src, outputSize);
544
- const [contentEl, setContentEl] = React.useState(null);
545
- React.useEffect(() => {
546
- contentEl?.closest('[role="dialog"]')?.focus();
547
- }, [step, contentEl]);
548
- return /* @__PURE__ */ jsxs(Dialog, { width: MODAL_WIDTH, onClose, children: [
549
- /* @__PURE__ */ jsx(Dialog.Header, { title: isCamera ? labels.cameraTitle : labels.cropTitle, description: isCamera ? labels.cameraHint : labels.cropHint }),
550
- /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs("div", { ref: setContentEl, children: [
551
- 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(
552
- CropStage,
553
- {
554
- stageRef: crop.setStageEl,
555
- onPointerDown: crop.onPointerDown,
556
- onPointerMove: crop.onPointerMove,
557
- onPointerUp: crop.onPointerUp,
558
- onWheel: (e) => crop.setZoomAt(crop.zoom - e.deltaY * 2e-3),
559
- children: src && // eslint-disable-next-line @next/next/no-img-element
560
- /* @__PURE__ */ jsx(
561
- "img",
562
- {
563
- ref: crop.setImgEl,
564
- src,
565
- alt: "",
566
- draggable: false,
567
- onLoad: (e) => crop.onImgLoad(e.currentTarget),
568
- style: sx({ position: "absolute", left: crop.offset.x, top: crop.offset.y, width: crop.dispW, height: crop.dispH, maxWidth: "none", userSelect: "none", pointerEvents: "none" })
569
- }
570
- )
571
- },
572
- "crop"
573
- ),
574
- /* @__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: [
575
- /* @__PURE__ */ jsx(ZoomOut, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } }),
576
- /* @__PURE__ */ jsx(
577
- "input",
578
- {
579
- type: "range",
580
- min: 1,
581
- max: 3,
582
- step: 0.01,
583
- value: crop.zoom,
584
- onChange: (e) => crop.setZoomAt(Number(e.target.value)),
585
- "aria-label": labels.zoom,
586
- style: sx({ flex: 1, accentColor: "var(--interactive-primary)" })
587
- }
588
- ),
589
- /* @__PURE__ */ jsx(ZoomIn, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto" } })
590
- ] }) })
591
- ] }) }),
592
- /* @__PURE__ */ jsx(Dialog.Footer, { fill: !isCamera && Boolean(onRetake), children: isCamera ? /* @__PURE__ */ jsxs(React.Fragment, { children: [
593
- /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 }), onClick: onClose, children: labels.cancel }),
594
- /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Camera, { size: 16, strokeWidth: 2 }), onClick: () => camera.shoot(onCameraShot), disabled: !camera.ready, children: labels.capture })
595
- ] }, "camera") : /* @__PURE__ */ jsxs(React.Fragment, { children: [
596
- onRetake && /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(RotateCcw, { size: 16, strokeWidth: 2 }), onClick: onRetake, children: labels.retake }),
597
- /* @__PURE__ */ jsx(Button, { variant: "secondary", iconLeft: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 }), onClick: onClose, children: labels.cancel }),
598
- /* @__PURE__ */ jsx(Button, { iconLeft: /* @__PURE__ */ jsx(Check, { size: 16, strokeWidth: 2.5 }), onClick: () => crop.save(onSave), children: labels.save })
599
- ] }, "crop") })
600
- ] });
601
- }
602
347
  export {
603
348
  AvatarUpload
604
349
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/AvatarUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Camera, Check, ImagePlus, Pencil, RotateCcw, Trash2, X, ZoomIn, ZoomOut } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { Dialog } from '../feedback/Dialog';\nimport { Button } from '../core/Button';\n\n/**\n * Profile-photo picker: an avatar disc with a camera button. Pick from the\n * library (or the camera on touch), frame the face in a circular crop, and it\n * hands back a **cropped, downscaled** `File` (JPEG). For attachments / documents\n * / multiple files use `FileUpload` instead.\n *\n * Client-side only downscales and re-encodes; it does not decode HEIC (no\n * browser but Safari can) - that is a server-side job. HEIC picks are rejected\n * with a message.\n */\n/** User-facing strings - English by default; pass overrides for another locale. */\nexport interface AvatarUploadLabels {\n trigger: string;\n upload: string;\n takePhoto: string;\n remove: string;\n cropTitle: string;\n cropHint: string;\n cameraTitle: string;\n cameraHint: string;\n capture: string;\n /** On the crop step, only shown for a shot taken with the camera; reopens it directly. */\n retake: string;\n cancel: string;\n save: string;\n zoom: string;\n heicError: string;\n notImage: string;\n tooLarge: (mb: number) => string;\n unreadable: string;\n cameraError: string;\n}\n\nconst EN: AvatarUploadLabels = {\n trigger: 'Change photo',\n upload: 'Upload a photo',\n takePhoto: 'Take a photo',\n remove: 'Remove photo',\n cropTitle: 'Adjust the photo',\n cropHint: 'Drag to reposition · scroll to zoom.',\n cameraTitle: 'Take a photo',\n cameraHint: 'Line your face up with the circle.',\n capture: 'Capture',\n retake: 'Retake',\n cancel: 'Cancel',\n save: 'Save',\n zoom: 'Zoom',\n heicError: \"That format (HEIC) won't open in the browser, upload a JPG or PNG.\",\n notImage: 'Choose an image file.',\n tooLarge: (mb) => `The image is over ${mb} MB.`,\n unreadable: \"Couldn't read that image. Try a JPG or PNG.\",\n cameraError: \"Couldn't open the camera: upload a photo from your library instead.\",\n};\n\nexport interface AvatarUploadProps {\n /** Full name - drives the initials fallback and the alt text. */\n name?: string;\n /** Current photo: a `File` (freshly cropped) or an existing URL string. */\n value?: File | string | null;\n onChange?: (file: File | null) => void;\n /** Disc diameter in px. */\n size?: number;\n /** Exported square size in px - the crop is drawn to this. */\n outputSize?: number;\n /** Reject picks larger than this (before crop). */\n maxSizeMB?: number;\n /** Override the English UI strings (menu, crop dialog, messages). */\n labels?: Partial<AvatarUploadLabels>;\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /**\n * Whether to allow taking a photo via camera (default true).\n * Set to `false` when picking an organization or brand logo, where taking a\n * live selfie/photo makes no sense.\n */\n allowCamera?: boolean;\n}\n\nfunction initials(name: string): string {\n return (name || '')\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((w) => w[0] || '')\n .join('')\n .toUpperCase();\n}\n\nconst isHeic = (f: File) => /image\\/heic|image\\/heif/i.test(f.type) || /\\.(heic|heif)$/i.test(f.name);\n\nexport const AvatarUpload = React.forwardRef<HTMLInputElement, AvatarUploadProps>(function AvatarUpload(\n {\n name = '',\n value,\n onChange,\n size = 96,\n outputSize = 512,\n maxSizeMB = 8,\n labels: labelsProp,\n label,\n hint,\n error,\n required,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n allowCamera = true,\n },\n forwardedRef,\n) {\n const t = React.useMemo<AvatarUploadLabels>(() => ({ ...EN, ...labelsProp }), [labelsProp]);\n const autoId = React.useId();\n const rid = id || autoId;\n const libRef = React.useRef<HTMLInputElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n const [menuOpen, setMenuOpen] = React.useState(false);\n const [menuPos, setMenuPos] = React.useState<{ top: number; left: number } | null>(null);\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [cropSrc, setCropSrc] = React.useState<string | null>(null);\n // Whether the photo now in the crop step came from the camera. Only then does the crop\n // modal offer \"Retake\" (a library pick already has its own way to change: cancel and pick\n // another file from the system's own dialog).\n const [cropFromCamera, setCropFromCamera] = React.useState(false);\n const [cameraOpen, setCameraOpen] = React.useState(false);\n const [internal, setInternal] = React.useState<File | null>(null);\n\n const current = value !== undefined ? value : internal;\n\n // Preview URL for the current photo.\n const [preview, setPreview] = React.useState<string | null>(typeof current === 'string' ? current : null);\n React.useEffect(() => {\n if (current instanceof File) {\n const u = URL.createObjectURL(current);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an object URL\n setPreview(u);\n return () => URL.revokeObjectURL(u);\n }\n setPreview(typeof current === 'string' ? current : null);\n }, [current]);\n\n const itemCount = (allowCamera ? 1 : 0) + 1 + (current ? 1 : 0);\n\n const toggleMenu = () => {\n if (!allowCamera && !current) {\n libRef.current?.click();\n return;\n }\n if (menuOpen) {\n setMenuOpen(false);\n return;\n }\n const r = triggerRef.current?.getBoundingClientRect();\n if (r) {\n const h = itemCount * 40 + 8;\n const flipUp = r.bottom + 6 + h > window.innerHeight - 8;\n setMenuPos({\n top: flipUp ? Math.max(8, r.top - 6 - h) : r.bottom + 6,\n left: Math.max(8, Math.min(r.left, window.innerWidth - 208)),\n });\n }\n setMenuOpen(true);\n };\n\n // Close the menu on outside click / Escape / scroll - it is portalled to <body>.\n React.useEffect(() => {\n if (!menuOpen) return;\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || menuRef.current?.contains(target)) return;\n setMenuOpen(false);\n };\n const close = () => setMenuOpen(false);\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();\n document.addEventListener('mousedown', onDown);\n document.addEventListener('keydown', onKey);\n window.addEventListener('scroll', close, true);\n window.addEventListener('resize', close);\n return () => {\n document.removeEventListener('mousedown', onDown);\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('scroll', close, true);\n window.removeEventListener('resize', close);\n };\n }, [menuOpen]);\n\n // One dialog for the flow, on whichever step is current: the crop once there is a photo,\n // else the live camera. A shot or a Retake flips both at once, so the step just changes.\n // The `Dialog` it is drawn in already locks the page scroll and closes on Escape (through the\n // `onClose` handed to it below), so nothing here does: a second lock of our own used to be\n // released after the Dialog's and left the page unable to scroll (SS-402).\n const step: Step | null = cropSrc ? 'crop' : allowCamera && cameraOpen ? 'camera' : null;\n\n const pick = (files: FileList | null) => {\n const f = files?.[0];\n if (!f) return;\n if (isHeic(f)) {\n setRejected(t.heicError);\n return;\n }\n if (!f.type.startsWith('image/')) {\n setRejected(t.notImage);\n return;\n }\n if (f.size > maxSizeMB * 1048576) {\n setRejected(t.tooLarge(maxSizeMB));\n return;\n }\n const url = URL.createObjectURL(f);\n const probe = new Image();\n probe.onload = () => {\n setRejected(null);\n setCropFromCamera(false);\n setCropSrc(url);\n };\n probe.onerror = () => {\n URL.revokeObjectURL(url);\n setRejected(t.unreadable);\n };\n probe.src = url;\n };\n\n const commit = (file: File | null) => {\n if (value === undefined) setInternal(file);\n onChange?.(file);\n };\n\n const onCropSave = (blob: Blob) => {\n const file = new File([blob], 'avatar.jpg', { type: 'image/jpeg' });\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n commit(file);\n };\n const onCropCancel = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n };\n\n const onCameraShot = (blob: Blob) => {\n setCameraOpen(false);\n setRejected(null);\n setCropFromCamera(true);\n setCropSrc(URL.createObjectURL(blob));\n };\n\n // Straight back to the live camera, no menu in between: the crop modal's \"Retake\".\n const onRetake = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n setCameraOpen(true);\n };\n\n const cameraBtn = Math.max(30, Math.round(size * 0.34));\n\n // What `Field` shows as the error: the consumer's, or a rejected pick's (type, size, unreadable).\n const shownError = error || rejected || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree: the pencil is what takes focus.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input ref={mergeRefs(libRef, forwardedRef)} id={rid} type=\"file\" accept=\"image/*\" disabled={disabled} onChange={(e) => pick(e.target.files)} style={{ display: 'none' }} />\n\n <div style={sx({ position: 'relative', width: size, height: size, flex: '0 0 auto', opacity: disabled ? 0.6 : 1 })}>\n <span\n style={sx({\n width: size,\n height: size,\n borderRadius: '999px',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: preview ? 'var(--bg-subtle)' : 'color-mix(in srgb, var(--brand-500) 22%, var(--bg-surface))',\n border: '1px solid ' + (preview ? 'var(--border-subtle)' : 'color-mix(in srgb, var(--brand-500) 30%, transparent)'),\n color: 'var(--text-brand)',\n fontFamily: 'var(--font-display)',\n fontWeight: 'var(--weight-bold)',\n fontSize: Math.round(size * 0.34),\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {preview ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={preview} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n initials(name) || <ImagePlus size={Math.round(size * 0.3)} strokeWidth={1.75} />\n )}\n </span>\n\n {!disabled && (\n <button\n ref={triggerRef}\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={t.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n {...a11y}\n onClick={toggleMenu}\n style={sx({\n position: 'absolute',\n right: -2,\n bottom: -2,\n width: cameraBtn,\n height: cameraBtn,\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-sm)',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <Pencil size={Math.round(cameraBtn * 0.46)} strokeWidth={1.75} />\n </button>\n )}\n\n </div>\n\n {menuOpen &&\n menuPos &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n style={sx({\n position: 'fixed',\n top: menuPos.top,\n left: menuPos.left,\n minWidth: 200,\n zIndex: 1000,\n padding: 'var(--space-1)',\n borderRadius: 'var(--radius-md)',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-lg)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n <MenuItem\n icon={<ImagePlus size={16} strokeWidth={1.75} />}\n label={t.upload}\n onClick={() => {\n setMenuOpen(false);\n libRef.current?.click();\n }}\n />\n {allowCamera && (\n <MenuItem\n icon={<Camera size={16} strokeWidth={1.75} />}\n label={t.takePhoto}\n onClick={() => {\n setMenuOpen(false);\n setRejected(null);\n setCameraOpen(true);\n }}\n />\n )}\n {current && (\n <MenuItem\n icon={<Trash2 size={16} strokeWidth={1.75} />}\n label={t.remove}\n danger\n onClick={() => {\n setMenuOpen(false);\n commit(null);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n\n {step && (\n <CaptureDialog\n step={step}\n src={cropSrc}\n outputSize={outputSize}\n labels={t}\n onClose={step === 'camera' ? () => setCameraOpen(false) : onCropCancel}\n onCameraShot={onCameraShot}\n onCameraError={() => {\n setCameraOpen(false);\n setRejected(t.cameraError);\n }}\n onSave={onCropSave}\n onRetake={cropFromCamera ? onRetake : undefined}\n />\n )}\n </Field>\n );\n});\n\nAvatarUpload.displayName = 'AvatarUpload';\n\nfunction MenuItem({ icon, label, onClick, danger }: { icon: React.ReactNode; label: string; onClick: () => void; danger?: boolean }) {\n const [hover, setHover] = React.useState(false);\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={onClick}\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n minHeight: 40,\n padding: '0 var(--space-3)',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: hover ? 'var(--bg-subtle)' : 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: danger ? 'var(--interactive-error)' : 'var(--text-primary)',\n textAlign: 'left',\n })}\n >\n {icon}\n {label}\n </button>\n );\n}\n\nconst DEFAULT_STAGE = 280; // crop stage's assumed size (px) before its own ResizeObserver measures it\n\n/**\n * Width of the camera and crop dialogs. They are two steps of one flow (a shot goes straight\n * to the crop), so they share it: a dialog that changed size between the steps would jump.\n * Wider than `Dialog`'s default 352: with Retake the crop footer has three real Buttons, and\n * in Portuguese (\"Tirar outra\", \"Cancelar\", \"Gravar\") they add up to 384px, more than the\n * 358px of content a 400px dialog leaves. 440 gives 398px, so they fit on one line with ~14px\n * to spare. `Dialog` already caps at `min(100%, ...)` for narrow viewports (see\n * feedback/Dialog.tsx), so a phone just gets a narrower dialog. Widening only moves the limit\n * though: the crop footer's `fill` is what keeps a longer language, or that phone, from\n * stranding the primary button.\n */\nconst MODAL_WIDTH = 440;\n\n/** Height reserved for the zoom row, so the camera step (which has none) is as tall as the crop step. */\nconst ZOOM_ROW_HEIGHT = 24;\n\n/**\n * The square viewport + circular guide, shared by the crop and camera modals.\n * `width: 100%` + `aspectRatio: 1`, not a fixed pixel box: it spans exactly the same\n * width as `Dialog.Header`'s title and `Dialog.Footer`'s buttons (both just block-level\n * or flex content inside the same padded `Dialog.Body`), instead of a fixed size\n * centered with margins of its own that didn't match theirs (SS-322 follow-up, the\n * stage read as misaligned from the rest of the dialog). Also needs no separate\n * mobile-width handling of its own: whatever width the dialog ends up at (already\n * responsive, see `feedback/Dialog.tsx`), the stage fills it exactly, staying square\n * via `aspectRatio`.\n */\nfunction CropStage({ children, onPointerDown, onPointerMove, onPointerUp, onWheel, stageRef }: {\n children: React.ReactNode;\n onPointerDown?: (e: React.PointerEvent) => void;\n onPointerMove?: (e: React.PointerEvent) => void;\n onPointerUp?: (e: React.PointerEvent) => void;\n onWheel?: (e: React.WheelEvent) => void;\n /** `useCropper` reads the live rendered size off this to drive the crop math (`V`). */\n stageRef?: React.Ref<HTMLDivElement>;\n}) {\n return (\n <div\n ref={stageRef}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onWheel={onWheel}\n style={sx({\n position: 'relative',\n width: '100%',\n aspectRatio: '1',\n overflow: 'hidden',\n borderRadius: 'var(--radius-lg)',\n background: 'var(--bg-sunken)',\n cursor: onPointerDown ? 'grab' : 'default',\n touchAction: 'none',\n })}\n >\n {children}\n <span\n style={sx({\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: '999px',\n boxShadow: '0 0 0 9999px color-mix(in srgb, var(--bg-overlay) 80%, transparent)',\n outline: '1px solid rgba(255, 255, 255, 0.9)',\n outlineOffset: -1,\n })}\n />\n </div>\n );\n}\n\n/** Which step of the photo flow the dialog is on. */\ntype Step = 'camera' | 'crop';\n\n/**\n * Live camera via `getUserMedia`, while `active`. A failure (no API, permission denied)\n * goes through `onError`. `ready` turns true once the stream is flowing; going inactive\n * stops the tracks, so the camera light goes off as soon as the dialog leaves this step.\n */\nfunction useCamera(active: boolean, onError: () => void) {\n const videoRef = React.useRef<HTMLVideoElement | null>(null);\n const streamRef = React.useRef<MediaStream | null>(null);\n const [ready, setReady] = React.useState(false);\n // Read through a ref so a new `onError` closure each render does not restart the camera.\n const onErrorRef = React.useRef(onError);\n React.useEffect(() => {\n onErrorRef.current = onError;\n });\n\n React.useEffect(() => {\n if (!active) return;\n let cancelled = false;\n let started: MediaStream | null = null;\n const md = typeof navigator !== 'undefined' ? navigator.mediaDevices : undefined;\n if (!md?.getUserMedia) {\n onErrorRef.current();\n return;\n }\n md.getUserMedia({ video: { facingMode: 'user', width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false })\n .then((s) => {\n if (cancelled) {\n s.getTracks().forEach((tr) => tr.stop());\n return;\n }\n started = s;\n streamRef.current = s;\n if (videoRef.current) videoRef.current.srcObject = s;\n setReady(true);\n })\n .catch(() => onErrorRef.current());\n return () => {\n cancelled = true;\n started?.getTracks().forEach((tr) => tr.stop());\n streamRef.current = null;\n setReady(false);\n };\n }, [active]);\n\n // The `<video>` may mount after the stream arrives (`Dialog` renders its children a render\n // late) or the other way round, so wire them up whichever comes last: here for the element,\n // above for the stream.\n const attachVideo = React.useCallback((el: HTMLVideoElement | null) => {\n videoRef.current = el;\n if (el && streamRef.current) el.srcObject = streamRef.current;\n }, []);\n\n /** Grabs the centred square of the current frame, mirrored like the preview, as a JPEG. */\n const shoot = (onShot: (b: Blob) => void) => {\n const v = videoRef.current;\n if (!v || !v.videoWidth) return;\n const s = Math.min(v.videoWidth, v.videoHeight);\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = s;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n ctx.translate(s, 0);\n ctx.scale(-1, 1);\n ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);\n canvas.toBlob((b) => b && onShot(b), 'image/jpeg', 0.9);\n };\n\n return { attachVideo, ready, shoot };\n}\n\n/**\n * The crop state and math for one picked photo (`src`): pan, zoom, the stage's live size,\n * and the export. It lives above the dialog, not inside the crop step, so the header, body\n * and footer of a single `Dialog` can all read it while the camera step swaps in and out.\n * Everything resets when `src` changes, so a retaken photo starts centred at 1x.\n */\nfunction useCropper(src: string | null, outputSize: number) {\n const [imgEl, setImgEl] = React.useState<HTMLImageElement | null>(null);\n // A *callback* ref (kept as state), not a plain `useRef` + a `[]`-effect: `Dialog` renders\n // its children only from the render *after* its own `mounted` flips true (SSR-safe portal),\n // so on the stage's very first mount a `useEffect(..., [])` reading `stageRef.current` at\n // that point would still see `null` and, with no deps to fire again on, never retry, so `V`\n // would then stay stuck at the `DEFAULT_STAGE` guess forever (this exact bug, caught live:\n // the displayed image stayed 280px inside a stage CSS had already sized at ~344px, a gray\n // gap on two edges). The callback fires the moment React actually attaches the node.\n const [stageEl, setStageEl] = React.useState<HTMLDivElement | null>(null);\n // The stage's own live rendered size (it's `width: 100%` of the dialog body now, not a\n // fixed px box), read via ResizeObserver. `DEFAULT_STAGE` is only the guess for the very\n // first paint, before the observer's first callback lands.\n const [V, setV] = React.useState(DEFAULT_STAGE);\n const prevV = React.useRef(V);\n const [nat, setNat] = React.useState<{ w: number; h: number } | null>(null);\n const [zoom, setZoom] = React.useState(1);\n const [offset, setOffset] = React.useState({ x: 0, y: 0 });\n const drag = React.useRef<{ x: number; y: number } | null>(null);\n\n // A new photo starts from scratch. Adjusting state while rendering (rather than in an\n // effect) means the stale pan / zoom is never painted against the new image.\n const [seenSrc, setSeenSrc] = React.useState(src);\n if (src !== seenSrc) {\n setSeenSrc(src);\n setNat(null);\n setZoom(1);\n setOffset({ x: 0, y: 0 });\n }\n\n React.useEffect(() => {\n if (!stageEl) return;\n const ro = new ResizeObserver((entries) => {\n const w = Math.round(entries[0]?.contentRect.width ?? 0);\n if (!w || w === prevV.current) return;\n // A live resize while the dialog is open (a phone rotated, a window resized) or the\n // very first real measurement replacing `DEFAULT_STAGE`: rescale the pan offset by\n // the same factor as the viewport itself, so the framed crop doesn't jump. `scale`\n // (see below) is linear in `V`, so multiplying the offset by `newV / oldV` keeps\n // the same fraction of the image framed.\n const factor = w / prevV.current;\n prevV.current = w;\n setV(w);\n setOffset((o) => ({ x: o.x * factor, y: o.y * factor }));\n });\n ro.observe(stageEl);\n return () => ro.disconnect();\n }, [stageEl]);\n\n const scaleMin = nat ? V / Math.min(nat.w, nat.h) : 1;\n const scale = scaleMin * zoom;\n const dispW = nat ? nat.w * scale : V;\n const dispH = nat ? nat.h * scale : V;\n\n const clamp = React.useCallback(\n (o: { x: number; y: number }) => ({\n x: Math.min(0, Math.max(V - dispW, o.x)),\n y: Math.min(0, Math.max(V - dispH, o.y)),\n }),\n [V, dispW, dispH],\n );\n\n const onImgLoad = (el: HTMLImageElement) => {\n const w = el.naturalWidth;\n const h = el.naturalHeight;\n setNat({ w, h });\n const s = V / Math.min(w, h);\n setOffset({ x: (V - w * s) / 2, y: (V - h * s) / 2 });\n };\n\n const setZoomAt = (nextZoom: number) => {\n const z = Math.min(3, Math.max(1, nextZoom));\n setZoom((prevZ) => {\n const oldScale = scaleMin * prevZ;\n const newScale = scaleMin * z;\n setOffset((o) => {\n const imgX = (V / 2 - o.x) / oldScale;\n const imgY = (V / 2 - o.y) / oldScale;\n return clamp({ x: V / 2 - imgX * newScale, y: V / 2 - imgY * newScale });\n });\n return z;\n });\n };\n\n const onPointerDown = (e: React.PointerEvent) => {\n (e.target as HTMLElement).setPointerCapture(e.pointerId);\n drag.current = { x: e.clientX, y: e.clientY };\n };\n const onPointerMove = (e: React.PointerEvent) => {\n if (!drag.current) return;\n const dx = e.clientX - drag.current.x;\n const dy = e.clientY - drag.current.y;\n drag.current = { x: e.clientX, y: e.clientY };\n setOffset((o) => clamp({ x: o.x + dx, y: o.y + dy }));\n };\n const onPointerUp = () => {\n drag.current = null;\n };\n\n const save = (onSave: (b: Blob) => void) => {\n if (!imgEl || !nat) return;\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = outputSize;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n const sSize = V / scale;\n ctx.drawImage(imgEl, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);\n canvas.toBlob((b) => b && onSave(b), 'image/jpeg', 0.85);\n };\n\n return { setImgEl, setStageEl, zoom, setZoomAt, offset, dispW, dispH, onImgLoad, onPointerDown, onPointerMove, onPointerUp, save };\n}\n\n/**\n * The one dialog for the whole photo flow: the live camera, then the crop (and back, on\n * Retake). It stays mounted across the steps and only its header text, stage and buttons\n * swap, so the panel does not close and reopen (no second pop-in, no scroll-lock or focus\n * hand-off) and it keeps one size. `Dialog.Header` / `Body` / `Footer` are direct children\n * on purpose: `Dialog` reads them off its children to pad the body and label itself, which\n * a wrapper component per step would hide from it.\n */\nfunction CaptureDialog({\n step,\n src,\n outputSize,\n labels,\n onClose,\n onCameraShot,\n onCameraError,\n onSave,\n onRetake,\n}: {\n step: Step;\n /** The photo being cropped; only set on the crop step. */\n src: string | null;\n outputSize: number;\n labels: AvatarUploadLabels;\n onClose: () => void;\n onCameraShot: (b: Blob) => void;\n onCameraError: () => void;\n onSave: (b: Blob) => void;\n /** Only set for a shot taken with the camera; shows the \"Retake\" button. */\n onRetake?: () => void;\n}) {\n const isCamera = step === 'camera';\n const camera = useCamera(isCamera, onCameraError);\n const crop = useCropper(src, outputSize);\n\n // The step's buttons unmount with it, and with them the focused one: without this, focus\n // would fall to the page behind the dialog and Tab would leave the trap. `Dialog` only\n // pulls focus in when it opens, so do it again on every step change.\n const [contentEl, setContentEl] = React.useState<HTMLDivElement | null>(null);\n React.useEffect(() => {\n contentEl?.closest<HTMLElement>('[role=\"dialog\"]')?.focus();\n }, [step, contentEl]);\n\n /* eslint-disable react-hooks/refs -- `useCamera` / `useCropper` return event handlers that reach a\n ref (`videoRef`, the drag origin), so the lint marks every property read off them; but those\n refs are only touched when a handler runs from an event, never during this render. */\n return (\n <Dialog width={MODAL_WIDTH} onClose={onClose}>\n <Dialog.Header title={isCamera ? labels.cameraTitle : labels.cropTitle} description={isCamera ? labels.cameraHint : labels.cropHint} />\n <Dialog.Body>\n <div ref={setContentEl}>\n {isCamera ? (\n <CropStage key=\"camera\">\n <video ref={camera.attachVideo} autoPlay playsInline muted style={sx({ width: '100%', height: '100%', objectFit: 'cover', transform: 'scaleX(-1)' })} />\n </CropStage>\n ) : (\n <CropStage\n key=\"crop\"\n stageRef={crop.setStageEl}\n onPointerDown={crop.onPointerDown}\n onPointerMove={crop.onPointerMove}\n onPointerUp={crop.onPointerUp}\n onWheel={(e) => crop.setZoomAt(crop.zoom - e.deltaY * 0.002)}\n >\n {src && (\n // eslint-disable-next-line @next/next/no-img-element\n <img\n ref={crop.setImgEl}\n src={src}\n alt=\"\"\n draggable={false}\n onLoad={(e) => crop.onImgLoad(e.currentTarget)}\n style={sx({ position: 'absolute', left: crop.offset.x, top: crop.offset.y, width: crop.dispW, height: crop.dispH, maxWidth: 'none', userSelect: 'none', pointerEvents: 'none' })}\n />\n )}\n </CropStage>\n )}\n\n {/* The zoom row is only there on the crop step, but the camera step keeps its room, so the dialog is the same height on both. */}\n <div style={sx({ display: 'flex', alignItems: 'center', gap: 'var(--space-3)', marginTop: 'var(--space-4)', minHeight: ZOOM_ROW_HEIGHT, color: 'var(--text-muted)' })}>\n {!isCamera && (\n <>\n <ZoomOut size={16} strokeWidth={1.75} style={{ flex: '0 0 auto' }} />\n <input\n type=\"range\"\n min={1}\n max={3}\n step={0.01}\n value={crop.zoom}\n onChange={(e) => crop.setZoomAt(Number(e.target.value))}\n aria-label={labels.zoom}\n style={sx({ flex: 1, accentColor: 'var(--interactive-primary)' })}\n />\n <ZoomIn size={16} strokeWidth={1.75} style={{ flex: '0 0 auto' }} />\n </>\n )}\n </div>\n </div>\n </Dialog.Body>\n {/* Three actions (crop after a camera shot, with Retake) share the row and each line they wrap onto; two stay right-aligned, as before. */}\n <Dialog.Footer fill={!isCamera && Boolean(onRetake)}>\n {isCamera ? (\n <React.Fragment key=\"camera\">\n <Button variant=\"secondary\" iconLeft={<X size={16} strokeWidth={2} />} onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button iconLeft={<Camera size={16} strokeWidth={2} />} onClick={() => camera.shoot(onCameraShot)} disabled={!camera.ready}>\n {labels.capture}\n </Button>\n </React.Fragment>\n ) : (\n <React.Fragment key=\"crop\">\n {onRetake && (\n <Button variant=\"secondary\" iconLeft={<RotateCcw size={16} strokeWidth={2} />} onClick={onRetake}>\n {labels.retake}\n </Button>\n )}\n <Button variant=\"secondary\" iconLeft={<X size={16} strokeWidth={2} />} onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button iconLeft={<Check size={16} strokeWidth={2.5} />} onClick={() => crop.save(onSave)}>\n {labels.save}\n </Button>\n </React.Fragment>\n )}\n </Dialog.Footer>\n </Dialog>\n );\n /* eslint-enable react-hooks/refs */\n}\n"],"mappings":";AA2RM,SAqgBQ,UArgBR,KAEA,YAFA;AAzRN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,OAAO,WAAW,QAAQ,WAAW,QAAQ,GAAG,QAAQ,eAAe;AACxF,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,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AW,GAAG;AAAA,SACpE,GAEJ;AAAA,OACF,GACF;AAAA,IAEA,oBAAC,OAAO,QAAP,EAAc,MAAM,CAAC,YAAY,QAAQ,QAAQ,GAC/C,qBACC,qBAAC,MAAM,UAAN,EACC;AAAA,0BAAC,UAAO,SAAQ,aAAY,UAAU,oBAAC,KAAE,MAAM,IAAI,aAAa,GAAG,GAAI,SAAS,SAC7E,iBAAO,QACV;AAAA,MACA,oBAAC,UAAO,UAAU,oBAAC,UAAO,MAAM,IAAI,aAAa,GAAG,GAAI,SAAS,MAAM,OAAO,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,OAClH,iBAAO,SACV;AAAA,SANkB,QAOpB,IAEA,qBAAC,MAAM,UAAN,EACE;AAAA,kBACC,oBAAC,UAAO,SAAQ,aAAY,UAAU,oBAAC,aAAU,MAAM,IAAI,aAAa,GAAG,GAAI,SAAS,UACrF,iBAAO,QACV;AAAA,MAEF,oBAAC,UAAO,SAAQ,aAAY,UAAU,oBAAC,KAAE,MAAM,IAAI,aAAa,GAAG,GAAI,SAAS,SAC7E,iBAAO,QACV;AAAA,MACA,oBAAC,UAAO,UAAU,oBAAC,SAAM,MAAM,IAAI,aAAa,KAAK,GAAI,SAAS,MAAM,KAAK,KAAK,MAAM,GACrF,iBAAO,MACV;AAAA,SAXkB,MAYpB,GAEJ;AAAA,KACF;AAGJ;","names":["AvatarUpload"]}
1
+ {"version":3,"sources":["../../src/forms/AvatarUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Camera, ImagePlus, Pencil, Trash2 } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { CaptureDialog, type Step } from './_internal/AvatarCaptureDialog';\n\n/**\n * Profile-photo picker: an avatar disc with a camera button. Pick from the\n * library (or the camera on touch), frame the face in a circular crop, and it\n * hands back a **cropped, downscaled** `File` (JPEG). For attachments / documents\n * / multiple files use `FileUpload` instead.\n *\n * Client-side only downscales and re-encodes; it does not decode HEIC (no\n * browser but Safari can) - that is a server-side job. HEIC picks are rejected\n * with a message.\n */\n/** User-facing strings - English by default; pass overrides for another locale. */\nexport interface AvatarUploadLabels {\n trigger: string;\n upload: string;\n takePhoto: string;\n remove: string;\n cropTitle: string;\n cropHint: string;\n cameraTitle: string;\n cameraHint: string;\n capture: string;\n /** On the crop step, only shown for a shot taken with the camera; reopens it directly. */\n retake: string;\n cancel: string;\n save: string;\n zoom: string;\n heicError: string;\n notImage: string;\n tooLarge: (mb: number) => string;\n unreadable: string;\n cameraError: string;\n}\n\nconst EN: AvatarUploadLabels = {\n trigger: 'Change photo',\n upload: 'Upload a photo',\n takePhoto: 'Take a photo',\n remove: 'Remove photo',\n cropTitle: 'Adjust the photo',\n cropHint: 'Drag to reposition · scroll to zoom.',\n cameraTitle: 'Take a photo',\n cameraHint: 'Line your face up with the circle.',\n capture: 'Capture',\n retake: 'Retake',\n cancel: 'Cancel',\n save: 'Save',\n zoom: 'Zoom',\n heicError: \"That format (HEIC) won't open in the browser, upload a JPG or PNG.\",\n notImage: 'Choose an image file.',\n tooLarge: (mb) => `The image is over ${mb} MB.`,\n unreadable: \"Couldn't read that image. Try a JPG or PNG.\",\n cameraError: \"Couldn't open the camera: upload a photo from your library instead.\",\n};\n\nexport interface AvatarUploadProps {\n /** Full name - drives the initials fallback and the alt text. */\n name?: string;\n /** Current photo: a `File` (freshly cropped) or an existing URL string. */\n value?: File | string | null;\n onChange?: (file: File | null) => void;\n /** Disc diameter in px. */\n size?: number;\n /** Exported square size in px - the crop is drawn to this. */\n outputSize?: number;\n /** Reject picks larger than this (before crop). */\n maxSizeMB?: number;\n /** Override the English UI strings (menu, crop dialog, messages). */\n labels?: Partial<AvatarUploadLabels>;\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /**\n * Whether to allow taking a photo via camera (default true).\n * Set to `false` when picking an organization or brand logo, where taking a\n * live selfie/photo makes no sense.\n */\n allowCamera?: boolean;\n}\n\nfunction initials(name: string): string {\n return (name || '')\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((w) => w[0] || '')\n .join('')\n .toUpperCase();\n}\n\nconst isHeic = (f: File) => /image\\/heic|image\\/heif/i.test(f.type) || /\\.(heic|heif)$/i.test(f.name);\n\nexport const AvatarUpload = React.forwardRef<HTMLInputElement, AvatarUploadProps>(function AvatarUpload(\n {\n name = '',\n value,\n onChange,\n size = 96,\n outputSize = 512,\n maxSizeMB = 8,\n labels: labelsProp,\n label,\n hint,\n error,\n required,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n allowCamera = true,\n },\n forwardedRef,\n) {\n const t = React.useMemo<AvatarUploadLabels>(() => ({ ...EN, ...labelsProp }), [labelsProp]);\n const autoId = React.useId();\n const rid = id || autoId;\n const libRef = React.useRef<HTMLInputElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n const [menuOpen, setMenuOpen] = React.useState(false);\n const [menuPos, setMenuPos] = React.useState<{ top: number; left: number } | null>(null);\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [cropSrc, setCropSrc] = React.useState<string | null>(null);\n // Whether the photo now in the crop step came from the camera. Only then does the crop\n // modal offer \"Retake\" (a library pick already has its own way to change: cancel and pick\n // another file from the system's own dialog).\n const [cropFromCamera, setCropFromCamera] = React.useState(false);\n const [cameraOpen, setCameraOpen] = React.useState(false);\n const [internal, setInternal] = React.useState<File | null>(null);\n\n const current = value !== undefined ? value : internal;\n\n // Preview URL for the current photo.\n const [preview, setPreview] = React.useState<string | null>(typeof current === 'string' ? current : null);\n React.useEffect(() => {\n if (current instanceof File) {\n const u = URL.createObjectURL(current);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an object URL\n setPreview(u);\n return () => URL.revokeObjectURL(u);\n }\n setPreview(typeof current === 'string' ? current : null);\n }, [current]);\n\n const itemCount = (allowCamera ? 1 : 0) + 1 + (current ? 1 : 0);\n\n const toggleMenu = () => {\n if (!allowCamera && !current) {\n libRef.current?.click();\n return;\n }\n if (menuOpen) {\n setMenuOpen(false);\n return;\n }\n const r = triggerRef.current?.getBoundingClientRect();\n if (r) {\n const h = itemCount * 40 + 8;\n const flipUp = r.bottom + 6 + h > window.innerHeight - 8;\n setMenuPos({\n top: flipUp ? Math.max(8, r.top - 6 - h) : r.bottom + 6,\n left: Math.max(8, Math.min(r.left, window.innerWidth - 208)),\n });\n }\n setMenuOpen(true);\n };\n\n // Close the menu on outside click / Escape / scroll - it is portalled to <body>.\n React.useEffect(() => {\n if (!menuOpen) return;\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || menuRef.current?.contains(target)) return;\n setMenuOpen(false);\n };\n const close = () => setMenuOpen(false);\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();\n document.addEventListener('mousedown', onDown);\n document.addEventListener('keydown', onKey);\n window.addEventListener('scroll', close, true);\n window.addEventListener('resize', close);\n return () => {\n document.removeEventListener('mousedown', onDown);\n document.removeEventListener('keydown', onKey);\n window.removeEventListener('scroll', close, true);\n window.removeEventListener('resize', close);\n };\n }, [menuOpen]);\n\n // One dialog for the flow, on whichever step is current: the crop once there is a photo,\n // else the live camera. A shot or a Retake flips both at once, so the step just changes.\n // The `Dialog` it is drawn in already locks the page scroll and closes on Escape (through the\n // `onClose` handed to it below), so nothing here does: a second lock of our own used to be\n // released after the Dialog's and left the page unable to scroll (SS-402).\n const step: Step | null = cropSrc ? 'crop' : allowCamera && cameraOpen ? 'camera' : null;\n\n const pick = (files: FileList | null) => {\n const f = files?.[0];\n if (!f) return;\n if (isHeic(f)) {\n setRejected(t.heicError);\n return;\n }\n if (!f.type.startsWith('image/')) {\n setRejected(t.notImage);\n return;\n }\n if (f.size > maxSizeMB * 1048576) {\n setRejected(t.tooLarge(maxSizeMB));\n return;\n }\n const url = URL.createObjectURL(f);\n const probe = new Image();\n probe.onload = () => {\n setRejected(null);\n setCropFromCamera(false);\n setCropSrc(url);\n };\n probe.onerror = () => {\n URL.revokeObjectURL(url);\n setRejected(t.unreadable);\n };\n probe.src = url;\n };\n\n const commit = (file: File | null) => {\n if (value === undefined) setInternal(file);\n onChange?.(file);\n };\n\n const onCropSave = (blob: Blob) => {\n const file = new File([blob], 'avatar.jpg', { type: 'image/jpeg' });\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n commit(file);\n };\n const onCropCancel = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n };\n\n const onCameraShot = (blob: Blob) => {\n setCameraOpen(false);\n setRejected(null);\n setCropFromCamera(true);\n setCropSrc(URL.createObjectURL(blob));\n };\n\n // Straight back to the live camera, no menu in between: the crop modal's \"Retake\".\n const onRetake = () => {\n if (cropSrc) URL.revokeObjectURL(cropSrc);\n setCropSrc(null);\n setCameraOpen(true);\n };\n\n const cameraBtn = Math.max(30, Math.round(size * 0.34));\n\n // What `Field` shows as the error: the consumer's, or a rejected pick's (type, size, unreadable).\n const shownError = error || rejected || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree: the pencil is what takes focus.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input ref={mergeRefs(libRef, forwardedRef)} id={rid} type=\"file\" accept=\"image/*\" disabled={disabled} onChange={(e) => pick(e.target.files)} style={{ display: 'none' }} />\n\n <div style={sx({ position: 'relative', width: size, height: size, flex: '0 0 auto', opacity: disabled ? 0.6 : 1 })}>\n <span\n style={sx({\n width: size,\n height: size,\n borderRadius: '999px',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: preview ? 'var(--bg-subtle)' : 'color-mix(in srgb, var(--brand-500) 22%, var(--bg-surface))',\n border: '1px solid ' + (preview ? 'var(--border-subtle)' : 'color-mix(in srgb, var(--brand-500) 30%, transparent)'),\n color: 'var(--text-brand)',\n fontFamily: 'var(--font-display)',\n fontWeight: 'var(--weight-bold)',\n fontSize: Math.round(size * 0.34),\n letterSpacing: 'var(--tracking-snug)',\n })}\n >\n {preview ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={preview} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n initials(name) || <ImagePlus size={Math.round(size * 0.3)} strokeWidth={1.75} />\n )}\n </span>\n\n {!disabled && (\n <button\n ref={triggerRef}\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={t.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n {...a11y}\n onClick={toggleMenu}\n style={sx({\n position: 'absolute',\n right: -2,\n bottom: -2,\n width: cameraBtn,\n height: cameraBtn,\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-sm)',\n color: 'var(--text-secondary)',\n cursor: 'pointer',\n })}\n >\n <Pencil size={Math.round(cameraBtn * 0.46)} strokeWidth={1.75} />\n </button>\n )}\n\n </div>\n\n {menuOpen &&\n menuPos &&\n createPortal(\n <div\n ref={menuRef}\n role=\"menu\"\n style={sx({\n position: 'fixed',\n top: menuPos.top,\n left: menuPos.left,\n minWidth: 200,\n zIndex: 1000,\n padding: 'var(--space-1)',\n borderRadius: 'var(--radius-md)',\n background: 'var(--bg-surface)',\n border: '1px solid var(--border-default)',\n boxShadow: 'var(--shadow-lg)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n <MenuItem\n icon={<ImagePlus size={16} strokeWidth={1.75} />}\n label={t.upload}\n onClick={() => {\n setMenuOpen(false);\n libRef.current?.click();\n }}\n />\n {allowCamera && (\n <MenuItem\n icon={<Camera size={16} strokeWidth={1.75} />}\n label={t.takePhoto}\n onClick={() => {\n setMenuOpen(false);\n setRejected(null);\n setCameraOpen(true);\n }}\n />\n )}\n {current && (\n <MenuItem\n icon={<Trash2 size={16} strokeWidth={1.75} />}\n label={t.remove}\n danger\n onClick={() => {\n setMenuOpen(false);\n commit(null);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n\n {step && (\n <CaptureDialog\n step={step}\n src={cropSrc}\n outputSize={outputSize}\n labels={t}\n onClose={step === 'camera' ? () => setCameraOpen(false) : onCropCancel}\n onCameraShot={onCameraShot}\n onCameraError={() => {\n setCameraOpen(false);\n setRejected(t.cameraError);\n }}\n onSave={onCropSave}\n onRetake={cropFromCamera ? onRetake : undefined}\n />\n )}\n </Field>\n );\n});\n\nAvatarUpload.displayName = 'AvatarUpload';\n\nfunction MenuItem({ icon, label, onClick, danger }: { icon: React.ReactNode; label: string; onClick: () => void; danger?: boolean }) {\n const [hover, setHover] = React.useState(false);\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={onClick}\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n minHeight: 40,\n padding: '0 var(--space-3)',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: hover ? 'var(--bg-subtle)' : 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: danger ? 'var(--interactive-error)' : 'var(--text-primary)',\n textAlign: 'left',\n })}\n >\n {icon}\n {label}\n </button>\n );\n}\n"],"mappings":";AA0RM,cAEA,YAFA;AAxRN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,WAAW,QAAQ,cAAc;AAClD,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBA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ACA,QAAQ;AAAA,QACR,SAAS,SAAS,WAAW,MAAM,cAAc,KAAK,IAAI;AAAA,QAC1D;AAAA,QACA,eAAe,MAAM;AACnB,wBAAc,KAAK;AACnB,sBAAY,EAAE,WAAW;AAAA,QAC3B;AAAA,QACA,QAAQ;AAAA,QACR,UAAU,iBAAiB,WAAW;AAAA;AAAA,IACxC;AAAA,KAEJ;AAEJ,CAAC;AAED,aAAa,cAAc;AAE3B,SAAS,SAAS,EAAE,MAAM,OAAO,SAAS,OAAO,GAAoF;AACnI,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA,cAAc,MAAM,SAAS,IAAI;AAAA,MACjC,cAAc,MAAM,SAAS,KAAK;AAAA,MAClC,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,KAAK;AAAA,QACL,OAAO;AAAA,QACP,WAAW;AAAA,QACX,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,YAAY,QAAQ,qBAAqB;AAAA,QACzC,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,OAAO,SAAS,6BAA6B;AAAA,QAC7C,WAAW;AAAA,MACb,CAAC;AAAA,MAEA;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["AvatarUpload"]}
@@ -8,6 +8,7 @@ import { Field } from "../_internal/Field.js";
8
8
  import { fieldA11y } from "../_internal/fieldA11y.js";
9
9
  import { useIsoLayoutEffect } from "../_internal/useIsoLayoutEffect.js";
10
10
  import { useMenuPlacement } from "../_internal/useMenuPlacement.js";
11
+ import { useOutsidePress } from "../_internal/useOutsidePress.js";
11
12
  import { CalendarGrid } from "./_internal/CalendarGrid.js";
12
13
  import { parseISODate as parseISO, toISODate as toISO } from "./_internal/calendarRange.js";
13
14
  import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
@@ -87,14 +88,9 @@ const DatePicker = React.forwardRef(function DatePicker2({
87
88
  const above = field.top - GAP - height;
88
89
  setFitTop(below + height <= viewport - EDGE ? below : above >= EDGE ? above : Math.max(EDGE, viewport - EDGE - height));
89
90
  }, [portalled, place, viewYear, viewMonth]);
91
+ useOutsidePress(open, [rootRef, popoverRef], () => setOpen(false));
90
92
  React.useEffect(() => {
91
93
  if (!open) return;
92
- const onDown = (e) => {
93
- const target = e.target;
94
- if (rootRef.current && !rootRef.current.contains(target) && !popoverRef.current?.contains(target)) {
95
- setOpen(false);
96
- }
97
- };
98
94
  const onKey = (e) => {
99
95
  if (e.key === "Escape") {
100
96
  e.preventDefault();
@@ -102,12 +98,8 @@ const DatePicker = React.forwardRef(function DatePicker2({
102
98
  triggerRef.current?.focus();
103
99
  }
104
100
  };
105
- document.addEventListener("pointerdown", onDown, true);
106
101
  document.addEventListener("keydown", onKey, true);
107
- return () => {
108
- document.removeEventListener("pointerdown", onDown, true);
109
- document.removeEventListener("keydown", onKey, true);
110
- };
102
+ return () => document.removeEventListener("keydown", onKey, true);
111
103
  }, [open]);
112
104
  const openPopover = () => {
113
105
  if (disabled) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * The widest a calendar gets once it leaves the field's own width, i.e. when portalled out of a Dialog. Its\n * cells are square, so it is as tall as it is wide: at the width of a wide dialog field it would be a\n * 450px-tall slab that covers the field and half the window. Inline it is untouched (still the field's width).\n */\nconst PORTALLED_MAX_WIDTH = 320;\n\n/** What a keyboard can reach inside `root`, in tab order (the calendar's roving day has `tabindex=\"0\"`, the others `-1`). */\nfunction tabbables(root: HTMLElement | null): HTMLElement[] {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>('button:not(:disabled), [tabindex]')).filter((el) => el.tabIndex >= 0);\n}\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n /**\n * Fires when the month on screen changes (the arrows, or the month / year popover), with the\n * new year and the 0-indexed month. Not when the popover opens: it opens on the month of the\n * value, or on the current one. Refresh `dayDots` / `renderDay` here.\n */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second\n * argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells\n * grow taller to hold it.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers\n * (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of\n * the month on screen, so refresh them in `onMonthChange`.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\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\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const popoverRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // Where the calendar sits. Normally a plain `position: absolute` child of\n // `rootRef` (itself `position: relative`) - the same \"inline\" strategy\n // Select's panel uses for its common case, and the same one DateTimePicker's\n // own month/year popover already uses. The browser glues it to the trigger\n // through *any* scroll (page or a nested overflow container) for free - no JS\n // measuring position, no listening for scroll/resize, and critically, it\n // never has to close on scroll the way a `position: fixed` popover computed\n // once would (that was tried first here and didn't hold up - see PR history).\n //\n // The one place that fails is inside a `position: fixed` container (a\n // Dialog): its body scrolls and clips an inline child, cutting the calendar\n // off. There `useMenuPlacement` answers 'fixed' (what Select and\n // Autocomplete already do) and the calendar is portalled to <body> at the\n // field's viewport rect, closing if the field moves. Outside a dialog nothing\n // changes: still inline, still below the field, never flipped (the hook's\n // `above` / `maxH` are not used at all: see `fitTop` for the portalled case).\n // `itemCount` is just the hook's height estimate; a calendar is not a list.\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef: popoverRef,\n itemCount: 8,\n onDismiss: () => setOpen(false),\n });\n const portalled = open && place?.strategy === 'fixed';\n\n // The hook picks \"below\" or \"above\" from a rough guess at the height, which suits a list capped at 288px but not\n // a calendar (about as tall as it is wide). So once the portalled calendar is on screen it is measured and kept\n // inside the window: under the field if it fits, else above it, else as far up as it needs (over the field rather\n // than cut off). The month changes the row count, hence the dependencies. Runs before paint: no visible jump.\n const [fitTop, setFitTop] = React.useState<number | null>(null);\n useIsoLayoutEffect(() => {\n const popover = popoverRef.current;\n const box = boxRef.current;\n if (!portalled || !popover || !box) return;\n const GAP = 6;\n const EDGE = 8;\n const field = box.getBoundingClientRect();\n const height = popover.offsetHeight;\n const viewport = window.innerHeight || document.documentElement.clientHeight || 900;\n const below = field.bottom + GAP;\n const above = field.top - GAP - height;\n setFitTop(below + height <= viewport - EDGE ? below : above >= EDGE ? above : Math.max(EDGE, viewport - EDGE - height));\n }, [portalled, place, viewYear, viewMonth]);\n\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n // The portalled calendar is outside `rootRef` in the DOM but still part of the field.\n const target = e.target as Node;\n if (rootRef.current && !rootRef.current.contains(target) && !popoverRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // handled: a Dialog around the field keeps its own Esc for the next press\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n document.addEventListener('keydown', onKey, true);\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n document.removeEventListener('keydown', onKey, true);\n };\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const clear = () => {\n if (value === undefined) setInner('');\n onChange?.('');\n triggerRef.current?.focus();\n };\n\n // Inline, the calendar follows the field in the DOM, so Tab walks field -> calendar -> next field on its\n // own. Portalled to the end of <body> it does not, so the focus is handed over by hand to keep that order.\n const onBoxKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab' || e.shiftKey || !portalled) return;\n const controls = tabbables(e.currentTarget);\n if (e.target !== controls[controls.length - 1]) return; // not the control the calendar follows\n const first = tabbables(popoverRef.current)[0];\n if (!first) return;\n e.preventDefault();\n first.focus();\n };\n\n const onPopoverKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab') return;\n const controls = tabbables(boxRef.current);\n const field = controls[controls.length - 1]; // the control the calendar follows in the DOM\n const inside = tabbables(e.currentTarget);\n if (e.shiftKey && e.target === inside[0]) {\n e.preventDefault();\n field?.focus();\n } else if (!e.shiftKey && e.target === inside[inside.length - 1]) {\n // Not prevented on purpose: with the focus back on the field the Tab goes on to whatever follows it.\n setOpen(false);\n field?.focus();\n }\n };\n\n // One popover, two positions (see `useMenuPlacement` above): the calendar and its look are the same.\n const renderPopover = (position: React.CSSProperties) => (\n <div\n ref={popoverRef}\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n onKeyDown={portalled ? onPopoverKeyDown : undefined}\n style={sx({\n ...position,\n // The 7-column grid needs some floor width to stay readable -\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\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 <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n onMonthChange?.(y, m);\n }}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n - the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div ref={boxRef} onKeyDown={onBoxKeyDown} style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && place?.strategy === 'inline' &&\n renderPopover({ position: 'absolute', top: 'calc(100% + 6px)', left: 0, right: 0, zIndex: 20 })}\n {open && place?.strategy === 'fixed' &&\n createPortal(\n renderPopover({\n position: 'fixed',\n top: fitTop ?? place.top, // `fitTop` is measured (see above); the hook's guess only holds the first, unpainted render\n left: place.left,\n width: Math.min(place.width, PORTALLED_MAX_WIDTH),\n boxSizing: 'border-box',\n zIndex: 1100, // above the Dialog (1000), level with Select / Autocomplete's portalled lists\n }),\n document.body,\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AA0TM,cA6BI,YA7BJ;AAxTN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,UAAU,aAAa,aAAa;AAC7D,SAAS,qBAAqB;AAE9B,MAAM,OAAO;AAAA,EACX,SAAS,EAAE,aAAa,mBAAmB,aAAa,iBAAiB,YAAY,cAAc;AAAA,EACnG,IAAI,EAAE,aAAa,eAAe,aAAa,iBAAiB,YAAY,aAAa;AAC3F;AAOA,MAAM,sBAAsB;AAG5B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A,YAChB,aAAa;AAAA,YACb,SAAS;AAAA,YACT,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,YAAY;AAAA,YACZ,OAAO;AAAA,YACP,QAAQ;AAAA,UACV,CAAC;AAAA,UAED,8BAAC,KAAE,MAAM,IAAI,aAAa,GAAG;AAAA;AAAA,MAC/B;AAAA,OAEJ;AAAA,IAEC,QAAQ,OAAO,aAAa,YAC3B,cAAc,EAAE,UAAU,YAAY,KAAK,oBAAoB,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,CAAC;AAAA,IAC/F,QAAQ,OAAO,aAAa,WAC3B;AAAA,MACE,cAAc;AAAA,QACZ,UAAU;AAAA,QACV,KAAK,UAAU,MAAM;AAAA;AAAA,QACrB,MAAM,MAAM;AAAA,QACZ,OAAO,KAAK,IAAI,MAAM,OAAO,mBAAmB;AAAA,QAChD,WAAW;AAAA,QACX,QAAQ;AAAA;AAAA,MACV,CAAC;AAAA,MACD,SAAS;AAAA,IACX;AAAA,KACJ,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;","names":["DatePicker"]}
1
+ {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * The widest a calendar gets once it leaves the field's own width, i.e. when portalled out of a Dialog. Its\n * cells are square, so it is as tall as it is wide: at the width of a wide dialog field it would be a\n * 450px-tall slab that covers the field and half the window. Inline it is untouched (still the field's width).\n */\nconst PORTALLED_MAX_WIDTH = 320;\n\n/** What a keyboard can reach inside `root`, in tab order (the calendar's roving day has `tabindex=\"0\"`, the others `-1`). */\nfunction tabbables(root: HTMLElement | null): HTMLElement[] {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>('button:not(:disabled), [tabindex]')).filter((el) => el.tabIndex >= 0);\n}\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n /**\n * Fires when the month on screen changes (the arrows, or the month / year popover), with the\n * new year and the 0-indexed month. Not when the popover opens: it opens on the month of the\n * value, or on the current one. Refresh `dayDots` / `renderDay` here.\n */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second\n * argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells\n * grow taller to hold it.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers\n * (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of\n * the month on screen, so refresh them in `onMonthChange`.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\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\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const popoverRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // Where the calendar sits. Normally a plain `position: absolute` child of\n // `rootRef` (itself `position: relative`) - the same \"inline\" strategy\n // Select's panel uses for its common case, and the same one DateTimePicker's\n // own month/year popover already uses. The browser glues it to the trigger\n // through *any* scroll (page or a nested overflow container) for free - no JS\n // measuring position, no listening for scroll/resize, and critically, it\n // never has to close on scroll the way a `position: fixed` popover computed\n // once would (that was tried first here and didn't hold up - see PR history).\n //\n // The one place that fails is inside a `position: fixed` container (a\n // Dialog): its body scrolls and clips an inline child, cutting the calendar\n // off. There `useMenuPlacement` answers 'fixed' (what Select and\n // Autocomplete already do) and the calendar is portalled to <body> at the\n // field's viewport rect, closing if the field moves. Outside a dialog nothing\n // changes: still inline, still below the field, never flipped (the hook's\n // `above` / `maxH` are not used at all: see `fitTop` for the portalled case).\n // `itemCount` is just the hook's height estimate; a calendar is not a list.\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef: popoverRef,\n itemCount: 8,\n onDismiss: () => setOpen(false),\n });\n const portalled = open && place?.strategy === 'fixed';\n\n // The hook picks \"below\" or \"above\" from a rough guess at the height, which suits a list capped at 288px but not\n // a calendar (about as tall as it is wide). So once the portalled calendar is on screen it is measured and kept\n // inside the window: under the field if it fits, else above it, else as far up as it needs (over the field rather\n // than cut off). The month changes the row count, hence the dependencies. Runs before paint: no visible jump.\n const [fitTop, setFitTop] = React.useState<number | null>(null);\n useIsoLayoutEffect(() => {\n const popover = popoverRef.current;\n const box = boxRef.current;\n if (!portalled || !popover || !box) return;\n const GAP = 6;\n const EDGE = 8;\n const field = box.getBoundingClientRect();\n const height = popover.offsetHeight;\n const viewport = window.innerHeight || document.documentElement.clientHeight || 900;\n const below = field.bottom + GAP;\n const above = field.top - GAP - height;\n setFitTop(below + height <= viewport - EDGE ? below : above >= EDGE ? above : Math.max(EDGE, viewport - EDGE - height));\n }, [portalled, place, viewYear, viewMonth]);\n\n // A press outside the field closes the calendar. The portalled calendar is outside `rootRef` in the DOM but\n // still part of the field, so both count as inside.\n useOutsidePress(open, [rootRef, popoverRef], () => setOpen(false));\n React.useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // handled: a Dialog around the field keeps its own Esc for the next press\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('keydown', onKey, true);\n return () => document.removeEventListener('keydown', onKey, true);\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const clear = () => {\n if (value === undefined) setInner('');\n onChange?.('');\n triggerRef.current?.focus();\n };\n\n // Inline, the calendar follows the field in the DOM, so Tab walks field -> calendar -> next field on its\n // own. Portalled to the end of <body> it does not, so the focus is handed over by hand to keep that order.\n const onBoxKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab' || e.shiftKey || !portalled) return;\n const controls = tabbables(e.currentTarget);\n if (e.target !== controls[controls.length - 1]) return; // not the control the calendar follows\n const first = tabbables(popoverRef.current)[0];\n if (!first) return;\n e.preventDefault();\n first.focus();\n };\n\n const onPopoverKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab') return;\n const controls = tabbables(boxRef.current);\n const field = controls[controls.length - 1]; // the control the calendar follows in the DOM\n const inside = tabbables(e.currentTarget);\n if (e.shiftKey && e.target === inside[0]) {\n e.preventDefault();\n field?.focus();\n } else if (!e.shiftKey && e.target === inside[inside.length - 1]) {\n // Not prevented on purpose: with the focus back on the field the Tab goes on to whatever follows it.\n setOpen(false);\n field?.focus();\n }\n };\n\n // One popover, two positions (see `useMenuPlacement` above): the calendar and its look are the same.\n const renderPopover = (position: React.CSSProperties) => (\n <div\n ref={popoverRef}\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n onKeyDown={portalled ? onPopoverKeyDown : undefined}\n style={sx({\n ...position,\n // The 7-column grid needs some floor width to stay readable -\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\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 <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n onMonthChange?.(y, m);\n }}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n - the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div ref={boxRef} onKeyDown={onBoxKeyDown} style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && place?.strategy === 'inline' &&\n renderPopover({ position: 'absolute', top: 'calc(100% + 6px)', left: 0, right: 0, zIndex: 20 })}\n {open && place?.strategy === 'fixed' &&\n createPortal(\n renderPopover({\n position: 'fixed',\n top: fitTop ?? place.top, // `fitTop` is measured (see above); the hook's guess only holds the first, unpainted render\n left: place.left,\n width: Math.min(place.width, PORTALLED_MAX_WIDTH),\n boxSizing: 'border-box',\n zIndex: 1100, // above the Dialog (1000), level with Select / Autocomplete's portalled lists\n }),\n document.body,\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AAmTM,cA6BI,YA7BJ;AAjTN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,UAAU,aAAa,aAAa;AAC7D,SAAS,qBAAqB;AAE9B,MAAM,OAAO;AAAA,EACX,SAAS,EAAE,aAAa,mBAAmB,aAAa,iBAAiB,YAAY,cAAc;AAAA,EACnG,IAAI,EAAE,aAAa,eAAe,aAAa,iBAAiB,YAAY,aAAa;AAC3F;AAOA,MAAM,sBAAsB;AAG5B,SAAS,UAAU,MAAyC;AAC1D,MAAI,CAAC,KAAM,QAAO,CAAC;AACnB,SAAO,MAAM,KAAK,KAAK,iBAA8B,mCAAmC,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG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