# KptInputNumber (kpt-input-number) A numeric field with stepper arrows on Signal Forms. The value is number | null. `showButtons="false"` gives the arrow-less variant - for "from-to" ranges. Import: `import { KptInputNumber } from '@konce-pt/angular';` ## Inputs / model - `value`: model (or `formField`) - `min`/`max`: number | undefined; `step`: number (default 1). Under `[formField]` do NOT bind the bounds - they are declared by `min()`/`max()` in `form()`, and `FormField` injects them into these inputs itself; `[min]`/`[max]` next to `[formField]` is a compilation error (FORM_FIELD_UNSUPPORTED_BINDING). Bind them directly only together with `[(value)]`. - `suffix`: string (e.g. ' %'); `placeholder`: string - `showButtons`: boolean (default `true`) - `false` hides the `-`/`+` arrows; the field content then aligns left, as in `kpt-input` (the `.kpt-input-number--plain` modifier) - `disabled`/`readonly`/`invalid`/`touched`: boolean; `touch`: output. `readonly` (also from `readonly()` in the schema) leaves the value selectable but blocks typing, the arrows and the buttons (`aria-readonly`) ## Example ## A "from-to" range (cross-field validation) Two separate form fields; the "to >= from" rule is attached through `validateTree` on the root. The error is aimed at a specific field with the `fieldTree` property - otherwise it would land on the form and would not show up under any control. import { form, max, min, validateTree } from '@angular/forms/signals'; model = signal({ priceFrom: null as number | null, priceTo: null as number | null }); rangeForm = form(this.model, (path) => { min(path.priceFrom, 0, { message: 'The value cannot be negative' }); max(path.priceFrom, 9999, { message: 'The value cannot exceed 9999' }); min(path.priceTo, 0, { message: 'The value cannot be negative' }); max(path.priceTo, 9999, { message: 'The value cannot exceed 9999' }); validateTree(path, (ctx) => { const from = ctx.valueOf(path.priceFrom); const to = ctx.valueOf(path.priceTo); if (from === null || to === null || from <= to) return null; return { kind: 'range', message: 'The "to" value cannot be lower than "from"', fieldTree: ctx.fieldTreeOf(path.priceTo), // the error lands on the "to" field }; }); }); // template - two columns from md up (utility classes from @konce-pt/grid)
`ctx.valueOf(path.x)` reads another field's value, `ctx.fieldTreeOf(path.x)` points at the field the error belongs to. Messages are supplied through `errorFor()` with a `touched()` gate - do not gate the validators. The full submit flow: `## A form from scratch (Signal Forms)` in the root llms.txt. ## Keyboard The field is `role="spinbutton"` with `aria-valuemin`/`aria-valuemax`/`aria-valuenow` (and `aria-valuetext` with the `suffix`, "5 pcs"). `ArrowUp`/`ArrowDown` change the value by `step`, `PageUp`/`PageDown` by ten steps; stepping is rounded to the precision of `step` or of the current value, whichever is finer (`1.25` + 1 gives `2.25`, not `2`). Only a plain decimal is accepted while typing - `0x1A`, `1e3` and `Infinity` are ignored. A typed value is **not** clamped while typing ("150" with `max` 99 stays "150", so the form's `max()` can report it) - it is clamped on blur. The `-`/`+` buttons sit outside the Tab order and do not take focus from the field, so focus never drops to `` when a button goes disabled at a limit. ## Screen reader and keyboard The value is shown in the active locale's notation (PL `12,5`), without thousands separators - the field accepts both a dot and a comma, and digit grouping would clash with what the user types. ## 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`. New: `id`, `ariaLabel`, `required` and `aria-invalid` on the field. ## Tokens The field `--kpt-form-field-*`; the buttons `--kpt-color-muted`.