entasis 0.13.5 → 0.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/components/Address/Address.svelte +44 -0
  2. package/dist/components/Address/Address.svelte.d.ts +4 -0
  3. package/dist/components/Address/address.d.ts +99 -0
  4. package/dist/components/Address/address.google.d.ts +89 -0
  5. package/dist/components/Address/address.google.fixtures.json +808 -0
  6. package/dist/components/Address/address.google.js +184 -0
  7. package/dist/components/Address/address.js +109 -0
  8. package/dist/components/Address/address.mcp.d.ts +1 -0
  9. package/dist/components/Address/address.mcp.js +100 -0
  10. package/dist/components/Address/address.props.d.ts +26 -0
  11. package/dist/components/Address/address.props.js +1 -0
  12. package/dist/components/Address/address.provider.d.ts +19 -0
  13. package/dist/components/Address/address.provider.js +69 -0
  14. package/dist/components/Address/address.theme.d.ts +63 -0
  15. package/dist/components/Address/address.theme.js +42 -0
  16. package/dist/components/Address/index.d.ts +6 -0
  17. package/dist/components/Address/index.js +5 -0
  18. package/dist/components/Form/AddressInput/AddressInput.svelte +482 -0
  19. package/dist/components/Form/AddressInput/AddressInput.svelte.d.ts +4 -0
  20. package/dist/components/Form/AddressInput/addressInput.mcp.d.ts +1 -0
  21. package/dist/components/Form/AddressInput/addressInput.mcp.js +110 -0
  22. package/dist/components/Form/AddressInput/addressInput.props.d.ts +72 -0
  23. package/dist/components/Form/AddressInput/addressInput.props.js +1 -0
  24. package/dist/components/Form/AddressInput/addressInput.theme.d.ts +63 -0
  25. package/dist/components/Form/AddressInput/addressInput.theme.js +55 -0
  26. package/dist/components/Form/AddressInput/index.d.ts +3 -0
  27. package/dist/components/Form/AddressInput/index.js +2 -0
  28. package/dist/components/Form/Field/field.d.ts +5 -2
  29. package/dist/components/Form/Field/field.state.svelte.js +4 -0
  30. package/dist/components/Form/Field/index.d.ts +1 -1
  31. package/dist/components/Form/Field/schemas.js +8 -0
  32. package/dist/components/Form/Form/FormInputRenderer.svelte +6 -0
  33. package/dist/components/Form/Form/form.d.ts +6 -0
  34. package/dist/components/Form/Form/form.mcp.d.ts +1 -1
  35. package/dist/components/Form/Form/form.mcp.js +1 -1
  36. package/dist/components/Form/Form/form.state.svelte.d.ts +142 -11
  37. package/dist/components/Form/Form/form.state.svelte.js +2 -0
  38. package/dist/components/Form/Form/visibility.d.ts +186 -20
  39. package/dist/components/Form/MultiStepForm/multiStepForm.state.svelte.d.ts +136 -0
  40. package/dist/components/Form/SignatureInput/SignatureInput.svelte +327 -0
  41. package/dist/components/Form/SignatureInput/SignatureInput.svelte.d.ts +4 -0
  42. package/dist/components/Form/SignatureInput/index.d.ts +4 -0
  43. package/dist/components/Form/SignatureInput/index.js +2 -0
  44. package/dist/components/Form/SignatureInput/signatureInput.mcp.d.ts +1 -0
  45. package/dist/components/Form/SignatureInput/signatureInput.mcp.js +74 -0
  46. package/dist/components/Form/SignatureInput/signatureInput.props.d.ts +29 -0
  47. package/dist/components/Form/SignatureInput/signatureInput.props.js +1 -0
  48. package/dist/components/Form/SignatureInput/signatureInput.strokes.d.ts +77 -0
  49. package/dist/components/Form/SignatureInput/signatureInput.strokes.js +149 -0
  50. package/dist/components/Form/SignatureInput/signatureInput.theme.d.ts +99 -0
  51. package/dist/components/Form/SignatureInput/signatureInput.theme.js +70 -0
  52. package/dist/generated/componentAliases.d.ts +3 -0
  53. package/dist/generated/componentAliases.js +3 -0
  54. package/dist/generated/componentContract.d.ts +46 -1
  55. package/dist/generated/componentContract.js +113 -0
  56. package/dist/generated/componentMcpRegistry.js +6 -0
  57. package/dist/i18n/ar.js +18 -0
  58. package/dist/i18n/de.js +18 -0
  59. package/dist/i18n/en.d.ts +18 -0
  60. package/dist/i18n/en.js +18 -0
  61. package/dist/i18n/es.js +18 -0
  62. package/dist/i18n/fr.js +18 -0
  63. package/dist/i18n/ja.js +18 -0
  64. package/dist/i18n/pt.js +18 -0
  65. package/dist/i18n/zh.js +18 -0
  66. package/package.json +25 -1
