@r2digisolutions/components 0.21.28 → 0.21.29

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.
@@ -17,7 +17,12 @@
17
17
  label?: string;
18
18
  hint?: string;
19
19
  accept?: string;
20
- /** Form field name for the hidden file input (default `'files'`). */
20
+ /**
21
+ * Form field name for the file input.
22
+ * Leave unset for picker-only usage (`bind:files` / `onchange`) so the input is
23
+ * ignored by parent remote forms. When set with `multiple`, a `[]` suffix is
24
+ * added automatically unless the name already ends with `[]`.
25
+ */
21
26
  name?: string;
22
27
  /** Allow selecting more than one file (default true). */
23
28
  multiple?: boolean;
@@ -40,7 +45,7 @@
40
45
  label = 'Drop files here',
41
46
  hint = 'or click to browse',
42
47
  accept,
43
- name = 'files',
48
+ name,
44
49
  multiple = true,
45
50
  maxFiles,
46
51
  disabled = false,
@@ -63,6 +68,13 @@
63
68
  const previewUrls = new Set<string>();
64
69
 
65
70
  const maxBytes = $derived(maxSizeMb * 1024 * 1024);
71
+ const inputName = $derived(
72
+ !name
73
+ ? undefined
74
+ : multiple && !name.endsWith('[]')
75
+ ? `${name}[]`
76
+ : name
77
+ );
66
78
 
67
79
  function formatBytes(bytes: number): string {
68
80
  if (bytes === 0) return '0 B';
@@ -263,7 +275,7 @@
263
275
  <input
264
276
  bind:this={inputEl}
265
277
  id={inputId}
266
- name={name || undefined}
278
+ name={inputName}
267
279
  type="file"
268
280
  class="sr-only"
269
281
  aria-label={label}
@@ -8,7 +8,12 @@ interface DropZoneProps {
8
8
  label?: string;
9
9
  hint?: string;
10
10
  accept?: string;
11
- /** Form field name for the hidden file input (default `'files'`). */
11
+ /**
12
+ * Form field name for the file input.
13
+ * Leave unset for picker-only usage (`bind:files` / `onchange`) so the input is
14
+ * ignored by parent remote forms. When set with `multiple`, a `[]` suffix is
15
+ * added automatically unless the name already ends with `[]`.
16
+ */
12
17
  name?: string;
13
18
  /** Allow selecting more than one file (default true). */
14
19
  multiple?: boolean;
@@ -77,6 +77,7 @@
77
77
 
78
78
  <div class={['w-full space-y-1', className]}>
79
79
  <DropZone
80
+ {name}
80
81
  {label}
81
82
  {hint}
82
83
  {accept}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.21.28",
3
+ "version": "0.21.29",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",