@lerianstudio/sindarian-ui 2.0.0-beta.2 → 2.0.0-beta.21

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 (227) hide show
  1. package/LICENSE +93 -0
  2. package/README.md +52 -1
  3. package/dist/components/breadcrumb/index.d.ts.map +1 -1
  4. package/dist/components/breadcrumb/index.js +25 -1
  5. package/dist/components/card/account-card/index.js +5 -5
  6. package/dist/components/card/basic-card/index.d.ts.map +1 -1
  7. package/dist/components/card/basic-card/index.js +2 -2
  8. package/dist/components/card/entity-card/index.js +1 -1
  9. package/dist/components/dialog/confirmation-dialog/index.d.ts.map +1 -1
  10. package/dist/components/dialog/confirmation-dialog/index.js +4 -1
  11. package/dist/components/entity-box/index.d.ts +18 -2
  12. package/dist/components/entity-box/index.d.ts.map +1 -1
  13. package/dist/components/entity-box/index.js +32 -4
  14. package/dist/components/form/date-picker-field/index.js +1 -1
  15. package/dist/components/form/date-range-field/index.js +1 -1
  16. package/dist/components/form/date-time-picker-field/index.js +1 -1
  17. package/dist/components/form/password-field/index.d.ts +5 -1
  18. package/dist/components/form/password-field/index.d.ts.map +1 -1
  19. package/dist/components/form/password-field/index.js +2 -2
  20. package/dist/components/form/select-field/index.d.ts +15 -1
  21. package/dist/components/form/select-field/index.d.ts.map +1 -1
  22. package/dist/components/form/select-field/index.js +28 -3
  23. package/dist/components/form/switch-field/index.d.ts.map +1 -1
  24. package/dist/components/form/switch-field/index.js +6 -1
  25. package/dist/components/page/index.d.ts +35 -1
  26. package/dist/components/page/index.d.ts.map +1 -1
  27. package/dist/components/page/index.js +6 -2
  28. package/dist/components/page-header/index.js +1 -1
  29. package/dist/components/table/id-table-cell.d.ts +13 -1
  30. package/dist/components/table/id-table-cell.d.ts.map +1 -1
  31. package/dist/components/table/id-table-cell.js +99 -9
  32. package/dist/components/table/index.d.ts +1 -0
  33. package/dist/components/table/index.d.ts.map +1 -1
  34. package/dist/components/table/index.js +1 -0
  35. package/dist/components/table/locked-table-actions.d.ts +24 -0
  36. package/dist/components/table/locked-table-actions.d.ts.map +1 -1
  37. package/dist/components/table/locked-table-actions.js +31 -1
  38. package/dist/components/table/name-table-cell.d.ts +57 -4
  39. package/dist/components/table/name-table-cell.d.ts.map +1 -1
  40. package/dist/components/table/name-table-cell.js +50 -2
  41. package/dist/components/ui/autocomplete/index.d.ts +24 -0
  42. package/dist/components/ui/autocomplete/index.d.ts.map +1 -1
  43. package/dist/components/ui/autocomplete/index.js +24 -0
  44. package/dist/components/ui/badge/index.d.ts +11 -7
  45. package/dist/components/ui/badge/index.d.ts.map +1 -1
  46. package/dist/components/ui/badge/index.js +20 -8
  47. package/dist/components/ui/button/index.d.ts +3 -3
  48. package/dist/components/ui/copy-field/index.d.ts +25 -1
  49. package/dist/components/ui/copy-field/index.d.ts.map +1 -1
  50. package/dist/components/ui/copy-field/index.js +16 -8
  51. package/dist/components/ui/dialog/index.d.ts +1 -1
  52. package/dist/components/ui/dialog/index.d.ts.map +1 -1
  53. package/dist/components/ui/dialog/index.js +2 -2
  54. package/dist/components/ui/file-upload/index.d.ts +159 -0
  55. package/dist/components/ui/file-upload/index.d.ts.map +1 -1
  56. package/dist/components/ui/file-upload/index.js +308 -6
  57. package/dist/components/ui/icon-button/index.d.ts +1 -1
  58. package/dist/components/ui/icon-button/styles.css +42 -0
  59. package/dist/components/ui/input/styles.css +79 -4
  60. package/dist/components/ui/lerian-wordmark/index.d.ts +6 -0
  61. package/dist/components/ui/lerian-wordmark/index.d.ts.map +1 -0
  62. package/dist/components/ui/lerian-wordmark/index.js +7 -0
  63. package/dist/components/ui/otp-input/index.js +1 -1
  64. package/dist/components/ui/radio-group/index.js +1 -1
  65. package/dist/components/ui/select/index.d.ts.map +1 -1
  66. package/dist/components/ui/select/index.js +8 -4
  67. package/dist/components/ui/select/styles.css +1 -1
  68. package/dist/components/ui/sheet/index.d.ts +42 -0
  69. package/dist/components/ui/sheet/index.d.ts.map +1 -1
  70. package/dist/components/ui/sheet/index.js +47 -14
  71. package/dist/components/ui/sidebar/index.d.ts +1 -0
  72. package/dist/components/ui/sidebar/index.d.ts.map +1 -1
  73. package/dist/components/ui/sidebar/index.js +1 -0
  74. package/dist/components/ui/sidebar/sidebar-expand-button.d.ts +1 -1
  75. package/dist/components/ui/sidebar/sidebar-expand-button.d.ts.map +1 -1
  76. package/dist/components/ui/sidebar/sidebar-expand-button.js +15 -1
  77. package/dist/components/ui/sidebar/sidebar-item.d.ts +1 -1
  78. package/dist/components/ui/sidebar/sidebar-item.d.ts.map +1 -1
  79. package/dist/components/ui/sidebar/sidebar-item.js +28 -4
  80. package/dist/components/ui/sidebar/sidebar-provider.d.ts +58 -0
  81. package/dist/components/ui/sidebar/sidebar-provider.d.ts.map +1 -1
  82. package/dist/components/ui/sidebar/sidebar-provider.js +146 -4
  83. package/dist/components/ui/sidebar/sidebar-root.d.ts +38 -1
  84. package/dist/components/ui/sidebar/sidebar-root.d.ts.map +1 -1
  85. package/dist/components/ui/sidebar/sidebar-root.js +111 -5
  86. package/dist/components/ui/sidebar/sidebar-trigger.d.ts +45 -0
  87. package/dist/components/ui/sidebar/sidebar-trigger.d.ts.map +1 -0
  88. package/dist/components/ui/sidebar/sidebar-trigger.js +57 -0
  89. package/dist/components/ui/textarea/index.js +1 -1
  90. package/dist/components/ui/toast/toaster.d.ts +5 -1
  91. package/dist/components/ui/toast/toaster.d.ts.map +1 -1
  92. package/dist/components/ui/toast/toaster.js +3 -2
  93. package/dist/enterprise/data-table/index.d.ts +77 -7
  94. package/dist/enterprise/data-table/index.d.ts.map +1 -1
  95. package/dist/enterprise/data-table/index.js +56 -11
  96. package/dist/enterprise/date-range-picker/index.js +4 -4
  97. package/dist/enterprise/number-input/index.d.ts.map +1 -1
  98. package/dist/enterprise/number-input/index.js +1 -1
  99. package/dist/esm/components/breadcrumb/index.d.ts.map +1 -1
  100. package/dist/esm/components/breadcrumb/index.js +25 -1
  101. package/dist/esm/components/card/account-card/index.js +5 -5
  102. package/dist/esm/components/card/basic-card/index.d.ts.map +1 -1
  103. package/dist/esm/components/card/basic-card/index.js +2 -2
  104. package/dist/esm/components/card/entity-card/index.js +1 -1
  105. package/dist/esm/components/dialog/confirmation-dialog/index.d.ts.map +1 -1
  106. package/dist/esm/components/dialog/confirmation-dialog/index.js +4 -1
  107. package/dist/esm/components/entity-box/index.d.ts +18 -2
  108. package/dist/esm/components/entity-box/index.d.ts.map +1 -1
  109. package/dist/esm/components/entity-box/index.js +29 -4
  110. package/dist/esm/components/form/date-picker-field/index.js +1 -1
  111. package/dist/esm/components/form/date-range-field/index.js +1 -1
  112. package/dist/esm/components/form/date-time-picker-field/index.js +1 -1
  113. package/dist/esm/components/form/password-field/index.d.ts +5 -1
  114. package/dist/esm/components/form/password-field/index.d.ts.map +1 -1
  115. package/dist/esm/components/form/password-field/index.js +2 -2
  116. package/dist/esm/components/form/select-field/index.d.ts +15 -1
  117. package/dist/esm/components/form/select-field/index.d.ts.map +1 -1
  118. package/dist/esm/components/form/select-field/index.js +29 -4
  119. package/dist/esm/components/form/switch-field/index.d.ts.map +1 -1
  120. package/dist/esm/components/form/switch-field/index.js +7 -2
  121. package/dist/esm/components/page/index.d.ts +35 -1
  122. package/dist/esm/components/page/index.d.ts.map +1 -1
  123. package/dist/esm/components/page/index.js +6 -2
  124. package/dist/esm/components/page-header/index.js +1 -1
  125. package/dist/esm/components/table/id-table-cell.d.ts +13 -1
  126. package/dist/esm/components/table/id-table-cell.d.ts.map +1 -1
  127. package/dist/esm/components/table/id-table-cell.js +100 -7
  128. package/dist/esm/components/table/index.d.ts +1 -0
  129. package/dist/esm/components/table/index.d.ts.map +1 -1
  130. package/dist/esm/components/table/index.js +1 -0
  131. package/dist/esm/components/table/locked-table-actions.d.ts +24 -0
  132. package/dist/esm/components/table/locked-table-actions.d.ts.map +1 -1
  133. package/dist/esm/components/table/locked-table-actions.js +31 -1
  134. package/dist/esm/components/table/name-table-cell.d.ts +57 -4
  135. package/dist/esm/components/table/name-table-cell.d.ts.map +1 -1
  136. package/dist/esm/components/table/name-table-cell.js +50 -2
  137. package/dist/esm/components/ui/autocomplete/index.d.ts +24 -0
  138. package/dist/esm/components/ui/autocomplete/index.d.ts.map +1 -1
  139. package/dist/esm/components/ui/autocomplete/index.js +24 -0
  140. package/dist/esm/components/ui/badge/index.d.ts +11 -7
  141. package/dist/esm/components/ui/badge/index.d.ts.map +1 -1
  142. package/dist/esm/components/ui/badge/index.js +20 -8
  143. package/dist/esm/components/ui/button/index.d.ts +3 -3
  144. package/dist/esm/components/ui/copy-field/index.d.ts +25 -1
  145. package/dist/esm/components/ui/copy-field/index.d.ts.map +1 -1
  146. package/dist/esm/components/ui/copy-field/index.js +16 -8
  147. package/dist/esm/components/ui/dialog/index.d.ts +1 -1
  148. package/dist/esm/components/ui/dialog/index.d.ts.map +1 -1
  149. package/dist/esm/components/ui/dialog/index.js +3 -3
  150. package/dist/esm/components/ui/file-upload/index.d.ts +159 -0
  151. package/dist/esm/components/ui/file-upload/index.d.ts.map +1 -1
  152. package/dist/esm/components/ui/file-upload/index.js +307 -5
  153. package/dist/esm/components/ui/icon-button/index.d.ts +1 -1
  154. package/dist/esm/components/ui/lerian-wordmark/index.d.ts +6 -0
  155. package/dist/esm/components/ui/lerian-wordmark/index.d.ts.map +1 -0
  156. package/dist/esm/components/ui/lerian-wordmark/index.js +4 -0
  157. package/dist/esm/components/ui/otp-input/index.js +1 -1
  158. package/dist/esm/components/ui/radio-group/index.js +1 -1
  159. package/dist/esm/components/ui/select/index.d.ts.map +1 -1
  160. package/dist/esm/components/ui/select/index.js +8 -4
  161. package/dist/esm/components/ui/sheet/index.d.ts +42 -0
  162. package/dist/esm/components/ui/sheet/index.d.ts.map +1 -1
  163. package/dist/esm/components/ui/sheet/index.js +48 -15
  164. package/dist/esm/components/ui/sidebar/index.d.ts +1 -0
  165. package/dist/esm/components/ui/sidebar/index.d.ts.map +1 -1
  166. package/dist/esm/components/ui/sidebar/index.js +1 -0
  167. package/dist/esm/components/ui/sidebar/sidebar-expand-button.d.ts +1 -1
  168. package/dist/esm/components/ui/sidebar/sidebar-expand-button.d.ts.map +1 -1
  169. package/dist/esm/components/ui/sidebar/sidebar-expand-button.js +15 -1
  170. package/dist/esm/components/ui/sidebar/sidebar-item.d.ts +1 -1
  171. package/dist/esm/components/ui/sidebar/sidebar-item.d.ts.map +1 -1
  172. package/dist/esm/components/ui/sidebar/sidebar-item.js +28 -4
  173. package/dist/esm/components/ui/sidebar/sidebar-provider.d.ts +58 -0
  174. package/dist/esm/components/ui/sidebar/sidebar-provider.d.ts.map +1 -1
  175. package/dist/esm/components/ui/sidebar/sidebar-provider.js +143 -1
  176. package/dist/esm/components/ui/sidebar/sidebar-root.d.ts +38 -1
  177. package/dist/esm/components/ui/sidebar/sidebar-root.d.ts.map +1 -1
  178. package/dist/esm/components/ui/sidebar/sidebar-root.js +113 -7
  179. package/dist/esm/components/ui/sidebar/sidebar-trigger.d.ts +45 -0
  180. package/dist/esm/components/ui/sidebar/sidebar-trigger.d.ts.map +1 -0
  181. package/dist/esm/components/ui/sidebar/sidebar-trigger.js +53 -0
  182. package/dist/esm/components/ui/textarea/index.js +1 -1
  183. package/dist/esm/components/ui/toast/toaster.d.ts +5 -1
  184. package/dist/esm/components/ui/toast/toaster.d.ts.map +1 -1
  185. package/dist/esm/components/ui/toast/toaster.js +3 -2
  186. package/dist/esm/enterprise/data-table/index.d.ts +77 -7
  187. package/dist/esm/enterprise/data-table/index.d.ts.map +1 -1
  188. package/dist/esm/enterprise/data-table/index.js +57 -12
  189. package/dist/esm/enterprise/date-range-picker/index.js +4 -4
  190. package/dist/esm/enterprise/number-input/index.d.ts.map +1 -1
  191. package/dist/esm/enterprise/number-input/index.js +1 -1
  192. package/dist/esm/hooks/use-toast.d.ts +18 -2
  193. package/dist/esm/hooks/use-toast.d.ts.map +1 -1
  194. package/dist/esm/hooks/use-toast.js +60 -16
  195. package/dist/esm/index.d.ts +3 -0
  196. package/dist/esm/index.d.ts.map +1 -1
  197. package/dist/esm/index.js +3 -0
  198. package/dist/esm/lib/utils.d.ts +2 -0
  199. package/dist/esm/lib/utils.d.ts.map +1 -1
  200. package/dist/esm/lib/utils.js +10 -0
  201. package/dist/esm/toast/helpers.d.ts +13 -0
  202. package/dist/esm/toast/helpers.d.ts.map +1 -1
  203. package/dist/esm/toast/helpers.js +8 -1
  204. package/dist/fonts/OFL.txt +96 -0
  205. package/dist/fonts/ibm-plex-mono-latin-400.woff2 +0 -0
  206. package/dist/fonts/ibm-plex-mono-latin-500.woff2 +0 -0
  207. package/dist/fonts/ibm-plex-serif-latin-400.woff2 +0 -0
  208. package/dist/fonts/ibm-plex-serif-latin-500.woff2 +0 -0
  209. package/dist/fonts/inter-latin.woff2 +0 -0
  210. package/dist/fonts.css +46 -0
  211. package/dist/globals.css +62 -362
  212. package/dist/hooks/use-toast.d.ts +18 -2
  213. package/dist/hooks/use-toast.d.ts.map +1 -1
  214. package/dist/hooks/use-toast.js +61 -16
  215. package/dist/index.d.ts +3 -0
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js +3 -0
  218. package/dist/lib/utils.d.ts +2 -0
  219. package/dist/lib/utils.d.ts.map +1 -1
  220. package/dist/lib/utils.js +11 -0
  221. package/dist/public/wordmark.svg +1 -0
  222. package/dist/standalone.css +10 -0
  223. package/dist/toast/helpers.d.ts +13 -0
  224. package/dist/toast/helpers.d.ts.map +1 -1
  225. package/dist/toast/helpers.js +8 -1
  226. package/dist/tokens.css +367 -0
  227. package/package.json +9 -6
