@allxsmith/bestax-bulma 5.54.1 → 5.55.0

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 (74) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Command.js +22 -22
  4. package/dist/esm/components/Command.js.map +1 -1
  5. package/dist/esm/components/DataTable.js +215 -0
  6. package/dist/esm/components/DataTable.js.map +1 -0
  7. package/dist/esm/components/useDataTable.js +482 -0
  8. package/dist/esm/components/useDataTable.js.map +1 -0
  9. package/dist/esm/elements/ColorSwatch.js +49 -0
  10. package/dist/esm/elements/ColorSwatch.js.map +1 -0
  11. package/dist/esm/elements/RingProgress.js +3 -3
  12. package/dist/esm/elements/Td.js +4 -2
  13. package/dist/esm/elements/Td.js.map +1 -1
  14. package/dist/esm/elements/Th.js +13 -5
  15. package/dist/esm/elements/Th.js.map +1 -1
  16. package/dist/esm/elements/Tr.js.map +1 -1
  17. package/dist/esm/form/ColorPicker.js +540 -0
  18. package/dist/esm/form/ColorPicker.js.map +1 -0
  19. package/dist/esm/form/Combobox.js +18 -18
  20. package/dist/esm/form/Combobox.js.map +1 -1
  21. package/dist/esm/form/Dropzone.js +524 -0
  22. package/dist/esm/form/Dropzone.js.map +1 -0
  23. package/dist/esm/form/_colorInternals/colorMath.js +292 -0
  24. package/dist/esm/form/_colorInternals/colorMath.js.map +1 -0
  25. package/dist/esm/form/_colorInternals/pickerState.js +160 -0
  26. package/dist/esm/form/_colorInternals/pickerState.js.map +1 -0
  27. package/dist/esm/helpers/statusRegion.js +3 -3
  28. package/dist/esm/helpers/statusRegion.js.map +1 -1
  29. package/dist/esm/helpers/useFocusTrap.js +2 -2
  30. package/dist/extras.css +1 -1
  31. package/dist/extras.css.map +1 -1
  32. package/dist/index.cjs +2986 -796
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.esm.js +5 -0
  35. package/dist/index.esm.js.map +1 -1
  36. package/dist/types/components/DataTable.d.ts +120 -0
  37. package/dist/types/components/useDataTable.d.ts +445 -0
  38. package/dist/types/elements/ColorSwatch.d.ts +54 -0
  39. package/dist/types/elements/Td.d.ts +9 -1
  40. package/dist/types/elements/Th.d.ts +14 -2
  41. package/dist/types/elements/Tr.d.ts +10 -1
  42. package/dist/types/form/ColorPicker.d.ts +266 -0
  43. package/dist/types/form/Dropzone.d.ts +138 -0
  44. package/dist/types/form/_colorInternals/colorMath.d.ts +63 -0
  45. package/dist/types/form/_colorInternals/pickerState.d.ts +62 -0
  46. package/dist/types/index.d.ts +4 -0
  47. package/dist/types-cjs/components/DataTable.d.ts +120 -0
  48. package/dist/types-cjs/components/useDataTable.d.ts +445 -0
  49. package/dist/types-cjs/elements/ColorSwatch.d.ts +54 -0
  50. package/dist/types-cjs/elements/Td.d.ts +9 -1
  51. package/dist/types-cjs/elements/Th.d.ts +14 -2
  52. package/dist/types-cjs/elements/Tr.d.ts +10 -1
  53. package/dist/types-cjs/form/ColorPicker.d.ts +266 -0
  54. package/dist/types-cjs/form/Dropzone.d.ts +138 -0
  55. package/dist/types-cjs/form/_colorInternals/colorMath.d.ts +63 -0
  56. package/dist/types-cjs/form/_colorInternals/pickerState.d.ts +62 -0
  57. package/dist/types-cjs/index.d.ts +4 -0
  58. package/dist/versions/bestax-no-dark-mode.css +1 -1
  59. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  60. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  61. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  62. package/dist/versions/bestax-no-helpers.css +1 -1
  63. package/dist/versions/bestax-no-helpers.css.map +1 -1
  64. package/dist/versions/bestax-prefixed.css +1 -1
  65. package/dist/versions/bestax-prefixed.css.map +1 -1
  66. package/package.json +1 -1
  67. package/src/scss/components/_datatable.scss +152 -0
  68. package/src/scss/components/_index.scss +1 -0
  69. package/src/scss/elements/_colorswatch.scss +100 -0
  70. package/src/scss/elements/_index.scss +1 -0
  71. package/src/scss/form/_checkbox.scss +53 -0
  72. package/src/scss/form/_colorpicker.scss +354 -0
  73. package/src/scss/form/_dropzone.scss +233 -0
  74. package/src/scss/form/_index.scss +2 -0
