@r2digisolutions/components 0.21.25 → 0.21.27
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,6 +17,8 @@
|
|
|
17
17
|
label?: string;
|
|
18
18
|
hint?: string;
|
|
19
19
|
accept?: string;
|
|
20
|
+
/** Form field name for the hidden file input (default `'files'`). */
|
|
21
|
+
name?: string;
|
|
20
22
|
/** Allow selecting more than one file (default true). */
|
|
21
23
|
multiple?: boolean;
|
|
22
24
|
/** Cap on how many files can be kept when multiple. */
|
|
@@ -38,6 +40,7 @@
|
|
|
38
40
|
label = 'Drop files here',
|
|
39
41
|
hint = 'or click to browse',
|
|
40
42
|
accept,
|
|
43
|
+
name = 'files',
|
|
41
44
|
multiple = true,
|
|
42
45
|
maxFiles,
|
|
43
46
|
disabled = false,
|
|
@@ -50,6 +53,8 @@
|
|
|
50
53
|
onremove
|
|
51
54
|
}: DropZoneProps = $props();
|
|
52
55
|
|
|
56
|
+
const inputId = $props.id();
|
|
57
|
+
|
|
53
58
|
let dragging = $state(false);
|
|
54
59
|
let error = $state('');
|
|
55
60
|
let inputEl = $state<HTMLInputElement | null>(null);
|
|
@@ -97,7 +102,16 @@
|
|
|
97
102
|
return rules.some((rule) => {
|
|
98
103
|
if (rule.startsWith('.')) return name.endsWith(rule);
|
|
99
104
|
if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));
|
|
100
|
-
|
|
105
|
+
if (type && type === rule) return true;
|
|
106
|
+
// image/png → also match *.png when browser leaves type empty
|
|
107
|
+
const slash = rule.lastIndexOf('/');
|
|
108
|
+
if (slash > 0) {
|
|
109
|
+
const subtype = rule.slice(slash + 1);
|
|
110
|
+
if (subtype && subtype !== '*' && name.endsWith(`.${subtype}`)) return true;
|
|
111
|
+
if (subtype === 'jpeg' && name.endsWith('.jpg')) return true;
|
|
112
|
+
if (subtype === 'svg+xml' && name.endsWith('.svg')) return true;
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
101
115
|
});
|
|
102
116
|
}
|
|
103
117
|
|
|
@@ -248,8 +262,11 @@
|
|
|
248
262
|
</div>
|
|
249
263
|
<input
|
|
250
264
|
bind:this={inputEl}
|
|
265
|
+
id={inputId}
|
|
266
|
+
{name}
|
|
251
267
|
type="file"
|
|
252
268
|
class="sr-only"
|
|
269
|
+
aria-label={label}
|
|
253
270
|
{accept}
|
|
254
271
|
{multiple}
|
|
255
272
|
{disabled}
|
|
@@ -8,6 +8,8 @@ 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'`). */
|
|
12
|
+
name?: string;
|
|
11
13
|
/** Allow selecting more than one file (default true). */
|
|
12
14
|
multiple?: boolean;
|
|
13
15
|
/** Cap on how many files can be kept when multiple. */
|