# KptInput (kpt-input) The Koncept UI text field, integrated with Angular Signal Forms. It implements `FormValueControl` - bind it with the `FormField` directive (`@angular/forms/signals`). No `ControlValueAccessor`. Import: `import { KptInput } from '@konce-pt/angular';` ## Selector `kpt-input` ## Usage with Signal Forms import { form, FormField, required, email } from '@angular/forms/signals'; model = signal({ email: '' }); loginForm = form(this.model, (p) => { required(p.email, { message: 'E-mail is required' }); email(p.email, { message: 'Enter a valid e-mail address' }); }); // template (imports: [KptInput, FormField, FormRoot, KptButton])
Sign in `[formRoot]` sets `novalidate` and calls `submit()` on its own; `submit()` does `markAsTouched()` on its own. Do not gate validators with `when: state.touched()` - it breaks `valid()`. The full flow: the `## A form from scratch (Signal Forms)` section in the root llms.txt. ## Presentational inputs - `type`: 'text'|'email'|'password'|'number'|'search'|'tel'|'url'|'time' (default 'text') - `placeholder`: string - `id`: string - lands on the inner `` (for `label[for]`); the host does not carry it - `ariaLabel`: string | null - `autocomplete`: string | null - a hint for the browser and the password manager (e.g. `email`, `username`, `one-time-code`); without it autofill does not work - `clearable`: boolean (default: `true` only for `type="search"`) - a clear button, see "Clear button" - `icon`: string - a registry icon at the start of the field (`search`, `mail`...). Decorative: the field's name comes from the label or the aria label, so the icon stays out of the accessibility tree; a click on it lands in the field ## State bound automatically by FormField `value` (model, required), `disabled`, `readonly`, `required`, `invalid`, `errors`, `touched`; the `touch` output (emitted on blur). Do not set them by hand when used with a form. ## Label and description `id` goes to the native field - the host never carries it; without one it is generated. Inside `kpt-form-field` the control links itself: the wrapper's `label[for]` points at it and the hint or error is added to `aria-describedby`, so `controlId` is not needed. Without a wrapper, name it with `ariaLabel`. ## Clear button `type="search"` gets a clear button at the end of the field as soon as it has a value; `clearable` turns it on for any other type, `clearable="false"` turns it off. The browser's own "x" (`::-webkit-search-cancel-button`) is always hidden - Chromium and Safari draw it differently and Firefox not at all. The button is hidden while the field is empty, disabled or read-only. Clearing dispatches a real `input` event, so the value goes through the same path as typed text, and the focus stays in the field. The button is `tabindex="-1"` (like the `KptInputNumber` steppers); from the keyboard `Escape` clears a filled field and stops the event, so the first `Escape` does not close the dialog the field sits in. Its name comes from `input.clear` in the dictionary. The host gets `data-clear` while the button is visible. ## Tokens `--kpt-form-field-{bg,text,placeholder,border,border-hover,border-focus,border-error,radius}`. ## Accessibility - `aria-invalid="true"` only once the field is invalid **and** touched (`blur`) - a fresh, empty form is not painted red. - `aria-required="true"` with `required` - deliberately not the native `required` attribute, which would block the submit event and run browser validation alongside Signal Forms. - Error messages are usually rendered by `kpt-form-field` (`role="alert"`). ## Dictation - Dictation (`speech*` below) needs `provideKptSpeech()` in the app - see `kpt-speech-button`. - `speech`: boolean = false - a microphone at the end of the field (`kpt-speech-button`, Web Speech API). Without browser support it is not shown and the field keeps its normal padding. - `speechLang`: string | null - BCP 47 tag; without it from `KptI18n.locale`. - `speechColor`: `'primary' | 'danger' | 'success' | 'warning' | 'info'` = `'primary'` - colour of "stop" and the wave while listening. - `speechMode`: `'insert' | 'append' | 'replace'` = `'insert'`. `replace` clears the field the moment the microphone is clicked (undoable with Ctrl+Z) and stops after one utterance - the search pattern. Interim words are visible in the field but never reach the model; final text enters through the field's `(input)` like typed text, so `[formField]` validates whole words only.