@exhaustive-ui/core 22.1.0 → 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,429 @@
1
+ import { TemplateRef } from '@angular/core';
2
+ import { PassThrough, PassThroughOption } from '@exhaustive-ui/core/api';
3
+
4
+ /**
5
+ * Custom passthrough(pt) options.
6
+ * @template I Type of instance.
7
+ *
8
+ * @see {@link FileInput.pt}
9
+ * @group Interface
10
+ */
11
+ interface FileInputPassThroughOptions<I = unknown> {
12
+ /**
13
+ * Used to pass attributes to the root's DOM element.
14
+ */
15
+ root?: PassThroughOption<HTMLElement, I>;
16
+ /**
17
+ * Used to pass attributes to the hidden file input's DOM element.
18
+ */
19
+ input?: PassThroughOption<HTMLInputElement, I>;
20
+ /**
21
+ * Used to pass attributes to the dropzone's DOM element.
22
+ */
23
+ dropzone?: PassThroughOption<HTMLDivElement, I>;
24
+ /**
25
+ * Used to pass attributes to the dropzone icon's DOM element.
26
+ */
27
+ dropzoneIcon?: PassThroughOption<SVGElement, I>;
28
+ /**
29
+ * Used to pass attributes to the dropzone label's DOM element.
30
+ */
31
+ label?: PassThroughOption<HTMLSpanElement, I>;
32
+ /**
33
+ * Used to pass attributes to the hint's DOM element.
34
+ */
35
+ hint?: PassThroughOption<HTMLSpanElement, I>;
36
+ /**
37
+ * Used to pass attributes to the upload summary's DOM element.
38
+ */
39
+ summary?: PassThroughOption<HTMLDivElement, I>;
40
+ /**
41
+ * Used to pass attributes to the file list's DOM element.
42
+ */
43
+ list?: PassThroughOption<HTMLUListElement, I>;
44
+ /**
45
+ * Used to pass attributes to a file row's DOM element.
46
+ */
47
+ item?: PassThroughOption<HTMLLIElement, I>;
48
+ /**
49
+ * Used to pass attributes to a thumbnail's DOM element.
50
+ */
51
+ thumbnail?: PassThroughOption<HTMLDivElement, I>;
52
+ /**
53
+ * Used to pass attributes to a file name's DOM element.
54
+ */
55
+ name?: PassThroughOption<HTMLSpanElement, I>;
56
+ /**
57
+ * Used to pass attributes to the size and status line's DOM element.
58
+ */
59
+ meta?: PassThroughOption<HTMLDivElement, I>;
60
+ /**
61
+ * Used to pass attributes to a progress bar's DOM element.
62
+ */
63
+ progress?: PassThroughOption<HTMLDivElement, I>;
64
+ /**
65
+ * Used to pass attributes to the actions container of a row or tile.
66
+ */
67
+ actions?: PassThroughOption<HTMLDivElement, I>;
68
+ /**
69
+ * Used to pass attributes to an action button's DOM element.
70
+ */
71
+ action?: PassThroughOption<HTMLButtonElement | HTMLAnchorElement, I>;
72
+ /**
73
+ * Used to pass attributes to the image grid's DOM element.
74
+ */
75
+ grid?: PassThroughOption<HTMLUListElement, I>;
76
+ /**
77
+ * Used to pass attributes to an image tile's DOM element.
78
+ */
79
+ tile?: PassThroughOption<HTMLLIElement, I>;
80
+ /**
81
+ * Used to pass attributes to the add tile's DOM element.
82
+ */
83
+ add?: PassThroughOption<HTMLButtonElement, I>;
84
+ /**
85
+ * Used to pass attributes to the avatar's DOM element.
86
+ */
87
+ avatar?: PassThroughOption<HTMLDivElement, I>;
88
+ }
89
+ /**
90
+ * Defines valid pass-through options in FileInput component.
91
+ * @see {@link FileInputPassThroughOptions}
92
+ *
93
+ * @template I Type of instance.
94
+ */
95
+ type FileInputPassThrough<I = unknown> = PassThrough<I, FileInputPassThroughOptions<I>>;
96
+ /**
97
+ * Layout of the component.
98
+ * - `list`: a dropzone above a list of files.
99
+ * - `images`: a grid of square thumbnails with an add tile.
100
+ * - `avatar`: a single clickable image, for a profile picture or a logo.
101
+ * @group Types
102
+ */
103
+ type FileInputVariant = 'list' | 'images' | 'avatar';
104
+ /**
105
+ * Status of a file.
106
+ * - `selected`: accepted, no upload configured.
107
+ * - `queued`: waiting for a free upload slot.
108
+ * - `uploading`: being uploaded.
109
+ * - `uploaded`: uploaded.
110
+ * - `failed`: the upload failed; it can be retried.
111
+ * - `canceled`: the upload was canceled; it can be retried.
112
+ * - `invalid`: rejected by a validation rule; it is not part of the value.
113
+ * - `existing`: a file already stored on the server, passed through the `existing` input.
114
+ * @group Types
115
+ */
116
+ type FileInputStatus = 'selected' | 'queued' | 'uploading' | 'uploaded' | 'failed' | 'canceled' | 'invalid' | 'existing';
117
+ /**
118
+ * Validation rule a file broke, or `upload` when the upload failed.
119
+ * @group Types
120
+ */
121
+ type FileInputErrorCode = 'type' | 'maxFileSize' | 'minFileSize' | 'maxFiles' | 'maxTotalSize' | 'upload';
122
+ /**
123
+ * A file shown by the component.
124
+ * @group Interface
125
+ */
126
+ interface FileInputItem {
127
+ /**
128
+ * Unique identifier of the item.
129
+ */
130
+ id: string;
131
+ /**
132
+ * The selected file. Undefined for an existing file.
133
+ */
134
+ file?: File;
135
+ /**
136
+ * File name.
137
+ */
138
+ name: string;
139
+ /**
140
+ * Folder of the file relative to a dropped folder, ending with a slash. Empty when the file was not in a folder.
141
+ */
142
+ path: string;
143
+ /**
144
+ * Size in bytes, when known.
145
+ */
146
+ size?: number;
147
+ /**
148
+ * MIME type, when known.
149
+ */
150
+ type: string;
151
+ /**
152
+ * Current status.
153
+ */
154
+ status: FileInputStatus;
155
+ /**
156
+ * Upload progress, from 0 to 100.
157
+ */
158
+ progress: number;
159
+ /**
160
+ * Rule the file broke, or `upload` when the upload failed.
161
+ */
162
+ errorCode?: FileInputErrorCode;
163
+ /**
164
+ * Message shown for the error.
165
+ */
166
+ error?: string;
167
+ /**
168
+ * Response returned by the upload.
169
+ */
170
+ response?: any;
171
+ /**
172
+ * URL of the image preview, for images.
173
+ */
174
+ previewUrl?: string;
175
+ /**
176
+ * The existing file this item stands for, when status is `existing`.
177
+ */
178
+ existing?: FileInputExistingFile;
179
+ }
180
+ /**
181
+ * A file already stored on the server.
182
+ * @group Interface
183
+ */
184
+ interface FileInputExistingFile {
185
+ /**
186
+ * Identifier of the file on the server.
187
+ */
188
+ id?: any;
189
+ /**
190
+ * File name.
191
+ */
192
+ name: string;
193
+ /**
194
+ * Size in bytes.
195
+ */
196
+ size?: number;
197
+ /**
198
+ * MIME type.
199
+ */
200
+ type?: string;
201
+ /**
202
+ * Download URL. When set, a download button is shown.
203
+ */
204
+ url?: string;
205
+ /**
206
+ * Thumbnail URL, for images. Falls back to `url` for image types.
207
+ */
208
+ thumbnail?: string;
209
+ }
210
+ /**
211
+ * Context passed to an upload handler.
212
+ * @group Interface
213
+ */
214
+ interface FileInputUploadContext {
215
+ /**
216
+ * Signal aborted when the user cancels the upload or removes the file.
217
+ */
218
+ signal: AbortSignal;
219
+ /**
220
+ * Reports the progress of the upload, from 0 to 100.
221
+ */
222
+ progress: (percent: number) => void;
223
+ /**
224
+ * The item being uploaded.
225
+ */
226
+ item: FileInputItem;
227
+ }
228
+ /**
229
+ * Function that uploads one file. Resolve with the server response, reject to mark the upload as failed.
230
+ * @group Types
231
+ */
232
+ type FileInputUploadHandler = (file: File, context: FileInputUploadContext) => Promise<any>;
233
+ /**
234
+ * Texts of the component. Placeholders such as `{0}` are replaced with values.
235
+ * @group Interface
236
+ */
237
+ interface FileInputLabels {
238
+ /** Dropzone text before the browse link. */
239
+ dropzone: string;
240
+ /** Browse link of the dropzone. */
241
+ browse: string;
242
+ /** Add tile of the images variant. */
243
+ add: string;
244
+ /** Avatar overlay when there is no image. */
245
+ avatarAdd: string;
246
+ /** Avatar overlay when there is an image. */
247
+ avatarChange: string;
248
+ /** Badge of the first image in the images variant. */
249
+ cover: string;
250
+ /** Remove button. */
251
+ remove: string;
252
+ /** Cancel button of an upload. */
253
+ cancel: string;
254
+ /** Retry button of a failed or canceled upload. */
255
+ retry: string;
256
+ /** Download button of an existing file. */
257
+ download: string;
258
+ /** Delete button of an existing file. */
259
+ delete: string;
260
+ /** Status of a queued file. */
261
+ queued: string;
262
+ /** Status of an uploaded file. */
263
+ uploaded: string;
264
+ /** Status of a canceled upload. */
265
+ canceled: string;
266
+ /** Summary of the uploads: `{0}` uploaded files, `{1}` files, `{2}` uploaded size, `{3}` total size. */
267
+ summary: string;
268
+ /** Error of a file type that is not accepted. */
269
+ typeError: string;
270
+ /** Error of a file that is too large: `{0}` file size, `{1}` maximum. */
271
+ maxFileSizeError: string;
272
+ /** Error of a file that is too small: `{0}` file size, `{1}` minimum. */
273
+ minFileSizeError: string;
274
+ /** Error when the file limit is reached: `{0}` limit. */
275
+ maxFilesError: string;
276
+ /** Error when the total size limit is exceeded: `{0}` limit. */
277
+ maxTotalSizeError: string;
278
+ /** Error of a failed upload. */
279
+ uploadError: string;
280
+ /** Announcement when files are added: `{0}` count. */
281
+ addedMessage: string;
282
+ /** Announcement when files are rejected: `{0}` count. */
283
+ rejectedMessage: string;
284
+ /** Announcement when a file is uploaded: `{0}` name. */
285
+ uploadedMessage: string;
286
+ /** Announcement when an upload fails: `{0}` name. */
287
+ failedMessage: string;
288
+ /** Announcement when a file is removed: `{0}` name. */
289
+ removedMessage: string;
290
+ /** Accessible label of the file list. */
291
+ listLabel: string;
292
+ }
293
+ /**
294
+ * Custom select event.
295
+ * @see {@link FileInput.onSelect}
296
+ * @group Events
297
+ */
298
+ interface FileInputSelectEvent {
299
+ /**
300
+ * Browser event.
301
+ */
302
+ originalEvent?: Event;
303
+ /**
304
+ * Items added, including the invalid ones.
305
+ */
306
+ items: FileInputItem[];
307
+ }
308
+ /**
309
+ * Custom item event.
310
+ * @see {@link FileInput.onRemove}
311
+ * @see {@link FileInput.onCancel}
312
+ * @group Events
313
+ */
314
+ interface FileInputItemEvent {
315
+ /**
316
+ * The item.
317
+ */
318
+ item: FileInputItem;
319
+ }
320
+ /**
321
+ * Custom upload event.
322
+ * @see {@link FileInput.onUpload}
323
+ * @group Events
324
+ */
325
+ interface FileInputUploadEvent {
326
+ /**
327
+ * The uploaded item.
328
+ */
329
+ item: FileInputItem;
330
+ /**
331
+ * Response of the upload.
332
+ */
333
+ response: any;
334
+ }
335
+ /**
336
+ * Custom error event.
337
+ * @see {@link FileInput.onError}
338
+ * @group Events
339
+ */
340
+ interface FileInputErrorEvent {
341
+ /**
342
+ * The item that failed.
343
+ */
344
+ item: FileInputItem;
345
+ /**
346
+ * The error raised by the upload.
347
+ */
348
+ error: any;
349
+ }
350
+ /**
351
+ * Custom complete event, emitted when the last upload of a batch ends.
352
+ * @see {@link FileInput.onComplete}
353
+ * @group Events
354
+ */
355
+ interface FileInputCompleteEvent {
356
+ /**
357
+ * Uploaded items.
358
+ */
359
+ uploaded: FileInputItem[];
360
+ /**
361
+ * Failed items.
362
+ */
363
+ failed: FileInputItem[];
364
+ }
365
+ /**
366
+ * Custom remove existing event.
367
+ * @see {@link FileInput.onRemoveExisting}
368
+ * @group Events
369
+ */
370
+ interface FileInputRemoveExistingEvent {
371
+ /**
372
+ * The existing file the user removed.
373
+ */
374
+ file: FileInputExistingFile;
375
+ }
376
+ /**
377
+ * Context of the dropzone template.
378
+ * @group Interface
379
+ */
380
+ interface FileInputDropzoneTemplateContext {
381
+ /**
382
+ * Opens the file picker.
383
+ */
384
+ open: () => void;
385
+ /**
386
+ * Whether files are dragged over the dropzone.
387
+ */
388
+ active: boolean;
389
+ }
390
+ /**
391
+ * Context of the item template.
392
+ * @group Interface
393
+ */
394
+ interface FileInputItemTemplateContext {
395
+ /**
396
+ * The item.
397
+ */
398
+ $implicit: FileInputItem;
399
+ /**
400
+ * Removes the item.
401
+ */
402
+ remove: () => void;
403
+ /**
404
+ * Retries the upload of the item.
405
+ */
406
+ retry: () => void;
407
+ /**
408
+ * Cancels the upload of the item.
409
+ */
410
+ cancel: () => void;
411
+ }
412
+ /**
413
+ * Defines valid templates in FileInput.
414
+ * @group Templates
415
+ */
416
+ interface FileInputTemplates {
417
+ /**
418
+ * Custom content of the dropzone.
419
+ * @param {FileInputDropzoneTemplateContext} context - dropzone context.
420
+ */
421
+ dropzone(context: FileInputDropzoneTemplateContext): TemplateRef<FileInputDropzoneTemplateContext>;
422
+ /**
423
+ * Custom row of the list variant.
424
+ * @param {FileInputItemTemplateContext} context - item context.
425
+ */
426
+ item(context: FileInputItemTemplateContext): TemplateRef<FileInputItemTemplateContext>;
427
+ }
428
+
429
+ export type { FileInputCompleteEvent, FileInputDropzoneTemplateContext, FileInputErrorCode, FileInputErrorEvent, FileInputExistingFile, FileInputItem, FileInputItemEvent, FileInputItemTemplateContext, FileInputLabels, FileInputPassThrough, FileInputPassThroughOptions, FileInputRemoveExistingEvent, FileInputSelectEvent, FileInputStatus, FileInputTemplates, FileInputUploadContext, FileInputUploadEvent, FileInputUploadHandler, FileInputVariant };