@neural-ui/core 1.3.2 → 1.5.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/README.md +14 -7
- package/calendar/package.json +4 -0
- package/fesm2022/neural-ui-core-accordion.mjs +8 -6
- package/fesm2022/neural-ui-core-accordion.mjs.map +1 -1
- package/fesm2022/neural-ui-core-autocomplete.mjs +121 -29
- package/fesm2022/neural-ui-core-autocomplete.mjs.map +1 -1
- package/fesm2022/neural-ui-core-badge.mjs +2 -2
- package/fesm2022/neural-ui-core-badge.mjs.map +1 -1
- package/fesm2022/neural-ui-core-block-ui.mjs +2 -2
- package/fesm2022/neural-ui-core-button.mjs +2 -2
- package/fesm2022/neural-ui-core-button.mjs.map +1 -1
- package/fesm2022/neural-ui-core-calendar.mjs +551 -0
- package/fesm2022/neural-ui-core-calendar.mjs.map +1 -0
- package/fesm2022/neural-ui-core-chip.mjs +2 -2
- package/fesm2022/neural-ui-core-chip.mjs.map +1 -1
- package/fesm2022/neural-ui-core-color-picker.mjs +3 -9
- package/fesm2022/neural-ui-core-color-picker.mjs.map +1 -1
- package/fesm2022/neural-ui-core-confirm-dialog.mjs +2 -2
- package/fesm2022/neural-ui-core-confirm-dialog.mjs.map +1 -1
- package/fesm2022/neural-ui-core-dashboard-grid.mjs +2 -2
- package/fesm2022/neural-ui-core-dashboard-grid.mjs.map +1 -1
- package/fesm2022/neural-ui-core-date-input.mjs +2 -2
- package/fesm2022/neural-ui-core-date-input.mjs.map +1 -1
- package/fesm2022/neural-ui-core-filter-bar.mjs +2 -2
- package/fesm2022/neural-ui-core-filter-bar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-image-gallery.mjs +224 -0
- package/fesm2022/neural-ui-core-image-gallery.mjs.map +1 -0
- package/fesm2022/neural-ui-core-input.mjs +2 -2
- package/fesm2022/neural-ui-core-kanban.mjs +270 -0
- package/fesm2022/neural-ui-core-kanban.mjs.map +1 -0
- package/fesm2022/neural-ui-core-meter-group.mjs +2 -2
- package/fesm2022/neural-ui-core-modal.mjs +81 -31
- package/fesm2022/neural-ui-core-modal.mjs.map +1 -1
- package/fesm2022/neural-ui-core-multiselect.mjs +269 -99
- package/fesm2022/neural-ui-core-multiselect.mjs.map +1 -1
- package/fesm2022/neural-ui-core-nav.mjs +4 -6
- package/fesm2022/neural-ui-core-nav.mjs.map +1 -1
- package/fesm2022/neural-ui-core-number-input.mjs +2 -2
- package/fesm2022/neural-ui-core-pagination.mjs +2 -2
- package/fesm2022/neural-ui-core-pagination.mjs.map +1 -1
- package/fesm2022/neural-ui-core-progress-bar.mjs +2 -2
- package/fesm2022/neural-ui-core-scheduler-gantt.mjs +289 -0
- package/fesm2022/neural-ui-core-scheduler-gantt.mjs.map +1 -0
- package/fesm2022/neural-ui-core-select.mjs +276 -101
- package/fesm2022/neural-ui-core-select.mjs.map +1 -1
- package/fesm2022/neural-ui-core-sidebar.mjs +3 -2
- package/fesm2022/neural-ui-core-sidebar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-slider.mjs +2 -2
- package/fesm2022/neural-ui-core-slider.mjs.map +1 -1
- package/fesm2022/neural-ui-core-split-button.mjs +2 -2
- package/fesm2022/neural-ui-core-split-button.mjs.map +1 -1
- package/fesm2022/neural-ui-core-stepper.mjs +2 -2
- package/fesm2022/neural-ui-core-stepper.mjs.map +1 -1
- package/fesm2022/neural-ui-core-table.mjs +435 -34
- package/fesm2022/neural-ui-core-table.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tabs.mjs +11 -4
- package/fesm2022/neural-ui-core-tabs.mjs.map +1 -1
- package/fesm2022/neural-ui-core-textarea.mjs +2 -2
- package/fesm2022/neural-ui-core-timeline-grid.mjs +215 -0
- package/fesm2022/neural-ui-core-timeline-grid.mjs.map +1 -0
- package/fesm2022/neural-ui-core-toggle-button-group.mjs +2 -2
- package/fesm2022/neural-ui-core-toggle-button-group.mjs.map +1 -1
- package/fesm2022/neural-ui-core-toolbar.mjs +2 -2
- package/fesm2022/neural-ui-core-toolbar.mjs.map +1 -1
- package/fesm2022/neural-ui-core-tree-table.mjs +262 -0
- package/fesm2022/neural-ui-core-tree-table.mjs.map +1 -0
- package/fesm2022/neural-ui-core-tree.mjs +413 -0
- package/fesm2022/neural-ui-core-tree.mjs.map +1 -0
- package/fesm2022/neural-ui-core-uploader.mjs +624 -0
- package/fesm2022/neural-ui-core-uploader.mjs.map +1 -0
- package/fesm2022/neural-ui-core-url-state.mjs +90 -10
- package/fesm2022/neural-ui-core-url-state.mjs.map +1 -1
- package/fesm2022/neural-ui-core-virtual-list.mjs +53 -23
- package/fesm2022/neural-ui-core-virtual-list.mjs.map +1 -1
- package/fesm2022/neural-ui-core.mjs +3 -1
- package/fesm2022/neural-ui-core.mjs.map +1 -1
- package/image-gallery/package.json +4 -0
- package/kanban/package.json +4 -0
- package/package.json +34 -2
- package/scheduler-gantt/package.json +4 -0
- package/styles/_tokens.scss +13 -4
- package/timeline-grid/package.json +4 -0
- package/tree/package.json +4 -0
- package/tree-table/package.json +4 -0
- package/types/neural-ui-core-autocomplete.d.ts +10 -1
- package/types/neural-ui-core-calendar.d.ts +79 -0
- package/types/neural-ui-core-color-picker.d.ts +0 -1
- package/types/neural-ui-core-image-gallery.d.ts +26 -0
- package/types/neural-ui-core-kanban.d.ts +52 -0
- package/types/neural-ui-core-modal.d.ts +22 -16
- package/types/neural-ui-core-multiselect.d.ts +13 -1
- package/types/neural-ui-core-scheduler-gantt.d.ts +68 -0
- package/types/neural-ui-core-select.d.ts +14 -1
- package/types/neural-ui-core-sidebar.d.ts +1 -0
- package/types/neural-ui-core-table.d.ts +66 -4
- package/types/neural-ui-core-tabs.d.ts +1 -0
- package/types/neural-ui-core-timeline-grid.d.ts +55 -0
- package/types/neural-ui-core-tree-table.d.ts +72 -0
- package/types/neural-ui-core-tree.d.ts +52 -0
- package/types/neural-ui-core-uploader.d.ts +98 -0
- package/types/neural-ui-core-url-state.d.ts +9 -0
- package/types/neural-ui-core-virtual-list.d.ts +17 -1
- package/uploader/package.json +4 -0
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { viewChild, input, output, signal, computed, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { NeuButtonComponent } from '@neural-ui/core/button';
|
|
5
|
+
import { NeuProgressBarComponent } from '@neural-ui/core/progress-bar';
|
|
6
|
+
|
|
7
|
+
let _neuUploaderIdSeq = 0;
|
|
8
|
+
class NeuUploaderComponent {
|
|
9
|
+
fileInput = viewChild.required('fileInput');
|
|
10
|
+
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
11
|
+
hint = input('', ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
12
|
+
errorMessage = input('', ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
13
|
+
placeholder = input('Drag files here or select them from your device.', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
14
|
+
pickerDescription = input('Use the button below to choose files from your device.', ...(ngDevMode ? [{ debugName: "pickerDescription" }] : /* istanbul ignore next */ []));
|
|
15
|
+
dropzoneLabel = input('Drop files here to add them', ...(ngDevMode ? [{ debugName: "dropzoneLabel" }] : /* istanbul ignore next */ []));
|
|
16
|
+
chooseLabel = input('Choose files', ...(ngDevMode ? [{ debugName: "chooseLabel" }] : /* istanbul ignore next */ []));
|
|
17
|
+
clearLabel = input('Clear', ...(ngDevMode ? [{ debugName: "clearLabel" }] : /* istanbul ignore next */ []));
|
|
18
|
+
progressLabel = input('Upload in progress', ...(ngDevMode ? [{ debugName: "progressLabel" }] : /* istanbul ignore next */ []));
|
|
19
|
+
showPickerText = input(false, ...(ngDevMode ? [{ debugName: "showPickerText" }] : /* istanbul ignore next */ []));
|
|
20
|
+
showProgress = input(true, ...(ngDevMode ? [{ debugName: "showProgress" }] : /* istanbul ignore next */ []));
|
|
21
|
+
listAriaLabel = input('Selected files', ...(ngDevMode ? [{ debugName: "listAriaLabel" }] : /* istanbul ignore next */ []));
|
|
22
|
+
removeAriaLabel = input('Remove file', ...(ngDevMode ? [{ debugName: "removeAriaLabel" }] : /* istanbul ignore next */ []));
|
|
23
|
+
acceptedTypesLabel = input('Allowed types', ...(ngDevMode ? [{ debugName: "acceptedTypesLabel" }] : /* istanbul ignore next */ []));
|
|
24
|
+
maxFileSizeTextLabel = input('Max size', ...(ngDevMode ? [{ debugName: "maxFileSizeTextLabel" }] : /* istanbul ignore next */ []));
|
|
25
|
+
fileCountSingularLabel = input('file', ...(ngDevMode ? [{ debugName: "fileCountSingularLabel" }] : /* istanbul ignore next */ []));
|
|
26
|
+
fileCountPluralLabel = input('files', ...(ngDevMode ? [{ debugName: "fileCountPluralLabel" }] : /* istanbul ignore next */ []));
|
|
27
|
+
emptySelectionMessage = input('No file was selected.', ...(ngDevMode ? [{ debugName: "emptySelectionMessage" }] : /* istanbul ignore next */ []));
|
|
28
|
+
invalidTypeMessage = input('File {{fileName}} does not match the allowed file types.', ...(ngDevMode ? [{ debugName: "invalidTypeMessage" }] : /* istanbul ignore next */ []));
|
|
29
|
+
maxFileSizeMessage = input('File {{fileName}} exceeds the allowed maximum size.', ...(ngDevMode ? [{ debugName: "maxFileSizeMessage" }] : /* istanbul ignore next */ []));
|
|
30
|
+
duplicateFileMessage = input('File {{fileName}} has already been selected.', ...(ngDevMode ? [{ debugName: "duplicateFileMessage" }] : /* istanbul ignore next */ []));
|
|
31
|
+
maxFilesMessage = input('You can only select up to {{maxFiles}} files.', ...(ngDevMode ? [{ debugName: "maxFilesMessage" }] : /* istanbul ignore next */ []));
|
|
32
|
+
accept = input('', ...(ngDevMode ? [{ debugName: "accept" }] : /* istanbul ignore next */ []));
|
|
33
|
+
multiple = input(true, ...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
|
|
34
|
+
dropzone = input(true, ...(ngDevMode ? [{ debugName: "dropzone" }] : /* istanbul ignore next */ []));
|
|
35
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
36
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
37
|
+
maxFiles = input(null, ...(ngDevMode ? [{ debugName: "maxFiles" }] : /* istanbul ignore next */ []));
|
|
38
|
+
maxFileSize = input(null, ...(ngDevMode ? [{ debugName: "maxFileSize" }] : /* istanbul ignore next */ []));
|
|
39
|
+
progress = input(null, ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
|
|
40
|
+
filesSelected = output();
|
|
41
|
+
fileRemoved = output();
|
|
42
|
+
filesRejected = output();
|
|
43
|
+
cleared = output();
|
|
44
|
+
inputId = input(`neu-uploader-${++_neuUploaderIdSeq}`, ...(ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []));
|
|
45
|
+
isDragOver = signal(false, ...(ngDevMode ? [{ debugName: "isDragOver" }] : /* istanbul ignore next */ []));
|
|
46
|
+
internalErrors = signal([], ...(ngDevMode ? [{ debugName: "internalErrors" }] : /* istanbul ignore next */ []));
|
|
47
|
+
fileItems = signal([], ...(ngDevMode ? [{ debugName: "fileItems" }] : /* istanbul ignore next */ []));
|
|
48
|
+
cvaDisabled = signal(false, ...(ngDevMode ? [{ debugName: "cvaDisabled" }] : /* istanbul ignore next */ []));
|
|
49
|
+
onChange = () => { };
|
|
50
|
+
onTouched = () => { };
|
|
51
|
+
isDisabledFinal = computed(() => this.disabled() || this.cvaDisabled(), ...(ngDevMode ? [{ debugName: "isDisabledFinal" }] : /* istanbul ignore next */ []));
|
|
52
|
+
hasError = computed(() => !!this.displayErrorMessage(), ...(ngDevMode ? [{ debugName: "hasError" }] : /* istanbul ignore next */ []));
|
|
53
|
+
shouldShowProgress = computed(() => this.showProgress() && this.progress() !== null, ...(ngDevMode ? [{ debugName: "shouldShowProgress" }] : /* istanbul ignore next */ []));
|
|
54
|
+
pickerButtonAriaLabel = computed(() => this.showPickerText() && this.chooseLabel() ? null : this.chooseLabel(), ...(ngDevMode ? [{ debugName: "pickerButtonAriaLabel" }] : /* istanbul ignore next */ []));
|
|
55
|
+
describedBy = computed(() => {
|
|
56
|
+
if (this.hasError()) {
|
|
57
|
+
return `${this.inputId()}-error`;
|
|
58
|
+
}
|
|
59
|
+
return this.hint() ? `${this.inputId()}-hint` : null;
|
|
60
|
+
}, ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
|
|
61
|
+
headlineText = computed(() => this.isDragOver() && this.dropzone() ? this.dropzoneLabel() : this.chooseLabel(), ...(ngDevMode ? [{ debugName: "headlineText" }] : /* istanbul ignore next */ []));
|
|
62
|
+
descriptionText = computed(() => {
|
|
63
|
+
const parts = [this.dropzone() ? this.placeholder() : this.pickerDescription()];
|
|
64
|
+
if (this.accept()) {
|
|
65
|
+
parts.push(`${this.acceptedTypesLabel()}: ${this.accept()}`);
|
|
66
|
+
}
|
|
67
|
+
if (this.maxFileSize() !== null) {
|
|
68
|
+
parts.push(`${this.maxFileSizeTextLabel()}: ${this.formatBytes(this.maxFileSize() ?? 0)}`);
|
|
69
|
+
}
|
|
70
|
+
return parts.join(' · ');
|
|
71
|
+
}, ...(ngDevMode ? [{ debugName: "descriptionText" }] : /* istanbul ignore next */ []));
|
|
72
|
+
summaryText = computed(() => {
|
|
73
|
+
const totalSize = this.fileItems().reduce((acc, item) => acc + item.size, 0);
|
|
74
|
+
const fileCount = this.fileItems().length;
|
|
75
|
+
return `${fileCount} ${fileCount === 1 ? this.fileCountSingularLabel() : this.fileCountPluralLabel()} · ${this.formatBytes(totalSize)}`;
|
|
76
|
+
}, ...(ngDevMode ? [{ debugName: "summaryText" }] : /* istanbul ignore next */ []));
|
|
77
|
+
displayErrorMessage = computed(() => {
|
|
78
|
+
if (this.errorMessage()) {
|
|
79
|
+
return this.errorMessage();
|
|
80
|
+
}
|
|
81
|
+
const [first] = this.internalErrors();
|
|
82
|
+
return first?.message ?? '';
|
|
83
|
+
}, ...(ngDevMode ? [{ debugName: "displayErrorMessage" }] : /* istanbul ignore next */ []));
|
|
84
|
+
writeValue(value) {
|
|
85
|
+
if (!value) {
|
|
86
|
+
this.fileItems.set([]);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const files = Array.isArray(value) ? value : [value];
|
|
90
|
+
this.fileItems.set(files.map((file) => this.toItem(file)));
|
|
91
|
+
}
|
|
92
|
+
registerOnChange(fn) {
|
|
93
|
+
this.onChange = fn;
|
|
94
|
+
}
|
|
95
|
+
registerOnTouched(fn) {
|
|
96
|
+
this.onTouched = fn;
|
|
97
|
+
}
|
|
98
|
+
setDisabledState(isDisabled) {
|
|
99
|
+
this.cvaDisabled.set(isDisabled);
|
|
100
|
+
}
|
|
101
|
+
openFilePicker() {
|
|
102
|
+
if (this.isDisabledFinal()) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.onTouched();
|
|
106
|
+
this.fileInput().nativeElement.click();
|
|
107
|
+
}
|
|
108
|
+
onDropzoneKey(event) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
this.openFilePicker();
|
|
111
|
+
}
|
|
112
|
+
onNativeInputChange(event) {
|
|
113
|
+
const input = event.target;
|
|
114
|
+
this.consumeFiles(input.files);
|
|
115
|
+
input.value = '';
|
|
116
|
+
}
|
|
117
|
+
onDragOver(event) {
|
|
118
|
+
if (!this.dropzone() || this.isDisabledFinal()) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
this.isDragOver.set(true);
|
|
123
|
+
}
|
|
124
|
+
onDragLeave(event) {
|
|
125
|
+
if (!this.dropzone()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
this.isDragOver.set(false);
|
|
130
|
+
}
|
|
131
|
+
onDrop(event) {
|
|
132
|
+
if (!this.dropzone() || this.isDisabledFinal()) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
this.isDragOver.set(false);
|
|
137
|
+
this.consumeFiles(event.dataTransfer?.files ?? null);
|
|
138
|
+
}
|
|
139
|
+
removeFile(id, event) {
|
|
140
|
+
event?.stopPropagation();
|
|
141
|
+
const current = this.fileItems();
|
|
142
|
+
const match = current.find((item) => item.id === id);
|
|
143
|
+
if (!match) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const next = current.filter((item) => item.id !== id);
|
|
147
|
+
this.fileItems.set(next);
|
|
148
|
+
this.internalErrors.set([]);
|
|
149
|
+
this.emitValue(next);
|
|
150
|
+
this.fileRemoved.emit(match.file);
|
|
151
|
+
this.onTouched();
|
|
152
|
+
}
|
|
153
|
+
clearFiles(event) {
|
|
154
|
+
event?.stopPropagation();
|
|
155
|
+
this.fileItems.set([]);
|
|
156
|
+
this.internalErrors.set([]);
|
|
157
|
+
this.fileInput().nativeElement.value = '';
|
|
158
|
+
this.emitValue([]);
|
|
159
|
+
this.cleared.emit();
|
|
160
|
+
this.onTouched();
|
|
161
|
+
}
|
|
162
|
+
formatBytes(bytes) {
|
|
163
|
+
if (bytes === 0) {
|
|
164
|
+
return '0 B';
|
|
165
|
+
}
|
|
166
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
167
|
+
const base = 1024;
|
|
168
|
+
const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(base)), units.length - 1);
|
|
169
|
+
const size = bytes / Math.pow(base, exponent);
|
|
170
|
+
return `${size.toFixed(size >= 10 || exponent === 0 ? 0 : 1)} ${units[exponent]}`;
|
|
171
|
+
}
|
|
172
|
+
consumeFiles(list) {
|
|
173
|
+
if (!list || list.length === 0) {
|
|
174
|
+
this.reportErrors([
|
|
175
|
+
{
|
|
176
|
+
code: 'empty-selection',
|
|
177
|
+
message: this.emptySelectionMessage(),
|
|
178
|
+
},
|
|
179
|
+
]);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
this.onTouched();
|
|
183
|
+
const incoming = Array.from(list);
|
|
184
|
+
const current = this.fileItems();
|
|
185
|
+
const nextItems = this.multiple() ? [...current] : [];
|
|
186
|
+
const errors = [];
|
|
187
|
+
const existingIds = new Set(nextItems.map((item) => item.id));
|
|
188
|
+
for (const file of incoming) {
|
|
189
|
+
if (!this.isAcceptedType(file)) {
|
|
190
|
+
errors.push({
|
|
191
|
+
code: 'accept',
|
|
192
|
+
file,
|
|
193
|
+
message: this.interpolate(this.invalidTypeMessage(), { fileName: file.name }),
|
|
194
|
+
});
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (this.maxFileSize() !== null && file.size > (this.maxFileSize() ?? 0)) {
|
|
198
|
+
errors.push({
|
|
199
|
+
code: 'max-file-size',
|
|
200
|
+
file,
|
|
201
|
+
message: this.interpolate(this.maxFileSizeMessage(), { fileName: file.name }),
|
|
202
|
+
});
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const item = this.toItem(file);
|
|
206
|
+
if (existingIds.has(item.id)) {
|
|
207
|
+
errors.push({
|
|
208
|
+
code: 'duplicate',
|
|
209
|
+
file,
|
|
210
|
+
message: this.interpolate(this.duplicateFileMessage(), { fileName: file.name }),
|
|
211
|
+
});
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (this.maxFiles() !== null && nextItems.length >= (this.maxFiles() ?? 0)) {
|
|
215
|
+
errors.push({
|
|
216
|
+
code: 'max-files',
|
|
217
|
+
file,
|
|
218
|
+
message: this.interpolate(this.maxFilesMessage(), {
|
|
219
|
+
maxFiles: String(this.maxFiles() ?? 0),
|
|
220
|
+
}),
|
|
221
|
+
});
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
nextItems.push(item);
|
|
225
|
+
existingIds.add(item.id);
|
|
226
|
+
if (!this.multiple()) {
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
this.fileItems.set(nextItems);
|
|
231
|
+
this.internalErrors.set(errors);
|
|
232
|
+
this.emitValue(nextItems);
|
|
233
|
+
this.filesSelected.emit(nextItems.map((item) => item.file));
|
|
234
|
+
if (errors.length > 0) {
|
|
235
|
+
this.filesRejected.emit(errors);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
emitValue(items) {
|
|
239
|
+
this.onChange(items.map((item) => item.file));
|
|
240
|
+
}
|
|
241
|
+
toItem(file) {
|
|
242
|
+
return {
|
|
243
|
+
id: this.fileSignature(file),
|
|
244
|
+
file,
|
|
245
|
+
name: file.name,
|
|
246
|
+
size: file.size,
|
|
247
|
+
type: file.type,
|
|
248
|
+
progress: this.progress(),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
fileSignature(file) {
|
|
252
|
+
return `${file.name}__${file.size}__${file.lastModified}`;
|
|
253
|
+
}
|
|
254
|
+
reportErrors(errors) {
|
|
255
|
+
this.internalErrors.set(errors);
|
|
256
|
+
this.filesRejected.emit(errors);
|
|
257
|
+
}
|
|
258
|
+
interpolate(template, values) {
|
|
259
|
+
return Object.entries(values).reduce((result, [key, value]) => result.replaceAll(`{{${key}}}`, value), template);
|
|
260
|
+
}
|
|
261
|
+
isAcceptedType(file) {
|
|
262
|
+
const accept = this.accept().trim();
|
|
263
|
+
if (!accept) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
const acceptedTypes = accept
|
|
267
|
+
.split(',')
|
|
268
|
+
.map((item) => item.trim().toLowerCase())
|
|
269
|
+
.filter(Boolean);
|
|
270
|
+
const fileName = file.name.toLowerCase();
|
|
271
|
+
const mimeType = file.type.toLowerCase();
|
|
272
|
+
return acceptedTypes.some((rule) => {
|
|
273
|
+
if (rule.startsWith('.')) {
|
|
274
|
+
return fileName.endsWith(rule);
|
|
275
|
+
}
|
|
276
|
+
if (rule.endsWith('/*')) {
|
|
277
|
+
const prefix = rule.slice(0, -1);
|
|
278
|
+
return mimeType.startsWith(prefix);
|
|
279
|
+
}
|
|
280
|
+
return mimeType === rule;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: NeuUploaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
284
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: NeuUploaderComponent, isStandalone: true, selector: "neu-uploader", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, pickerDescription: { classPropertyName: "pickerDescription", publicName: "pickerDescription", isSignal: true, isRequired: false, transformFunction: null }, dropzoneLabel: { classPropertyName: "dropzoneLabel", publicName: "dropzoneLabel", isSignal: true, isRequired: false, transformFunction: null }, chooseLabel: { classPropertyName: "chooseLabel", publicName: "chooseLabel", isSignal: true, isRequired: false, transformFunction: null }, clearLabel: { classPropertyName: "clearLabel", publicName: "clearLabel", isSignal: true, isRequired: false, transformFunction: null }, progressLabel: { classPropertyName: "progressLabel", publicName: "progressLabel", isSignal: true, isRequired: false, transformFunction: null }, showPickerText: { classPropertyName: "showPickerText", publicName: "showPickerText", isSignal: true, isRequired: false, transformFunction: null }, showProgress: { classPropertyName: "showProgress", publicName: "showProgress", isSignal: true, isRequired: false, transformFunction: null }, listAriaLabel: { classPropertyName: "listAriaLabel", publicName: "listAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, removeAriaLabel: { classPropertyName: "removeAriaLabel", publicName: "removeAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, acceptedTypesLabel: { classPropertyName: "acceptedTypesLabel", publicName: "acceptedTypesLabel", isSignal: true, isRequired: false, transformFunction: null }, maxFileSizeTextLabel: { classPropertyName: "maxFileSizeTextLabel", publicName: "maxFileSizeTextLabel", isSignal: true, isRequired: false, transformFunction: null }, fileCountSingularLabel: { classPropertyName: "fileCountSingularLabel", publicName: "fileCountSingularLabel", isSignal: true, isRequired: false, transformFunction: null }, fileCountPluralLabel: { classPropertyName: "fileCountPluralLabel", publicName: "fileCountPluralLabel", isSignal: true, isRequired: false, transformFunction: null }, emptySelectionMessage: { classPropertyName: "emptySelectionMessage", publicName: "emptySelectionMessage", isSignal: true, isRequired: false, transformFunction: null }, invalidTypeMessage: { classPropertyName: "invalidTypeMessage", publicName: "invalidTypeMessage", isSignal: true, isRequired: false, transformFunction: null }, maxFileSizeMessage: { classPropertyName: "maxFileSizeMessage", publicName: "maxFileSizeMessage", isSignal: true, isRequired: false, transformFunction: null }, duplicateFileMessage: { classPropertyName: "duplicateFileMessage", publicName: "duplicateFileMessage", isSignal: true, isRequired: false, transformFunction: null }, maxFilesMessage: { classPropertyName: "maxFilesMessage", publicName: "maxFilesMessage", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, dropzone: { classPropertyName: "dropzone", publicName: "dropzone", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, maxFiles: { classPropertyName: "maxFiles", publicName: "maxFiles", isSignal: true, isRequired: false, transformFunction: null }, maxFileSize: { classPropertyName: "maxFileSize", publicName: "maxFileSize", isSignal: true, isRequired: false, transformFunction: null }, progress: { classPropertyName: "progress", publicName: "progress", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filesSelected: "filesSelected", fileRemoved: "fileRemoved", filesRejected: "filesRejected", cleared: "cleared" }, host: { properties: { "class.neu-uploader-host--sm": "size() === \"sm\"", "class.neu-uploader-host--lg": "size() === \"lg\"" }, classAttribute: "neu-uploader-host" }, providers: [
|
|
285
|
+
{
|
|
286
|
+
provide: NG_VALUE_ACCESSOR,
|
|
287
|
+
useExisting: forwardRef(() => NeuUploaderComponent),
|
|
288
|
+
multi: true,
|
|
289
|
+
},
|
|
290
|
+
], viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
291
|
+
@if (label()) {
|
|
292
|
+
<label class="neu-uploader__label" [for]="inputId()">{{ label() }}</label>
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
<input
|
|
296
|
+
#fileInput
|
|
297
|
+
class="neu-uploader__native-input"
|
|
298
|
+
[id]="inputId()"
|
|
299
|
+
type="file"
|
|
300
|
+
[attr.accept]="accept() || null"
|
|
301
|
+
[attr.multiple]="multiple() ? '' : null"
|
|
302
|
+
[disabled]="isDisabledFinal()"
|
|
303
|
+
[attr.aria-describedby]="describedBy()"
|
|
304
|
+
[attr.aria-invalid]="hasError() ? 'true' : null"
|
|
305
|
+
(change)="onNativeInputChange($event)"
|
|
306
|
+
/>
|
|
307
|
+
|
|
308
|
+
<div
|
|
309
|
+
class="neu-uploader"
|
|
310
|
+
[class.neu-uploader--disabled]="isDisabledFinal()"
|
|
311
|
+
[class.neu-uploader--drag-over]="isDragOver()"
|
|
312
|
+
[class.neu-uploader--error]="hasError()"
|
|
313
|
+
[class.neu-uploader--has-files]="fileItems().length > 0"
|
|
314
|
+
[class.neu-uploader--picker-only]="!dropzone()"
|
|
315
|
+
>
|
|
316
|
+
@if (dropzone()) {
|
|
317
|
+
<div
|
|
318
|
+
class="neu-uploader__dropzone"
|
|
319
|
+
[attr.aria-describedby]="describedBy()"
|
|
320
|
+
(click)="openFilePicker()"
|
|
321
|
+
(dragover)="onDragOver($event)"
|
|
322
|
+
(dragleave)="onDragLeave($event)"
|
|
323
|
+
(drop)="onDrop($event)"
|
|
324
|
+
>
|
|
325
|
+
<div class="neu-uploader__empty-icon" aria-hidden="true">
|
|
326
|
+
<svg
|
|
327
|
+
viewBox="0 0 24 24"
|
|
328
|
+
fill="none"
|
|
329
|
+
stroke="currentColor"
|
|
330
|
+
stroke-width="1.8"
|
|
331
|
+
stroke-linecap="round"
|
|
332
|
+
stroke-linejoin="round"
|
|
333
|
+
>
|
|
334
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
335
|
+
<polyline points="17 8 12 3 7 8" />
|
|
336
|
+
<line x1="12" y1="3" x2="12" y2="15" />
|
|
337
|
+
</svg>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<div class="neu-uploader__copy">
|
|
341
|
+
<p class="neu-uploader__headline">{{ headlineText() }}</p>
|
|
342
|
+
<p class="neu-uploader__description">{{ descriptionText() }}</p>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
<div class="neu-uploader__actions">
|
|
346
|
+
<button
|
|
347
|
+
neu-button
|
|
348
|
+
type="button"
|
|
349
|
+
variant="primary"
|
|
350
|
+
size="sm"
|
|
351
|
+
(click)="openFilePicker(); $event.stopPropagation()"
|
|
352
|
+
>
|
|
353
|
+
{{ chooseLabel() }}
|
|
354
|
+
</button>
|
|
355
|
+
@if (fileItems().length > 0) {
|
|
356
|
+
<button
|
|
357
|
+
neu-button
|
|
358
|
+
type="button"
|
|
359
|
+
variant="outline"
|
|
360
|
+
size="sm"
|
|
361
|
+
(click)="clearFiles($event)"
|
|
362
|
+
>
|
|
363
|
+
{{ clearLabel() }}
|
|
364
|
+
</button>
|
|
365
|
+
}
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
} @else {
|
|
369
|
+
<button
|
|
370
|
+
neu-button
|
|
371
|
+
type="button"
|
|
372
|
+
variant="primary"
|
|
373
|
+
size="sm"
|
|
374
|
+
icon="lucideUpload"
|
|
375
|
+
class="neu-uploader__picker-trigger"
|
|
376
|
+
[disabled]="isDisabledFinal()"
|
|
377
|
+
[attr.aria-label]="pickerButtonAriaLabel()"
|
|
378
|
+
[attr.aria-describedby]="describedBy()"
|
|
379
|
+
(click)="openFilePicker()"
|
|
380
|
+
>
|
|
381
|
+
@if (showPickerText() && chooseLabel()) {
|
|
382
|
+
{{ chooseLabel() }}
|
|
383
|
+
}
|
|
384
|
+
</button>
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
@if (shouldShowProgress()) {
|
|
388
|
+
<div class="neu-uploader__progress">
|
|
389
|
+
<neu-progress-bar
|
|
390
|
+
[value]="progress() ?? 0"
|
|
391
|
+
[label]="progressLabel()"
|
|
392
|
+
[showValue]="true"
|
|
393
|
+
size="sm"
|
|
394
|
+
/>
|
|
395
|
+
</div>
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
@if (fileItems().length > 0) {
|
|
399
|
+
<div class="neu-uploader__summary">
|
|
400
|
+
<span>{{ summaryText() }}</span>
|
|
401
|
+
@if (maxFiles() !== null) {
|
|
402
|
+
<span>{{ fileItems().length }}/{{ maxFiles() }}</span>
|
|
403
|
+
}
|
|
404
|
+
</div>
|
|
405
|
+
|
|
406
|
+
<ul class="neu-uploader__list" [attr.aria-label]="listAriaLabel()">
|
|
407
|
+
@for (item of fileItems(); track item.id) {
|
|
408
|
+
<li class="neu-uploader__item">
|
|
409
|
+
<div class="neu-uploader__item-main">
|
|
410
|
+
<span class="neu-uploader__item-name">{{ item.name }}</span>
|
|
411
|
+
<span class="neu-uploader__item-meta">{{ formatBytes(item.size) }}</span>
|
|
412
|
+
</div>
|
|
413
|
+
<button
|
|
414
|
+
class="neu-uploader__remove"
|
|
415
|
+
type="button"
|
|
416
|
+
[disabled]="isDisabledFinal()"
|
|
417
|
+
[attr.aria-label]="removeAriaLabel() + ' ' + item.name"
|
|
418
|
+
(click)="removeFile(item.id, $event)"
|
|
419
|
+
>
|
|
420
|
+
<svg
|
|
421
|
+
viewBox="0 0 24 24"
|
|
422
|
+
fill="none"
|
|
423
|
+
stroke="currentColor"
|
|
424
|
+
stroke-width="2"
|
|
425
|
+
stroke-linecap="round"
|
|
426
|
+
stroke-linejoin="round"
|
|
427
|
+
aria-hidden="true"
|
|
428
|
+
>
|
|
429
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
430
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
431
|
+
</svg>
|
|
432
|
+
</button>
|
|
433
|
+
</li>
|
|
434
|
+
}
|
|
435
|
+
</ul>
|
|
436
|
+
}
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
@if (hasError()) {
|
|
440
|
+
<p class="neu-uploader__error" [id]="inputId() + '-error'" role="alert">
|
|
441
|
+
{{ displayErrorMessage() }}
|
|
442
|
+
</p>
|
|
443
|
+
} @else if (hint()) {
|
|
444
|
+
<p class="neu-uploader__hint" [id]="inputId() + '-hint'">{{ hint() }}</p>
|
|
445
|
+
}
|
|
446
|
+
`, isInline: true, styles: [".neu-uploader-host{display:block}.neu-uploader-host--sm .neu-uploader__dropzone{min-height:144px;padding:var(--neu-space-4)}.neu-uploader-host--sm .neu-uploader__headline{font-size:var(--neu-text-base)}.neu-uploader-host--lg .neu-uploader__dropzone{min-height:208px;padding:var(--neu-space-8)}.neu-uploader-host--lg .neu-uploader__headline{font-size:var(--neu-text-xl)}.neu-uploader__label{display:block;font-size:var(--neu-text-sm);font-weight:500;color:var(--neu-text-muted);margin-bottom:var(--neu-space-2)}.neu-uploader__native-input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.neu-uploader{display:grid;gap:var(--neu-space-3)}.neu-uploader--picker-only{gap:var(--neu-space-2)}.neu-uploader--picker-only .neu-uploader__copy{gap:2px;max-width:none}.neu-uploader--picker-only .neu-uploader__progress{padding:var(--neu-space-2) var(--neu-space-3)}.neu-uploader--picker-only .neu-uploader__headline{font-size:var(--neu-text-base)}.neu-uploader--drag-over .neu-uploader__dropzone{border-color:var(--neu-primary);box-shadow:var(--neu-focus-ring-strong);transform:translateY(-1px)}.neu-uploader--error .neu-uploader__dropzone{border-color:var(--neu-error);background:radial-gradient(circle at top right,color-mix(in srgb,var(--neu-error) 6%,transparent),transparent 35%),color-mix(in srgb,var(--neu-error) 5%,var(--neu-surface))}.neu-uploader--disabled .neu-uploader__dropzone{opacity:.7;cursor:not-allowed;background:var(--neu-surface-2)}.neu-uploader__dropzone{position:relative;display:grid;justify-items:center;gap:var(--neu-space-3);min-height:176px;padding:var(--neu-space-6);background:radial-gradient(circle at top right,color-mix(in srgb,var(--neu-primary) 7%,transparent),transparent 35%),color-mix(in srgb,var(--neu-surface) 97%,var(--neu-primary));border:1.5px dashed var(--neu-border-hover);border-radius:var(--neu-radius-lg);box-shadow:var(--neu-shadow-sm);cursor:pointer;text-align:center;transition:border-color var(--neu-transition),box-shadow var(--neu-transition),background var(--neu-transition),transform var(--neu-transition)}.neu-uploader__dropzone:hover{border-color:var(--neu-primary);box-shadow:var(--neu-shadow)}.neu-uploader__dropzone:focus-visible{outline:none;box-shadow:var(--neu-focus-ring-strong);border-color:var(--neu-primary)}.neu-uploader__picker-trigger{justify-self:start}.neu-uploader__actions--picker-only{justify-content:flex-end;flex-shrink:0}@media(max-width:640px){.neu-uploader__actions--picker-only{justify-content:flex-start}}.neu-uploader__empty-icon{display:grid;place-items:center;width:56px;height:56px;border-radius:var(--neu-radius-full);background:color-mix(in srgb,var(--neu-primary) 12%,transparent);color:var(--neu-primary)}.neu-uploader__empty-icon svg{width:24px;height:24px}.neu-uploader__copy{display:grid;gap:var(--neu-space-1);max-width:40rem}.neu-uploader__headline{margin:0;color:var(--neu-text);font-size:var(--neu-text-lg);font-weight:700}.neu-uploader__description{margin:0;color:var(--neu-text-muted);font-size:var(--neu-text-sm);line-height:1.55}.neu-uploader__actions{display:flex;flex-wrap:wrap;justify-content:center;gap:var(--neu-space-2)}.neu-uploader__progress,.neu-uploader__summary,.neu-uploader__list{background:var(--neu-surface);border:1px solid var(--neu-border);border-radius:var(--neu-radius)}.neu-uploader__progress{padding:var(--neu-space-3)}.neu-uploader__summary{display:flex;align-items:center;justify-content:space-between;gap:var(--neu-space-3);padding:var(--neu-space-3) var(--neu-space-4);font-size:var(--neu-text-sm);color:var(--neu-text-muted)}.neu-uploader__list{list-style:none;margin:0;padding:0;overflow:hidden}.neu-uploader__item{display:flex;align-items:center;justify-content:space-between;gap:var(--neu-space-3);padding:var(--neu-space-3) var(--neu-space-4)}.neu-uploader__item:not(:last-child){border-bottom:1px solid var(--neu-border)}.neu-uploader__item-main{display:grid;gap:2px;min-width:0}.neu-uploader__item-name{font-size:var(--neu-text-sm);font-weight:600;color:var(--neu-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.neu-uploader__item-meta{font-size:var(--neu-text-xs);color:var(--neu-text-muted)}.neu-uploader__remove{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;border:none;border-radius:var(--neu-radius-full);background:transparent;color:var(--neu-text-muted);cursor:pointer;transition:background-color var(--neu-transition),color var(--neu-transition),box-shadow var(--neu-transition)}.neu-uploader__remove:hover:not(:disabled){background:var(--neu-error-bg);color:var(--neu-error)}.neu-uploader__remove:focus-visible{outline:none;box-shadow:var(--neu-focus-ring)}.neu-uploader__remove:disabled{cursor:not-allowed;opacity:.55}.neu-uploader__remove svg{width:1rem;height:1rem}.neu-uploader__error,.neu-uploader__hint{margin-top:var(--neu-space-1);font-size:var(--neu-text-xs);line-height:1.45}.neu-uploader__error{color:var(--neu-error-text)}.neu-uploader__hint{color:var(--neu-text-muted)}@media(max-width:399px){.neu-uploader__dropzone{min-height:auto;padding:var(--neu-space-5)}.neu-uploader--picker-only .neu-uploader__dropzone{grid-template-columns:1fr;align-items:start;gap:var(--neu-space-3);padding:var(--neu-space-4)}.neu-uploader--picker-only .neu-uploader__actions{justify-content:flex-start}.neu-uploader__summary,.neu-uploader__item{align-items:flex-start;flex-direction:column}.neu-uploader__remove{align-self:flex-end}}\n"], dependencies: [{ kind: "component", type: NeuButtonComponent, selector: "button[neu-button]", inputs: ["variant", "size", "disabled", "loading", "fullWidth", "icon", "iconPosition", "iconOnly", "ariaLabel"], outputs: ["neuClick"] }, { kind: "component", type: NeuProgressBarComponent, selector: "neu-progress-bar", inputs: ["value", "variant", "label", "showValue", "indeterminate", "size"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
447
|
+
}
|
|
448
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: NeuUploaderComponent, decorators: [{
|
|
449
|
+
type: Component,
|
|
450
|
+
args: [{ selector: 'neu-uploader', imports: [NeuButtonComponent, NeuProgressBarComponent], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
451
|
+
{
|
|
452
|
+
provide: NG_VALUE_ACCESSOR,
|
|
453
|
+
useExisting: forwardRef(() => NeuUploaderComponent),
|
|
454
|
+
multi: true,
|
|
455
|
+
},
|
|
456
|
+
], host: {
|
|
457
|
+
class: 'neu-uploader-host',
|
|
458
|
+
'[class.neu-uploader-host--sm]': 'size() === "sm"',
|
|
459
|
+
'[class.neu-uploader-host--lg]': 'size() === "lg"',
|
|
460
|
+
}, template: `
|
|
461
|
+
@if (label()) {
|
|
462
|
+
<label class="neu-uploader__label" [for]="inputId()">{{ label() }}</label>
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
<input
|
|
466
|
+
#fileInput
|
|
467
|
+
class="neu-uploader__native-input"
|
|
468
|
+
[id]="inputId()"
|
|
469
|
+
type="file"
|
|
470
|
+
[attr.accept]="accept() || null"
|
|
471
|
+
[attr.multiple]="multiple() ? '' : null"
|
|
472
|
+
[disabled]="isDisabledFinal()"
|
|
473
|
+
[attr.aria-describedby]="describedBy()"
|
|
474
|
+
[attr.aria-invalid]="hasError() ? 'true' : null"
|
|
475
|
+
(change)="onNativeInputChange($event)"
|
|
476
|
+
/>
|
|
477
|
+
|
|
478
|
+
<div
|
|
479
|
+
class="neu-uploader"
|
|
480
|
+
[class.neu-uploader--disabled]="isDisabledFinal()"
|
|
481
|
+
[class.neu-uploader--drag-over]="isDragOver()"
|
|
482
|
+
[class.neu-uploader--error]="hasError()"
|
|
483
|
+
[class.neu-uploader--has-files]="fileItems().length > 0"
|
|
484
|
+
[class.neu-uploader--picker-only]="!dropzone()"
|
|
485
|
+
>
|
|
486
|
+
@if (dropzone()) {
|
|
487
|
+
<div
|
|
488
|
+
class="neu-uploader__dropzone"
|
|
489
|
+
[attr.aria-describedby]="describedBy()"
|
|
490
|
+
(click)="openFilePicker()"
|
|
491
|
+
(dragover)="onDragOver($event)"
|
|
492
|
+
(dragleave)="onDragLeave($event)"
|
|
493
|
+
(drop)="onDrop($event)"
|
|
494
|
+
>
|
|
495
|
+
<div class="neu-uploader__empty-icon" aria-hidden="true">
|
|
496
|
+
<svg
|
|
497
|
+
viewBox="0 0 24 24"
|
|
498
|
+
fill="none"
|
|
499
|
+
stroke="currentColor"
|
|
500
|
+
stroke-width="1.8"
|
|
501
|
+
stroke-linecap="round"
|
|
502
|
+
stroke-linejoin="round"
|
|
503
|
+
>
|
|
504
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
505
|
+
<polyline points="17 8 12 3 7 8" />
|
|
506
|
+
<line x1="12" y1="3" x2="12" y2="15" />
|
|
507
|
+
</svg>
|
|
508
|
+
</div>
|
|
509
|
+
|
|
510
|
+
<div class="neu-uploader__copy">
|
|
511
|
+
<p class="neu-uploader__headline">{{ headlineText() }}</p>
|
|
512
|
+
<p class="neu-uploader__description">{{ descriptionText() }}</p>
|
|
513
|
+
</div>
|
|
514
|
+
|
|
515
|
+
<div class="neu-uploader__actions">
|
|
516
|
+
<button
|
|
517
|
+
neu-button
|
|
518
|
+
type="button"
|
|
519
|
+
variant="primary"
|
|
520
|
+
size="sm"
|
|
521
|
+
(click)="openFilePicker(); $event.stopPropagation()"
|
|
522
|
+
>
|
|
523
|
+
{{ chooseLabel() }}
|
|
524
|
+
</button>
|
|
525
|
+
@if (fileItems().length > 0) {
|
|
526
|
+
<button
|
|
527
|
+
neu-button
|
|
528
|
+
type="button"
|
|
529
|
+
variant="outline"
|
|
530
|
+
size="sm"
|
|
531
|
+
(click)="clearFiles($event)"
|
|
532
|
+
>
|
|
533
|
+
{{ clearLabel() }}
|
|
534
|
+
</button>
|
|
535
|
+
}
|
|
536
|
+
</div>
|
|
537
|
+
</div>
|
|
538
|
+
} @else {
|
|
539
|
+
<button
|
|
540
|
+
neu-button
|
|
541
|
+
type="button"
|
|
542
|
+
variant="primary"
|
|
543
|
+
size="sm"
|
|
544
|
+
icon="lucideUpload"
|
|
545
|
+
class="neu-uploader__picker-trigger"
|
|
546
|
+
[disabled]="isDisabledFinal()"
|
|
547
|
+
[attr.aria-label]="pickerButtonAriaLabel()"
|
|
548
|
+
[attr.aria-describedby]="describedBy()"
|
|
549
|
+
(click)="openFilePicker()"
|
|
550
|
+
>
|
|
551
|
+
@if (showPickerText() && chooseLabel()) {
|
|
552
|
+
{{ chooseLabel() }}
|
|
553
|
+
}
|
|
554
|
+
</button>
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
@if (shouldShowProgress()) {
|
|
558
|
+
<div class="neu-uploader__progress">
|
|
559
|
+
<neu-progress-bar
|
|
560
|
+
[value]="progress() ?? 0"
|
|
561
|
+
[label]="progressLabel()"
|
|
562
|
+
[showValue]="true"
|
|
563
|
+
size="sm"
|
|
564
|
+
/>
|
|
565
|
+
</div>
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
@if (fileItems().length > 0) {
|
|
569
|
+
<div class="neu-uploader__summary">
|
|
570
|
+
<span>{{ summaryText() }}</span>
|
|
571
|
+
@if (maxFiles() !== null) {
|
|
572
|
+
<span>{{ fileItems().length }}/{{ maxFiles() }}</span>
|
|
573
|
+
}
|
|
574
|
+
</div>
|
|
575
|
+
|
|
576
|
+
<ul class="neu-uploader__list" [attr.aria-label]="listAriaLabel()">
|
|
577
|
+
@for (item of fileItems(); track item.id) {
|
|
578
|
+
<li class="neu-uploader__item">
|
|
579
|
+
<div class="neu-uploader__item-main">
|
|
580
|
+
<span class="neu-uploader__item-name">{{ item.name }}</span>
|
|
581
|
+
<span class="neu-uploader__item-meta">{{ formatBytes(item.size) }}</span>
|
|
582
|
+
</div>
|
|
583
|
+
<button
|
|
584
|
+
class="neu-uploader__remove"
|
|
585
|
+
type="button"
|
|
586
|
+
[disabled]="isDisabledFinal()"
|
|
587
|
+
[attr.aria-label]="removeAriaLabel() + ' ' + item.name"
|
|
588
|
+
(click)="removeFile(item.id, $event)"
|
|
589
|
+
>
|
|
590
|
+
<svg
|
|
591
|
+
viewBox="0 0 24 24"
|
|
592
|
+
fill="none"
|
|
593
|
+
stroke="currentColor"
|
|
594
|
+
stroke-width="2"
|
|
595
|
+
stroke-linecap="round"
|
|
596
|
+
stroke-linejoin="round"
|
|
597
|
+
aria-hidden="true"
|
|
598
|
+
>
|
|
599
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
600
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
601
|
+
</svg>
|
|
602
|
+
</button>
|
|
603
|
+
</li>
|
|
604
|
+
}
|
|
605
|
+
</ul>
|
|
606
|
+
}
|
|
607
|
+
</div>
|
|
608
|
+
|
|
609
|
+
@if (hasError()) {
|
|
610
|
+
<p class="neu-uploader__error" [id]="inputId() + '-error'" role="alert">
|
|
611
|
+
{{ displayErrorMessage() }}
|
|
612
|
+
</p>
|
|
613
|
+
} @else if (hint()) {
|
|
614
|
+
<p class="neu-uploader__hint" [id]="inputId() + '-hint'">{{ hint() }}</p>
|
|
615
|
+
}
|
|
616
|
+
`, styles: [".neu-uploader-host{display:block}.neu-uploader-host--sm .neu-uploader__dropzone{min-height:144px;padding:var(--neu-space-4)}.neu-uploader-host--sm .neu-uploader__headline{font-size:var(--neu-text-base)}.neu-uploader-host--lg .neu-uploader__dropzone{min-height:208px;padding:var(--neu-space-8)}.neu-uploader-host--lg .neu-uploader__headline{font-size:var(--neu-text-xl)}.neu-uploader__label{display:block;font-size:var(--neu-text-sm);font-weight:500;color:var(--neu-text-muted);margin-bottom:var(--neu-space-2)}.neu-uploader__native-input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.neu-uploader{display:grid;gap:var(--neu-space-3)}.neu-uploader--picker-only{gap:var(--neu-space-2)}.neu-uploader--picker-only .neu-uploader__copy{gap:2px;max-width:none}.neu-uploader--picker-only .neu-uploader__progress{padding:var(--neu-space-2) var(--neu-space-3)}.neu-uploader--picker-only .neu-uploader__headline{font-size:var(--neu-text-base)}.neu-uploader--drag-over .neu-uploader__dropzone{border-color:var(--neu-primary);box-shadow:var(--neu-focus-ring-strong);transform:translateY(-1px)}.neu-uploader--error .neu-uploader__dropzone{border-color:var(--neu-error);background:radial-gradient(circle at top right,color-mix(in srgb,var(--neu-error) 6%,transparent),transparent 35%),color-mix(in srgb,var(--neu-error) 5%,var(--neu-surface))}.neu-uploader--disabled .neu-uploader__dropzone{opacity:.7;cursor:not-allowed;background:var(--neu-surface-2)}.neu-uploader__dropzone{position:relative;display:grid;justify-items:center;gap:var(--neu-space-3);min-height:176px;padding:var(--neu-space-6);background:radial-gradient(circle at top right,color-mix(in srgb,var(--neu-primary) 7%,transparent),transparent 35%),color-mix(in srgb,var(--neu-surface) 97%,var(--neu-primary));border:1.5px dashed var(--neu-border-hover);border-radius:var(--neu-radius-lg);box-shadow:var(--neu-shadow-sm);cursor:pointer;text-align:center;transition:border-color var(--neu-transition),box-shadow var(--neu-transition),background var(--neu-transition),transform var(--neu-transition)}.neu-uploader__dropzone:hover{border-color:var(--neu-primary);box-shadow:var(--neu-shadow)}.neu-uploader__dropzone:focus-visible{outline:none;box-shadow:var(--neu-focus-ring-strong);border-color:var(--neu-primary)}.neu-uploader__picker-trigger{justify-self:start}.neu-uploader__actions--picker-only{justify-content:flex-end;flex-shrink:0}@media(max-width:640px){.neu-uploader__actions--picker-only{justify-content:flex-start}}.neu-uploader__empty-icon{display:grid;place-items:center;width:56px;height:56px;border-radius:var(--neu-radius-full);background:color-mix(in srgb,var(--neu-primary) 12%,transparent);color:var(--neu-primary)}.neu-uploader__empty-icon svg{width:24px;height:24px}.neu-uploader__copy{display:grid;gap:var(--neu-space-1);max-width:40rem}.neu-uploader__headline{margin:0;color:var(--neu-text);font-size:var(--neu-text-lg);font-weight:700}.neu-uploader__description{margin:0;color:var(--neu-text-muted);font-size:var(--neu-text-sm);line-height:1.55}.neu-uploader__actions{display:flex;flex-wrap:wrap;justify-content:center;gap:var(--neu-space-2)}.neu-uploader__progress,.neu-uploader__summary,.neu-uploader__list{background:var(--neu-surface);border:1px solid var(--neu-border);border-radius:var(--neu-radius)}.neu-uploader__progress{padding:var(--neu-space-3)}.neu-uploader__summary{display:flex;align-items:center;justify-content:space-between;gap:var(--neu-space-3);padding:var(--neu-space-3) var(--neu-space-4);font-size:var(--neu-text-sm);color:var(--neu-text-muted)}.neu-uploader__list{list-style:none;margin:0;padding:0;overflow:hidden}.neu-uploader__item{display:flex;align-items:center;justify-content:space-between;gap:var(--neu-space-3);padding:var(--neu-space-3) var(--neu-space-4)}.neu-uploader__item:not(:last-child){border-bottom:1px solid var(--neu-border)}.neu-uploader__item-main{display:grid;gap:2px;min-width:0}.neu-uploader__item-name{font-size:var(--neu-text-sm);font-weight:600;color:var(--neu-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.neu-uploader__item-meta{font-size:var(--neu-text-xs);color:var(--neu-text-muted)}.neu-uploader__remove{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;border:none;border-radius:var(--neu-radius-full);background:transparent;color:var(--neu-text-muted);cursor:pointer;transition:background-color var(--neu-transition),color var(--neu-transition),box-shadow var(--neu-transition)}.neu-uploader__remove:hover:not(:disabled){background:var(--neu-error-bg);color:var(--neu-error)}.neu-uploader__remove:focus-visible{outline:none;box-shadow:var(--neu-focus-ring)}.neu-uploader__remove:disabled{cursor:not-allowed;opacity:.55}.neu-uploader__remove svg{width:1rem;height:1rem}.neu-uploader__error,.neu-uploader__hint{margin-top:var(--neu-space-1);font-size:var(--neu-text-xs);line-height:1.45}.neu-uploader__error{color:var(--neu-error-text)}.neu-uploader__hint{color:var(--neu-text-muted)}@media(max-width:399px){.neu-uploader__dropzone{min-height:auto;padding:var(--neu-space-5)}.neu-uploader--picker-only .neu-uploader__dropzone{grid-template-columns:1fr;align-items:start;gap:var(--neu-space-3);padding:var(--neu-space-4)}.neu-uploader--picker-only .neu-uploader__actions{justify-content:flex-start}.neu-uploader__summary,.neu-uploader__item{align-items:flex-start;flex-direction:column}.neu-uploader__remove{align-self:flex-end}}\n"] }]
|
|
617
|
+
}], propDecorators: { fileInput: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], pickerDescription: [{ type: i0.Input, args: [{ isSignal: true, alias: "pickerDescription", required: false }] }], dropzoneLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropzoneLabel", required: false }] }], chooseLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "chooseLabel", required: false }] }], clearLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearLabel", required: false }] }], progressLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "progressLabel", required: false }] }], showPickerText: [{ type: i0.Input, args: [{ isSignal: true, alias: "showPickerText", required: false }] }], showProgress: [{ type: i0.Input, args: [{ isSignal: true, alias: "showProgress", required: false }] }], listAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "listAriaLabel", required: false }] }], removeAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "removeAriaLabel", required: false }] }], acceptedTypesLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptedTypesLabel", required: false }] }], maxFileSizeTextLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFileSizeTextLabel", required: false }] }], fileCountSingularLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileCountSingularLabel", required: false }] }], fileCountPluralLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileCountPluralLabel", required: false }] }], emptySelectionMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptySelectionMessage", required: false }] }], invalidTypeMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalidTypeMessage", required: false }] }], maxFileSizeMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFileSizeMessage", required: false }] }], duplicateFileMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "duplicateFileMessage", required: false }] }], maxFilesMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFilesMessage", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], dropzone: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropzone", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], maxFiles: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFiles", required: false }] }], maxFileSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFileSize", required: false }] }], progress: [{ type: i0.Input, args: [{ isSignal: true, alias: "progress", required: false }] }], filesSelected: [{ type: i0.Output, args: ["filesSelected"] }], fileRemoved: [{ type: i0.Output, args: ["fileRemoved"] }], filesRejected: [{ type: i0.Output, args: ["filesRejected"] }], cleared: [{ type: i0.Output, args: ["cleared"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }] } });
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Generated bundle index. Do not edit.
|
|
621
|
+
*/
|
|
622
|
+
|
|
623
|
+
export { NeuUploaderComponent };
|
|
624
|
+
//# sourceMappingURL=neural-ui-core-uploader.mjs.map
|