filepond
Version:
FilePond, where files go to stretch their bits.
175 lines (174 loc) • 8.22 kB
TypeScript
import type { Locale } from '../../types/index.js';
import type { FilePondEntrySource, FilePondEntry } from '../../types/index.js';
import type { ExtensionFactory } from '../../core/extensionManager.js';
import { type EntryTreeOn, type Needle } from '../../core/entryTree.js';
import { HTMLElementSafe } from '../../common/ssr.js';
export interface FilePondInputElementEventMap {
change: CustomEvent<null>;
entrieschange: CustomEvent<FilePondEntry[]>;
connected: CustomEvent<null>;
disconnected: CustomEvent<null>;
}
interface FilePondInputElementEvents {
addEventListener<K extends keyof FilePondInputElementEventMap>(type: K, listener: (this: FilePondInputElement, event: FilePondInputElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
}
/**
* FilePond Custom Input Element
*
* @event {CustomEvent<null>} 'change' - Fired when form value changed
* @event {CustomEvent<FilePondEntry[]>} 'entrieschange' - Fired when entries list updated
* @event {CustomEvent<null>} 'connected' - Fired when connected to the DOM
* @event {CustomEvent<null>} 'disconnected' - Fired when disconnected from the DOM
*/
export declare class FilePondInputElement extends HTMLElementSafe implements FilePondInputElementEvents {
/** Returns a reference to the shadow root element */
get _root(): HTMLDivElement;
/** Returns a reference to the slot element */
get _slot(): HTMLSlotElement;
/** Attributes being observed for changes */
static get observedAttributes(): string[];
/** Called when attributes are changed, added, removed, or replaced */
attributeChangedCallback(name: string, _: string, value: string | boolean): void;
/** Disable the field and sets the disabled attribute */
set disabled(value: boolean);
/** Gets the field disabled state */
get disabled(): boolean;
/** Set the field webkitdirectory state */
set webkitdirectory(value: boolean);
/** Gets the field webkitdirectory state */
get webkitdirectory(): boolean;
/** Toggle the field multiple state */
set multiple(allowMultiple: boolean);
/** Gets the field multiple state */
get multiple(): boolean;
/**
* Set field as readonly. Only for situations where FilePond has initial files and those files
* should be posted. The `readonly` attribute isn't supported on a file input element as it
* cannot have an initial value.
*/
set readOnly(value: boolean);
/** Gets the field readonly state */
get readOnly(): boolean;
/** Set field as required */
set required(value: boolean);
/** Gets the field required state */
get required(): boolean;
/** Accepted files setter https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept */
set accept(value: string);
/** Returns the current value of accept */
get accept(): string;
/** Ignored files */
set ignoredEntryPatterns(value: RegExp[]);
/** Toggle browse button */
set noBrowse(value: boolean);
/** Returns the current browse button state */
get noBrowse(): boolean;
/** Min file size setter, accepts a number of bytes or a natural filesize string like 1MB */
set minSize(value: number | string);
/** Returns the currently set min file size */
get minSize(): number | string | undefined;
/** Max file size setter, accepts a number of bytes or a natural filesize string like 1MB */
set maxSize(value: number | string);
/** Returns the currently set max file size */
get maxSize(): number | string | undefined;
/** Min total file size setter, accepts a number of bytes or a natural filesize string like 1MB */
set minListSize(value: number | string);
/** Returns the currently set min total file size */
get minListSize(): number | string | undefined;
/** Max total file size setter, accepts a number of bytes or a natural filesize string like 1MB */
set maxListSize(value: number | string);
/** Returns the currently set max total file size */
get maxListSize(): number | string | undefined;
/** Min total entries setter, an integer, defaults to `0` */
set minFiles(value: number);
/** Returns the currently set min total entries */
get minFiles(): number;
/** Max total entries setter, an integer, defaults to `Infinity` */
set maxFiles(value: number);
/** Returns the currently set max total entries */
get maxFiles(): number;
/** Set the current entries */
set entries(entries: FilePondEntrySource[]);
/** Returns a `structuredClone` of the current entries array */
get currentEntries(): FilePondEntry[];
/** Sets the locale */
set locale(value: Locale);
/** Returns the current locale object, so it's easier to extend or override */
get locale(): Locale | undefined;
/** Sets custom extensions to load */
set extensions(extensions: ExtensionFactory[]);
/** Update worker url */
set workersURL(value: URL);
/** Opens the system file browser */
browse(): void;
/** Subscribe to internal entryTree events */
on: EntryTreeOn;
/** Add one or more entries to the end of the list or insert them at a specific index */
insertEntries(entry: FilePondEntry | FilePondEntry[], index?: number | number[]): void;
/** Find entries in the entry tree */
findEntries(...needles: Needle[]): FilePondEntry | (FilePondEntry | undefined)[] | undefined;
/** Find entries in the entry tree */
removeEntries(...needles: Needle[]): void | {
entry: FilePondEntry;
index: number[];
} | (void | {
entry: FilePondEntry;
index: number[];
})[];
/** Sorts the entry tree using the passed sorting function */
sortEntries(fn: (a: FilePondEntry, b: FilePondEntry) => 1 | -1 | 0): void;
/** Update an entry */
updateEntry(needle: Needle, ...props: any[]): void;
/** Update an entry state */
updateEntryState(needle: Needle, ...props: any[]): void;
/** Move entry from current location to new index */
moveEntry(needle: Needle, index: number | number[]): void;
/** Replace entry with one or more entries */
replaceEntry(needle: Needle, ...entries: FilePondEntry[]): void;
/** Called when the custom element is created */
constructor(options: {
styles: string[];
});
/** Called each time the element is added to the document */
connectedCallback(): void;
/** Called each time the element is removed from the document. */
disconnectedCallback(): void;
/** This makes the element associable with its parent form */
static formAssociated: boolean;
/** Sets the current field name */
set name(value: string);
/** Returns the current field name */
get name(): string | undefined;
/** Proxy for Element internals `form` getter */
get form(): HTMLFormElement | undefined;
/**
* Sets/Updates the value of the the entry manager
*
* Will also remember this value for when form is reset
*/
set value(value: string | FilePondEntrySource[]);
/** Proxy for `entries` getter */
get value(): FilePondEntry[];
/** Validates the current state of the field */
checkValidity(): boolean | undefined;
/** Proxy for element internals `reportValidity()` method */
reportValidity(): void;
/** Proxy for element internals `validity` getter */
get validity(): ValidityState;
/** Proxy for element internals `validationMessage` getter */
get validationMessage(): string;
/** Called when element or parent element (for example a `<fieldset>`) is set to disabled */
formDisabledCallback(isDisabled: boolean): void;
/**
* Called when user resets form. Resets field to initial state. The initial state is either
* empty or set to what the developer has set to the `.entries` prop. This tries to mimic the
* workings of `setAttribute` on default form fields.
*
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset
*/
formResetCallback(): void;
/** Called when user returns to form with back button */
formStateRestoreCallback(state: any, mode: string): void;
}
export {};