@particle-academy/react-fancy 6.10.0 → 6.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{chunk-GEQKNV7E.js → chunk-26GRLVCQ.js} +17 -13
  3. package/dist/chunk-26GRLVCQ.js.map +1 -0
  4. package/dist/{chunk-ZHTK4IPQ.js → chunk-4676NOI6.js} +17 -13
  5. package/dist/chunk-4676NOI6.js.map +1 -0
  6. package/dist/{chunk-HANQYZW2.cjs → chunk-GB2EGMVQ.cjs} +16 -12
  7. package/dist/chunk-GB2EGMVQ.cjs.map +1 -0
  8. package/dist/chunk-HHCVBIMM.js +21 -0
  9. package/dist/chunk-HHCVBIMM.js.map +1 -0
  10. package/dist/{chunk-NIFHAFKK.cjs → chunk-JFPBW5MO.cjs} +17 -13
  11. package/dist/chunk-JFPBW5MO.cjs.map +1 -0
  12. package/dist/{chunk-ZBXJDQXN.js → chunk-JJYMRV62.js} +17 -13
  13. package/dist/chunk-JJYMRV62.js.map +1 -0
  14. package/dist/{chunk-R6O6SLXK.js → chunk-LG2O26CG.js} +13 -8
  15. package/dist/chunk-LG2O26CG.js.map +1 -0
  16. package/dist/{chunk-5U2DZ7AV.js → chunk-MUV7OK3W.js} +8 -6
  17. package/dist/chunk-MUV7OK3W.js.map +1 -0
  18. package/dist/{chunk-EC4ZYZNK.cjs → chunk-NFUKNVB7.cjs} +13 -8
  19. package/dist/chunk-NFUKNVB7.cjs.map +1 -0
  20. package/dist/chunk-RE3PMG47.cjs +23 -0
  21. package/dist/chunk-RE3PMG47.cjs.map +1 -0
  22. package/dist/{chunk-7NRG77U5.cjs → chunk-TXQT6S4D.cjs} +16 -12
  23. package/dist/chunk-TXQT6S4D.cjs.map +1 -0
  24. package/dist/{chunk-TXTRTTG7.cjs → chunk-UOG3O3KP.cjs} +8 -6
  25. package/dist/chunk-UOG3O3KP.cjs.map +1 -0
  26. package/dist/command.cjs +5 -4
  27. package/dist/command.js +3 -2
  28. package/dist/drawer.cjs +5 -4
  29. package/dist/drawer.d.cts +8 -1
  30. package/dist/drawer.d.ts +8 -1
  31. package/dist/drawer.js +3 -2
  32. package/dist/editor.cjs +1 -1
  33. package/dist/editor.js +1 -1
  34. package/dist/file-upload.cjs +3 -3
  35. package/dist/file-upload.js +1 -1
  36. package/dist/index.cjs +15 -14
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +12 -1
  39. package/dist/index.d.ts +12 -1
  40. package/dist/index.js +6 -5
  41. package/dist/index.js.map +1 -1
  42. package/dist/mobile-menu.cjs +1 -1
  43. package/dist/mobile-menu.js +1 -1
  44. package/dist/modal.cjs +5 -4
  45. package/dist/modal.d.cts +11 -1
  46. package/dist/modal.d.ts +11 -1
  47. package/dist/modal.js +3 -2
  48. package/dist/sidebar.cjs +1 -1
  49. package/dist/sidebar.js +1 -1
  50. package/package.json +1 -1
  51. package/dist/chunk-5U2DZ7AV.js.map +0 -1
  52. package/dist/chunk-7NRG77U5.cjs.map +0 -1
  53. package/dist/chunk-EC4ZYZNK.cjs.map +0 -1
  54. package/dist/chunk-GEQKNV7E.js.map +0 -1
  55. package/dist/chunk-HANQYZW2.cjs.map +0 -1
  56. package/dist/chunk-NIFHAFKK.cjs.map +0 -1
  57. package/dist/chunk-R6O6SLXK.js.map +0 -1
  58. package/dist/chunk-TXTRTTG7.cjs.map +0 -1
  59. package/dist/chunk-ZBXJDQXN.js.map +0 -1
  60. package/dist/chunk-ZHTK4IPQ.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -11,6 +11,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [6.11.1] - 2026-11-07
15
+
16
+ ### Fixed
17
+
18
+ - **`FileUpload` text follows the `--fancy-text-*` theme tokens.** The dropzone hint and icon, the list's size meta, the thumbnail's file name and extension, and the remove button were bare `text-zinc-*`, so an app that mapped the tokens themed every other component and left FileUpload grey. On a `#0A2347` surface the hint was 3.23:1, under AA (found by axe at AAA in a consumer app). They now read `--fancy-text-muted` (hint, meta, name, extension, remove), `--fancy-text-soft` (remove on hover) and `--fancy-text-faint` (the decorative file glyphs), with the same fallbacks as every other component. Default contrast also improves where it fell short: the hint in dark mode was 3.67:1 and is now 6.75:1; the size meta in light was 2.62:1 and is now 4.83:1; the list's remove icon was 2.62:1 in light, under the 3:1 a text-less control owes (WCAG 1.4.11), and is now 4.83:1. During drag-over the hint and icon step up to `--fancy-text-subtle`, because muted on the blue drag fill is 4.44:1; subtle is 7.09:1 there. **Consumer action:** none; an app that maps `--fancy-text-muted` now themes the FileUpload hint.
19
+ - **The thumbnail remove button shows on keyboard focus.** It was `opacity-0` until the tile was hovered, so tabbing onto it focused an invisible control. **Consumer action:** none.
20
+ - **Known limit:** the kit's muted token is 4.83:1 on the default light surface and 6.75:1 on the default dark one, below AAA's 7:1 in both. FileUpload uses it as the other components do; the token is unchanged. An app that needs AAA can map `--fancy-text-muted` / `--fancy-text-muted-dark`.
21
+
22
+ ## [6.11.0] - 2026-11-04
23
+
24
+ ### Added
25
+
26
+ - **`Modal.Header` and `Drawer.Header` take `closeLabel`**, the close button's accessible name, so it can be translated. Default `"Close"`, as before. **Consumer action:** none; pass your locale's word if you localise.
27
+ - **`useFocusTrap` takes an optional third argument, `restoreTo`**, a ref to the element focus returns to on disable. Without it the hook behaves as before. **Consumer action:** none.
28
+
29
+ ### Fixed
30
+
31
+ - **`Modal`, `Drawer` and `Command` now trap focus.** The trap ran in the commit where `open` flipped, but the panel exists two renders later (`useAnimation` mounts it, then `Portal` renders it). It found no element, returned, and never ran again. So focus never moved into the dialog, Tab and Shift+Tab walked out of it, and closing never returned focus to the trigger. This affected every one of them, opened from a trigger or rendered open, with or without motion. The trap now runs once the panel is mounted. The element to return to is recorded when `open` flips, so a dialog whose content autofocuses (Command's input) still returns focus to the trigger. A container-attached `Drawer` still does not trap. Verified in headless Chromium, with and without `prefers-reduced-motion`. **Consumer action:** none. If you worked around it by focusing inside the dialog yourself, that still works.
32
+ - **The focus trap ignores elements with `tabindex="-1"`.** Its selector matched Command's options, which are `tabindex="-1"`, and took one for the last tab stop. Focus was never on it, so Tab never wrapped and left the palette. **Consumer action:** none.
33
+ - **The `Modal.Header` and `Drawer.Header` close buttons are a 44px target** (WCAG 2.5.5, AAA). They were 28px and 26px. A `::before` extends the hit area. The button, the icon, the hover fill and the header's height are unchanged. **Consumer action:** none.
34
+
14
35
  ## [6.10.0] - 2026-11-04
15
36
 
16
37
  ### Added
@@ -1,9 +1,9 @@
1
- import { useFocusTrap } from './chunk-5U2DZ7AV.js';
1
+ import { useDialogFocusTrap } from './chunk-HHCVBIMM.js';
2
2
  import { useAnimation } from './chunk-3K2CEAI7.js';
3
3
  import { Portal } from './chunk-RBCMKPBX.js';
4
4
  import { useEscapeKey } from './chunk-YX6FTJ6N.js';
5
5
  import { cn } from './chunk-MMW2JGKZ.js';
6
- import { createContext, useRef, useCallback, useEffect, useMemo, useContext } from 'react';
6
+ import { createContext, useCallback, useEffect, useMemo, useContext } from 'react';
7
7
  import { X } from 'lucide-react';
8
8
  import { jsx, jsxs } from 'react/jsx-runtime';
9
9
 
@@ -15,7 +15,7 @@ function useModal() {
15
15
  }
16
16
  return ctx;
17
17
  }