@@ -4,6 +4,7 @@ import * as React from 'react';
4
4
  import { Check, Copy, Eye, EyeOff } from 'lucide-react';
5
5
  import { IconButton } from '../../../components/ui/icon-button/index.js';
6
6
  import { useToast } from '../../../hooks/use-toast.js';
7
+ import { cn } from '../../../lib/utils.js';
7
8
  const DEFAULT_COPY_LABEL = 'Copied to clipboard!';
8
9
  const FALLBACK_COPY_LABEL = 'Copy not available — text selected, press Ctrl/Cmd+C';
9
10
  const COPIED_ICON_TIMEOUT = 1500;
@@ -31,17 +32,18 @@ const clearClipboardIfUnchanged = async (copiedValue) => {
31
32
  // Read or write refused; the clipboard stays as-is.
32
33
  }
33
34
  };
34
- export function CopyField({ value, label, masked = false, onCopyLabel, revealLabel = 'Show value', hideLabel = 'Hide value', valueLabel = 'Value to copy', clearClipboardAfter }) {
35
+ export function CopyField({ value, label, masked = false, onCopyLabel, revealLabel = 'Show value', hideLabel = 'Hide value', valueLabel = 'Value to copy', copyLabel, fallbackLabel, mono = false, description, clearClipboardAfter }) {
35
36
  const { toast } = useToast();
36
37
  const generatedId = React.useId();
37
38
  const inputId = `${generatedId}-copy-field`;
39
+ const descriptionId = `${inputId}-description`;
38
40
  const inputRef = React.useRef(null);
39
41
  const copiedTimerRef = React.useRef(null);
40
42
  const clearTimerRef = React.useRef(null);
41
43
  const [revealed, setRevealed] = React.useState(false);
42
44
  const [copied, setCopied] = React.useState(false);
43
45
  const showAsText = !masked || revealed;
44
- const copyAccessibleName = label ? `Copy ${label}` : 'Copy value';
46
+ const copyAccessibleName = copyLabel ?? (label ? `Copy ${label}` : 'Copy value');
45
47
  React.useEffect(() => {
46
48
  return () => {
47
49
  if (copiedTimerRef.current) {
@@ -73,7 +75,10 @@ export function CopyField({ value, label, masked = false, onCopyLabel, revealLab
73
75
  };
74
76
  const handleFallback = () => {
75
77
  selectFieldText();
76
- toast({ title: FALLBACK_COPY_LABEL });
78
+ toast({
79
+ variant: 'destructive',
80
+ title: fallbackLabel ?? FALLBACK_COPY_LABEL
81
+ });
77
82
  };
78
83
  const handleCopy = async () => {
79
84
  if (!isClipboardAvailable()) {
@@ -105,15 +110,18 @@ export function CopyField({ value, label, masked = false, onCopyLabel, revealLab
105
110
  handleFallback();
106
111
  }
107
112
  };
108
- return (_jsxs("div", { "data-slot": "copy-field", className: "flex w-full flex-col gap-2", children: [label ? (_jsx("label", { htmlFor: inputId, className: "text-muted-foreground text-sm font-semibold", children: label })) : null, _jsxs("div", { "data-slot": "input-wrapper", className: "border-input-border focus-within:border-ring flex h-10 w-full cursor-text items-center gap-1 rounded-md border pr-1 pl-4 transition-[color,box-shadow]", children: [_jsx("input", { ref: inputRef, id: inputId, "data-slot": "input", "data-testid": "copy-field-input", type: showAsText ? 'text' : 'password', value: value, readOnly: true,
113
+ return (_jsxs("div", { "data-slot": "copy-field", className: "flex w-full flex-col gap-2", children: [label ? (_jsx("label", { htmlFor: inputId, className: "text-muted-foreground text-sm font-semibold", children: label })) : null, _jsxs("div", { "data-slot": "input-wrapper", className: "border-input-border focus-within:border-ring has-[input:focus]:ring-ring flex h-10 w-full cursor-text items-center gap-1 rounded-md border pr-1 pl-4 transition-[color,box-shadow] has-[input:focus]:ring-2", children: [_jsx("input", { ref: inputRef, id: inputId, "data-slot": "input", "data-testid": "copy-field-input", type: showAsText ? 'text' : 'password', value: value, readOnly: true,
109
114
  // This field holds secrets: TOTP manual-entry secrets, recovery
110
115
  // codes. While masked it renders as type="password", which invites
111
116
  // browsers and password managers to autofill it or offer to SAVE its
112
117
  // value, and spellcheck can ship the text to a remote service.
113
- autoComplete: "off", spellCheck: false, "aria-label": label ? undefined : valueLabel,
118
+ autoComplete: "off", spellCheck: false, "aria-label": label ? undefined : valueLabel, "aria-describedby": description ? descriptionId : undefined,
114
119
  // `min-w-0` lets this flex item shrink below its content width so a
115
120
  // long value (e.g. a UUID recovery code) scrolls inside the field
116
- // instead of overflowing its container. No `font-mono`: the value
117
- // inherits the app sans font (Inter) so it matches every other field.
118
- className: "text-input-foreground h-full min-w-0 flex-1 cursor-text border-none bg-transparent text-sm outline-none select-text focus:ring-0 focus:ring-offset-0" }), masked ? (_jsx(IconButton, { type: "button", variant: "outline", size: "small", rounded: true, "aria-pressed": revealed, "aria-label": revealed ? hideLabel : revealLabel, onClick: () => setRevealed((prev) => !prev), children: revealed ? _jsx(EyeOff, {}) : _jsx(Eye, {}) })) : null, _jsx(IconButton, { type: "button", variant: "outline", size: "small", rounded: true, "aria-label": copyAccessibleName, onClick: handleCopy, children: copied ? _jsx(Check, {}) : _jsx(Copy, {}) })] })] }));
121
+ // instead of overflowing its container. Sans by default, inheriting
122
+ // the app font (Inter) so the field matches every other input;
123
+ // `mono` opts identifiers, tokens and recovery codes into the
124
+ // monospace face, where telling 0 from O decides whether the value
125
+ // read back is the value.
126
+ className: cn('text-input-foreground h-full min-w-0 flex-1 cursor-text border-none bg-transparent text-sm outline-none select-text focus:ring-0 focus:ring-offset-0', mono && 'font-mono') }), masked ? (_jsx(IconButton, { type: "button", variant: "outline", size: "small", rounded: true, "aria-label": revealed ? hideLabel : revealLabel, onClick: () => setRevealed((prev) => !prev), children: revealed ? _jsx(EyeOff, {}) : _jsx(Eye, {}) })) : null, _jsx(IconButton, { type: "button", variant: "outline", size: "small", rounded: true, "aria-label": copyAccessibleName, onClick: handleCopy, children: copied ? _jsx(Check, {}) : _jsx(Copy, {}) })] }), description ? (_jsx("p", { "data-slot": "copy-field-description", id: descriptionId, className: "text-muted-foreground text-xs", children: description })) : null] }));
119
127
  }
@@ -5,7 +5,7 @@ declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogP
5
5
  declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
6
6
  declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element;
7
7
  declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
8
- declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
8
+ declare function DialogContent({ className, children, showCloseButton, onInteractOutside, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
9
9
  showCloseButton?: boolean;
10
10
  }): React.JSX.Element;
11
11
  declare function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/dialog/index.tsx"],"names":[],"mappings":"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AAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,WAAW,CAAC,qBAQ1D;AAED,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,iBAAiB,EAClB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/dialog/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAA;AAKzD,iBAAS,MAAM,CAAC,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,qBAEnD;AAED,iBAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,qBAEtD;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,MAAM,CAAC,qBAErD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,qBAEpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,qBAQtD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,eAAsB,EACtB,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,GAAG;IACxD,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,qBAyBA;AAED,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAQzE;AAED,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAQzE;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,qBAQpD;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,WAAW,CAAC,qBAQ1D;AAED,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,iBAAiB,EAClB,CAAA"}
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as DialogPrimitive from '@radix-ui/react-dialog';
4
4
  import { X } from 'lucide-react';
5
- import { cn } from '../../../lib/utils.js';
5
+ import { cn, keepOpenOnToast } from '../../../lib/utils.js';
6
6
  function Dialog({ ...props }) {
7
7
  return _jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
8
8
  }
@@ -18,8 +18,8 @@ function DialogClose({ ...props }) {
18
18
  function DialogOverlay({ className, ...props }) {
19
19
  return (_jsx(DialogPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn('dialog-overlay', className), ...props }));
20
20
  }
21
- function DialogContent({ className, children, showCloseButton = true, ...props }) {
22
- return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", className: cn('dialog-content', !showCloseButton && '*:data-radix-dialog-close:hidden', className), ...props, children: [children, _jsxs(DialogPrimitive.Close, { "data-slot": "dialog-close", className: "dialog-close", children: [_jsx(X, { className: "size-4" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] }));
21
+ function DialogContent({ className, children, showCloseButton = true, onInteractOutside, ...props }) {
22
+ return (_jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "data-slot": "dialog-content", className: cn('dialog-content', !showCloseButton && '*:data-radix-dialog-close:hidden', className), onInteractOutside: keepOpenOnToast(onInteractOutside), ...props, children: [children, _jsxs(DialogPrimitive.Close, { "data-slot": "dialog-close", className: "dialog-close", children: [_jsx(X, { className: "size-4" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] }));
23
23
  }
24
24
  function DialogHeader({ className, ...props }) {
25
25
  return (_jsx("div", { "data-slot": "dialog-header", className: cn('dialog-header', className), ...props }));
@@ -158,4 +158,163 @@ export declare const FileUpload: React.ForwardRefExoticComponent<{
158
158
  'aria-describedby'?: string;
159
159
  'aria-label'?: string;
160
160
  } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "className" | "disabled" | "type" | "value" | "onChange" | "onError" | "onSelect" | "accept" | "multiple"> & React.RefAttributes<HTMLInputElement>>;
161
+ /**
162
+ * A rejection from `MultipleFileUpload`: every rejection the single-file
163
+ * sibling can produce, plus the one only a plural selection has — the cap.
164
+ */
165
+ export type MultipleFileUploadError = FileUploadError | {
166
+ kind: 'too-many';
167
+ file: File;
168
+ maxFiles: number;
169
+ };
170
+ /** Overrides for the fixed English copy. Every field is optional. */
171
+ export interface MultipleFileUploadLabels {
172
+ /** Emphasised call to action in the empty zone. Defaults to "Choose files". */
173
+ action?: string;
174
+ /** Trailing hint after the action. Defaults to "or drag and drop". */
175
+ hint?: string;
176
+ /** Zone copy once `maxFiles` is reached. Receives the cap to interpolate. */
177
+ full?: (maxFiles: number) => string;
178
+ /**
179
+ * Accessible name of a row's remove control. Receives that row's file, so the
180
+ * name identifies it. Defaults to `Remove <filename>`.
181
+ */
182
+ remove?: (file: File) => string;
183
+ /**
184
+ * Copy for one rejection. Called once per rejection in a batch; use the
185
+ * exported `humanizeSize` to format `maxSizeBytes`. Return `null`,
186
+ * `undefined` or `''` to stay SILENT and leave the announcement to the host's
187
+ * own `onError` handling. A batch whose every message is silent renders no
188
+ * alert at all.
189
+ */
190
+ error?: (error: MultipleFileUploadError) => string | null | undefined;
191
+ }
192
+ export type MultipleFileUploadProps = {
193
+ /** Comma-separated accept filter. Applied to every file, extension or MIME. */
194
+ accept?: string;
195
+ /** Inclusive per-file byte ceiling. Applied to each file independently. */
196
+ maxSizeBytes?: number;
197
+ /** Ceiling on the TOTAL selection. Omitted means unbounded. */
198
+ maxFiles?: number;
199
+ /** Controlled selection. The host owns state; defaults to empty. */
200
+ value?: FileUploadResult[];
201
+ /**
202
+ * How each accepted file is handed over. `'text'` (default) decodes UTF-8
203
+ * and populates `text`; `'none'` skips decoding entirely and is the mode
204
+ * BINARY files need. See FileUpload's `readAs` for why.
205
+ */
206
+ readAs?: FileUploadReadAs;
207
+ /** Override the fixed English copy. Omitted fields keep their defaults. */
208
+ labels?: MultipleFileUploadLabels;
209
+ /** Fires with the WHOLE next selection whenever files are added or removed. */
210
+ onValueChange: (values: FileUploadResult[]) => void;
211
+ /** Fires once per rejected file. A batch can produce several. */
212
+ onError?: (error: MultipleFileUploadError) => void;
213
+ disabled?: boolean;
214
+ id?: string;
215
+ className?: string;
216
+ 'aria-invalid'?: boolean;
217
+ 'aria-required'?: boolean;
218
+ 'aria-describedby'?: string;
219
+ 'aria-label'?: string;
220
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'accept' | 'value' | 'disabled' | 'onChange' | 'onSelect' | 'className' | 'multiple' | 'onError'>;
221
+ /**
222
+ * MultipleFileUpload: the plural sibling of FileUpload. Pick SEVERAL files,
223
+ * accumulate them across repeated picks, validate each one, cap the total, and
224
+ * hand back `FileUploadResult[]`.
225
+ *
226
+ * A SIBLING COMPONENT, not a `multiple` flag. This library already answers
227
+ * "this one takes many" that way (`Select` / `MultipleSelect`), and FileUpload
228
+ * strips `'multiple'` from its props on purpose: single-file is its contract,
229
+ * not a default it happens to have. A boolean would have forced every prop
230
+ * here into a union that means one thing when the flag is set and another when
231
+ * it is not: `value` as `Result | Result[] | null`, a `maxFiles` that is
232
+ * meaningless in half the configurations, and a remove control whose
233
+ * accessible name is fixed copy in one mode and per-file in the other. The
234
+ * plural props follow the house shape for plural components: `value?: T[]`
235
+ * with `onValueChange?: (values: T[]) => void`.
236
+ *
237
+ * WHERE THE LINE SITS: this component owns SELECTION and nothing after it.
238
+ * Choosing, validating, capping, listing and removing are its job; uploading
239
+ * is not. That split is not squeamishness about scope, it is where the
240
+ * knowledge actually lives. An upload needs an endpoint, an auth scheme, a
241
+ * concurrency policy, a retry policy and, very often, a parent id that does
242
+ * not exist yet when the files are chosen: the motivating host stages evidence
243
+ * files while a form is being filled and can only upload them against the id
244
+ * that its create call returns afterwards. None of that is knowable from
245
+ * inside a library primitive, and a component that guessed would have to be
246
+ * fought rather than used. So the host keeps its own per-file record with
247
+ * status and retry, and this component keeps the part a form can hold and
248
+ * validate: the chosen files. `FileUploadResult[]` is a value; an upload state
249
+ * machine is not.
250
+ *
251
+ * ACCUMULATION is the defining behaviour. A second pick ADDS to the selection
252
+ * rather than replacing it, because a user assembling five documents does it
253
+ * in two or three trips to the file dialog, not one. Everything else follows
254
+ * from that: room is measured against what is already selected, and the batch
255
+ * that overflows the cap still contributes the files that fit.
256
+ *
257
+ * A BATCH SURVIVES ITS OWN CASUALTIES. One file rejected for type, size or a
258
+ * failed read does not discard the rest of the batch, and it does not consume
259
+ * a slot either: validation runs over the WHOLE batch before the cap is
260
+ * applied, so a file that was never eligible cannot cost an eligible one its
261
+ * place, and `'too-many'` always names a file a slot would genuinely have
262
+ * taken. The alternative punishes
263
+ * a user for a mistake in one file by throwing away four good ones, and hands
264
+ * back no way to tell which was which. Every rejection is reported through
265
+ * `onError` and announced together in one `role="alert"`.
266
+ *
267
+ * Accessibility follows the sibling BELOW THE CAP: the real `<input
268
+ * type="file">` is `sr-only` but focusable and labelable, and never
269
+ * `aria-hidden`, so FormControl-injected ARIA and react-hook-form's focus on
270
+ * error both work while the picker is enabled. At the cap that changes, and
271
+ * the paragraph below says how.
272
+ * The file list sits OUTSIDE the click zone, so activating a remove control
273
+ * cannot also reopen the picker, and each remove control is named after its
274
+ * own file: a column of identical "Remove file" buttons tells a screen-reader
275
+ * user nothing about which row they are on.
276
+ *
277
+ * AT THE CAP the picker takes the native `disabled` attribute, and that DOES
278
+ * take it out of the tab order. This is the one state in which the input is
279
+ * not a focus target, and the one state in which focus-on-error cannot land on
280
+ * it, so it is a real cost rather than a free win. The cap has no counterpart
281
+ * in the single-file sibling, so the precedent followed here is
282
+ * `DateRangePicker`'s trigger: a control whose only job is to open a dialog has
283
+ * no state worth keeping focusable, and native `disabled` is what both removes
284
+ * it from the tab order and keeps the dialog shut. The alternative, an enabled
285
+ * picker that opens the file dialog and then refuses every file with
286
+ * `too-many`, is a control that lies about being available. What keeps the cap
287
+ * from being a dead end is the escape hatch: the remove controls answer to
288
+ * `disabled` alone and NEVER to the cap, so they stay focusable and removing
289
+ * one file reopens the picker.
290
+ */
291
+ export declare const MultipleFileUpload: React.ForwardRefExoticComponent<{
292
+ /** Comma-separated accept filter. Applied to every file, extension or MIME. */
293
+ accept?: string;
294
+ /** Inclusive per-file byte ceiling. Applied to each file independently. */
295
+ maxSizeBytes?: number;
296
+ /** Ceiling on the TOTAL selection. Omitted means unbounded. */
297
+ maxFiles?: number;
298
+ /** Controlled selection. The host owns state; defaults to empty. */
299
+ value?: FileUploadResult[];
300
+ /**
301
+ * How each accepted file is handed over. `'text'` (default) decodes UTF-8
302
+ * and populates `text`; `'none'` skips decoding entirely and is the mode
303
+ * BINARY files need. See FileUpload's `readAs` for why.
304
+ */
305
+ readAs?: FileUploadReadAs;
306
+ /** Override the fixed English copy. Omitted fields keep their defaults. */
307
+ labels?: MultipleFileUploadLabels;
308
+ /** Fires with the WHOLE next selection whenever files are added or removed. */
309
+ onValueChange: (values: FileUploadResult[]) => void;
310
+ /** Fires once per rejected file. A batch can produce several. */
311
+ onError?: (error: MultipleFileUploadError) => void;
312
+ disabled?: boolean;
313
+ id?: string;
314
+ className?: string;
315
+ 'aria-invalid'?: boolean;
316
+ 'aria-required'?: boolean;
317
+ 'aria-describedby'?: string;
318
+ 'aria-label'?: string;
319
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "className" | "disabled" | "type" | "value" | "onChange" | "onError" | "onSelect" | "accept" | "multiple"> & React.RefAttributes<HTMLInputElement>>;
161
320
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/file-upload/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3D,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAA;AAEvC,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sEAA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B;;;;OAIG;aACM,gBAAgB;IACzB,2EAA2E;aAClE,wBAAwB;IACjC,+EAA+E;mBAChE,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,IAAI;IACnD,iEAAiE;cACvD,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI;eACvC,OAAO;SACb,MAAM;gBACC,MAAM;qBACD,OAAO;sBACN,OAAO;yBACJ,MAAM;mBACZ,MAAM;yMAkdrB,CAAA"}
@@ -188,10 +188,18 @@ export const FileUpload = React.forwardRef(function FileUpload({ accept, maxSize
188
188
  event.target.value = '';
189
189
  handleFile(file);
190
190
  };
191
+ // `preventDefault` FIRST, and unconditionally. Returning before it does
192
+ // not merely refuse the drop: nothing cancels the browser's OWN action for
193
+ // a dropped file, so the window navigates to the file and whatever the
194
+ // page held unsaved is gone. A zone the host turned off has to swallow the
195
+ // drop, never hand it back to the browser. `dropEffect` says so to the
196
+ // cursor while the file is still in the air.
191
197
  const onDragOver = (event) => {
192
- if (disabled)
193
- return;
194
198
  event.preventDefault();
199
+ if (disabled) {
200
+ event.dataTransfer.dropEffect = 'none';
201
+ return;
202
+ }
195
203
  setDragActive(true);
196
204
  };
197
205
  const onDragLeave = (event) => {
@@ -199,10 +207,13 @@ export const FileUpload = React.forwardRef(function FileUpload({ accept, maxSize
199
207
  setDragActive(false);
200
208
  };
201
209
  const onDrop = (event) => {
202
- if (disabled)
203
- return;
204
210
  event.preventDefault();
211
+ // Cleared before the gate, not after, so a host that disables the zone
212
+ // mid-drag does not leave it highlighted for a drag that can no longer
213
+ // land.
205
214
  setDragActive(false);
215
+ if (disabled)
216
+ return;
206
217
  handleFile(event.dataTransfer.files?.[0]);
207
218
  };
208
219
  // Mouse convenience only: clicking the styled zone opens the picker. A
@@ -222,7 +233,7 @@ export const FileUpload = React.forwardRef(function FileUpload({ accept, maxSize
222
233
  if (internalRef.current)
223
234
  internalRef.current.value = '';
224
235
  };
225
- return (_jsxs("div", { className: cn('space-y-2', className), children: [_jsxs("div", { onClick: openPicker, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, className: cn('border-input bg-card focus-within:ring-ring focus-within:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-within:ring-destructive flex w-full items-center gap-3 rounded-md border px-3 py-4 text-sm shadow-xs transition-colors focus-within:ring-2 focus-within:ring-offset-1 focus-within:outline-none', dragActive &&
236
+ return (_jsxs("div", { className: cn('space-y-2', className), children: [_jsxs("div", { onClick: openPicker, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, className: cn('border-input-border bg-card focus-within:ring-ring focus-within:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-within:ring-destructive flex w-full items-center gap-3 rounded-md border px-3 py-4 text-sm shadow-xs transition-colors focus-within:ring-2 focus-within:ring-offset-1 focus-within:outline-none', dragActive &&
226
237
  'border-ring ring-ring ring-offset-background ring-2 ring-offset-1', disabled
227
238
  ? 'border-muted bg-muted/30 cursor-not-allowed shadow-none'
228
239
  : 'cursor-pointer'), "aria-invalid": invalid || undefined, children: [_jsx("input", { ref: internalRef, id: inputId, type: "file", accept: accept, disabled: disabled, className: "sr-only", "aria-invalid": invalid || undefined, "aria-required": ariaRequired || undefined, "aria-describedby": describedBy, "aria-label": ariaLabel, onChange: onInputChange, ...rest }), _jsx(Upload, { className: "text-muted-foreground size-4 shrink-0", "aria-hidden": "true" }), value ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "min-w-0 flex-1 truncate", children: [_jsx("span", { className: "text-foreground font-medium", children: value.file.name }), ' ', _jsx("span", { className: "text-muted-foreground tabular-nums", children: humanizeSize(value.file.size) })] }), _jsx(IconButton, { type: "button", variant: "plain", size: "small", disabled: disabled, "aria-label": labels?.remove?.trim() ? labels.remove : 'Remove file', onClick: (event) => {
@@ -232,3 +243,294 @@ export const FileUpload = React.forwardRef(function FileUpload({ accept, maxSize
232
243
  }, children: _jsx(X, { className: "size-4", "aria-hidden": "true" }) })] })) : (_jsxs("span", { className: "text-muted-foreground", children: [_jsx("span", { className: "text-foreground font-medium", children: labels?.action ?? 'Choose a file' }), ' ', labels?.hint ?? 'or drag and drop'] }))] }), errorText ? (_jsx("p", { id: errorId, role: "alert", className: "text-system-error-h1a text-xs font-medium", children: errorText })) : null] }));
233
244
  });
234
245
  FileUpload.displayName = 'FileUpload';
246
+ /** The default English announcement for each rejection kind. */
247
+ function defaultMultipleErrorMessage(error) {
248
+ if (error.kind === 'too-many') {
249
+ return `Too many files (max ${error.maxFiles}). ${error.file.name} was not added.`;
250
+ }
251
+ return defaultErrorMessage(error);
252
+ }
253
+ /** The default zone copy once the cap is reached, in grammatical English. */
254
+ function defaultFullMessage(maxFiles) {
255
+ return maxFiles === 1
256
+ ? 'Maximum of 1 file reached.'
257
+ : `Maximum of ${maxFiles} files reached.`;
258
+ }
259
+ /**
260
+ * MultipleFileUpload: the plural sibling of FileUpload. Pick SEVERAL files,
261
+ * accumulate them across repeated picks, validate each one, cap the total, and
262
+ * hand back `FileUploadResult[]`.
263
+ *
264
+ * A SIBLING COMPONENT, not a `multiple` flag. This library already answers
265
+ * "this one takes many" that way (`Select` / `MultipleSelect`), and FileUpload
266
+ * strips `'multiple'` from its props on purpose: single-file is its contract,
267
+ * not a default it happens to have. A boolean would have forced every prop
268
+ * here into a union that means one thing when the flag is set and another when
269
+ * it is not: `value` as `Result | Result[] | null`, a `maxFiles` that is
270
+ * meaningless in half the configurations, and a remove control whose
271
+ * accessible name is fixed copy in one mode and per-file in the other. The
272
+ * plural props follow the house shape for plural components: `value?: T[]`
273
+ * with `onValueChange?: (values: T[]) => void`.
274
+ *
275
+ * WHERE THE LINE SITS: this component owns SELECTION and nothing after it.
276
+ * Choosing, validating, capping, listing and removing are its job; uploading
277
+ * is not. That split is not squeamishness about scope, it is where the
278
+ * knowledge actually lives. An upload needs an endpoint, an auth scheme, a
279
+ * concurrency policy, a retry policy and, very often, a parent id that does
280
+ * not exist yet when the files are chosen: the motivating host stages evidence
281
+ * files while a form is being filled and can only upload them against the id
282
+ * that its create call returns afterwards. None of that is knowable from
283
+ * inside a library primitive, and a component that guessed would have to be
284
+ * fought rather than used. So the host keeps its own per-file record with
285
+ * status and retry, and this component keeps the part a form can hold and
286
+ * validate: the chosen files. `FileUploadResult[]` is a value; an upload state
287
+ * machine is not.
288
+ *
289
+ * ACCUMULATION is the defining behaviour. A second pick ADDS to the selection
290
+ * rather than replacing it, because a user assembling five documents does it
291
+ * in two or three trips to the file dialog, not one. Everything else follows
292
+ * from that: room is measured against what is already selected, and the batch
293
+ * that overflows the cap still contributes the files that fit.
294
+ *
295
+ * A BATCH SURVIVES ITS OWN CASUALTIES. One file rejected for type, size or a
296
+ * failed read does not discard the rest of the batch, and it does not consume
297
+ * a slot either: validation runs over the WHOLE batch before the cap is
298
+ * applied, so a file that was never eligible cannot cost an eligible one its
299
+ * place, and `'too-many'` always names a file a slot would genuinely have
300
+ * taken. The alternative punishes
301
+ * a user for a mistake in one file by throwing away four good ones, and hands
302
+ * back no way to tell which was which. Every rejection is reported through
303
+ * `onError` and announced together in one `role="alert"`.
304
+ *
305
+ * Accessibility follows the sibling BELOW THE CAP: the real `<input
306
+ * type="file">` is `sr-only` but focusable and labelable, and never
307
+ * `aria-hidden`, so FormControl-injected ARIA and react-hook-form's focus on
308
+ * error both work while the picker is enabled. At the cap that changes, and
309
+ * the paragraph below says how.
310
+ * The file list sits OUTSIDE the click zone, so activating a remove control
311
+ * cannot also reopen the picker, and each remove control is named after its
312
+ * own file: a column of identical "Remove file" buttons tells a screen-reader
313
+ * user nothing about which row they are on.
314
+ *
315
+ * AT THE CAP the picker takes the native `disabled` attribute, and that DOES
316
+ * take it out of the tab order. This is the one state in which the input is
317
+ * not a focus target, and the one state in which focus-on-error cannot land on
318
+ * it, so it is a real cost rather than a free win. The cap has no counterpart
319
+ * in the single-file sibling, so the precedent followed here is
320
+ * `DateRangePicker`'s trigger: a control whose only job is to open a dialog has
321
+ * no state worth keeping focusable, and native `disabled` is what both removes
322
+ * it from the tab order and keeps the dialog shut. The alternative, an enabled
323
+ * picker that opens the file dialog and then refuses every file with
324
+ * `too-many`, is a control that lies about being available. What keeps the cap
325
+ * from being a dead end is the escape hatch: the remove controls answer to
326
+ * `disabled` alone and NEVER to the cap, so they stay focusable and removing
327
+ * one file reopens the picker.
328
+ */
329
+ export const MultipleFileUpload = React.forwardRef(function MultipleFileUpload({ accept, maxSizeBytes, maxFiles, value = [], readAs = 'text', labels, onValueChange, onError, disabled = false, id, className, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, 'aria-describedby': ariaDescribedby, 'aria-label': ariaLabel, ...rest }, ref) {
330
+ const internalRef = React.useRef(null);
331
+ React.useImperativeHandle(ref, () => internalRef.current);
332
+ const reactId = React.useId();
333
+ const inputId = id ?? reactId;
334
+ const errorId = `${inputId}-file-upload-error`;
335
+ const [dragActive, setDragActive] = React.useState(false);
336
+ const [errors, setErrors] = React.useState([]);
337
+ // The authoritative base for the next append. Props win on every render, so
338
+ // the host stays in control; the commit below also writes through, so a
339
+ // second batch that settles before the host has re-rendered still appends to
340
+ // the first batch's result instead of overwriting it.
341
+ const valueRef = React.useRef(value);
342
+ React.useEffect(() => {
343
+ valueRef.current = value;
344
+ });
345
+ // Superseding is NOT the contract here the way it is in the single-file
346
+ // sibling — batches accumulate, so an in-flight read is never stale. The
347
+ // readers are tracked for the one case that does have to stop them: an
348
+ // unmount. A read that lands afterwards would settle its batch and commit,
349
+ // calling the host's `onValueChange` for a component that no longer exists.
350
+ const readersRef = React.useRef(new Set());
351
+ React.useEffect(() => () => {
352
+ for (const reader of readersRef.current)
353
+ reader.abort();
354
+ readersRef.current.clear();
355
+ }, []);
356
+ const invalid = ariaInvalid || errors.length > 0;
357
+ // Resolve the announcements BEFORE deciding whether the alert exists: a
358
+ // consumer that returns nothing for every rejection is opting out of this
359
+ // surface, and an association pointing at an unrendered node is worse than
360
+ // none.
361
+ const messages = errors
362
+ .map((failure) => labels?.error
363
+ ? labels.error(failure)
364
+ : defaultMultipleErrorMessage(failure))
365
+ .filter((message) => Boolean(message));
366
+ // A plain join, never `cn`: tailwind-merge treats these as class names and
367
+ // would drop an id that happens to look like a conflicting utility.
368
+ const describedBy = [ariaDescribedby, messages.length > 0 ? errorId : undefined]
369
+ .filter(Boolean)
370
+ .join(' ') || undefined;
371
+ const full = maxFiles !== undefined && value.length >= maxFiles;
372
+ // Removing must stay possible at the cap, so only the PICKER closes.
373
+ const pickerDisabled = disabled || full;
374
+ const roomFor = (selected) => maxFiles === undefined
375
+ ? Number.POSITIVE_INFINITY
376
+ : Math.max(maxFiles - selected, 0);
377
+ // The cap is enforced HERE, at the only place that appends, because only the
378
+ // commit knows the base it lands on. `ingest` measures room too, but for an
379
+ // asynchronous batch it measures it BEFORE any read settles: two overlapping
380
+ // batches both see the pre-commit selection and would each believe they fit.
381
+ const commit = (accepted, rejections) => {
382
+ const room = roomFor(valueRef.current.length);
383
+ const fitting = accepted.slice(0, room);
384
+ const overflow = accepted[room];
385
+ const failures = overflow !== undefined && maxFiles !== undefined
386
+ ? [
387
+ ...rejections,
388
+ { kind: 'too-many', file: overflow.file, maxFiles }
389
+ ]
390
+ : rejections;
391
+ setErrors(failures);
392
+ for (const rejection of failures)
393
+ onError?.(rejection);
394
+ if (fitting.length === 0)
395
+ return;
396
+ const next = [...valueRef.current, ...fitting];
397
+ valueRef.current = next;
398
+ onValueChange(next);
399
+ };
400
+ const ingest = (incoming) => {
401
+ if (incoming.length === 0)
402
+ return;
403
+ const room = roomFor(valueRef.current.length);
404
+ const rejections = [];
405
+ // Validate EVERY file BEFORE the cap is applied. Slicing to the remaining
406
+ // room first would let a file that was never eligible consume a slot a
407
+ // good file could have used — one bad pick costing a good one, which is
408
+ // the opposite of a batch surviving its own casualties — and it would
409
+ // leave every file past the slice window neither validated nor reported.
410
+ // Validation is pure metadata (size and accept), so running it over files
411
+ // that may not fit costs nothing.
412
+ const eligible = [];
413
+ for (const file of incoming) {
414
+ const rejection = validateFile(file, { accept, maxSizeBytes });
415
+ // Continue rather than abort: one bad file must not cost the good ones.
416
+ if (rejection) {
417
+ rejections.push(rejection);
418
+ continue;
419
+ }
420
+ eligible.push(file);
421
+ }
422
+ // The cap then applies to the SURVIVORS. One rejection for the batch,
423
+ // naming the FIRST eligible file that did not fit: naming one already
424
+ // refused for its size or type would blame the cap for the wrong thing,
425
+ // and repeating it per overflowing file buries the actionable part.
426
+ if (eligible.length > room && maxFiles !== undefined) {
427
+ rejections.push({ kind: 'too-many', file: eligible[room], maxFiles });
428
+ }
429
+ const candidates = eligible.slice(0, room);
430
+ // Binary path: no decode, no reader, no retained garbage string.
431
+ if (readAs === 'none') {
432
+ commit(candidates.map((file) => ({ file, text: '' })), rejections);
433
+ return;
434
+ }
435
+ if (candidates.length === 0) {
436
+ commit([], rejections);
437
+ return;
438
+ }
439
+ // Slot-per-candidate so the emitted batch keeps PICK order regardless of
440
+ // the order the reads settle in. A null slot is a read that failed; the
441
+ // batch commits once every read has settled, one way or the other.
442
+ const slots = new Array(candidates.length).fill(null);
443
+ let remaining = candidates.length;
444
+ const settle = () => {
445
+ remaining -= 1;
446
+ if (remaining > 0)
447
+ return;
448
+ const accepted = [];
449
+ const readFailures = [];
450
+ slots.forEach((slot, index) => {
451
+ if (slot)
452
+ accepted.push(slot);
453
+ else
454
+ readFailures.push({ kind: 'read-failed', file: candidates[index] });
455
+ });
456
+ commit(accepted, [...rejections, ...readFailures]);
457
+ };
458
+ candidates.forEach((file, index) => {
459
+ const reader = new FileReader();
460
+ readersRef.current.add(reader);
461
+ // Deliberately no `onabort` handler: an aborted read must NOT settle,
462
+ // or the batch would commit at exactly the moment we are stopping it.
463
+ reader.onload = () => {
464
+ readersRef.current.delete(reader);
465
+ slots[index] = { file, text: String(reader.result ?? '') };
466
+ settle();
467
+ };
468
+ reader.onerror = () => {
469
+ readersRef.current.delete(reader);
470
+ settle();
471
+ };
472
+ reader.readAsText(file);
473
+ });
474
+ };
475
+ const onInputChange = (event) => {
476
+ const files = Array.from(event.target.files ?? []);
477
+ // Release the FileList the moment it has been read, or re-picking the same
478
+ // file is silently a no-op: the browser fires `change` only when the
479
+ // selection DIFFERS from what the input already holds.
480
+ event.target.value = '';
481
+ ingest(files);
482
+ };
483
+ // `preventDefault` FIRST, and unconditionally. Returning before it does
484
+ // not merely refuse the drop: nothing cancels the browser's OWN action for
485
+ // a dropped file, so the window navigates to the file and whatever the
486
+ // page held unsaved is gone. A zone the host turned off has to swallow the
487
+ // drop, never hand it back to the browser. `dropEffect` says so to the
488
+ // cursor while the file is still in the air.
489
+ const onDragOver = (event) => {
490
+ event.preventDefault();
491
+ if (disabled) {
492
+ event.dataTransfer.dropEffect = 'none';
493
+ return;
494
+ }
495
+ setDragActive(true);
496
+ };
497
+ const onDragLeave = (event) => {
498
+ event.preventDefault();
499
+ setDragActive(false);
500
+ };
501
+ const onDrop = (event) => {
502
+ event.preventDefault();
503
+ // Cleared before the gate, not after, so a host that disables the zone
504
+ // mid-drag does not leave it highlighted for a drag that can no longer
505
+ // land.
506
+ setDragActive(false);
507
+ if (disabled)
508
+ return;
509
+ // Deliberately NOT gated on `full`: a drop onto a full zone is answered
510
+ // with the too-many rejection, which says why, instead of nothing at all.
511
+ ingest(Array.from(event.dataTransfer.files ?? []));
512
+ };
513
+ // Mouse convenience only. A click that ORIGINATED on the input already opens
514
+ // the picker natively and bubbles up here, so ignore it or it opens twice.
515
+ const openPicker = (event) => {
516
+ if (pickerDisabled || event.target === internalRef.current)
517
+ return;
518
+ internalRef.current?.click();
519
+ };
520
+ const removeAt = (index) => {
521
+ // By index, not by name: two files can share a filename and identity is
522
+ // what the row actually stands for.
523
+ const next = valueRef.current.filter((_, position) => position !== index);
524
+ valueRef.current = next;
525
+ onValueChange(next);
526
+ };
527
+ return (_jsxs("div", { className: cn('space-y-2', className), children: [_jsxs("div", { onClick: openPicker, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, className: cn('border-input-border bg-card focus-within:ring-ring focus-within:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-within:ring-destructive flex w-full items-center gap-3 rounded-md border px-3 py-4 text-sm shadow-xs transition-colors focus-within:ring-2 focus-within:ring-offset-1 focus-within:outline-none', dragActive &&
528
+ 'border-ring ring-ring ring-offset-background ring-2 ring-offset-1', pickerDisabled
529
+ ? 'border-muted bg-muted/30 cursor-not-allowed shadow-none'
530
+ : 'cursor-pointer'), "aria-invalid": invalid || undefined, children: [_jsx("input", { ref: internalRef, id: inputId, type: "file", multiple: true, accept: accept, disabled: pickerDisabled, className: "sr-only", "aria-invalid": invalid || undefined, "aria-required": ariaRequired || undefined, "aria-describedby": describedBy, "aria-label": ariaLabel, onChange: onInputChange, ...rest }), _jsx(Upload, { className: "text-muted-foreground size-4 shrink-0", "aria-hidden": "true" }), full && maxFiles !== undefined ? (_jsx("span", { className: "text-muted-foreground", children: labels?.full
531
+ ? labels.full(maxFiles)
532
+ : defaultFullMessage(maxFiles) })) : (_jsxs("span", { className: "text-muted-foreground", children: [_jsx("span", { className: "text-foreground font-medium", children: labels?.action ?? 'Choose files' }), ' ', labels?.hint ?? 'or drag and drop'] }))] }), value.length > 0 ? (_jsx("ul", { className: "space-y-1", children: value.map((entry, index) => (_jsxs("li", { className: "flex items-center gap-3 text-sm", children: [_jsxs("span", { className: "min-w-0 flex-1 truncate", children: [_jsx("span", { className: "text-foreground font-medium", children: entry.file.name }), ' ', _jsx("span", { className: "text-muted-foreground tabular-nums", children: humanizeSize(entry.file.size) })] }), _jsx(IconButton, { type: "button", variant: "plain", size: "small", disabled: disabled, "aria-label": labels?.remove
533
+ ? labels.remove(entry.file)
534
+ : `Remove ${entry.file.name}`, onClick: () => removeAt(index), children: _jsx(X, { className: "size-4", "aria-hidden": "true" }) })] }, `${entry.file.name}-${index}`))) })) : null, messages.length > 0 ? (_jsx("div", { id: errorId, role: "alert", className: "space-y-1", children: messages.map((message, index) => (_jsx("p", { className: "text-system-error-h1a text-xs font-medium", children: message }, index))) })) : null] }));
535
+ });
536
+ MultipleFileUpload.displayName = 'MultipleFileUpload';