-
-
Notifications
You must be signed in to change notification settings - Fork 833
/
Copy pathindex.d.ts
993 lines (936 loc) · 31.7 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
// Based on definitions by Zach Posten for React-Filepond <https://github.com/zposten>
// Updated by FilePond Contributors
/* Disable no-redundant-jsdoc since @default statements are NOT redundant */
/* tslint:disable:no-redundant-jsdoc */
export { };
export enum FileStatus {
INIT = 1,
IDLE = 2,
PROCESSING_QUEUED = 9,
PROCESSING = 3,
PROCESSING_COMPLETE = 5,
PROCESSING_ERROR = 6,
PROCESSING_REVERT_ERROR = 10,
LOADING = 7,
LOAD_ERROR = 8
}
export enum Status {
EMPTY = 0,
IDLE = 1,
ERROR = 2,
BUSY = 3,
READY = 4
}
export enum FileOrigin {
INPUT = 1,
LIMBO = 2,
LOCAL = 3
}
// TODO replace all references to `ActualFileObject` with native `File`
/**
* @deprecated Don't use this type explicitly within your code. It'll be replaced with the native `File` type in a future release.
*/
export type ActualFileObject = Blob & { readonly lastModified: number; readonly name: string; };
/**
* A custom FilePond File.
*/
export class FilePondFile {
/** Returns the ID of the file. */
id: string;
/** Returns the server id of the file. */
serverId: string;
/** Returns the source of the file. */
source: ActualFileObject | string;
/** Returns the origin of the file. */
origin: FileOrigin;
/** Returns the current status of the file. */
status: FileStatus;
/** Returns the File object. */
file: ActualFileObject;
/** Returns the file extensions. */
fileExtension: string;
/** Returns the size of the file. */
fileSize: number;
/** Returns the type of the file. */
fileType: string;
/** Returns the full name of the file. */
filename: string;
/** Returns the name of the file without extension. */
filenameWithoutExtension: string;
/** Aborts loading of this file */
abortLoad: () => void;
/** Aborts processing of this file */
abortProcessing: () => void;
/**
* Retrieve metadata saved to the file, pass a key to retrieve
* a specific part of the metadata (e.g. 'crop' or 'resize').
* If no key is passed, the entire metadata object is returned.
*/
getMetadata: (key?: string) => any;
/** Add additional metadata to the file */
setMetadata: (key: string, value: any, silent?: boolean) => void;
}
// TODO delete
/**
* A custom FilePond File. Don't confuse this with the native `File` type.
*
* @deprecated use `FilePondFile` instead. This type will be removed in a future release.
*/
export class File extends FilePondFile {}
export interface ServerUrl {
url: string;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
withCredentials?: boolean;
headers?: { [key: string]: string | boolean | number };
timeout?: number;
/**
* Called when server response is received, useful for getting
* the unique file id from the server response.
*/
onload?: (response: any) => number | string;
/**
* Called when server error is received, receives the response
* body, useful to select the relevant error data.
*/
onerror?: (responseBody: any) => any;
/**
* Called with the formdata object right before it is sent,
* return extended formdata object to make changes.
*/
ondata?: (data: FormData) => FormData;
}
export type ProgressServerConfigFunction = (
/**
* Flag indicating if the resource has a length that can be calculated.
* If not, the totalDataAmount has no significant value. Setting this to
* false switches the FilePond loading indicator to infinite mode.
*/
isLengthComputable: boolean,
/** The amount of data currently transferred. */
loadedDataAmount: number,
/** The total amount of data to be transferred. */
totalDataAmount: number,
) => void;
export interface ProcessServerChunkTransferOptions {
chunkTransferId: string,
chunkServer: ServerUrl,
/**
* Chunk uploads enabled
*/
chunkUploads: boolean,
/**
* Forcing use of chunk uploads even for files smaller than chunk size
*/
chunkForce: boolean,
/**
* Size of chunks
*/
chunkSize: number,
/**
* Amount of times to retry upload of a chunk when it fails
*/
chunkRetryDelays: number[]
}
export type ProcessServerConfigFunction = (
/** The name of the input field. */
fieldName: string,
/** The actual file object to send. */
file: ActualFileObject,
metadata: { [key: string]: any },
/**
* Should call the load method when done and pass the returned server file id.
* This server file id is then used later on when reverting or restoring a file
* so that your server knows which file to return without exposing that info
* to the client.
*/
load: (p: string | { [key: string]: any }) => void,
/** Call if something goes wrong, will exit after. */
error: (errorText: string) => void,
/**
* Should call the progress method to update the progress to 100% before calling load().
* Setting computable to false switches the loading indicator to infinite mode.
*/
progress: ProgressServerConfigFunction,
/** Let FilePond know the request has been cancelled. */
abort: () => void,
/**
* Let Filepond know and store the current file chunk transfer id so it can track the
* progress of the whole file upload
*/
transfer: (transferId: string) => void,
options: ProcessServerChunkTransferOptions
) => void;
export type RevertServerConfigFunction = (
/** Server file id of the file to restore. */
uniqueFieldId: any,
/** Should call the load method when done. */
load: () => void,
/** Call if something goes wrong, will exit after. */
error: (errorText: string) => void
) => void;
export type RestoreServerConfigFunction = (
/** Server file id of the file to restore. */
uniqueFileId: any,
/** Should call the load method with a file object or blob when done. */
load: (file: ActualFileObject) => void,
/** Call if something goes wrong, will exit after. */
error: (errorText: string) => void,
/**
* Should call the progress method to update the progress to 100% before calling load().
* Setting computable to false switches the loading indicator to infinite mode.
*/
progress: ProgressServerConfigFunction,
/** Let FilePond know the request has been cancelled. */
abort: () => void,
/**
* Can call the headers method to supply FilePond with early response header string.
* https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders
*/
headers: (headersString: string) => void
) => void;
export type LoadServerConfigFunction = (
source: any,
/** Should call the load method with a file object or blob when done. */
load: (file: ActualFileObject | Blob) => void,
/** Call if something goes wrong, will exit after. */
error: (errorText: string) => void,
/**
* Should call the progress method to update the progress to 100% before calling load().
* Setting computable to false switches the loading indicator to infinite mode.
*/
progress: ProgressServerConfigFunction,
/** Let FilePond know the request has been cancelled. */
abort: () => void,
/**
* Can call the headers method to supply FilePond with early response header string.
* https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders>
*/
headers: (headersString: string) => void
) => void;
export type FetchServerConfigFunction = (
url: string,
/** Should call the load method with a file object or blob when done. */
load: (file: ActualFileObject | Blob) => void,
/** Call if something goes wrong, will exit after. */
error: (errorText: string) => void,
/**
* Should call the progress method to update the progress to 100% before calling load().
* Setting computable to false switches the loading indicator to infinite mode.
*/
progress: ProgressServerConfigFunction,
/** Let FilePond know the request has been cancelled. */
abort: () => void,
/**
* Can call the headers method to supply FilePond with early response header string.
* https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders
*/
headers: (headersString: string) => void
) => void;
export type RemoveServerConfigFunction = (
/** Local file source */
source: any,
/** Call when done */
load: () => void,
/** Call if something goes wrong, will exit after. */
error: (errorText: string) => void
) => void;
export interface FilePondInitialFile {
/** The server file reference. */
source: string;
options: {
/** Origin of file being added. */
type: 'input' | 'limbo' | 'local';
/** Mock file information. */
file?: {
name?: string;
size?: number;
type?: string;
};
/** File initial metadata. */
metadata?: { [key: string]: any };
};
}
export interface FilePondServerConfigProps {
/**
* Immediately upload new files to the server.
* @default true
*/
instantUpload?: boolean;
/**
* The maximum number of files that can be uploaded in parallel.
* @default 2
*/
maxParallelUploads?: number;
/**
* Server API Configuration.
* See: https://pqina.nl/filepond/docs/patterns/api/server
* @default null
*/
server?: string | {
url?: string
timeout?: number
headers?: { [key: string]: string | boolean | number };
process?: string | ServerUrl | ProcessServerConfigFunction | null;
revert?: string | ServerUrl | RevertServerConfigFunction | null;
restore?: string | ServerUrl | RestoreServerConfigFunction | null;
load?: string | ServerUrl | LoadServerConfigFunction | null;
fetch?: string | ServerUrl | FetchServerConfigFunction | null;
remove?: RemoveServerConfigFunction | null;
} | null;
/**
* Enable chunk uploads
* @default false
*/
chunkUploads?: boolean;
/**
* Force use of chunk uploads even for files smaller than chunk size
* @default false
*/
chunkForce?: boolean;
/**
* Size of chunks (5MB default)
* @default 5000000
*/
chunkSize?: number;
/**
* Amount of times to retry upload of a chunk when it fails
* @default [500, 1000, 3000]
*/
chunkRetryDelays?: number[];
/**
* A list of file locations that should be loaded immediately.
* See: https://pqina.nl/filepond/docs/patterns/api/filepond-object/#setting-initial-files
* @default []
*/
files?: Array<FilePondInitialFile | ActualFileObject | Blob | string>;
}
export interface FilePondDragDropProps {
/**
* FilePond will catch all files dropped on the webpage.
* @default false
*/
dropOnPage?: boolean;
/**
* Require drop on the FilePond element itself to catch the file.
* @default true
*/
dropOnElement?: boolean;
/**
* When enabled, files are validated before they are dropped.
* A file is not added when it’s invalid.
* @default false
*/
dropValidation?: boolean;
/**
* Ignored file names when handling dropped directories.
* Dropping directories is not supported on all browsers.
* @default ['.ds_store', 'thumbs.db', 'desktop.ini']
*/
ignoredFiles?: string[];
}
export interface FilePondLabelProps {
/**
* The decimal separator used to render numbers.
* By default this is determined automatically.
* @default 'auto'
*/
labelDecimalSeparator?: string;
/**
* The thousands separator used to render numbers.
* By default this is determined automatically.
* @default 'auto'
*/
labelThousandsSeparator?: string;
/**
* Default label shown to indicate this is a drop area.
* FilePond will automatically bind browse file events to
* the element with CSS class .filepond--label-action.
* @default 'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>'
*/
labelIdle?: string;
/**
* Label shown when the field contains invalid files and is validated by the parent form.
* @default 'Field contains invalid files'
*/
labelInvalidField?: string;
/**
* Label used while waiting for file size information.
* @default 'Waiting for size'
*/
labelFileWaitingForSize?: string;
/**
* Label used when no file size information was received.
* @default 'Size not available'
*/
labelFileSizeNotAvailable?: string;
/**
* Label used when showing the number of files and there is only one.
* @default 'file in list'
*/
labelFileCountSingular?: string;
/**
* Label used when showing the number of files and there is more than one.
* @default 'files in list'
*/
labelFileCountPlural?: string;
/**
* Label used while loading a file.
* @default 'Loading'
*/
labelFileLoading?: string;
/**
* Label used when file is added (assistive only).
* @default 'Added'
*/
labelFileAdded?: string;
/**
* Label used when file load failed.
* @default 'Error during load'
*/
labelFileLoadError?: ((error: any) => string) | string;
/**
* Label used when file is removed (assistive only).
* @default 'Removed'
*/
labelFileRemoved?: string;
/**
* Label used when something went during during removing the file upload.
* @default 'Error during remove'
*/
labelFileRemoveError?: ((error: any) => string) | string;
/**
* Label used when uploading a file.
* @default 'Uploading'
*/
labelFileProcessing?: string;
/**
* Label used when file upload has completed.
* @default 'Upload complete'
*/
labelFileProcessingComplete?: string;
/**
* Label used when upload was cancelled.
* @default 'Upload cancelled'
*/
labelFileProcessingAborted?: string;
/**
* Label used when something went wrong during file upload.
* @default 'Error during upload'
*/
labelFileProcessingError?: ((error: any) => string) | string;
/**
* Label used when something went wrong during reverting the file upload.
* @default 'Error during revert'
*/
labelFileProcessingRevertError?: ((error: any) => string) | string;
/**
* Label used to indicate to the user that an action can be cancelled.
* @default 'tap to cancel'
*/
labelTapToCancel?: string;
/**
* Label used to indicate to the user that an action can be retried.
* @default 'tap to retry'
*/
labelTapToRetry?: string;
/**
* Label used to indicate to the user that an action can be undone.
* @default 'tap to undo'
*/
labelTapToUndo?: string;
/**
* Label used for remove button.
* @default 'Remove'
*/
labelButtonRemoveItem?: string;
/**
* Label used for abort load button.
* @default 'Abort'
*/
labelButtonAbortItemLoad?: string;
/**
* Label used for retry load.
* @default 'Retry'
*/
labelButtonRetryItemLoad?: string;
/**
* Label used for abort upload button.
* @default 'Cancel'
*/
labelButtonAbortItemProcessing?: string;
/**
* Label used for undo upload button.
* @default 'Undo'
*/
labelButtonUndoItemProcessing?: string;
/**
* Label used for retry upload button.
* @default 'Retry'
*/
labelButtonRetryItemProcessing?: string;
/**
* Label used for upload button.
* @default 'Upload'
*/
labelButtonProcessItem?: string;
}
export interface FilePondSvgIconProps {
/**
* The icon used for remove actions.
* @default '<svg></svg>'
*/
iconRemove?: string;
/**
* The icon used for process actions.
* @default '<svg></svg>'
*/
iconProcess?: string;
/**
* The icon used for retry actions.
* @default '<svg></svg>'
*/
iconRetry?: string;
/**
* The icon used for undo actions.
* @default '<svg></svg>'
*/
iconUndo?: string;
/**
* The icon used for done.
* @default '<svg></svg>'
*/
iconDone?: string;
}
export interface FilePondErrorDescription {
type: string;
code: number;
body: string;
}
export interface FilePondCallbacks {
/** FilePond instance has been created and is ready. */
init?: () => void;
/**
* FilePond instance throws a warning. For instance
* when the maximum amount of files has been reached.
* Optionally receives file if error is related to a
* file object.
*/
warning?: (error: any, file?: FilePondFile, status?: any) => void;
/**
* FilePond instance throws an error. Optionally receives
* file if error is related to a file object.
*/
error?: (error: FilePondErrorDescription, file?: FilePondFile, status?: any) => void;
/** Started file load. */
addfilestart?: (file: FilePondFile) => void;
/** Made progress loading a file. */
addfileprogress?: (file: FilePondFile, progress: number) => void;
/** If no error, file has been successfully loaded. */
addfile?: (error: FilePondErrorDescription | null, file: FilePondFile) => void;
/** Started processing a file. */
processfilestart?: (file: FilePondFile) => void;
/** Made progress processing a file. */
processfileprogress?: (file: FilePondFile, progress: number) => void;
/** Aborted processing of a file. */
processfileabort?: (file: FilePondFile) => void;
/** Processing of a file has been reverted. */
processfilerevert?: (file: FilePondFile) => void;
/** If no error, Processing of a file has been completed. */
processfile?: (error: FilePondErrorDescription | null, file: FilePondFile) => void;
/** Called when all files in the list have been processed. */
processfiles?: () => void;
/** File has been removed. */
removefile?: (error: FilePondErrorDescription | null, file: FilePondFile) => void;
/**
* File has been transformed by the transform plugin or
* another plugin subscribing to the prepare_output filter.
* It receives the file item and the output data.
*/
preparefile?: (file: FilePondFile, output: any) => void;
/** A file has been added or removed, receives a list of file items. */
updatefiles?: (files: FilePondFile[]) => void;
/* Called when a file is clicked or tapped. **/
activatefile?: (file: FilePondFile) => void;
/** Called when the files have been reordered */
reorderfiles?: (files: FilePondFile[]) => void;
}
export type FilePondCallbackProps = {
[Property in keyof FilePondCallbacks as `on${Property}`]: FilePondCallbacks[Property]
};
export interface FilePondHookProps {
/**
* FilePond is about to allow this item to be dropped, it can be a URL or a File object.
*
* Return `true` or `false` depending on if you want to allow the item to be dropped.
*/
beforeDropFile?: (file: FilePondFile | string) => boolean;
/**
* FilePond is about to add this file.
*
* Return `false` to prevent adding it, or return a `Promise` and resolve with `true` or `false`.
*/
beforeAddFile?: (item: FilePondFile) => boolean | Promise<boolean>;
/**
* FilePond is about to remove this file.
*
* Return `false` to prevent adding it, or return a `Promise` and resolve with `true` or `false`.
*/
beforeRemoveFile?: (item: FilePondFile) => boolean | Promise<boolean>;
}
export interface FilePondStyleProps {
/**
* Set a different layout render mode.
* @default null
*/
stylePanelLayout?: 'integrated' | 'compact' | 'circle' | 'integrated circle' | 'compact circle' | null;
/**
* Set a forced aspect ratio for the FilePond drop area.
*
* Accepts human readable aspect ratios like `1:1` or numeric aspect ratios like `0.75`.
* @default null
*/
stylePanelAspectRatio?: string | null;
/**
* Set a forced aspect ratio for the file items.
*
* Useful when rendering cropped or fixed aspect ratio images in grid view.
* @default null
*/
styleItemPanelAspectRatio?: string | null;
/**
* The position of the remove item button.
* @default 'left'
*/
styleButtonRemoveItemPosition?: string;
/**
* The position of the remove item button.
* @default 'right'
*/
styleButtonProcessItemPosition?: string;
/**
* The position of the load indicator.
* @default 'right'
*/
styleLoadIndicatorPosition?: string;
/**
* The position of the progress indicator.
* @default 'right'
*/
styleProgressIndicatorPosition?: string;
/**
* Enable to align the remove button to the left side of the file item.
* @default false
*/
styleButtonRemoveItemAlign?: boolean;
}
export type CaptureAttribute = "camera" | "microphone" | "camcorder";
export interface FilePondBaseProps {
/**
* The ID to add to the root element.
* @default null
*/
id?: string | null;
/**
* The input field name to use.
* @default 'filepond'
*/
name?: string;
/**
* Class Name to put on wrapper.
* @default null
*/
className?: string | null;
/**
* Sets the required attribute to the output field.
* @default false
*/
required?: boolean;
/**
* Sets the disabled attribute to the output field.
* @default false
*/
disabled?: boolean;
/**
* Sets the given value to the capture attribute.
* @default null
*/
captureMethod?: CaptureAttribute | null;
/**
* Set to false to prevent FilePond from setting the file input field `accept` attribute to the value of the `acceptedFileTypes`.
*/
allowSyncAcceptAttribute?: boolean;
/**
* Enable or disable drag n’ drop.
* @default true
*/
allowDrop?: boolean;
/**
* Enable or disable file browser.
* @default true
*/
allowBrowse?: boolean;
/**
* Enable or disable pasting of files. Pasting files is not
* supported on all browsers.
* @default true
*/
allowPaste?: boolean;
/**
* Enable or disable adding multiple files.
* @default false
*/
allowMultiple?: boolean;
/**
* Allow drop to replace a file, only works when allowMultiple is false.
* @default true
*/
allowReplace?: boolean;
/**
* Allows the user to revert file upload.
* @default true
*/
allowRevert?: boolean;
/**
* Allows user to process a file. When set to false, this removes the file upload button.
* @default true
*/
allowProcess?: boolean;
/**
* Allows the user to reorder the file items
* @default false
*/
allowReorder?: boolean;
/**
* Allow only selecting directories with browse (no support for filtering dnd at this point)
* @default false
*/
allowDirectoriesOnly?: boolean;
/**
* Require the file to be successfully reverted before continuing.
* @default false
*/
forceRevert?: boolean;
/**
* The maximum number of files that filepond pond can handle.
* @default null
*/
maxFiles?: number | null;
/**
* Enables custom validity messages.
* @default false
*/
checkValidity?: boolean;
/**
* Set to false to always add items to beginning or end of list.
* @default true
*/
itemInsertLocationFreedom?: boolean;
/**
* Default index in list to add items that have been dropped at the top of the list.
* @default 'before'
*/
itemInsertLocation?: 'before' | 'after' | ((a: FilePondFile, b: FilePondFile) => number);
/**
* The interval to use before showing each item being added to the list.
* @default 75
*/
itemInsertInterval?: number;
/**
* The base value used to calculate file size
* @default 1000
*/
fileSizeBase?: number;
/**
* Tells FilePond to store files in hidden file input elements so they can be posted along with
* normal form post. This only works if the browser supports the DataTransfer constructor,
* this is the case on Firefox, Chrome, Chromium powered browsers and Safari version 14.1
* and higher.
* @default false
*/
storeAsFile?: boolean;
/**
* Shows Powered by PQINA in footer. Can be disabled by setting to false, but please do
* link to https://pqina.nl somewhere else on your website, or otherwise donate to help
* keep the project alive.
* @default "Powered by PQINA"
*/
credits?: false
}
// TODO delete
/**
* @deprecated use `FilePondOptions`. This will be removed in a future release.
*/
export interface FilePondOptionProps extends
FilePondDragDropProps,
FilePondServerConfigProps,
FilePondLabelProps,
FilePondSvgIconProps,
FilePondCallbackProps,
FilePondHookProps,
FilePondStyleProps,
FilePondBaseProps { }
export interface FilePondOptions extends
FilePondDragDropProps,
FilePondServerConfigProps,
FilePondLabelProps,
FilePondSvgIconProps,
FilePondCallbackProps,
FilePondHookProps,
FilePondStyleProps,
FilePondBaseProps { }
export type FilePondEvent = keyof FilePondCallbacks;
type Prefix<K> = K extends string ? `FilePond:${K}` : K;
export type FilePondEventPrefixed = Prefix<FilePondEvent>
export interface RemoveFileOptions {
remove?: boolean;
revert?: boolean;
}
export interface FilePond extends Required<FilePondOptions> {}
export interface FilePond {
/**
* The root element of the Filepond instance.
*/
readonly element: Element | null;
/**
* Returns the current status of the FilePond instance.
* @default Status.EMPTY
*/
readonly status: Status;
/** Override multiple options at once. */
setOptions(options: FilePondOptions): void;
/**
* Adds a file.
* @param options.index The index that the file should be added at.
*/
addFile(source: ActualFileObject | Blob | string, options?: { index?: number } & Partial<FilePondInitialFile["options"]>): Promise<FilePondFile>;
/**
* Adds multiple files.
* @param options.index The index that the files should be added at.
*/
addFiles(source: ActualFileObject[] | Blob[] | string[], options?: { index: number }): Promise<FilePondFile[]>;
/**
* Moves a file. Select file with query and supply target index.
* @param query The file reference, id, or index.
* @param index The index to move the file to.
*/
moveFile(query: FilePondFile | string | number, index: number): void;
/**
* Removes a file.
* @param query The file reference, id, or index. If no query is provided, removes the first file in the list.
* @param options Options for removal
*/
removeFile(query?: FilePondFile | string | number, options?: RemoveFileOptions): void;
/**
* Removes the first file in the list.
* @param options Options for removal
*/
removeFile(options: RemoveFileOptions): void;
/**
* Removes files matching the query.
* @param query Array containing file references, ids, and/or indexes. If no array is provided, all files are removed
* @param options Options for removal
*/
removeFiles(query?: Array<FilePondFile | string | number>, options?: RemoveFileOptions): void;
/**
* Removes all files.
* @param options Options for removal
*/
removeFiles(options: RemoveFileOptions): void;
/**
* Processes a file. If no parameter is provided, processes the first file in the list.
* @param query The file reference, id, or index
*/
processFile(query?: FilePondFile | string | number): Promise<FilePondFile>;
/**
* Processes multiple files. If no parameter is provided, processes all files.
* @param query The file reference(s), id(s), or index(es)
*/
processFiles(query?: FilePondFile[] | string[] | number[]): Promise<FilePondFile[]>;
/**
* Starts preparing the file matching the given query, returns a Promise, the Promise is resolved with the file item and the output file { file, output }
* @param query The file reference, id, or index
*/
prepareFile(query?: FilePondFile | string | number): Promise<{file: FilePondFile, output: any}>;
/**
* Processes multiple files. If no parameter is provided, processes all files.
* @param query Array containing file reference(s), id(s), or index(es)
*/
prepareFiles(query?: FilePondFile[] | string[] | number[]): Promise<Array<{file: FilePondFile, output: any}>>;
/**
* Returns a file. If no parameter is provided, returns the first file in the list.
* @param query The file id, or index
*/
getFile(query?: string | number): FilePondFile;
/** Returns all files. */
getFiles(): FilePondFile[];
/**
* Manually trigger the browse files panel.
*
* Only works if the call originates from the user.
*/
browse(): void;
/**
* Sort the items in the files list.
* @param compare The comparison function
*/
sort(compare: (a: FilePondFile, b: FilePondFile) => number): void;
/** Destroys this FilePond instance. */
destroy(): void;
/** Inserts the FilePond instance after the supplied element. */
insertAfter(element: Element): void;
/** Inserts the FilePond instance before the supplied element. */
insertBefore(element: Element): void;
/** Appends FilePond to the given element. */
appendTo(element: Element): void;
/** Returns true if the current instance is attached to the supplied element. */
isAttachedTo(element: Element): void;
/** Replaces the supplied element with FilePond. */
replaceElement(element: Element): void;
/** If FilePond replaced the original element, this restores the original element to its original glory. */
restoreElement(element: Element): void;
/**
* Adds an event listener to the given event.
* @param event Name of the event, prefixed with `Filepond:`
* @param fn Event handler
*/
addEventListener(event: FilePondEventPrefixed, fn: (e: any) => void): void;
/**
* Listen to an event.
* @param event Name of the event
* @param fn Event handler, signature is identical to the callback method
*/
on<E extends keyof FilePondCallbacks>(event: E, fn: NonNullable<FilePondCallbacks[E]>): void;
/**
* Listen to an event once and remove the handler.
* @param event Name of the event
* @param fn Event handler, signature is identical to the callback method
*/
onOnce<E extends keyof FilePondCallbacks>(event: E, fn: NonNullable<FilePondCallbacks[E]>): void;
/**
* Stop listening to an event.
* @param event Name of the event
* @param fn Event handler, signature is identical to the callback method
*/
off<E extends keyof FilePondCallbacks>(event: E, fn: NonNullable<FilePondCallbacks[E]>): void;
}
/** Creates a new FilePond instance. */
export function create(element?: Element, options?: FilePondOptions): FilePond;
/** Destroys the FilePond instance attached to the supplied element. */
export function destroy(element: Element): void;
/** Returns the FilePond instance attached to the supplied element. */
export function find(element: Element): FilePond;
/**
* Parses a given section of the DOM tree for elements with class
* .filepond and turns them into FilePond elements.
*/
export function parse(context: Element): void;
/** Registers a FilePond plugin for later use. */
export function registerPlugin(...plugins: any[]): void;
/** Sets page level default options for all FilePond instances. */
export function setOptions(options: FilePondOptions): void;
/** Returns the current default options. */
export function getOptions(): FilePondOptions;
/** Determines whether or not the browser supports FilePond. */
export function supported(): boolean;
/** Returns an object describing all the available options and their types, useful for writing FilePond adapters. */
export const OptionTypes: object;