import type { Component, Snippet } from 'svelte'; import type { HTMLInputAttributes, HTMLTextareaAttributes } from 'svelte/elements'; import type { ValidationContext, ValidationResult } from '../../utils/validation'; export type InputValidator = (context: ValidationContext) => ValidationResult; type InputType = | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'image' | 'month' | 'number' | 'password' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week'; type FieldProps = { /** Generated internally for the label association. */ id?: never; /** Field label, a string or Svelte snippet. */ label: string | Snippet; /** Description shown below the field, a string or Svelte snippet. */ description?: string | Snippet; /** Configuration key and HTML name attribute. */ name?: string; /** Set the field as required. */ required?: boolean; /** Disables the field. */ disabled?: boolean; /** Prevents editing while keeping the field focusable. */ readonly?: boolean; /** Shows or hides the field without destroying it. */ show?: boolean; /** CSS class added to the form-group wrapper. */ class?: string; /** Field value. */ value?: string | number; /** Callback for the native input event with the updated value. */ onInput?: (value: string | number, event: Event) => void | Promise; /** Callback for the native change event with the updated value. */ onChange?: (value: string | number, event: Event) => void | Promise; /** Custom validator. */ validate?: InputValidator; /** Content rendered after the field and validation message. */ children?: Snippet; /** Type of the input, default is 'text'. */ type?: InputType; }; type InputProps = Omit< HTMLInputAttributes, keyof FieldProps | 'oninput' | 'onchange' | 'aria-describedby' | 'aria-invalid' > export type Props = FieldProps & InputProps; /** * An input component. * See [Readme](https://docs.soleil.se/packages/config-svelte/components/input/). */ declare const InputField: Component; export default InputField;