import { LitElement, type CSSResultGroup, type PropertyValues, type TemplateResult } from "lit"; import { createValidator, getFormState, getFormValue, getValidityAnchor, onReportValidity } from "../utils/index.ts"; import { RetryEvent } from "./events.ts"; import FileInputValidator from "./Validator.ts"; interface TapsiFileInputEventMap extends HTMLElementEventMap { [RetryEvent.type]: RetryEvent; } declare const BaseClass: import("../utils/index.ts").MixinReturn import("../utils/index.ts").WithElementInternals) & typeof LitElement & import("../utils/mixins/with-form-associated.ts").FormAssociatedConstructor, import("../utils/index.ts").FormAssociated>, import("../utils/index.ts").ConstraintValidation>, import("../utils/index.ts").OnReportValidity>; /** * @summary Used to select and upload files or drag and drop files. * * @tag tapsi-file-input * * @slot [placeholder-icon] - The slot for icon placeholder. * * @fires {RetryEvent} retry - Fires when the retry button is clicked. (bubbles) * @fires {ClearEvent} clear - Fires when user clicks on the clear button for reseting the input value (bubbles) * @fires {Event} change - * Fires when the user modifies the element's value. * Unlike the `input` event, the change event is not necessarily fired for each * alteration to an element's `value`. (bubbles) * @fires {Event} input - * Fires when the value of an input element has been changed as a direct result * of a user action. (bubbles) */ export declare class FileInput extends BaseClass { /** @internal */ static readonly styles: CSSResultGroup; /** @internal */ static shadowRootOptions: ShadowRootInit; /** @internal */ addEventListener: (type: K, listener: (this: FileInput, ev: TapsiFileInputEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void; /** @internal */ removeEventListener: (type: K, listener: (this: FileInput, ev: TapsiFileInputEventMap[K]) => void, options?: boolean | EventListenerOptions) => void; /** * Identifies the element (or elements) that labels the input. * * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby * * @prop {string} labelledBy * @attr {string} labelledby * @default "" */ labelledBy: string; /** * Indicates the loading state of the component. * * - If `false`, the component is not in a loading state. * - If `true`, a spinner will appear indicating the component is loading. * - If a number between 0 and 100, it shows the percentage of the loading state. * * @prop {boolean | number} loading * @attr {string} loading * @default false */ loading: boolean | number; /** * Conveys additional information below the file input, such as how it should * be used. * * @prop {string} supportingText * @attr {string} supporting-text * @default "" */ supportingText: string; /** * Whether the file input allows the user to select more than one file. * * @prop {boolean} multiple * @attr {string} multiple * @default false */ multiple: boolean; /** * Indicates whether or not a user should be able to edit the file input's * value. * * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly * * @prop {boolean} readOnly * @attr {string} readonly * @default false */ readOnly: boolean; /** * The text showing in file input when it is in loading state. * * @prop {string} loadingText * @attr {string} loading-text * @default "در حال بارگذاری..." */ loadingText: string; /** * The error message that replaces supporting text when `error` is true. If * `errorText` is an empty string, then the supporting text will continue to * show. * * This error message overrides the error message displayed by * `reportValidity()`. * * @prop {string} errotText * @attr {string} error-text * @default "" */ errorText: string; /** * Whether the file input has error. * * @prop {boolean} error * @attr {string} error * @default false */ error: boolean; /** * Whether the file input has retry button in error state. * * @prop {boolean} retryableError * @attr {string} retryable-error * @default false */ retryableError: boolean; /** * Used for showing camera for mobile devices. * * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#capture * * @prop {string} capture * @attr {string} capture * @default "" */ capture: string; /** * Specifying what file format does the file input accepts. * * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept * * @prop {string} accept * @attr {string} accept * @default "" */ accept: string; /** * A placeholder text for the input component when no file has been selected. * * @prop {string} placeholder * @attr {string} placeholder * @default "انتخاب فایل" */ placeholder: string; /** * The label of the file input. * - If the `hideLabel` property is true, the label will be hidden visually * but still accessible to screen readers. * - Otherwise, a visible label element will be rendered. * * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label * * @prop {string} label * @attr {string} label * @default "" */ label: string; /** * Whether to hide the label or not. * * @prop {boolean} hideLabel * @attr {string} hide-label * @default false */ hideLabel: boolean; /** * Indicates that the user must specify a value for the input before the * owning form can be submitted and will render an error state when * `reportValidity()` is invoked when value is empty. * * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required * * @prop {boolean} required * @attr {string} required * @default false */ required: boolean; /** * Indicates that the element should be focused on page load. * * https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus * * @prop {boolean} autofocus * @attr {string} autofocus * @default false */ autofocus: boolean; /** * The current value of the input. It is always a string. */ get value(): string; /** * The list of selected files. */ get files(): FileList | null; private _hasPlaceholderIconSlot; /** * When set to true, the error text's `role="alert"` will be removed, then * re-added after an animation frame. This will re-announce an error message * to screen readers. */ private _refreshErrorAlert; private _nativeError; private _nativeErrorText; private _files; private _placeholderIconSlotNodes; private _root; private _input; constructor(); protected firstUpdated(changed: PropertyValues): void; protected willUpdate(changed: PropertyValues): void; protected updated(changed: PropertyValues): void; /** @internal */ connectedCallback(): void; /** @internal */ disconnectedCallback(): void; /** @internal */ focus(options?: FocusOptions): void; /** @internal */ blur(): void; /** @internal */ click(): void; private _handleInput; private _handleChange; private _handlePlaceholderIconSlotChange; private _handleDrop; private _handleActivationClick; private _hasError; /** @internal */ [getFormValue](): string; /** @internal */ [getFormState](): string; /** @internal */ formResetCallback(): void; /** @internal */ [createValidator](): FileInputValidator; /** * Re-announces the field's error supporting text to screen readers. * * Error text announces to screen readers anytime it is visible and changes. * Use the method to re-announce the message when the text has not changed, * but announcement is still needed (such as for `reportValidity()`). */ private _reannounceError; /** @internal */ formDisabledCallback(disabled: boolean): void; /** @internal */ [getValidityAnchor](): null; /** @internal */ [onReportValidity](invalidEvent: Event | null): void; private _hasValidLabel; private _logErrors; /** * Reset the text field to its default value. */ reset(): void; private _getErrorText; private _getSupportingOrErrorText; private get _isLoading(); private get _isInteractable(); private get _shouldShowOverlay(); private _handleClick; private _handleClear; private _handleRetry; private _renderHelperText; private _renderLabel; private _renderPreview; private _renderLoadingState; private _renderRetry; private _renderErrorState; private _renderEmptyState; private _preventDragMove; private _renderOverlay; private _renderOverlayContent; private _renderClearIcon; protected render(): TemplateResult; } export {};