@@ -0,0 +1,72 @@
1
+ import type { Messages } from '../../../i18n/en.js';
2
+ import type { WithAttachments } from '../../../types/props.js';
3
+ import type { Address, AddressField, AddressProvider } from '../../Address/address.js';
4
+ import type { InputProps } from '../Field/field.js';
5
+ import type { AddressInputThemeProps } from './addressInput.theme.js';
6
+ /** One part's settings in `fields`. */
7
+ export type AddressFieldConfig = {
8
+ /** The part. */
9
+ field: AddressField;
10
+ /** Share of its row, as a proportion of the other parts' widths. @default 1 */
11
+ width?: number;
12
+ /** Label, over the i18n catalog's. */
13
+ label?: string;
14
+ /** Hint in the empty input. The street line defaults to the search hint. */
15
+ placeholder?: string;
16
+ };
17
+ /** A part, by name or with its settings. */
18
+ export type AddressFieldItem = AddressField | AddressFieldConfig;
19
+ /** A row of the layout: one part, or several side by side. */
20
+ export type AddressFieldRow = AddressFieldItem | readonly AddressFieldItem[];
21
+ /**
22
+ * `fields`: one input per part, the street line searching as you type. `search`: one search
23
+ * input showing the chosen address on one line, with a button to edit the parts by hand.
24
+ */
25
+ export type AddressInputLayout = 'fields' | 'search';
26
+ export type AddressInputProps = WithAttachments<Omit<InputProps<'address'>, 'theme' | 'placeholder'> & {
27
+ /**
28
+ * Searches addresses as the street line is typed and fills every part from the chosen
29
+ * suggestion. Defaults to the provider `setAddressProvider` set for the app, else to Google
30
+ * Places through the app's `/api/places` route (served by `createGooglePlacesProxy` from
31
+ * `entasis/address`; without that route the search turns itself off). `null` turns the
32
+ * search off: the parts are typed by hand.
33
+ */
34
+ provider?: AddressProvider | null;
35
+ /**
36
+ * The parts the field shows and how they are laid out: one row per entry, a part on its own
37
+ * or several side by side in an array, each by name or with its settings (`{ field, width,
38
+ * label, placeholder }`). Widths share a row by proportion; a narrow field stacks every part.
39
+ * @default ['line1', 'line2', [{ field: 'postalCode', width: 1 }, { field: 'city', width: 2 }], 'country']
40
+ */
41
+ fields?: readonly AddressFieldRow[];
42
+ /**
43
+ * Parts a person may type in. Others show what the search filled, read-only. Defaults to
44
+ * every shown part.
45
+ */
46
+ editableFields?: readonly AddressField[];
47
+ /**
48
+ * Parts that must be filled once the address is started (or always, when `required`).
49
+ * Defaults to the shown parts except `line2` and `region` when `required` is set, and to
50
+ * none otherwise.
51
+ */
52
+ requiredFields?: readonly AddressField[];
53
+ /** ISO 3166-1 alpha-2 codes the search and the country list are limited to. */
54
+ countries?: readonly string[];
55
+ /** Country code an address starts in, until the search or the person picks another. */
56
+ defaultCountry?: string;
57
+ /** One input per part, or one search input. @default 'fields' */
58
+ layout?: AddressInputLayout;
59
+ /** Characters typed before the search runs. @default 3 */
60
+ minSearchLength?: number;
61
+ /**
62
+ * Hint in the search input (the street line, or the single input of `layout="search"`).
63
+ * Defaults to the i18n `addressSearchPlaceholder`.
64
+ */
65
+ placeholder?: string;
66
+ /** Called with the address a chosen suggestion resolved to, after the value changed. */
67
+ onResolve?: (address: Address) => void;
68
+ /** Per-instance translations merged over the global i18n catalog. */
69
+ i18n?: Partial<Messages>;
70
+ /** Theme overrides for the parts grid and the surrounding field. */
71
+ theme?: AddressInputThemeProps & InputProps<'address'>['theme'];
72
+ }>;
@@ -0,0 +1,63 @@
1
+ import { type InferComponentTheme } from '../../../utils/cva/index.js';
2
+ export declare const addressInputTheme: {
3
+ parts: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
4
+ grid: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
5
+ density: {
6
+ compact: string;
7
+ normal: string;
8
+ comfortable: string;
9
+ };
10
+ }> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
11
+ row: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
12
+ density: {
13
+ compact: string;
14
+ normal: string;
15
+ comfortable: string;
16
+ };
17
+ }> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
18
+ part: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
19
+ search: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
20
+ partErrors: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
21
+ };
22
+ export type AddressInputTheme = typeof addressInputTheme;
23
+ export type AddressInputThemeProps = InferComponentTheme<AddressInputTheme>;
24
+ export declare const setAddressInputTheme: (theme: InferComponentTheme<{
25
+ parts: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
26
+ grid: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
27
+ density: {
28
+ compact: string;
29
+ normal: string;
30
+ comfortable: string;
31
+ };
32
+ }> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
33
+ row: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
34
+ density: {
35
+ compact: string;
36
+ normal: string;
37
+ comfortable: string;
38
+ };
39
+ }> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
40
+ part: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
41
+ search: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
42
+ partErrors: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
43
+ }>) => void;
44
+ export declare const useAddressInputTheme: import("../../../utils/cva/theme.ts").UseComponentTheme<{
45
+ parts: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
46
+ grid: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
47
+ density: {
48
+ compact: string;
49
+ normal: string;
50
+ comfortable: string;
51
+ };
52
+ }> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
53
+ row: (props?: (import("../../../utils/cva/types.ts").CVAVariantSchema<{
54
+ density: {
55
+ compact: string;
56
+ normal: string;
57
+ comfortable: string;
58
+ };
59
+ }> & import("../../../utils/cva/types.ts").CVAClassProp) | undefined) => string;
60
+ part: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
61
+ search: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
62
+ partErrors: (props?: import("../../../utils/cva/types.ts").CVAClassProp | undefined) => string;
63
+ }>;
@@ -0,0 +1,55 @@
1
+ import { cva, setComponentTheme, useComponentTheme } from '../../../utils/cva/index.js';
2
+ const defaultParts = cva({
3
+ base: '@container w-full min-w-0'
4
+ });
5
+ // The rows, one under the other.
6
+ const defaultGrid = cva({
7
+ base: 'flex w-full min-w-0 flex-col',
8
+ variants: {
9
+ density: {
10
+ compact: 'gap-sm',
11
+ normal: 'gap-md',
12
+ comfortable: 'gap-lg'
13
+ }
14
+ },
15
+ defaultVariants: {
16
+ density: 'normal'
17
+ }
18
+ });
19
+ // One row: its parts side by side by their widths (`--address-row-columns`) from 28rem of the
20
+ // field's width, stacked below.
21
+ const defaultRow = cva({
22
+ base: 'grid w-full min-w-0 grid-cols-1 @md:grid-cols-[var(--address-row-columns)]',
23
+ variants: {
24
+ density: {
25
+ compact: 'gap-sm',
26
+ normal: 'gap-md',
27
+ comfortable: 'gap-lg'
28
+ }
29
+ },
30
+ defaultVariants: {
31
+ density: 'normal'
32
+ }
33
+ });
34
+ const defaultPart = cva({
35
+ base: 'min-w-0'
36
+ });
37
+ // The search input takes the field's width; the "enter by hand" link keeps to its start.
38
+ const defaultSearch = cva({
39
+ base: 'flex w-full min-w-0 flex-col gap-xs [&>button]:self-start'
40
+ });
41
+ // A part's own error block: its message describes the part's input, but the address announces
42
+ // it, so the block stays out of sight and out of the accessibility tree.
43
+ const defaultPartErrors = cva({
44
+ base: 'hidden'
45
+ });
46
+ export const addressInputTheme = {
47
+ parts: defaultParts,
48
+ grid: defaultGrid,
49
+ row: defaultRow,
50
+ part: defaultPart,
51
+ search: defaultSearch,
52
+ partErrors: defaultPartErrors
53
+ };
54
+ export const setAddressInputTheme = setComponentTheme('address-input');
55
+ export const useAddressInputTheme = useComponentTheme('address-input', addressInputTheme);
@@ -0,0 +1,3 @@
1
+ export { default as AddressInput } from './AddressInput.svelte';
2
+ export type { AddressFieldConfig, AddressFieldItem, AddressFieldRow, AddressInputLayout, AddressInputProps } from './addressInput.props.js';
3
+ export { addressInputTheme, setAddressInputTheme, useAddressInputTheme, type AddressInputTheme, type AddressInputThemeProps } from './addressInput.theme.js';
@@ -0,0 +1,2 @@
1
+ export { default as AddressInput } from './AddressInput.svelte';
2
+ export { addressInputTheme, setAddressInputTheme, useAddressInputTheme } from './addressInput.theme.js';
@@ -7,6 +7,7 @@ import type { FieldMessageOverrides } from './field.messages.js';
7
7
  import type { FieldThemeProps } from './field.theme.js';
8
8
  import type { Density, Sizes } from '../../../types/theme.js';
9
9
  import type { FormInputRegistry } from '../Form/form.js';