18
- function ModalHeader({ children, className }) {
18
+ function ModalHeader({ children, className, closeLabel = "Close" }) {
19
19
  const { close } = useModal();
20
20
  return /* @__PURE__ */ jsxs(
21
21
  "div",
@@ -32,8 +32,9 @@ function ModalHeader({ children, className }) {
32
32
  {
33
33
  type: "button",
34
34
  onClick: close,
35
- className: "rounded-lg p-1 text-zinc-400 transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300",
36
- "aria-label": "Close",
35
+ "data-react-fancy-modal-close": "",
36
+ className: "relative rounded-lg p-1 text-zinc-400 before:absolute before:-inset-2 before:content-[''] transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300",
37
+ "aria-label": closeLabel,
37
38
  children: /* @__PURE__ */ jsx(X, { size: 20 })
38
39
  }
39
40
  )
@@ -83,10 +84,8 @@ function ModalRoot({
83
84
  className,
84
85
  ...rest
85
86
  }) {
86
- const panelRef = useRef(null);
87
87
  const close = useCallback(() => onClose(), [onClose]);
88
88
  useEscapeKey(close, open);
89
- useFocusTrap(panelRef, open);
90
89
  useEffect(() => {
91
90
  if (open) {
92
91
  const original = document.body.style.overflow;
@@ -101,6 +100,14 @@ function ModalRoot({
101
100
  enterClass: "fancy-slide-up",
102
101
  exitClass: "fancy-fade-out"
103
102
  });
103
+ const attachTrap = useDialogFocusTrap(open);
104
+ const attachPanel = useCallback(
105
+ (node) => {
106
+ animRef.current = node;
107
+ attachTrap(node);
108
+ },
109
+ [animRef, attachTrap]
110
+ );
104
111
  const ctx = useMemo(() => ({ open, close }), [open, close]);
105
112
  if (!mounted) return null;
106
113
  return /* @__PURE__ */ jsx(ModalContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4", children: [
@@ -115,10 +122,7 @@ function ModalRoot({
115
122
  /* @__PURE__ */ jsx(
116
123
  "div",
117
124
  {
118
- ref: (node) => {
119
- panelRef.current = node;
120
- animRef.current = node;
121
- },
125
+ ref: attachPanel,
122
126
  "data-react-fancy-modal": "",
123
127
  role: "dialog",
124
128
  "aria-modal": "true",
@@ -141,5 +145,5 @@ var Modal = Object.assign(ModalRoot, {
141
145
  });
142
146
 
143
147
  export { Modal, useModal };
144
- //# sourceMappingURL=chunk-GEQKNV7E.js.map
145
- //# sourceMappingURL=chunk-GEQKNV7E.js.map
148
+ //# sourceMappingURL=chunk-26GRLVCQ.js.map
149
+ //# sourceMappingURL=chunk-26GRLVCQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Modal/Modal.context.ts","../src/components/Modal/ModalHeader.tsx","../src/components/Modal/ModalBody.tsx","../src/components/Modal/ModalFooter.tsx","../src/components/Modal/Modal.tsx"],"names":["jsx","jsxs"],"mappings":";;;;;;;;;AAGO,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AAEjE,SAAS,QAAA,GAA8B;AAC5C,EAAA,MAAM,GAAA,GAAM,WAAW,YAAY,CAAA;AACnC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,GAAA;AACT;ACEO,SAAS,YAAY,EAAE,QAAA,EAAU,SAAA,EAAW,UAAA,GAAa,SAAQ,EAAqB;AAC3F,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,QAAA,EAAS;AAE3B,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,+BAAA,EAA8B,EAAA;AAAA,MAC9B,SAAA,EAAW,EAAA;AAAA,QACT,kLAAA;AAAA,QACA;AAAA,OACF;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,2IAAA,EAA6I,QAAA,EAAS,CAAA;AAAA,wBACrK,GAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,QAAA;AAAA,YACL,OAAA,EAAS,KAAA;AAAA,YACT,8BAAA,EAA6B,EAAA;AAAA,YAC7B,SAAA,EAAU,wSAAA;AAAA,YACV,YAAA,EAAY,UAAA;AAAA,YAEZ,QAAA,kBAAA,GAAA,CAAC,CAAA,EAAA,EAAE,IAAA,EAAM,EAAA,EAAI;AAAA;AAAA;AACf;AAAA;AAAA,GACF;AAEJ;AAEA,WAAA,CAAY,WAAA,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A,EAAY;AAAA;AAAA,KACd;AAAA,oBAEAA,GAAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA,EAAK,WAAA;AAAA,QACL,wBAAA,EAAuB,EAAA;AAAA,QACvB,IAAA,EAAK,QAAA;AAAA,QACL,YAAA,EAAW,MAAA;AAAA,QACV,GAAG,IAAA;AAAA,QACJ,SAAA,EAAW,EAAA;AAAA,UACT,2TAAA;AAAA,UACA,SAAS,IAAI,CAAA;AAAA,UACb,SAAA;AAAA,UACA;AAAA,SACF;AAAA,QAEC;AAAA;AAAA;AACH,GAAA,EACF,GACF,CAAA,EACF,CAAA;AAEJ;AAEO,IAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW;AAAA,EAC5C,MAAA,EAAQ,WAAA;AAAA,EACR,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ;AACV,CAAC","file":"chunk-26GRLVCQ.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { ModalContextValue } from \"./Modal.types\";\n\nexport const ModalContext = createContext<ModalContextValue | null>(null);\n\nexport function useModal(): ModalContextValue {\n const ctx = useContext(ModalContext);\n if (!ctx) {\n throw new Error(\"Modal compound components must be used within <Modal>\");\n }\n return ctx;\n}\n","import { X } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport { useModal } from \"./Modal.context\";\nimport type { ModalHeaderProps } from \"./Modal.types\";\n\n/**\n * The close button draws at 28px (20px icon + `p-1`) and HITS at 44px, the\n * WCAG 2.5.5 (AAA) target: a `::before` overhangs it by 8px on every side. A\n * pseudo-element is part of its button for hit-testing, so the look, the hover\n * fill and the header's height are all unchanged — the header's `py-4` already\n * has room for the overhang. A size option was the alternative; it would have\n * left every existing Modal at 28px unless someone opted in.\n */\nexport function ModalHeader({ children, className, closeLabel = \"Close\" }: ModalHeaderProps) {\n const { close } = useModal();\n\n return (\n <div\n data-react-fancy-modal-header=\"\"\n className={cn(\n \"flex items-center justify-between border-b border-[color:var(--fancy-border,var(--color-zinc-200))] px-6 py-4 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n <div className=\"text-lg font-semibold text-[color:var(--fancy-text,var(--color-zinc-900))] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))]\">{children}</div>\n <button\n type=\"button\"\n onClick={close}\n data-react-fancy-modal-close=\"\"\n className=\"relative rounded-lg p-1 text-zinc-400 before:absolute before:-inset-2 before:content-[''] transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300\"\n aria-label={closeLabel}\n >\n <X size={20} />\n </button>\n </div>\n );\n}\n\nModalHeader.displayName = \"ModalHeader\";\n","import { cn } from \"../../utils/cn\";\nimport type { ModalBodyProps } from \"./Modal.types\";\n\nexport function ModalBody({ children, className }: ModalBodyProps) {\n return (\n // `min-h-0` is load-bearing, not decoration. A flex child defaults to\n // `min-height: auto`, which refuses to shrink below its content — so\n // `flex-1` alone would push the panel through its own max-height and the\n // scrollbar would never appear. This is what permits the overflow that\n // `overflow-y-auto` then handles.\n <div data-react-fancy-modal-body=\"\" className={cn(\"min-h-0 flex-1 overflow-y-auto px-6 py-4 text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]\", className)}>\n {children}\n </div>\n );\n}\n\nModalBody.displayName = \"ModalBody\";\n","import { cn } from \"../../utils/cn\";\nimport type { ModalFooterProps } from \"./Modal.types\";\n\nexport function ModalFooter({ children, className }: ModalFooterProps) {\n return (\n <div\n data-react-fancy-modal-footer=\"\"\n className={cn(\n \"flex items-center justify-end gap-3 border-t border-[color:var(--fancy-border,var(--color-zinc-200))] px-6 py-4 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nModalFooter.displayName = \"ModalFooter\";\n","import { useCallback, useEffect, useMemo } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { ModalContext } from \"./Modal.context\";\nimport { ModalHeader } from \"./ModalHeader\";\nimport { ModalBody } from \"./ModalBody\";\nimport { ModalFooter } from \"./ModalFooter\";\nimport { useDialogFocusTrap } from \"../../hooks/use-dialog-focus-trap\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useAnimation } from \"../../hooks/use-animation\";\nimport type { ModalProps } from \"./Modal.types\";\n\n/**\n * Every size is capped against the VIEWPORT, not just the width.\n *\n * Only `full` used to carry a max-height. The other four were width-constrained\n * and vertically unbounded, so a modal with long content simply grew past the\n * bottom of the screen and the rest became unreachable — no scrollbar, because\n * there was no overflow to scroll: the box got taller instead.\n *\n * `ModalBody` already had `flex-1 overflow-y-auto` and the panel already had\n * `overflow-hidden`. The scrolling machinery was complete and inert, waiting on\n * the one constraint that makes it engage.\n *\n * `dvh` over `vh` deliberately: on mobile browsers `100vh` is the tallest the\n * viewport ever gets, ignoring the address bar, so a `vh`-capped modal still\n * runs under the chrome on exactly the devices with least room. `dvh` tracks\n * the visible height. The `vh` fallback is listed first for any engine that\n * does not know `dvh` yet — an unknown unit drops the declaration, so ordering\n * is what keeps the old behaviour rather than none.\n */\nconst VIEWPORT_CAP = \"max-h-[calc(100vh-2rem)] max-h-[calc(100dvh-2rem)]\";\n\nconst SIZE_MAP = {\n sm: `max-w-sm ${VIEWPORT_CAP}`,\n md: `max-w-lg ${VIEWPORT_CAP}`,\n lg: `max-w-2xl ${VIEWPORT_CAP}`,\n xl: `max-w-4xl ${VIEWPORT_CAP}`,\n full: `max-w-[calc(100vw-2rem)] ${VIEWPORT_CAP}`,\n} as const;\n\nfunction ModalRoot({\n children,\n open,\n onClose,\n size = \"md\",\n className,\n ...rest\n}: ModalProps) {\n const close = useCallback(() => onClose(), [onClose]);\n useEscapeKey(close, open);\n\n // Body scroll lock\n useEffect(() => {\n if (open) {\n const original = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n document.body.style.overflow = original;\n };\n }\n }, [open]);\n\n const { mounted, className: animClass, ref: animRef } = useAnimation({\n open,\n enterClass: \"fancy-slide-up\",\n exitClass: \"fancy-fade-out\",\n });\n\n // The panel mounts renders after `open` flips; see useDialogFocusTrap.\n const attachTrap = useDialogFocusTrap(open);\n const attachPanel = useCallback(\n (node: HTMLDivElement | null) => {\n (animRef as React.MutableRefObject<HTMLElement | null>).current = node;\n attachTrap(node);\n },\n [animRef, attachTrap],\n );\n\n const ctx = useMemo(() => ({ open, close }), [open, close]);\n\n if (!mounted) return null;\n\n return (\n <ModalContext.Provider value={ctx}>\n <Portal>\n <div className=\"fixed inset-0 z-50 flex items-center justify-center p-4\">\n {/* Backdrop */}\n <div\n className=\"absolute inset-0 bg-black/50 backdrop-blur-sm\"\n onClick={close}\n aria-hidden=\"true\"\n />\n {/* Panel */}\n <div\n ref={attachPanel}\n data-react-fancy-modal=\"\"\n role=\"dialog\"\n aria-modal=\"true\"\n {...rest}\n className={cn(\n \"relative flex w-full flex-col overflow-hidden rounded-2xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] shadow-xl dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n SIZE_MAP[size],\n animClass,\n className,\n )}\n >\n {children}\n </div>\n </div>\n </Portal>\n </ModalContext.Provider>\n );\n}\n\nexport const Modal = Object.assign(ModalRoot, {\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n});\n"]}
@@ -26,6 +26,7 @@ function FileUploadDropzone({
26
26
  const inputId = useId();
27
27
  const custom = children !== void 0 && children !== null;
28
28
  const inputLabel = browseLabel ?? (custom ? DEFAULT_BROWSE_LABEL : DEFAULT_COPY);
29
+ const hintColour = dragOver ? "text-[color:var(--fancy-text-subtle,var(--color-zinc-600))] dark:text-[color:var(--fancy-text-subtle-dark,var(--color-zinc-400))]" : "text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]";
29
30
  const handleDrop = useCallback(
30
31
  (e) => {
31
32
  e.preventDefault();
@@ -111,8 +112,8 @@ function FileUploadDropzone({
111
112
  disabled,
112
113
  className: "flex cursor-pointer flex-col items-center rounded-md outline-none disabled:cursor-not-allowed",
113
114
  children: [
114
- /* @__PURE__ */ jsx(Upload, { size: 32, strokeWidth: 1.5, "aria-hidden": "true", className: "mb-2 text-zinc-400" }),
115
- /* @__PURE__ */ jsx("span", { className: "text-sm text-zinc-500", children: DEFAULT_COPY })
115
+ /* @__PURE__ */ jsx(Upload, { size: 32, strokeWidth: 1.5, "aria-hidden": "true", className: cn("mb-2", hintColour) }),
116
+ /* @__PURE__ */ jsx("span", { className: cn("text-sm", hintColour), children: DEFAULT_COPY })
116
117
  ]
117
118
  }
118
119
  )
@@ -130,6 +131,9 @@ function getExtension(name) {
130
131
  const parts = name.split(".");
131
132
  return parts.length > 1 ? parts.pop().toUpperCase() : "";
132
133
  }
134
+ var MUTED = "text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]";
135
+ var FAINT = "text-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))]";
136
+ var REMOVE = `${MUTED} hover:text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:hover:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]`;
133
137
  function ThumbnailItem({ file, index, onRemove }) {
134
138
  const isImage = file.type.startsWith("image/");
135
139
  const objectUrl = useMemo(() => isImage ? URL.createObjectURL(file) : null, [file, isImage]);
@@ -141,21 +145,21 @@ function ThumbnailItem({ file, index, onRemove }) {
141
145
  return /* @__PURE__ */ jsxs("div", { className: "group relative flex w-20 flex-col items-center gap-1", children: [
142
146
  /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800", children: [
143
147
  isImage && objectUrl ? /* @__PURE__ */ jsx("img", { src: objectUrl, alt: file.name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center gap-1", children: [
144
- /* @__PURE__ */ jsx(File, { size: 20, className: "text-zinc-400" }),
145
- /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-zinc-500", children: getExtension(file.name) })
148
+ /* @__PURE__ */ jsx(File, { size: 20, "aria-hidden": "true", className: FAINT }),
149
+ /* @__PURE__ */ jsx("span", { className: cn("text-[10px] font-medium", MUTED), children: getExtension(file.name) })
146
150
  ] }),
147
151
  /* @__PURE__ */ jsx(
148
152
  "button",
149
153
  {
150
154
  type: "button",
151
155
  onClick: () => onRemove(index),
152
- className: "absolute top-1 end-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity hover:bg-black/80 group-hover:opacity-100",
156
+ className: "absolute top-1 end-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity hover:bg-black/80 group-hover:opacity-100 focus-visible:opacity-100",
153
157
  "aria-label": `Remove ${file.name}`,
154
- children: /* @__PURE__ */ jsx(X, { size: 10 })
158
+ children: /* @__PURE__ */ jsx(X, { size: 10, "aria-hidden": "true" })
155
159
  }
156
160
  )
157
161
  ] }),
158
- /* @__PURE__ */ jsx("span", { className: "w-full truncate text-center text-xs text-zinc-500", children: file.name })
162
+ /* @__PURE__ */ jsx("span", { className: cn("w-full truncate text-center text-xs", MUTED), children: file.name })
159
163
  ] });
160
164
  }
161
165
  function FileUploadList({ thumbnail, className }) {
@@ -169,17 +173,17 @@ function FileUploadList({ thumbnail, className }) {
169
173
  {
170
174
  className: "flex items-center gap-3 rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] px-3 py-2 text-sm dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]",
171
175
  children: [
172
- /* @__PURE__ */ jsx(File, { size: 16, className: "shrink-0 text-zinc-400" }),
176
+ /* @__PURE__ */ jsx(File, { size: 16, "aria-hidden": "true", className: cn("shrink-0", FAINT) }),
173
177
  /* @__PURE__ */ jsx("span", { className: "flex-1 truncate", children: file.name }),
174
- /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-zinc-400", children: formatSize(file.size) }),
178
+ /* @__PURE__ */ jsx("span", { className: cn("shrink-0 text-xs", MUTED), children: formatSize(file.size) }),
175
179
  /* @__PURE__ */ jsx(
176
180
  "button",
177
181
  {
178
182
  type: "button",
179
183
  onClick: () => removeFile(i),
180
- className: "shrink-0 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",
184
+ className: cn("shrink-0", REMOVE),
181
185
  "aria-label": `Remove ${file.name}`,
182
- children: /* @__PURE__ */ jsx(X, { size: 14 })
186
+ children: /* @__PURE__ */ jsx(X, { size: 14, "aria-hidden": "true" })
183
187
  }
184
188
  )
185
189
  ]
@@ -273,5 +277,5 @@ var FileUpload = Object.assign(FileUploadRoot, {
273
277
  });
274
278
 
275
279
  export { FileUpload, useFileUpload };
276
- //# sourceMappingURL=chunk-ZHTK4IPQ.js.map
277
- //# sourceMappingURL=chunk-ZHTK4IPQ.js.map
280
+ //# sourceMappingURL=chunk-4676NOI6.js.map
281
+ //# sourceMappingURL=chunk-4676NOI6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/FileUpload/FileUpload.context.ts","../src/components/FileUpload/FileUploadDropzone.tsx","../src/components/FileUpload/FileUploadList.tsx","../src/components/FileUpload/matchesAccept.ts","../src/components/FileUpload/FileUpload.tsx"],"names":["jsxs","jsx","useState","useCallback","useMemo"],"mappings":";;;;;AAGO,IAAM,iBAAA,GACX,cAA6C,IAAI,CAAA;AAE5C,SAAS,aA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AAkB;AACjB,MAAA,MAAM,UAAU,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA,EAAG,CAAA,KAAM,MAAM,KAAK,CAAA;AAClD,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,gBAAA,CAAiB,OAAO,CAAA;AACjD,MAAA,QAAA,GAAW,OAAO,CAAA;AAAA,IACpB,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,QAAA,EAAU,KAAK;AAAA,GACzB;AAEA,EAAA,MAAM,GAAA,GAAMC,OAAAA;AAAA,IACV,OAAO,EAAE,KAAA,EAAO,UAAU,UAAA,EAAY,QAAA,EAAU,QAAQ,QAAA,EAAS,CAAA;AAAA,IACjE,CAAC,KAAA,EAAO,QAAA,EAAU,UAAA,EAAY,QAAA,EAAU,QAAQ,QAAQ;AAAA,GAC1D;AAEA,EAAA,uBACEH,GAAAA,CAAC,iBAAA,CAAkB,QAAA,EAAlB,EAA2B,OAAO,GAAA,EACjC,QAAA,kBAAAA,GAAAA,CAAC,KAAA,EAAA,EAAI,gCAA6B,EAAA,EAAG,SAAA,EAAW,GAAG,SAAS,CAAA,EAAI,UAAS,CAAA,EAC3E,CAAA;AAEJ;AAEO,IAAM,UAAA,GAAa,MAAA,CAAO,MAAA,CAAO,cAAA,EAAgB;AAAA,EACtD,QAAA,EAAU,kBAAA;AAAA,EACV,IAAA,EAAM;AACR,CAAC","file":"chunk-4676NOI6.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { FileUploadContextValue } from \"./FileUpload.types\";\n\nexport const FileUploadContext =\n createContext<FileUploadContextValue | null>(null);\n\nexport function useFileUpload(): FileUploadContextValue {\n const ctx = useContext(FileUploadContext);\n if (!ctx) {\n throw new Error(\n \"FileUpload compound components must be used within <FileUpload>\",\n );\n }\n return ctx;\n}\n","import { useCallback, useId, useRef, useState } from \"react\";\nimport { Upload } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport { useFileUpload } from \"./FileUpload.context\";\nimport type { FileUploadDropzoneProps } from \"./FileUpload.types\";\n\n/** Accessible name of the browse trigger when the zone has custom children. */\nconst DEFAULT_BROWSE_LABEL = \"Browse files\";\n\n/** The default zone copy; it doubles as the trigger's accessible name. */\nconst DEFAULT_COPY = \"Drop files here or click to browse\";\n\n/*\n * Keyboard access (after 5.59.0). Until then the zone was a clickable div around a\n * display:none input: no tab stop, no role, no key handler, so a keyboard or\n * switch user could not open the picker at all.\n *\n * The trigger is a REAL <button type=\"button\">, not a div with role=\"button\":\n * focus, Enter and Space (Space on keyup, cancelled by moving off) then come\n * from the platform instead of a key handler that has to get those right.\n *\n * - Default content: the button wraps the icon and the copy, so the visible\n * text IS its accessible name and the look is unchanged.\n * - Custom children: they may contain their own interactive content, which a\n * button must not wrap, so the button is visually hidden beside them and the\n * ZONE draws the focus ring (has-focus-visible) — the focus indicator is\n * never invisible.\n *\n * A click anywhere on the zone still opens the picker, as before; a click on\n * the button bubbles to the zone and is handled there once.\n */\nexport function FileUploadDropzone({\n children,\n className,\n browseLabel,\n}: FileUploadDropzoneProps) {\n const { addFiles, disabled, accept, multiple } = useFileUpload();\n const [dragOver, setDragOver] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const custom = children !== undefined && children !== null;\n const inputLabel = browseLabel ?? (custom ? DEFAULT_BROWSE_LABEL : DEFAULT_COPY);\n\n /*\n * The hint (and the icon above it) read the host's text tokens. They were\n * bare zinc until 6.11.1, so an app that mapped `--fancy-text-muted` themed\n * every component but this one: on a #0A2347 surface the hint was 3.23:1.\n *\n * Drag-over steps up to `subtle`: the drag fill (blue-50) is darker than the\n * page, and muted on it is 4.44:1, under AA. Subtle is 7.09:1 there.\n */\n const hintColour = dragOver\n ? \"text-[color:var(--fancy-text-subtle,var(--color-zinc-600))] dark:text-[color:var(--fancy-text-subtle-dark,var(--color-zinc-400))]\"\n : \"text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\";\n\n const handleDrop = useCallback(\n (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n if (disabled) return;\n addFiles(e.dataTransfer.files);\n },\n [addFiles, disabled],\n );\n\n const handleDragOver = useCallback((e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(true);\n }, []);\n\n const handleDragLeave = useCallback(() => setDragOver(false), []);\n\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n if (disabled) return;\n // The input's own click bubbles back up here; re-entering would ask for a\n // second picker.\n if (e.target === inputRef.current) return;\n inputRef.current?.click();\n },\n [disabled],\n );\n\n return (\n <div\n data-react-fancy-file-upload-dropzone=\"\"\n data-drag-over={dragOver ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n aria-disabled={disabled || undefined}\n onDrop={handleDrop}\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onClick={handleClick}\n className={cn(\n \"flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed p-8 text-center transition-[color,background-color,border-color,box-shadow]\",\n // Full opacity on purpose: a translucent 2px ring over a dashed border\n // falls under WCAG 2.2's 3:1 for a focus indicator. The offset gap is\n // painted with the surface token so it matches the page in dark mode.\n \"has-focus-visible:ring-2 has-focus-visible:ring-offset-2 has-focus-visible:ring-[color:var(--fancy-focus,var(--color-blue-500))] has-focus-visible:ring-offset-[color:var(--fancy-surface,var(--color-white))] dark:has-focus-visible:ring-[color:var(--fancy-focus-dark,var(--color-blue-400))] dark:has-focus-visible:ring-offset-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n dragOver\n ? \"border-blue-400 bg-blue-50 dark:border-blue-500 dark:bg-blue-950\"\n : \"border-[color:var(--fancy-border-strong,var(--color-zinc-300))] hover:border-zinc-400 dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-700))] dark:hover:border-zinc-500\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n >\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n className=\"hidden\"\n tabIndex={-1}\n aria-label={inputLabel}\n onChange={(e) => {\n if (e.target.files) addFiles(e.target.files);\n\n // Reset, or choosing the SAME file again fires no `change` event at\n // all and the gesture is simply dead — \"remove it, then re-add it\"\n // and \"retry the import that just failed\" both stop working. The\n // component never sees those files to reject them; it is not asked.\n e.target.value = \"\";\n }}\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n />\n {custom ? (\n <>\n {children}\n <button\n type=\"button\"\n data-react-fancy-file-upload-browse=\"\"\n aria-controls={inputId}\n disabled={disabled}\n className=\"sr-only\"\n >\n {browseLabel ?? DEFAULT_BROWSE_LABEL}\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n data-react-fancy-file-upload-browse=\"\"\n aria-controls={inputId}\n aria-label={browseLabel}\n disabled={disabled}\n className=\"flex cursor-pointer flex-col items-center rounded-md outline-none disabled:cursor-not-allowed\"\n >\n <Upload size={32} strokeWidth={1.5} aria-hidden=\"true\" className={cn(\"mb-2\", hintColour)} />\n <span className={cn(\"text-sm\", hintColour)}>{DEFAULT_COPY}</span>\n </button>\n )}\n </div>\n );\n}\n\nFileUploadDropzone.displayName = \"FileUploadDropzone\";\n","import { useEffect, useMemo } from \"react\";\nimport { File, X } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport { useFileUpload } from \"./FileUpload.context\";\nimport type { FileUploadListProps } from \"./FileUpload.types\";\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nfunction getExtension(name: string): string {\n const parts = name.split(\".\");\n return parts.length > 1 ? parts.pop()!.toUpperCase() : \"\";\n}\n\n/*\n * Text colours read the host's `--fancy-text-*` tokens (bare zinc until\n * 6.11.1). Fallbacks are the kit-wide defaults, so an app that maps nothing\n * sees the same greys every other component uses.\n */\nconst MUTED =\n \"text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\";\n/** Decorative file glyphs (aria-hidden): themed, but owe no text contrast. */\nconst FAINT =\n \"text-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))]\";\n/**\n * The list's remove control is an icon with no text, so its glyph owes 3:1\n * (WCAG 1.4.11). Bare zinc-400 was 2.62:1 on white; muted is 4.83:1.\n */\nconst REMOVE =\n `${MUTED} hover:text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:hover:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]`;\n\nfunction ThumbnailItem({ file, index, onRemove }: { file: File; index: number; onRemove: (i: number) => void }) {\n const isImage = file.type.startsWith(\"image/\");\n const objectUrl = useMemo(() => (isImage ? URL.createObjectURL(file) : null), [file, isImage]);\n\n useEffect(() => {\n return () => {\n if (objectUrl) URL.revokeObjectURL(objectUrl);\n };\n }, [objectUrl]);\n\n return (\n <div className=\"group relative flex w-20 flex-col items-center gap-1\">\n <div className=\"relative h-20 w-20 overflow-hidden rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800\">\n {isImage && objectUrl ? (\n <img src={objectUrl} alt={file.name} className=\"h-full w-full object-cover\" />\n ) : (\n <div className=\"flex h-full w-full flex-col items-center justify-center gap-1\">\n <File size={20} aria-hidden=\"true\" className={FAINT} />\n <span className={cn(\"text-[10px] font-medium\", MUTED)}>{getExtension(file.name)}</span>\n </div>\n )}\n <button\n type=\"button\"\n onClick={() => onRemove(index)}\n // Hidden until the tile is hovered, so keyboard focus must reveal it\n // too, or a keyboard user tabs onto an invisible control.\n className=\"absolute top-1 end-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity hover:bg-black/80 group-hover:opacity-100 focus-visible:opacity-100\"\n aria-label={`Remove ${file.name}`}\n >\n <X size={10} aria-hidden=\"true\" />\n </button>\n </div>\n <span className={cn(\"w-full truncate text-center text-xs\", MUTED)}>{file.name}</span>\n </div>\n );\n}\n\nexport function FileUploadList({ thumbnail, className }: FileUploadListProps) {\n const { files, removeFile } = useFileUpload();\n\n if (files.length === 0) return null;\n\n if (thumbnail) {\n return (\n <div data-react-fancy-file-upload-list=\"\" className={cn(\"mt-3 flex flex-wrap gap-3\", className)}>\n {files.map((file, i) => (\n <ThumbnailItem key={`${file.name}-${i}`} file={file} index={i} onRemove={removeFile} />\n ))}\n </div>\n );\n }\n\n return (\n <ul data-react-fancy-file-upload-list=\"\" className={cn(\"mt-3 space-y-2\", className)}>\n {files.map((file, i) => (\n <li\n key={`${file.name}-${i}`}\n className=\"flex items-center gap-3 rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] px-3 py-2 text-sm dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n >\n <File size={16} aria-hidden=\"true\" className={cn(\"shrink-0\", FAINT)} />\n <span className=\"flex-1 truncate\">{file.name}</span>\n <span className={cn(\"shrink-0 text-xs\", MUTED)}>\n {formatSize(file.size)}\n </span>\n <button\n type=\"button\"\n onClick={() => removeFile(i)}\n className={cn(\"shrink-0\", REMOVE)}\n aria-label={`Remove ${file.name}`}\n >\n <X size={14} aria-hidden=\"true\" />\n </button>\n </li>\n ))}\n </ul>\n );\n}\n\nFileUploadList.displayName = \"FileUploadList\";\n","/**\n * Does a file satisfy an `accept` string?\n *\n * The browser enforces `accept` in the FILE PICKER only. A drag-and-drop never\n * opens a picker, so on the drop path this is the only thing standing between an\n * image-only dropzone and a dropped executable. Forwarding the attribute to the\n * hidden input is half the job; this is the other half.\n *\n * Follows the HTML `accept` grammar: a comma-separated list of extensions\n * (`.csv`), exact MIME types (`text/plain`) and type wildcards (`image/*`).\n * Matching is case-insensitive, because a drop reports whatever the OS says and\n * `TEXT/PLAIN` is a real thing to receive.\n *\n * A dropped file often carries an EMPTY `type` — the OS may not know it and\n * `File.type` is a hint, never a guarantee. That is why extension rules are\n * checked against the name and not the type: an `accept=\".csv\"` zone has to work\n * for a .csv whose type is `\"\"`, which is the common case rather than the edge.\n */\nexport function matchesAccept(file: File, accept: string): boolean {\n const rules = accept\n .split(\",\")\n .map((rule) => rule.trim().toLowerCase())\n .filter(Boolean);\n\n // An accept string that lists nothing constrains nothing. Failing closed here\n // would turn `accept=\"\"` into a dropzone that silently swallows every file.\n if (rules.length === 0) return true;\n\n const type = file.type.toLowerCase();\n const name = file.name.toLowerCase();\n\n return rules.some((rule) => {\n if (rule.startsWith(\".\")) return name.endsWith(rule);\n if (rule.endsWith(\"/*\")) return type.startsWith(rule.slice(0, -1));\n return type === rule;\n });\n}\n","import { useCallback, useMemo, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FileUploadContext } from \"./FileUpload.context\";\nimport { FileUploadDropzone } from \"./FileUploadDropzone\";\nimport { FileUploadList } from \"./FileUploadList\";\nimport { matchesAccept } from \"./matchesAccept\";\nimport type {\n FileRejection,\n FileRejectionReason,\n FileUploadProps,\n} from \"./FileUpload.types\";\n\nfunction rejection(file: File, reason: FileRejectionReason): FileRejection {\n return { name: file.name, size: file.size, type: file.type, reason };\n}\n\nfunction FileUploadRoot({\n children,\n value,\n onChange,\n onReject,\n accept,\n multiple = true,\n maxFiles,\n maxSize,\n disabled = false,\n className,\n}: FileUploadProps) {\n const [internalFiles, setInternalFiles] = useState<File[]>([]);\n const files = value ?? internalFiles;\n\n const addFiles = useCallback(\n (newFiles: FileList | File[]) => {\n let toAdd = Array.from(newFiles);\n const rejections: FileRejection[] = [];\n\n // Each file is reported once, under the first rule it failed.\n const keepOnly = (\n passes: (f: File) => boolean,\n reason: FileRejectionReason,\n ) => {\n toAdd = toAdd.filter((f) => {\n if (passes(f)) return true;\n rejections.push(rejection(f, reason));\n return false;\n });\n };\n\n // `accept` is enforced HERE, not only on the input: the input's attribute\n // governs the picker, and a drop never opens one.\n if (accept) {\n keepOnly((f) => matchesAccept(f, accept), \"accept\");\n }\n\n if (maxSize) {\n keepOnly((f) => f.size <= maxSize, \"maxSize\");\n }\n\n /*\n * `multiple={false}` REPLACES; `maxFiles` refuses the overflow.\n *\n * These used to be the same rule — a cap of one, first-wins — on the\n * reasoning that the two props must not disagree about what a single-file\n * upload means. But they are different statements:\n *\n * - `maxFiles={n}` is a QUOTA. Dropping five files into a three-file\n * field should keep three, not the last three.\n * - `multiple={false}` is a FIELD SHAPE: this input holds one file. Its\n * analogue is a radio group, where choosing again MOVES the selection.\n *\n * Under the old rule a single-file field could never change its mind: the\n * second choice computed `[old, new].slice(0, 1)` and discarded the new\n * file in silence. The YouGene estate worked around it by remounting the\n * component with a `key`, which is the shape of a bug rather than a\n * preference.\n */\n if (multiple === false) {\n /*\n * The FIRST of the incoming batch, not the last.\n *\n * Two separate questions hide here, and only one of them was the bug:\n *\n * - ACROSS gestures — choose a file, then choose another. The second\n * must win, or the field cannot change its mind. That is the fix.\n * - WITHIN one gesture — drop two files at once onto a single-file\n * field. Which one wins is arbitrary, and taking the first is what\n * has always shipped; there is no replacement intent in a single\n * ambiguous drop.\n *\n * Taking `slice(-1)` would have answered both with \"the last\", quietly\n * changing the second. The existing drop test caught it.\n */\n const replacement = toAdd.slice(0, 1);\n // Nothing survived the accept/size filters — leave the field alone\n // rather than clearing a file the user never asked to remove.\n const next = replacement.length > 0 ? replacement : files;\n\n // The file being replaced was not refused; the rest of this batch was,\n // by a field that holds one.\n for (const f of toAdd.slice(1)) rejections.push(rejection(f, \"maxFiles\"));\n\n if (value === undefined) setInternalFiles(next);\n onChange?.(next);\n if (rejections.length > 0) onReject?.(rejections);\n\n return;\n }\n\n const updated = [...files, ...toAdd];\n const limited = maxFiles ? updated.slice(0, maxFiles) : updated;\n\n for (const f of updated.slice(limited.length)) rejections.push(rejection(f, \"maxFiles\"));\n\n if (value === undefined) setInternalFiles(limited);\n onChange?.(limited);\n if (rejections.length > 0) onReject?.(rejections);\n },\n [accept, files, maxFiles, maxSize, multiple, onChange, onReject, value],\n );\n\n const removeFile = useCallback(\n (index: number) => {\n const updated = files.filter((_, i) => i !== index);\n if (value === undefined) setInternalFiles(updated);\n onChange?.(updated);\n },\n [files, onChange, value],\n );\n\n const ctx = useMemo(\n () => ({ files, addFiles, removeFile, disabled, accept, multiple }),\n [files, addFiles, removeFile, disabled, accept, multiple],\n );\n\n return (\n <FileUploadContext.Provider value={ctx}>\n <div data-react-fancy-file-upload=\"\" className={cn(className)}>{children}</div>\n </FileUploadContext.Provider>\n );\n}\n\nexport const FileUpload = Object.assign(FileUploadRoot, {\n Dropzone: FileUploadDropzone,\n List: FileUploadList,\n});\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkTXTRTTG7_cjs = require('./chunk-TXTRTTG7.cjs');
3
+ var chunkRE3PMG47_cjs = require('./chunk-RE3PMG47.cjs');
4
4
  var chunkFQZE5N2N_cjs = require('./chunk-FQZE5N2N.cjs');
5
5
  var chunkTI7D4QDM_cjs = require('./chunk-TI7D4QDM.cjs');
6
6
  var chunkOUYC6EIL_cjs = require('./chunk-OUYC6EIL.cjs');
@@ -17,7 +17,7 @@ function useModal() {
17
17
  }
18
18
  return ctx;
19
19
  }
20
- function ModalHeader({ children, className }) {
20
+ function ModalHeader({ children, className, closeLabel = "Close" }) {
21
21
  const { close } = useModal();
22
22
  return /* @__PURE__ */ jsxRuntime.jsxs(
23
23
  "div",
@@ -34,8 +34,9 @@ function ModalHeader({ children, className }) {
34
34
  {
35
35
  type: "button",
36
36
  onClick: close,
37
- className: "rounded-lg p-1 text-zinc-400 transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300",
38
- "aria-label": "Close",
37
+ "data-react-fancy-modal-close": "",
38
+ className: "relative rounded-lg p-1 text-zinc-400 before:absolute before:-inset-2 before:content-[''] transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300",
39
+ "aria-label": closeLabel,
39
40
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 20 })
40
41
  }
41
42
  )
@@ -85,10 +86,8 @@ function ModalRoot({
85
86
  className,
86
87
  ...rest
87
88
  }) {
88
- const panelRef = react.useRef(null);
89
89
  const close = react.useCallback(() => onClose(), [onClose]);
90
90
  chunkOUYC6EIL_cjs.useEscapeKey(close, open);
91
- chunkTXTRTTG7_cjs.useFocusTrap(panelRef, open);
92
91
  react.useEffect(() => {
93
92
  if (open) {
94
93
  const original = document.body.style.overflow;
@@ -103,6 +102,14 @@ function ModalRoot({
103
102
  enterClass: "fancy-slide-up",
104
103
  exitClass: "fancy-fade-out"
105
104
  });
105
+ const attachTrap = chunkRE3PMG47_cjs.useDialogFocusTrap(open);
106
+ const attachPanel = react.useCallback(
107
+ (node) => {
108
+ animRef.current = node;
109
+ attachTrap(node);
110
+ },
111
+ [animRef, attachTrap]
112
+ );
106
113
  const ctx = react.useMemo(() => ({ open, close }), [open, close]);
107
114
  if (!mounted) return null;
108
115
  return /* @__PURE__ */ jsxRuntime.jsx(ModalContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxRuntime.jsx(chunkTI7D4QDM_cjs.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4", children: [
@@ -117,10 +124,7 @@ function ModalRoot({
117
124
  /* @__PURE__ */ jsxRuntime.jsx(
118
125
  "div",
119
126
  {
120
- ref: (node) => {
121
- panelRef.current = node;
122
- animRef.current = node;
123
- },
127
+ ref: attachPanel,
124
128
  "data-react-fancy-modal": "",
125
129
  role: "dialog",
126
130
  "aria-modal": "true",
@@ -144,5 +148,5 @@ var Modal = Object.assign(ModalRoot, {
144
148
 
145
149
  exports.Modal = Modal;
146
150
  exports.useModal = useModal;
147
- //# sourceMappingURL=chunk-HANQYZW2.cjs.map
148
- //# sourceMappingURL=chunk-HANQYZW2.cjs.map
151
+ //# sourceMappingURL=chunk-GB2EGMVQ.cjs.map
152
+ //# sourceMappingURL=chunk-GB2EGMVQ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Modal/Modal.context.ts","../src/components/Modal/ModalHeader.tsx","../src/components/Modal/ModalBody.tsx","../src/components/Modal/ModalFooter.tsx","../src/components/Modal/Modal.tsx"],"names":["createContext","useContext","jsxs","cn","jsx","X","useCallback","useEscapeKey","useEffect","useAnimation","useDialogFocusTrap","useMemo","Portal"],"mappings":";;;;;;;;;;;AAGO,IAAM,YAAA,GAAeA,oBAAwC,IAAI,CAAA;AAEjE,SAAS,QAAA,GAA8B;AAC5C,EAAA,MAAM,GAAA,GAAMC,iBAAW,YAAY,CAAA;AACnC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,GAAA;AACT;ACEO,SAAS,YAAY,EAAE,QAAA,EAAU,SAAA,EAAW,UAAA,GAAa,SAAQ,EAAqB;AAC3F,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,QAAA,EAAS;AAE3B,EAAA,uBACEC,eAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,+BAAA,EAA8B,EAAA;AAAA,MAC9B,SAAA,EAAWC,oBAAA;AAAA,QACT,kLAAA;AAAA,QACA;AAAA,OACF;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAAC,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,2IAAA,EAA6I,QAAA,EAAS,CAAA;AAAA,wBACrKA,cAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,QAAA;AAAA,YACL,OAAA,EAAS,KAAA;AAAA,YACT,8BAAA,EAA6B,EAAA;AAAA,YAC7B,SAAA,EAAU,wSAAA;AAAA,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,eAAAA,CAAC,KAAA,EAAA,EAAI,WAAU,yDAAA,EAEb,QAAA,EAAA;AAAA,oBAAAE,cAAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAU,+CAAA;AAAA,QACV,OAAA,EAAS,KAAA;AAAA,QACT,aAAA,EAAY;AAAA;AAAA,KACd;AAAA,oBAEAA,cAAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA,EAAK,WAAA;AAAA,QACL,wBAAA,EAAuB,EAAA;AAAA,QACvB,IAAA,EAAK,QAAA;AAAA,QACL,YAAA,EAAW,MAAA;AAAA,QACV,GAAG,IAAA;AAAA,QACJ,SAAA,EAAWD,oBAAA;AAAA,UACT,2TAAA;AAAA,UACA,SAAS,IAAI,CAAA;AAAA,UACb,SAAA;AAAA,UACA;AAAA,SACF;AAAA,QAEC;AAAA;AAAA;AACH,GAAA,EACF,GACF,CAAA,EACF,CAAA;AAEJ;AAEO,IAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW;AAAA,EAC5C,MAAA,EAAQ,WAAA;AAAA,EACR,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ;AACV,CAAC","file":"chunk-GB2EGMVQ.cjs","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { ModalContextValue } from \"./Modal.types\";\n\nexport const ModalContext = createContext<ModalContextValue | null>(null);\n\nexport function useModal(): ModalContextValue {\n const ctx = useContext(ModalContext);\n if (!ctx) {\n throw new Error(\"Modal compound components must be used within <Modal>\");\n }\n return ctx;\n}\n","import { X } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport { useModal } from \"./Modal.context\";\nimport type { ModalHeaderProps } from \"./Modal.types\";\n\n/**\n * The close button draws at 28px (20px icon + `p-1`) and HITS at 44px, the\n * WCAG 2.5.5 (AAA) target: a `::before` overhangs it by 8px on every side. A\n * pseudo-element is part of its button for hit-testing, so the look, the hover\n * fill and the header's height are all unchanged — the header's `py-4` already\n * has room for the overhang. A size option was the alternative; it would have\n * left every existing Modal at 28px unless someone opted in.\n */\nexport function ModalHeader({ children, className, closeLabel = \"Close\" }: ModalHeaderProps) {\n const { close } = useModal();\n\n return (\n <div\n data-react-fancy-modal-header=\"\"\n className={cn(\n \"flex items-center justify-between border-b border-[color:var(--fancy-border,var(--color-zinc-200))] px-6 py-4 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n <div className=\"text-lg font-semibold text-[color:var(--fancy-text,var(--color-zinc-900))] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))]\">{children}</div>\n <button\n type=\"button\"\n onClick={close}\n data-react-fancy-modal-close=\"\"\n className=\"relative rounded-lg p-1 text-zinc-400 before:absolute before:-inset-2 before:content-[''] transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] hover:text-zinc-600 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))] dark:hover:text-zinc-300\"\n aria-label={closeLabel}\n >\n <X size={20} />\n </button>\n </div>\n );\n}\n\nModalHeader.displayName = \"ModalHeader\";\n","import { cn } from \"../../utils/cn\";\nimport type { ModalBodyProps } from \"./Modal.types\";\n\nexport function ModalBody({ children, className }: ModalBodyProps) {\n return (\n // `min-h-0` is load-bearing, not decoration. A flex child defaults to\n // `min-height: auto`, which refuses to shrink below its content — so\n // `flex-1` alone would push the panel through its own max-height and the\n // scrollbar would never appear. This is what permits the overflow that\n // `overflow-y-auto` then handles.\n <div data-react-fancy-modal-body=\"\" className={cn(\"min-h-0 flex-1 overflow-y-auto px-6 py-4 text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]\", className)}>\n {children}\n </div>\n );\n}\n\nModalBody.displayName = \"ModalBody\";\n","import { cn } from \"../../utils/cn\";\nimport type { ModalFooterProps } from \"./Modal.types\";\n\nexport function ModalFooter({ children, className }: ModalFooterProps) {\n return (\n <div\n data-react-fancy-modal-footer=\"\"\n className={cn(\n \"flex items-center justify-end gap-3 border-t border-[color:var(--fancy-border,var(--color-zinc-200))] px-6 py-4 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nModalFooter.displayName = \"ModalFooter\";\n","import { useCallback, useEffect, useMemo } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { ModalContext } from \"./Modal.context\";\nimport { ModalHeader } from \"./ModalHeader\";\nimport { ModalBody } from \"./ModalBody\";\nimport { ModalFooter } from \"./ModalFooter\";\nimport { useDialogFocusTrap } from \"../../hooks/use-dialog-focus-trap\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useAnimation } from \"../../hooks/use-animation\";\nimport type { ModalProps } from \"./Modal.types\";\n\n/**\n * Every size is capped against the VIEWPORT, not just the width.\n *\n * Only `full` used to carry a max-height. The other four were width-constrained\n * and vertically unbounded, so a modal with long content simply grew past the\n * bottom of the screen and the rest became unreachable — no scrollbar, because\n * there was no overflow to scroll: the box got taller instead.\n *\n * `ModalBody` already had `flex-1 overflow-y-auto` and the panel already had\n * `overflow-hidden`. The scrolling machinery was complete and inert, waiting on\n * the one constraint that makes it engage.\n *\n * `dvh` over `vh` deliberately: on mobile browsers `100vh` is the tallest the\n * viewport ever gets, ignoring the address bar, so a `vh`-capped modal still\n * runs under the chrome on exactly the devices with least room. `dvh` tracks\n * the visible height. The `vh` fallback is listed first for any engine that\n * does not know `dvh` yet — an unknown unit drops the declaration, so ordering\n * is what keeps the old behaviour rather than none.\n */\nconst VIEWPORT_CAP = \"max-h-[calc(100vh-2rem)] max-h-[calc(100dvh-2rem)]\";\n\nconst SIZE_MAP = {\n sm: `max-w-sm ${VIEWPORT_CAP}`,\n md: `max-w-lg ${VIEWPORT_CAP}`,\n lg: `max-w-2xl ${VIEWPORT_CAP}`,\n xl: `max-w-4xl ${VIEWPORT_CAP}`,\n full: `max-w-[calc(100vw-2rem)] ${VIEWPORT_CAP}`,\n} as const;\n\nfunction ModalRoot({\n children,\n open,\n onClose,\n size = \"md\",\n className,\n ...rest\n}: ModalProps) {\n const close = useCallback(() => onClose(), [onClose]);\n useEscapeKey(close, open);\n\n // Body scroll lock\n useEffect(() => {\n if (open) {\n const original = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n document.body.style.overflow = original;\n };\n }\n }, [open]);\n\n const { mounted, className: animClass, ref: animRef } = useAnimation({\n open,\n enterClass: \"fancy-slide-up\",\n exitClass: \"fancy-fade-out\",\n });\n\n // The panel mounts renders after `open` flips; see useDialogFocusTrap.\n const attachTrap = useDialogFocusTrap(open);\n const attachPanel = useCallback(\n (node: HTMLDivElement | null) => {\n (animRef as React.MutableRefObject<HTMLElement | null>).current = node;\n attachTrap(node);\n },\n [animRef, attachTrap],\n );\n\n const ctx = useMemo(() => ({ open, close }), [open, close]);\n\n if (!mounted) return null;\n\n return (\n <ModalContext.Provider value={ctx}>\n <Portal>\n <div className=\"fixed inset-0 z-50 flex items-center justify-center p-4\">\n {/* Backdrop */}\n <div\n className=\"absolute inset-0 bg-black/50 backdrop-blur-sm\"\n onClick={close}\n aria-hidden=\"true\"\n />\n {/* Panel */}\n <div\n ref={attachPanel}\n data-react-fancy-modal=\"\"\n role=\"dialog\"\n aria-modal=\"true\"\n {...rest}\n className={cn(\n \"relative flex w-full flex-col overflow-hidden rounded-2xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] shadow-xl dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n SIZE_MAP[size],\n animClass,\n className,\n )}\n >\n {children}\n </div>\n </div>\n </Portal>\n </ModalContext.Provider>\n );\n}\n\nexport const Modal = Object.assign(ModalRoot, {\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n});\n"]}
@@ -0,0 +1,21 @@
1
+ import { useFocusTrap } from './chunk-MUV7OK3W.js';
2
+ import { useRef, useState, useLayoutEffect, useCallback } from 'react';
3
+
4
+ function useDialogFocusTrap(open, enabled = true) {
5
+ const ref = useRef(null);
6
+ const opener = useRef(null);
7
+ const [node, setNode] = useState(null);
8
+ const active = open && enabled;
9
+ useLayoutEffect(() => {
10
+ if (active) opener.current = document.activeElement;
11
+ }, [active]);
12
+ useFocusTrap(ref, active && node !== null, opener);
13
+ return useCallback((el) => {
14
+ ref.current = el;
15
+ setNode(el);
16
+ }, []);
17
+ }
18
+
19
+ export { useDialogFocusTrap };
20
+ //# sourceMappingURL=chunk-HHCVBIMM.js.map
21
+ //# sourceMappingURL=chunk-HHCVBIMM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-dialog-focus-trap.ts"],"names":[],"mappings":";;;AAoBO,SAAS,kBAAA,CACd,IAAA,EACA,OAAA,GAAmB,IAAA,EACiB;AACpC,EAAA,MAAM,GAAA,GAAM,OAA2B,IAAI,CAAA;AAC3C,EAAA,MAAM,MAAA,GAAS,OAA2B,IAAI,CAAA;AAC9C,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAA6B,IAAI,CAAA;AACzD,EAAA,MAAM,SAAS,IAAA,IAAQ,OAAA;AAEvB,EAAA,eAAA,CAAgB,MAAM;AACpB,IAAA,IAAI,MAAA,EAAQ,MAAA,CAAO,OAAA,GAAU,QAAA,CAAS,aAAA;AAAA,EACxC,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,YAAA,CAAa,GAAA,EAAK,MAAA,IAAU,IAAA,KAAS,IAAA,EAAM,MAAM,CAAA;AAEjD,EAAA,OAAO,WAAA,CAAY,CAAC,EAAA,KAA2B;AAC7C,IAAA,GAAA,CAAI,OAAA,GAAU,EAAA;AACd,IAAA,OAAA,CAAQ,EAAE,CAAA;AAAA,EACZ,CAAA,EAAG,EAAE,CAAA;AACP","file":"chunk-HHCVBIMM.js","sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { useFocusTrap } from \"./use-focus-trap\";\n\n/**\n * The focus trap for a dialog whose panel mounts LATER than `open` flips —\n * Modal, Drawer and Command, all of which render through `useAnimation` (the\n * panel mounts a render after `open`) and `Portal` (its children a render after\n * that). Returns a callback ref for the panel.\n *\n * Up to 6.10.0 these called `useFocusTrap(ref, open)` directly. Its effect ran in\n * the commit where `open` flipped, found `ref.current === null`, returned, and\n * never ran again because its deps had not changed — so focus never moved in,\n * Tab walked out of the dialog, and close restored nothing. Keying the trap on\n * the panel NODE makes it run in the commit the panel actually appears, with or\n * without an animation.\n *\n * The opener is captured when `open` flips, before the panel exists. Captured at\n * trap time instead it would be whatever the panel autofocused (Command's\n * input), and close would \"restore\" focus into the dialog that is going away.\n */\nexport function useDialogFocusTrap(\n open: boolean,\n enabled: boolean = true,\n): (node: HTMLElement | null) => void {\n const ref = useRef<HTMLElement | null>(null);\n const opener = useRef<HTMLElement | null>(null);\n const [node, setNode] = useState<HTMLElement | null>(null);\n const active = open && enabled;\n\n useLayoutEffect(() => {\n if (active) opener.current = document.activeElement as HTMLElement | null;\n }, [active]);\n\n useFocusTrap(ref, active && node !== null, opener);\n\n return useCallback((el: HTMLElement | null) => {\n ref.current = el;\n setNode(el);\n }, []);\n}\n"]}
@@ -28,6 +28,7 @@ function FileUploadDropzone({
28
28
  const inputId = react.useId();
29
29
  const custom = children !== void 0 && children !== null;
30
30
  const inputLabel = browseLabel ?? (custom ? DEFAULT_BROWSE_LABEL : DEFAULT_COPY);
31
+ const hintColour = dragOver ? "text-[color:var(--fancy-text-subtle,var(--color-zinc-600))] dark:text-[color:var(--fancy-text-subtle-dark,var(--color-zinc-400))]" : "text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]";
31
32
  const handleDrop = react.useCallback(
32
33
  (e) => {
33
34
  e.preventDefault();
@@ -113,8 +114,8 @@ function FileUploadDropzone({
113
114
  disabled,
114
115
  className: "flex cursor-pointer flex-col items-center rounded-md outline-none disabled:cursor-not-allowed",
115
116
  children: [
116
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { size: 32, strokeWidth: 1.5, "aria-hidden": "true", className: "mb-2 text-zinc-400" }),
117
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-zinc-500", children: DEFAULT_COPY })
117
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { size: 32, strokeWidth: 1.5, "aria-hidden": "true", className: chunkZU5Q77OT_cjs.cn("mb-2", hintColour) }),
118
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkZU5Q77OT_cjs.cn("text-sm", hintColour), children: DEFAULT_COPY })
118
119
  ]
119
120
  }
120
121
  )
@@ -132,6 +133,9 @@ function getExtension(name) {
132
133
  const parts = name.split(".");
133
134
  return parts.length > 1 ? parts.pop().toUpperCase() : "";
134
135
  }
136
+ var MUTED = "text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]";
137
+ var FAINT = "text-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))]";
138
+ var REMOVE = `${MUTED} hover:text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:hover:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]`;
135
139
  function ThumbnailItem({ file, index, onRemove }) {
136
140
  const isImage = file.type.startsWith("image/");
137
141
  const objectUrl = react.useMemo(() => isImage ? URL.createObjectURL(file) : null, [file, isImage]);
@@ -143,21 +147,21 @@ function ThumbnailItem({ file, index, onRemove }) {
143
147
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group relative flex w-20 flex-col items-center gap-1", children: [
144
148
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800", children: [
145
149
  isImage && objectUrl ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: objectUrl, alt: file.name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center gap-1", children: [
146
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.File, { size: 20, className: "text-zinc-400" }),
147
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-medium text-zinc-500", children: getExtension(file.name) })
150
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.File, { size: 20, "aria-hidden": "true", className: FAINT }),
151
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkZU5Q77OT_cjs.cn("text-[10px] font-medium", MUTED), children: getExtension(file.name) })
148
152
  ] }),
149
153
  /* @__PURE__ */ jsxRuntime.jsx(
150
154
  "button",
151
155
  {
152
156
  type: "button",
153
157
  onClick: () => onRemove(index),
154
- className: "absolute top-1 end-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity hover:bg-black/80 group-hover:opacity-100",
158
+ className: "absolute top-1 end-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity hover:bg-black/80 group-hover:opacity-100 focus-visible:opacity-100",
155
159
  "aria-label": `Remove ${file.name}`,
156
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 10 })
160
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 10, "aria-hidden": "true" })
157
161
  }
158
162
  )
159
163
  ] }),
160
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-full truncate text-center text-xs text-zinc-500", children: file.name })
164
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkZU5Q77OT_cjs.cn("w-full truncate text-center text-xs", MUTED), children: file.name })
161
165
  ] });
162
166
  }
163
167
  function FileUploadList({ thumbnail, className }) {
@@ -171,17 +175,17 @@ function FileUploadList({ thumbnail, className }) {
171
175
  {
172
176
  className: "flex items-center gap-3 rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] px-3 py-2 text-sm dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]",
173
177
  children: [
174
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.File, { size: 16, className: "shrink-0 text-zinc-400" }),
178
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.File, { size: 16, "aria-hidden": "true", className: chunkZU5Q77OT_cjs.cn("shrink-0", FAINT) }),
175
179
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate", children: file.name }),
176
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-xs text-zinc-400", children: formatSize(file.size) }),
180
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkZU5Q77OT_cjs.cn("shrink-0 text-xs", MUTED), children: formatSize(file.size) }),
177
181
  /* @__PURE__ */ jsxRuntime.jsx(
178
182
  "button",
179
183
  {
180
184
  type: "button",
181
185
  onClick: () => removeFile(i),
182
- className: "shrink-0 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",
186
+ className: chunkZU5Q77OT_cjs.cn("shrink-0", REMOVE),
183
187
  "aria-label": `Remove ${file.name}`,
184
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 14 })
188
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 14, "aria-hidden": "true" })
185
189
  }
186
190
  )
187
191
  ]
@@ -276,5 +280,5 @@ var FileUpload = Object.assign(FileUploadRoot, {
276
280
 
277
281
  exports.FileUpload = FileUpload;
278
282
  exports.useFileUpload = useFileUpload;
279
- //# sourceMappingURL=chunk-NIFHAFKK.cjs.map
280
- //# sourceMappingURL=chunk-NIFHAFKK.cjs.map
283
+ //# sourceMappingURL=chunk-JFPBW5MO.cjs.map
284
+ //# sourceMappingURL=chunk-JFPBW5MO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/FileUpload/FileUpload.context.ts","../src/components/FileUpload/FileUploadDropzone.tsx","../src/components/FileUpload/FileUploadList.tsx","../src/components/FileUpload/matchesAccept.ts","../src/components/FileUpload/FileUpload.tsx"],"names":["createContext","useContext","useState","useRef","useId","useCallback","jsxs","cn","jsx","Fragment","Upload","useMemo","useEffect","File","X"],"mappings":";;;;;;;AAGO,IAAM,iBAAA,GACXA,oBAA6C,IAAI,CAAA;AAE5C,SAAS,aAAA,GAAwC;AACtD,EAAA,MAAM,GAAA,GAAMC,iBAAW,iBAAiB,CAAA;AACxC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;ACPA,IAAM,oBAAA,GAAuB,cAAA;AAG7B,IAAM,YAAA,GAAe,oCAAA;AAqBd,SAAS,kBAAA,CAAmB;AAAA,EACjC,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA,EAA4B;AAC1B,EAAA,MAAM,EAAE,QAAA,EAAU,QAAA,EAAU,MAAA,EAAQ,QAAA,KAAa,aAAA,EAAc;AAC/D,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAIC,eAAS,KAAK,CAAA;AAC9C,EAAA,MAAM,QAAA,GAAWC,aAAyB,IAAI,CAAA;AAC9C,EAAA,MAAM,UAAUC,WAAA,EAAM;AACtB,EAAA,MAAM,MAAA,GAAS,QAAA,KAAa,MAAA,IAAa,QAAA,KAAa,IAAA;AACtD,EAAA,MAAM,UAAA,GAAa,WAAA,KAAgB,MAAA,GAAS,oBAAA,GAAuB,YAAA,CAAA;AAUnE,EAAA,MAAM,UAAA,GAAa,WACf,mIAAA,GACA,iIAAA;AAEJ,EAAA,MAAM,UAAA,GAAaC,iBAAA;AAAA,IACjB,CAAC,CAAA,KAAuB;AACtB,MAAA,CAA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AAA,EAAM;AACR,CAAC","file":"chunk-JFPBW5MO.cjs","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { FileUploadContextValue } from \"./FileUpload.types\";\n\nexport const FileUploadContext =\n createContext<FileUploadContextValue | null>(null);\n\nexport function useFileUpload(): FileUploadContextValue {\n const ctx = useContext(FileUploadContext);\n if (!ctx) {\n throw new Error(\n \"FileUpload compound components must be used within <FileUpload>\",\n );\n }\n return ctx;\n}\n","import { useCallback, useId, useRef, useState } from \"react\";\nimport { Upload } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport { useFileUpload } from \"./FileUpload.context\";\nimport type { FileUploadDropzoneProps } from \"./FileUpload.types\";\n\n/** Accessible name of the browse trigger when the zone has custom children. */\nconst DEFAULT_BROWSE_LABEL = \"Browse files\";\n\n/** The default zone copy; it doubles as the trigger's accessible name. */\nconst DEFAULT_COPY = \"Drop files here or click to browse\";\n\n/*\n * Keyboard access (after 5.59.0). Until then the zone was a clickable div around a\n * display:none input: no tab stop, no role, no key handler, so a keyboard or\n * switch user could not open the picker at all.\n *\n * The trigger is a REAL <button type=\"button\">, not a div with role=\"button\":\n * focus, Enter and Space (Space on keyup, cancelled by moving off) then come\n * from the platform instead of a key handler that has to get those right.\n *\n * - Default content: the button wraps the icon and the copy, so the visible\n * text IS its accessible name and the look is unchanged.\n * - Custom children: they may contain their own interactive content, which a\n * button must not wrap, so the button is visually hidden beside them and the\n * ZONE draws the focus ring (has-focus-visible) — the focus indicator is\n * never invisible.\n *\n * A click anywhere on the zone still opens the picker, as before; a click on\n * the button bubbles to the zone and is handled there once.\n */\nexport function FileUploadDropzone({\n children,\n className,\n browseLabel,\n}: FileUploadDropzoneProps) {\n const { addFiles, disabled, accept, multiple } = useFileUpload();\n const [dragOver, setDragOver] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const custom = children !== undefined && children !== null;\n const inputLabel = browseLabel ?? (custom ? DEFAULT_BROWSE_LABEL : DEFAULT_COPY);\n\n /*\n * The hint (and the icon above it) read the host's text tokens. They were\n * bare zinc until 6.11.1, so an app that mapped `--fancy-text-muted` themed\n * every component but this one: on a #0A2347 surface the hint was 3.23:1.\n *\n * Drag-over steps up to `subtle`: the drag fill (blue-50) is darker than the\n * page, and muted on it is 4.44:1, under AA. Subtle is 7.09:1 there.\n */\n const hintColour = dragOver\n ? \"text-[color:var(--fancy-text-subtle,var(--color-zinc-600))] dark:text-[color:var(--fancy-text-subtle-dark,var(--color-zinc-400))]\"\n : \"text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\";\n\n const handleDrop = useCallback(\n (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n if (disabled) return;\n addFiles(e.dataTransfer.files);\n },\n [addFiles, disabled],\n );\n\n const handleDragOver = useCallback((e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(true);\n }, []);\n\n const handleDragLeave = useCallback(() => setDragOver(false), []);\n\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n if (disabled) return;\n // The input's own click bubbles back up here; re-entering would ask for a\n // second picker.\n if (e.target === inputRef.current) return;\n inputRef.current?.click();\n },\n [disabled],\n );\n\n return (\n <div\n data-react-fancy-file-upload-dropzone=\"\"\n data-drag-over={dragOver ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n aria-disabled={disabled || undefined}\n onDrop={handleDrop}\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onClick={handleClick}\n className={cn(\n \"flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed p-8 text-center transition-[color,background-color,border-color,box-shadow]\",\n // Full opacity on purpose: a translucent 2px ring over a dashed border\n // falls under WCAG 2.2's 3:1 for a focus indicator. The offset gap is\n // painted with the surface token so it matches the page in dark mode.\n \"has-focus-visible:ring-2 has-focus-visible:ring-offset-2 has-focus-visible:ring-[color:var(--fancy-focus,var(--color-blue-500))] has-focus-visible:ring-offset-[color:var(--fancy-surface,var(--color-white))] dark:has-focus-visible:ring-[color:var(--fancy-focus-dark,var(--color-blue-400))] dark:has-focus-visible:ring-offset-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n dragOver\n ? \"border-blue-400 bg-blue-50 dark:border-blue-500 dark:bg-blue-950\"\n : \"border-[color:var(--fancy-border-strong,var(--color-zinc-300))] hover:border-zinc-400 dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-700))] dark:hover:border-zinc-500\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n >\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n className=\"hidden\"\n tabIndex={-1}\n aria-label={inputLabel}\n onChange={(e) => {\n if (e.target.files) addFiles(e.target.files);\n\n // Reset, or choosing the SAME file again fires no `change` event at\n // all and the gesture is simply dead — \"remove it, then re-add it\"\n // and \"retry the import that just failed\" both stop working. The\n // component never sees those files to reject them; it is not asked.\n e.target.value = \"\";\n }}\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n />\n {custom ? (\n <>\n {children}\n <button\n type=\"button\"\n data-react-fancy-file-upload-browse=\"\"\n aria-controls={inputId}\n disabled={disabled}\n className=\"sr-only\"\n >\n {browseLabel ?? DEFAULT_BROWSE_LABEL}\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n data-react-fancy-file-upload-browse=\"\"\n aria-controls={inputId}\n aria-label={browseLabel}\n disabled={disabled}\n className=\"flex cursor-pointer flex-col items-center rounded-md outline-none disabled:cursor-not-allowed\"\n >\n <Upload size={32} strokeWidth={1.5} aria-hidden=\"true\" className={cn(\"mb-2\", hintColour)} />\n <span className={cn(\"text-sm\", hintColour)}>{DEFAULT_COPY}</span>\n </button>\n )}\n </div>\n );\n}\n\nFileUploadDropzone.displayName = \"FileUploadDropzone\";\n","import { useEffect, useMemo } from \"react\";\nimport { File, X } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport { useFileUpload } from \"./FileUpload.context\";\nimport type { FileUploadListProps } from \"./FileUpload.types\";\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nfunction getExtension(name: string): string {\n const parts = name.split(\".\");\n return parts.length > 1 ? parts.pop()!.toUpperCase() : \"\";\n}\n\n/*\n * Text colours read the host's `--fancy-text-*` tokens (bare zinc until\n * 6.11.1). Fallbacks are the kit-wide defaults, so an app that maps nothing\n * sees the same greys every other component uses.\n */\nconst MUTED =\n \"text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\";\n/** Decorative file glyphs (aria-hidden): themed, but owe no text contrast. */\nconst FAINT =\n \"text-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))]\";\n/**\n * The list's remove control is an icon with no text, so its glyph owes 3:1\n * (WCAG 1.4.11). Bare zinc-400 was 2.62:1 on white; muted is 4.83:1.\n */\nconst REMOVE =\n `${MUTED} hover:text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:hover:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]`;\n\nfunction ThumbnailItem({ file, index, onRemove }: { file: File; index: number; onRemove: (i: number) => void }) {\n const isImage = file.type.startsWith(\"image/\");\n const objectUrl = useMemo(() => (isImage ? URL.createObjectURL(file) : null), [file, isImage]);\n\n useEffect(() => {\n return () => {\n if (objectUrl) URL.revokeObjectURL(objectUrl);\n };\n }, [objectUrl]);\n\n return (\n <div className=\"group relative flex w-20 flex-col items-center gap-1\">\n <div className=\"relative h-20 w-20 overflow-hidden rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800\">\n {isImage && objectUrl ? (\n <img src={objectUrl} alt={file.name} className=\"h-full w-full object-cover\" />\n ) : (\n <div className=\"flex h-full w-full flex-col items-center justify-center gap-1\">\n <File size={20} aria-hidden=\"true\" className={FAINT} />\n <span className={cn(\"text-[10px] font-medium\", MUTED)}>{getExtension(file.name)}</span>\n </div>\n )}\n <button\n type=\"button\"\n onClick={() => onRemove(index)}\n // Hidden until the tile is hovered, so keyboard focus must reveal it\n // too, or a keyboard user tabs onto an invisible control.\n className=\"absolute top-1 end-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/60 text-white opacity-0 transition-opacity hover:bg-black/80 group-hover:opacity-100 focus-visible:opacity-100\"\n aria-label={`Remove ${file.name}`}\n >\n <X size={10} aria-hidden=\"true\" />\n </button>\n </div>\n <span className={cn(\"w-full truncate text-center text-xs\", MUTED)}>{file.name}</span>\n </div>\n );\n}\n\nexport function FileUploadList({ thumbnail, className }: FileUploadListProps) {\n const { files, removeFile } = useFileUpload();\n\n if (files.length === 0) return null;\n\n if (thumbnail) {\n return (\n <div data-react-fancy-file-upload-list=\"\" className={cn(\"mt-3 flex flex-wrap gap-3\", className)}>\n {files.map((file, i) => (\n <ThumbnailItem key={`${file.name}-${i}`} file={file} index={i} onRemove={removeFile} />\n ))}\n </div>\n );\n }\n\n return (\n <ul data-react-fancy-file-upload-list=\"\" className={cn(\"mt-3 space-y-2\", className)}>\n {files.map((file, i) => (\n <li\n key={`${file.name}-${i}`}\n className=\"flex items-center gap-3 rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] px-3 py-2 text-sm dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n >\n <File size={16} aria-hidden=\"true\" className={cn(\"shrink-0\", FAINT)} />\n <span className=\"flex-1 truncate\">{file.name}</span>\n <span className={cn(\"shrink-0 text-xs\", MUTED)}>\n {formatSize(file.size)}\n </span>\n <button\n type=\"button\"\n onClick={() => removeFile(i)}\n className={cn(\"shrink-0\", REMOVE)}\n aria-label={`Remove ${file.name}`}\n >\n <X size={14} aria-hidden=\"true\" />\n </button>\n </li>\n ))}\n </ul>\n );\n}\n\nFileUploadList.displayName = \"FileUploadList\";\n","/**\n * Does a file satisfy an `accept` string?\n *\n * The browser enforces `accept` in the FILE PICKER only. A drag-and-drop never\n * opens a picker, so on the drop path this is the only thing standing between an\n * image-only dropzone and a dropped executable. Forwarding the attribute to the\n * hidden input is half the job; this is the other half.\n *\n * Follows the HTML `accept` grammar: a comma-separated list of extensions\n * (`.csv`), exact MIME types (`text/plain`) and type wildcards (`image/*`).\n * Matching is case-insensitive, because a drop reports whatever the OS says and\n * `TEXT/PLAIN` is a real thing to receive.\n *\n * A dropped file often carries an EMPTY `type` — the OS may not know it and\n * `File.type` is a hint, never a guarantee. That is why extension rules are\n * checked against the name and not the type: an `accept=\".csv\"` zone has to work\n * for a .csv whose type is `\"\"`, which is the common case rather than the edge.\n */\nexport function matchesAccept(file: File, accept: string): boolean {\n const rules = accept\n .split(\",\")\n .map((rule) => rule.trim().toLowerCase())\n .filter(Boolean);\n\n // An accept string that lists nothing constrains nothing. Failing closed here\n // would turn `accept=\"\"` into a dropzone that silently swallows every file.\n if (rules.length === 0) return true;\n\n const type = file.type.toLowerCase();\n const name = file.name.toLowerCase();\n\n return rules.some((rule) => {\n if (rule.startsWith(\".\")) return name.endsWith(rule);\n if (rule.endsWith(\"/*\")) return type.startsWith(rule.slice(0, -1));\n return type === rule;\n });\n}\n","import { useCallback, useMemo, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { FileUploadContext } from \"./FileUpload.context\";\nimport { FileUploadDropzone } from \"./FileUploadDropzone\";\nimport { FileUploadList } from \"./FileUploadList\";\nimport { matchesAccept } from \"./matchesAccept\";\nimport type {\n FileRejection,\n FileRejectionReason,\n FileUploadProps,\n} from \"./FileUpload.types\";\n\nfunction rejection(file: File, reason: FileRejectionReason): FileRejection {\n return { name: file.name, size: file.size, type: file.type, reason };\n}\n\nfunction FileUploadRoot({\n children,\n value,\n onChange,\n onReject,\n accept,\n multiple = true,\n maxFiles,\n maxSize,\n disabled = false,\n className,\n}: FileUploadProps) {\n const [internalFiles, setInternalFiles] = useState<File[]>([]);\n const files = value ?? internalFiles;\n\n const addFiles = useCallback(\n (newFiles: FileList | File[]) => {\n let toAdd = Array.from(newFiles);\n const rejections: FileRejection[] = [];\n\n // Each file is reported once, under the first rule it failed.\n const keepOnly = (\n passes: (f: File) => boolean,\n reason: FileRejectionReason,\n ) => {\n toAdd = toAdd.filter((f) => {\n if (passes(f)) return true;\n rejections.push(rejection(f, reason));\n return false;\n });\n };\n\n // `accept` is enforced HERE, not only on the input: the input's attribute\n // governs the picker, and a drop never opens one.\n if (accept) {\n keepOnly((f) => matchesAccept(f, accept), \"accept\");\n }\n\n if (maxSize) {\n keepOnly((f) => f.size <= maxSize, \"maxSize\");\n }\n\n /*\n * `multiple={false}` REPLACES; `maxFiles` refuses the overflow.\n *\n * These used to be the same rule — a cap of one, first-wins — on the\n * reasoning that the two props must not disagree about what a single-file\n * upload means. But they are different statements:\n *\n * - `maxFiles={n}` is a QUOTA. Dropping five files into a three-file\n * field should keep three, not the last three.\n * - `multiple={false}` is a FIELD SHAPE: this input holds one file. Its\n * analogue is a radio group, where choosing again MOVES the selection.\n *\n * Under the old rule a single-file field could never change its mind: the\n * second choice computed `[old, new].slice(0, 1)` and discarded the new\n * file in silence. The YouGene estate worked around it by remounting the\n * component with a `key`, which is the shape of a bug rather than a\n * preference.\n */\n if (multiple === false) {\n /*\n * The FIRST of the incoming batch, not the last.\n *\n * Two separate questions hide here, and only one of them was the bug:\n *\n * - ACROSS gestures — choose a file, then choose another. The second\n * must win, or the field cannot change its mind. That is the fix.\n * - WITHIN one gesture — drop two files at once onto a single-file\n * field. Which one wins is arbitrary, and taking the first is what\n * has always shipped; there is no replacement intent in a single\n * ambiguous drop.\n *\n * Taking `slice(-1)` would have answered both with \"the last\", quietly\n * changing the second. The existing drop test caught it.\n */\n const replacement = toAdd.slice(0, 1);\n // Nothing survived the accept/size filters — leave the field alone\n // rather than clearing a file the user never asked to remove.\n const next = replacement.length > 0 ? replacement : files;\n\n // The file being replaced was not refused; the rest of this batch was,\n // by a field that holds one.\n for (const f of toAdd.slice(1)) rejections.push(rejection(f, \"maxFiles\"));\n\n if (value === undefined) setInternalFiles(next);\n onChange?.(next);\n if (rejections.length > 0) onReject?.(rejections);\n\n return;\n }\n\n const updated = [...files, ...toAdd];\n const limited = maxFiles ? updated.slice(0, maxFiles) : updated;\n\n for (const f of updated.slice(limited.length)) rejections.push(rejection(f, \"maxFiles\"));\n\n if (value === undefined) setInternalFiles(limited);\n onChange?.(limited);\n if (rejections.length > 0) onReject?.(rejections);\n },\n [accept, files, maxFiles, maxSize, multiple, onChange, onReject, value],\n );\n\n const removeFile = useCallback(\n (index: number) => {\n const updated = files.filter((_, i) => i !== index);\n if (value === undefined) setInternalFiles(updated);\n onChange?.(updated);\n },\n [files, onChange, value],\n );\n\n const ctx = useMemo(\n () => ({ files, addFiles, removeFile, disabled, accept, multiple }),\n [files, addFiles, removeFile, disabled, accept, multiple],\n );\n\n return (\n <FileUploadContext.Provider value={ctx}>\n <div data-react-fancy-file-upload=\"\" className={cn(className)}>{children}</div>\n </FileUploadContext.Provider>\n );\n}\n\nexport const FileUpload = Object.assign(FileUploadRoot, {\n Dropzone: FileUploadDropzone,\n List: FileUploadList,\n});\n"]}