import * as _angular_core from '@angular/core'; import { Signal, Provider } from '@angular/core'; import { BooleanInput, NumberInput } from '@angular/cdk/coercion'; import * as ng_primitives_state from 'ng-primitives/state'; import { Observable } from 'rxjs'; /** * Why a file was rejected. */ type NgpFileRejectionReason = 'type' | 'size' | 'count'; /** * A file that failed validation, with every rule it broke. */ interface NgpFileRejection { readonly file: File; readonly reasons: NgpFileRejectionReason[]; } /** * Where pasted files are captured: on the focused host element, anywhere in the document, or not at all. */ type NgpFilePasteTarget = false | 'host' | 'document'; /** * Capture files dropped on the element. */ declare class NgpFileDropzone { /** * Access the global file dropzone configuration. */ private readonly config; /** * The accepted file types. This can be an array of strings or a comma-separated string. * Accepted types can either be file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`). */ readonly fileTypes: _angular_core.InputSignalWithTransform; /** * Whether to allow multiple files to be selected. */ readonly multiple: _angular_core.InputSignalWithTransform; /** * Whether to allow the user to select directories. */ readonly directory: _angular_core.InputSignalWithTransform; /** * The maximum size of each file in bytes. Larger files are rejected. */ readonly maxFileSize: _angular_core.InputSignalWithTransform; /** * Where pasted files are captured: `'host'` (or the bare attribute) while the element is focused, * `'document'` anywhere on the page, or `false` to ignore pastes. */ readonly paste: _angular_core.InputSignalWithTransform; /** * Whether the file dropzone is disabled. */ readonly disabled: _angular_core.InputSignalWithTransform; /** * Emits when the user selects files. */ readonly selected: _angular_core.OutputEmitterRef; /** * Emits when no files are selected because every file failed validation. */ readonly rejected: _angular_core.OutputEmitterRef; /** * Emits every file that failed validation and why, including when other files were accepted. */ readonly rejectedFiles: _angular_core.OutputEmitterRef; /** * Emits when the user drags a file over the file upload. */ readonly dragOver: _angular_core.OutputEmitterRef; private readonly state; /** * Whether the user is currently dragging a file over the file upload. */ readonly isDragOver: _angular_core.WritableSignal; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * The state for the NgpFileDropzone directive. */ interface NgpFileDropzoneState { /** * Whether the file dropzone is disabled. */ readonly disabled: Signal; /** * Whether the user is currently dragging over the element. */ readonly isDragOver: Signal; /** * Observable that emits when files are selected. */ readonly selected: Observable; /** * Observable that emits when files are rejected. */ readonly rejected: Observable; /** * Observable that emits every file that failed validation, and why. */ readonly rejectedFiles: Observable; /** * Observable that emits when drag over state changes. */ readonly dragOver: Observable; /** * Set the accepted file types. */ readonly fileTypes: Signal; /** * Whether multiple files can be selected. */ readonly multiple: Signal; /** * Whether directories can be selected. */ readonly directory: Signal; /** * Set the disabled state. */ setDisabled(value: boolean): void; } /** * The props for the NgpFileDropzone state. */ interface NgpFileDropzoneProps { /** * The accepted file types. */ readonly fileTypes?: Signal; /** * Whether multiple files can be selected. */ readonly multiple?: Signal; /** * Whether directories can be selected. */ readonly directory?: Signal; /** * The maximum size of each file in bytes. */ readonly maxFileSize?: Signal; /** * Where pasted files are captured. */ readonly paste?: Signal; /** * Whether the file dropzone is disabled. */ readonly disabled?: Signal; /** * Callback when files are selected. */ readonly onSelected?: (files: FileList | null) => void; /** * Callback when files are rejected. */ readonly onRejected?: () => void; /** * Callback with every file that failed validation, and why. */ readonly onRejectedFiles?: (rejections: NgpFileRejection[]) => void; /** * Callback when drag over state changes. */ readonly onDragOver?: (isDragOver: boolean) => void; } declare const ngpFileDropzone: ({ fileTypes, multiple, directory, maxFileSize, paste, disabled: _disabled, onSelected, onRejected, onRejectedFiles, onDragOver, }: NgpFileDropzoneProps) => { disabled: _angular_core.WritableSignal; fileTypes: Signal; multiple: Signal; directory: Signal; isDragOver: _angular_core.WritableSignal; selected: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; setDisabled: (value: boolean) => void; }; declare const injectFileDropzoneState: { (): Signal<{ disabled: _angular_core.WritableSignal; fileTypes: Signal; multiple: Signal; directory: Signal; isDragOver: _angular_core.WritableSignal; selected: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; setDisabled: (value: boolean) => void; }>; (options: ng_primitives_state.StateInjectionOptions): Signal<{ disabled: _angular_core.WritableSignal; fileTypes: Signal; multiple: Signal; directory: Signal; isDragOver: _angular_core.WritableSignal; selected: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; setDisabled: (value: boolean) => void; } | null>; (options?: ng_primitives_state.StateInjectionOptions): Signal<{ disabled: _angular_core.WritableSignal; fileTypes: Signal; multiple: Signal; directory: Signal; isDragOver: _angular_core.WritableSignal; selected: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; setDisabled: (value: boolean) => void; }> | Signal<{ disabled: _angular_core.WritableSignal; fileTypes: Signal; multiple: Signal; directory: Signal; isDragOver: _angular_core.WritableSignal; selected: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; setDisabled: (value: boolean) => void; } | null>; }; declare const provideFileDropzoneState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; /** * A directive that allows you to turn any element into a file upload trigger. */ declare class NgpFileUpload { /** * Access the global file upload configuration. */ private readonly config; /** * The accepted file types. This can be an array of strings or a comma-separated string. * Accepted types can either be file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`). */ readonly fileTypes: _angular_core.InputSignalWithTransform; /** * Whether to allow multiple files to be selected. */ readonly multiple: _angular_core.InputSignalWithTransform; /** * Whether to allow the user to select directories. */ readonly directory: _angular_core.InputSignalWithTransform; /** * Whether drag-and-drop is enabled. */ readonly dragAndDrop: _angular_core.InputSignalWithTransform; /** * The maximum size of each file in bytes. Larger files are rejected. */ readonly maxFileSize: _angular_core.InputSignalWithTransform; /** * Where pasted files are captured: `'host'` (or the bare attribute) while the element is focused, * `'document'` anywhere on the page, or `false` to ignore pastes. */ readonly paste: _angular_core.InputSignalWithTransform; /** * Whether the file upload is disabled. */ readonly disabled: _angular_core.InputSignalWithTransform; /** * Emits when the user selects files. */ readonly selected: _angular_core.OutputEmitterRef; /** * Emits when the user cancel the file selection. */ readonly canceled: _angular_core.OutputEmitterRef; /** * Emits when no files are selected because every file failed validation. */ readonly rejected: _angular_core.OutputEmitterRef; /** * Emits every file that failed validation and why, including when other files were accepted. */ readonly rejectedFiles: _angular_core.OutputEmitterRef; /** * Emits when the user drags a file over the file upload. */ readonly dragOver: _angular_core.OutputEmitterRef; private readonly state; /** * Whether the user is currently dragging a file over the file upload. */ readonly isDragOver: _angular_core.WritableSignal; /** * Show the file dialog. */ showFileDialog(): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * The state for the NgpFileUpload directive. */ interface NgpFileUploadState { /** * Whether the user is currently dragging over the element. */ readonly isDragOver: Signal; /** * Observable that emits when files are selected. */ readonly selected: Observable; /** * Observable that emits when file selection is canceled. */ readonly canceled: Observable; /** * Observable that emits when files are rejected. */ readonly rejected: Observable; /** * Observable that emits every file that failed validation, and why. */ readonly rejectedFiles: Observable; /** * Observable that emits when drag over state changes. */ readonly dragOver: Observable; /** * Show the file dialog. */ showFileDialog(): void; } /** * The props for the NgpFileUpload state. */ interface NgpFileUploadProps { /** * The accepted file types. */ readonly fileTypes?: Signal; /** * Whether multiple files can be selected. */ readonly multiple?: Signal; /** * Whether directories can be selected. */ readonly directory?: Signal; /** * The maximum size of each file in bytes. */ readonly maxFileSize?: Signal; /** * Where pasted files are captured. */ readonly paste?: Signal; /** * Whether drag and drop is enabled. */ readonly dragAndDrop?: Signal; /** * Whether the file upload is disabled. */ readonly disabled?: Signal; /** * Callback when files are selected. */ readonly onSelected?: (files: FileList | null) => void; /** * Callback when file selection is canceled. */ readonly onCanceled?: () => void; /** * Callback when files are rejected. */ readonly onRejected?: () => void; /** * Callback with every file that failed validation, and why. */ readonly onRejectedFiles?: (rejections: NgpFileRejection[]) => void; /** * Callback when drag over state changes. */ readonly onDragOver?: (isDragOver: boolean) => void; } declare const ngpFileUpload: ({ fileTypes, multiple, directory, maxFileSize, paste, dragAndDrop, disabled, onSelected, onCanceled, onRejected, onRejectedFiles, onDragOver, }: NgpFileUploadProps) => { isDragOver: _angular_core.WritableSignal; selected: Observable; canceled: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; showFileDialog: () => void; }; declare const injectFileUploadState: { (): Signal<{ isDragOver: _angular_core.WritableSignal; selected: Observable; canceled: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; showFileDialog: () => void; }>; (options: ng_primitives_state.StateInjectionOptions): Signal<{ isDragOver: _angular_core.WritableSignal; selected: Observable; canceled: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; showFileDialog: () => void; } | null>; (options?: ng_primitives_state.StateInjectionOptions): Signal<{ isDragOver: _angular_core.WritableSignal; selected: Observable; canceled: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; showFileDialog: () => void; }> | Signal<{ isDragOver: _angular_core.WritableSignal; selected: Observable; canceled: Observable; rejected: Observable; rejectedFiles: Observable; dragOver: Observable; showFileDialog: () => void; } | null>; }; declare const provideFileUploadState: (opts?: { inherit?: boolean; }) => _angular_core.FactoryProvider; interface NgpFileDropzoneConfig { /** * The accepted file types, either file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`). * @default undefined */ fileTypes: string[] | undefined; /** * Whether to allow multiple files to be selected. * @default false */ multiple: boolean; /** * Whether to allow the user to select directories. * @default false */ directory: boolean; /** * The maximum size of each file in bytes. * @default undefined */ maxFileSize?: number; /** * Where pasted files are captured: `'host'` while the element is focused, `'document'` anywhere * on the page, or `false` to ignore pastes. * @default false */ paste?: NgpFilePasteTarget; /** * Whether the file dropzone is disabled. * @default false */ disabled: boolean; } /** * Provide the default File Dropzone configuration * @param config The File Dropzone configuration * @returns The provider */ declare function provideFileDropzoneConfig(config: Partial): Provider[]; interface NgpFileUploadConfig { /** * The accepted file types, either file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`). * @default undefined */ fileTypes: string[] | undefined; /** * Whether to allow multiple files to be selected. * @default false */ multiple: boolean; /** * Whether to allow the user to select directories. * @default false */ directory: boolean; /** * The maximum size of each file in bytes. * @default undefined */ maxFileSize?: number; /** * Where pasted files are captured: `'host'` while the element is focused, `'document'` anywhere * on the page, or `false` to ignore pastes. * @default false */ paste?: NgpFilePasteTarget; /** * Whether drag-and-drop is enabled. * @default true */ dragAndDrop: boolean; /** * Whether the file upload is disabled. * @default false */ disabled: boolean; } /** * Provide the default File Upload configuration * @param config The File Upload configuration * @returns The provider */ declare function provideFileUploadConfig(config: Partial): Provider[]; export { NgpFileDropzone, NgpFileUpload, injectFileDropzoneState, injectFileUploadState, ngpFileDropzone, ngpFileUpload, provideFileDropzoneConfig, provideFileDropzoneState, provideFileUploadConfig, provideFileUploadState }; export type { NgpFileDropzoneConfig, NgpFileDropzoneProps, NgpFileDropzoneState, NgpFilePasteTarget, NgpFileRejection, NgpFileRejectionReason, NgpFileUploadConfig, NgpFileUploadProps, NgpFileUploadState };