10
+ import type { Address } from '../../Address/address.js';
10
11
  export type KeyValuePair = {
11
12
  key: string;
12
13
  value: string;
@@ -16,6 +17,8 @@ export type RichTextInputType = 'rich-text';
16
17
  export type NumberInputType = 'number' | 'slider';
17
18
  export type RatingInputType = 'rating';
18
19
  export type VoiceInputType = 'voice';
20
+ export type SignatureInputType = 'signature';
21
+ export type AddressInputType = 'address';
19
22
  export type SliderRangeInputType = 'slider-range';
20
23
  export type TagInputType = 'tag';
21
24
  export type TagGroupInputType = 'tag-group';
@@ -38,7 +41,7 @@ export type FieldAttributes = Omit<HTMLAttributes<HTMLElement>, 'class' | 'id'>;
38
41
  * field label.
39
42
  */
40
43
  export type FieldButtonAttributes = Omit<HTMLButtonAttributes, 'class' | 'disabled' | 'form' | 'id' | 'name' | 'role' | 'type' | 'value' | 'aria-checked' | 'aria-disabled' | 'aria-readonly' | 'aria-required'>;
41
- export type InputType = FileInputType | SliderRangeInputType | DateInputType | ColorInputType | NumberInputType | RatingInputType | VoiceInputType | TimeInputType | TextInputType | RichTextInputType | BooleanInputType | MultipleChoiceInputType | TagInputType | TagGroupInputType | KeyValueInputType | PinInputType | SingleOptionInputType | CalendarInputType;
44
+ export type InputType = FileInputType | SliderRangeInputType | DateInputType | ColorInputType | NumberInputType | RatingInputType | VoiceInputType | SignatureInputType | AddressInputType | TimeInputType | TextInputType | RichTextInputType | BooleanInputType | MultipleChoiceInputType | TagInputType | TagGroupInputType | KeyValueInputType | PinInputType | SingleOptionInputType | CalendarInputType;
42
45
  /** Input types an app registered: the keys of its `FormInputRegistry` augmentation. */
43
46
  export type RegisteredInputType = Extract<keyof FormInputRegistry, string>;
44
47
  /** Every type a field can carry: the built-in inputs and the ones an app registered. */
@@ -46,7 +49,7 @@ export type FieldType = InputType | RegisteredInputType;
46
49
  type RegisteredInputValue<T extends RegisteredInputType> = FormInputRegistry[T] extends {
47
50
  value: infer Value;
48
51
  } ? Value : unknown;
49
- export type FieldValue<T extends FieldType> = T extends RegisteredInputType ? RegisteredInputValue<T> : T extends 'file' ? File : T extends 'files' ? File[] : T extends DateInputType ? Date : T extends SliderRangeInputType ? number[] : T extends NumberInputType ? number : T extends RatingInputType ? number : T extends VoiceInputType ? Blob : T extends TimeInputType ? number : T extends TextInputType ? string : T extends RichTextInputType ? string : T extends PinInputType ? string : T extends BooleanInputType ? boolean : T extends MultipleChoiceInputType ? string[] : T extends TagInputType ? string[] : T extends TagGroupInputType ? string | string[] | null : T extends KeyValueInputType ? KeyValuePair[] : T extends SingleOptionInputType ? string : T extends 'calendar' ? Date : T extends 'calendar-range' ? [Date | null, Date | null] : T extends ColorInputType ? string : never;
52
+ export type FieldValue<T extends FieldType> = T extends RegisteredInputType ? RegisteredInputValue<T> : T extends 'file' ? File : T extends 'files' ? File[] : T extends DateInputType ? Date : T extends SliderRangeInputType ? number[] : T extends NumberInputType ? number : T extends RatingInputType ? number : T extends VoiceInputType ? Blob : T extends SignatureInputType ? string : T extends AddressInputType ? Address : T extends TimeInputType ? number : T extends TextInputType ? string : T extends RichTextInputType ? string : T extends PinInputType ? string : T extends BooleanInputType ? boolean : T extends MultipleChoiceInputType ? string[] : T extends TagInputType ? string[] : T extends TagGroupInputType ? string | string[] | null : T extends KeyValueInputType ? KeyValuePair[] : T extends SingleOptionInputType ? string : T extends 'calendar' ? Date : T extends 'calendar-range' ? [Date | null, Date | null] : T extends ColorInputType ? string : never;
50
53
  export type InputProps<T extends FieldType> = WithSlot<{
51
54
  /** Form field name, used as the key when the input is part of a Form. */
52
55
  name?: string;
@@ -5,6 +5,7 @@ import { getFormInputDefinition, getRegisteredInputSchema } from '../Form/form.r
5
5
  import { getContext, onDestroy, setContext, untrack } from 'svelte';
6
6
  import { getFirstTabbable } from '../../../utils/focus.js';
7
7
  import { isEmptyValue, valuesEqual } from '../../../utils/values.js';
8
+ import { isAddressEmpty } from '../../Address/address.js';
8
9
  import { useI18nResolver } from '../../../i18n/context.svelte.js';
9
10
  import { describeFieldIssue, resolveFieldMessages } from './field.messages.js';
10
11
  const FIELD_GROUP_CONTEXT = Symbol('entasis:field-group');
@@ -527,6 +528,9 @@ export const createFieldState = (options) => {
527
528
  // A rating of zero stars is no rating.
528
529
  if (field.type === 'rating')
529
530
  return !value;
531
+ // An address with none of its parts filled is no address.
532
+ if (field.type === 'address')
533
+ return isAddressEmpty(value);
530
534
  return isEmptyValue(value);
531
535
  }
532
536
  function lengthMessage(value) {
@@ -7,4 +7,4 @@ export { schemas as fieldSchemas } from './schemas.js';
7
7
  export type { FieldControlAttributes, FieldState, FieldValidationResult, FieldValidatorResult, ValidationMode } from './field.state.svelte.js';
8
8
  export type { FieldMessageOverrides, FieldMessages } from './field.messages.js';
9
9
  export { fieldTheme, setFieldTheme, useFieldTheme, type FieldTheme, type FieldThemeProps } from './field.theme.js';
10
- export { fieldStructure, llmDescription, type BooleanInputType, type CalendarInputType, type ColorInputType, type DateInputType, type FieldAttributes, type FieldButtonAttributes, type FieldLabelPosition, type FieldProps, type FieldValue, type FileInputType, type InputProps, type InputType, type KeyValueInputType, type KeyValuePair, type MultipleChoiceInputType, type NumberInputType, type PinInputType, type RatingInputType, type RichTextInputType, type SingleOptionInputType, type SliderRangeInputType, type TagGroupInputType, type TagInputType, type TextInputType, type TimeInputType, type VoiceInputType } from './field.js';
10
+ export { fieldStructure, llmDescription, type BooleanInputType, type CalendarInputType, type ColorInputType, type DateInputType, type FieldAttributes, type FieldButtonAttributes, type FieldLabelPosition, type FieldProps, type FieldValue, type FileInputType, type InputProps, type InputType, type KeyValueInputType, type KeyValuePair, type MultipleChoiceInputType, type NumberInputType, type PinInputType, type RatingInputType, type RichTextInputType, type AddressInputType, type SignatureInputType, type SingleOptionInputType, type SliderRangeInputType, type TagGroupInputType, type TagInputType, type TextInputType, type TimeInputType, type VoiceInputType } from './field.js';
@@ -36,6 +36,10 @@ export const schemas = {
36
36
  rating: v.pipe(v.number(), v.minValue(0.5)),
37
37
  // Voice input type
38
38
  voice: v.instance(Blob),
39
+ // Signature input type: the exported image as a data URL
40
+ signature: v.pipe(v.string(), v.minLength(1)),
41
+ // Address input type: an object of parts (emptiness is checked by the field)
42
+ address: v.looseObject({}),
39
43
  // Tag input type
40
44
  tag: nonEmptyArray(v.string()),
41
45
  'tag-group': tagGroupValue,
@@ -85,6 +89,10 @@ export const schemas = {
85
89
  rating: optional(v.number()),
86
90
  // Voice input type
87
91
  voice: optional(v.instance(Blob)),
92
+ // Signature input type
93
+ signature: optional(emptyStringNull(v.string())),
94
+ // Address input type
95
+ address: optional(v.looseObject({})),
88
96
  // Tag input type
89
97
  tag: optional(emptyArrayNull(v.array(v.string()))),
90
98
  'tag-group': optional(v.union([emptyStringNull(v.string()), emptyArrayNull(v.array(v.string()))])),
@@ -2,6 +2,7 @@
2
2
  import type { Density, Sizes } from '../../../types/theme.js';
3
3
  import type { FieldLabelPosition } from '../Field/field.js';
4
4
  import RichTextInput from '../../RichTextInput/RichTextInput.svelte';
5
+ import AddressInput from '../AddressInput/AddressInput.svelte';
5
6
  import CalendarInput from '../Calendar/CalendarInput.svelte';
6
7
  import Checkbox from '../Checkbox/Checkbox.svelte';
7
8
  import CheckboxesInput from '../CheckboxesInput/CheckboxesInput.svelte';
@@ -19,6 +20,7 @@
19
20
  import RadioInput from '../RadioInput/RadioInput.svelte';
20
21
  import RatingInput from '../RatingInput/RatingInput.svelte';
21
22
  import Select from '../Select/Select.svelte';
23
+ import SignatureInput from '../SignatureInput/SignatureInput.svelte';
22
24
  import Slider from '../Slider/Slider.svelte';
23
25
  import Switch from '../Switch/Switch.svelte';
24
26
  import TagGroup from '../TagGroup/TagGroup.svelte';
@@ -67,6 +69,10 @@
67
69
  <RatingInput {...inputProps as FormInputProps<'rating'>} {name} />
68
70
  {:else if input.type === 'voice'}
69
71
  <VoiceInput {...inputProps as FormInputProps<'voice'>} {name} />
72
+ {:else if input.type === 'signature'}
73
+ <SignatureInput {...inputProps as FormInputProps<'signature'>} {name} />
74
+ {:else if input.type === 'address'}
75
+ <AddressInput {...inputProps as FormInputProps<'address'>} {name} />
70
76
  {:else if input.type === 'slider'}
71
77
  <Slider {...inputProps as FormInputProps<'slider'>} {name} />
72
78
  {:else if input.type === 'slider-range'}
@@ -4,6 +4,8 @@ import type { TextInputProps } from '../TextInput/textInput.props.js';
4
4
  import type { NumberInputProps } from '../NumberInput/numberInput.props.js';
5
5
  import type { RatingInputProps } from '../RatingInput/ratingInput.props.js';
6
6
  import type { VoiceInputProps } from '../VoiceInput/voiceInput.props.js';
7
+ import type { SignatureInputProps } from '../SignatureInput/signatureInput.props.js';
8
+ import type { AddressInputProps } from '../AddressInput/addressInput.props.js';
7
9
  import type { SliderProps } from '../Slider/slider.props.js';
8
10
  import type { TextAreaProps } from '../TextArea/textArea.props.js';
9
11
  import type { SelectProps } from '../Select/select.props.js';
@@ -92,6 +94,10 @@ type BaseFormFieldInput = ({
92
94
  } & RatingInputProps) | ({
93
95
  type: 'voice';
94
96
  } & VoiceInputProps) | ({
97
+ type: 'signature';
98
+ } & SignatureInputProps) | ({
99
+ type: 'address';
100
+ } & AddressInputProps) | ({
95
101
  type: 'slider';
96
102
  } & SliderProps) | ({
97
103
  type: 'slider-range';
@@ -1 +1 @@
1
- export declare const formDescription = "\n# Form\n\nForm renders configured entasis fields inside a div, owns their state and validation, and submits programmatically. It provides managed Enter-key navigation and submission, but not native form events, browser constraint validation, or FormData behavior. For a plain <form> (a SvelteKit form action), use the controls directly: each submits its name and value through hidden inputs, follows the form's reset, and accepts a form prop when it sits outside the form.\n\n## Basic usage\n\n```svelte\n<script lang=\"ts\">\n\timport {\n\t\tForm,\n\t\ttype FormState,\n\t\ttype InferFormValue,\n\t\ttype LiveFormValue\n\t} from 'entasis/form';\n\n\tconst inputs = {\n\t\tidentity: {\n\t\t\ttype: 'group',\n\t\t\tlabel: 'Identity',\n\t\t\tdescription: 'Core account details',\n\t\t\tcolumns: 2,\n\t\t\tinputs: {\n\t\t\t\tname: { type: 'text', label: 'Name', required: true },\n\t\t\t\temail: { type: 'email', label: 'Email', required: true }\n\t\t\t}\n\t\t}\n\t} as const;\n\n\tlet value = $state<LiveFormValue<typeof inputs>>({ name: 'Ada' });\n\tlet form = $state<FormState<typeof inputs>>();\n\tlet submitted = $state<InferFormValue<typeof inputs> | null>(null);\n</script>\n\n<Form\n\t{inputs}\n\tbind:value\n\tbind:form\n\tvariant=\"card\"\n\tlayout=\"horizontal\"\n\tsize=\"small\"\n\tdensity=\"normal\"\n\tactions={[\n\t\t{\n\t\t\tchildren: 'Save',\n\t\t\tonAction: (payload) => payload.submit()\n\t\t}\n\t]}\n\tonSubmit={(validatedValue) => {\n\t\tsubmitted = validatedValue;\n\t}}\n/>\n```\n\n## Props\n\n- **inputs** (required): ordered object keyed by entry name. Entries may be value-bearing fields, visual groups, action-button rows, or custom snippets. Only fields contribute keys to the live and validated values.\n- **value** (bindable): controlled partial live value. Visible mounted fields are published; hidden fields are omitted. A supplied top-level value takes precedence over an input's configured value.\n- **defaultValue**: initial partial live value when value is omitted.\n- **onValueChange**: called once when a user changes the visible live value. Parent value updates do not emit it.\n- **form** (bindable): the FormState instance.\n- **onSubmit**: called with the validated visible payload. Its return value is ignored; rejected promises propagate.\n- **size**: small, normal (default), or large. Controls Form typography and becomes the fallback size for fields and actions. An explicit field or action size takes precedence.\n- **density**: compact, normal (default), or comfortable. Controls gaps between the Form header, fields, footer, and actions independently from size.\n- **variant**: plain (default), sectioned, or card. All variants consume the shared Card typography. Plain remains transparent without separators. Sectioned stays transparent and adds edge-to-edge separators between the header, visible top-level fields or groups, and footer. Card adds the same separators inside the Card surface and inset; Card header/footer padding applies only to that variant. Separators do not appear between fields inside a group.\n- **layout**: vertical (default) or horizontal. Horizontal keeps one field per row and places labels to the left once each field is at least 32rem wide; fields remain stacked in narrower forms.\n- **actions**: optional array of Button props. Each action's onAction receives the live FormState, so a submit action calls form.submit(). Actions are disabled while the form is submitting; their own loading and disabled props are composed with that protection.\n- **validationMode**: submit (default), blur, or change. When a field validates by itself besides a submit: submit waits for the first submit attempt and then re-validates each edited field, blur validates when focus leaves the field, change validates on every accepted change. A field that shows an error always re-validates as it is edited. A field's own validationMode takes precedence, and mounting never validates.\n- **validationDebounce**: milliseconds an edit waits before the validation it triggers, so an async onValidate is not called on every keystroke. Submit and blur validate at once. A field's own validationDebounce takes precedence.\n- **errors**: errors from outside the form, for example a SvelteKit ActionData, keyed by field name with one message or a list of them. They show under their fields, survive validation, do not block a submit (the server re-checks), and clear when that field's value next changes. Changing the prop replaces the errors; the first errored field in render order is revealed.\n- **disabled**: disables every field, for example disabled={form.loading} while a submission runs. Disabled fields skip validation and, as in a native form, are left out of the submitted value. The root carries data-disabled. A disabled option inside an enabled radio or checkbox group is different: when selected it stays in that field's value, while a plain native <form> leaves it out of its submission.\n- **readOnly**: makes every field read-only. Values stay focusable, validated and submitted, but users cannot change them. The root carries data-readonly.\n- **class**: additional classes on the root div.\n- **theme**: Form theme overrides for root, header, title, description, group, group label/description/fields, top-level items, custom entries, footer, and actions. Global Card typography and section-rhythm changes flow into all Form variants before Form-specific overrides are composed; Card surface changes apply only to the card variant.\n\nThe **header**, **title**, **description**, **children**, and **footer** snippets each receive the FormState instance directly. No-argument snippets remain valid.\n\nField wrapper attributes and native control attributes have separate owners. Use fieldAttrs for the shared Field wrapper. Controls expose a typed bag for their actual native element, such as inputAttrs on TextInput, textareaAttrs on TextArea, and triggerAttrs on the custom Select's combobox button.\n\n## FormState\n\n- **value**: current visible partial value.\n- **loading**: true while a submission is pending: async validators first, then the handler.\n- **hasError**: true after validation fails or errors are set from outside; reset after successful validation.\n- **dirty**: true when any field differs from its initial value (null, an empty string and an empty list count as equal).\n- **touched**: true once focus has entered and left any field.\n- **validating**: true while an async onValidate of any field is pending.\n- **submitCount**: how many times the form was validated to submit.\n- **validate(options?)**: validates every visible, enabled field synchronously and returns the validated visible payload, or false after revealing the first invalid field. Disabled fields are skipped and left out of the payload. Pass { reveal: false } to check quietly: no scrolling, no focus, and the call does not count as a submit attempt. It does not wait for async validators.\n- **validateAsync(options?)**: like validate, and waits for async validators; returns a promise.\n- **validateField(name)**: validates one field now and returns whether it is valid. It neither scrolls nor focuses. A name that is not a visible field returns false; a disabled field skips validation and returns true; a field whose async validator is still running returns false, so use validateAsync to wait.\n- **submit()**: returns a promise of the validated visible payload, or false. It waits for pending async validators. Concurrent calls share the active promise.\n- **setErrors(errors)**: shows errors from outside the form under their fields, replacing those set before; setErrors({}) clears them. Call it from onSubmit with the server response. The first errored field in render order is revealed once the submission ends.\n- **reset(value?)**: restores every field to its initial value, or to value where it gives one, and makes that the new baseline. Errors, touched, dirty and the submit count clear, fields do not echo onValueChange, and the form's onValueChange runs once if the visible value changed. Conditional visibility is evaluated again.\n- **advanceFrom(field)**: moves on from a registered field as Enter does in a text field: the last navigable field submits, any other validates and focuses the next field when valid. Returns false when the field is hidden, disabled or not part of this form. Controls that own Enter themselves, such as checkboxes and radios, call it from their key handler and fall back to the native form otherwise.\n\n## Enter-key behavior\n\nOn an enabled, editable single-line input, Enter validates the current field. A valid field moves focus to the next visible enabled field, while an invalid field remains focused and displays its errors. Enter on a valid final navigable field calls form.submit(). Multiline editors and controls that already own Enter, such as selects and combobox menus, keep their native component behavior. A control that owns Enter can continue the flow with form.advanceFrom(field). Modified, repeated, and IME-composition Enter events are ignored.\n\n## Programmatic Dialog forms\n\nMount one Ask host near the application root, then call ask() from any client-side event. Both exports come from entasis/form:\n\n```svelte\n<script lang=\"ts\">\n\timport { Ask, ask } from 'entasis/form';\n\n\tconst inputs = {\n\t\tname: { type: 'text', label: 'Name', required: true },\n\t\temail: { type: 'email', label: 'Email', required: true }\n\t} as const;\n\n\tasync function editProfile() {\n\t\tconst outcome = await ask({\n\t\t\ttitle: 'Edit profile',\n\t\t\tdescription: 'Review the account details.',\n\t\t\tinputs,\n\t\t\tvalue: { name: 'Ada' },\n\t\t\tconfirm: 'Save',\n\t\t\tcancel: 'Cancel'\n\t\t});\n\n\t\tif (outcome.submitted) {\n\t\t\t// outcome.value is InferFormValue<typeof inputs>\n\t\t} else {\n\t\t\t// outcome.value is the partial, visible live value at cancellation\n\t\t}\n\t}\n</script>\n\n<Ask />\n```\n\nAskOptions accepts inputs, value, onSubmit, class, size, density, variant, layout, theme, validationMode, and validationDebounce with the same contracts as Form. Disabled fields are left out of the result. title is required for the Dialog's accessible name. confirm and cancel accept a string or Button presentation props plus text. Their click, loading, link, and native type behavior is owned by Ask. Set type on the mounted Ask host for its default Dialog type; a request's optional dialog object may override type and also accepts responsive, size, and scroll. With scroll 'inner' (the default) the form is the Dialog's only scrolling part: a form taller than the viewport scrolls inside its body (`data-slot=\"ask-body\"`) while the title, description and Confirm/Cancel row stay on screen, and the body keeps room around its fields so a focus ring is never clipped. With scroll 'outer' the whole card grows and the page behind it scrolls instead.\n\nValidation failures keep the Dialog open and focus the first invalid field. A successful submission resolves with the validated visible payload. Cancel, the close button, and Escape resolve with submitted: false and the current partial visible value. Outside-click and swipe dismissal are disabled. While submission is active, all close paths and actions are protected. Rejected onSubmit promises reject ask() after the Dialog closes. Concurrent ask() calls render as independent stacked Dialogs. Calling ask() during SSR or without one mounted host rejects clearly.\n\n## Visibility and values\n\nThe visible prop may be a boolean or a predicate receiving the complete private value cache:\n\n```svelte\n<Form\n\tinputs={{\n\t\tcontactMethod: {\n\t\t\ttype: 'select',\n\t\t\tlabel: 'Contact method',\n\t\t\titems: [\n\t\t\t\t{ label: 'Email', value: 'email' },\n\t\t\t\t{ label: 'Phone', value: 'phone' }\n\t\t\t]\n\t\t},\n\t\tphone: {\n\t\t\ttype: 'phone',\n\t\t\tlabel: 'Phone',\n\t\t\tvisible: (value) => value.contactMethod === 'phone'\n\t\t}\n\t}}\n/>\n```\n\nHidden field values are preserved privately and restored when shown again. Hidden fields are excluded from value, validation, and submission. Removing an input definition removes its cached value.\n\n## Field label position\n\nAll configured inputs inherit the Form layout through the shared Field wrapper. Set labelPosition: 'top' or 'left' on an individual input to override the Form layout without affecting value inference:\n\n```ts\nexport const inputs = {\n\tname: { type: 'text', label: 'Name' },\n\tnotes: { type: 'textarea', label: 'Notes', labelPosition: 'top' }\n} as const;\n```\n\nThe left position becomes a two-column label/control layout once the field is at least 32rem wide and remains stacked in narrower forms. The breakpoint is a container query against the field, so a form in a narrow drawer stacks on any screen. Form uses layout rather than orientation so controls such as Slider retain their own orientation prop.\n\n## Visual groups\n\nA group renders a transparent semantic fieldset with a required legend label and an optional description. Its label and description use the same size scale as ordinary fields; grouping does not add another card or padded container:\n\n```ts\nimport type { InferFormValue } from 'entasis/form';\n\nexport const inputs = {\n\tcontact: {\n\t\ttype: 'group',\n\t\tlabel: 'Contact details',\n\t\tdescription: 'How we can reach you',\n\t\tcolumns: 1,\n\t\tinputs: {\n\t\t\temail: { type: 'email', label: 'Email', required: true },\n\t\t\tphone: { type: 'phone', label: 'Phone' }\n\t\t}\n\t}\n} as const;\n\ntype Value = InferFormValue<typeof inputs>;\n// { email: string; phone: string | null }\n```\n\nSet disabled on a group to disable every field inside it, as a native disabled fieldset does (the fieldset renders disabled and data-disabled), or readOnly to make them read-only (data-readonly). A field is disabled or read-only when it, its group, or the Form is.\n\nThe group key is visual only and never appears in value or submission output. Descendant field names remain top-level, so duplicate names across groups are rejected. Group visibility hides all descendants, preserves field values in the private cache, and makes inferred field keys optional. In a vertical form layout, set columns to 1, 2, 3, or 4 to control the equal-width grid; the count is a container query against the form width (2 columns from 42rem, 3 from 56rem, 4 from 72rem), and groups collapse to one column in narrower forms. Horizontal form layouts ignore columns and always render group entries in one column. A child class may span tracks when an entry needs more room. Groups may contain fields, action rows, and custom snippets; nested groups are intentionally unsupported.\n\n## Custom value fields\n\nUse type: 'field' when Form must own a value but a custom control must render it. fieldType selects the existing FieldState schema and inferred value type. The snippet receives that registered FieldState controller:\n\n```svelte\n{#snippet handleControl(field)}\n\t<input\n\t\t{...field.controlAttrs}\n\t\t{@attach field.control}\n\t\tbind:value={field.value}\n\t/>\n{/snippet}\n\n<Form\n\tinputs={{\n\t\thandle: {\n\t\t\ttype: 'field',\n\t\t\tfieldType: 'text',\n\t\t\tlabel: 'Handle',\n\t\t\trequired: true,\n\t\t\tsnippet: handleControl\n\t\t}\n\t}}\n/>\n```\n\nThe controller exposes value, disabled, required, validation state, accessible ids, controlAttrs, and the control attachment. The entry participates in bind:value, visibility, validation, submission, and InferFormValue through the same FieldState owner as built-in controls.\n\n## App-defined input types\n\nAn app can add its own input types to every Form and ask() dialog, by name, so entries stay plain data that serializes (JSON from a server, a tool call, a database). Two steps, once per app.\n\nType it: augment `FormInputRegistry` with the value the input holds and the props its entries take.\n\n```ts\n// doc-fence: skip (imports a sibling component; tooling/component-contract/consumer-form-input.ts checks this exact setup against the package)\nimport { registerFormInputs } from 'entasis/form';\nimport MoneyInput from './MoneyInput.svelte';\n\nexport type Money = { amount: number; currency: string };\n\ndeclare module 'entasis/form' {\n\tinterface FormInputRegistry {\n\t\tmoney: { value: Money; props: { currencies?: string[] } };\n\t}\n}\n\nregisterFormInputs({\n\tmoney: {\n\t\tcomponent: MoneyInput,\n\t\tisEmpty: (value) => value?.amount === undefined,\n\t\tvalidate: (value) => (value.amount < 0 ? 'Must not be negative' : null)\n\t}\n});\n```\n\nRegister it: call registerFormInputs at the top level of a module the server and the browser both load before a form renders, such as one the root layout imports. Its keys are checked against the registry; built-in type names are refused, and registering a type again replaces it.\n\nThe component renders the control alone. Form wraps it in Field (label, description, errors) and hands it the field it registered, typed from the registry, plus the entry's own props:\n\n```svelte\n<!-- doc-fence: skip -->\n<!-- Needs the money registration above; tooling/component-contract/consumer-money-input.svelte is the checked copy. -->\n<script lang=\"ts\">\n\timport type { FormInputComponentProps } from 'entasis/form';\n\n\tlet { field, currencies = ['EUR'] }: FormInputComponentProps<'money'> = $props();\n\tconst currency = $derived(field.value?.currency ?? currencies[0] ?? 'EUR');\n</script>\n\n<input\n\ttype=\"number\"\n\t{...field.controlAttrs}\n\t{@attach field.control}\n\tvalue={field.value?.amount ?? ''}\n\toninput={(event) => field.setValue({ amount: Number(event.currentTarget.value), currency })}\n/>\n```\n\nEntries then use the type like a built-in one, in Form inputs, groups, and ask():\n\n```ts\n// doc-fence: skip (needs the money registration above)\nconst result = await ask({\n\ttitle: 'Set a price',\n\tconfirm: 'Save',\n\tcancel: 'Cancel',\n\tinputs: { price: { type: 'money', label: 'Price', required: true, currencies: ['EUR', 'USD'] } }\n});\nif (result.submitted) result.value.price; // Money\n```\n\nEvery Field entry option applies (label, description, required, disabled, readOnly, messages, size, density, visible, defaultValue, onValidate, onValueChange, slots); any other key goes to the component. required rejects what isEmpty reports empty (by default null, undefined, an empty string, or an array with no values) with the catalog required message, and isEmpty also decides whether the field reads as filled; validate runs for every entry of the type, before the entry's own onValidate. The value takes part in bind:value, visibility, validation, submission, and InferFormValue like a built-in input's. An entry whose type is neither built-in nor registered throws when the form reads it.\n\n## Non-value entries\n\nUse type: 'action' to place a labelled row of buttons in the ordered inputs flow. It accepts optional label and description content plus the same Form-aware action objects as the top-level actions prop. Its label position follows the Form layout unless labelPosition overrides it. Form size is the default button size, action density follows the Form, and loading or disabled protection cannot be overridden while the Form is submitting.\n\nUse type: 'custom' to place a snippet in the flow. The snippet receives the live public FormState and owns its own surface and padding; Form adds neither. Both entry types support class and visible, may appear at the top level or inside a group, and are omitted from bind:value, validation, and inferred submission output:\n\n```svelte\n{#snippet accountStatus(form)}\n\t<p>{Object.keys(form.value).length} visible values</p>\n{/snippet}\n\n<Form\n\tinputs={{\n\t\tname: { type: 'text', label: 'Name', required: true },\n\t\tstatus: { type: 'custom', snippet: accountStatus },\n\t\tcontrols: {\n\t\t\ttype: 'action',\n\t\t\tlabel: 'Account actions',\n\t\t\tdescription: 'Validate or save this account.',\n\t\t\tactions: [\n\t\t\t\t{ children: 'Validate', variant: 'soft', onAction: (payload) => payload.validate() },\n\t\t\t\t{ children: 'Save', onAction: (payload) => payload.submit() }\n\t\t\t]\n\t\t}\n\t}}\n/>\n```\n\nFor this configuration, InferFormValue contains name only; status and controls are presentation keys.\n\n## Validation\n\nBuilt-in validation uses the field schema. Every message a user sees comes from the i18n catalog in the active locale, never from the validation library: an empty required field shows one required message (for a checkbox or switch, that it must be on), and email, URL, length, range and incomplete-code failures each have their own message. Override them per entry with messages:\n\n```ts\nimport type { FormInputs } from 'entasis/form';\n\nexport const inputs = {\n\tname: { type: 'text', label: 'Name', required: true, messages: { required: 'Enter your name' } },\n\tcode: {\n\t\ttype: 'pin',\n\t\tlabel: 'Code',\n\t\tlength: 6,\n\t\trequired: true,\n\t\tmessages: { incomplete: (length) => 'Enter the ' + length + '-digit code' }\n\t}\n} satisfies FormInputs;\n```\n\nonValidate may return:\n\n- false, null, undefined, an empty string, or an empty array for valid input;\n- true for the catalog's generic invalid message;\n- a string for one error, shown verbatim;\n- a string array for multiple errors.\n\nValidation runs on submission. Failed submission scrolls to and focuses the first invalid control in render order. Disabled fields, directly or through a disabled group or Form, skip validation and are left out of the submitted value, as in a native form; entries that declare disabled become optional keys in InferFormValue. Read-only fields still validate and submit.\n\n### When fields validate\n\nvalidationMode on the Form, or on one entry, picks when a field validates by itself:\n\n```ts\nimport type { FormInputs } from 'entasis/form';\n\nexport const inputs = {\n\tusername: { type: 'text', label: 'Username', required: true, validationMode: 'change' },\n\temail: { type: 'email', label: 'Email', required: true }\n} satisfies FormInputs;\n// <Form {inputs} validationMode=\"blur\" />: email validates when focus leaves it,\n// username validates on every change.\n```\n\nsubmit (the default) validates on a submit attempt, and from then on re-validates each edited field. blur validates when focus leaves the field, including a popup the field opened. change validates on every accepted change, including values synced from a parent. Whatever the mode, a field that shows an error re-validates as it is edited, and a blur that settles the value (trimming, say) validates the settled value. validationDebounce delays the validation an edit triggers; submit and blur never wait.\n\n### Async validators\n\nonValidate may return a promise. While it is pending the field is neither valid nor invalid: no aria-invalid and no data-invalid, and its root carries data-validating. A result for an older value is dropped, a rejected promise marks the field invalid with the generic message, and unmounting cancels the work. submit() waits for pending validators before it calls onSubmit (loading is true meanwhile); validate() stays synchronous, so use validateAsync() to wait.\n\n```ts\nimport type { FormInputs } from 'entasis/form';\n\ndeclare function isTaken(username: string): Promise<boolean>;\n\nexport const inputs = {\n\tusername: {\n\t\ttype: 'text',\n\t\tlabel: 'Username',\n\t\trequired: true,\n\t\tonValidate: async (username) => ((await isTaken(username)) ? 'That username is taken' : null)\n\t}\n} satisfies FormInputs;\n```\n\n### Server errors\n\nPass the errors of a failed save as the errors prop or call form.setErrors(). They show under their fields, are not wiped by validation, do not block a re-submit, and clear on that field's next change:\n\n```svelte\n<script lang=\"ts\">\n\timport { Form, type FormState, type FormInputs } from 'entasis/form';\n\n\tconst inputs = {\n\t\temail: { type: 'email', label: 'Email', required: true }\n\t} satisfies FormInputs;\n\n\tlet form = $state<FormState<typeof inputs>>();\n</script>\n\n<Form\n\t{inputs}\n\tbind:form\n\tonSubmit={async (value) => {\n\t\tconst response = await fetch('/api/signup', { method: 'POST', body: JSON.stringify(value) });\n\t\tif (!response.ok) form?.setErrors({ email: 'Already registered' });\n\t}}\n/>\n```\n\n### Dirty, touched and reset\n\nEvery field reports touched, dirty and filled (data-touched, data-dirty and data-filled on its root); form.dirty and form.touched are true when any field is. form.reset() returns every field to its initial value and clears errors, touched and dirty; form.reset(value) restores the given values instead and makes them the new baseline.\n\nErrors fade and grow in; reduced motion and the Theme motion tokens apply (the field theme motion slot).\n\n## Supported input types\n\ntext, email, url, password, number, rating, voice, slider, slider-range, textarea, rich-text, select, select-multiple, combobox, radio, checkboxes, checkbox, switch, phone, calendar, calendar-range, date, datetime, color, file, files, tag-group, tag, keyvalue, pin, and time.\n\nAlternative displays are display: 'selector' for date and calendar-range, and display: 'picker' for color.\n\nfield is the custom value-bearing entry. group, action, and custom are structural visual nodes rather than value-bearing input types.\n";
1
+ export declare const formDescription = "\n# Form\n\nForm renders configured entasis fields inside a div, owns their state and validation, and submits programmatically. It provides managed Enter-key navigation and submission, but not native form events, browser constraint validation, or FormData behavior. For a plain <form> (a SvelteKit form action), use the controls directly: each submits its name and value through hidden inputs, follows the form's reset, and accepts a form prop when it sits outside the form.\n\n## Basic usage\n\n```svelte\n<script lang=\"ts\">\n\timport {\n\t\tForm,\n\t\ttype FormState,\n\t\ttype InferFormValue,\n\t\ttype LiveFormValue\n\t} from 'entasis/form';\n\n\tconst inputs = {\n\t\tidentity: {\n\t\t\ttype: 'group',\n\t\t\tlabel: 'Identity',\n\t\t\tdescription: 'Core account details',\n\t\t\tcolumns: 2,\n\t\t\tinputs: {\n\t\t\t\tname: { type: 'text', label: 'Name', required: true },\n\t\t\t\temail: { type: 'email', label: 'Email', required: true }\n\t\t\t}\n\t\t}\n\t} as const;\n\n\tlet value = $state<LiveFormValue<typeof inputs>>({ name: 'Ada' });\n\tlet form = $state<FormState<typeof inputs>>();\n\tlet submitted = $state<InferFormValue<typeof inputs> | null>(null);\n</script>\n\n<Form\n\t{inputs}\n\tbind:value\n\tbind:form\n\tvariant=\"card\"\n\tlayout=\"horizontal\"\n\tsize=\"small\"\n\tdensity=\"normal\"\n\tactions={[\n\t\t{\n\t\t\tchildren: 'Save',\n\t\t\tonAction: (payload) => payload.submit()\n\t\t}\n\t]}\n\tonSubmit={(validatedValue) => {\n\t\tsubmitted = validatedValue;\n\t}}\n/>\n```\n\n## Props\n\n- **inputs** (required): ordered object keyed by entry name. Entries may be value-bearing fields, visual groups, action-button rows, or custom snippets. Only fields contribute keys to the live and validated values.\n- **value** (bindable): controlled partial live value. Visible mounted fields are published; hidden fields are omitted. A supplied top-level value takes precedence over an input's configured value.\n- **defaultValue**: initial partial live value when value is omitted.\n- **onValueChange**: called once when a user changes the visible live value. Parent value updates do not emit it.\n- **form** (bindable): the FormState instance.\n- **onSubmit**: called with the validated visible payload. Its return value is ignored; rejected promises propagate.\n- **size**: small, normal (default), or large. Controls Form typography and becomes the fallback size for fields and actions. An explicit field or action size takes precedence.\n- **density**: compact, normal (default), or comfortable. Controls gaps between the Form header, fields, footer, and actions independently from size.\n- **variant**: plain (default), sectioned, or card. All variants consume the shared Card typography. Plain remains transparent without separators. Sectioned stays transparent and adds edge-to-edge separators between the header, visible top-level fields or groups, and footer. Card adds the same separators inside the Card surface and inset; Card header/footer padding applies only to that variant. Separators do not appear between fields inside a group.\n- **layout**: vertical (default) or horizontal. Horizontal keeps one field per row and places labels to the left once each field is at least 32rem wide; fields remain stacked in narrower forms.\n- **actions**: optional array of Button props. Each action's onAction receives the live FormState, so a submit action calls form.submit(). Actions are disabled while the form is submitting; their own loading and disabled props are composed with that protection.\n- **validationMode**: submit (default), blur, or change. When a field validates by itself besides a submit: submit waits for the first submit attempt and then re-validates each edited field, blur validates when focus leaves the field, change validates on every accepted change. A field that shows an error always re-validates as it is edited. A field's own validationMode takes precedence, and mounting never validates.\n- **validationDebounce**: milliseconds an edit waits before the validation it triggers, so an async onValidate is not called on every keystroke. Submit and blur validate at once. A field's own validationDebounce takes precedence.\n- **errors**: errors from outside the form, for example a SvelteKit ActionData, keyed by field name with one message or a list of them. They show under their fields, survive validation, do not block a submit (the server re-checks), and clear when that field's value next changes. Changing the prop replaces the errors; the first errored field in render order is revealed.\n- **disabled**: disables every field, for example disabled={form.loading} while a submission runs. Disabled fields skip validation and, as in a native form, are left out of the submitted value. The root carries data-disabled. A disabled option inside an enabled radio or checkbox group is different: when selected it stays in that field's value, while a plain native <form> leaves it out of its submission.\n- **readOnly**: makes every field read-only. Values stay focusable, validated and submitted, but users cannot change them. The root carries data-readonly.\n- **class**: additional classes on the root div.\n- **theme**: Form theme overrides for root, header, title, description, group, group label/description/fields, top-level items, custom entries, footer, and actions. Global Card typography and section-rhythm changes flow into all Form variants before Form-specific overrides are composed; Card surface changes apply only to the card variant.\n\nThe **header**, **title**, **description**, **children**, and **footer** snippets each receive the FormState instance directly. No-argument snippets remain valid.\n\nField wrapper attributes and native control attributes have separate owners. Use fieldAttrs for the shared Field wrapper. Controls expose a typed bag for their actual native element, such as inputAttrs on TextInput, textareaAttrs on TextArea, and triggerAttrs on the custom Select's combobox button.\n\n## FormState\n\n- **value**: current visible partial value.\n- **loading**: true while a submission is pending: async validators first, then the handler.\n- **hasError**: true after validation fails or errors are set from outside; reset after successful validation.\n- **dirty**: true when any field differs from its initial value (null, an empty string and an empty list count as equal).\n- **touched**: true once focus has entered and left any field.\n- **validating**: true while an async onValidate of any field is pending.\n- **submitCount**: how many times the form was validated to submit.\n- **validate(options?)**: validates every visible, enabled field synchronously and returns the validated visible payload, or false after revealing the first invalid field. Disabled fields are skipped and left out of the payload. Pass { reveal: false } to check quietly: no scrolling, no focus, and the call does not count as a submit attempt. It does not wait for async validators.\n- **validateAsync(options?)**: like validate, and waits for async validators; returns a promise.\n- **validateField(name)**: validates one field now and returns whether it is valid. It neither scrolls nor focuses. A name that is not a visible field returns false; a disabled field skips validation and returns true; a field whose async validator is still running returns false, so use validateAsync to wait.\n- **submit()**: returns a promise of the validated visible payload, or false. It waits for pending async validators. Concurrent calls share the active promise.\n- **setErrors(errors)**: shows errors from outside the form under their fields, replacing those set before; setErrors({}) clears them. Call it from onSubmit with the server response. The first errored field in render order is revealed once the submission ends.\n- **reset(value?)**: restores every field to its initial value, or to value where it gives one, and makes that the new baseline. Errors, touched, dirty and the submit count clear, fields do not echo onValueChange, and the form's onValueChange runs once if the visible value changed. Conditional visibility is evaluated again.\n- **advanceFrom(field)**: moves on from a registered field as Enter does in a text field: the last navigable field submits, any other validates and focuses the next field when valid. Returns false when the field is hidden, disabled or not part of this form. Controls that own Enter themselves, such as checkboxes and radios, call it from their key handler and fall back to the native form otherwise.\n\n## Enter-key behavior\n\nOn an enabled, editable single-line input, Enter validates the current field. A valid field moves focus to the next visible enabled field, while an invalid field remains focused and displays its errors. Enter on a valid final navigable field calls form.submit(). Multiline editors and controls that already own Enter, such as selects and combobox menus, keep their native component behavior. A control that owns Enter can continue the flow with form.advanceFrom(field). Modified, repeated, and IME-composition Enter events are ignored.\n\n## Programmatic Dialog forms\n\nMount one Ask host near the application root, then call ask() from any client-side event. Both exports come from entasis/form:\n\n```svelte\n<script lang=\"ts\">\n\timport { Ask, ask } from 'entasis/form';\n\n\tconst inputs = {\n\t\tname: { type: 'text', label: 'Name', required: true },\n\t\temail: { type: 'email', label: 'Email', required: true }\n\t} as const;\n\n\tasync function editProfile() {\n\t\tconst outcome = await ask({\n\t\t\ttitle: 'Edit profile',\n\t\t\tdescription: 'Review the account details.',\n\t\t\tinputs,\n\t\t\tvalue: { name: 'Ada' },\n\t\t\tconfirm: 'Save',\n\t\t\tcancel: 'Cancel'\n\t\t});\n\n\t\tif (outcome.submitted) {\n\t\t\t// outcome.value is InferFormValue<typeof inputs>\n\t\t} else {\n\t\t\t// outcome.value is the partial, visible live value at cancellation\n\t\t}\n\t}\n</script>\n\n<Ask />\n```\n\nAskOptions accepts inputs, value, onSubmit, class, size, density, variant, layout, theme, validationMode, and validationDebounce with the same contracts as Form. Disabled fields are left out of the result. title is required for the Dialog's accessible name. confirm and cancel accept a string or Button presentation props plus text. Their click, loading, link, and native type behavior is owned by Ask. Set type on the mounted Ask host for its default Dialog type; a request's optional dialog object may override type and also accepts responsive, size, and scroll. With scroll 'inner' (the default) the form is the Dialog's only scrolling part: a form taller than the viewport scrolls inside its body (`data-slot=\"ask-body\"`) while the title, description and Confirm/Cancel row stay on screen, and the body keeps room around its fields so a focus ring is never clipped. With scroll 'outer' the whole card grows and the page behind it scrolls instead.\n\nValidation failures keep the Dialog open and focus the first invalid field. A successful submission resolves with the validated visible payload. Cancel, the close button, and Escape resolve with submitted: false and the current partial visible value. Outside-click and swipe dismissal are disabled. While submission is active, all close paths and actions are protected. Rejected onSubmit promises reject ask() after the Dialog closes. Concurrent ask() calls render as independent stacked Dialogs. Calling ask() during SSR or without one mounted host rejects clearly.\n\n## Visibility and values\n\nThe visible prop may be a boolean or a predicate receiving the complete private value cache:\n\n```svelte\n<Form\n\tinputs={{\n\t\tcontactMethod: {\n\t\t\ttype: 'select',\n\t\t\tlabel: 'Contact method',\n\t\t\titems: [\n\t\t\t\t{ label: 'Email', value: 'email' },\n\t\t\t\t{ label: 'Phone', value: 'phone' }\n\t\t\t]\n\t\t},\n\t\tphone: {\n\t\t\ttype: 'phone',\n\t\t\tlabel: 'Phone',\n\t\t\tvisible: (value) => value.contactMethod === 'phone'\n\t\t}\n\t}}\n/>\n```\n\nHidden field values are preserved privately and restored when shown again. Hidden fields are excluded from value, validation, and submission. Removing an input definition removes its cached value.\n\n## Field label position\n\nAll configured inputs inherit the Form layout through the shared Field wrapper. Set labelPosition: 'top' or 'left' on an individual input to override the Form layout without affecting value inference:\n\n```ts\nexport const inputs = {\n\tname: { type: 'text', label: 'Name' },\n\tnotes: { type: 'textarea', label: 'Notes', labelPosition: 'top' }\n} as const;\n```\n\nThe left position becomes a two-column label/control layout once the field is at least 32rem wide and remains stacked in narrower forms. The breakpoint is a container query against the field, so a form in a narrow drawer stacks on any screen. Form uses layout rather than orientation so controls such as Slider retain their own orientation prop.\n\n## Visual groups\n\nA group renders a transparent semantic fieldset with a required legend label and an optional description. Its label and description use the same size scale as ordinary fields; grouping does not add another card or padded container:\n\n```ts\nimport type { InferFormValue } from 'entasis/form';\n\nexport const inputs = {\n\tcontact: {\n\t\ttype: 'group',\n\t\tlabel: 'Contact details',\n\t\tdescription: 'How we can reach you',\n\t\tcolumns: 1,\n\t\tinputs: {\n\t\t\temail: { type: 'email', label: 'Email', required: true },\n\t\t\tphone: { type: 'phone', label: 'Phone' }\n\t\t}\n\t}\n} as const;\n\ntype Value = InferFormValue<typeof inputs>;\n// { email: string; phone: string | null }\n```\n\nSet disabled on a group to disable every field inside it, as a native disabled fieldset does (the fieldset renders disabled and data-disabled), or readOnly to make them read-only (data-readonly). A field is disabled or read-only when it, its group, or the Form is.\n\nThe group key is visual only and never appears in value or submission output. Descendant field names remain top-level, so duplicate names across groups are rejected. Group visibility hides all descendants, preserves field values in the private cache, and makes inferred field keys optional. In a vertical form layout, set columns to 1, 2, 3, or 4 to control the equal-width grid; the count is a container query against the form width (2 columns from 42rem, 3 from 56rem, 4 from 72rem), and groups collapse to one column in narrower forms. Horizontal form layouts ignore columns and always render group entries in one column. A child class may span tracks when an entry needs more room. Groups may contain fields, action rows, and custom snippets; nested groups are intentionally unsupported.\n\n## Custom value fields\n\nUse type: 'field' when Form must own a value but a custom control must render it. fieldType selects the existing FieldState schema and inferred value type. The snippet receives that registered FieldState controller:\n\n```svelte\n{#snippet handleControl(field)}\n\t<input\n\t\t{...field.controlAttrs}\n\t\t{@attach field.control}\n\t\tbind:value={field.value}\n\t/>\n{/snippet}\n\n<Form\n\tinputs={{\n\t\thandle: {\n\t\t\ttype: 'field',\n\t\t\tfieldType: 'text',\n\t\t\tlabel: 'Handle',\n\t\t\trequired: true,\n\t\t\tsnippet: handleControl\n\t\t}\n\t}}\n/>\n```\n\nThe controller exposes value, disabled, required, validation state, accessible ids, controlAttrs, and the control attachment. The entry participates in bind:value, visibility, validation, submission, and InferFormValue through the same FieldState owner as built-in controls.\n\n## App-defined input types\n\nAn app can add its own input types to every Form and ask() dialog, by name, so entries stay plain data that serializes (JSON from a server, a tool call, a database). Two steps, once per app.\n\nType it: augment `FormInputRegistry` with the value the input holds and the props its entries take.\n\n```ts\n// doc-fence: skip (imports a sibling component; tooling/component-contract/consumer-form-input.ts checks this exact setup against the package)\nimport { registerFormInputs } from 'entasis/form';\nimport MoneyInput from './MoneyInput.svelte';\n\nexport type Money = { amount: number; currency: string };\n\ndeclare module 'entasis/form' {\n\tinterface FormInputRegistry {\n\t\tmoney: { value: Money; props: { currencies?: string[] } };\n\t}\n}\n\nregisterFormInputs({\n\tmoney: {\n\t\tcomponent: MoneyInput,\n\t\tisEmpty: (value) => value?.amount === undefined,\n\t\tvalidate: (value) => (value.amount < 0 ? 'Must not be negative' : null)\n\t}\n});\n```\n\nRegister it: call registerFormInputs at the top level of a module the server and the browser both load before a form renders, such as one the root layout imports. Its keys are checked against the registry; built-in type names are refused, and registering a type again replaces it.\n\nThe component renders the control alone. Form wraps it in Field (label, description, errors) and hands it the field it registered, typed from the registry, plus the entry's own props:\n\n```svelte\n<!-- doc-fence: skip -->\n<!-- Needs the money registration above; tooling/component-contract/consumer-money-input.svelte is the checked copy. -->\n<script lang=\"ts\">\n\timport type { FormInputComponentProps } from 'entasis/form';\n\n\tlet { field, currencies = ['EUR'] }: FormInputComponentProps<'money'> = $props();\n\tconst currency = $derived(field.value?.currency ?? currencies[0] ?? 'EUR');\n</script>\n\n<input\n\ttype=\"number\"\n\t{...field.controlAttrs}\n\t{@attach field.control}\n\tvalue={field.value?.amount ?? ''}\n\toninput={(event) => field.setValue({ amount: Number(event.currentTarget.value), currency })}\n/>\n```\n\nEntries then use the type like a built-in one, in Form inputs, groups, and ask():\n\n```ts\n// doc-fence: skip (needs the money registration above)\nconst result = await ask({\n\ttitle: 'Set a price',\n\tconfirm: 'Save',\n\tcancel: 'Cancel',\n\tinputs: { price: { type: 'money', label: 'Price', required: true, currencies: ['EUR', 'USD'] } }\n});\nif (result.submitted) result.value.price; // Money\n```\n\nEvery Field entry option applies (label, description, required, disabled, readOnly, messages, size, density, visible, defaultValue, onValidate, onValueChange, slots); any other key goes to the component. required rejects what isEmpty reports empty (by default null, undefined, an empty string, or an array with no values) with the catalog required message, and isEmpty also decides whether the field reads as filled; validate runs for every entry of the type, before the entry's own onValidate. The value takes part in bind:value, visibility, validation, submission, and InferFormValue like a built-in input's. An entry whose type is neither built-in nor registered throws when the form reads it.\n\n## Non-value entries\n\nUse type: 'action' to place a labelled row of buttons in the ordered inputs flow. It accepts optional label and description content plus the same Form-aware action objects as the top-level actions prop. Its label position follows the Form layout unless labelPosition overrides it. Form size is the default button size, action density follows the Form, and loading or disabled protection cannot be overridden while the Form is submitting.\n\nUse type: 'custom' to place a snippet in the flow. The snippet receives the live public FormState and owns its own surface and padding; Form adds neither. Both entry types support class and visible, may appear at the top level or inside a group, and are omitted from bind:value, validation, and inferred submission output:\n\n```svelte\n{#snippet accountStatus(form)}\n\t<p>{Object.keys(form.value).length} visible values</p>\n{/snippet}\n\n<Form\n\tinputs={{\n\t\tname: { type: 'text', label: 'Name', required: true },\n\t\tstatus: { type: 'custom', snippet: accountStatus },\n\t\tcontrols: {\n\t\t\ttype: 'action',\n\t\t\tlabel: 'Account actions',\n\t\t\tdescription: 'Validate or save this account.',\n\t\t\tactions: [\n\t\t\t\t{ children: 'Validate', variant: 'soft', onAction: (payload) => payload.validate() },\n\t\t\t\t{ children: 'Save', onAction: (payload) => payload.submit() }\n\t\t\t]\n\t\t}\n\t}}\n/>\n```\n\nFor this configuration, InferFormValue contains name only; status and controls are presentation keys.\n\n## Validation\n\nBuilt-in validation uses the field schema. Every message a user sees comes from the i18n catalog in the active locale, never from the validation library: an empty required field shows one required message (for a checkbox or switch, that it must be on), and email, URL, length, range and incomplete-code failures each have their own message. Override them per entry with messages:\n\n```ts\nimport type { FormInputs } from 'entasis/form';\n\nexport const inputs = {\n\tname: { type: 'text', label: 'Name', required: true, messages: { required: 'Enter your name' } },\n\tcode: {\n\t\ttype: 'pin',\n\t\tlabel: 'Code',\n\t\tlength: 6,\n\t\trequired: true,\n\t\tmessages: { incomplete: (length) => 'Enter the ' + length + '-digit code' }\n\t}\n} satisfies FormInputs;\n```\n\nonValidate may return:\n\n- false, null, undefined, an empty string, or an empty array for valid input;\n- true for the catalog's generic invalid message;\n- a string for one error, shown verbatim;\n- a string array for multiple errors.\n\nValidation runs on submission. Failed submission scrolls to and focuses the first invalid control in render order. Disabled fields, directly or through a disabled group or Form, skip validation and are left out of the submitted value, as in a native form; entries that declare disabled become optional keys in InferFormValue. Read-only fields still validate and submit.\n\n### When fields validate\n\nvalidationMode on the Form, or on one entry, picks when a field validates by itself:\n\n```ts\nimport type { FormInputs } from 'entasis/form';\n\nexport const inputs = {\n\tusername: { type: 'text', label: 'Username', required: true, validationMode: 'change' },\n\temail: { type: 'email', label: 'Email', required: true }\n} satisfies FormInputs;\n// <Form {inputs} validationMode=\"blur\" />: email validates when focus leaves it,\n// username validates on every change.\n```\n\nsubmit (the default) validates on a submit attempt, and from then on re-validates each edited field. blur validates when focus leaves the field, including a popup the field opened. change validates on every accepted change, including values synced from a parent. Whatever the mode, a field that shows an error re-validates as it is edited, and a blur that settles the value (trimming, say) validates the settled value. validationDebounce delays the validation an edit triggers; submit and blur never wait.\n\n### Async validators\n\nonValidate may return a promise. While it is pending the field is neither valid nor invalid: no aria-invalid and no data-invalid, and its root carries data-validating. A result for an older value is dropped, a rejected promise marks the field invalid with the generic message, and unmounting cancels the work. submit() waits for pending validators before it calls onSubmit (loading is true meanwhile); validate() stays synchronous, so use validateAsync() to wait.\n\n```ts\nimport type { FormInputs } from 'entasis/form';\n\ndeclare function isTaken(username: string): Promise<boolean>;\n\nexport const inputs = {\n\tusername: {\n\t\ttype: 'text',\n\t\tlabel: 'Username',\n\t\trequired: true,\n\t\tonValidate: async (username) => ((await isTaken(username)) ? 'That username is taken' : null)\n\t}\n} satisfies FormInputs;\n```\n\n### Server errors\n\nPass the errors of a failed save as the errors prop or call form.setErrors(). They show under their fields, are not wiped by validation, do not block a re-submit, and clear on that field's next change:\n\n```svelte\n<script lang=\"ts\">\n\timport { Form, type FormState, type FormInputs } from 'entasis/form';\n\n\tconst inputs = {\n\t\temail: { type: 'email', label: 'Email', required: true }\n\t} satisfies FormInputs;\n\n\tlet form = $state<FormState<typeof inputs>>();\n</script>\n\n<Form\n\t{inputs}\n\tbind:form\n\tonSubmit={async (value) => {\n\t\tconst response = await fetch('/api/signup', { method: 'POST', body: JSON.stringify(value) });\n\t\tif (!response.ok) form?.setErrors({ email: 'Already registered' });\n\t}}\n/>\n```\n\n### Dirty, touched and reset\n\nEvery field reports touched, dirty and filled (data-touched, data-dirty and data-filled on its root); form.dirty and form.touched are true when any field is. form.reset() returns every field to its initial value and clears errors, touched and dirty; form.reset(value) restores the given values instead and makes them the new baseline.\n\nErrors fade and grow in; reduced motion and the Theme motion tokens apply (the field theme motion slot).\n\n## Supported input types\n\ntext, email, url, password, number, rating, voice, signature, address, slider, slider-range, textarea, rich-text, select, select-multiple, combobox, radio, checkboxes, checkbox, switch, phone, calendar, calendar-range, date, datetime, color, file, files, tag-group, tag, keyvalue, pin, and time.\n\nAlternative displays are display: 'selector' for date and calendar-range, and display: 'picker' for color.\n\nfield is the custom value-bearing entry. group, action, and custom are structural visual nodes rather than value-bearing input types.\n";
@@ -424,7 +424,7 @@ Errors fade and grow in; reduced motion and the Theme motion tokens apply (the f
424
424
 
425
425
  ## Supported input types
426
426
 
427
- text, email, url, password, number, rating, voice, slider, slider-range, textarea, rich-text, select, select-multiple, combobox, radio, checkboxes, checkbox, switch, phone, calendar, calendar-range, date, datetime, color, file, files, tag-group, tag, keyvalue, pin, and time.
427
+ text, email, url, password, number, rating, voice, signature, address, slider, slider-range, textarea, rich-text, select, select-multiple, combobox, radio, checkboxes, checkbox, switch, phone, calendar, calendar-range, date, datetime, color, file, files, tag-group, tag, keyvalue, pin, and time.
428
428
 
429
429
  Alternative displays are display: 'selector' for date and calendar-range, and display: 'picker' for color.
430
430