@nanahoshi/mona-ui 0.32.3 → 0.34.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/docs/api/file-upload.md +174 -0
- package/docs/api/grid.md +46 -13
- package/docs/api/i18n.md +46 -0
- package/docs/api/locales.md +14 -14
- package/docs/file-upload.md +516 -0
- package/docs/forms.md +2 -0
- package/docs/grid-columns.md +121 -17
- package/docs/grid-state-export.md +24 -7
- package/docs/grid.md +1 -1
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-command.mjs +4 -3
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-file-upload.mjs +1137 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs → nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.mjs} +8 -3
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-C1qjq2s7.mjs → nanahoshi-mona-ui-grid-grid-list.component-S2iCn8TV.mjs} +10 -6
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-CgOt2A6O.mjs → nanahoshi-mona-ui-grid-grid-row.component-BUJvgihp.mjs} +23 -8
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-tguG2LpN.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-Wndy-_Bt.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs → nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs} +230 -18
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +425 -31
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +74 -0
- package/fesm2022/nanahoshi-mona-ui-internal-live-announcer.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +50 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +44 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +44 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +2 -2
- package/file-upload/package.json +4 -0
- package/i18n/catalogs/en-US.messages.json +29 -0
- package/internal/live-announcer/package.json +4 -0
- package/llms.txt +6 -4
- package/locales/ar-sa/ar-sa.messages.json +29 -0
- package/locales/de-de/de-de.messages.json +29 -0
- package/locales/es-es/es-es.messages.json +29 -0
- package/locales/fr-fr/fr-fr.messages.json +29 -0
- package/locales/id-id/id-id.messages.json +29 -0
- package/locales/it-it/it-it.messages.json +29 -0
- package/locales/ja-jp/ja-jp.messages.json +29 -0
- package/locales/ko-kr/ko-kr.messages.json +29 -0
- package/locales/pl-pl/pl-pl.messages.json +29 -0
- package/locales/pt-br/pt-br.messages.json +29 -0
- package/locales/ru-ru/ru-ru.messages.json +29 -0
- package/locales/tr-tr/tr-tr.messages.json +29 -0
- package/locales/zh-cn/zh-cn.messages.json +29 -0
- package/locales/zh-tw/zh-tw.messages.json +29 -0
- package/package.json +9 -1
- package/types/nanahoshi-mona-ui-file-upload.d.ts +366 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +142 -64
- package/types/nanahoshi-mona-ui-i18n.d.ts +60 -0
- package/types/nanahoshi-mona-ui-internal-live-announcer.d.ts +12 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +29 -0
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
import { DOCUMENT } from "@angular/common";
|
|
2
|
+
import { HttpEventType, HttpResponse, HttpResponseBase } from "@angular/common/http";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import { Component, DestroyRef, ElementRef, Injector, afterNextRender, booleanAttribute, computed, effect, inject, input, model, numberAttribute, output, signal, untracked, viewChild } from "@angular/core";
|
|
5
|
+
import { LucideCircleAlert, LucideCircleCheck, LucideCloudUpload, LucideFile, LucideRotateCw, LucideX } from "@lucide/angular";
|
|
6
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
7
|
+
import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
|
|
8
|
+
import { createElementControlId, injectEffectiveDisabled, injectLabelAssociation, themeControlSurfaceClasses } from "@nanahoshi/mona-ui/internal";
|
|
9
|
+
import { ProgressBarComponent } from "@nanahoshi/mona-ui/progress-bar";
|
|
10
|
+
import { isObservable } from "rxjs";
|
|
11
|
+
import { twMerge } from "tailwind-merge";
|
|
12
|
+
import { cva } from "class-variance-authority";
|
|
13
|
+
function localizeNumber(value, options) {
|
|
14
|
+
return formatNumber(value, "en-US", options);
|
|
15
|
+
}
|
|
16
|
+
const PLURAL_RULES = new Intl.PluralRules("en-US");
|
|
17
|
+
function plural(category, forms) {
|
|
18
|
+
return (forms[category] ?? forms.other)();
|
|
19
|
+
}
|
|
20
|
+
const FILE_UPLOAD_DEFAULT_MESSAGES = {
|
|
21
|
+
browse: "Browse files",
|
|
22
|
+
browseFile: "Choose a file",
|
|
23
|
+
cancel: (name) => `Cancel the upload of ${name}`,
|
|
24
|
+
clear: "Clear",
|
|
25
|
+
dropFile: "Drag a file here",
|
|
26
|
+
dropFiles: "Drag files here",
|
|
27
|
+
dropToAdd: "Drop to add",
|
|
28
|
+
fileFailed: (name) => `${name} couldn't be uploaded.`,
|
|
29
|
+
fileRejected: (name, reason) => `${name} wasn't added. ${reason}`,
|
|
30
|
+
fileRemoved: (name) => `${name} removed.`,
|
|
31
|
+
fileTypes: (types) => `File types: ${types}`,
|
|
32
|
+
fileUploaded: (name) => `${name} uploaded.`,
|
|
33
|
+
files: "Files",
|
|
34
|
+
filesAdded: (count) => plural(PLURAL_RULES.select(count), {
|
|
35
|
+
one: () => `${localizeNumber(count)} file added.`,
|
|
36
|
+
other: () => `${localizeNumber(count)} files added.`
|
|
37
|
+
}),
|
|
38
|
+
invalidType: "This file type isn't accepted.",
|
|
39
|
+
maxFileSize: (size) => `Max. file size: ${size}`,
|
|
40
|
+
maxFiles: (count) => `Up to ${plural(PLURAL_RULES.select(count), {
|
|
41
|
+
one: () => `${localizeNumber(count)} file`,
|
|
42
|
+
other: () => `${localizeNumber(count)} files`
|
|
43
|
+
})}`,
|
|
44
|
+
readyToUpload: "Ready to upload",
|
|
45
|
+
remove: (name) => `Remove ${name}`,
|
|
46
|
+
retry: (name) => `Retry the upload of ${name}`,
|
|
47
|
+
tooLarge: (size) => `The file is larger than ${size}.`,
|
|
48
|
+
tooMany: (count) => `No more than ${plural(PLURAL_RULES.select(count), {
|
|
49
|
+
one: () => `${localizeNumber(count)} file`,
|
|
50
|
+
other: () => `${localizeNumber(count)} files`
|
|
51
|
+
})} can be added.`,
|
|
52
|
+
tooSmall: (size) => `The file is smaller than ${size}.`,
|
|
53
|
+
upload: "Upload",
|
|
54
|
+
uploadFailed: "The upload failed.",
|
|
55
|
+
uploaded: "Uploaded",
|
|
56
|
+
uploading: "Uploading"
|
|
57
|
+
};
|
|
58
|
+
const fileUploadThemeVariants = cva(`flex min-w-0 flex-col gap-2 text-sm text-foreground`);
|
|
59
|
+
const fileUploadZoneThemeVariants = cva(`
|
|
60
|
+
flex flex-col items-center justify-center gap-1
|
|
61
|
+
px-4 py-6 text-center
|
|
62
|
+
${themeControlSurfaceClasses}
|
|
63
|
+
rounded-md border border-dashed border-input-border
|
|
64
|
+
cursor-pointer transition-colors
|
|
65
|
+
not-data-[disabled='true']:not-data-[readonly='true']:hover:border-focus-indicator
|
|
66
|
+
|
|
67
|
+
data-[dragging='true']:border-solid
|
|
68
|
+
data-[dragging='true']:border-focus-indicator
|
|
69
|
+
data-[dragging='true']:bg-selected
|
|
70
|
+
data-[dragging='true']:text-selected-foreground
|
|
71
|
+
forced-colors:data-[dragging='true']:border-[Highlight]
|
|
72
|
+
|
|
73
|
+
data-[invalid='true']:border-error
|
|
74
|
+
|
|
75
|
+
data-[disabled='true']:cursor-not-allowed
|
|
76
|
+
data-[disabled='true']:border-disabled-border
|
|
77
|
+
data-[disabled='true']:bg-disabled-background
|
|
78
|
+
data-[disabled='true']:text-disabled-foreground
|
|
79
|
+
data-[readonly='true']:cursor-default
|
|
80
|
+
`);
|
|
81
|
+
const fileUploadZoneIconThemeVariants = cva(`mb-1 text-muted-foreground in-data-[disabled='true']:text-inherit in-data-[dragging='true']:text-inherit`);
|
|
82
|
+
const fileUploadZoneTextThemeVariants = cva(`font-medium`);
|
|
83
|
+
const fileUploadRestrictionsThemeVariants = cva(`text-xs text-muted-foreground in-data-[disabled='true']:text-inherit in-data-[dragging='true']:text-inherit`);
|
|
84
|
+
const fileUploadBrowseThemeVariants = cva(`mt-2`);
|
|
85
|
+
const fileUploadListThemeVariants = cva(`flex flex-col gap-1.5`);
|
|
86
|
+
const fileUploadItemThemeVariants = cva(`
|
|
87
|
+
flex items-center gap-3 min-w-0
|
|
88
|
+
rounded-md border border-border px-3 py-2
|
|
89
|
+
${themeControlSurfaceClasses}
|
|
90
|
+
data-[status='failed']:border-error
|
|
91
|
+
data-[status='rejected']:border-error
|
|
92
|
+
`);
|
|
93
|
+
const fileUploadItemIconThemeVariants = cva(`shrink-0`, {
|
|
94
|
+
variants: { tone: {
|
|
95
|
+
error: "text-error",
|
|
96
|
+
muted: "text-muted-foreground",
|
|
97
|
+
success: "text-success"
|
|
98
|
+
} },
|
|
99
|
+
defaultVariants: { tone: "muted" }
|
|
100
|
+
});
|
|
101
|
+
const fileUploadItemBodyThemeVariants = cva(`flex min-w-0 flex-1 flex-col gap-1`);
|
|
102
|
+
const fileUploadItemNameThemeVariants = cva(`truncate font-medium`);
|
|
103
|
+
const fileUploadItemStatusThemeVariants = cva(`text-xs`, {
|
|
104
|
+
variants: { tone: {
|
|
105
|
+
error: "text-error",
|
|
106
|
+
muted: "text-muted-foreground"
|
|
107
|
+
} },
|
|
108
|
+
defaultVariants: { tone: "muted" }
|
|
109
|
+
});
|
|
110
|
+
const fileUploadItemProgressThemeVariants = cva(`h-1`);
|
|
111
|
+
const fileUploadItemActionsThemeVariants = cva(`flex shrink-0 items-center gap-1`);
|
|
112
|
+
const fileUploadActionsThemeVariants = cva(`flex justify-end gap-2`);
|
|
113
|
+
const FILE_SIZE_UNITS = [
|
|
114
|
+
"byte",
|
|
115
|
+
"kilobyte",
|
|
116
|
+
"megabyte",
|
|
117
|
+
"gigabyte",
|
|
118
|
+
"terabyte"
|
|
119
|
+
];
|
|
120
|
+
function parseAccept(accept) {
|
|
121
|
+
return (accept ?? "").split(",").map((token) => token.trim().toLowerCase()).filter((token) => token.length > 0);
|
|
122
|
+
}
|
|
123
|
+
function matchesAccept(file, accept) {
|
|
124
|
+
if (accept.length === 0) return true;
|
|
125
|
+
const name = file.name.toLowerCase();
|
|
126
|
+
const type = file.type.toLowerCase();
|
|
127
|
+
return accept.some((token) => {
|
|
128
|
+
if (token.startsWith(".")) return name.endsWith(token);
|
|
129
|
+
if (token.endsWith("/*")) return type.startsWith(token.slice(0, -1));
|
|
130
|
+
return type === token;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function checkFile(file, rules) {
|
|
134
|
+
if (!matchesAccept(file, rules.accept)) return "type";
|
|
135
|
+
if (rules.maxFileSize != null && file.size > rules.maxFileSize) return "maxFileSize";
|
|
136
|
+
if (rules.minFileSize != null && file.size < rules.minFileSize) return "minFileSize";
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
function isSameFile(a, b) {
|
|
140
|
+
return a.name === b.name && a.size === b.size && a.type === b.type && a.lastModified === b.lastModified;
|
|
141
|
+
}
|
|
142
|
+
function isSameFileList(a, b) {
|
|
143
|
+
return a.length === b.length && a.every((file, index) => file === b[index]);
|
|
144
|
+
}
|
|
145
|
+
function formatFileSize(bytes, localeId) {
|
|
146
|
+
let value = Math.max(0, bytes);
|
|
147
|
+
let unit = 0;
|
|
148
|
+
while (value >= 1024 && unit < FILE_SIZE_UNITS.length - 1) {
|
|
149
|
+
value /= 1024;
|
|
150
|
+
unit++;
|
|
151
|
+
}
|
|
152
|
+
return formatNumber(value, localeId, {
|
|
153
|
+
maximumFractionDigits: unit === 0 || value >= 100 ? 0 : 1,
|
|
154
|
+
style: "unit",
|
|
155
|
+
unit: FILE_SIZE_UNITS[unit],
|
|
156
|
+
unitDisplay: unit === 0 ? "long" : "short"
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function describeAccept(accept, localeId) {
|
|
160
|
+
const names = [...new Set(accept.map((token) => token.startsWith(".") ? token.slice(1).toUpperCase() : token))];
|
|
161
|
+
try {
|
|
162
|
+
return new Intl.ListFormat(localeId, { type: "disjunction" }).format(names);
|
|
163
|
+
} catch {
|
|
164
|
+
return names.join(", ");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const ANNOUNCEMENT_REPEAT_DELAY = 100;
|
|
168
|
+
function isHttpEventWithoutResult(value) {
|
|
169
|
+
if (value instanceof HttpResponseBase) return !(value instanceof HttpResponse);
|
|
170
|
+
if (value == null || typeof value !== "object") return false;
|
|
171
|
+
const type = value.type;
|
|
172
|
+
if (type === HttpEventType.Sent) return Object.keys(value).length === 1;
|
|
173
|
+
return (type === HttpEventType.UploadProgress || type === HttpEventType.DownloadProgress) && typeof value.loaded === "number";
|
|
174
|
+
}
|
|
175
|
+
function httpUploadProgress(value) {
|
|
176
|
+
if (value == null || typeof value !== "object") return null;
|
|
177
|
+
const event = value;
|
|
178
|
+
if (event.type !== HttpEventType.UploadProgress || typeof event.loaded !== "number") return null;
|
|
179
|
+
return {
|
|
180
|
+
loaded: event.loaded,
|
|
181
|
+
total: typeof event.total === "number" ? event.total : void 0
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
var FileUploadComponent = class FileUploadComponent {
|
|
185
|
+
#destroyRef;
|
|
186
|
+
#document;
|
|
187
|
+
#entries;
|
|
188
|
+
#hostElementRef;
|
|
189
|
+
#i18n;
|
|
190
|
+
#injector;
|
|
191
|
+
#label;
|
|
192
|
+
#maxFiles;
|
|
193
|
+
#rules;
|
|
194
|
+
#announcementTimer;
|
|
195
|
+
#dragDepth;
|
|
196
|
+
#nextKey;
|
|
197
|
+
#writtenValue;
|
|
198
|
+
constructor() {
|
|
199
|
+
this.#destroyRef = inject(DestroyRef);
|
|
200
|
+
this.#document = inject(DOCUMENT);
|
|
201
|
+
this.#entries = signal([], ...ngDevMode ? [{ debugName: "#entries" }] : /* istanbul ignore next */ []);
|
|
202
|
+
this.#hostElementRef = inject(ElementRef);
|
|
203
|
+
this.#i18n = inject(MonaI18nService);
|
|
204
|
+
this.#injector = inject(Injector);
|
|
205
|
+
this.#label = injectLabelAssociation({
|
|
206
|
+
activate: () => this.focus(),
|
|
207
|
+
ariaDescribedBy: () => this.ariaDescribedBy(),
|
|
208
|
+
ariaLabel: () => this.ariaLabel(),
|
|
209
|
+
ariaLabelledBy: () => this.ariaLabelledBy(),
|
|
210
|
+
focus: () => this.focus()
|
|
211
|
+
});
|
|
212
|
+
this.#maxFiles = computed(() => {
|
|
213
|
+
const maxFiles = this.maxFiles();
|
|
214
|
+
return maxFiles != null && Number.isFinite(maxFiles) && maxFiles >= 1 ? Math.floor(maxFiles) : null;
|
|
215
|
+
}, ...ngDevMode ? [{ debugName: "#maxFiles" }] : /* istanbul ignore next */ []);
|
|
216
|
+
this.#rules = computed(() => ({
|
|
217
|
+
accept: parseAccept(this.accept()),
|
|
218
|
+
maxFileSize: this.#positiveOrNull(this.maxFileSize()),
|
|
219
|
+
minFileSize: this.#positiveOrNull(this.minFileSize())
|
|
220
|
+
}), ...ngDevMode ? [{ debugName: "#rules" }] : /* istanbul ignore next */ []);
|
|
221
|
+
this.#announcementTimer = void 0;
|
|
222
|
+
this.#dragDepth = 0;
|
|
223
|
+
this.#nextKey = 0;
|
|
224
|
+
this.#writtenValue = null;
|
|
225
|
+
this.actionsClass = fileUploadActionsThemeVariants();
|
|
226
|
+
this.announcement = signal("", ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
|
|
227
|
+
this.browseButtonRef = viewChild.required("browseButton", ...ngDevMode ? [{ debugName: "browseButtonRef" }] : /* istanbul ignore next */ []);
|
|
228
|
+
this.browseClass = fileUploadBrowseThemeVariants();
|
|
229
|
+
this.browseDescribedBy = computed(() => {
|
|
230
|
+
return [this.restrictions() ? this.restrictionsId : null, this.#label.describedBy()].filter((id) => !!id).join(" ") || null;
|
|
231
|
+
}, ...ngDevMode ? [{ debugName: "browseDescribedBy" }] : /* istanbul ignore next */ []);
|
|
232
|
+
this.classes = computed(() => twMerge(fileUploadThemeVariants(), this.userClass()), ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
233
|
+
this.dragging = signal(false, ...ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []);
|
|
234
|
+
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
235
|
+
this.fileInputRef = viewChild.required("fileInput", ...ngDevMode ? [{ debugName: "fileInputRef" }] : /* istanbul ignore next */ []);
|
|
236
|
+
this.interactive = computed(() => !this.effectiveDisabled() && !this.readonly(), ...ngDevMode ? [{ debugName: "interactive" }] : /* istanbul ignore next */ []);
|
|
237
|
+
this.invalidState = computed(() => this.touched() && (this.invalid() || this.required() && (this.value() ?? []).length === 0), ...ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []);
|
|
238
|
+
this.itemActionsClass = fileUploadItemActionsThemeVariants();
|
|
239
|
+
this.itemBodyClass = fileUploadItemBodyThemeVariants();
|
|
240
|
+
this.itemClass = fileUploadItemThemeVariants();
|
|
241
|
+
this.itemIconClass = {
|
|
242
|
+
error: fileUploadItemIconThemeVariants({ tone: "error" }),
|
|
243
|
+
file: fileUploadItemIconThemeVariants({ tone: "muted" }),
|
|
244
|
+
uploaded: fileUploadItemIconThemeVariants({ tone: "success" })
|
|
245
|
+
};
|
|
246
|
+
this.itemNameClass = fileUploadItemNameThemeVariants();
|
|
247
|
+
this.itemProgressClass = fileUploadItemProgressThemeVariants();
|
|
248
|
+
this.itemStatusClass = {
|
|
249
|
+
error: fileUploadItemStatusThemeVariants({ tone: "error" }),
|
|
250
|
+
muted: fileUploadItemStatusThemeVariants({ tone: "muted" })
|
|
251
|
+
};
|
|
252
|
+
this.labelledBy = this.#label.labelledBy;
|
|
253
|
+
this.listClass = fileUploadListThemeVariants();
|
|
254
|
+
this.listId = createElementControlId();
|
|
255
|
+
this.messages = this.#i18n.componentMessages("fileUpload", FILE_UPLOAD_DEFAULT_MESSAGES);
|
|
256
|
+
this.pendingActionsShown = computed(() => this.upload() != null && !this.autoUpload() && this.interactive() && this.#entries().some((entry) => entry.item.status === "selected"), ...ngDevMode ? [{ debugName: "pendingActionsShown" }] : /* istanbul ignore next */ []);
|
|
257
|
+
this.restrictions = computed(() => {
|
|
258
|
+
const messages = this.messages();
|
|
259
|
+
const localeId = this.#i18n.localeId();
|
|
260
|
+
const rules = this.#rules();
|
|
261
|
+
const parts = [];
|
|
262
|
+
if (rules.accept.length > 0) parts.push(messages.fileTypes(describeAccept(rules.accept, localeId)));
|
|
263
|
+
if (rules.maxFileSize != null) parts.push(messages.maxFileSize(formatFileSize(rules.maxFileSize, localeId)));
|
|
264
|
+
const maxFiles = this.#maxFiles();
|
|
265
|
+
if (this.multiple() && maxFiles != null) parts.push(messages.maxFiles(maxFiles));
|
|
266
|
+
return parts.join(" · ");
|
|
267
|
+
}, ...ngDevMode ? [{ debugName: "restrictions" }] : /* istanbul ignore next */ []);
|
|
268
|
+
this.restrictionsClass = fileUploadRestrictionsThemeVariants();
|
|
269
|
+
this.restrictionsId = createElementControlId();
|
|
270
|
+
this.rows = computed(() => {
|
|
271
|
+
const messages = this.messages();
|
|
272
|
+
const localeId = this.#i18n.localeId();
|
|
273
|
+
const waiting = this.upload() != null && !this.autoUpload();
|
|
274
|
+
return this.#entries().map(({ item, key }) => {
|
|
275
|
+
const size = formatFileSize(item.file.size, localeId);
|
|
276
|
+
let status;
|
|
277
|
+
switch (item.status) {
|
|
278
|
+
case "failed":
|
|
279
|
+
status = messages.uploadFailed;
|
|
280
|
+
break;
|
|
281
|
+
case "rejected":
|
|
282
|
+
status = this.#rejectionMessage(item.rejection);
|
|
283
|
+
break;
|
|
284
|
+
case "selected":
|
|
285
|
+
status = waiting ? `${size} · ${messages.readyToUpload}` : size;
|
|
286
|
+
break;
|
|
287
|
+
case "uploaded":
|
|
288
|
+
status = `${size} · ${messages.uploaded}`;
|
|
289
|
+
break;
|
|
290
|
+
case "uploading": status = item.progress == null ? `${size} · ${messages.uploading}` : `${size} · ${messages.uploading} · ${formatNumber(item.progress, localeId, { style: "percent" })}`;
|
|
291
|
+
}
|
|
292
|
+
const error = item.status === "failed" || item.status === "rejected";
|
|
293
|
+
return {
|
|
294
|
+
actionsShown: !this.readonly(),
|
|
295
|
+
icon: error ? "error" : item.status === "uploaded" ? "uploaded" : "file",
|
|
296
|
+
item,
|
|
297
|
+
key,
|
|
298
|
+
nameId: `${this.listId}-${key}-name`,
|
|
299
|
+
progressLabel: item.file.name,
|
|
300
|
+
progressValue: item.progress == null ? null : Math.round(item.progress * 100),
|
|
301
|
+
removeLabel: item.status === "uploading" ? messages.cancel(item.file.name) : messages.remove(item.file.name),
|
|
302
|
+
retryLabel: messages.retry(item.file.name),
|
|
303
|
+
status,
|
|
304
|
+
statusError: error,
|
|
305
|
+
statusId: `${this.listId}-${key}-status`
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
}, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
|
|
309
|
+
this.zoneClass = fileUploadZoneThemeVariants();
|
|
310
|
+
this.zoneIconClass = fileUploadZoneIconThemeVariants();
|
|
311
|
+
this.zoneTextClass = fileUploadZoneTextThemeVariants();
|
|
312
|
+
this.accept = input("", ...ngDevMode ? [{ debugName: "accept" }] : /* istanbul ignore next */ []);
|
|
313
|
+
this.ariaDescribedBy = input(null, {
|
|
314
|
+
...ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {},
|
|
315
|
+
alias: "aria-describedby"
|
|
316
|
+
});
|
|
317
|
+
this.ariaLabel = input(null, {
|
|
318
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
319
|
+
alias: "aria-label"
|
|
320
|
+
});
|
|
321
|
+
this.ariaLabelledBy = input(null, {
|
|
322
|
+
...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
|
|
323
|
+
alias: "aria-labelledby"
|
|
324
|
+
});
|
|
325
|
+
this.autoUpload = input(true, {
|
|
326
|
+
...ngDevMode ? { debugName: "autoUpload" } : /* istanbul ignore next */ {},
|
|
327
|
+
transform: booleanAttribute
|
|
328
|
+
});
|
|
329
|
+
this.disabled = input(false, {
|
|
330
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
331
|
+
transform: booleanAttribute
|
|
332
|
+
});
|
|
333
|
+
this.invalid = input(false, {
|
|
334
|
+
...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
|
|
335
|
+
transform: booleanAttribute
|
|
336
|
+
});
|
|
337
|
+
this.items = computed(() => this.#entries().map((entry) => entry.item), ...ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []);
|
|
338
|
+
this.maxFileSize = input(null, {
|
|
339
|
+
...ngDevMode ? { debugName: "maxFileSize" } : /* istanbul ignore next */ {},
|
|
340
|
+
transform: optionalNumberAttribute
|
|
341
|
+
});
|
|
342
|
+
this.maxFiles = input(null, {
|
|
343
|
+
...ngDevMode ? { debugName: "maxFiles" } : /* istanbul ignore next */ {},
|
|
344
|
+
transform: optionalNumberAttribute
|
|
345
|
+
});
|
|
346
|
+
this.minFileSize = input(null, {
|
|
347
|
+
...ngDevMode ? { debugName: "minFileSize" } : /* istanbul ignore next */ {},
|
|
348
|
+
transform: optionalNumberAttribute
|
|
349
|
+
});
|
|
350
|
+
this.multiple = input(true, {
|
|
351
|
+
...ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {},
|
|
352
|
+
transform: booleanAttribute
|
|
353
|
+
});
|
|
354
|
+
this.readonly = input(false, {
|
|
355
|
+
...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
|
|
356
|
+
transform: booleanAttribute
|
|
357
|
+
});
|
|
358
|
+
this.remove = output();
|
|
359
|
+
this.required = input(false, {
|
|
360
|
+
...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
|
|
361
|
+
transform: booleanAttribute
|
|
362
|
+
});
|
|
363
|
+
this.touch = output();
|
|
364
|
+
this.touched = input(false, {
|
|
365
|
+
...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
|
|
366
|
+
transform: booleanAttribute
|
|
367
|
+
});
|
|
368
|
+
this.upload = input(null, ...ngDevMode ? [{ debugName: "upload" }] : /* istanbul ignore next */ []);
|
|
369
|
+
this.uploadError = output();
|
|
370
|
+
this.uploadSuccess = output();
|
|
371
|
+
this.uploading = computed(() => this.#entries().some((entry) => entry.item.status === "uploading"), ...ngDevMode ? [{ debugName: "uploading" }] : /* istanbul ignore next */ []);
|
|
372
|
+
this.userClass = input("", {
|
|
373
|
+
...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
|
|
374
|
+
alias: "class"
|
|
375
|
+
});
|
|
376
|
+
this.value = model([], ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
377
|
+
effect(() => {
|
|
378
|
+
const value = this.value() ?? [];
|
|
379
|
+
untracked(() => this.#adoptValue(value));
|
|
380
|
+
});
|
|
381
|
+
this.#destroyRef.onDestroy(() => {
|
|
382
|
+
clearTimeout(this.#announcementTimer);
|
|
383
|
+
for (const entry of this.#entries()) entry.abort?.();
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
browse() {
|
|
387
|
+
if (this.interactive()) this.fileInputRef().nativeElement.click();
|
|
388
|
+
}
|
|
389
|
+
clearFiles() {
|
|
390
|
+
const entries = this.#entries();
|
|
391
|
+
if (entries.length === 0) return;
|
|
392
|
+
for (const entry of entries) entry.abort?.();
|
|
393
|
+
this.#entries.set([]);
|
|
394
|
+
this.#writeValue();
|
|
395
|
+
for (const entry of entries) if (entry.item.status !== "rejected") this.remove.emit(entry.item);
|
|
396
|
+
}
|
|
397
|
+
focus() {
|
|
398
|
+
this.browseButtonRef().nativeElement.focus();
|
|
399
|
+
}
|
|
400
|
+
setLabelledBy(id) {
|
|
401
|
+
this.#label.setLabelledBy(id);
|
|
402
|
+
}
|
|
403
|
+
uploadFiles() {
|
|
404
|
+
if (this.upload() == null) return;
|
|
405
|
+
for (const entry of this.#entries()) if (entry.item.status === "selected") this.#startUpload(entry.key);
|
|
406
|
+
}
|
|
407
|
+
onClearClick() {
|
|
408
|
+
this.clearFiles();
|
|
409
|
+
this.focus();
|
|
410
|
+
}
|
|
411
|
+
onDragEnter(event) {
|
|
412
|
+
if (!this.#carriesFiles(event)) return;
|
|
413
|
+
event.preventDefault();
|
|
414
|
+
if (!this.interactive()) return;
|
|
415
|
+
this.#dragDepth++;
|
|
416
|
+
this.dragging.set(true);
|
|
417
|
+
}
|
|
418
|
+
onDragLeave(event) {
|
|
419
|
+
if (!this.#carriesFiles(event) || this.#dragDepth === 0) return;
|
|
420
|
+
this.#dragDepth--;
|
|
421
|
+
if (this.#dragDepth === 0) this.dragging.set(false);
|
|
422
|
+
}
|
|
423
|
+
onDragOver(event) {
|
|
424
|
+
if (!this.#carriesFiles(event)) return;
|
|
425
|
+
event.preventDefault();
|
|
426
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = this.interactive() ? "copy" : "none";
|
|
427
|
+
}
|
|
428
|
+
onDrop(event) {
|
|
429
|
+
if (!this.#carriesFiles(event)) return;
|
|
430
|
+
event.preventDefault();
|
|
431
|
+
this.#dragDepth = 0;
|
|
432
|
+
this.dragging.set(false);
|
|
433
|
+
if (!this.interactive()) return;
|
|
434
|
+
this.#addFiles(Array.from(event.dataTransfer?.files ?? []));
|
|
435
|
+
this.touch.emit();
|
|
436
|
+
}
|
|
437
|
+
onFileInputChange(event) {
|
|
438
|
+
const input = event.target;
|
|
439
|
+
const files = Array.from(input.files ?? []);
|
|
440
|
+
input.value = "";
|
|
441
|
+
this.#addFiles(files);
|
|
442
|
+
}
|
|
443
|
+
onFocusOut(event) {
|
|
444
|
+
const next = event.relatedTarget;
|
|
445
|
+
if (next != null && this.#hostElementRef.nativeElement.contains(next)) return;
|
|
446
|
+
if (next == null && !this.#document.hasFocus()) return;
|
|
447
|
+
this.touch.emit();
|
|
448
|
+
}
|
|
449
|
+
onRemoveClick(row) {
|
|
450
|
+
this.#removeEntry(row.key);
|
|
451
|
+
}
|
|
452
|
+
onRetryClick(row) {
|
|
453
|
+
const hadFocus = this.#rowHasFocus(row.key);
|
|
454
|
+
this.#startUpload(row.key);
|
|
455
|
+
if (hadFocus) afterNextRender(() => this.#hostElementRef.nativeElement.querySelector(`[data-file-row="${row.key}"] [data-file-action="remove"]`)?.focus(), { injector: this.#injector });
|
|
456
|
+
}
|
|
457
|
+
onUploadClick() {
|
|
458
|
+
this.uploadFiles();
|
|
459
|
+
this.focus();
|
|
460
|
+
}
|
|
461
|
+
onZoneClick(event) {
|
|
462
|
+
if (event.target instanceof Element && this.browseButtonRef().nativeElement.contains(event.target)) return;
|
|
463
|
+
event.preventDefault();
|
|
464
|
+
this.browse();
|
|
465
|
+
}
|
|
466
|
+
#addFiles(files) {
|
|
467
|
+
if (!this.interactive() || files.length === 0) return;
|
|
468
|
+
const rules = this.#rules();
|
|
469
|
+
const multiple = this.multiple();
|
|
470
|
+
const limit = multiple ? this.#maxFiles() ?? Number.POSITIVE_INFINITY : 1;
|
|
471
|
+
const kept = this.#entries().filter((entry) => entry.item.status !== "rejected");
|
|
472
|
+
const added = [];
|
|
473
|
+
const rejected = [];
|
|
474
|
+
for (const file of files) {
|
|
475
|
+
if ([...kept, ...added].some((entry) => isSameFile(entry.item.file, file)) && multiple) continue;
|
|
476
|
+
let rejection = checkFile(file, rules);
|
|
477
|
+
const count = (multiple ? kept.length : 0) + added.length;
|
|
478
|
+
if (rejection == null && count >= limit) rejection = "maxFiles";
|
|
479
|
+
if (rejection == null) added.push(this.#createEntry(file, "selected"));
|
|
480
|
+
else rejected.push(this.#createEntry(file, "rejected", rejection));
|
|
481
|
+
}
|
|
482
|
+
const replaced = !multiple && added.length > 0 ? kept : [];
|
|
483
|
+
for (const entry of replaced) entry.abort?.();
|
|
484
|
+
const remaining = replaced.length > 0 ? [] : kept;
|
|
485
|
+
this.#entries.set([
|
|
486
|
+
...remaining,
|
|
487
|
+
...added,
|
|
488
|
+
...rejected
|
|
489
|
+
]);
|
|
490
|
+
this.#writeValue();
|
|
491
|
+
this.#announceAdded(added, rejected);
|
|
492
|
+
if (this.upload() != null && this.autoUpload()) for (const entry of added) this.#startUpload(entry.key);
|
|
493
|
+
}
|
|
494
|
+
#adoptValue(value) {
|
|
495
|
+
if (value === this.#writtenValue || isSameFileList(value, this.#valueFiles(this.#entries()))) {
|
|
496
|
+
this.#writtenValue = value;
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
for (const entry of this.#entries()) entry.abort?.();
|
|
500
|
+
const status = this.upload() != null ? "uploaded" : "selected";
|
|
501
|
+
this.#entries.set(value.map((file) => this.#createEntry(file, status)));
|
|
502
|
+
this.#writtenValue = value;
|
|
503
|
+
}
|
|
504
|
+
#announce(message) {
|
|
505
|
+
if (!message) return;
|
|
506
|
+
clearTimeout(this.#announcementTimer);
|
|
507
|
+
if (this.announcement() !== message) {
|
|
508
|
+
this.announcement.set(message);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
this.announcement.set("");
|
|
512
|
+
this.#announcementTimer = setTimeout(() => this.announcement.set(message), ANNOUNCEMENT_REPEAT_DELAY);
|
|
513
|
+
}
|
|
514
|
+
#announceAdded(added, rejected) {
|
|
515
|
+
const messages = this.messages();
|
|
516
|
+
const parts = [];
|
|
517
|
+
if (added.length > 0) parts.push(messages.filesAdded(added.length));
|
|
518
|
+
for (const entry of rejected) parts.push(messages.fileRejected(entry.item.file.name, this.#rejectionMessage(entry.item.rejection)));
|
|
519
|
+
this.#announce(parts.join(" "));
|
|
520
|
+
}
|
|
521
|
+
#carriesFiles(event) {
|
|
522
|
+
const types = event.dataTransfer?.types;
|
|
523
|
+
return types != null && Array.from(types).includes("Files");
|
|
524
|
+
}
|
|
525
|
+
#createEntry(file, status, rejection = null) {
|
|
526
|
+
return {
|
|
527
|
+
abort: null,
|
|
528
|
+
item: {
|
|
529
|
+
error: null,
|
|
530
|
+
file,
|
|
531
|
+
progress: null,
|
|
532
|
+
rejection,
|
|
533
|
+
response: null,
|
|
534
|
+
status
|
|
535
|
+
},
|
|
536
|
+
key: this.#nextKey++
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
#focusAfterRemoval(index) {
|
|
540
|
+
afterNextRender(() => {
|
|
541
|
+
const rows = this.#hostElementRef.nativeElement.querySelectorAll("[data-file-row]");
|
|
542
|
+
(rows[Math.min(index, rows.length - 1)]?.querySelector("button:not(:disabled)") ?? this.browseButtonRef().nativeElement).focus();
|
|
543
|
+
}, { injector: this.#injector });
|
|
544
|
+
}
|
|
545
|
+
#patchEntry(key, patch, abort) {
|
|
546
|
+
const entries = this.#entries();
|
|
547
|
+
const index = entries.findIndex((entry) => entry.key === key);
|
|
548
|
+
if (index < 0) return null;
|
|
549
|
+
const entry = entries[index];
|
|
550
|
+
const item = {
|
|
551
|
+
...entry.item,
|
|
552
|
+
...patch
|
|
553
|
+
};
|
|
554
|
+
const next = [...entries];
|
|
555
|
+
next[index] = {
|
|
556
|
+
abort: abort === void 0 ? entry.abort : abort,
|
|
557
|
+
item,
|
|
558
|
+
key
|
|
559
|
+
};
|
|
560
|
+
this.#entries.set(next);
|
|
561
|
+
return item;
|
|
562
|
+
}
|
|
563
|
+
#positiveOrNull(value) {
|
|
564
|
+
return value != null && Number.isFinite(value) && value > 0 ? value : null;
|
|
565
|
+
}
|
|
566
|
+
#rejectionMessage(rejection) {
|
|
567
|
+
const messages = this.messages();
|
|
568
|
+
const localeId = this.#i18n.localeId();
|
|
569
|
+
switch (rejection) {
|
|
570
|
+
case "maxFileSize": return messages.tooLarge(formatFileSize(this.#rules().maxFileSize ?? 0, localeId));
|
|
571
|
+
case "maxFiles": return messages.tooMany(this.multiple() ? this.#maxFiles() ?? 1 : 1);
|
|
572
|
+
case "minFileSize": return messages.tooSmall(formatFileSize(this.#rules().minFileSize ?? 0, localeId));
|
|
573
|
+
case "type": return messages.invalidType;
|
|
574
|
+
default: return "";
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
#removeEntry(key) {
|
|
578
|
+
const entries = this.#entries();
|
|
579
|
+
const index = entries.findIndex((entry) => entry.key === key);
|
|
580
|
+
if (index < 0) return;
|
|
581
|
+
const entry = entries[index];
|
|
582
|
+
const hadFocus = this.#rowHasFocus(key);
|
|
583
|
+
entry.abort?.();
|
|
584
|
+
this.#entries.set(entries.filter((other) => other.key !== key));
|
|
585
|
+
this.#writeValue();
|
|
586
|
+
if (entry.item.status !== "rejected") this.remove.emit(entry.item);
|
|
587
|
+
this.#announce(this.messages().fileRemoved(entry.item.file.name));
|
|
588
|
+
if (hadFocus) this.#focusAfterRemoval(index);
|
|
589
|
+
}
|
|
590
|
+
#rowHasFocus(key) {
|
|
591
|
+
const row = this.#hostElementRef.nativeElement.querySelector(`[data-file-row="${key}"]`);
|
|
592
|
+
return row != null && row.contains(this.#document.activeElement);
|
|
593
|
+
}
|
|
594
|
+
#startUpload(key) {
|
|
595
|
+
const handler = this.upload();
|
|
596
|
+
const entry = this.#entries().find((other) => other.key === key);
|
|
597
|
+
if (handler == null || entry == null || entry.item.status === "uploading" || entry.item.status === "rejected") return;
|
|
598
|
+
const file = entry.item.file;
|
|
599
|
+
const controller = new AbortController();
|
|
600
|
+
let finished = false;
|
|
601
|
+
let subscription = null;
|
|
602
|
+
const abort = () => {
|
|
603
|
+
finished = true;
|
|
604
|
+
controller.abort();
|
|
605
|
+
subscription?.unsubscribe();
|
|
606
|
+
};
|
|
607
|
+
const context = {
|
|
608
|
+
progress: (loaded, total = file.size) => {
|
|
609
|
+
if (!finished && Number.isFinite(loaded) && total > 0) this.#patchEntry(key, { progress: Math.min(1, Math.max(0, loaded / total)) });
|
|
610
|
+
},
|
|
611
|
+
signal: controller.signal
|
|
612
|
+
};
|
|
613
|
+
const succeed = (response) => {
|
|
614
|
+
if (finished) return;
|
|
615
|
+
finished = true;
|
|
616
|
+
const item = this.#patchEntry(key, {
|
|
617
|
+
progress: 1,
|
|
618
|
+
response,
|
|
619
|
+
status: "uploaded"
|
|
620
|
+
}, null);
|
|
621
|
+
this.#writeValue();
|
|
622
|
+
if (item) {
|
|
623
|
+
this.uploadSuccess.emit(item);
|
|
624
|
+
this.#announce(this.messages().fileUploaded(file.name));
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
const fail = (error) => {
|
|
628
|
+
if (finished) return;
|
|
629
|
+
finished = true;
|
|
630
|
+
const item = this.#patchEntry(key, {
|
|
631
|
+
error,
|
|
632
|
+
progress: null,
|
|
633
|
+
status: "failed"
|
|
634
|
+
}, null);
|
|
635
|
+
if (item) {
|
|
636
|
+
this.uploadError.emit(item);
|
|
637
|
+
this.#announce(this.messages().fileFailed(file.name));
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
this.#patchEntry(key, {
|
|
641
|
+
error: null,
|
|
642
|
+
progress: null,
|
|
643
|
+
response: null,
|
|
644
|
+
status: "uploading"
|
|
645
|
+
}, abort);
|
|
646
|
+
let result;
|
|
647
|
+
try {
|
|
648
|
+
result = handler(file, context);
|
|
649
|
+
} catch (error) {
|
|
650
|
+
fail(error);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
if (isObservable(result)) {
|
|
654
|
+
let response = void 0;
|
|
655
|
+
subscription = result.subscribe({
|
|
656
|
+
complete: () => succeed(response),
|
|
657
|
+
error: (error) => fail(error),
|
|
658
|
+
next: (value) => {
|
|
659
|
+
const progress = httpUploadProgress(value);
|
|
660
|
+
if (progress) context.progress(progress.loaded, progress.total);
|
|
661
|
+
else if (value instanceof HttpResponse) response = value.body;
|
|
662
|
+
else if (!isHttpEventWithoutResult(value)) response = value;
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
if (finished) subscription.unsubscribe();
|
|
666
|
+
} else Promise.resolve(result).then(succeed, fail);
|
|
667
|
+
}
|
|
668
|
+
#valueFiles(entries) {
|
|
669
|
+
const status = this.upload() != null ? "uploaded" : "selected";
|
|
670
|
+
return entries.filter((entry) => entry.item.status === status).map((entry) => entry.item.file);
|
|
671
|
+
}
|
|
672
|
+
#writeValue() {
|
|
673
|
+
const files = this.#valueFiles(this.#entries());
|
|
674
|
+
if (isSameFileList(files, this.value() ?? [])) return;
|
|
675
|
+
this.#writtenValue = files;
|
|
676
|
+
this.value.set(files);
|
|
677
|
+
}
|
|
678
|
+
static {
|
|
679
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
680
|
+
minVersion: "12.0.0",
|
|
681
|
+
version: "22.2.6",
|
|
682
|
+
ngImport: i0,
|
|
683
|
+
type: FileUploadComponent,
|
|
684
|
+
deps: [],
|
|
685
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
static {
|
|
689
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
690
|
+
minVersion: "17.0.0",
|
|
691
|
+
version: "22.2.6",
|
|
692
|
+
type: FileUploadComponent,
|
|
693
|
+
isStandalone: true,
|
|
694
|
+
selector: "mona-file-upload",
|
|
695
|
+
inputs: {
|
|
696
|
+
accept: {
|
|
697
|
+
classPropertyName: "accept",
|
|
698
|
+
publicName: "accept",
|
|
699
|
+
isSignal: true,
|
|
700
|
+
isRequired: false,
|
|
701
|
+
transformFunction: null
|
|
702
|
+
},
|
|
703
|
+
ariaDescribedBy: {
|
|
704
|
+
classPropertyName: "ariaDescribedBy",
|
|
705
|
+
publicName: "aria-describedby",
|
|
706
|
+
isSignal: true,
|
|
707
|
+
isRequired: false,
|
|
708
|
+
transformFunction: null
|
|
709
|
+
},
|
|
710
|
+
ariaLabel: {
|
|
711
|
+
classPropertyName: "ariaLabel",
|
|
712
|
+
publicName: "aria-label",
|
|
713
|
+
isSignal: true,
|
|
714
|
+
isRequired: false,
|
|
715
|
+
transformFunction: null
|
|
716
|
+
},
|
|
717
|
+
ariaLabelledBy: {
|
|
718
|
+
classPropertyName: "ariaLabelledBy",
|
|
719
|
+
publicName: "aria-labelledby",
|
|
720
|
+
isSignal: true,
|
|
721
|
+
isRequired: false,
|
|
722
|
+
transformFunction: null
|
|
723
|
+
},
|
|
724
|
+
autoUpload: {
|
|
725
|
+
classPropertyName: "autoUpload",
|
|
726
|
+
publicName: "autoUpload",
|
|
727
|
+
isSignal: true,
|
|
728
|
+
isRequired: false,
|
|
729
|
+
transformFunction: null
|
|
730
|
+
},
|
|
731
|
+
disabled: {
|
|
732
|
+
classPropertyName: "disabled",
|
|
733
|
+
publicName: "disabled",
|
|
734
|
+
isSignal: true,
|
|
735
|
+
isRequired: false,
|
|
736
|
+
transformFunction: null
|
|
737
|
+
},
|
|
738
|
+
invalid: {
|
|
739
|
+
classPropertyName: "invalid",
|
|
740
|
+
publicName: "invalid",
|
|
741
|
+
isSignal: true,
|
|
742
|
+
isRequired: false,
|
|
743
|
+
transformFunction: null
|
|
744
|
+
},
|
|
745
|
+
maxFileSize: {
|
|
746
|
+
classPropertyName: "maxFileSize",
|
|
747
|
+
publicName: "maxFileSize",
|
|
748
|
+
isSignal: true,
|
|
749
|
+
isRequired: false,
|
|
750
|
+
transformFunction: null
|
|
751
|
+
},
|
|
752
|
+
maxFiles: {
|
|
753
|
+
classPropertyName: "maxFiles",
|
|
754
|
+
publicName: "maxFiles",
|
|
755
|
+
isSignal: true,
|
|
756
|
+
isRequired: false,
|
|
757
|
+
transformFunction: null
|
|
758
|
+
},
|
|
759
|
+
minFileSize: {
|
|
760
|
+
classPropertyName: "minFileSize",
|
|
761
|
+
publicName: "minFileSize",
|
|
762
|
+
isSignal: true,
|
|
763
|
+
isRequired: false,
|
|
764
|
+
transformFunction: null
|
|
765
|
+
},
|
|
766
|
+
multiple: {
|
|
767
|
+
classPropertyName: "multiple",
|
|
768
|
+
publicName: "multiple",
|
|
769
|
+
isSignal: true,
|
|
770
|
+
isRequired: false,
|
|
771
|
+
transformFunction: null
|
|
772
|
+
},
|
|
773
|
+
readonly: {
|
|
774
|
+
classPropertyName: "readonly",
|
|
775
|
+
publicName: "readonly",
|
|
776
|
+
isSignal: true,
|
|
777
|
+
isRequired: false,
|
|
778
|
+
transformFunction: null
|
|
779
|
+
},
|
|
780
|
+
required: {
|
|
781
|
+
classPropertyName: "required",
|
|
782
|
+
publicName: "required",
|
|
783
|
+
isSignal: true,
|
|
784
|
+
isRequired: false,
|
|
785
|
+
transformFunction: null
|
|
786
|
+
},
|
|
787
|
+
touched: {
|
|
788
|
+
classPropertyName: "touched",
|
|
789
|
+
publicName: "touched",
|
|
790
|
+
isSignal: true,
|
|
791
|
+
isRequired: false,
|
|
792
|
+
transformFunction: null
|
|
793
|
+
},
|
|
794
|
+
upload: {
|
|
795
|
+
classPropertyName: "upload",
|
|
796
|
+
publicName: "upload",
|
|
797
|
+
isSignal: true,
|
|
798
|
+
isRequired: false,
|
|
799
|
+
transformFunction: null
|
|
800
|
+
},
|
|
801
|
+
userClass: {
|
|
802
|
+
classPropertyName: "userClass",
|
|
803
|
+
publicName: "class",
|
|
804
|
+
isSignal: true,
|
|
805
|
+
isRequired: false,
|
|
806
|
+
transformFunction: null
|
|
807
|
+
},
|
|
808
|
+
value: {
|
|
809
|
+
classPropertyName: "value",
|
|
810
|
+
publicName: "value",
|
|
811
|
+
isSignal: true,
|
|
812
|
+
isRequired: false,
|
|
813
|
+
transformFunction: null
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
outputs: {
|
|
817
|
+
remove: "remove",
|
|
818
|
+
touch: "touch",
|
|
819
|
+
uploadError: "uploadError",
|
|
820
|
+
uploadSuccess: "uploadSuccess",
|
|
821
|
+
value: "valueChange"
|
|
822
|
+
},
|
|
823
|
+
host: {
|
|
824
|
+
attributes: { "role": "group" },
|
|
825
|
+
listeners: { "focusout": "onFocusOut($event)" },
|
|
826
|
+
properties: {
|
|
827
|
+
"attr.aria-describedby": "null",
|
|
828
|
+
"attr.aria-label": "ariaLabel() || null",
|
|
829
|
+
"attr.aria-labelledby": "labelledBy()",
|
|
830
|
+
"attr.data-disabled": "effectiveDisabled() || null",
|
|
831
|
+
"attr.data-invalid": "invalidState() || null",
|
|
832
|
+
"attr.data-readonly": "readonly() || null",
|
|
833
|
+
"class": "classes()"
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
viewQueries: [{
|
|
837
|
+
propertyName: "browseButtonRef",
|
|
838
|
+
first: true,
|
|
839
|
+
predicate: ["browseButton"],
|
|
840
|
+
descendants: true,
|
|
841
|
+
isSignal: true
|
|
842
|
+
}, {
|
|
843
|
+
propertyName: "fileInputRef",
|
|
844
|
+
first: true,
|
|
845
|
+
predicate: ["fileInput"],
|
|
846
|
+
descendants: true,
|
|
847
|
+
isSignal: true
|
|
848
|
+
}],
|
|
849
|
+
exportAs: ["monaFileUpload"],
|
|
850
|
+
ngImport: i0,
|
|
851
|
+
template: "<!-- The zone also opens the dialog on a click, as a shortcut for the pointer; the browse button is the way in for the keyboard. -->\n<div\n [class]=\"zoneClass\"\n [attr.data-disabled]=\"effectiveDisabled() || null\"\n [attr.data-dragging]=\"dragging() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.data-readonly]=\"readonly() || null\"\n (click)=\"onZoneClick($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\">\n <svg lucideCloudUpload [class]=\"zoneIconClass\" [size]=\"24\" aria-hidden=\"true\"></svg>\n <span [class]=\"zoneTextClass\">\n {{ dragging() ? messages().dropToAdd : multiple() ? messages().dropFiles : messages().dropFile }}\n </span>\n @if (restrictions()) {\n <span [class]=\"restrictionsClass\" [id]=\"restrictionsId\">{{ restrictions() }}</span>\n }\n <button\n #browseButton\n monaButton\n size=\"small\"\n [class]=\"browseClass\"\n [attr.aria-describedby]=\"browseDescribedBy()\"\n [disabled]=\"!interactive()\"\n (click)=\"browse()\">\n {{ multiple() ? messages().browse : messages().browseFile }}\n </button>\n</div>\n<input\n #fileInput\n type=\"file\"\n class=\"sr-only\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [accept]=\"accept()\"\n [disabled]=\"!interactive()\"\n [multiple]=\"multiple()\"\n (change)=\"onFileInputChange($event)\" />\n\n@if (rows().length > 0) {\n <ul [class]=\"listClass\" [attr.aria-label]=\"messages().files\">\n @for (row of rows(); track row.key) {\n <li [class]=\"itemClass\" [attr.data-file-row]=\"row.key\" [attr.data-status]=\"row.item.status\">\n @switch (row.icon) {\n @case (\"error\") {\n <svg lucideCircleAlert [class]=\"itemIconClass.error\" [size]=\"18\" aria-hidden=\"true\"></svg>\n }\n @case (\"uploaded\") {\n <svg lucideCircleCheck [class]=\"itemIconClass.uploaded\" [size]=\"18\" aria-hidden=\"true\"></svg>\n }\n @default {\n <svg lucideFile [class]=\"itemIconClass.file\" [size]=\"18\" aria-hidden=\"true\"></svg>\n }\n }\n <div [class]=\"itemBodyClass\">\n <span [class]=\"itemNameClass\" [id]=\"row.nameId\" [attr.title]=\"row.item.file.name\">\n {{ row.item.file.name }}\n </span>\n <span [class]=\"row.statusError ? itemStatusClass.error : itemStatusClass.muted\" [id]=\"row.statusId\">\n {{ row.status }}\n </span>\n @if (row.item.status === \"uploading\") {\n <mona-progress-bar\n [class]=\"itemProgressClass\"\n [aria-label]=\"row.progressLabel\"\n [indeterminate]=\"row.progressValue === null\"\n [labelVisible]=\"false\"\n [rounded]=\"'full'\"\n [value]=\"row.progressValue ?? 0\" />\n }\n </div>\n @if (row.actionsShown) {\n <div [class]=\"itemActionsClass\">\n @if (row.item.status === \"failed\") {\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [attr.aria-label]=\"row.retryLabel\"\n [attr.aria-describedby]=\"row.statusId\"\n [disabled]=\"!interactive()\"\n [iconOnly]=\"true\"\n (click)=\"onRetryClick(row)\">\n <svg lucideRotateCw [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n }\n <button\n monaButton\n data-file-action=\"remove\"\n look=\"ghost\"\n size=\"small\"\n [attr.aria-label]=\"row.removeLabel\"\n [disabled]=\"!interactive()\"\n [iconOnly]=\"true\"\n (click)=\"onRemoveClick(row)\">\n <svg lucideX [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n }\n </li>\n }\n </ul>\n}\n\n@if (pendingActionsShown()) {\n <div [class]=\"actionsClass\">\n <button monaButton look=\"ghost\" size=\"small\" (click)=\"onClearClick()\">{{ messages().clear }}</button>\n <button monaButton look=\"primary\" size=\"small\" (click)=\"onUploadClick()\">{{ messages().upload }}</button>\n </div>\n}\n<span class=\"sr-only\" role=\"status\" aria-atomic=\"true\">{{ announcement() }}</span>\n",
|
|
852
|
+
dependencies: [
|
|
853
|
+
{
|
|
854
|
+
kind: "directive",
|
|
855
|
+
type: ButtonDirective,
|
|
856
|
+
selector: "button[monaButton]",
|
|
857
|
+
inputs: [
|
|
858
|
+
"aria-haspopup",
|
|
859
|
+
"disabled",
|
|
860
|
+
"iconOnly",
|
|
861
|
+
"loading",
|
|
862
|
+
"look",
|
|
863
|
+
"rounded",
|
|
864
|
+
"selected",
|
|
865
|
+
"size",
|
|
866
|
+
"tabindex",
|
|
867
|
+
"toggleable",
|
|
868
|
+
"type",
|
|
869
|
+
"class",
|
|
870
|
+
"value"
|
|
871
|
+
],
|
|
872
|
+
outputs: ["lookChange", "selectedChange"]
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
kind: "component",
|
|
876
|
+
type: LucideCircleAlert,
|
|
877
|
+
selector: "svg[lucideCircleExclamationPoint], svg[lucideAlertCircle], svg[lucideCircleAlert]"
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
kind: "component",
|
|
881
|
+
type: LucideCircleCheck,
|
|
882
|
+
selector: "svg[lucideCircleCheck], svg[lucideCheckCircle2]"
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
kind: "component",
|
|
886
|
+
type: LucideCloudUpload,
|
|
887
|
+
selector: "svg[lucideCloudUpload], svg[lucideUploadCloud]"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
kind: "component",
|
|
891
|
+
type: LucideFile,
|
|
892
|
+
selector: "svg[lucideFile]"
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
kind: "component",
|
|
896
|
+
type: LucideRotateCw,
|
|
897
|
+
selector: "svg[lucideRotateCw]"
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
kind: "component",
|
|
901
|
+
type: LucideX,
|
|
902
|
+
selector: "svg[lucideX]"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
kind: "component",
|
|
906
|
+
type: ProgressBarComponent,
|
|
907
|
+
selector: "mona-progress-bar",
|
|
908
|
+
inputs: [
|
|
909
|
+
"animate",
|
|
910
|
+
"aria-label",
|
|
911
|
+
"aria-valuetext",
|
|
912
|
+
"color",
|
|
913
|
+
"disabled",
|
|
914
|
+
"indeterminate",
|
|
915
|
+
"labelPosition",
|
|
916
|
+
"labelStyles",
|
|
917
|
+
"labelVisible",
|
|
918
|
+
"max",
|
|
919
|
+
"min",
|
|
920
|
+
"rounded",
|
|
921
|
+
"class",
|
|
922
|
+
"value"
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
]
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
930
|
+
minVersion: "12.0.0",
|
|
931
|
+
version: "22.2.6",
|
|
932
|
+
ngImport: i0,
|
|
933
|
+
type: FileUploadComponent,
|
|
934
|
+
decorators: [{
|
|
935
|
+
type: Component,
|
|
936
|
+
args: [{
|
|
937
|
+
selector: "mona-file-upload",
|
|
938
|
+
exportAs: "monaFileUpload",
|
|
939
|
+
imports: [
|
|
940
|
+
ButtonDirective,
|
|
941
|
+
LucideCircleAlert,
|
|
942
|
+
LucideCircleCheck,
|
|
943
|
+
LucideCloudUpload,
|
|
944
|
+
LucideFile,
|
|
945
|
+
LucideRotateCw,
|
|
946
|
+
LucideX,
|
|
947
|
+
ProgressBarComponent
|
|
948
|
+
],
|
|
949
|
+
host: {
|
|
950
|
+
role: "group",
|
|
951
|
+
"[attr.aria-describedby]": "null",
|
|
952
|
+
"[attr.aria-label]": "ariaLabel() || null",
|
|
953
|
+
"[attr.aria-labelledby]": "labelledBy()",
|
|
954
|
+
"[attr.data-disabled]": "effectiveDisabled() || null",
|
|
955
|
+
"[attr.data-invalid]": "invalidState() || null",
|
|
956
|
+
"[attr.data-readonly]": "readonly() || null",
|
|
957
|
+
"[class]": "classes()",
|
|
958
|
+
"(focusout)": "onFocusOut($event)"
|
|
959
|
+
},
|
|
960
|
+
template: "<!-- The zone also opens the dialog on a click, as a shortcut for the pointer; the browse button is the way in for the keyboard. -->\n<div\n [class]=\"zoneClass\"\n [attr.data-disabled]=\"effectiveDisabled() || null\"\n [attr.data-dragging]=\"dragging() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.data-readonly]=\"readonly() || null\"\n (click)=\"onZoneClick($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\">\n <svg lucideCloudUpload [class]=\"zoneIconClass\" [size]=\"24\" aria-hidden=\"true\"></svg>\n <span [class]=\"zoneTextClass\">\n {{ dragging() ? messages().dropToAdd : multiple() ? messages().dropFiles : messages().dropFile }}\n </span>\n @if (restrictions()) {\n <span [class]=\"restrictionsClass\" [id]=\"restrictionsId\">{{ restrictions() }}</span>\n }\n <button\n #browseButton\n monaButton\n size=\"small\"\n [class]=\"browseClass\"\n [attr.aria-describedby]=\"browseDescribedBy()\"\n [disabled]=\"!interactive()\"\n (click)=\"browse()\">\n {{ multiple() ? messages().browse : messages().browseFile }}\n </button>\n</div>\n<input\n #fileInput\n type=\"file\"\n class=\"sr-only\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [accept]=\"accept()\"\n [disabled]=\"!interactive()\"\n [multiple]=\"multiple()\"\n (change)=\"onFileInputChange($event)\" />\n\n@if (rows().length > 0) {\n <ul [class]=\"listClass\" [attr.aria-label]=\"messages().files\">\n @for (row of rows(); track row.key) {\n <li [class]=\"itemClass\" [attr.data-file-row]=\"row.key\" [attr.data-status]=\"row.item.status\">\n @switch (row.icon) {\n @case (\"error\") {\n <svg lucideCircleAlert [class]=\"itemIconClass.error\" [size]=\"18\" aria-hidden=\"true\"></svg>\n }\n @case (\"uploaded\") {\n <svg lucideCircleCheck [class]=\"itemIconClass.uploaded\" [size]=\"18\" aria-hidden=\"true\"></svg>\n }\n @default {\n <svg lucideFile [class]=\"itemIconClass.file\" [size]=\"18\" aria-hidden=\"true\"></svg>\n }\n }\n <div [class]=\"itemBodyClass\">\n <span [class]=\"itemNameClass\" [id]=\"row.nameId\" [attr.title]=\"row.item.file.name\">\n {{ row.item.file.name }}\n </span>\n <span [class]=\"row.statusError ? itemStatusClass.error : itemStatusClass.muted\" [id]=\"row.statusId\">\n {{ row.status }}\n </span>\n @if (row.item.status === \"uploading\") {\n <mona-progress-bar\n [class]=\"itemProgressClass\"\n [aria-label]=\"row.progressLabel\"\n [indeterminate]=\"row.progressValue === null\"\n [labelVisible]=\"false\"\n [rounded]=\"'full'\"\n [value]=\"row.progressValue ?? 0\" />\n }\n </div>\n @if (row.actionsShown) {\n <div [class]=\"itemActionsClass\">\n @if (row.item.status === \"failed\") {\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [attr.aria-label]=\"row.retryLabel\"\n [attr.aria-describedby]=\"row.statusId\"\n [disabled]=\"!interactive()\"\n [iconOnly]=\"true\"\n (click)=\"onRetryClick(row)\">\n <svg lucideRotateCw [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n }\n <button\n monaButton\n data-file-action=\"remove\"\n look=\"ghost\"\n size=\"small\"\n [attr.aria-label]=\"row.removeLabel\"\n [disabled]=\"!interactive()\"\n [iconOnly]=\"true\"\n (click)=\"onRemoveClick(row)\">\n <svg lucideX [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n }\n </li>\n }\n </ul>\n}\n\n@if (pendingActionsShown()) {\n <div [class]=\"actionsClass\">\n <button monaButton look=\"ghost\" size=\"small\" (click)=\"onClearClick()\">{{ messages().clear }}</button>\n <button monaButton look=\"primary\" size=\"small\" (click)=\"onUploadClick()\">{{ messages().upload }}</button>\n </div>\n}\n<span class=\"sr-only\" role=\"status\" aria-atomic=\"true\">{{ announcement() }}</span>\n"
|
|
961
|
+
}]
|
|
962
|
+
}],
|
|
963
|
+
ctorParameters: () => [],
|
|
964
|
+
propDecorators: {
|
|
965
|
+
browseButtonRef: [{
|
|
966
|
+
type: i0.ViewChild,
|
|
967
|
+
args: ["browseButton", { isSignal: true }]
|
|
968
|
+
}],
|
|
969
|
+
fileInputRef: [{
|
|
970
|
+
type: i0.ViewChild,
|
|
971
|
+
args: ["fileInput", { isSignal: true }]
|
|
972
|
+
}],
|
|
973
|
+
accept: [{
|
|
974
|
+
type: i0.Input,
|
|
975
|
+
args: [{
|
|
976
|
+
isSignal: true,
|
|
977
|
+
alias: "accept",
|
|
978
|
+
required: false
|
|
979
|
+
}]
|
|
980
|
+
}],
|
|
981
|
+
ariaDescribedBy: [{
|
|
982
|
+
type: i0.Input,
|
|
983
|
+
args: [{
|
|
984
|
+
isSignal: true,
|
|
985
|
+
alias: "aria-describedby",
|
|
986
|
+
required: false
|
|
987
|
+
}]
|
|
988
|
+
}],
|
|
989
|
+
ariaLabel: [{
|
|
990
|
+
type: i0.Input,
|
|
991
|
+
args: [{
|
|
992
|
+
isSignal: true,
|
|
993
|
+
alias: "aria-label",
|
|
994
|
+
required: false
|
|
995
|
+
}]
|
|
996
|
+
}],
|
|
997
|
+
ariaLabelledBy: [{
|
|
998
|
+
type: i0.Input,
|
|
999
|
+
args: [{
|
|
1000
|
+
isSignal: true,
|
|
1001
|
+
alias: "aria-labelledby",
|
|
1002
|
+
required: false
|
|
1003
|
+
}]
|
|
1004
|
+
}],
|
|
1005
|
+
autoUpload: [{
|
|
1006
|
+
type: i0.Input,
|
|
1007
|
+
args: [{
|
|
1008
|
+
isSignal: true,
|
|
1009
|
+
alias: "autoUpload",
|
|
1010
|
+
required: false
|
|
1011
|
+
}]
|
|
1012
|
+
}],
|
|
1013
|
+
disabled: [{
|
|
1014
|
+
type: i0.Input,
|
|
1015
|
+
args: [{
|
|
1016
|
+
isSignal: true,
|
|
1017
|
+
alias: "disabled",
|
|
1018
|
+
required: false
|
|
1019
|
+
}]
|
|
1020
|
+
}],
|
|
1021
|
+
invalid: [{
|
|
1022
|
+
type: i0.Input,
|
|
1023
|
+
args: [{
|
|
1024
|
+
isSignal: true,
|
|
1025
|
+
alias: "invalid",
|
|
1026
|
+
required: false
|
|
1027
|
+
}]
|
|
1028
|
+
}],
|
|
1029
|
+
maxFileSize: [{
|
|
1030
|
+
type: i0.Input,
|
|
1031
|
+
args: [{
|
|
1032
|
+
isSignal: true,
|
|
1033
|
+
alias: "maxFileSize",
|
|
1034
|
+
required: false
|
|
1035
|
+
}]
|
|
1036
|
+
}],
|
|
1037
|
+
maxFiles: [{
|
|
1038
|
+
type: i0.Input,
|
|
1039
|
+
args: [{
|
|
1040
|
+
isSignal: true,
|
|
1041
|
+
alias: "maxFiles",
|
|
1042
|
+
required: false
|
|
1043
|
+
}]
|
|
1044
|
+
}],
|
|
1045
|
+
minFileSize: [{
|
|
1046
|
+
type: i0.Input,
|
|
1047
|
+
args: [{
|
|
1048
|
+
isSignal: true,
|
|
1049
|
+
alias: "minFileSize",
|
|
1050
|
+
required: false
|
|
1051
|
+
}]
|
|
1052
|
+
}],
|
|
1053
|
+
multiple: [{
|
|
1054
|
+
type: i0.Input,
|
|
1055
|
+
args: [{
|
|
1056
|
+
isSignal: true,
|
|
1057
|
+
alias: "multiple",
|
|
1058
|
+
required: false
|
|
1059
|
+
}]
|
|
1060
|
+
}],
|
|
1061
|
+
readonly: [{
|
|
1062
|
+
type: i0.Input,
|
|
1063
|
+
args: [{
|
|
1064
|
+
isSignal: true,
|
|
1065
|
+
alias: "readonly",
|
|
1066
|
+
required: false
|
|
1067
|
+
}]
|
|
1068
|
+
}],
|
|
1069
|
+
remove: [{
|
|
1070
|
+
type: i0.Output,
|
|
1071
|
+
args: ["remove"]
|
|
1072
|
+
}],
|
|
1073
|
+
required: [{
|
|
1074
|
+
type: i0.Input,
|
|
1075
|
+
args: [{
|
|
1076
|
+
isSignal: true,
|
|
1077
|
+
alias: "required",
|
|
1078
|
+
required: false
|
|
1079
|
+
}]
|
|
1080
|
+
}],
|
|
1081
|
+
touch: [{
|
|
1082
|
+
type: i0.Output,
|
|
1083
|
+
args: ["touch"]
|
|
1084
|
+
}],
|
|
1085
|
+
touched: [{
|
|
1086
|
+
type: i0.Input,
|
|
1087
|
+
args: [{
|
|
1088
|
+
isSignal: true,
|
|
1089
|
+
alias: "touched",
|
|
1090
|
+
required: false
|
|
1091
|
+
}]
|
|
1092
|
+
}],
|
|
1093
|
+
upload: [{
|
|
1094
|
+
type: i0.Input,
|
|
1095
|
+
args: [{
|
|
1096
|
+
isSignal: true,
|
|
1097
|
+
alias: "upload",
|
|
1098
|
+
required: false
|
|
1099
|
+
}]
|
|
1100
|
+
}],
|
|
1101
|
+
uploadError: [{
|
|
1102
|
+
type: i0.Output,
|
|
1103
|
+
args: ["uploadError"]
|
|
1104
|
+
}],
|
|
1105
|
+
uploadSuccess: [{
|
|
1106
|
+
type: i0.Output,
|
|
1107
|
+
args: ["uploadSuccess"]
|
|
1108
|
+
}],
|
|
1109
|
+
userClass: [{
|
|
1110
|
+
type: i0.Input,
|
|
1111
|
+
args: [{
|
|
1112
|
+
isSignal: true,
|
|
1113
|
+
alias: "class",
|
|
1114
|
+
required: false
|
|
1115
|
+
}]
|
|
1116
|
+
}],
|
|
1117
|
+
value: [{
|
|
1118
|
+
type: i0.Input,
|
|
1119
|
+
args: [{
|
|
1120
|
+
isSignal: true,
|
|
1121
|
+
alias: "value",
|
|
1122
|
+
required: false
|
|
1123
|
+
}]
|
|
1124
|
+
}, {
|
|
1125
|
+
type: i0.Output,
|
|
1126
|
+
args: ["valueChange"]
|
|
1127
|
+
}]
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
function optionalNumberAttribute(value) {
|
|
1131
|
+
if (value == null || value === "") return null;
|
|
1132
|
+
const number = numberAttribute(value, NaN);
|
|
1133
|
+
return Number.isNaN(number) ? null : number;
|
|
1134
|
+
}
|
|
1135
|
+
export { FILE_UPLOAD_DEFAULT_MESSAGES, FileUploadComponent, formatFileSize };
|
|
1136
|
+
|
|
1137
|
+
//# sourceMappingURL=nanahoshi-mona-ui-file-upload.mjs.map
|