import { FormControl } from '../form-control'; /** * This control only accepts a subset of input types */ export type DatacomInputType = 'text' | 'number' | 'password' | 'tel' | 'time' | 'url' | 'week' | 'month' | 'email'; /** * Display indicator. This has an explicit 'none' so the indicator * can be removed without having to remove the html attribute (or set it empty string). */ export type IndicatorType = 'none' | 'working' | 'done'; /** * Datacom Input field * * The control is scoped rather than shadow so the input field can participate in a form submit. * * @see https://brandhub.datacom.com/d/fjZSq4WewHBg/components#/components/button */ export declare class DatacomInput implements FormControl { private inputElement; private formElement; /** * HTML element input properties */ name: string; value?: string; type: DatacomInputType; placeholder?: string; disabled?: boolean; maxlength?: number; minlength?: number; readonly?: boolean; required?: boolean; form?: string; formaction?: string; formenctype?: string; formmethod?: string; formnovalidate?: boolean; formtarget?: string; pattern?: string; min?: number; max?: number; step?: number; inputmode?: string; size?: number; title: string; /** * Optional label for control. * This can be omitted if the host element has a text children. */ label?: string; /** * Error message to display in the case of input validity checks * or explicitly with 'valid' property */ message?: string; isValid?: boolean; /** * Optional help text */ help?: string; /** * Feedback indicator */ indicator?: IndicatorType; /** * Automatically show error state if invalid on form submit */ autoValidate?: boolean; /** * Error mutable state will re-render the control to display error message, icon and focus border */ isInError: boolean; /** * Editing mutable state will re-render the control to display input element */ isEditing: boolean; /** * The component is 'dirty' if it has been touched by user input * * @see onInput */ private isDirty; /** * Emit changed event when input changes. This relays up the 'input' event, but with * the control's current value rather than the input value. */ private changed; /** * Random id used by label to associate with the input control. * * This is randomly generated as it cannot be coded to a known value as all instances * on the page would have the same value. */ private inputId; /** * Force validation on the form control to display any error messages * * @returns boolean */ validate(): Promise; /** * Check if the control is valid */ checkValidity(): Promise; /** * Switch the control to edit mode if it is not already editing. */ edit(): Promise; /** * Entering the control switches to edit mode */ onFocus(): void; /** * Capture input event and reemit a custom 'changed' event with the new control value */ onInput(): void; /** * Leaving the input field: * - switches to view mode * - validates the control and displays error message */ onBlur(event: FocusEvent): void; /** * Capture input element reference on mount * * @param el */ private setInputElementRef; /** * Watch for form submit and prevent if the input is invalid * * @param event */ onFormSubmit: (event: SubmitEvent) => void; /** * When the component loads for the first time find the nearest form * and watch for submit if autoValidate is true */ componentDidLoad(): void; /** * When removed from the DOM, remove any event listeners */ disconnectedCallback(): void; render(): any; }