/** * Centralized TypeScript types for accessibility and form attributes * No more magic strings or numbers! */ /** * HTML5 autocomplete attribute values * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete */ export type AutocompleteValue = 'off' | 'on' | 'name' | 'honorific-prefix' | 'given-name' | 'additional-name' | 'family-name' | 'honorific-suffix' | 'nickname' | 'email' | 'username' | 'new-password' | 'current-password' | 'one-time-code' | 'organization-title' | 'organization' | 'street-address' | 'address-line1' | 'address-line2' | 'address-line3' | 'address-level4' | 'address-level3' | 'address-level2' | 'address-level1' | 'country' | 'country-name' | 'postal-code' | 'cc-name' | 'cc-given-name' | 'cc-additional-name' | 'cc-family-name' | 'cc-number' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-csc' | 'cc-type' | 'transaction-currency' | 'transaction-amount' | 'language' | 'bday' | 'bday-day' | 'bday-month' | 'bday-year' | 'sex' | 'url' | 'photo'; /** * HTML input types */ export type InputType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search'; /** * HTML inputmode attribute values * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode */ export type InputMode = 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'; /** * HTML button types */ export type ButtonType = 'button' | 'submit' | 'reset'; /** * Form encoding types */ export type FormEncType = 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain'; /** * Form method types */ export type FormMethod = 'post' | 'get' | 'dialog'; /** * Form target types */ export type FormTarget = '_blank' | '_self' | '_parent' | '_top' | string; /** Source of truth for ARIA attribute value types */ type AriaAttrs = import('svelte/elements').AriaAttributes; type AriaAttrValue = NonNullable; /** ARIA boolean values (can be string or boolean per ARIA spec) */ export type AriaBoolean = AriaAttrValue<'aria-expanded'>; /** ARIA tristate values (for checkboxes, etc.) */ export type AriaTristate = AriaAttrValue<'aria-pressed'>; /** ARIA haspopup values */ export type AriaHaspopup = AriaAttrValue<'aria-haspopup'>; /** ARIA live region values */ export type AriaLive = AriaAttrValue<'aria-live'>; /** ARIA current values */ export type AriaCurrent = AriaAttrValue<'aria-current'>; /** ARIA relevant tokens */ export type AriaRelevant = AriaAttrValue<'aria-relevant'>; /** ARIA orientation values */ export type AriaOrientation = AriaAttrValue<'aria-orientation'>; /** * Common ID reference type */ export type IdReference = string; /** * Direction type for arrow keys */ export type Direction = 'up' | 'down' | 'left' | 'right'; /** * Helper type to normalize ARIA boolean values * Converts string literals to actual booleans */ export type NormalizedAriaBoolean = T extends 'true' | 'false' ? boolean : T; /** * Helper to normalize ARIA tristate values */ export type NormalizedAriaTristate = T extends 'true' | 'false' | 'mixed' ? boolean | 'mixed' : T; /** * Utility constants for common values */ export declare const CONSTANTS: { /** Default autocomplete values for common form fields */ readonly AUTOCOMPLETE: { readonly EMAIL: "email"; readonly USERNAME: "username"; readonly PASSWORD: "current-password"; readonly NEW_PASSWORD: "new-password"; readonly NAME: "name"; readonly FIRST_NAME: "given-name"; readonly LAST_NAME: "family-name"; readonly PHONE: "tel"; readonly POSTAL_CODE: "postal-code"; }; /** Common button types */ readonly BUTTON_TYPE: { readonly BUTTON: "button"; readonly SUBMIT: "submit"; readonly RESET: "reset"; }; /** Common input types */ readonly INPUT_TYPE: { readonly TEXT: "text"; readonly EMAIL: "email"; readonly PASSWORD: "password"; readonly NUMBER: "number"; readonly TEL: "tel"; readonly URL: "url"; readonly SEARCH: "search"; }; /** Common input modes */ readonly INPUT_MODE: { readonly NONE: "none"; readonly TEXT: "text"; readonly TEL: "tel"; readonly URL: "url"; readonly EMAIL: "email"; readonly NUMERIC: "numeric"; readonly DECIMAL: "decimal"; readonly SEARCH: "search"; }; /** Form encoding types */ readonly FORM_ENCTYPE: { readonly URLENCODED: "application/x-www-form-urlencoded"; readonly MULTIPART: "multipart/form-data"; readonly TEXT: "text/plain"; }; /** Form method types */ readonly FORM_METHOD: { readonly POST: "post"; readonly GET: "get"; readonly DIALOG: "dialog"; }; /** Form target types */ readonly FORM_TARGET: { readonly BLANK: "_blank"; readonly SELF: "_self"; readonly PARENT: "_parent"; readonly TOP: "_top"; }; /** ARIA live values */ readonly ARIA_LIVE: { readonly POLITE: "polite"; readonly ASSERTIVE: "assertive"; readonly OFF: "off"; }; /** ARIA orientation values */ readonly ARIA_ORIENTATION: { readonly HORIZONTAL: "horizontal"; readonly VERTICAL: "vertical"; }; /** ARIA boolean values */ readonly ARIA_BOOLEAN: { readonly TRUE: "true"; readonly FALSE: "false"; }; /** ARIA tristate values */ readonly ARIA_TRISTATE: { readonly TRUE: "true"; readonly FALSE: "false"; readonly MIXED: "mixed"; }; }; /** * Type helper to extract values from constants object */ export type ConstValue = T extends { [K: string]: infer V; } ? V : never; /** * Common form field configuration types */ export interface FormFieldConfig { /** Field identifier */ id?: string; /** Field name for form submission */ name?: string; /** Whether the field is required */ required?: boolean; /** Whether the field is disabled */ disabled?: boolean; /** Whether the field is read-only */ readonly?: boolean; /** Field label */ label?: string; /** Field description/help text */ description?: string; /** Error message */ error?: string; } /** * Accessible label configuration */ export interface LabelConfig { /** Direct label for screen readers */ label?: string; /** ID of element that labels this component */ labelledby?: string; /** ID of element that describes this component */ describedby?: string; } /** * Validation state configuration */ export interface ValidationConfig { /** Whether the value is invalid */ invalid?: boolean; /** Whether the field is required */ required?: boolean; /** ID of element containing error message */ errormessage?: string; } /** * Interactive state configuration */ export interface InteractiveStateConfig { /** Toggle button pressed state */ pressed?: boolean | 'mixed'; /** Expanded/collapsed state */ expanded?: boolean; /** Checkbox/switch checked state */ checked?: boolean | 'mixed'; /** Listbox/tab/option selected state */ selected?: AriaBoolean; /** Disabled state */ disabled?: boolean; /** Busy/loading state */ busy?: boolean; /** Current item within container (nav/breadcrumb/stepper) */ current?: AriaCurrent; } /** * Widget-specific configuration */ export interface WidgetConfig { /** Element that this controls */ controls?: string; /** Popup behavior */ haspopup?: AriaHaspopup; /** Current value within a range */ valuenow?: number; /** Text representation of value */ valuetext?: string; /** Minimum value */ valuemin?: number; /** Maximum value */ valuemax?: number; /** Live region behavior */ live?: AriaLive; /** Element ID that receives focus */ activedescendant?: string; /** Current position in a list */ posinset?: number; /** Total items in a list */ setsize?: number; /** Heading level */ level?: number; /** Orientation */ orientation?: AriaOrientation; } export {};