import React from "react"; import { XmFileInput as XmFileInputElement, CustomEvent, } from "../lit/components/file-input/index.js"; /** * A generic type for strongly typing custom events with their targets * @template T - The type of the event target (extends EventTarget) * @template D - The type of the detail payload for the custom event */ type TypedEvent = E & { target: T; }; /** `XmFileInput` component event */ export type XmFileInputElementEvent = TypedEvent< XmFileInputElement, E >; export type { XmFileInputElement, CustomEvent }; export interface XmFileInputProps extends Pick< React.AllHTMLAttributes, | "children" | "dir" | "hidden" | "id" | "lang" | "slot" | "style" | "title" | "translate" | "onClick" | "onFocus" | "onBlur" > { /** Allow selecting more than one file. */ multiple?: boolean; /** undefined */ required?: boolean; /** undefined */ disabled?: boolean; /** undefined */ readOnly?: boolean; /** undefined */ loading?: boolean; /** INITIAL checked for toggle subclasses; mapped from attribute `checked`. */ initialChecked?: boolean; /** Native accept filter (e.g. ".yml,.json,image/*"). */ accept?: XmFileInputElement["accept"]; /** undefined */ label?: XmFileInputElement["label"]; /** undefined */ helper?: XmFileInputElement["helper"]; /** Severity copy. Non-empty ⇒ the field is in error (icon + copy, never color). */ error?: XmFileInputElement["error"]; /** undefined */ size?: XmFileInputElement["size"]; /** Form-control name — mirrors native . */ name?: XmFileInputElement["name"]; /** INITIAL value (uncontrolled-first, AD-6): the `value` attribute seeds the live state once, then never overrides user input. Mapped from attribute `value` so authors write ``. */ initialValue?: XmFileInputElement["initialValue"]; /** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */ className?: string; /** Contains a space-separated list of the part names of the element that should be exposed on the host element. */ exportparts?: string; /** Used for labels to link them with their inputs (using input id). */ htmlFor?: string; /** Used to help React identify which items have changed, are added, or are removed within a list. */ key?: number | string; /** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */ part?: string; /** A mutable ref object whose `.current` property is initialized to the passed argument (`initialValue`). The returned object will persist for the full lifetime of the component. */ ref?: React.Ref; /** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */ tabIndex?: number; /** Public read contract (AD-6a) — the selected files. */ files?: XmFileInputElement["files"]; /** Fired on commit with the new value in `detail`. */ onChange?: (event: XmFileInputElementEvent) => void; /** Fired on each edit with the current value in `detail` (inherited by every field). */ onInput?: (event: XmFileInputElementEvent) => void; } /** * * * ## Attributes & Properties * * Component attributes and properties that can be applied to the element or by using JavaScript. * * - `accept`: Native accept filter (e.g. ".yml,.json,image/*"). * - `multiple`: Allow selecting more than one file. * - `label`: undefined * - `helper`: undefined * - `error`: Severity copy. Non-empty ⇒ the field is in error (icon + copy, never color). * - `size`: undefined * - `required`: undefined * - `disabled`: undefined * - `readonly`/`readOnly`: undefined * - `loading`: undefined * - `name`: Form-control name — mirrors native . * - `value`/`initialValue`: INITIAL value (uncontrolled-first, AD-6): the `value` attribute seeds the * live state once, then never overrides user input. Mapped from attribute * `value` so authors write ``. * - `checked`/`initialChecked`: INITIAL checked for toggle subclasses; mapped from attribute `checked`. * - `files`: Public read contract (AD-6a) — the selected files. (property only) (readonly) * - `readonly`: undefined (property only) * - `value`: Programmatic reset support — setting `value` after first paint updates live state. (property only) * - `checked`: Public read contract for toggle subclasses (AD-6a). (property only) * * ## Events * * Events that will be emitted by the component. * * - `change`: Fired on commit with the new value in `detail`. * - `input`: Fired on each edit with the current value in `detail` (inherited by every field). * * ## Methods * * Methods that can be called to access component functionality. * * - `setFormDisabled(disabled: boolean) => void`: Down-propagation hook: xm-form (Story 2.10) sets this; it OR's with the * field's own disabled and can never re-enable a self-disabled field. */ export const XmFileInput: React.ForwardRefExoticComponent;