@nldd/design-system 0.12.0 → 0.13.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.
- package/custom-elements.json +556 -14
- package/dist/components/actions/button-group/button-group.d.ts +4 -3
- package/dist/components/actions/button-group/button-group.d.ts.map +1 -1
- package/dist/components/actions/button-group/button-group.js +4 -3
- package/dist/components/actions/button-group/button-group.js.map +1 -1
- package/dist/components/actions/button-group/button-group.styles.d.ts.map +1 -1
- package/dist/components/actions/button-group/button-group.styles.js +6 -6
- package/dist/components/actions/button-group/button-group.styles.js.map +1 -1
- package/dist/components/actions/menu/menu.d.ts.map +1 -1
- package/dist/components/actions/menu/menu.js +3 -0
- package/dist/components/actions/menu/menu.js.map +1 -1
- package/dist/components/components.js +3307 -1742
- package/dist/components/content/avatar/avatar.d.ts +2 -1
- package/dist/components/content/avatar/avatar.d.ts.map +1 -1
- package/dist/components/content/avatar/avatar.js +12 -1
- package/dist/components/content/avatar/avatar.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.d.ts +30 -2
- package/dist/components/content/avatar-group/avatar-group.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.i18n.d.ts +1 -0
- package/dist/components/content/avatar-group/avatar-group.i18n.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.i18n.js +1 -0
- package/dist/components/content/avatar-group/avatar-group.i18n.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.js +96 -7
- package/dist/components/content/avatar-group/avatar-group.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.styles.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.styles.js +35 -1
- package/dist/components/content/avatar-group/avatar-group.styles.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.template.d.ts +1 -0
- package/dist/components/content/avatar-group/avatar-group.template.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.template.js +52 -29
- package/dist/components/content/avatar-group/avatar-group.template.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.js +46 -13
- package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
- package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
- package/dist/components/content/icon/icon-aliases.js +19 -0
- package/dist/components/content/icon/icon-aliases.js.map +1 -1
- package/dist/components/content/icon/icon-gallery-status.d.ts.map +1 -1
- package/dist/components/content/icon/icon-gallery-status.js +10 -0
- package/dist/components/content/icon/icon-gallery-status.js.map +1 -1
- package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
- package/dist/components/content/icon/icon-registry.js +10 -2
- package/dist/components/content/icon/icon-registry.js.map +1 -1
- package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/content/tooltip/tooltip.js +2 -0
- package/dist/components/content/tooltip/tooltip.js.map +1 -1
- package/dist/components/{icon-DFhgRf3P.js → icon-BJHKWhY5.js} +21 -2
- package/dist/components/{icon-button-Sxkh5cVr.js → icon-button-DhBIq6lN.js} +75 -2
- package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.styles.js +36 -6
- package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
- package/dist/components/inputs/date-picker/date-picker.d.ts +2 -2
- package/dist/components/inputs/date-picker/date-picker.i18n.d.ts +1 -1
- package/dist/components/inputs/date-picker/date-picker.i18n.js +1 -1
- package/dist/components/inputs/date-picker/date-picker.i18n.js.map +1 -1
- package/dist/components/inputs/date-picker/date-picker.template.js +1 -1
- package/dist/components/inputs/date-picker/date-picker.template.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.d.ts +86 -10
- package/dist/components/inputs/file-field/file-field.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.drop.d.ts +34 -0
- package/dist/components/inputs/file-field/file-field.drop.d.ts.map +1 -0
- package/dist/components/inputs/file-field/file-field.drop.js +176 -0
- package/dist/components/inputs/file-field/file-field.drop.js.map +1 -0
- package/dist/components/inputs/file-field/file-field.i18n.d.ts +20 -1
- package/dist/components/inputs/file-field/file-field.i18n.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.i18n.js +20 -1
- package/dist/components/inputs/file-field/file-field.i18n.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.js +283 -15
- package/dist/components/inputs/file-field/file-field.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.styles.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.styles.js +245 -10
- package/dist/components/inputs/file-field/file-field.styles.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.template.d.ts +1 -0
- package/dist/components/inputs/file-field/file-field.template.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.template.js +167 -28
- package/dist/components/inputs/file-field/file-field.template.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.truncate.d.ts +22 -0
- package/dist/components/inputs/file-field/file-field.truncate.d.ts.map +1 -0
- package/dist/components/inputs/file-field/file-field.truncate.js +62 -0
- package/dist/components/inputs/file-field/file-field.truncate.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.d.ts +10 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.js +141 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js +55 -7
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.i18n.d.ts +5 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.i18n.js +7 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.js +34 -3
- package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.markdown.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.markdown.js +6 -2
- package/dist/components/inputs/text-editor/text-editor.markdown.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.selection.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.selection.js +11 -1
- package/dist/components/inputs/text-editor/text-editor.selection.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.styles.js +130 -7
- package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.tasks.d.ts +17 -0
- package/dist/components/inputs/text-editor/text-editor.tasks.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.tasks.js +109 -0
- package/dist/components/inputs/text-editor/text-editor.tasks.js.map +1 -0
- package/dist/components/layout/page-sections/hero/hero-corner.styles.d.ts.map +1 -1
- package/dist/components/layout/page-sections/hero/hero-corner.styles.js +61 -0
- package/dist/components/layout/page-sections/hero/hero-corner.styles.js.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.d.ts +1 -1
- package/dist/components/layout/page-sections/hero/hero.js +1 -1
- package/dist/components/layout/popover/popover.d.ts +6 -0
- package/dist/components/layout/popover/popover.d.ts.map +1 -1
- package/dist/components/layout/popover/popover.js +16 -0
- package/dist/components/layout/popover/popover.js.map +1 -1
- package/dist/components/layout/popover/popover.styles.d.ts.map +1 -1
- package/dist/components/layout/popover/popover.styles.js +13 -0
- package/dist/components/layout/popover/popover.styles.js.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.js +5 -0
- package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
- package/dist/components/navigation/menu-bar/menu-bar.d.ts.map +1 -1
- package/dist/components/navigation/menu-bar/menu-bar.js +2 -0
- package/dist/components/navigation/menu-bar/menu-bar.js.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +3 -0
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
- package/dist/components/status-and-feedback/banner/banner.d.ts +1 -1
- package/dist/components/status-and-feedback/banner/banner.js +2 -2
- package/dist/components/status-and-feedback/banner/banner.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.d.ts +1 -1
- package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.js +4 -2
- package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.i18n.d.ts +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.i18n.js +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.i18n.js.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.js +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.js.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.i18n.d.ts +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.i18n.js +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.i18n.js.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.js +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.js.map +1 -1
- package/dist/css/themes/donkergeel.css +5 -0
- package/dist/css/themes/geel.css +5 -0
- package/dist/css/themes.css +10 -0
- package/dist/css/variables.css +11 -11
- package/dist/nldd.min.js +1909 -1317
- package/dist/translations/en-US.d.ts.map +1 -1
- package/dist/translations/en-US.js +29 -4
- package/dist/translations/en-US.js.map +1 -1
- package/dist/translations/fy.d.ts.map +1 -1
- package/dist/translations/fy.js +29 -4
- package/dist/translations/fy.js.map +1 -1
- package/dist/translations/nl.generated.d.ts +29 -4
- package/dist/translations/nl.generated.d.ts.map +1 -1
- package/dist/translations/pap-AW.d.ts.map +1 -1
- package/dist/translations/pap-AW.js +29 -4
- package/dist/translations/pap-AW.js.map +1 -1
- package/dist/translations/pap-CW.d.ts.map +1 -1
- package/dist/translations/pap-CW.js +29 -4
- package/dist/translations/pap-CW.js.map +1 -1
- package/dist/types/vue.d.ts +12 -12
- package/dist/utilities/carried-context.d.ts +20 -0
- package/dist/utilities/carried-context.d.ts.map +1 -0
- package/dist/utilities/carried-context.js +76 -0
- package/dist/utilities/carried-context.js.map +1 -0
- package/dist/utilities/codemirror/languages.d.ts +5 -1
- package/dist/utilities/codemirror/languages.d.ts.map +1 -1
- package/dist/utilities/codemirror/languages.js +21 -1
- package/dist/utilities/codemirror/languages.js.map +1 -1
- package/dist/utilities/dismiss-from-title-bar.d.ts +1 -1
- package/dist/utilities/dismiss-from-title-bar.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/* Drag and drop for nldd-file-field: matching files against `accept`, and one
|
|
2
|
+
* listener set on the window shared by every field on the page.
|
|
3
|
+
*
|
|
4
|
+
* The window listeners do two things. While files are dragged over the page,
|
|
5
|
+
* every field shows it is a place to put them, and the field under the pointer
|
|
6
|
+
* shows it will take them. And a file dropped next to a field, where nothing
|
|
7
|
+
* else takes it, no longer makes the browser open it and leave the page with
|
|
8
|
+
* the form half filled in. A drop that something else handles (another drop
|
|
9
|
+
* zone, an editable field, a native file input) is left alone. */
|
|
10
|
+
/* MIME types of the extensions an `accept` most often names. While a file is
|
|
11
|
+
* dragged only its type is known, not its name, so this is how an extension in
|
|
12
|
+
* `accept` is matched before the drop. An extension missing here is not judged
|
|
13
|
+
* until the drop, when the name is there. */
|
|
14
|
+
const EXTENSION_TYPES = {
|
|
15
|
+
pdf: ['application/pdf'],
|
|
16
|
+
png: ['image/png'],
|
|
17
|
+
jpg: ['image/jpeg'],
|
|
18
|
+
jpeg: ['image/jpeg'],
|
|
19
|
+
gif: ['image/gif'],
|
|
20
|
+
webp: ['image/webp'],
|
|
21
|
+
svg: ['image/svg+xml'],
|
|
22
|
+
heic: ['image/heic'],
|
|
23
|
+
tif: ['image/tiff'],
|
|
24
|
+
tiff: ['image/tiff'],
|
|
25
|
+
txt: ['text/plain'],
|
|
26
|
+
csv: ['text/csv'],
|
|
27
|
+
json: ['application/json'],
|
|
28
|
+
odt: ['application/vnd.oasis.opendocument.text'],
|
|
29
|
+
ods: ['application/vnd.oasis.opendocument.spreadsheet'],
|
|
30
|
+
odp: ['application/vnd.oasis.opendocument.presentation'],
|
|
31
|
+
docx: ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
|
32
|
+
xlsx: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
|
33
|
+
};
|
|
34
|
+
/** How an extension is named to a person: one name for the spellings of one
|
|
35
|
+
* format. Any other extension is named in capitals. */
|
|
36
|
+
const EXTENSION_NAMES = { jpeg: 'JPG', tif: 'TIFF' };
|
|
37
|
+
/** What `accept` takes, named for a person, for the message on a drop of the
|
|
38
|
+
* wrong type. Null when any part has no name (an `application/vnd…` type),
|
|
39
|
+
* so the message does not list half of what is allowed. */
|
|
40
|
+
export function acceptNames(accept) {
|
|
41
|
+
const names = [];
|
|
42
|
+
const add = (name) => {
|
|
43
|
+
if (!names.some((known) => JSON.stringify(known) === JSON.stringify(name)))
|
|
44
|
+
names.push(name);
|
|
45
|
+
};
|
|
46
|
+
for (const token of tokens(accept)) {
|
|
47
|
+
if (token.startsWith('.')) {
|
|
48
|
+
const extension = token.slice(1);
|
|
49
|
+
add(EXTENSION_NAMES[extension] ?? extension.toUpperCase());
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const family = /^(image|video|audio)\/\*$/.exec(token)?.[1];
|
|
53
|
+
if (family) {
|
|
54
|
+
add({ family });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const extension = Object.keys(EXTENSION_TYPES).find((key) => EXTENSION_TYPES[key].includes(token));
|
|
58
|
+
if (!extension)
|
|
59
|
+
return null;
|
|
60
|
+
add(EXTENSION_NAMES[extension] ?? extension.toUpperCase());
|
|
61
|
+
}
|
|
62
|
+
return names.length > 0 ? names : null;
|
|
63
|
+
}
|
|
64
|
+
/** One spelling per format, so `.jpg` in `accept` takes a `.jpeg` file, as the
|
|
65
|
+
* file dialog does, which filters on the format and not on the letters. */
|
|
66
|
+
function sameFormat(extension) {
|
|
67
|
+
return { jpeg: 'jpg', tif: 'tiff' }[extension] ?? extension;
|
|
68
|
+
}
|
|
69
|
+
function tokens(accept) {
|
|
70
|
+
return accept.split(',').map((token) => token.trim().toLowerCase()).filter(Boolean);
|
|
71
|
+
}
|
|
72
|
+
function typeMatches(token, type) {
|
|
73
|
+
if (token.endsWith('/*'))
|
|
74
|
+
return type.startsWith(token.slice(0, -1));
|
|
75
|
+
return token === type;
|
|
76
|
+
}
|
|
77
|
+
/** Whether a dropped file fits `accept`, judged on its name and its type, the
|
|
78
|
+
* way the file dialog filters. An empty `accept` takes everything. */
|
|
79
|
+
export function fileMatches(accept, file) {
|
|
80
|
+
const list = tokens(accept);
|
|
81
|
+
if (list.length === 0)
|
|
82
|
+
return true;
|
|
83
|
+
const name = file.name.toLowerCase();
|
|
84
|
+
// Some platforms give HEIC and other less common formats no type, where the
|
|
85
|
+
// file dialog still goes by the extension; so does this.
|
|
86
|
+
const type = file.type.toLowerCase() || EXTENSION_TYPES[name.slice(name.lastIndexOf('.') + 1)]?.[0] || '';
|
|
87
|
+
const extension = sameFormat(name.slice(name.lastIndexOf('.') + 1));
|
|
88
|
+
return list.some((token) => (token.startsWith('.') ? sameFormat(token.slice(1)) === extension : typeMatches(token, type)));
|
|
89
|
+
}
|
|
90
|
+
/** Whether a dragged file of `type` can be ruled out against `accept` before the
|
|
91
|
+
* drop. Only a certain mismatch counts: an empty type or an extension this
|
|
92
|
+
* module has no type for leaves the answer to the drop. */
|
|
93
|
+
export function typeRuledOut(accept, type) {
|
|
94
|
+
const list = tokens(accept);
|
|
95
|
+
if (list.length === 0 || !type)
|
|
96
|
+
return false;
|
|
97
|
+
const lower = type.toLowerCase();
|
|
98
|
+
return list.every((token) => {
|
|
99
|
+
if (!token.startsWith('.'))
|
|
100
|
+
return !typeMatches(token, lower);
|
|
101
|
+
const known = EXTENSION_TYPES[token.slice(1)];
|
|
102
|
+
return known !== undefined && !known.includes(lower);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** Whether a drop holds a folder. It arrives as a File without type or
|
|
106
|
+
* extension, which the field could not read, so it is refused. */
|
|
107
|
+
export function holdsFolder(transfer) {
|
|
108
|
+
return Array.from(transfer.items).some((item) => item.kind === 'file' && item.webkitGetAsEntry?.()?.isDirectory);
|
|
109
|
+
}
|
|
110
|
+
/** Whether a drag carries files, as opposed to text or a link. */
|
|
111
|
+
export function carriesFiles(transfer) {
|
|
112
|
+
return !!transfer && Array.from(transfer.types).includes('Files');
|
|
113
|
+
}
|
|
114
|
+
/** Whether something under the pointer takes a dropped file on its own: the
|
|
115
|
+
* browser's default for it is not to open the file, so it is not ours to stop. */
|
|
116
|
+
function takesDropItself(path) {
|
|
117
|
+
const target = path[0];
|
|
118
|
+
if (!(target instanceof HTMLElement))
|
|
119
|
+
return false;
|
|
120
|
+
return target.isContentEditable
|
|
121
|
+
|| target instanceof HTMLTextAreaElement
|
|
122
|
+
|| (target instanceof HTMLInputElement && target.type === 'file');
|
|
123
|
+
}
|
|
124
|
+
const targets = new Set();
|
|
125
|
+
/* Dragover keeps firing while the pointer is on the page, even when it stands
|
|
126
|
+
* still: about every 50ms in Chrome, every 350ms in Firefox. A drag that leaves
|
|
127
|
+
* the window or is canceled sends no reliable event in every browser, so the
|
|
128
|
+
* page state ends when dragover stops coming, with room for a late event. A
|
|
129
|
+
* drop or dragend ends it at once. */
|
|
130
|
+
const DRAG_TIMEOUT_MS = 1000;
|
|
131
|
+
let endTimer;
|
|
132
|
+
function end() {
|
|
133
|
+
clearTimeout(endTimer);
|
|
134
|
+
for (const target of targets)
|
|
135
|
+
target._setDrag('none', null);
|
|
136
|
+
}
|
|
137
|
+
function onDragOver(event) {
|
|
138
|
+
if (!carriesFiles(event.dataTransfer))
|
|
139
|
+
return;
|
|
140
|
+
const path = event.composedPath();
|
|
141
|
+
for (const target of targets)
|
|
142
|
+
target._setDrag(path.includes(target) ? 'over' : 'page', event.dataTransfer);
|
|
143
|
+
clearTimeout(endTimer);
|
|
144
|
+
endTimer = setTimeout(end, DRAG_TIMEOUT_MS);
|
|
145
|
+
if (event.defaultPrevented || takesDropItself(path))
|
|
146
|
+
return;
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
event.dataTransfer.dropEffect = 'none';
|
|
149
|
+
}
|
|
150
|
+
function onDrop(event) {
|
|
151
|
+
if (!carriesFiles(event.dataTransfer))
|
|
152
|
+
return;
|
|
153
|
+
if (!event.defaultPrevented && !takesDropItself(event.composedPath()))
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
end();
|
|
156
|
+
}
|
|
157
|
+
/** Registers a field with the shared window listeners, which exist while at
|
|
158
|
+
* least one field is connected. */
|
|
159
|
+
export function watchDrags(target) {
|
|
160
|
+
if (targets.size === 0) {
|
|
161
|
+
window.addEventListener('dragover', onDragOver);
|
|
162
|
+
window.addEventListener('drop', onDrop);
|
|
163
|
+
window.addEventListener('dragend', end);
|
|
164
|
+
}
|
|
165
|
+
targets.add(target);
|
|
166
|
+
}
|
|
167
|
+
export function unwatchDrags(target) {
|
|
168
|
+
targets.delete(target);
|
|
169
|
+
if (targets.size > 0)
|
|
170
|
+
return;
|
|
171
|
+
window.removeEventListener('dragover', onDragOver);
|
|
172
|
+
window.removeEventListener('drop', onDrop);
|
|
173
|
+
window.removeEventListener('dragend', end);
|
|
174
|
+
clearTimeout(endTimer);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=file-field.drop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-field.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,KAAK,CAAC,gBAAgB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QAAE,KAAK,CAAC,cAAc,EAAE,CAAC;IAC9F,GAAG,EAAE,CAAC;AACP,CAAC;AAED;oCACoC;AACpC,MAAM,UAAU,UAAU,CAAC,MAAkB;IAC5C,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAChD,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC9C,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC;QAAE,OAAO;IAC7B,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACnD,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC3C,YAAY,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
export declare const nlddFileFieldTranslations: {
|
|
2
2
|
'components.file-field.to-choose-file-action': string;
|
|
3
3
|
'components.file-field.to-choose-files-action': string;
|
|
4
|
-
'components.file-field.
|
|
4
|
+
'components.file-field.to-change-action': string;
|
|
5
|
+
'components.file-field.drop-hint-lowercase-text': string;
|
|
6
|
+
'components.file-field.drop-hint-multiple-lowercase-text': string;
|
|
7
|
+
'components.file-field.drag-here-text': string;
|
|
8
|
+
'components.file-field.drag-here-multiple-text': string;
|
|
9
|
+
'components.file-field.drop-here-text': string;
|
|
10
|
+
'components.file-field.drop-here-multiple-text': string;
|
|
11
|
+
'components.file-field.replace-drag-text': string;
|
|
12
|
+
'components.file-field.replace-drop-text': string;
|
|
13
|
+
'components.file-field.file-type-error-text': string;
|
|
14
|
+
'components.file-field.files-type-error-text': string;
|
|
15
|
+
'components.file-field.wrong-file-type-error-text': string;
|
|
16
|
+
'components.file-field.image-lowercase': string;
|
|
17
|
+
'components.file-field.video-lowercase': string;
|
|
18
|
+
'components.file-field.audio-file-lowercase': string;
|
|
19
|
+
'components.file-field.list-lowercase-text': string;
|
|
20
|
+
'components.file-field.too-many-files-error-text': string;
|
|
21
|
+
'components.file-field.folder-error-text': string;
|
|
22
|
+
'components.file-field.folder-multiple-error-text': string;
|
|
5
23
|
'components.file-field.file-count-text': string;
|
|
24
|
+
'components.file-field.file-chosen-text': string;
|
|
6
25
|
'components.file-field.clear-action': string;
|
|
7
26
|
'components.file-field.required-error-text': string;
|
|
8
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-field.i18n.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/file-field/file-field.i18n.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"file-field.i18n.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/file-field/file-field.i18n.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BrC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,OAAO,yBAAyB,CAAC"}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
export const nlddFileFieldTranslations = {
|
|
2
2
|
'components.file-field.to-choose-file-action': 'Bestand kiezen',
|
|
3
3
|
'components.file-field.to-choose-files-action': 'Bestanden kiezen',
|
|
4
|
-
'components.file-field.
|
|
4
|
+
'components.file-field.to-change-action': 'Wijzigen',
|
|
5
|
+
'components.file-field.drop-hint-lowercase-text': 'of sleep het hierheen',
|
|
6
|
+
'components.file-field.drop-hint-multiple-lowercase-text': 'of sleep ze hierheen',
|
|
7
|
+
'components.file-field.drag-here-text': 'Sleep het bestand hierheen',
|
|
8
|
+
'components.file-field.drag-here-multiple-text': 'Sleep de bestanden hierheen',
|
|
9
|
+
'components.file-field.drop-here-text': 'Zet het bestand hier neer',
|
|
10
|
+
'components.file-field.drop-here-multiple-text': 'Zet de bestanden hier neer',
|
|
11
|
+
'components.file-field.replace-drag-text': 'Sleep hierheen om te vervangen',
|
|
12
|
+
'components.file-field.replace-drop-text': 'Zet hier neer om te vervangen',
|
|
13
|
+
'components.file-field.file-type-error-text': 'Het bestand moet een {types} zijn',
|
|
14
|
+
'components.file-field.files-type-error-text': 'Elk bestand moet een {types} zijn',
|
|
15
|
+
'components.file-field.wrong-file-type-error-text': 'Dit bestandstype past niet',
|
|
16
|
+
'components.file-field.image-lowercase': 'afbeelding',
|
|
17
|
+
'components.file-field.video-lowercase': 'video',
|
|
18
|
+
'components.file-field.audio-file-lowercase': 'geluidsbestand',
|
|
19
|
+
'components.file-field.list-lowercase-text': '{items} of {last}',
|
|
20
|
+
'components.file-field.too-many-files-error-text': 'Sleep één bestand',
|
|
21
|
+
'components.file-field.folder-error-text': 'Sleep een bestand, geen map',
|
|
22
|
+
'components.file-field.folder-multiple-error-text': 'Sleep bestanden, geen map',
|
|
5
23
|
'components.file-field.file-count-text': '{count} bestanden',
|
|
24
|
+
'components.file-field.file-chosen-text': '{name} gekozen',
|
|
6
25
|
'components.file-field.clear-action': 'Wis selectie',
|
|
7
26
|
'components.file-field.required-error-text': 'Kies een bestand',
|
|
8
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-field.i18n.js","sourceRoot":"","sources":["../../../../src/components/inputs/file-field/file-field.i18n.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,6CAA6C,EAAE,gBAAgB;IAC/D,8CAA8C,EAAE,kBAAkB;IAClE,
|
|
1
|
+
{"version":3,"file":"file-field.i18n.js","sourceRoot":"","sources":["../../../../src/components/inputs/file-field/file-field.i18n.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,6CAA6C,EAAE,gBAAgB;IAC/D,8CAA8C,EAAE,kBAAkB;IAClE,wCAAwC,EAAE,UAAU;IACpD,gDAAgD,EAAE,uBAAuB;IACzE,yDAAyD,EAAE,sBAAsB;IACjF,sCAAsC,EAAE,4BAA4B;IACpE,+CAA+C,EAAE,6BAA6B;IAC9E,sCAAsC,EAAE,2BAA2B;IACnE,+CAA+C,EAAE,4BAA4B;IAC7E,yCAAyC,EAAE,gCAAgC;IAC3E,yCAAyC,EAAE,+BAA+B;IAC1E,4CAA4C,EAAE,mCAAmC;IACjF,6CAA6C,EAAE,mCAAmC;IAClF,kDAAkD,EAAE,4BAA4B;IAChF,uCAAuC,EAAE,YAAY;IACrD,uCAAuC,EAAE,OAAO;IAChD,4CAA4C,EAAE,gBAAgB;IAC9D,2CAA2C,EAAE,mBAAmB;IAChE,iDAAiD,EAAE,mBAAmB;IACtE,yCAAyC,EAAE,6BAA6B;IACxE,kDAAkD,EAAE,2BAA2B;IAC/E,uCAAuC,EAAE,mBAAmB;IAC5D,wCAAwC,EAAE,gBAAgB;IAC1D,oCAAoC,EAAE,cAAc;IACpD,2CAA2C,EAAE,kBAAkB;CAC/D,CAAC"}
|
|
@@ -7,18 +7,41 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
/**
|
|
8
8
|
* Nederlandse Digitale Dienst File Field Component (Lit + TypeScript)
|
|
9
9
|
*
|
|
10
|
-
* A file picker that reads as one control
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* A file picker that reads as one control. Empty, the whole tinted surface is
|
|
11
|
+
* one button with one sentence centered in it, "Bestand kiezen of sleep het
|
|
12
|
+
* hierheen", its first part accented, so a press anywhere on it opens the file
|
|
13
|
+
* dialog. Once a file is chosen, the surface shows it with the icon of its
|
|
14
|
+
* format, its name, a button to choose another and a dismiss button to clear it
|
|
15
|
+
* again. A long name is cut in the middle, so its start and its end stay in
|
|
16
|
+
* view ("Screenshot 20…at 13.12.21.png"); it then shows whole in a tooltip, and
|
|
17
|
+
* a screen reader reads it whole either way. It wraps a hidden native
|
|
18
|
+
* `<input type="file">`, which is what makes the picker open at all — a file
|
|
19
|
+
* dialog only opens from a user gesture on a real input.
|
|
20
|
+
*
|
|
21
|
+
* Files can be dropped on the whole field. A drop goes through the same input,
|
|
22
|
+
* so it fires the same `change` with the same detail and submits the same way as
|
|
23
|
+
* a pick. `accept` and `multiple` hold for a drop too, which the native input
|
|
24
|
+
* does not do: a drop that does not fit is refused as a whole, the previous
|
|
25
|
+
* choice stays, and the field says why for a few seconds: "Sleep één
|
|
26
|
+
* bestand", or what `accept` takes, named from it ("Het bestand moet een PDF
|
|
27
|
+
* zijn"; "Dit bestandstype past niet" where a type in it has no name). A
|
|
28
|
+
* dropped folder is refused as well ("Sleep een bestand, geen map"): it
|
|
29
|
+
* arrives as a file without a type that cannot be read, and only the drop
|
|
30
|
+
* tells it apart, not the drag. The message stays for a few seconds and then
|
|
31
|
+
* gives way to the field again.
|
|
32
|
+
*
|
|
33
|
+
* While files are dragged over the page, every field marks itself as a place
|
|
34
|
+
* to put them, and the field under the pointer says it will take them (a field
|
|
35
|
+
* with a file: that they replace it), or turns critical and refuses already
|
|
36
|
+
* when the number or the type rules them out. A file dropped next to a field no
|
|
37
|
+
* longer makes the browser open it and leave the page; a drop that another drop zone or an
|
|
38
|
+
* editable field takes is left alone. On a device without hover there is no
|
|
39
|
+
* dragging, so the field there drops the hint.
|
|
15
40
|
*
|
|
16
41
|
* The surface deliberately does not look like an input field. A border with
|
|
17
|
-
* field semantics promises you can type into it; here you can only press
|
|
18
|
-
*
|
|
19
|
-
* `--semantics-input-fields-*`.
|
|
20
|
-
* therefore sits a shade darker in the surface, which is what marks it as the
|
|
21
|
-
* thing to press.
|
|
42
|
+
* field semantics promises you can type into it; here you can only press it or
|
|
43
|
+
* drop a file on it, so it has the border of a tinted surface instead of
|
|
44
|
+
* `--semantics-input-fields-*`.
|
|
22
45
|
*
|
|
23
46
|
* Several files are summarized, not listed: "3 bestanden" with a single cross
|
|
24
47
|
* that clears all of them. Every pick replaces the whole FileList, and rebuilding
|
|
@@ -53,8 +76,18 @@ import { reflectNonDefault } from '../../../utilities/reflect-non-default.js';
|
|
|
53
76
|
import { fileFieldStyles } from './file-field.styles.js';
|
|
54
77
|
import { fileFieldTemplate } from './file-field.template.js';
|
|
55
78
|
import { nlddFileFieldTranslations } from './file-field.i18n.js';
|
|
79
|
+
import { acceptNames, carriesFiles, holdsFolder, fileMatches, typeRuledOut, unwatchDrags, watchDrags, } from './file-field.drop.js';
|
|
80
|
+
import { textMeasurer, truncateMiddle } from './file-field.truncate.js';
|
|
56
81
|
import { DescribedBy } from '../../../utilities/described-by-mixin.js';
|
|
57
82
|
import { translate } from '../../../utilities/translations.js';
|
|
83
|
+
/** How long the message of a refused drop stays in the field. */
|
|
84
|
+
const REJECTION_MS = 4000;
|
|
85
|
+
/** The word for a family of types in `accept`, such as `image/*`. */
|
|
86
|
+
const FAMILY_KEYS = {
|
|
87
|
+
image: 'components.file-field.image-lowercase',
|
|
88
|
+
video: 'components.file-field.video-lowercase',
|
|
89
|
+
audio: 'components.file-field.audio-file-lowercase',
|
|
90
|
+
};
|
|
58
91
|
let NLDDFileField = class NLDDFileField extends DescribedBy(FormAssociated(LitElement)) {
|
|
59
92
|
constructor() {
|
|
60
93
|
super(...arguments);
|
|
@@ -74,6 +107,67 @@ let NLDDFileField = class NLDDFileField extends DescribedBy(FormAssociated(LitEl
|
|
|
74
107
|
/** The chosen files. Mirrors the input's FileList; there is no setter, because
|
|
75
108
|
* browsers refuse a programmatic file selection. */
|
|
76
109
|
this._files = [];
|
|
110
|
+
/** @internal Where a dragged file is, seen from this field. */
|
|
111
|
+
this._drag = 'none';
|
|
112
|
+
/** @internal Why the file under the pointer would be refused. */
|
|
113
|
+
this._dragRejection = null;
|
|
114
|
+
/** @internal The chosen name cut in the middle to fit, or null before it is
|
|
115
|
+
* measured, while CSS cuts it with its end in view. */
|
|
116
|
+
this._fittedName = null;
|
|
117
|
+
/** @internal Whether the name is cut short, and so shows whole in a tooltip. */
|
|
118
|
+
this._nameTruncated = false;
|
|
119
|
+
/** @internal What a screen reader hears after a drop that was taken. */
|
|
120
|
+
this._announcement = '';
|
|
121
|
+
/** @internal Why the last drop was refused; shown for a few seconds. */
|
|
122
|
+
this._rejection = null;
|
|
123
|
+
this._handleDragOver = (e) => {
|
|
124
|
+
if (this.disabled || !e.dataTransfer || !carriesFiles(e.dataTransfer))
|
|
125
|
+
return;
|
|
126
|
+
// Left unhandled, the window listener refuses the drop with a no-drop cursor.
|
|
127
|
+
if (this._judge(e.dataTransfer))
|
|
128
|
+
return;
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
e.dataTransfer.dropEffect = 'copy';
|
|
131
|
+
};
|
|
132
|
+
this._handleDrop = (e) => {
|
|
133
|
+
if (!e.dataTransfer || !carriesFiles(e.dataTransfer))
|
|
134
|
+
return;
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
if (this.disabled)
|
|
137
|
+
return;
|
|
138
|
+
const files = Array.from(e.dataTransfer.files);
|
|
139
|
+
const rejection = this._judge(e.dataTransfer, files);
|
|
140
|
+
if (rejection) {
|
|
141
|
+
this._rejection = rejection;
|
|
142
|
+
// Shown for a while, then the field reads as itself again: the message
|
|
143
|
+
// takes the place of "Bestand kiezen", and a field that kept it looked
|
|
144
|
+
// as if it no longer did anything. The status line keeps it for a
|
|
145
|
+
// screen reader.
|
|
146
|
+
clearTimeout(this._rejectionTimer);
|
|
147
|
+
this._rejectionTimer = setTimeout(() => {
|
|
148
|
+
this._announcement = this._rejectionText(rejection);
|
|
149
|
+
this._rejection = null;
|
|
150
|
+
}, REJECTION_MS);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (this._input)
|
|
154
|
+
this._input.files = e.dataTransfer.files;
|
|
155
|
+
this._files = files;
|
|
156
|
+
this._rejection = null;
|
|
157
|
+
// A pick moves focus to the change button, which names the file; a drop
|
|
158
|
+
// moves nothing, so it is said.
|
|
159
|
+
this._announcement = this._t('components.file-field.file-chosen-text', { name: this._valueLabel() });
|
|
160
|
+
this._commit();
|
|
161
|
+
};
|
|
162
|
+
this._clearRejection = () => {
|
|
163
|
+
clearTimeout(this._rejectionTimer);
|
|
164
|
+
this._rejection = null;
|
|
165
|
+
this._announcement = '';
|
|
166
|
+
};
|
|
167
|
+
this._handleKeydown = (e) => {
|
|
168
|
+
if (e.key === 'Escape')
|
|
169
|
+
this._clearRejection();
|
|
170
|
+
};
|
|
77
171
|
}
|
|
78
172
|
get files() {
|
|
79
173
|
return this._files;
|
|
@@ -100,15 +194,130 @@ let NLDDFileField = class NLDDFileField extends DescribedBy(FormAssociated(LitEl
|
|
|
100
194
|
return '';
|
|
101
195
|
return `${this._chooseLabel()}, ${this.accessibleLabel}`;
|
|
102
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* The change button is where focus lands after a pick, so its name says for
|
|
199
|
+
* which field and which file is chosen, as a native file input does. The
|
|
200
|
+
* visible text comes first, so a voice command with it still finds the
|
|
201
|
+
* button (WCAG 2.5.3).
|
|
202
|
+
*
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
_changeAccessibleLabel() {
|
|
206
|
+
return [this._t('components.file-field.to-change-action'), this.accessibleLabel, this._valueLabel()]
|
|
207
|
+
.filter(Boolean)
|
|
208
|
+
.join(', ');
|
|
209
|
+
}
|
|
210
|
+
/** @internal The cross says which file it clears. */
|
|
211
|
+
_clearAccessibleLabel() {
|
|
212
|
+
return `${this._t('components.file-field.clear-action')}, ${this._valueLabel()}`;
|
|
213
|
+
}
|
|
214
|
+
/** @internal */
|
|
215
|
+
_rejectionText(reason) {
|
|
216
|
+
if (reason === 'count')
|
|
217
|
+
return this._t('components.file-field.too-many-files-error-text');
|
|
218
|
+
if (reason === 'folder') {
|
|
219
|
+
return this.multiple
|
|
220
|
+
? this._t('components.file-field.folder-multiple-error-text')
|
|
221
|
+
: this._t('components.file-field.folder-error-text');
|
|
222
|
+
}
|
|
223
|
+
const names = acceptNames(this.accept);
|
|
224
|
+
if (!names)
|
|
225
|
+
return this._t('components.file-field.wrong-file-type-error-text');
|
|
226
|
+
const named = names.map((name) => (typeof name === 'string'
|
|
227
|
+
? name
|
|
228
|
+
: this._t(FAMILY_KEYS[name.family])));
|
|
229
|
+
const types = named.length === 1
|
|
230
|
+
? named[0]
|
|
231
|
+
: this._t('components.file-field.list-lowercase-text', { items: named.slice(0, -1).join(', '), last: named[named.length - 1] });
|
|
232
|
+
return this.multiple
|
|
233
|
+
? this._t('components.file-field.files-type-error-text', { types })
|
|
234
|
+
: this._t('components.file-field.file-type-error-text', { types });
|
|
235
|
+
}
|
|
103
236
|
/** @internal */
|
|
104
237
|
_valueLabel() {
|
|
105
|
-
if (this._files.length === 0)
|
|
106
|
-
return this._t('components.file-field.no-file-chosen-text');
|
|
107
238
|
if (this._files.length === 1)
|
|
108
239
|
return this._files[0].name;
|
|
109
240
|
return this._t('components.file-field.file-count-text', { count: this._files.length });
|
|
110
241
|
}
|
|
242
|
+
connectedCallback() {
|
|
243
|
+
super.connectedCallback();
|
|
244
|
+
watchDrags(this);
|
|
245
|
+
this._resizeObserver ?? (this._resizeObserver = new ResizeObserver(() => this._fitName()));
|
|
246
|
+
this._resizeObserver.observe(this);
|
|
247
|
+
// The first measurement can run in the fallback font.
|
|
248
|
+
void document.fonts?.ready.then(() => {
|
|
249
|
+
if (this.isConnected)
|
|
250
|
+
this._fitName();
|
|
251
|
+
});
|
|
252
|
+
this.addEventListener('dragover', this._handleDragOver);
|
|
253
|
+
this.addEventListener('drop', this._handleDrop);
|
|
254
|
+
this.addEventListener('pointerdown', this._clearRejection);
|
|
255
|
+
this.addEventListener('keydown', this._handleKeydown);
|
|
256
|
+
}
|
|
257
|
+
disconnectedCallback() {
|
|
258
|
+
super.disconnectedCallback();
|
|
259
|
+
unwatchDrags(this);
|
|
260
|
+
this._resizeObserver?.disconnect();
|
|
261
|
+
clearTimeout(this._rejectionTimer);
|
|
262
|
+
this._observedValue = undefined;
|
|
263
|
+
this.removeEventListener('dragover', this._handleDragOver);
|
|
264
|
+
this.removeEventListener('drop', this._handleDrop);
|
|
265
|
+
this.removeEventListener('pointerdown', this._clearRejection);
|
|
266
|
+
this.removeEventListener('keydown', this._handleKeydown);
|
|
267
|
+
}
|
|
268
|
+
updated(changed) {
|
|
269
|
+
// Dragging hides the name, so it is measured again once it is back.
|
|
270
|
+
if (changed.has('_files') || changed.has('size') || changed.has('_drag'))
|
|
271
|
+
void this._fitNameAfterRender();
|
|
272
|
+
}
|
|
273
|
+
/** Measures once the buttons beside the name have rendered and taken their
|
|
274
|
+
* width, and after this update rather than in it, where a state change
|
|
275
|
+
* would start another. */
|
|
276
|
+
async _fitNameAfterRender() {
|
|
277
|
+
const buttons = this.shadowRoot?.querySelectorAll('nldd-button, nldd-icon-button') ?? [];
|
|
278
|
+
await Promise.all(Array.from(buttons, (button) => button.updateComplete));
|
|
279
|
+
this._fitName();
|
|
280
|
+
}
|
|
281
|
+
/** Cuts the chosen name in the middle to the width it has. Without a width
|
|
282
|
+
* (a hidden field), it falls back to the CSS cut of the first render. */
|
|
283
|
+
_fitName() {
|
|
284
|
+
const value = this.shadowRoot?.querySelector('.file-field__value');
|
|
285
|
+
const name = this.shadowRoot?.querySelector('.file-field__name');
|
|
286
|
+
if (this._files.length !== 1 || !value || !name) {
|
|
287
|
+
this._fittedName = null;
|
|
288
|
+
this._nameTruncated = false;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
// The buttons beside the name take their width after their own render, so
|
|
292
|
+
// the width of the name itself is watched, not only the host's.
|
|
293
|
+
if (value !== this._observedValue) {
|
|
294
|
+
if (this._observedValue)
|
|
295
|
+
this._resizeObserver?.unobserve(this._observedValue);
|
|
296
|
+
this._resizeObserver?.observe(value);
|
|
297
|
+
this._observedValue = value;
|
|
298
|
+
}
|
|
299
|
+
const style = getComputedStyle(value);
|
|
300
|
+
const width = value.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
|
301
|
+
if (width <= 0) {
|
|
302
|
+
this._fittedName = null;
|
|
303
|
+
this._nameTruncated = false;
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const { measure, done } = textMeasurer(name);
|
|
307
|
+
try {
|
|
308
|
+
const { text, truncated } = truncateMiddle(this._files[0].name, width, measure);
|
|
309
|
+
this._fittedName = text;
|
|
310
|
+
this._nameTruncated = truncated;
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
done();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
111
316
|
willUpdate(changed) {
|
|
317
|
+
if (changed.has('_files')) {
|
|
318
|
+
this._fittedName = null;
|
|
319
|
+
this._nameTruncated = false;
|
|
320
|
+
}
|
|
112
321
|
if (changed.has('required'))
|
|
113
322
|
this._updateValidity();
|
|
114
323
|
if (changed.has('accessibleLabel'))
|
|
@@ -116,14 +325,51 @@ let NLDDFileField = class NLDDFileField extends DescribedBy(FormAssociated(LitEl
|
|
|
116
325
|
}
|
|
117
326
|
/** @internal */
|
|
118
327
|
_handleChoose() {
|
|
328
|
+
this._clearRejection();
|
|
119
329
|
this._input?.click();
|
|
120
330
|
}
|
|
121
331
|
/** @internal */
|
|
122
332
|
_handleInputChange(e) {
|
|
123
333
|
e.stopPropagation();
|
|
124
334
|
const input = e.target;
|
|
335
|
+
// The choose button gives way to the change button once there is a file,
|
|
336
|
+
// and the other way round, so focus would land on the body.
|
|
337
|
+
const hadFocus = this.matches(':focus-within');
|
|
125
338
|
this._files = input.files ? Array.from(input.files) : [];
|
|
339
|
+
this._rejection = null;
|
|
126
340
|
this._commit();
|
|
341
|
+
if (hadFocus)
|
|
342
|
+
void this.updateComplete.then(() => this.focus());
|
|
343
|
+
}
|
|
344
|
+
// — Drag and drop ————————————————————————————————————————————————————————
|
|
345
|
+
/** Why a drag or drop would be refused: too many files for a field without
|
|
346
|
+
* `multiple`, or a type `accept` rules out. With `files` the drop is judged
|
|
347
|
+
* on names and types; without, a drag only on what it shows before the drop. */
|
|
348
|
+
_judge(transfer, files) {
|
|
349
|
+
if (files) {
|
|
350
|
+
if (!this.multiple && files.length > 1)
|
|
351
|
+
return 'count';
|
|
352
|
+
if (holdsFolder(transfer))
|
|
353
|
+
return 'folder';
|
|
354
|
+
return files.every((file) => fileMatches(this.accept, file)) ? null : 'type';
|
|
355
|
+
}
|
|
356
|
+
const items = Array.from(transfer.items).filter((item) => item.kind === 'file');
|
|
357
|
+
if (!this.multiple && items.length > 1)
|
|
358
|
+
return 'count';
|
|
359
|
+
return items.some((item) => typeRuledOut(this.accept, item.type)) ? 'type' : null;
|
|
360
|
+
}
|
|
361
|
+
/** @internal Called by the shared window listeners in file-field.drop.ts. */
|
|
362
|
+
_setDrag(state, transfer) {
|
|
363
|
+
if (this.disabled)
|
|
364
|
+
state = 'none';
|
|
365
|
+
// Called on every dragover on the page; only over the field is there
|
|
366
|
+
// anything to judge.
|
|
367
|
+
if (state !== 'over' && state === this._drag)
|
|
368
|
+
return;
|
|
369
|
+
if (state !== 'none' && this._drag === 'none')
|
|
370
|
+
this._clearRejection();
|
|
371
|
+
this._dragRejection = state === 'over' && transfer ? this._judge(transfer) : null;
|
|
372
|
+
this._drag = this._dragRejection ? 'rejected' : state;
|
|
127
373
|
}
|
|
128
374
|
/** @internal */
|
|
129
375
|
_handleClear() {
|
|
@@ -177,19 +423,23 @@ let NLDDFileField = class NLDDFileField extends DescribedBy(FormAssociated(LitEl
|
|
|
177
423
|
this._files = [];
|
|
178
424
|
this.commitFormValue();
|
|
179
425
|
}
|
|
426
|
+
/** The button that opens the dialog: the whole surface while the field is
|
|
427
|
+
* empty, "Wijzigen" once it has a file. */
|
|
428
|
+
_chooseButton() {
|
|
429
|
+
return this.shadowRoot?.querySelector('.file-field__browse-button, nldd-button') ?? null;
|
|
430
|
+
}
|
|
180
431
|
/**
|
|
181
432
|
* Delegates focus to the choose button rather than the hidden input: an input
|
|
182
433
|
* that is `display: none` cannot take focus, and the button is what a user
|
|
183
434
|
* sees as the control.
|
|
184
435
|
*/
|
|
185
436
|
focus(options) {
|
|
186
|
-
|
|
187
|
-
button?.focus(options);
|
|
437
|
+
this._chooseButton()?.focus(options);
|
|
188
438
|
}
|
|
189
439
|
/** The file input is display:none and therefore not in the accessibility tree.
|
|
190
440
|
* What a screen reader meets is the button, so the description goes there. */
|
|
191
441
|
describedTarget() {
|
|
192
|
-
return this.
|
|
442
|
+
return this._chooseButton();
|
|
193
443
|
}
|
|
194
444
|
render() {
|
|
195
445
|
return fileFieldTemplate(this);
|
|
@@ -235,6 +485,24 @@ __decorate([
|
|
|
235
485
|
__decorate([
|
|
236
486
|
state()
|
|
237
487
|
], NLDDFileField.prototype, "_files", void 0);
|
|
488
|
+
__decorate([
|
|
489
|
+
state()
|
|
490
|
+
], NLDDFileField.prototype, "_drag", void 0);
|
|
491
|
+
__decorate([
|
|
492
|
+
state()
|
|
493
|
+
], NLDDFileField.prototype, "_dragRejection", void 0);
|
|
494
|
+
__decorate([
|
|
495
|
+
state()
|
|
496
|
+
], NLDDFileField.prototype, "_fittedName", void 0);
|
|
497
|
+
__decorate([
|
|
498
|
+
state()
|
|
499
|
+
], NLDDFileField.prototype, "_nameTruncated", void 0);
|
|
500
|
+
__decorate([
|
|
501
|
+
state()
|
|
502
|
+
], NLDDFileField.prototype, "_announcement", void 0);
|
|
503
|
+
__decorate([
|
|
504
|
+
state()
|
|
505
|
+
], NLDDFileField.prototype, "_rejection", void 0);
|
|
238
506
|
__decorate([
|
|
239
507
|
query('.file-field__input')
|
|
240
508
|
], NLDDFileField.prototype, "_input", void 0);
|