@@ -0,0 +1,524 @@
1
+ /* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import { forwardRef, useState, useReducer, useRef, useCallback, useEffect, useId } from 'react';
4
+ import { usePrefixedClassNames, classNames, prefixedClassNames } from '../helpers/classNames.js';
5
+ import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
6
+ import { useConfig } from '../helpers/Config.js';
7
+ import { useNumberFormat } from '../helpers/localeFormat.js';
8
+ import { StatusRegion } from '../helpers/statusRegion.js';
9
+ import { warnOnce } from '../helpers/devWarnings.js';
10
+ import { Delete } from '../elements/Delete.js';
11
+ import { useFieldsetDisabled, useInsideField, useInsideControl, rendersOwnField } from './FormContext.js';
12
+ import { Field } from './Field.js';
13
+ import { useAutoLabelId } from './useAutoLabelId.js';
14
+
15
+ const noFiles = [];
16
+ const noRefusals = [];
17
+ const noAnnouncements = [];
18
+ const describeAnnouncement = (announcement) => announcement.text;
19
+ /**
20
+ * The tokens of an `accept` attribute that HTML recognizes, lowercased: an
21
+ * extension (`.pdf`), a wildcard (`image/*`) or a MIME type. Others are
22
+ * ignored, as browsers ignore them.
23
+ */
24
+ const acceptTokens = (accept) => (accept ?? '')
25
+ .split(',')
26
+ .map(token => token.trim().toLowerCase())
27
+ .filter(token => token.length > 1 && (token[0] === '.' || token.includes('/')));
28
+ /** Whether `accept`'s tokens take a file with this name and type. */
29
+ const accepts = (tokens, name, type) => {
30
+ if (tokens.length === 0)
31
+ return true;
32
+ const lowerName = name.toLowerCase();
33
+ const lowerType = type.toLowerCase();
34
+ return tokens.some(token => token[0] === '.'
35
+ ? lowerName.endsWith(token)
36
+ : token.endsWith('/*')
37
+ ? lowerType.startsWith(token.slice(0, -1))
38
+ : lowerType === token);
39
+ };
40
+ /** Whether a drag or a clipboard carries files. */
41
+ const carriesFiles = (data) => !!data && Array.from(data.types ?? []).includes('Files');
42
+ /** The files a drop or a paste brings, with folders marked. */
43
+ const incomingFrom = (data) => {
44
+ if (!data)
45
+ return [];
46
+ const items = Array.from(data.items ?? []).filter(item => item.kind === 'file');
47
+ if (items.length === 0) {
48
+ return Array.from(data.files ?? [], file => ({ file, folder: false }));
49
+ }
50
+ const incoming = [];
51
+ for (const item of items) {
52
+ const file = item.getAsFile();
53
+ if (!file)
54
+ continue;
55
+ const entry = item.webkitGetAsEntry?.();
56
+ incoming.push({ file, folder: !!entry?.isDirectory });
57
+ }
58
+ return incoming;
59
+ };
60
+ /** The same file: one object, or one picked again with the same details. */
61
+ const sameFile = (a, b) => a === b ||
62
+ (a.name === b.name && a.size === b.size && a.lastModified === b.lastModified);
63
+ /** Whether two lists hold the same files in the same order. */
64
+ const sameFiles = (a, b) => !!a && a.length === b.length && b.every((file, i) => sameFile(a[i], file));
65
+ /**
66
+ * Writes files to a file input, through a `DataTransfer`, the one way script
67
+ * can build a `FileList`. Where there's no `DataTransfer` the input is left as
68
+ * it is.
69
+ */
70
+ const writeFiles = (input, files) => {
71
+ if (typeof DataTransfer !== 'function')
72
+ return;
73
+ const transfer = new DataTransfer();
74
+ for (const file of files)
75
+ transfer.items.add(file);
76
+ input.files = transfer.files;
77
+ };
78
+ /** The units a file size is written in, largest first. */
79
+ const sizeUnits = [
80
+ ['gigabyte', 1e9, 'GB'],
81
+ ['megabyte', 1e6, 'MB'],
82
+ ['kilobyte', 1e3, 'kB'],
83
+ ];
84
+ /**
85
+ * A file size for display, in decimal units ("1.2 MB"), in the locale of a
86
+ * `LocaleProvider` around it, or as English writes it outside one.
87
+ */
88
+ const formatFileSize = (bytes, formatNumber) => {
89
+ for (const [unit, factor, symbol] of sizeUnits) {
90
+ if (bytes >= factor) {
91
+ const value = bytes / factor;
92
+ return formatNumber
93
+ ? formatNumber(value, {
94
+ style: 'unit',
95
+ unit,
96
+ unitDisplay: 'short',
97
+ maximumFractionDigits: 1,
98
+ })
99
+ : `${Math.round(value * 10) / 10} ${symbol}`;
100
+ }
101
+ }
102
+ return formatNumber
103
+ ? formatNumber(bytes, { style: 'unit', unit: 'byte', unitDisplay: 'long' })
104
+ : `${bytes} ${bytes === 1 ? 'byte' : 'bytes'}`;
105
+ };
106
+ /** A word for each kind of file `accept` names: "PDF", "image". */
107
+ const typeNames = (tokens) => {
108
+ const names = [];
109
+ for (const token of tokens) {
110
+ let name = token;
111
+ if (token[0] === '.') {
112
+ name = token.slice(1).toUpperCase();
113
+ }
114
+ else {
115
+ const [type, subtype] = token.split('/');
116
+ const core = subtype.split('+')[0];
117
+ if (subtype === '*')
118
+ name = type;
119
+ else if (core === 'plain')
120
+ name = 'text';
121
+ else if (/^[a-z0-9]+$/.test(core))
122
+ name = core.toUpperCase();
123
+ }
124
+ if (!names.includes(name))
125
+ names.push(name);
126
+ }
127
+ return names;
128
+ };
129
+ /** "A", "A or B", "A, B, or C". */
130
+ const orList = (items) => items.length <= 2
131
+ ? items.join(' or ')
132
+ : `${items.slice(0, -1).join(', ')}, or ${items[items.length - 1]}`;
133
+ /**
134
+ * The `Dropzone` component is an area to drop files on or click to pick
135
+ * them, which checks each file and lists the chosen ones with a way to remove
136
+ * each.
137
+ *
138
+ * It's Bulma's boxed, full-width file widget with the real
139
+ * `<input type="file">` lying over it, so the input is the one tab stop, the
140
+ * click target and the drop target, and Enter and Space open the picker. The
141
+ * input holds the chosen files: a pick, drop or paste that passes the checks
142
+ * is written to it, so a form submits the files under `name`. It doesn't
143
+ * upload anything.
144
+ *
145
+ * @function
146
+ * @param {DropzoneProps} props - Props for the Dropzone component.
147
+ * @returns {JSX.Element} The rendered dropzone.
148
+ *
149
+ * @example
150
+ * <Dropzone
151
+ * label="CV"
152
+ * name="cv"
153
+ * accept=".pdf,application/pdf"
154
+ * maxSize={5_000_000}
155
+ * hint="PDF up to 5 MB"
156
+ * />
157
+ */
158
+ const Dropzone = forwardRef(({
159
+ // Field props
160
+ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, color, size, buttonLabel, icon, hint, maxSize, maxFiles, files: filesProp, onFilesChange, onReject, showFileList = true, allowPaste = true, preventDocumentDrop = true, removeLabel, rejectionMessage, addedMessage, removedMessage, className, accept, multiple, disabled: disabledProp, onChange, onClick, onDragEnter, onDragOver, onDragLeave, onDrop, onPaste, 'aria-describedby': ariaDescribedBy, ...props }, ref) => {
161
+ const disabled = useFieldsetDisabled(disabledProp);
162
+ const controlled = filesProp !== undefined;
163
+ const [ownFiles, setOwnFiles] = useState(noFiles);
164
+ const files = filesProp ?? ownFiles;
165
+ // A render the controlled list needs after a change, so that one the app
166
+ // didn't take is undone.
167
+ const [, rerender] = useReducer((n) => n + 1, 0);
168
+ const [refusals, setRefusals] = useState(noRefusals);
169
+ const [drag, setDrag] = useState(null);
170
+ const [announcements, setAnnouncements] = useState(noAnnouncements);
171
+ const inputRef = useRef(null);
172
+ const listRef = useRef(null);
173
+ // Set while Dropzone dispatches the input's own events, so its change
174
+ // handler hands them on rather than reading them as a pick.
175
+ const dispatchingRef = useRef(false);
176
+ // The row a removal emptied, whose neighbour takes focus.
177
+ const removedRowRef = useRef(null);
178
+ const announcedRef = useRef(0);
179
+ // What the input held when it was last clicked (Enter and Space click it
180
+ // too), which a pick adds to: by the time the pick's change arrives, the
181
+ // browser has replaced the input's files with the picked ones.
182
+ const pickBaseRef = useRef(null);
183
+ const setInputRef = useCallback((node) => {
184
+ inputRef.current = node;
185
+ if (typeof ref === 'function')
186
+ ref(node);
187
+ else if (ref) {
188
+ ref.current =
189
+ node;
190
+ }
191
+ }, [ref]);
192
+ const formatNumber = useNumberFormat();
193
+ const tokens = acceptTokens(accept);
194
+ const sizeText = (bytes) => formatFileSize(bytes, formatNumber);
195
+ const countText = (count) => formatNumber ? formatNumber(count) : String(count);
196
+ // The files a pick, drop or paste builds on, and a removal takes one from.
197
+ // Controlled, that's `files`. Uncontrolled, it's the input itself rather
198
+ // than the list: a script can rewrite the input through the ref, emptying
199
+ // it with `value = ''` or setting its `files`, and no event reports that,
200
+ // so the list catches up only at the next change. Where there's no
201
+ // DataTransfer to write the input with, the list is all there is.
202
+ const current = () => controlled || typeof DataTransfer !== 'function'
203
+ ? files
204
+ : Array.from(inputRef.current.files);
205
+ const messageFor = (refusal) => {
206
+ const { file, code } = refusal;
207
+ if (rejectionMessage)
208
+ return rejectionMessage({ file, code });
209
+ if (code === 'file-too-large') {
210
+ return `${file.name}: larger than ${sizeText(maxSize)}`;
211
+ }
212
+ if (code === 'too-many-files') {
213
+ const most = multiple ? maxFiles : 1;
214
+ return `${file.name}: only ${most === 1 ? 'one file' : `${countText(most)} files`}`;
215
+ }
216
+ return refusal.folder
217
+ ? `${file.name}: folders can't be added`
218
+ : `${file.name}: only ${orList(typeNames(tokens))} files`;
219
+ };
220
+ const announce = (texts) => {
221
+ if (texts.length === 0)
222
+ return;
223
+ const batch = ++announcedRef.current;
224
+ setAnnouncements(texts.map((text, i) => ({ id: `${batch}-${i}`, text })));
225
+ };
226
+ /**
227
+ * Makes `next` the chosen files: writes them to the input, and when they
228
+ * differ from the list, dispatches the input's `input` and `change` and
229
+ * reports the new list.
230
+ */
231
+ const commit = (next) => {
232
+ pickBaseRef.current = null;
233
+ const input = inputRef.current;
234
+ if (!sameFiles(input.files, next))
235
+ writeFiles(input, next);
236
+ if (sameFiles(files, next))
237
+ return;
238
+ if (controlled)
239
+ rerender();
240
+ else
241
+ setOwnFiles(next);
242
+ onFilesChange?.(next);
243
+ dispatchingRef.current = true;
244
+ try {
245
+ input.dispatchEvent(new Event('input', { bubbles: true }));
246
+ input.dispatchEvent(new Event('change', { bubbles: true }));
247
+ }
248
+ finally {
249
+ dispatchingRef.current = false;
250
+ }
251
+ };
252
+ /** Checks the files a pick, drop or paste brings, and takes those that pass. */
253
+ const take = (incoming, base = current()) => {
254
+ const kept = multiple ? base : noFiles;
255
+ const room = multiple ? (maxFiles ?? Infinity) - kept.length : 1;
256
+ const added = [];
257
+ const refused = [];
258
+ for (const { file, folder } of incoming) {
259
+ const code = folder || !accepts(tokens, file.name, file.type)
260
+ ? 'file-invalid-type'
261
+ : maxSize !== undefined && file.size > maxSize
262
+ ? 'file-too-large'
263
+ : null;
264
+ if (code) {
265
+ refused.push({ file, code, folder });
266
+ }
267
+ else if (multiple &&
268
+ [...kept, ...added].some(f => sameFile(f, file))) ;
269
+ else if (added.length >= room) {
270
+ refused.push({ file, code: 'too-many-files', folder });
271
+ }
272
+ else {
273
+ added.push(file);
274
+ }
275
+ }
276
+ setRefusals(refused.length > 0 ? refused : noRefusals);
277
+ if (refused.length > 0) {
278
+ onReject?.(refused.map(({ file, code }) => ({ file, code })));
279
+ }
280
+ commit(added.length > 0 ? [...kept, ...added] : base);
281
+ const addedText = added.length === 0
282
+ ? []
283
+ : [
284
+ addedMessage
285
+ ? addedMessage(added)
286
+ : added.length === 1
287
+ ? `${added[0].name} added`
288
+ : `${countText(added.length)} files added`,
289
+ ];
290
+ announce([...addedText, ...refused.map(messageFor)]);
291
+ };
292
+ const remove = (index) => {
293
+ const file = files[index];
294
+ removedRowRef.current = index;
295
+ commit(current().filter(held => !sameFile(held, file)));
296
+ announce([
297
+ removedMessage ? removedMessage(file) : `${file.name} removed`,
298
+ ]);
299
+ };
300
+ const handleChange = (event) => {
301
+ if (dispatchingRef.current) {
302
+ onChange?.(event);
303
+ return;
304
+ }
305
+ // A pick: the browser has put the picked files in the input. They're
306
+ // added to what it held when it was clicked, or, for a picker opened
307
+ // with showPicker(), which clicks nothing, to the list. With none (a
308
+ // cancelled pick, in a browser that clears it), that stays.
309
+ const base = pickBaseRef.current ?? files;
310
+ const picked = Array.from(event.target.files ?? []);
311
+ if (picked.length === 0)
312
+ commit(base);
313
+ else
314
+ take(picked.map(file => ({ file, folder: false })), base);
315
+ };
316
+ const handleClick = (event) => {
317
+ onClick?.(event);
318
+ pickBaseRef.current = current();
319
+ };
320
+ // While files are dragged over the input it's cancelled, which makes the
321
+ // input the drop target and keeps the browser's own drop from running.
322
+ // Disabled, it refuses the drop, so the browser doesn't open the file.
323
+ const handleDragOver = (event) => {
324
+ (event.type === 'dragenter' ? onDragEnter : onDragOver)?.(event);
325
+ if (!carriesFiles(event.dataTransfer))
326
+ return;
327
+ event.preventDefault();
328
+ if (disabled) {
329
+ event.dataTransfer.dropEffect = 'none';
330
+ return;
331
+ }
332
+ event.dataTransfer.dropEffect = 'copy';
333
+ // Only the dragged files' types can be read, so a file is known to be
334
+ // refused only when `accept` names no extension and its type is known.
335
+ const room = multiple ? (maxFiles ?? Infinity) - current().length : 1;
336
+ const types = Array.from(event.dataTransfer.items ?? [])
337
+ .filter(item => item.kind === 'file')
338
+ .map(item => item.type);
339
+ const refused = room <= 0 ||
340
+ (types.length > 0 &&
341
+ tokens.length > 0 &&
342
+ !tokens.some(token => token[0] === '.') &&
343
+ types.every(type => type !== '' && !accepts(tokens, '', type)));
344
+ setDrag(refused ? 'reject' : 'over');
345
+ };
346
+ const handleDragLeave = (event) => {
347
+ onDragLeave?.(event);
348
+ setDrag(null);
349
+ };
350
+ const handleDrop = (event) => {
351
+ onDrop?.(event);
352
+ setDrag(null);
353
+ if (!carriesFiles(event.dataTransfer))
354
+ return;
355
+ event.preventDefault();
356
+ if (!disabled)
357
+ take(incomingFrom(event.dataTransfer));
358
+ };
359
+ const handlePaste = (event) => {
360
+ onPaste?.(event);
361
+ if (!allowPaste || disabled)
362
+ return;
363
+ const incoming = incomingFrom(event.clipboardData);
364
+ if (incoming.length === 0)
365
+ return;
366
+ event.preventDefault();
367
+ take(incoming);
368
+ };
369
+ // A controlled list: the input follows `files`, and a change the app
370
+ // didn't take is undone.
371
+ useEffect(() => {
372
+ const input = inputRef.current;
373
+ if (controlled && input && !sameFiles(input.files, files)) {
374
+ writeFiles(input, files);
375
+ }
376
+ });
377
+ // After a removal, focus goes to the remove button that took the removed
378
+ // one's place, else the one before, else the input.
379
+ useEffect(() => {
380
+ const row = removedRowRef.current;
381
+ if (row === null)
382
+ return;
383
+ removedRowRef.current = null;
384
+ const buttons = listRef.current?.querySelectorAll('button') ?? [];
385
+ const next = buttons[Math.min(row, buttons.length - 1)];
386
+ (next ?? inputRef.current)?.focus();
387
+ });
388
+ // A reset of the input's form empties the input, so the list and the
389
+ // refusals go too. The reset event fires before the form resets, and a
390
+ // listener after this one can still cancel it, so the list is cleared a
391
+ // task later, and only if the reset went ahead.
392
+ const latestRef = useRef({ files, controlled, onFilesChange });
393
+ useEffect(() => {
394
+ latestRef.current = { files, controlled, onFilesChange };
395
+ });
396
+ const formAttribute = props.form;
397
+ useEffect(() => {
398
+ const form = inputRef.current?.form;
399
+ if (!form)
400
+ return undefined;
401
+ let timer;
402
+ const onReset = (event) => {
403
+ timer = setTimeout(() => {
404
+ if (event.defaultPrevented)
405
+ return;
406
+ const latest = latestRef.current;
407
+ pickBaseRef.current = null;
408
+ setRefusals(noRefusals);
409
+ if (latest.files.length === 0)
410
+ return;
411
+ if (latest.controlled)
412
+ rerender();
413
+ else
414
+ setOwnFiles(noFiles);
415
+ latest.onFilesChange?.(noFiles);
416
+ });
417
+ };
418
+ form.addEventListener('reset', onReset);
419
+ return () => {
420
+ form.removeEventListener('reset', onReset);
421
+ clearTimeout(timer);
422
+ };
423
+ }, [formAttribute]);
424
+ // A file dropped just outside the zone would open in the tab. The guard
425
+ // cancels a file drag anywhere nothing else takes it, leaving alone
426
+ // enabled file inputs and editable fields, which take drops of their own,
427
+ // and drops something else already handled. It reads the event's real
428
+ // target, so a file input inside a shadow root is left alone too.
429
+ useEffect(() => {
430
+ if (!preventDocumentDrop)
431
+ return undefined;
432
+ const guard = (event) => {
433
+ if (event.defaultPrevented || !carriesFiles(event.dataTransfer)) {
434
+ return;
435
+ }
436
+ const target = event.composedPath()[0];
437
+ if (target instanceof Element &&
438
+ target.closest('input[type="file"]:not(:disabled), textarea, [contenteditable]:not([contenteditable="false"])')) {
439
+ return;
440
+ }
441
+ event.preventDefault();
442
+ if (event.type === 'dragover')
443
+ event.dataTransfer.dropEffect = 'none';
444
+ };
445
+ document.addEventListener('dragover', guard);
446
+ document.addEventListener('drop', guard);
447
+ return () => {
448
+ document.removeEventListener('dragover', guard);
449
+ document.removeEventListener('drop', guard);
450
+ };
451
+ }, [preventDocumentDrop]);
452
+ const warnsMaxFiles = maxFiles !== undefined && !multiple;
453
+ useEffect(() => {
454
+ if (warnsMaxFiles) {
455
+ warnOnce('Dropzone:maxFiles-without-multiple', '[bestax-bulma] <Dropzone maxFiles> takes effect only with ' +
456
+ 'multiple. Without it, each new file replaces the one chosen.');
457
+ }
458
+ }, [warnsMaxFiles]);
459
+ const insideField = useInsideField();
460
+ const insideControl = useInsideControl();
461
+ const ownField = rendersOwnField('Dropzone', {
462
+ insideField,
463
+ insideControl,
464
+ label,
465
+ message,
466
+ horizontal,
467
+ fieldClassName,
468
+ });
469
+ const { controlId, fieldLabelProps } = useAutoLabelId({
470
+ label,
471
+ id: props.id,
472
+ labelProps,
473
+ rendersLabel: ownField,
474
+ });
475
+ const { classPrefix } = useConfig();
476
+ const pcn = (...args) => prefixedClassNames(classPrefix, ...args);
477
+ // The input takes `controlId`, so `id` stays out of the spread, where an
478
+ // undefined `id` key would wipe the id the label points at.
479
+ const { id: _id, ...inputProps } = props;
480
+ const { bulmaHelperClasses, rest } = useBulmaClasses(inputProps);
481
+ const baseId = useId();
482
+ const hintId = `${baseId}-hint`;
483
+ const refusalsId = `${baseId}-refusals`;
484
+ const messageId = `${baseId}-message`;
485
+ const describedBy = [
486
+ ariaDescribedBy,
487
+ hint ? hintId : undefined,
488
+ refusals.length > 0 ? refusalsId : undefined,
489
+ message ? messageId : undefined,
490
+ ]
491
+ .filter(Boolean)
492
+ .join(' ') || undefined;
493
+ const rootClass = usePrefixedClassNames('dropzone', {
494
+ 'is-dragover': drag === 'over',
495
+ 'is-drag-reject': drag === 'reject',
496
+ 'is-disabled': disabled,
497
+ });
498
+ const zoneClass = usePrefixedClassNames('file', 'is-boxed', 'is-fullwidth', {
499
+ [`is-${color}`]: !!color,
500
+ [`is-${size}`]: !!size,
501
+ });
502
+ const helpClass = usePrefixedClassNames('help', {
503
+ [`is-${messageColor}`]: !!messageColor,
504
+ });
505
+ // Each row's key, from the file's details, which the list keeps unique.
506
+ const seen = new Map();
507
+ const keyOf = (file) => {
508
+ const key = `${file.name}:${file.size}:${file.lastModified}`;
509
+ const count = seen.get(key) ?? 0;
510
+ seen.set(key, count + 1);
511
+ return count === 0 ? key : `${key}:${count}`;
512
+ };
513
+ const dropzoneElement = (jsxs("div", { className: classNames(rootClass, bulmaHelperClasses, className), children: [jsx("div", { className: zoneClass, children: jsxs("label", { className: pcn('file-label'), children: [jsx("input", { ...rest, ref: setInputRef, className: pcn('file-input'), type: "file", id: controlId, accept: accept, multiple: multiple, disabled: disabled, "aria-describedby": describedBy, onChange: handleChange, onClick: handleClick, onDragEnter: handleDragOver, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onPaste: handlePaste }), jsxs("span", { className: pcn('file-cta'), children: [icon && jsx("span", { className: pcn('file-icon'), children: icon }), jsx("span", { className: pcn('file-label'), children: buttonLabel ||
514
+ (multiple ? 'Choose or drop files' : 'Choose or drop a file') })] })] }) }), hint && (jsx("p", { id: hintId, className: pcn('help', 'dropzone-hint'), children: hint })), showFileList && files.length > 0 && (jsx("ul", { ref: listRef, className: pcn('dropzone-list'), children: files.map((file, index) => (jsxs("li", { className: pcn('dropzone-item'), children: [jsx("span", { className: pcn('dropzone-name'), children: file.name }), jsx("span", { className: pcn('dropzone-size'), children: sizeText(file.size) }), !disabled && (jsx(Delete, { size: "small", ariaLabel: removeLabel ? removeLabel(file) : `Remove ${file.name}`, onClick: () => remove(index) }))] }, keyOf(file)))) })), refusals.length > 0 && (jsx("div", { id: refusalsId, className: pcn('dropzone-rejections'), children: refusals.map((refusal, index) => (jsx("p", { className: pcn('help', 'is-danger'), children: messageFor(refusal) }, index))) })), jsx(StatusRegion, { items: announcements, describe: describeAnnouncement })] }));
515
+ const messageEl = message ? (jsx("p", { id: messageId, className: helpClass, children: message })) : null;
516
+ if (ownField) {
517
+ return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [dropzoneElement, messageEl] }));
518
+ }
519
+ return (jsxs(Fragment, { children: [dropzoneElement, messageEl] }));
520
+ });
521
+ Dropzone.displayName = 'Dropzone';
522
+
523
+ export { Dropzone };
524
+ //# sourceMappingURL=Dropzone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dropzone.js","sources":["../../../src/form/Dropzone.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useReducer,\n useRef,\n useState,\n} from 'react';\nimport {\n classNames,\n usePrefixedClassNames,\n prefixedClassNames,\n} from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { useConfig } from '../helpers/Config';\nimport { useNumberFormat, NumberFormatter } from '../helpers/localeFormat';\nimport { StatusRegion } from '../helpers/statusRegion';\nimport { warnOnce } from '../helpers/devWarnings';\nimport { Delete } from '../elements/Delete';\nimport {\n useInsideField,\n useInsideControl,\n rendersOwnField,\n useFieldsetDisabled,\n} from './FormContext';\nimport { Field } from './Field';\nimport { FormFieldProps } from './fieldProps';\nimport { useAutoLabelId } from './useAutoLabelId';\n\n/** Why a Dropzone refused a file. */\nexport type DropzoneRejectionCode =\n 'file-invalid-type' | 'file-too-large' | 'too-many-files';\n\n/** A file a Dropzone refused, and why. */\nexport interface DropzoneRejection {\n /** The file. */\n file: File;\n /**\n * Why it was refused: `file-invalid-type` when `accept` doesn't take it, or\n * it's a folder; `file-too-large` when it's over `maxSize`; `too-many-files`\n * when the list is full.\n */\n code: DropzoneRejectionCode;\n}\n\n/**\n * Props for the Dropzone component.\n *\n * @helperProps Helper props go on the `.dropzone` root `<div>`, with\n * `className`. The other attributes go on the `<input>`.\n * @extraProp {string} [accept] - File types it takes, as the native attribute writes them (`.pdf`, `image/*`, `application/pdf`). The picker offers them, and Dropzone checks every pick, drop and paste against them by the same rules, since browsers don't check a dropped file. It goes by a file's name and type, not its contents.\n * @extraProp {boolean} [multiple=false] - Takes several files, and each pick, drop or paste adds to the list. Without it, a new file replaces the one chosen.\n * @extraProp {string} [name] - The files' name in the form's data. The input holds the chosen files, so a plain form submit, `FormData` and React 19 actions all carry them.\n * @extraProp {boolean} [required=false] - The browser's own check: a form won't submit with no file chosen.\n * @extraProp {boolean} [disabled=false] - Disables the input, hides the remove buttons and takes no drops. A disabled `Fieldset` around it does the same.\n * @extraProp {(event: React.ChangeEvent<HTMLInputElement>) => void} [onChange] - Called on the input's `change`, after each pick, drop, paste or removal that changes the files, with `event.target.files` holding the new list.\n * @extraProp {React.Ref<HTMLInputElement>} [ref] - Forwarded to the `<input>`, so `ref.current.showPicker()` opens the picker from a button of your own. A script that writes the input through it, such as `value = ''` to clear it or a form library setting `files`, changes what the input holds and what the next pick, drop or paste adds to, but no event reports the write, so the list shows it only from the next change. To clear the list at once, reset the form, or control it with `files` and set that to `[]`.\n */\nexport interface DropzoneProps\n extends\n Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'color' | 'type' | 'children' | 'value' | 'defaultValue'\n >,\n Omit<BulmaClassesProps, 'color'>,\n FormFieldProps {\n /** Field label, rendered above the zone. It names the input along with the zone's own text, through `htmlFor` (your `id` when you pass one). Inside an outer `Field` it's dropped, and that `Field`'s label names the input. */\n label?: React.ReactNode;\n /** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). */\n labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {\n [key: string]: unknown;\n };\n /** Bulma color modifier for the zone, as `File` takes it. */\n color?:\n | 'primary'\n | 'link'\n | 'info'\n | 'success'\n | 'warning'\n | 'danger'\n | 'black'\n | 'dark'\n | 'light'\n | 'white';\n /** Size modifier for the zone. */\n size?: 'small' | 'medium' | 'large';\n /**\n * The zone's text. It's the input's accessible name, so keep it short, and\n * put details such as \"PDF up to 5 MB\" in `hint`. Default: \"Choose or drop\n * a file\", or \"Choose or drop files\" with `multiple`.\n */\n buttonLabel?: React.ReactNode;\n /**\n * An icon above the zone's text. It sits inside the `<label>` that names\n * the input, so leave an `Icon` here unnamed (`<Icon name=\"upload\" />`).\n */\n icon?: React.ReactNode;\n /**\n * A line under the zone that describes the input through\n * `aria-describedby`, such as \"PDF up to 5 MB\".\n */\n hint?: React.ReactNode;\n /** The largest file it takes, in bytes. A bigger one is refused with `file-too-large`. */\n maxSize?: number;\n /**\n * With `multiple`, how many files the list holds at most. A drop that would\n * go over adds files up to the limit and refuses the rest with\n * `too-many-files`.\n */\n maxFiles?: number;\n /**\n * The chosen files, to control the list. The input and the list follow it,\n * and a change you don't take through `onFilesChange` is undone. Setting it\n * to `[]` clears both.\n */\n files?: File[];\n /** Called with the whole list of chosen files each time it changes. */\n onFilesChange?: (files: File[]) => void;\n /** Called with the files a pick, drop or paste refused, and why. */\n onReject?: (rejections: DropzoneRejection[]) => void;\n /**\n * Shows the chosen files under the zone, each with its size and a remove\n * button. Turn it off to show them your own way from `onFilesChange`. The\n * refusals still show.\n */\n showFileList?: boolean;\n /** Takes files pasted while the input has focus, through the same checks as a drop. */\n allowPaste?: boolean;\n /**\n * While it's on the page, stops the browser opening a file dropped outside\n * any drop target, which would leave the page. Drops on other file inputs\n * and on editable fields are left alone.\n */\n preventDocumentDrop?: boolean;\n /** Names a file's remove button, for localization. Default: `` `Remove ${file.name}` ``. */\n removeLabel?: (file: File) => string;\n /**\n * The text shown and announced for a refused file, for localization.\n * Default: the file's name and the reason, such as \"photo.png: only PDF\n * files\".\n */\n rejectionMessage?: (rejection: DropzoneRejection) => string;\n /**\n * What's announced when files are added, for localization. Default: the\n * file's name and \"added\", or a count (\"2 files added\").\n */\n addedMessage?: (files: File[]) => string;\n /** What's announced when a file is removed, for localization. Default: `` `${file.name} removed` ``. */\n removedMessage?: (file: File) => string;\n /**\n * Help or validation message under the Dropzone. It describes the input\n * through `aria-describedby`, after the hint and any refusals.\n */\n message?: React.ReactNode;\n /** Additional CSS classes for the root. */\n className?: string;\n}\n\n/** A file on its way in, and whether it's really a folder. */\ninterface Incoming {\n file: File;\n folder: boolean;\n}\n\n/** A refusal, with whether the file was a folder, which the default message says. */\ninterface Refusal extends DropzoneRejection {\n folder: boolean;\n}\n\n/** Something the status region says, with an id that's new each time. */\ninterface Announcement {\n id: string;\n text: string;\n}\n\nconst noFiles: File[] = [];\nconst noRefusals: Refusal[] = [];\nconst noAnnouncements: Announcement[] = [];\n\nconst describeAnnouncement = (announcement: Announcement) => announcement.text;\n\n/**\n * The tokens of an `accept` attribute that HTML recognizes, lowercased: an\n * extension (`.pdf`), a wildcard (`image/*`) or a MIME type. Others are\n * ignored, as browsers ignore them.\n */\nconst acceptTokens = (accept: string | undefined): string[] =>\n (accept ?? '')\n .split(',')\n .map(token => token.trim().toLowerCase())\n .filter(\n token => token.length > 1 && (token[0] === '.' || token.includes('/'))\n );\n\n/** Whether `accept`'s tokens take a file with this name and type. */\nconst accepts = (tokens: string[], name: string, type: string): boolean => {\n if (tokens.length === 0) return true;\n const lowerName = name.toLowerCase();\n const lowerType = type.toLowerCase();\n return tokens.some(token =>\n token[0] === '.'\n ? lowerName.endsWith(token)\n : token.endsWith('/*')\n ? lowerType.startsWith(token.slice(0, -1))\n : lowerType === token\n );\n};\n\n/** Whether a drag or a clipboard carries files. */\nconst carriesFiles = (data: DataTransfer | null): data is DataTransfer =>\n !!data && Array.from(data.types ?? []).includes('Files');\n\n/** The files a drop or a paste brings, with folders marked. */\nconst incomingFrom = (data: DataTransfer | null): Incoming[] => {\n if (!data) return [];\n const items = Array.from(data.items ?? []).filter(\n item => item.kind === 'file'\n );\n if (items.length === 0) {\n return Array.from(data.files ?? [], file => ({ file, folder: false }));\n }\n const incoming: Incoming[] = [];\n for (const item of items) {\n const file = item.getAsFile();\n if (!file) continue;\n const entry = item.webkitGetAsEntry?.();\n incoming.push({ file, folder: !!entry?.isDirectory });\n }\n return incoming;\n};\n\n/** The same file: one object, or one picked again with the same details. */\nconst sameFile = (a: File, b: File): boolean =>\n a === b ||\n (a.name === b.name && a.size === b.size && a.lastModified === b.lastModified);\n\n/** Whether two lists hold the same files in the same order. */\nconst sameFiles = (\n a: ArrayLike<File> | null | undefined,\n b: readonly File[]\n): boolean =>\n !!a && a.length === b.length && b.every((file, i) => sameFile(a[i], file));\n\n/**\n * Writes files to a file input, through a `DataTransfer`, the one way script\n * can build a `FileList`. Where there's no `DataTransfer` the input is left as\n * it is.\n */\nconst writeFiles = (input: HTMLInputElement, files: readonly File[]) => {\n if (typeof DataTransfer !== 'function') return;\n const transfer = new DataTransfer();\n for (const file of files) transfer.items.add(file);\n input.files = transfer.files;\n};\n\n/** The units a file size is written in, largest first. */\nconst sizeUnits = [\n ['gigabyte', 1e9, 'GB'],\n ['megabyte', 1e6, 'MB'],\n ['kilobyte', 1e3, 'kB'],\n] as const;\n\n/**\n * A file size for display, in decimal units (\"1.2 MB\"), in the locale of a\n * `LocaleProvider` around it, or as English writes it outside one.\n */\nconst formatFileSize = (\n bytes: number,\n formatNumber: NumberFormatter | null\n): string => {\n for (const [unit, factor, symbol] of sizeUnits) {\n if (bytes >= factor) {\n const value = bytes / factor;\n return formatNumber\n ? formatNumber(value, {\n style: 'unit',\n unit,\n unitDisplay: 'short',\n maximumFractionDigits: 1,\n })\n : `${Math.round(value * 10) / 10} ${symbol}`;\n }\n }\n return formatNumber\n ? formatNumber(bytes, { style: 'unit', unit: 'byte', unitDisplay: 'long' })\n : `${bytes} ${bytes === 1 ? 'byte' : 'bytes'}`;\n};\n\n/** A word for each kind of file `accept` names: \"PDF\", \"image\". */\nconst typeNames = (tokens: string[]): string[] => {\n const names: string[] = [];\n for (const token of tokens) {\n let name = token;\n if (token[0] === '.') {\n name = token.slice(1).toUpperCase();\n } else {\n const [type, subtype] = token.split('/');\n const core = subtype.split('+')[0];\n if (subtype === '*') name = type;\n else if (core === 'plain') name = 'text';\n else if (/^[a-z0-9]+$/.test(core)) name = core.toUpperCase();\n }\n if (!names.includes(name)) names.push(name);\n }\n return names;\n};\n\n/** \"A\", \"A or B\", \"A, B, or C\". */\nconst orList = (items: string[]): string =>\n items.length <= 2\n ? items.join(' or ')\n : `${items.slice(0, -1).join(', ')}, or ${items[items.length - 1]}`;\n\n/**\n * The `Dropzone` component is an area to drop files on or click to pick\n * them, which checks each file and lists the chosen ones with a way to remove\n * each.\n *\n * It's Bulma's boxed, full-width file widget with the real\n * `<input type=\"file\">` lying over it, so the input is the one tab stop, the\n * click target and the drop target, and Enter and Space open the picker. The\n * input holds the chosen files: a pick, drop or paste that passes the checks\n * is written to it, so a form submits the files under `name`. It doesn't\n * upload anything.\n *\n * @function\n * @param {DropzoneProps} props - Props for the Dropzone component.\n * @returns {JSX.Element} The rendered dropzone.\n *\n * @example\n * <Dropzone\n * label=\"CV\"\n * name=\"cv\"\n * accept=\".pdf,application/pdf\"\n * maxSize={5_000_000}\n * hint=\"PDF up to 5 MB\"\n * />\n */\nexport const Dropzone = forwardRef<HTMLInputElement, DropzoneProps>(\n (\n {\n // Field props\n label,\n labelSize,\n labelProps,\n horizontal,\n message,\n messageColor,\n fieldClassName,\n color,\n size,\n buttonLabel,\n icon,\n hint,\n maxSize,\n maxFiles,\n files: filesProp,\n onFilesChange,\n onReject,\n showFileList = true,\n allowPaste = true,\n preventDocumentDrop = true,\n removeLabel,\n rejectionMessage,\n addedMessage,\n removedMessage,\n className,\n accept,\n multiple,\n disabled: disabledProp,\n onChange,\n onClick,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n onPaste,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref\n ) => {\n const disabled = useFieldsetDisabled(disabledProp);\n const controlled = filesProp !== undefined;\n const [ownFiles, setOwnFiles] = useState<File[]>(noFiles);\n const files = filesProp ?? ownFiles;\n // A render the controlled list needs after a change, so that one the app\n // didn't take is undone.\n const [, rerender] = useReducer((n: number) => n + 1, 0);\n const [refusals, setRefusals] = useState<Refusal[]>(noRefusals);\n const [drag, setDrag] = useState<'over' | 'reject' | null>(null);\n const [announcements, setAnnouncements] =\n useState<Announcement[]>(noAnnouncements);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n const listRef = useRef<HTMLUListElement>(null);\n // Set while Dropzone dispatches the input's own events, so its change\n // handler hands them on rather than reading them as a pick.\n const dispatchingRef = useRef(false);\n // The row a removal emptied, whose neighbour takes focus.\n const removedRowRef = useRef<number | null>(null);\n const announcedRef = useRef(0);\n // What the input held when it was last clicked (Enter and Space click it\n // too), which a pick adds to: by the time the pick's change arrives, the\n // browser has replaced the input's files with the picked ones.\n const pickBaseRef = useRef<File[] | null>(null);\n\n const setInputRef = useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) {\n (ref as React.MutableRefObject<HTMLInputElement | null>).current =\n node;\n }\n },\n [ref]\n );\n\n const formatNumber = useNumberFormat();\n const tokens = acceptTokens(accept);\n const sizeText = (bytes: number) => formatFileSize(bytes, formatNumber);\n const countText = (count: number) =>\n formatNumber ? formatNumber(count) : String(count);\n\n // The files a pick, drop or paste builds on, and a removal takes one from.\n // Controlled, that's `files`. Uncontrolled, it's the input itself rather\n // than the list: a script can rewrite the input through the ref, emptying\n // it with `value = ''` or setting its `files`, and no event reports that,\n // so the list catches up only at the next change. Where there's no\n // DataTransfer to write the input with, the list is all there is.\n const current = (): File[] =>\n controlled || typeof DataTransfer !== 'function'\n ? files\n : Array.from((inputRef.current as HTMLInputElement).files as FileList);\n\n const messageFor = (refusal: Refusal): string => {\n const { file, code } = refusal;\n if (rejectionMessage) return rejectionMessage({ file, code });\n if (code === 'file-too-large') {\n return `${file.name}: larger than ${sizeText(maxSize as number)}`;\n }\n if (code === 'too-many-files') {\n const most = multiple ? (maxFiles as number) : 1;\n return `${file.name}: only ${most === 1 ? 'one file' : `${countText(most)} files`}`;\n }\n return refusal.folder\n ? `${file.name}: folders can't be added`\n : `${file.name}: only ${orList(typeNames(tokens))} files`;\n };\n\n const announce = (texts: string[]) => {\n if (texts.length === 0) return;\n const batch = ++announcedRef.current;\n setAnnouncements(texts.map((text, i) => ({ id: `${batch}-${i}`, text })));\n };\n\n /**\n * Makes `next` the chosen files: writes them to the input, and when they\n * differ from the list, dispatches the input's `input` and `change` and\n * reports the new list.\n */\n const commit = (next: File[]) => {\n pickBaseRef.current = null;\n const input = inputRef.current as HTMLInputElement;\n if (!sameFiles(input.files, next)) writeFiles(input, next);\n if (sameFiles(files, next)) return;\n if (controlled) rerender();\n else setOwnFiles(next);\n onFilesChange?.(next);\n dispatchingRef.current = true;\n try {\n input.dispatchEvent(new Event('input', { bubbles: true }));\n input.dispatchEvent(new Event('change', { bubbles: true }));\n } finally {\n dispatchingRef.current = false;\n }\n };\n\n /** Checks the files a pick, drop or paste brings, and takes those that pass. */\n const take = (incoming: Incoming[], base: File[] = current()) => {\n const kept = multiple ? base : noFiles;\n const room = multiple ? (maxFiles ?? Infinity) - kept.length : 1;\n const added: File[] = [];\n const refused: Refusal[] = [];\n for (const { file, folder } of incoming) {\n const code: DropzoneRejectionCode | null =\n folder || !accepts(tokens, file.name, file.type)\n ? 'file-invalid-type'\n : maxSize !== undefined && file.size > maxSize\n ? 'file-too-large'\n : null;\n if (code) {\n refused.push({ file, code, folder });\n } else if (\n multiple &&\n [...kept, ...added].some(f => sameFile(f, file))\n ) {\n // Already in the list: nothing to add, and nothing wrong.\n } else if (added.length >= room) {\n refused.push({ file, code: 'too-many-files', folder });\n } else {\n added.push(file);\n }\n }\n setRefusals(refused.length > 0 ? refused : noRefusals);\n if (refused.length > 0) {\n onReject?.(refused.map(({ file, code }) => ({ file, code })));\n }\n commit(added.length > 0 ? [...kept, ...added] : base);\n const addedText =\n added.length === 0\n ? []\n : [\n addedMessage\n ? addedMessage(added)\n : added.length === 1\n ? `${added[0].name} added`\n : `${countText(added.length)} files added`,\n ];\n announce([...addedText, ...refused.map(messageFor)]);\n };\n\n const remove = (index: number) => {\n const file = files[index];\n removedRowRef.current = index;\n commit(current().filter(held => !sameFile(held, file)));\n announce([\n removedMessage ? removedMessage(file) : `${file.name} removed`,\n ]);\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (dispatchingRef.current) {\n onChange?.(event);\n return;\n }\n // A pick: the browser has put the picked files in the input. They're\n // added to what it held when it was clicked, or, for a picker opened\n // with showPicker(), which clicks nothing, to the list. With none (a\n // cancelled pick, in a browser that clears it), that stays.\n const base = pickBaseRef.current ?? files;\n const picked = Array.from(event.target.files ?? []);\n if (picked.length === 0) commit(base);\n else\n take(\n picked.map(file => ({ file, folder: false })),\n base\n );\n };\n\n const handleClick = (event: React.MouseEvent<HTMLInputElement>) => {\n onClick?.(event);\n pickBaseRef.current = current();\n };\n\n // While files are dragged over the input it's cancelled, which makes the\n // input the drop target and keeps the browser's own drop from running.\n // Disabled, it refuses the drop, so the browser doesn't open the file.\n const handleDragOver = (event: React.DragEvent<HTMLInputElement>) => {\n (event.type === 'dragenter' ? onDragEnter : onDragOver)?.(event);\n if (!carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n if (disabled) {\n event.dataTransfer.dropEffect = 'none';\n return;\n }\n event.dataTransfer.dropEffect = 'copy';\n // Only the dragged files' types can be read, so a file is known to be\n // refused only when `accept` names no extension and its type is known.\n const room = multiple ? (maxFiles ?? Infinity) - current().length : 1;\n const types = Array.from(event.dataTransfer.items ?? [])\n .filter(item => item.kind === 'file')\n .map(item => item.type);\n const refused =\n room <= 0 ||\n (types.length > 0 &&\n tokens.length > 0 &&\n !tokens.some(token => token[0] === '.') &&\n types.every(type => type !== '' && !accepts(tokens, '', type)));\n setDrag(refused ? 'reject' : 'over');\n };\n\n const handleDragLeave = (event: React.DragEvent<HTMLInputElement>) => {\n onDragLeave?.(event);\n setDrag(null);\n };\n\n const handleDrop = (event: React.DragEvent<HTMLInputElement>) => {\n onDrop?.(event);\n setDrag(null);\n if (!carriesFiles(event.dataTransfer)) return;\n event.preventDefault();\n if (!disabled) take(incomingFrom(event.dataTransfer));\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event);\n if (!allowPaste || disabled) return;\n const incoming = incomingFrom(event.clipboardData);\n if (incoming.length === 0) return;\n event.preventDefault();\n take(incoming);\n };\n\n // A controlled list: the input follows `files`, and a change the app\n // didn't take is undone.\n useEffect(() => {\n const input = inputRef.current;\n if (controlled && input && !sameFiles(input.files, files)) {\n writeFiles(input, files);\n }\n });\n\n // After a removal, focus goes to the remove button that took the removed\n // one's place, else the one before, else the input.\n useEffect(() => {\n const row = removedRowRef.current;\n if (row === null) return;\n removedRowRef.current = null;\n const buttons = listRef.current?.querySelectorAll('button') ?? [];\n const next = buttons[Math.min(row, buttons.length - 1)];\n (next ?? inputRef.current)?.focus();\n });\n\n // A reset of the input's form empties the input, so the list and the\n // refusals go too. The reset event fires before the form resets, and a\n // listener after this one can still cancel it, so the list is cleared a\n // task later, and only if the reset went ahead.\n const latestRef = useRef({ files, controlled, onFilesChange });\n useEffect(() => {\n latestRef.current = { files, controlled, onFilesChange };\n });\n const formAttribute = props.form;\n useEffect(() => {\n const form = inputRef.current?.form;\n if (!form) return undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const onReset = (event: Event) => {\n timer = setTimeout(() => {\n if (event.defaultPrevented) return;\n const latest = latestRef.current;\n pickBaseRef.current = null;\n setRefusals(noRefusals);\n if (latest.files.length === 0) return;\n if (latest.controlled) rerender();\n else setOwnFiles(noFiles);\n latest.onFilesChange?.(noFiles);\n });\n };\n form.addEventListener('reset', onReset);\n return () => {\n form.removeEventListener('reset', onReset);\n clearTimeout(timer);\n };\n }, [formAttribute]);\n\n // A file dropped just outside the zone would open in the tab. The guard\n // cancels a file drag anywhere nothing else takes it, leaving alone\n // enabled file inputs and editable fields, which take drops of their own,\n // and drops something else already handled. It reads the event's real\n // target, so a file input inside a shadow root is left alone too.\n useEffect(() => {\n if (!preventDocumentDrop) return undefined;\n const guard = (event: DragEvent) => {\n if (event.defaultPrevented || !carriesFiles(event.dataTransfer)) {\n return;\n }\n const target = event.composedPath()[0];\n if (\n target instanceof Element &&\n target.closest(\n 'input[type=\"file\"]:not(:disabled), textarea, [contenteditable]:not([contenteditable=\"false\"])'\n )\n ) {\n return;\n }\n event.preventDefault();\n if (event.type === 'dragover') event.dataTransfer.dropEffect = 'none';\n };\n document.addEventListener('dragover', guard);\n document.addEventListener('drop', guard);\n return () => {\n document.removeEventListener('dragover', guard);\n document.removeEventListener('drop', guard);\n };\n }, [preventDocumentDrop]);\n\n const warnsMaxFiles = maxFiles !== undefined && !multiple;\n useEffect(() => {\n if (warnsMaxFiles) {\n warnOnce(\n 'Dropzone:maxFiles-without-multiple',\n '[bestax-bulma] <Dropzone maxFiles> takes effect only with ' +\n 'multiple. Without it, each new file replaces the one chosen.'\n );\n }\n }, [warnsMaxFiles]);\n\n const insideField = useInsideField();\n const insideControl = useInsideControl();\n const ownField = rendersOwnField('Dropzone', {\n insideField,\n insideControl,\n label,\n message,\n horizontal,\n fieldClassName,\n });\n const { controlId, fieldLabelProps } = useAutoLabelId({\n label,\n id: props.id,\n labelProps,\n rendersLabel: ownField,\n });\n const { classPrefix } = useConfig();\n const pcn = (...args: Parameters<typeof classNames>) =>\n prefixedClassNames(classPrefix, ...args);\n // The input takes `controlId`, so `id` stays out of the spread, where an\n // undefined `id` key would wipe the id the label points at.\n const { id: _id, ...inputProps } = props;\n const { bulmaHelperClasses, rest } = useBulmaClasses(inputProps);\n\n const baseId = useId();\n const hintId = `${baseId}-hint`;\n const refusalsId = `${baseId}-refusals`;\n const messageId = `${baseId}-message`;\n const describedBy =\n [\n ariaDescribedBy,\n hint ? hintId : undefined,\n refusals.length > 0 ? refusalsId : undefined,\n message ? messageId : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const rootClass = usePrefixedClassNames('dropzone', {\n 'is-dragover': drag === 'over',\n 'is-drag-reject': drag === 'reject',\n 'is-disabled': disabled,\n });\n const zoneClass = usePrefixedClassNames(\n 'file',\n 'is-boxed',\n 'is-fullwidth',\n {\n [`is-${color}`]: !!color,\n [`is-${size}`]: !!size,\n }\n );\n const helpClass = usePrefixedClassNames('help', {\n [`is-${messageColor}`]: !!messageColor,\n });\n\n // Each row's key, from the file's details, which the list keeps unique.\n const seen = new Map<string, number>();\n const keyOf = (file: File) => {\n const key = `${file.name}:${file.size}:${file.lastModified}`;\n const count = seen.get(key) ?? 0;\n seen.set(key, count + 1);\n return count === 0 ? key : `${key}:${count}`;\n };\n\n const dropzoneElement = (\n <div className={classNames(rootClass, bulmaHelperClasses, className)}>\n <div className={zoneClass}>\n <label className={pcn('file-label')}>\n <input\n {...rest}\n ref={setInputRef}\n className={pcn('file-input')}\n type=\"file\"\n id={controlId}\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n aria-describedby={describedBy}\n onChange={handleChange}\n onClick={handleClick}\n onDragEnter={handleDragOver}\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onDrop={handleDrop}\n onPaste={handlePaste}\n />\n <span className={pcn('file-cta')}>\n {icon && <span className={pcn('file-icon')}>{icon}</span>}\n <span className={pcn('file-label')}>\n {buttonLabel ||\n (multiple ? 'Choose or drop files' : 'Choose or drop a file')}\n </span>\n </span>\n </label>\n </div>\n {hint && (\n <p id={hintId} className={pcn('help', 'dropzone-hint')}>\n {hint}\n </p>\n )}\n {showFileList && files.length > 0 && (\n <ul ref={listRef} className={pcn('dropzone-list')}>\n {files.map((file, index) => (\n <li key={keyOf(file)} className={pcn('dropzone-item')}>\n <span className={pcn('dropzone-name')}>{file.name}</span>\n <span className={pcn('dropzone-size')}>\n {sizeText(file.size)}\n </span>\n {!disabled && (\n <Delete\n size=\"small\"\n ariaLabel={\n removeLabel ? removeLabel(file) : `Remove ${file.name}`\n }\n onClick={() => remove(index)}\n />\n )}\n </li>\n ))}\n </ul>\n )}\n {refusals.length > 0 && (\n <div id={refusalsId} className={pcn('dropzone-rejections')}>\n {refusals.map((refusal, index) => (\n <p key={index} className={pcn('help', 'is-danger')}>\n {messageFor(refusal)}\n </p>\n ))}\n </div>\n )}\n <StatusRegion items={announcements} describe={describeAnnouncement} />\n </div>\n );\n\n const messageEl = message ? (\n <p id={messageId} className={helpClass}>\n {message}\n </p>\n ) : null;\n\n if (ownField) {\n return (\n <Field\n label={label}\n labelSize={labelSize}\n labelProps={fieldLabelProps}\n horizontal={horizontal}\n className={fieldClassName}\n >\n {dropzoneElement}\n {messageEl}\n </Field>\n );\n }\n\n return (\n <>\n {dropzoneElement}\n {messageEl}\n </>\n );\n }\n);\n\nDropzone.displayName = 'Dropzone';\n\nexport default Dropzone;\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;AAgLA,MAAM,OAAO,GAAW,EAAE;AAC1B,MAAM,UAAU,GAAc,EAAE;AAChC,MAAM,eAAe,GAAmB,EAAE;AAE1C,MAAM,oBAAoB,GAAG,CAAC,YAA0B,KAAK,YAAY,CAAC,IAAI;AAE9E;;;;AAIG;AACH,MAAM,YAAY,GAAG,CAAC,MAA0B,KAC9C,CAAC,MAAM,IAAI,EAAE;KACV,KAAK,CAAC,GAAG;AACT,KAAA,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;KACvC,MAAM,CACL,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CACvE;AAEL;AACA,MAAM,OAAO,GAAG,CAAC,MAAgB,EAAE,IAAY,EAAE,IAAY,KAAa;AACxE,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE;AACpC,IAAA,MAAM,SAAS,GAAG,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