diff --git a/Documentation/CommandForm/number-input-field.md b/Documentation/CommandForm/number-input-field.md new file mode 100644 index 00000000..4c3a3674 --- /dev/null +++ b/Documentation/CommandForm/number-input-field.md @@ -0,0 +1,31 @@ +# NumberInputField + +`NumberInputField` binds the standalone locale-aware [`NumberInput`](../Common/number-input.md) to a non-null number property in an Arc `CommandForm`. + +```tsx +import { CommandDialog } from '@cratis/components/CommandDialog'; +import { NumberInputField } from '@cratis/components/CommandForm'; +import { UpdateSample } from './UpdateSample'; + + + + value={(command) => command.amount} + title='Amount' + required + min={0} + step={0.01} + minimumFractionDigits={2} + maximumFractionDigits={2} + suffix='kg' + /> +; +``` + +The adapter does not parse or format a second time. It reuses `NumberInput` and adds only CommandForm binding, title/error association, required-state propagation, blur validation, and the non-null command policy: + +- the command default is `0`; +- clearing the nullable edit state writes `0` to the command property; +- extracted `null`, `undefined`, or non-finite values become `0`; +- all locale, grouping, fraction, range, step, adornment, callback, part, and token behavior belongs to `NumberInput`. + +Use [`NumberField`](number-field.md) instead when the native `input[type=number]` behavior and its clear-to-zero contract are sufficient. The existing native field remains the smaller surface and does not add locale grouping, adornments, or a separate commit callback. diff --git a/Documentation/CommandForm/toc.yml b/Documentation/CommandForm/toc.yml index e192c4a4..bd3697fc 100644 --- a/Documentation/CommandForm/toc.yml +++ b/Documentation/CommandForm/toc.yml @@ -18,6 +18,8 @@ href: multi-select-field.md - name: NumberField href: number-field.md +- name: NumberInputField + href: number-input-field.md - name: PasswordField href: password-field.md - name: RadioButtonField diff --git a/Documentation/Common/basic-controls.md b/Documentation/Common/basic-controls.md index 07e7941d..90e8620c 100644 --- a/Documentation/Common/basic-controls.md +++ b/Documentation/Common/basic-controls.md @@ -10,6 +10,7 @@ import { Button, Checkbox, IconButton, + NumberInput, Radio, Surface, Switch, @@ -25,6 +26,7 @@ import { onChange={(value) => console.log(value)} />