@exhaustive-ui/core 22.0.1 → 22.2.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.
@@ -0,0 +1,1504 @@
1
+ export * from '@exhaustive-ui/core/types/fileinput';
2
+ import { NgTemplateOutlet } from '@angular/common';
3
+ import { HttpClient, HttpEventType } from '@angular/common/http';
4
+ import * as i0 from '@angular/core';
5
+ import { Injectable, forwardRef, inject, input, booleanAttribute, numberAttribute, output, contentChild, viewChild, signal, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
6
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
7
+ import { TranslationKeys, SharedModule } from '@exhaustive-ui/core/api';
8
+ import { PARENT_INSTANCE } from '@exhaustive-ui/core/basecomponent';
9
+ import { BaseEditableHolder } from '@exhaustive-ui/core/baseeditableholder';
10
+ import * as i1 from '@exhaustive-ui/core/bind';
11
+ import { Bind, BindModule } from '@exhaustive-ui/core/bind';
12
+ import { UploadIcon, TimesIcon, RefreshIcon, TrashIcon, ArrowDownIcon, BanIcon, CheckIcon } from '@exhaustive-ui/core/icons';
13
+ import { uuid } from '@exhaustive-ui/utils';
14
+ import { style } from '@exhaustive-ui/styles/fileinput';
15
+ import { BaseStyle } from '@exhaustive-ui/core/base';
16
+
17
+ const classes = {
18
+ root: ({ instance }) => [
19
+ 'p-fileinput p-component',
20
+ {
21
+ 'p-fileinput-images': instance.variant() === 'images',
22
+ 'p-fileinput-avatar-variant': instance.variant() === 'avatar',
23
+ 'p-fileinput-sm': instance.size() === 'small',
24
+ 'p-fileinput-lg': instance.size() === 'large',
25
+ 'p-fileinput-invalid': instance.$invalid(),
26
+ 'p-fileinput-disabled': instance.$disabled()
27
+ }
28
+ ],
29
+ input: 'p-fileinput-input',
30
+ dropzone: ({ instance }) => ['p-fileinput-dropzone', { 'p-fileinput-dropzone-active': instance.dragActive() }],
31
+ dropzoneIcon: 'p-fileinput-dropzone-icon',
32
+ label: 'p-fileinput-label',
33
+ browse: 'p-fileinput-browse',
34
+ hint: 'p-fileinput-hint',
35
+ summary: 'p-fileinput-summary',
36
+ progress: 'p-fileinput-progress',
37
+ progressValue: 'p-fileinput-progress-value',
38
+ list: 'p-fileinput-list',
39
+ item: ({ item }) => ['p-fileinput-item', { 'p-fileinput-item-error': item.status === 'invalid' || item.status === 'failed' }],
40
+ thumbnail: 'p-fileinput-thumbnail',
41
+ info: 'p-fileinput-info',
42
+ name: 'p-fileinput-name',
43
+ path: 'p-fileinput-path',
44
+ meta: 'p-fileinput-meta',
45
+ status: ({ item }) => ['p-fileinput-status', { 'p-fileinput-status-done': item.status === 'uploaded', 'p-fileinput-error': item.status === 'invalid' || item.status === 'failed' }],
46
+ actions: 'p-fileinput-actions',
47
+ action: 'p-fileinput-action',
48
+ actionIcon: 'p-fileinput-action-icon',
49
+ grid: 'p-fileinput-grid',
50
+ tile: ({ item }) => ['p-fileinput-tile', { 'p-fileinput-tile-error': item.status === 'invalid' || item.status === 'failed' }],
51
+ tileOverlay: 'p-fileinput-tile-overlay',
52
+ tileActions: 'p-fileinput-tile-actions',
53
+ tileDone: 'p-fileinput-tile-done',
54
+ cover: 'p-fileinput-cover',
55
+ add: ({ instance }) => ['p-fileinput-add', { 'p-fileinput-dropzone-active': instance.dragActive() }],
56
+ avatar: ({ instance }) => [
57
+ 'p-fileinput-avatar',
58
+ {
59
+ 'p-fileinput-avatar-square': instance.avatarShape() === 'square',
60
+ 'p-fileinput-avatar-filled': !!instance.avatarSrc(),
61
+ 'p-fileinput-avatar-uploading': instance.avatarItem()?.status === 'uploading'
62
+ }
63
+ ],
64
+ avatarIcon: 'p-fileinput-avatar-icon',
65
+ avatarOverlay: 'p-fileinput-avatar-overlay',
66
+ avatarError: 'p-fileinput-avatar-error'
67
+ };
68
+ class FileInputStyle extends BaseStyle {
69
+ name = 'fileinput';
70
+ style = style;
71
+ classes = classes;
72
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInputStyle, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
73
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInputStyle });
74
+ }
75
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInputStyle, decorators: [{
76
+ type: Injectable
77
+ }] });
78
+ /**
79
+ *
80
+ * FileInput selects files by drag and drop, paste or the file picker, validates them and uploads them with a progress per file.
81
+ *
82
+ * [Live Demo](https://exhaustive-ui.com/fileinput/)
83
+ *
84
+ * @module fileinputstyle
85
+ *
86
+ */
87
+ var FileInputClasses;
88
+ (function (FileInputClasses) {
89
+ /**
90
+ * Class name of the root element
91
+ */
92
+ FileInputClasses["root"] = "p-fileinput";
93
+ /**
94
+ * Class name of the hidden file input
95
+ */
96
+ FileInputClasses["input"] = "p-fileinput-input";
97
+ /**
98
+ * Class name of the dropzone
99
+ */
100
+ FileInputClasses["dropzone"] = "p-fileinput-dropzone";
101
+ /**
102
+ * Class name of the dropzone icon
103
+ */
104
+ FileInputClasses["dropzoneIcon"] = "p-fileinput-dropzone-icon";
105
+ /**
106
+ * Class name of the dropzone label
107
+ */
108
+ FileInputClasses["label"] = "p-fileinput-label";
109
+ /**
110
+ * Class name of the hint
111
+ */
112
+ FileInputClasses["hint"] = "p-fileinput-hint";
113
+ /**
114
+ * Class name of the upload summary
115
+ */
116
+ FileInputClasses["summary"] = "p-fileinput-summary";
117
+ /**
118
+ * Class name of a progress bar
119
+ */
120
+ FileInputClasses["progress"] = "p-fileinput-progress";
121
+ /**
122
+ * Class name of the file list
123
+ */
124
+ FileInputClasses["list"] = "p-fileinput-list";
125
+ /**
126
+ * Class name of a file row
127
+ */
128
+ FileInputClasses["item"] = "p-fileinput-item";
129
+ /**
130
+ * Class name of a thumbnail
131
+ */
132
+ FileInputClasses["thumbnail"] = "p-fileinput-thumbnail";
133
+ /**
134
+ * Class name of a file name
135
+ */
136
+ FileInputClasses["name"] = "p-fileinput-name";
137
+ /**
138
+ * Class name of the size and status line
139
+ */
140
+ FileInputClasses["meta"] = "p-fileinput-meta";
141
+ /**
142
+ * Class name of an action button
143
+ */
144
+ FileInputClasses["action"] = "p-fileinput-action";
145
+ /**
146
+ * Class name of the image grid
147
+ */
148
+ FileInputClasses["grid"] = "p-fileinput-grid";
149
+ /**
150
+ * Class name of an image tile
151
+ */
152
+ FileInputClasses["tile"] = "p-fileinput-tile";
153
+ /**
154
+ * Class name of the add tile
155
+ */
156
+ FileInputClasses["add"] = "p-fileinput-add";
157
+ /**
158
+ * Class name of the avatar
159
+ */
160
+ FileInputClasses["avatar"] = "p-fileinput-avatar";
161
+ })(FileInputClasses || (FileInputClasses = {}));
162
+
163
+ const FILEINPUT_VALUE_ACCESSOR = {
164
+ provide: NG_VALUE_ACCESSOR,
165
+ useExisting: forwardRef(() => FileInput),
166
+ multi: true
167
+ };
168
+ /**
169
+ * Default texts of FileInput.
170
+ * @group Constants
171
+ */
172
+ const FILEINPUT_DEFAULT_LABELS = {
173
+ dropzone: 'Drop files here or',
174
+ browse: 'browse',
175
+ add: 'Add',
176
+ avatarAdd: 'Add',
177
+ avatarChange: 'Change',
178
+ cover: 'Cover',
179
+ remove: 'Remove',
180
+ cancel: 'Cancel upload',
181
+ retry: 'Retry',
182
+ download: 'Download',
183
+ delete: 'Delete',
184
+ queued: 'Queued',
185
+ uploaded: 'Uploaded',
186
+ canceled: 'Canceled',
187
+ summary: '{0} of {1} uploaded · {2} of {3}',
188
+ typeError: 'This file type is not accepted',
189
+ maxFileSizeError: 'Too large: {0}, maximum {1}',
190
+ minFileSizeError: 'Too small: {0}, minimum {1}',
191
+ maxFilesError: 'Limit of {0} files reached',
192
+ maxTotalSizeError: 'Exceeds the total limit of {0}',
193
+ uploadError: 'Upload failed',
194
+ addedMessage: '{0} file(s) added',
195
+ rejectedMessage: '{0} rejected',
196
+ uploadedMessage: '{0} uploaded',
197
+ failedMessage: 'Upload of {0} failed',
198
+ removedMessage: '{0} removed',
199
+ listLabel: 'Selected files'
200
+ };
201
+ let fileInputItemId = 0;
202
+ const format = (text, ...values) => values.reduce((acc, value, index) => acc.replace(`{${index}}`, String(value)), text);
203
+ /**
204
+ * FileInput selects files by drag and drop, paste or the file picker, validates each file and uploads it with its own progress. It works with template-driven forms, reactive forms and Signal Forms.
205
+ * @group Components
206
+ */
207
+ class FileInput extends BaseEditableHolder {
208
+ componentName = 'FileInput';
209
+ bindDirectiveInstance = inject(Bind, { self: true });
210
+ _componentStyle = inject(FileInputStyle);
211
+ http = inject(HttpClient, { optional: true });
212
+ constructor() {
213
+ super();
214
+ this.bindHostAttrs(this.bindDirectiveInstance, () => this.ptms(['host', 'root']));
215
+ }
216
+ /******************** Inputs ********************/
217
+ /**
218
+ * Layout of the component: a dropzone with a list, a grid of images, or a single avatar.
219
+ * @defaultValue 'list'
220
+ * @group Props
221
+ */
222
+ variant = input('list', /* @ts-ignore */
223
+ ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
224
+ /**
225
+ * Shape of the avatar variant.
226
+ * @defaultValue 'circle'
227
+ * @group Props
228
+ */
229
+ avatarShape = input('circle', /* @ts-ignore */
230
+ ...(ngDevMode ? [{ debugName: "avatarShape" }] : /* istanbul ignore next */ []));
231
+ /**
232
+ * Whether several files can be selected. The value is then an array of files, otherwise a single file or null. Always false in the avatar variant.
233
+ * @defaultValue true
234
+ * @group Props
235
+ */
236
+ multiple = input(true, { ...(ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
237
+ /**
238
+ * Accepted file types, as in the accept attribute of a file input: extensions such as `.pdf` and MIME types such as `image/*`.
239
+ * @group Props
240
+ */
241
+ accept = input(/* @ts-ignore */
242
+ ...(ngDevMode ? [undefined, { debugName: "accept" }] : /* istanbul ignore next */ []));
243
+ /**
244
+ * On mobile devices, opens the camera directly: `user` for the front camera, `environment` for the back camera.
245
+ * @group Props
246
+ */
247
+ capture = input(/* @ts-ignore */
248
+ ...(ngDevMode ? [undefined, { debugName: "capture" }] : /* istanbul ignore next */ []));
249
+ /**
250
+ * Makes the file picker select a whole folder. Dropped folders are always accepted.
251
+ * @defaultValue false
252
+ * @group Props
253
+ */
254
+ directory = input(false, { ...(ngDevMode ? { debugName: "directory" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
255
+ /**
256
+ * Maximum size of a file, in bytes.
257
+ * @group Props
258
+ */
259
+ maxFileSize = input(undefined, { ...(ngDevMode ? { debugName: "maxFileSize" } : /* istanbul ignore next */ {}), transform: numberAttribute });
260
+ /**
261
+ * Minimum size of a file, in bytes.
262
+ * @group Props
263
+ */
264
+ minFileSize = input(undefined, { ...(ngDevMode ? { debugName: "minFileSize" } : /* istanbul ignore next */ {}), transform: numberAttribute });
265
+ /**
266
+ * Maximum number of files, existing files included.
267
+ * @group Props
268
+ */
269
+ maxFiles = input(undefined, { ...(ngDevMode ? { debugName: "maxFiles" } : /* istanbul ignore next */ {}), transform: numberAttribute });
270
+ /**
271
+ * Maximum size of all the files together, in bytes.
272
+ * @group Props
273
+ */
274
+ maxTotalSize = input(undefined, { ...(ngDevMode ? { debugName: "maxTotalSize" } : /* istanbul ignore next */ {}), transform: numberAttribute });
275
+ /**
276
+ * URL to upload each file to, in its own request. Requires provideHttpClient().
277
+ * @group Props
278
+ */
279
+ url = input(/* @ts-ignore */
280
+ ...(ngDevMode ? [undefined, { debugName: "url" }] : /* istanbul ignore next */ []));
281
+ /**
282
+ * HTTP method of the upload requests.
283
+ * @defaultValue 'post'
284
+ * @group Props
285
+ */
286
+ method = input('post', /* @ts-ignore */
287
+ ...(ngDevMode ? [{ debugName: "method" }] : /* istanbul ignore next */ []));
288
+ /**
289
+ * Headers of the upload requests.
290
+ * @group Props
291
+ */
292
+ headers = input(/* @ts-ignore */
293
+ ...(ngDevMode ? [undefined, { debugName: "headers" }] : /* istanbul ignore next */ []));
294
+ /**
295
+ * Whether the upload requests send cookies and credentials.
296
+ * @defaultValue false
297
+ * @group Props
298
+ */
299
+ withCredentials = input(false, { ...(ngDevMode ? { debugName: "withCredentials" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
300
+ /**
301
+ * Name of the form data field that holds the file in an upload request.
302
+ * @defaultValue 'file'
303
+ * @group Props
304
+ */
305
+ fieldName = input('file', /* @ts-ignore */
306
+ ...(ngDevMode ? [{ debugName: "fieldName" }] : /* istanbul ignore next */ []));
307
+ /**
308
+ * Function that uploads one file, used instead of url: to upload straight to cloud storage, or through your own service.
309
+ * @group Props
310
+ */
311
+ uploadHandler = input(/* @ts-ignore */
312
+ ...(ngDevMode ? [undefined, { debugName: "uploadHandler" }] : /* istanbul ignore next */ []));
313
+ /**
314
+ * Whether files start uploading as soon as they are added. When false, call upload().
315
+ * @defaultValue true
316
+ * @group Props
317
+ */
318
+ auto = input(true, { ...(ngDevMode ? { debugName: "auto" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
319
+ /**
320
+ * Maximum number of files uploaded at the same time.
321
+ * @defaultValue 3
322
+ * @group Props
323
+ */
324
+ concurrency = input(3, { ...(ngDevMode ? { debugName: "concurrency" } : /* istanbul ignore next */ {}), transform: numberAttribute });
325
+ /**
326
+ * Files already stored on the server, shown with a download and a delete button.
327
+ * @group Props
328
+ */
329
+ existing = input(/* @ts-ignore */
330
+ ...(ngDevMode ? [undefined, { debugName: "existing" }] : /* istanbul ignore next */ []));
331
+ /**
332
+ * Text under the dropzone label, such as the accepted types and sizes.
333
+ * @group Props
334
+ */
335
+ hint = input(/* @ts-ignore */
336
+ ...(ngDevMode ? [undefined, { debugName: "hint" }] : /* istanbul ignore next */ []));
337
+ /**
338
+ * Texts of the component, merged with the English defaults.
339
+ * @group Props
340
+ */
341
+ labels = input(/* @ts-ignore */
342
+ ...(ngDevMode ? [undefined, { debugName: "labels" }] : /* istanbul ignore next */ []));
343
+ /**
344
+ * Whether to show the summary of the uploads in progress.
345
+ * @defaultValue true
346
+ * @group Props
347
+ */
348
+ showSummary = input(true, { ...(ngDevMode ? { debugName: "showSummary" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
349
+ /**
350
+ * Size of the component.
351
+ * @group Props
352
+ */
353
+ size = input(/* @ts-ignore */
354
+ ...(ngDevMode ? [undefined, { debugName: "size" }] : /* istanbul ignore next */ []));
355
+ /**
356
+ * Identifier of the hidden file input.
357
+ * @group Props
358
+ */
359
+ inputId = input(/* @ts-ignore */
360
+ ...(ngDevMode ? [undefined, { debugName: "inputId" }] : /* istanbul ignore next */ []));
361
+ /**
362
+ * Accessible label of the dropzone, the add tile or the avatar.
363
+ * @group Props
364
+ */
365
+ ariaLabel = input(/* @ts-ignore */
366
+ ...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
367
+ /**
368
+ * Identifier of the element that labels the dropzone, the add tile or the avatar.
369
+ * @group Props
370
+ */
371
+ ariaLabelledBy = input(/* @ts-ignore */
372
+ ...(ngDevMode ? [undefined, { debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
373
+ /******************** Outputs ********************/
374
+ /**
375
+ * Callback to invoke when files are added, including the ones rejected by validation.
376
+ * @param {FileInputSelectEvent} event - Custom select event.
377
+ * @group Emits
378
+ */
379
+ onSelect = output();
380
+ /**
381
+ * Callback to invoke when the user removes a file.
382
+ * @param {FileInputItemEvent} event - Custom item event.
383
+ * @group Emits
384
+ */
385
+ onRemove = output();
386
+ /**
387
+ * Callback to invoke when the user cancels an upload.
388
+ * @param {FileInputItemEvent} event - Custom item event.
389
+ * @group Emits
390
+ */
391
+ onCancel = output();
392
+ /**
393
+ * Callback to invoke when a file is uploaded.
394
+ * @param {FileInputUploadEvent} event - Custom upload event.
395
+ * @group Emits
396
+ */
397
+ onUpload = output();
398
+ /**
399
+ * Callback to invoke when an upload fails.
400
+ * @param {FileInputErrorEvent} event - Custom error event.
401
+ * @group Emits
402
+ */
403
+ onError = output();
404
+ /**
405
+ * Callback to invoke when the last upload in progress ends.
406
+ * @param {FileInputCompleteEvent} event - Custom complete event.
407
+ * @group Emits
408
+ */
409
+ onComplete = output();
410
+ /**
411
+ * Callback to invoke when the user deletes an existing file. Delete it on the server from this callback.
412
+ * @param {FileInputRemoveExistingEvent} event - Custom remove existing event.
413
+ * @group Emits
414
+ */
415
+ onRemoveExisting = output();
416
+ /******************** Templates ********************/
417
+ /**
418
+ * Custom content of the dropzone.
419
+ * @param {FileInputDropzoneTemplateContext} context - dropzone context.
420
+ * @group Templates
421
+ */
422
+ dropzoneTemplate = contentChild('dropzone', { ...(ngDevMode ? { debugName: "dropzoneTemplate" } : /* istanbul ignore next */ {}), descendants: false });
423
+ /**
424
+ * Custom row of the list variant.
425
+ * @param {FileInputItemTemplateContext} context - item context.
426
+ * @group Templates
427
+ */
428
+ itemTemplate = contentChild('item', { ...(ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {}), descendants: false });
429
+ fileInput = viewChild('fileInput', /* @ts-ignore */
430
+ ...(ngDevMode ? [{ debugName: "fileInput" }] : /* istanbul ignore next */ []));
431
+ /******************** State ********************/
432
+ /**
433
+ * Files selected in this session, uploaded or not, including the invalid ones.
434
+ */
435
+ items = signal([], /* @ts-ignore */
436
+ ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
437
+ removedExisting = signal(new Set(), /* @ts-ignore */
438
+ ...(ngDevMode ? [{ debugName: "removedExisting" }] : /* istanbul ignore next */ []));
439
+ dragActive = signal(false, /* @ts-ignore */
440
+ ...(ngDevMode ? [{ debugName: "dragActive" }] : /* istanbul ignore next */ []));
441
+ announcement = signal('', /* @ts-ignore */
442
+ ...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
443
+ uid = uuid('pn_id_');
444
+ hintId = `${this.uid}_hint`;
445
+ openFn = () => this.open();
446
+ dragDepth = 0;
447
+ uploads = new Map();
448
+ batch = null;
449
+ isMultiple = computed(() => this.variant() !== 'avatar' && this.multiple(), /* @ts-ignore */
450
+ ...(ngDevMode ? [{ debugName: "isMultiple" }] : /* istanbul ignore next */ []));
451
+ $invalid = computed(() => !!this.invalid(), /* @ts-ignore */
452
+ ...(ngDevMode ? [{ debugName: "$invalid" }] : /* istanbul ignore next */ []));
453
+ mergedLabels = computed(() => ({ ...FILEINPUT_DEFAULT_LABELS, ...(this.labels() ?? {}) }), /* @ts-ignore */
454
+ ...(ngDevMode ? [{ debugName: "mergedLabels" }] : /* istanbul ignore next */ []));
455
+ existingItems = computed(() => {
456
+ const removed = this.removedExisting();
457
+ return (this.existing() ?? [])
458
+ .filter((file) => !removed.has(file.id ?? file.name))
459
+ .map((file) => ({
460
+ id: `existing_${file.id ?? file.name}`,
461
+ name: file.name,
462
+ path: '',
463
+ size: file.size,
464
+ type: file.type ?? '',
465
+ status: 'existing',
466
+ progress: 100,
467
+ existing: file
468
+ }));
469
+ }, /* @ts-ignore */
470
+ ...(ngDevMode ? [{ debugName: "existingItems" }] : /* istanbul ignore next */ []));
471
+ displayItems = computed(() => [...this.existingItems(), ...this.items()], /* @ts-ignore */
472
+ ...(ngDevMode ? [{ debugName: "displayItems" }] : /* istanbul ignore next */ []));
473
+ countedItems = computed(() => this.displayItems().filter((item) => item.status !== 'invalid'), /* @ts-ignore */
474
+ ...(ngDevMode ? [{ debugName: "countedItems" }] : /* istanbul ignore next */ []));
475
+ coverId = computed(() => this.countedItems()[0]?.id, /* @ts-ignore */
476
+ ...(ngDevMode ? [{ debugName: "coverId" }] : /* istanbul ignore next */ []));
477
+ canAdd = computed(() => {
478
+ const max = this.maxFiles();
479
+ return !this.$disabled() && (max === undefined || this.countedItems().length < max);
480
+ }, /* @ts-ignore */
481
+ ...(ngDevMode ? [{ debugName: "canAdd" }] : /* istanbul ignore next */ []));
482
+ avatarItem = computed(() => this.items().at(-1), /* @ts-ignore */
483
+ ...(ngDevMode ? [{ debugName: "avatarItem" }] : /* istanbul ignore next */ []));
484
+ avatarSrc = computed(() => {
485
+ const item = this.avatarItem();
486
+ if (item && item.status !== 'invalid') {
487
+ return item.previewUrl;
488
+ }
489
+ const existing = this.existingItems()[0];
490
+ return existing ? this.thumbnailOf(existing) : undefined;
491
+ }, /* @ts-ignore */
492
+ ...(ngDevMode ? [{ debugName: "avatarSrc" }] : /* istanbul ignore next */ []));
493
+ summary = computed(() => {
494
+ const items = this.items().filter((item) => item.status === 'queued' || item.status === 'uploading' || item.status === 'uploaded');
495
+ if (!items.some((item) => item.status !== 'uploaded')) {
496
+ return null;
497
+ }
498
+ const total = items.reduce((sum, item) => sum + (item.size ?? 0), 0);
499
+ const done = items.reduce((sum, item) => sum + (item.size ?? 0) * (item.status === 'uploaded' ? 1 : item.progress / 100), 0);
500
+ const count = items.filter((item) => item.status === 'uploaded').length;
501
+ return {
502
+ percent: total ? Math.round((done / total) * 100) : 0,
503
+ text: format(this.labelOf('summary'), count, items.length, this.formatSize(done), this.formatSize(total))
504
+ };
505
+ }, /* @ts-ignore */
506
+ ...(ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []));
507
+ dataP = computed(() => this.cn({
508
+ [this.variant()]: true,
509
+ invalid: this.$invalid(),
510
+ disabled: this.$disabled(),
511
+ [this.size()]: !!this.size()
512
+ }), /* @ts-ignore */
513
+ ...(ngDevMode ? [{ debugName: "dataP" }] : /* istanbul ignore next */ []));
514
+ /******************** Public methods ********************/
515
+ /**
516
+ * Opens the file picker.
517
+ * @group Method
518
+ */
519
+ open() {
520
+ if (!this.$disabled()) {
521
+ this.fileInput()?.nativeElement.click();
522
+ }
523
+ }
524
+ /**
525
+ * Adds files as if the user had selected them.
526
+ * @param {File[]} files - Files to add.
527
+ * @group Method
528
+ */
529
+ addFiles(files, event) {
530
+ this.add(files.map((file) => ({ file, path: '' })), event);
531
+ }
532
+ /**
533
+ * Uploads the selected files that are not uploaded yet. Only needed when auto is false.
534
+ * @group Method
535
+ */
536
+ upload() {
537
+ this.items.update((items) => items.map((item) => (item.status === 'selected' ? { ...item, status: 'queued' } : item)));
538
+ this.pump();
539
+ }
540
+ /**
541
+ * Removes a file. For an existing file, emits onRemoveExisting.
542
+ * @param {FileInputItem} item - The item to remove.
543
+ * @group Method
544
+ */
545
+ remove(item) {
546
+ if (item.status === 'existing') {
547
+ const file = item.existing;
548
+ this.removedExisting.update((set) => new Set(set).add(file.id ?? file.name));
549
+ this.onRemoveExisting.emit({ file });
550
+ }
551
+ else {
552
+ this.abort(item.id);
553
+ this.revoke(item);
554
+ this.items.update((items) => items.filter((it) => it.id !== item.id));
555
+ this.onRemove.emit({ item });
556
+ this.emitValue();
557
+ this.pump();
558
+ }
559
+ this.announce(format(this.labelOf('removedMessage'), item.name));
560
+ this.restoreFocus();
561
+ }
562
+ /**
563
+ * Cancels the upload of a file.
564
+ * @param {FileInputItem} item - The item to cancel.
565
+ * @group Method
566
+ */
567
+ cancel(item) {
568
+ this.abort(item.id);
569
+ this.patch(item.id, { status: 'canceled', progress: 0 });
570
+ this.onCancel.emit({ item });
571
+ this.pump();
572
+ }
573
+ /**
574
+ * Retries the upload of a failed or canceled file.
575
+ * @param {FileInputItem} item - The item to retry.
576
+ * @group Method
577
+ */
578
+ retry(item) {
579
+ this.patch(item.id, { status: 'queued', progress: 0, error: undefined, errorCode: undefined });
580
+ this.pump();
581
+ }
582
+ /**
583
+ * Removes all the selected files and cancels their uploads. Existing files are kept.
584
+ * @group Method
585
+ */
586
+ clear() {
587
+ this.items().forEach((item) => {
588
+ this.abort(item.id);
589
+ this.revoke(item);
590
+ });
591
+ this.items.set([]);
592
+ this.emitValue();
593
+ }
594
+ /******************** Template helpers ********************/
595
+ labelOf(key) {
596
+ return this.mergedLabels()[key];
597
+ }
598
+ /**
599
+ * Formats a size in bytes with decimal units, so that 5000000 reads 5 MB.
600
+ */
601
+ formatSize(bytes) {
602
+ const units = this.config.getTranslation(TranslationKeys.FILE_SIZE_TYPES) ?? ['B', 'KB', 'MB', 'GB', 'TB'];
603
+ if (!bytes) {
604
+ return `0 ${units[0]}`;
605
+ }
606
+ const index = Math.min(Math.floor(Math.log(bytes) / Math.log(1000)), units.length - 1);
607
+ const value = bytes / Math.pow(1000, index);
608
+ const formatted = new Intl.NumberFormat(undefined, { maximumFractionDigits: index < 2 ? 0 : 1 }).format(value);
609
+ return `${formatted} ${units[index]}`;
610
+ }
611
+ extensionOf(item) {
612
+ const dot = item.name.lastIndexOf('.');
613
+ return dot > 0 ? item.name.slice(dot + 1, dot + 5) : '';
614
+ }
615
+ thumbnailOf(item) {
616
+ if (item.previewUrl) {
617
+ return item.previewUrl;
618
+ }
619
+ const existing = item.existing;
620
+ if (existing) {
621
+ return existing.thumbnail ?? (this.isImage(existing.type ?? '', existing.name) ? existing.url : undefined);
622
+ }
623
+ return undefined;
624
+ }
625
+ statusLabel(item) {
626
+ switch (item.status) {
627
+ case 'queued':
628
+ return this.labelOf('queued');
629
+ case 'uploaded':
630
+ return this.labelOf('uploaded');
631
+ case 'canceled':
632
+ return this.labelOf('canceled');
633
+ default:
634
+ return undefined;
635
+ }
636
+ }
637
+ itemContext(item) {
638
+ return { $implicit: item, remove: () => this.remove(item), retry: () => this.retry(item), cancel: () => this.cancel(item) };
639
+ }
640
+ /******************** Event handlers ********************/
641
+ onFileInputChange(event) {
642
+ const target = event.target;
643
+ const files = Array.from(target.files ?? []);
644
+ this.add(files.map((file) => ({ file, path: this.relativeFolder(file.webkitRelativePath) })), event);
645
+ target.value = '';
646
+ }
647
+ onTriggerKeydown(event) {
648
+ if (event.key === 'Enter' || event.key === ' ') {
649
+ event.preventDefault();
650
+ this.open();
651
+ }
652
+ }
653
+ onDragEnter(event) {
654
+ if (this.$disabled() || !this.hasFiles(event)) {
655
+ return;
656
+ }
657
+ event.preventDefault();
658
+ this.dragDepth++;
659
+ this.dragActive.set(true);
660
+ }
661
+ onDragOver(event) {
662
+ if (this.$disabled() || !this.hasFiles(event)) {
663
+ return;
664
+ }
665
+ event.preventDefault();
666
+ if (event.dataTransfer) {
667
+ event.dataTransfer.dropEffect = 'copy';
668
+ }
669
+ }
670
+ onDragLeave(event) {
671
+ if (!this.dragActive()) {
672
+ return;
673
+ }
674
+ this.dragDepth = Math.max(0, this.dragDepth - 1);
675
+ if (this.dragDepth === 0) {
676
+ this.dragActive.set(false);
677
+ }
678
+ }
679
+ async onDrop(event) {
680
+ event.preventDefault();
681
+ this.dragDepth = 0;
682
+ this.dragActive.set(false);
683
+ if (this.$disabled() || !event.dataTransfer) {
684
+ return;
685
+ }
686
+ const entries = Array.from(event.dataTransfer.items ?? [])
687
+ .map((item) => (typeof item.webkitGetAsEntry === 'function' ? item.webkitGetAsEntry() : null))
688
+ .filter((entry) => !!entry);
689
+ if (entries.length && entries.some((entry) => entry.isDirectory)) {
690
+ const collected = [];
691
+ await Promise.all(entries.map((entry) => this.walk(entry, '', collected)));
692
+ this.add(collected, event);
693
+ }
694
+ else {
695
+ this.add(Array.from(event.dataTransfer.files).map((file) => ({ file, path: '' })), event);
696
+ }
697
+ }
698
+ onPaste(event) {
699
+ if (this.$disabled()) {
700
+ return;
701
+ }
702
+ const files = Array.from(event.clipboardData?.files ?? []);
703
+ if (!files.length) {
704
+ return;
705
+ }
706
+ event.preventDefault();
707
+ const stamp = new Date().toISOString().slice(0, 19).replace(/[-:T]/g, '');
708
+ this.add(files.map((file, index) => {
709
+ const generic = !file.name || /^image\.\w+$/.test(file.name);
710
+ const extension = file.type.split('/')[1] ?? 'bin';
711
+ const named = generic ? new File([file], `paste-${stamp}${index ? '-' + index : ''}.${extension}`, { type: file.type }) : file;
712
+ return { file: named, path: '' };
713
+ }), event);
714
+ }
715
+ /******************** Forms ********************/
716
+ writeControlValue(value, setModelValue) {
717
+ const files = value == null ? [] : Array.isArray(value) ? value : [value];
718
+ const current = this.valueFiles();
719
+ const same = files.length === current.length && files.every((file, index) => file === current[index]);
720
+ if (!same) {
721
+ this.items().forEach((item) => {
722
+ this.abort(item.id);
723
+ this.revoke(item);
724
+ });
725
+ this.items.set(files.filter((file) => typeof File !== 'undefined' && file instanceof File).map((file) => this.createItem(file, '', 'selected')));
726
+ }
727
+ setModelValue(value ?? (this.isMultiple() ? [] : null));
728
+ }
729
+ onDestroy() {
730
+ this.uploads.forEach((upload) => upload.abort());
731
+ this.uploads.clear();
732
+ this.items().forEach((item) => this.revoke(item));
733
+ }
734
+ /******************** Internals ********************/
735
+ add(entries, event) {
736
+ if (this.$disabled() || !entries.length) {
737
+ return;
738
+ }
739
+ if (!this.isMultiple()) {
740
+ entries = entries.slice(0, 1);
741
+ this.items().forEach((item) => {
742
+ this.abort(item.id);
743
+ this.revoke(item);
744
+ });
745
+ this.items.set([]);
746
+ }
747
+ const uploading = this.canUpload() && this.auto();
748
+ const added = [];
749
+ let counted = this.countedItems().length;
750
+ let total = this.countedItems().reduce((sum, item) => sum + (item.size ?? 0), 0);
751
+ for (const { file, path } of entries) {
752
+ const errorCode = this.validate(file, counted, total);
753
+ const item = this.createItem(file, path, errorCode ? 'invalid' : uploading ? 'queued' : 'selected');
754
+ if (errorCode) {
755
+ item.errorCode = errorCode;
756
+ item.error = this.errorMessage(errorCode, file);
757
+ }
758
+ else {
759
+ counted++;
760
+ total += file.size;
761
+ }
762
+ added.push(item);
763
+ }
764
+ this.items.update((items) => [...items, ...added]);
765
+ const rejected = added.filter((item) => item.status === 'invalid').length;
766
+ this.announce(format(this.labelOf('addedMessage'), added.length) + (rejected ? ', ' + format(this.labelOf('rejectedMessage'), rejected) : ''));
767
+ this.onSelect.emit({ originalEvent: event, items: added });
768
+ this.emitValue();
769
+ this.onModelTouched();
770
+ this.pump();
771
+ }
772
+ validate(file, counted, total) {
773
+ if (!this.isAccepted(file))
774
+ return 'type';
775
+ const max = this.maxFileSize();
776
+ if (max !== undefined && file.size > max)
777
+ return 'maxFileSize';
778
+ const min = this.minFileSize();
779
+ if (min !== undefined && file.size < min)
780
+ return 'minFileSize';
781
+ const maxFiles = this.maxFiles();
782
+ if (this.isMultiple() && maxFiles !== undefined && counted >= maxFiles)
783
+ return 'maxFiles';
784
+ const maxTotal = this.maxTotalSize();
785
+ if (maxTotal !== undefined && total + file.size > maxTotal)
786
+ return 'maxTotalSize';
787
+ return undefined;
788
+ }
789
+ errorMessage(code, file) {
790
+ switch (code) {
791
+ case 'maxFileSize':
792
+ return format(this.labelOf('maxFileSizeError'), this.formatSize(file.size), this.formatSize(this.maxFileSize()));
793
+ case 'minFileSize':
794
+ return format(this.labelOf('minFileSizeError'), this.formatSize(file.size), this.formatSize(this.minFileSize()));
795
+ case 'maxFiles':
796
+ return format(this.labelOf('maxFilesError'), this.maxFiles());
797
+ case 'maxTotalSize':
798
+ return format(this.labelOf('maxTotalSizeError'), this.formatSize(this.maxTotalSize()));
799
+ case 'upload':
800
+ return this.labelOf('uploadError');
801
+ default:
802
+ return this.labelOf('typeError');
803
+ }
804
+ }
805
+ isAccepted(file) {
806
+ const accept = this.accept();
807
+ if (!accept) {
808
+ return true;
809
+ }
810
+ const name = file.name.toLowerCase();
811
+ const type = (file.type || '').toLowerCase();
812
+ return accept
813
+ .split(',')
814
+ .map((rule) => rule.trim().toLowerCase())
815
+ .filter(Boolean)
816
+ .some((rule) => {
817
+ if (rule.startsWith('.'))
818
+ return name.endsWith(rule);
819
+ if (rule.endsWith('/*'))
820
+ return type.startsWith(rule.slice(0, -1));
821
+ return type === rule;
822
+ });
823
+ }
824
+ isImage(type, name) {
825
+ return type.startsWith('image/') || /\.(png|jpe?g|gif|webp|avif|svg|bmp)$/i.test(name);
826
+ }
827
+ createItem(file, path, status) {
828
+ const item = {
829
+ id: `${this.uid}_${++fileInputItemId}`,
830
+ file,
831
+ name: file.name,
832
+ path,
833
+ size: file.size,
834
+ type: file.type || '',
835
+ status,
836
+ progress: 0
837
+ };
838
+ if (status !== 'invalid' && this.isImage(item.type, item.name) && typeof URL !== 'undefined' && typeof URL.createObjectURL === 'function') {
839
+ item.previewUrl = URL.createObjectURL(file);
840
+ }
841
+ return item;
842
+ }
843
+ revoke(item) {
844
+ if (item.previewUrl && typeof URL !== 'undefined' && typeof URL.revokeObjectURL === 'function') {
845
+ URL.revokeObjectURL(item.previewUrl);
846
+ }
847
+ }
848
+ valueFiles() {
849
+ return this.items()
850
+ .filter((item) => item.status !== 'invalid' && item.file)
851
+ .map((item) => item.file);
852
+ }
853
+ emitValue() {
854
+ const files = this.valueFiles();
855
+ const value = this.isMultiple() ? files : (files.at(-1) ?? null);
856
+ this.writeModelValue(value);
857
+ this.onModelChange(value);
858
+ }
859
+ canUpload() {
860
+ return !!this.uploadHandler() || !!this.url();
861
+ }
862
+ pump() {
863
+ if (!this.canUpload()) {
864
+ return;
865
+ }
866
+ const limit = Math.max(1, this.concurrency() || 1);
867
+ let running = this.items().filter((item) => item.status === 'uploading').length;
868
+ for (const item of this.items()) {
869
+ if (running >= limit)
870
+ break;
871
+ if (item.status === 'queued') {
872
+ running++;
873
+ this.batch ??= { uploaded: [], failed: [] };
874
+ this.patch(item.id, { status: 'uploading', progress: 0 });
875
+ this.start(item);
876
+ }
877
+ }
878
+ }
879
+ start(item) {
880
+ const handler = this.uploadHandler();
881
+ if (handler) {
882
+ const controller = new AbortController();
883
+ this.uploads.set(item.id, { abort: () => controller.abort() });
884
+ handler(item.file, { signal: controller.signal, item, progress: (percent) => this.progress(item.id, percent) }).then((response) => !controller.signal.aborted && this.succeed(item.id, response), (error) => !controller.signal.aborted && this.fail(item.id, error));
885
+ return;
886
+ }
887
+ if (!this.http) {
888
+ this.fail(item.id, new Error('FileInput: the url input requires provideHttpClient().'));
889
+ return;
890
+ }
891
+ const body = new FormData();
892
+ body.append(this.fieldName(), item.file, item.name);
893
+ const subscription = this.http.request(this.method(), this.url(), { body, headers: this.headers(), reportProgress: true, observe: 'events', withCredentials: this.withCredentials() }).subscribe({
894
+ next: (event) => {
895
+ if (event.type === HttpEventType.UploadProgress && event.total) {
896
+ this.progress(item.id, (event.loaded / event.total) * 100);
897
+ }
898
+ else if (event.type === HttpEventType.Response) {
899
+ this.succeed(item.id, event.body);
900
+ }
901
+ },
902
+ error: (error) => this.fail(item.id, error)
903
+ });
904
+ this.uploads.set(item.id, { abort: () => subscription.unsubscribe() });
905
+ }
906
+ progress(id, percent) {
907
+ const current = this.items().find((item) => item.id === id);
908
+ if (current?.status === 'uploading') {
909
+ this.patch(id, { progress: Math.min(99, Math.max(0, Math.round(percent))) });
910
+ }
911
+ }
912
+ succeed(id, response) {
913
+ this.uploads.delete(id);
914
+ const item = this.patch(id, { status: 'uploaded', progress: 100, response });
915
+ if (item) {
916
+ this.batch?.uploaded.push(item);
917
+ this.onUpload.emit({ item, response });
918
+ this.announce(format(this.labelOf('uploadedMessage'), item.name));
919
+ }
920
+ this.afterUpload();
921
+ }
922
+ fail(id, error) {
923
+ this.uploads.delete(id);
924
+ const item = this.patch(id, { status: 'failed', progress: 0, errorCode: 'upload', error: this.labelOf('uploadError') });
925
+ if (item) {
926
+ this.batch?.failed.push(item);
927
+ this.onError.emit({ item, error });
928
+ this.announce(format(this.labelOf('failedMessage'), item.name));
929
+ }
930
+ this.afterUpload();
931
+ }
932
+ afterUpload() {
933
+ this.pump();
934
+ const busy = this.items().some((item) => item.status === 'uploading' || item.status === 'queued');
935
+ if (!busy && this.batch) {
936
+ const batch = this.batch;
937
+ this.batch = null;
938
+ this.onComplete.emit(batch);
939
+ }
940
+ }
941
+ abort(id) {
942
+ this.uploads.get(id)?.abort();
943
+ this.uploads.delete(id);
944
+ }
945
+ patch(id, changes) {
946
+ let updated;
947
+ this.items.update((items) => items.map((item) => {
948
+ if (item.id !== id)
949
+ return item;
950
+ updated = { ...item, ...changes };
951
+ return updated;
952
+ }));
953
+ return updated;
954
+ }
955
+ announce(message) {
956
+ this.announcement.set(message);
957
+ }
958
+ restoreFocus() {
959
+ setTimeout(() => {
960
+ const host = this.el.nativeElement;
961
+ if (host.contains(this.document.activeElement) && this.document.activeElement !== this.document.body) {
962
+ return;
963
+ }
964
+ const target = host.querySelector('.p-fileinput-action, .p-fileinput-add, .p-fileinput-dropzone, .p-fileinput-avatar');
965
+ target?.focus();
966
+ });
967
+ }
968
+ hasFiles(event) {
969
+ return Array.from(event.dataTransfer?.types ?? []).includes('Files');
970
+ }
971
+ relativeFolder(relativePath) {
972
+ if (!relativePath)
973
+ return '';
974
+ const index = relativePath.lastIndexOf('/');
975
+ return index > 0 ? relativePath.slice(0, index + 1) : '';
976
+ }
977
+ async walk(entry, prefix, out) {
978
+ if (entry.isFile) {
979
+ await new Promise((resolve) => entry.file((file) => {
980
+ out.push({ file, path: prefix });
981
+ resolve();
982
+ }, () => resolve()));
983
+ }
984
+ else if (entry.isDirectory) {
985
+ const reader = entry.createReader();
986
+ let batch;
987
+ do {
988
+ batch = await new Promise((resolve) => reader.readEntries(resolve, () => resolve([])));
989
+ await Promise.all(batch.map((child) => this.walk(child, `${prefix}${entry.name}/`, out)));
990
+ } while (batch.length);
991
+ }
992
+ }
993
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
994
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.1", type: FileInput, isStandalone: true, selector: "p-file, p-fileinput, p-file-input", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, avatarShape: { classPropertyName: "avatarShape", publicName: "avatarShape", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, capture: { classPropertyName: "capture", publicName: "capture", isSignal: true, isRequired: false, transformFunction: null }, directory: { classPropertyName: "directory", publicName: "directory", isSignal: true, isRequired: false, transformFunction: null }, maxFileSize: { classPropertyName: "maxFileSize", publicName: "maxFileSize", isSignal: true, isRequired: false, transformFunction: null }, minFileSize: { classPropertyName: "minFileSize", publicName: "minFileSize", isSignal: true, isRequired: false, transformFunction: null }, maxFiles: { classPropertyName: "maxFiles", publicName: "maxFiles", isSignal: true, isRequired: false, transformFunction: null }, maxTotalSize: { classPropertyName: "maxTotalSize", publicName: "maxTotalSize", isSignal: true, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: false, transformFunction: null }, method: { classPropertyName: "method", publicName: "method", isSignal: true, isRequired: false, transformFunction: null }, headers: { classPropertyName: "headers", publicName: "headers", isSignal: true, isRequired: false, transformFunction: null }, withCredentials: { classPropertyName: "withCredentials", publicName: "withCredentials", isSignal: true, isRequired: false, transformFunction: null }, fieldName: { classPropertyName: "fieldName", publicName: "fieldName", isSignal: true, isRequired: false, transformFunction: null }, uploadHandler: { classPropertyName: "uploadHandler", publicName: "uploadHandler", isSignal: true, isRequired: false, transformFunction: null }, auto: { classPropertyName: "auto", publicName: "auto", isSignal: true, isRequired: false, transformFunction: null }, concurrency: { classPropertyName: "concurrency", publicName: "concurrency", isSignal: true, isRequired: false, transformFunction: null }, existing: { classPropertyName: "existing", publicName: "existing", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null }, showSummary: { classPropertyName: "showSummary", publicName: "showSummary", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSelect: "onSelect", onRemove: "onRemove", onCancel: "onCancel", onUpload: "onUpload", onError: "onError", onComplete: "onComplete", onRemoveExisting: "onRemoveExisting" }, host: { listeners: { "paste": "onPaste($event)" }, properties: { "class": "cx('root')", "attr.data-p": "dataP()" } }, providers: [FILEINPUT_VALUE_ACCESSOR, FileInputStyle, { provide: PARENT_INSTANCE, useExisting: FileInput }], queries: [{ propertyName: "dropzoneTemplate", first: true, predicate: ["dropzone"], isSignal: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], isSignal: true }], viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], usesInheritance: true, hostDirectives: [{ directive: i1.Bind }], ngImport: i0, template: `
995
+ <input
996
+ #fileInput
997
+ type="file"
998
+ [class]="cx('input')"
999
+ [attr.id]="inputId()"
1000
+ [attr.name]="name()"
1001
+ [attr.accept]="accept()"
1002
+ [attr.capture]="capture()"
1003
+ [attr.webkitdirectory]="directory() ? '' : undefined"
1004
+ [multiple]="isMultiple()"
1005
+ [disabled]="$disabled()"
1006
+ tabindex="-1"
1007
+ aria-hidden="true"
1008
+ (change)="onFileInputChange($event)"
1009
+ [pBind]="ptm('input')"
1010
+ />
1011
+
1012
+ @if (variant() === 'avatar') {
1013
+ <div
1014
+ [class]="cx('avatar')"
1015
+ role="button"
1016
+ [attr.tabindex]="$disabled() ? -1 : 0"
1017
+ [attr.aria-label]="ariaLabel() || (avatarSrc() ? labelOf('avatarChange') : labelOf('avatarAdd'))"
1018
+ [attr.aria-labelledby]="ariaLabelledBy()"
1019
+ [attr.aria-disabled]="$disabled()"
1020
+ [attr.aria-invalid]="$invalid() || undefined"
1021
+ (click)="open()"
1022
+ (keydown)="onTriggerKeydown($event)"
1023
+ (dragenter)="onDragEnter($event)"
1024
+ (dragover)="onDragOver($event)"
1025
+ (dragleave)="onDragLeave($event)"
1026
+ (drop)="onDrop($event)"
1027
+ [pBind]="ptm('avatar')"
1028
+ >
1029
+ @if (avatarSrc()) {
1030
+ <img [src]="avatarSrc()" alt="" />
1031
+ } @else {
1032
+ <svg data-p-icon="upload" [class]="cx('avatarIcon')" aria-hidden="true" />
1033
+ }
1034
+ <span [class]="cx('avatarOverlay')" aria-hidden="true">
1035
+ @if (avatarItem()?.status === 'uploading') {
1036
+ {{ avatarItem()!.progress }} %
1037
+ } @else {
1038
+ {{ avatarSrc() ? labelOf('avatarChange') : labelOf('avatarAdd') }}
1039
+ }
1040
+ </span>
1041
+ </div>
1042
+ @if (avatarItem()?.error) {
1043
+ <span [class]="cx('avatarError')">{{ avatarItem()!.error }}</span>
1044
+ }
1045
+ } @else {
1046
+ @if (variant() === 'list') {
1047
+ <div
1048
+ [class]="cx('dropzone')"
1049
+ role="button"
1050
+ [attr.tabindex]="$disabled() ? -1 : 0"
1051
+ [attr.aria-label]="ariaLabel()"
1052
+ [attr.aria-labelledby]="ariaLabelledBy()"
1053
+ [attr.aria-describedby]="hint() ? hintId : undefined"
1054
+ [attr.aria-disabled]="$disabled()"
1055
+ [attr.aria-invalid]="$invalid() || undefined"
1056
+ (click)="open()"
1057
+ (keydown)="onTriggerKeydown($event)"
1058
+ (dragenter)="onDragEnter($event)"
1059
+ (dragover)="onDragOver($event)"
1060
+ (dragleave)="onDragLeave($event)"
1061
+ (drop)="onDrop($event)"
1062
+ [pBind]="ptm('dropzone')"
1063
+ >
1064
+ @if (dropzoneTemplate()) {
1065
+ <ng-container *ngTemplateOutlet="dropzoneTemplate()!; context: { open: openFn, active: dragActive() }" />
1066
+ } @else {
1067
+ <svg data-p-icon="upload" [class]="cx('dropzoneIcon')" aria-hidden="true" [pBind]="ptm('dropzoneIcon')" />
1068
+ <span [class]="cx('label')" [pBind]="ptm('label')"
1069
+ >{{ labelOf('dropzone') }} <span [class]="cx('browse')">{{ labelOf('browse') }}</span></span
1070
+ >
1071
+ @if (hint()) {
1072
+ <span [class]="cx('hint')" [attr.id]="hintId" [pBind]="ptm('hint')">{{ hint() }}</span>
1073
+ }
1074
+ }
1075
+ </div>
1076
+ }
1077
+
1078
+ @if (showSummary() && summary(); as s) {
1079
+ <div [class]="cx('summary')" [pBind]="ptm('summary')">
1080
+ <span>{{ s.text }}</span>
1081
+ <div [class]="cx('progress')" role="progressbar" aria-valuemin="0" aria-valuemax="100" [attr.aria-valuenow]="s.percent" [attr.aria-label]="s.text" [pBind]="ptm('progress')">
1082
+ <div [class]="cx('progressValue')" [style.width.%]="s.percent"></div>
1083
+ </div>
1084
+ </div>
1085
+ }
1086
+
1087
+ @if (variant() === 'list') {
1088
+ @if (displayItems().length) {
1089
+ <ul [class]="cx('list')" [attr.aria-label]="labelOf('listLabel')" [pBind]="ptm('list')">
1090
+ @for (item of displayItems(); track item.id) {
1091
+ @if (itemTemplate()) {
1092
+ <li [class]="cx('item', { item })" [pBind]="ptm('item')">
1093
+ <ng-container *ngTemplateOutlet="itemTemplate()!; context: itemContext(item)" />
1094
+ </li>
1095
+ } @else {
1096
+ <li [class]="cx('item', { item })" [attr.data-p-status]="item.status" [pBind]="ptm('item')">
1097
+ <div [class]="cx('thumbnail')" aria-hidden="true" [pBind]="ptm('thumbnail')">
1098
+ @if (thumbnailOf(item); as src) {
1099
+ <img [src]="src" alt="" />
1100
+ } @else {
1101
+ {{ extensionOf(item) }}
1102
+ }
1103
+ </div>
1104
+ <div [class]="cx('info')">
1105
+ <span [class]="cx('name')" [attr.title]="item.path + item.name" [pBind]="ptm('name')">
1106
+ @if (item.path) {
1107
+ <span [class]="cx('path')">{{ item.path }}</span>
1108
+ }
1109
+ {{ item.name }}</span
1110
+ >
1111
+ <div [class]="cx('meta')" [pBind]="ptm('meta')">
1112
+ @if (item.status === 'uploading') {
1113
+ <span>{{ item.progress }} %</span>
1114
+ <div [class]="cx('progress')" role="progressbar" aria-valuemin="0" aria-valuemax="100" [attr.aria-valuenow]="item.progress" [attr.aria-label]="item.name" [pBind]="ptm('progress')">
1115
+ <div [class]="cx('progressValue')" [style.width.%]="item.progress"></div>
1116
+ </div>
1117
+ } @else if (item.status === 'invalid' || item.status === 'failed') {
1118
+ <span [class]="cx('status', { item })">{{ item.error }}</span>
1119
+ } @else {
1120
+ @if (item.size !== undefined) {
1121
+ <span>{{ formatSize(item.size) }}</span>
1122
+ }
1123
+ @if (statusLabel(item); as label) {
1124
+ <span [class]="cx('status', { item })">· {{ label }}</span>
1125
+ }
1126
+ }
1127
+ </div>
1128
+ </div>
1129
+ <div [class]="cx('actions')" [pBind]="ptm('actions')">
1130
+ <ng-container *ngTemplateOutlet="actionsTemplate; context: { $implicit: item }" />
1131
+ </div>
1132
+ </li>
1133
+ }
1134
+ }
1135
+ </ul>
1136
+ }
1137
+ } @else {
1138
+ <ul [class]="cx('grid')" [attr.aria-label]="labelOf('listLabel')" [pBind]="ptm('grid')">
1139
+ @for (item of displayItems(); track item.id; let index = $index) {
1140
+ <li [class]="cx('tile', { item })" [attr.data-p-status]="item.status" [pBind]="ptm('tile')">
1141
+ @if (thumbnailOf(item); as src) {
1142
+ <img [src]="src" [attr.alt]="item.name" />
1143
+ }
1144
+ @if (item.status === 'uploading') {
1145
+ <div [class]="cx('tileOverlay')">
1146
+ <span>{{ item.progress }} %</span>
1147
+ <div [class]="cx('progress')" role="progressbar" aria-valuemin="0" aria-valuemax="100" [attr.aria-valuenow]="item.progress" [attr.aria-label]="item.name">
1148
+ <div [class]="cx('progressValue')" [style.width.%]="item.progress"></div>
1149
+ </div>
1150
+ </div>
1151
+ } @else if (item.status === 'queued') {
1152
+ <div [class]="cx('tileOverlay')">
1153
+ <span>{{ labelOf('queued') }}</span>
1154
+ </div>
1155
+ } @else if (item.status === 'invalid' || item.status === 'failed' || item.status === 'canceled') {
1156
+ <div [class]="cx('tileOverlay')">
1157
+ <span>{{ item.error || labelOf('canceled') }}</span>
1158
+ </div>
1159
+ }
1160
+ @if (item.id === coverId()) {
1161
+ <span [class]="cx('cover')">{{ labelOf('cover') }}</span>
1162
+ }
1163
+ @if (item.status === 'uploaded') {
1164
+ <span [class]="cx('tileDone')" [attr.aria-label]="labelOf('uploaded')" role="img"><svg data-p-icon="check" aria-hidden="true" /></span>
1165
+ }
1166
+ <div [class]="cx('tileActions')" [pBind]="ptm('actions')">
1167
+ <ng-container *ngTemplateOutlet="actionsTemplate; context: { $implicit: item }" />
1168
+ </div>
1169
+ </li>
1170
+ }
1171
+ @if (canAdd()) {
1172
+ <li>
1173
+ <button
1174
+ type="button"
1175
+ [class]="cx('add')"
1176
+ [attr.aria-label]="ariaLabel()"
1177
+ [attr.aria-labelledby]="ariaLabelledBy()"
1178
+ [attr.aria-invalid]="$invalid() || undefined"
1179
+ (click)="open()"
1180
+ (dragenter)="onDragEnter($event)"
1181
+ (dragover)="onDragOver($event)"
1182
+ (dragleave)="onDragLeave($event)"
1183
+ (drop)="onDrop($event)"
1184
+ [pBind]="ptm('add')"
1185
+ >
1186
+ <svg data-p-icon="upload" [class]="cx('dropzoneIcon')" aria-hidden="true" />
1187
+ {{ labelOf('add') }}
1188
+ </button>
1189
+ </li>
1190
+ }
1191
+ </ul>
1192
+ }
1193
+ }
1194
+
1195
+ <ng-template #actionsTemplate let-item>
1196
+ @switch (item.status) {
1197
+ @case ('uploading') {
1198
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('cancel') + ' ' + item.name" [attr.title]="labelOf('cancel')" (click)="cancel(item)" [pBind]="ptm('action')">
1199
+ <svg data-p-icon="ban" [class]="cx('actionIcon')" aria-hidden="true" />
1200
+ </button>
1201
+ }
1202
+ @case ('existing') {
1203
+ @if (item.existing?.url) {
1204
+ <a [class]="cx('action')" [attr.href]="item.existing.url" target="_blank" rel="noopener" download [attr.aria-label]="labelOf('download') + ' ' + item.name" [attr.title]="labelOf('download')" [pBind]="ptm('action')">
1205
+ <svg data-p-icon="arrow-down" [class]="cx('actionIcon')" aria-hidden="true" />
1206
+ </a>
1207
+ }
1208
+ @if (!$disabled()) {
1209
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('delete') + ' ' + item.name" [attr.title]="labelOf('delete')" (click)="remove(item)" [pBind]="ptm('action')">
1210
+ <svg data-p-icon="trash" [class]="cx('actionIcon')" aria-hidden="true" />
1211
+ </button>
1212
+ }
1213
+ }
1214
+ @default {
1215
+ @if (!$disabled()) {
1216
+ @if (item.status === 'failed' || item.status === 'canceled') {
1217
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('retry') + ' ' + item.name" [attr.title]="labelOf('retry')" (click)="retry(item)" [pBind]="ptm('action')">
1218
+ <svg data-p-icon="refresh" [class]="cx('actionIcon')" aria-hidden="true" />
1219
+ </button>
1220
+ }
1221
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('remove') + ' ' + item.name" [attr.title]="labelOf('remove')" (click)="remove(item)" [pBind]="ptm('action')">
1222
+ <svg data-p-icon="times" [class]="cx('actionIcon')" aria-hidden="true" />
1223
+ </button>
1224
+ }
1225
+ }
1226
+ }
1227
+ </ng-template>
1228
+
1229
+ <span class="p-hidden-accessible" aria-live="polite">{{ announcement() }}</span>
1230
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: SharedModule }, { kind: "ngmodule", type: BindModule }, { kind: "directive", type: i1.Bind, selector: "[pBind]", inputs: ["pBind"] }, { kind: "component", type: UploadIcon, selector: "[data-p-icon=\"upload\"]" }, { kind: "component", type: TimesIcon, selector: "[data-p-icon=\"times\"]" }, { kind: "component", type: RefreshIcon, selector: "[data-p-icon=\"refresh\"]" }, { kind: "component", type: TrashIcon, selector: "[data-p-icon=\"trash\"]" }, { kind: "component", type: ArrowDownIcon, selector: "[data-p-icon=\"arrow-down\"]" }, { kind: "component", type: BanIcon, selector: "[data-p-icon=\"ban\"]" }, { kind: "component", type: CheckIcon, selector: "[data-p-icon=\"check\"]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1231
+ }
1232
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInput, decorators: [{
1233
+ type: Component,
1234
+ args: [{
1235
+ selector: 'p-file, p-fileinput, p-file-input',
1236
+ standalone: true,
1237
+ imports: [NgTemplateOutlet, SharedModule, BindModule, UploadIcon, TimesIcon, RefreshIcon, TrashIcon, ArrowDownIcon, BanIcon, CheckIcon],
1238
+ template: `
1239
+ <input
1240
+ #fileInput
1241
+ type="file"
1242
+ [class]="cx('input')"
1243
+ [attr.id]="inputId()"
1244
+ [attr.name]="name()"
1245
+ [attr.accept]="accept()"
1246
+ [attr.capture]="capture()"
1247
+ [attr.webkitdirectory]="directory() ? '' : undefined"
1248
+ [multiple]="isMultiple()"
1249
+ [disabled]="$disabled()"
1250
+ tabindex="-1"
1251
+ aria-hidden="true"
1252
+ (change)="onFileInputChange($event)"
1253
+ [pBind]="ptm('input')"
1254
+ />
1255
+
1256
+ @if (variant() === 'avatar') {
1257
+ <div
1258
+ [class]="cx('avatar')"
1259
+ role="button"
1260
+ [attr.tabindex]="$disabled() ? -1 : 0"
1261
+ [attr.aria-label]="ariaLabel() || (avatarSrc() ? labelOf('avatarChange') : labelOf('avatarAdd'))"
1262
+ [attr.aria-labelledby]="ariaLabelledBy()"
1263
+ [attr.aria-disabled]="$disabled()"
1264
+ [attr.aria-invalid]="$invalid() || undefined"
1265
+ (click)="open()"
1266
+ (keydown)="onTriggerKeydown($event)"
1267
+ (dragenter)="onDragEnter($event)"
1268
+ (dragover)="onDragOver($event)"
1269
+ (dragleave)="onDragLeave($event)"
1270
+ (drop)="onDrop($event)"
1271
+ [pBind]="ptm('avatar')"
1272
+ >
1273
+ @if (avatarSrc()) {
1274
+ <img [src]="avatarSrc()" alt="" />
1275
+ } @else {
1276
+ <svg data-p-icon="upload" [class]="cx('avatarIcon')" aria-hidden="true" />
1277
+ }
1278
+ <span [class]="cx('avatarOverlay')" aria-hidden="true">
1279
+ @if (avatarItem()?.status === 'uploading') {
1280
+ {{ avatarItem()!.progress }} %
1281
+ } @else {
1282
+ {{ avatarSrc() ? labelOf('avatarChange') : labelOf('avatarAdd') }}
1283
+ }
1284
+ </span>
1285
+ </div>
1286
+ @if (avatarItem()?.error) {
1287
+ <span [class]="cx('avatarError')">{{ avatarItem()!.error }}</span>
1288
+ }
1289
+ } @else {
1290
+ @if (variant() === 'list') {
1291
+ <div
1292
+ [class]="cx('dropzone')"
1293
+ role="button"
1294
+ [attr.tabindex]="$disabled() ? -1 : 0"
1295
+ [attr.aria-label]="ariaLabel()"
1296
+ [attr.aria-labelledby]="ariaLabelledBy()"
1297
+ [attr.aria-describedby]="hint() ? hintId : undefined"
1298
+ [attr.aria-disabled]="$disabled()"
1299
+ [attr.aria-invalid]="$invalid() || undefined"
1300
+ (click)="open()"
1301
+ (keydown)="onTriggerKeydown($event)"
1302
+ (dragenter)="onDragEnter($event)"
1303
+ (dragover)="onDragOver($event)"
1304
+ (dragleave)="onDragLeave($event)"
1305
+ (drop)="onDrop($event)"
1306
+ [pBind]="ptm('dropzone')"
1307
+ >
1308
+ @if (dropzoneTemplate()) {
1309
+ <ng-container *ngTemplateOutlet="dropzoneTemplate()!; context: { open: openFn, active: dragActive() }" />
1310
+ } @else {
1311
+ <svg data-p-icon="upload" [class]="cx('dropzoneIcon')" aria-hidden="true" [pBind]="ptm('dropzoneIcon')" />
1312
+ <span [class]="cx('label')" [pBind]="ptm('label')"
1313
+ >{{ labelOf('dropzone') }} <span [class]="cx('browse')">{{ labelOf('browse') }}</span></span
1314
+ >
1315
+ @if (hint()) {
1316
+ <span [class]="cx('hint')" [attr.id]="hintId" [pBind]="ptm('hint')">{{ hint() }}</span>
1317
+ }
1318
+ }
1319
+ </div>
1320
+ }
1321
+
1322
+ @if (showSummary() && summary(); as s) {
1323
+ <div [class]="cx('summary')" [pBind]="ptm('summary')">
1324
+ <span>{{ s.text }}</span>
1325
+ <div [class]="cx('progress')" role="progressbar" aria-valuemin="0" aria-valuemax="100" [attr.aria-valuenow]="s.percent" [attr.aria-label]="s.text" [pBind]="ptm('progress')">
1326
+ <div [class]="cx('progressValue')" [style.width.%]="s.percent"></div>
1327
+ </div>
1328
+ </div>
1329
+ }
1330
+
1331
+ @if (variant() === 'list') {
1332
+ @if (displayItems().length) {
1333
+ <ul [class]="cx('list')" [attr.aria-label]="labelOf('listLabel')" [pBind]="ptm('list')">
1334
+ @for (item of displayItems(); track item.id) {
1335
+ @if (itemTemplate()) {
1336
+ <li [class]="cx('item', { item })" [pBind]="ptm('item')">
1337
+ <ng-container *ngTemplateOutlet="itemTemplate()!; context: itemContext(item)" />
1338
+ </li>
1339
+ } @else {
1340
+ <li [class]="cx('item', { item })" [attr.data-p-status]="item.status" [pBind]="ptm('item')">
1341
+ <div [class]="cx('thumbnail')" aria-hidden="true" [pBind]="ptm('thumbnail')">
1342
+ @if (thumbnailOf(item); as src) {
1343
+ <img [src]="src" alt="" />
1344
+ } @else {
1345
+ {{ extensionOf(item) }}
1346
+ }
1347
+ </div>
1348
+ <div [class]="cx('info')">
1349
+ <span [class]="cx('name')" [attr.title]="item.path + item.name" [pBind]="ptm('name')">
1350
+ @if (item.path) {
1351
+ <span [class]="cx('path')">{{ item.path }}</span>
1352
+ }
1353
+ {{ item.name }}</span
1354
+ >
1355
+ <div [class]="cx('meta')" [pBind]="ptm('meta')">
1356
+ @if (item.status === 'uploading') {
1357
+ <span>{{ item.progress }} %</span>
1358
+ <div [class]="cx('progress')" role="progressbar" aria-valuemin="0" aria-valuemax="100" [attr.aria-valuenow]="item.progress" [attr.aria-label]="item.name" [pBind]="ptm('progress')">
1359
+ <div [class]="cx('progressValue')" [style.width.%]="item.progress"></div>
1360
+ </div>
1361
+ } @else if (item.status === 'invalid' || item.status === 'failed') {
1362
+ <span [class]="cx('status', { item })">{{ item.error }}</span>
1363
+ } @else {
1364
+ @if (item.size !== undefined) {
1365
+ <span>{{ formatSize(item.size) }}</span>
1366
+ }
1367
+ @if (statusLabel(item); as label) {
1368
+ <span [class]="cx('status', { item })">· {{ label }}</span>
1369
+ }
1370
+ }
1371
+ </div>
1372
+ </div>
1373
+ <div [class]="cx('actions')" [pBind]="ptm('actions')">
1374
+ <ng-container *ngTemplateOutlet="actionsTemplate; context: { $implicit: item }" />
1375
+ </div>
1376
+ </li>
1377
+ }
1378
+ }
1379
+ </ul>
1380
+ }
1381
+ } @else {
1382
+ <ul [class]="cx('grid')" [attr.aria-label]="labelOf('listLabel')" [pBind]="ptm('grid')">
1383
+ @for (item of displayItems(); track item.id; let index = $index) {
1384
+ <li [class]="cx('tile', { item })" [attr.data-p-status]="item.status" [pBind]="ptm('tile')">
1385
+ @if (thumbnailOf(item); as src) {
1386
+ <img [src]="src" [attr.alt]="item.name" />
1387
+ }
1388
+ @if (item.status === 'uploading') {
1389
+ <div [class]="cx('tileOverlay')">
1390
+ <span>{{ item.progress }} %</span>
1391
+ <div [class]="cx('progress')" role="progressbar" aria-valuemin="0" aria-valuemax="100" [attr.aria-valuenow]="item.progress" [attr.aria-label]="item.name">
1392
+ <div [class]="cx('progressValue')" [style.width.%]="item.progress"></div>
1393
+ </div>
1394
+ </div>
1395
+ } @else if (item.status === 'queued') {
1396
+ <div [class]="cx('tileOverlay')">
1397
+ <span>{{ labelOf('queued') }}</span>
1398
+ </div>
1399
+ } @else if (item.status === 'invalid' || item.status === 'failed' || item.status === 'canceled') {
1400
+ <div [class]="cx('tileOverlay')">
1401
+ <span>{{ item.error || labelOf('canceled') }}</span>
1402
+ </div>
1403
+ }
1404
+ @if (item.id === coverId()) {
1405
+ <span [class]="cx('cover')">{{ labelOf('cover') }}</span>
1406
+ }
1407
+ @if (item.status === 'uploaded') {
1408
+ <span [class]="cx('tileDone')" [attr.aria-label]="labelOf('uploaded')" role="img"><svg data-p-icon="check" aria-hidden="true" /></span>
1409
+ }
1410
+ <div [class]="cx('tileActions')" [pBind]="ptm('actions')">
1411
+ <ng-container *ngTemplateOutlet="actionsTemplate; context: { $implicit: item }" />
1412
+ </div>
1413
+ </li>
1414
+ }
1415
+ @if (canAdd()) {
1416
+ <li>
1417
+ <button
1418
+ type="button"
1419
+ [class]="cx('add')"
1420
+ [attr.aria-label]="ariaLabel()"
1421
+ [attr.aria-labelledby]="ariaLabelledBy()"
1422
+ [attr.aria-invalid]="$invalid() || undefined"
1423
+ (click)="open()"
1424
+ (dragenter)="onDragEnter($event)"
1425
+ (dragover)="onDragOver($event)"
1426
+ (dragleave)="onDragLeave($event)"
1427
+ (drop)="onDrop($event)"
1428
+ [pBind]="ptm('add')"
1429
+ >
1430
+ <svg data-p-icon="upload" [class]="cx('dropzoneIcon')" aria-hidden="true" />
1431
+ {{ labelOf('add') }}
1432
+ </button>
1433
+ </li>
1434
+ }
1435
+ </ul>
1436
+ }
1437
+ }
1438
+
1439
+ <ng-template #actionsTemplate let-item>
1440
+ @switch (item.status) {
1441
+ @case ('uploading') {
1442
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('cancel') + ' ' + item.name" [attr.title]="labelOf('cancel')" (click)="cancel(item)" [pBind]="ptm('action')">
1443
+ <svg data-p-icon="ban" [class]="cx('actionIcon')" aria-hidden="true" />
1444
+ </button>
1445
+ }
1446
+ @case ('existing') {
1447
+ @if (item.existing?.url) {
1448
+ <a [class]="cx('action')" [attr.href]="item.existing.url" target="_blank" rel="noopener" download [attr.aria-label]="labelOf('download') + ' ' + item.name" [attr.title]="labelOf('download')" [pBind]="ptm('action')">
1449
+ <svg data-p-icon="arrow-down" [class]="cx('actionIcon')" aria-hidden="true" />
1450
+ </a>
1451
+ }
1452
+ @if (!$disabled()) {
1453
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('delete') + ' ' + item.name" [attr.title]="labelOf('delete')" (click)="remove(item)" [pBind]="ptm('action')">
1454
+ <svg data-p-icon="trash" [class]="cx('actionIcon')" aria-hidden="true" />
1455
+ </button>
1456
+ }
1457
+ }
1458
+ @default {
1459
+ @if (!$disabled()) {
1460
+ @if (item.status === 'failed' || item.status === 'canceled') {
1461
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('retry') + ' ' + item.name" [attr.title]="labelOf('retry')" (click)="retry(item)" [pBind]="ptm('action')">
1462
+ <svg data-p-icon="refresh" [class]="cx('actionIcon')" aria-hidden="true" />
1463
+ </button>
1464
+ }
1465
+ <button type="button" [class]="cx('action')" [attr.aria-label]="labelOf('remove') + ' ' + item.name" [attr.title]="labelOf('remove')" (click)="remove(item)" [pBind]="ptm('action')">
1466
+ <svg data-p-icon="times" [class]="cx('actionIcon')" aria-hidden="true" />
1467
+ </button>
1468
+ }
1469
+ }
1470
+ }
1471
+ </ng-template>
1472
+
1473
+ <span class="p-hidden-accessible" aria-live="polite">{{ announcement() }}</span>
1474
+ `,
1475
+ providers: [FILEINPUT_VALUE_ACCESSOR, FileInputStyle, { provide: PARENT_INSTANCE, useExisting: FileInput }],
1476
+ changeDetection: ChangeDetectionStrategy.OnPush,
1477
+ encapsulation: ViewEncapsulation.None,
1478
+ host: {
1479
+ '[class]': "cx('root')",
1480
+ '[attr.data-p]': 'dataP()',
1481
+ '(paste)': 'onPaste($event)'
1482
+ },
1483
+ hostDirectives: [Bind]
1484
+ }]
1485
+ }], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], avatarShape: [{ type: i0.Input, args: [{ isSignal: true, alias: "avatarShape", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], capture: [{ type: i0.Input, args: [{ isSignal: true, alias: "capture", required: false }] }], directory: [{ type: i0.Input, args: [{ isSignal: true, alias: "directory", required: false }] }], maxFileSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFileSize", required: false }] }], minFileSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "minFileSize", required: false }] }], maxFiles: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFiles", required: false }] }], maxTotalSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxTotalSize", required: false }] }], url: [{ type: i0.Input, args: [{ isSignal: true, alias: "url", required: false }] }], method: [{ type: i0.Input, args: [{ isSignal: true, alias: "method", required: false }] }], headers: [{ type: i0.Input, args: [{ isSignal: true, alias: "headers", required: false }] }], withCredentials: [{ type: i0.Input, args: [{ isSignal: true, alias: "withCredentials", required: false }] }], fieldName: [{ type: i0.Input, args: [{ isSignal: true, alias: "fieldName", required: false }] }], uploadHandler: [{ type: i0.Input, args: [{ isSignal: true, alias: "uploadHandler", required: false }] }], auto: [{ type: i0.Input, args: [{ isSignal: true, alias: "auto", required: false }] }], concurrency: [{ type: i0.Input, args: [{ isSignal: true, alias: "concurrency", required: false }] }], existing: [{ type: i0.Input, args: [{ isSignal: true, alias: "existing", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: false }] }], showSummary: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSummary", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledBy", required: false }] }], onSelect: [{ type: i0.Output, args: ["onSelect"] }], onRemove: [{ type: i0.Output, args: ["onRemove"] }], onCancel: [{ type: i0.Output, args: ["onCancel"] }], onUpload: [{ type: i0.Output, args: ["onUpload"] }], onError: [{ type: i0.Output, args: ["onError"] }], onComplete: [{ type: i0.Output, args: ["onComplete"] }], onRemoveExisting: [{ type: i0.Output, args: ["onRemoveExisting"] }], dropzoneTemplate: [{ type: i0.ContentChild, args: ['dropzone', { ...{ descendants: false }, isSignal: true }] }], itemTemplate: [{ type: i0.ContentChild, args: ['item', { ...{ descendants: false }, isSignal: true }] }], fileInput: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }] } });
1486
+ class FileInputModule {
1487
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1488
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.1", ngImport: i0, type: FileInputModule, imports: [FileInput, SharedModule], exports: [FileInput, SharedModule] });
1489
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInputModule, imports: [FileInput, SharedModule, SharedModule] });
1490
+ }
1491
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: FileInputModule, decorators: [{
1492
+ type: NgModule,
1493
+ args: [{
1494
+ imports: [FileInput, SharedModule],
1495
+ exports: [FileInput, SharedModule]
1496
+ }]
1497
+ }] });
1498
+
1499
+ /**
1500
+ * Generated bundle index. Do not edit.
1501
+ */
1502
+
1503
+ export { FILEINPUT_DEFAULT_LABELS, FILEINPUT_VALUE_ACCESSOR, FileInput, FileInputClasses, FileInputModule, FileInputStyle };
1504
+ //# sourceMappingURL=exhaustive-ui-core-fileinput.mjs.map