@native-form/core 0.1.0 → 0.1.1

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 (100) hide show
  1. package/dist/index.cjs +2073 -0
  2. package/dist/index.d.cts +495 -0
  3. package/dist/index.d.ts +495 -9
  4. package/dist/index.js +2030 -7
  5. package/package.json +5 -3
  6. package/dist/Discovery.d.ts +0 -2
  7. package/dist/Discovery.d.ts.map +0 -1
  8. package/dist/Discovery.js +0 -2
  9. package/dist/Discovery.js.map +0 -1
  10. package/dist/FieldErrorRenderer.d.ts +0 -2
  11. package/dist/FieldErrorRenderer.d.ts.map +0 -1
  12. package/dist/FieldErrorRenderer.js +0 -2
  13. package/dist/FieldErrorRenderer.js.map +0 -1
  14. package/dist/FieldNode.d.ts +0 -2
  15. package/dist/FieldNode.d.ts.map +0 -1
  16. package/dist/FieldNode.js +0 -2
  17. package/dist/FieldNode.js.map +0 -1
  18. package/dist/FieldRegistry.d.ts +0 -2
  19. package/dist/FieldRegistry.d.ts.map +0 -1
  20. package/dist/FieldRegistry.js +0 -2
  21. package/dist/FieldRegistry.js.map +0 -1
  22. package/dist/FieldState.d.ts +0 -2
  23. package/dist/FieldState.d.ts.map +0 -1
  24. package/dist/FieldState.js +0 -2
  25. package/dist/FieldState.js.map +0 -1
  26. package/dist/Path.d.ts +0 -78
  27. package/dist/Path.d.ts.map +0 -1
  28. package/dist/Path.js +0 -219
  29. package/dist/Path.js.map +0 -1
  30. package/dist/Runtime.d.ts +0 -2
  31. package/dist/Runtime.d.ts.map +0 -1
  32. package/dist/Runtime.js +0 -2
  33. package/dist/Runtime.js.map +0 -1
  34. package/dist/RuntimeMutationPolicy.d.ts +0 -2
  35. package/dist/RuntimeMutationPolicy.d.ts.map +0 -1
  36. package/dist/RuntimeMutationPolicy.js +0 -2
  37. package/dist/RuntimeMutationPolicy.js.map +0 -1
  38. package/dist/Serializer.d.ts +0 -2
  39. package/dist/Serializer.d.ts.map +0 -1
  40. package/dist/Serializer.js +0 -2
  41. package/dist/Serializer.js.map +0 -1
  42. package/dist/Validation.d.ts +0 -2
  43. package/dist/Validation.d.ts.map +0 -1
  44. package/dist/Validation.js +0 -2
  45. package/dist/Validation.js.map +0 -1
  46. package/dist/ValidationPipeline.d.ts +0 -2
  47. package/dist/ValidationPipeline.d.ts.map +0 -1
  48. package/dist/ValidationPipeline.js +0 -2
  49. package/dist/ValidationPipeline.js.map +0 -1
  50. package/dist/discovery/Discovery.d.ts +0 -5
  51. package/dist/discovery/Discovery.d.ts.map +0 -1
  52. package/dist/discovery/Discovery.js +0 -63
  53. package/dist/discovery/Discovery.js.map +0 -1
  54. package/dist/errors/FieldErrorRenderer.d.ts +0 -17
  55. package/dist/errors/FieldErrorRenderer.d.ts.map +0 -1
  56. package/dist/errors/FieldErrorRenderer.js +0 -115
  57. package/dist/errors/FieldErrorRenderer.js.map +0 -1
  58. package/dist/field/FieldNode.d.ts +0 -38
  59. package/dist/field/FieldNode.d.ts.map +0 -1
  60. package/dist/field/FieldNode.js +0 -154
  61. package/dist/field/FieldNode.js.map +0 -1
  62. package/dist/field/FieldRegistry.d.ts +0 -19
  63. package/dist/field/FieldRegistry.d.ts.map +0 -1
  64. package/dist/field/FieldRegistry.js +0 -46
  65. package/dist/field/FieldRegistry.js.map +0 -1
  66. package/dist/field/FieldState.d.ts +0 -13
  67. package/dist/field/FieldState.d.ts.map +0 -1
  68. package/dist/field/FieldState.js +0 -2
  69. package/dist/field/FieldState.js.map +0 -1
  70. package/dist/index.d.ts.map +0 -1
  71. package/dist/index.js.map +0 -1
  72. package/dist/runtime/Runtime.d.ts +0 -137
  73. package/dist/runtime/Runtime.d.ts.map +0 -1
  74. package/dist/runtime/Runtime.js +0 -1374
  75. package/dist/runtime/Runtime.js.map +0 -1
  76. package/dist/runtime/RuntimeMutationPolicy.d.ts +0 -3
  77. package/dist/runtime/RuntimeMutationPolicy.d.ts.map +0 -1
  78. package/dist/runtime/RuntimeMutationPolicy.js +0 -34
  79. package/dist/runtime/RuntimeMutationPolicy.js.map +0 -1
  80. package/dist/serialization/Serializer.d.ts +0 -52
  81. package/dist/serialization/Serializer.d.ts.map +0 -1
  82. package/dist/serialization/Serializer.js +0 -115
  83. package/dist/serialization/Serializer.js.map +0 -1
  84. package/dist/shared/types.d.ts +0 -66
  85. package/dist/shared/types.d.ts.map +0 -1
  86. package/dist/shared/types.js +0 -2
  87. package/dist/shared/types.js.map +0 -1
  88. package/dist/tsdoc-metadata.json +0 -11
  89. package/dist/types.d.ts +0 -2
  90. package/dist/types.d.ts.map +0 -1
  91. package/dist/types.js +0 -2
  92. package/dist/types.js.map +0 -1
  93. package/dist/validation/Validation.d.ts +0 -61
  94. package/dist/validation/Validation.d.ts.map +0 -1
  95. package/dist/validation/Validation.js +0 -34
  96. package/dist/validation/Validation.js.map +0 -1
  97. package/dist/validation/ValidationPipeline.d.ts +0 -61
  98. package/dist/validation/ValidationPipeline.d.ts.map +0 -1
  99. package/dist/validation/ValidationPipeline.js +0 -73
  100. package/dist/validation/ValidationPipeline.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,9 +1,495 @@
1
- export { Serializer, type SerializeFieldsOptions, } from "./serialization/Serializer";
2
- export { FieldNode } from "./field/FieldNode";
3
- export { Runtime, type RuntimeFormState, type RuntimeOptions, type RuntimePublicApi, } from "./Runtime";
4
- export { arrayItemPath, type ArrayItemPathInfo, type FieldPathSegment, formPath, getByPath, isArrayItemPath, matchArrayItemPath, normalizePath, parseArrayItemPath, remapArrayItemIndex, setByPath, shiftArrayItemIndex, splitPath, toNestedValues, } from "./Path";
5
- export { createValidationPipeline, type ValidationFieldMeta, type ValidationPipeline, type ValidationPipelineCapabilities, type ValidationPipelineContext, type ValidationPipelineOptions, } from "./ValidationPipeline";
6
- export { createValidator, type AsyncFieldValidator, type InferSchemaOutput, type SchemaLike, type StandardSchemaIssue, type StandardSchemaResult, type StandardSchemaV1, type ValidationContext, type ValidationIssue, type ValidationResult, type Validator, } from "./Validation";
7
- export { type FieldState } from "./FieldState";
8
- export { type FieldEvents, type FormEvents, type NativeFormElement, type NativeFormFlatValues, type NativeFormNestedValue, type NativeFormValue, type NativeFormValues, type RuntimeEvent, type RuntimeEventType, type RuntimeListener, type SerializationMode, type ValidationEvents, type ValidationMode, } from "./types";
9
- //# sourceMappingURL=index.d.ts.map
1
+ /**
2
+ * Supported validation modes for form and field lifecycle.
3
+ * - onChange: validates on every input/change event (live)
4
+ * - onBlur: validates when an input loses focus
5
+ * - onSubmit: validates only upon form submission
6
+ * - onTouched: validates on blur first, then on change for touched fields
7
+ * - all: validates on both input and blur events
8
+ * @public
9
+ */
10
+ type ValidationMode = "onChange" | "onBlur" | "onSubmit" | "onTouched" | "all";
11
+ /** @public */
12
+ type NativeFormElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
13
+ /**
14
+ * Supported serialization modes.
15
+ * - 'native': extracts string / FormData values matching browser native FormData.
16
+ * - 'typed': preserves typed primitives (numbers, booleans, FileLists, string arrays) via serializeFields.
17
+ * @public
18
+ */
19
+ type SerializationMode = "native" | "typed";
20
+ /** @public */
21
+ type NativeFormValue = FormDataEntryValue | FormDataEntryValue[] | number | boolean | FileList | null;
22
+ /** @public */
23
+ type NativeFormFlatValues = Record<string, NativeFormValue>;
24
+ /** @public */
25
+ type NativeFormNestedValue = NativeFormValue | {
26
+ [key: string]: NativeFormNestedValue;
27
+ } | NativeFormNestedValue[];
28
+ /** @public */
29
+ type NativeFormValues = Record<string, NativeFormNestedValue>;
30
+ /** @public */
31
+ type RuntimeEventType = "form:mount" | "form:unmount" | "form:invalid" | "form:reset" | "form:submit" | "validation:end" | "validation:start" | "field:blur" | "field:mount" | "field:unmount" | "field:update" | "field:input" | "field:change" | "field:reset" | "field:submit";
32
+ /** @public */
33
+ type FormEvents = {
34
+ type: "form:mount" | "form:unmount";
35
+ } | {
36
+ type: "form:reset" | "form:submit";
37
+ values: NativeFormValues;
38
+ } | {
39
+ type: "form:invalid";
40
+ errors: Record<string, string>;
41
+ values: NativeFormValues;
42
+ };
43
+ /** @public */
44
+ type ValidationEvents = {
45
+ type: "validation:start";
46
+ values: NativeFormValues;
47
+ } | {
48
+ type: "validation:end";
49
+ errors: Record<string, string>;
50
+ values: NativeFormValues;
51
+ };
52
+ /** @public */
53
+ type FieldEvents = {
54
+ type: "field:blur" | "field:update" | "field:input" | "field:change" | "field:reset";
55
+ field: string;
56
+ value: NativeFormValue | undefined;
57
+ values: NativeFormValues;
58
+ } | {
59
+ type: "field:mount" | "field:unmount" | "field:submit";
60
+ field: string;
61
+ };
62
+ /** @public */
63
+ type RuntimeEvent = FieldEvents | ValidationEvents | FormEvents;
64
+ /** @public */
65
+ type RuntimeListener = (event: RuntimeEvent) => void;
66
+
67
+ /** @public */
68
+ interface FieldState {
69
+ name: string;
70
+ dirty: boolean;
71
+ touched: boolean;
72
+ mounted: boolean;
73
+ initialValue: NativeFormValue | undefined;
74
+ value: NativeFormValue | undefined;
75
+ error?: string;
76
+ validating?: boolean;
77
+ }
78
+
79
+ /** @public */
80
+ declare class FieldNode {
81
+ readonly element: NativeFormElement;
82
+ constructor(element: NativeFormElement);
83
+ private dirty;
84
+ private touched;
85
+ private mounted;
86
+ private initialValue;
87
+ private stateValue;
88
+ private error?;
89
+ private validating;
90
+ get name(): string;
91
+ get tag(): string;
92
+ get type(): string;
93
+ get value(): unknown;
94
+ focus(): void;
95
+ blur(): void;
96
+ get isDirty(): boolean;
97
+ get isTouched(): boolean;
98
+ get isMounted(): boolean;
99
+ get isValidating(): boolean;
100
+ setValidating(validating: boolean): void;
101
+ register(initialValue?: NativeFormValue): void;
102
+ unregister(): void;
103
+ getState(): FieldState;
104
+ updateValue(value?: NativeFormValue): void;
105
+ markTouched(): void;
106
+ setError(message: string | undefined): void;
107
+ reset(value: NativeFormValue | undefined): void;
108
+ handleInput(value?: NativeFormValue): void;
109
+ handleChange(value?: NativeFormValue): void;
110
+ handleBlur(): void;
111
+ handleReset(value?: NativeFormValue): void;
112
+ handleSubmit(): void;
113
+ }
114
+
115
+ /**
116
+ * Configuration options for field-driven serialization.
117
+ * @public
118
+ */
119
+ interface SerializeFieldsOptions {
120
+ /**
121
+ * Whether to include disabled inputs in the serialized output.
122
+ * @defaultValue false
123
+ */
124
+ includeDisabled?: boolean;
125
+ /**
126
+ * Whether to coerce standalone unchecked checkboxes to `false` instead of omitting them.
127
+ * @defaultValue true
128
+ */
129
+ coerceUncheckedCheckboxes?: boolean;
130
+ /**
131
+ * Mode for value extraction:
132
+ * - 'typed': preserves numbers (valueAsNumber), booleans, and FileLists.
133
+ * - 'raw': extracts raw strings matching standard FormData entries.
134
+ * @defaultValue 'typed'
135
+ */
136
+ valueMode?: "typed" | "raw";
137
+ /**
138
+ * Output structure format:
139
+ * - 'flat': preserves exact input field names as top-level keys.
140
+ * - 'nested': resolves dot and bracket notation into deeply nested objects and arrays.
141
+ * @defaultValue 'flat'
142
+ */
143
+ nesting?: "flat" | "nested";
144
+ /**
145
+ * Custom value extractors for specific element tag names or input types.
146
+ */
147
+ customSerializers?: Record<string, (element: NativeFormElement, node: FieldNode) => unknown>;
148
+ }
149
+ /**
150
+ * Handles serialization of HTML forms and field node collections into structured key-value maps.
151
+ * @public
152
+ */
153
+ declare class Serializer {
154
+ /**
155
+ * Native FormData serialization baseline (100% backward compatible with browser form submission).
156
+ */
157
+ serialize(form: HTMLFormElement): NativeFormFlatValues;
158
+ /**
159
+ * Field-node-driven serialization supporting type preservation, unchecked checkbox coercion,
160
+ * disabled filtering, and custom element serializers.
161
+ */
162
+ serializeFields(fields: Iterable<FieldNode>, options?: SerializeFieldsOptions): NativeFormValues;
163
+ }
164
+
165
+ /** @public */
166
+ interface ValidationIssue {
167
+ name: string;
168
+ message: string;
169
+ }
170
+ /** @public */
171
+ interface ValidationContext {
172
+ form: HTMLFormElement;
173
+ signal: AbortSignal;
174
+ }
175
+ /** @public */
176
+ type ValidationResult<TValues extends NativeFormValues = NativeFormValues> = {
177
+ success: true;
178
+ values: TValues;
179
+ issues?: never;
180
+ } | {
181
+ success: false;
182
+ values?: never;
183
+ issues: ValidationIssue[];
184
+ };
185
+ /** @public */
186
+ type AsyncFieldValidator<TValue = unknown> = (value: TValue, context: ValidationContext) => Promise<string | undefined | void>;
187
+ /** @public */
188
+ interface Validator<TValues extends NativeFormValues = NativeFormValues> {
189
+ validate(values: NativeFormValues, context?: ValidationContext): ValidationResult<TValues> | Promise<ValidationResult<TValues>>;
190
+ }
191
+ /** @public */
192
+ interface StandardSchemaIssue {
193
+ message: string;
194
+ path?: readonly (PropertyKey | {
195
+ key: PropertyKey;
196
+ })[];
197
+ }
198
+ /** @public */
199
+ type StandardSchemaResult<TValues> = {
200
+ value: TValues;
201
+ issues?: never;
202
+ } | {
203
+ value?: never;
204
+ issues: readonly StandardSchemaIssue[];
205
+ };
206
+ /** @public */
207
+ interface StandardSchemaV1<TValues extends NativeFormValues = NativeFormValues> {
208
+ "~standard": {
209
+ version: 1;
210
+ vendor: string;
211
+ validate(value: unknown): StandardSchemaResult<TValues> | Promise<StandardSchemaResult<TValues>>;
212
+ types?: {
213
+ input: unknown;
214
+ output: TValues;
215
+ };
216
+ };
217
+ }
218
+ /** @public */
219
+ type SchemaLike<TValues extends NativeFormValues = NativeFormValues> = Validator<TValues> | StandardSchemaV1<TValues>;
220
+ /** @public */
221
+ type InferSchemaOutput<TSchema> = TSchema extends StandardSchemaV1<infer TValues> ? TValues : TSchema extends Validator<infer TValues> ? TValues : NativeFormValues;
222
+ /** @public */
223
+ declare function createValidator<TValues extends NativeFormValues>(schema: SchemaLike<TValues>): Validator<TValues>;
224
+
225
+ /** @public */
226
+ interface ValidationFieldMeta {
227
+ name: string;
228
+ validationMessage: string;
229
+ }
230
+ /** @public */
231
+ interface ValidationPipelineContext extends ValidationContext {
232
+ fields: ValidationFieldMeta[];
233
+ }
234
+ /** @public */
235
+ interface ValidationPipelineCapabilities {
236
+ /**
237
+ * When true, Runtime will call `validateField` for input/change-triggered
238
+ * validation. When false, Runtime falls back to `validate` even for
239
+ * field-triggered events.
240
+ */
241
+ supportsFieldScopedValidation: boolean;
242
+ }
243
+ /** @public */
244
+ interface ValidationPipeline<TValues extends NativeFormValues = NativeFormValues> {
245
+ /**
246
+ * Declares optional runtime behavior flags for how this pipeline wants to be
247
+ * invoked.
248
+ */
249
+ readonly capabilities?: ValidationPipelineCapabilities;
250
+ /**
251
+ * @example
252
+ * const pipeline: ValidationPipeline = {
253
+ * capabilities: { supportsFieldScopedValidation: false },
254
+ * async validate(values) {
255
+ * return { success: true, values };
256
+ * },
257
+ * async validateField(_field, values) {
258
+ * return { success: true, values };
259
+ * },
260
+ * };
261
+ */
262
+ /**
263
+ * Validates the full serialized values snapshot.
264
+ *
265
+ * Used for full-form validation flows (for example, submit).
266
+ */
267
+ validate(values: NativeFormValues, context: ValidationPipelineContext): ValidationResult<TValues> | Promise<ValidationResult<TValues>>;
268
+ /**
269
+ * Validates a field-triggered update with access to the active field and the
270
+ * full serialized snapshot.
271
+ *
272
+ * Used for input/change-triggered validation when supported.
273
+ */
274
+ validateField(field: ValidationFieldMeta, values: NativeFormValues, context: ValidationPipelineContext): ValidationResult<TValues> | Promise<ValidationResult<TValues>>;
275
+ }
276
+ /** @public */
277
+ interface ValidationPipelineOptions<TValues extends NativeFormValues = NativeFormValues> {
278
+ schema?: SchemaLike<TValues>;
279
+ validator?: Validator<TValues>;
280
+ }
281
+ /** @public */
282
+ declare function createValidationPipeline<TValues extends NativeFormValues = NativeFormValues>(options?: ValidationPipelineOptions<TValues>): ValidationPipeline<TValues>;
283
+
284
+ /** @public */
285
+ interface RuntimeOptions<TValues extends NativeFormValues = NativeFormValues> {
286
+ mode?: ValidationMode;
287
+ serializationMode?: SerializationMode;
288
+ serializeFieldsOptions?: SerializeFieldsOptions;
289
+ nesting?: "flat" | "nested";
290
+ /**
291
+ * When true, preserves serialized values of fields that are removed from the DOM,
292
+ * merging them into subsequent serializations and final submit.
293
+ * @defaultValue false
294
+ */
295
+ preserveUnmountedValues?: boolean;
296
+ schema?: SchemaLike<TValues>;
297
+ validator?: Validator<TValues>;
298
+ pipeline?: ValidationPipeline<TValues>;
299
+ debounceMs?: number;
300
+ asyncValidators?: Record<string, AsyncFieldValidator>;
301
+ onSubmit?: (values: TValues, event?: SubmitEvent) => void | Promise<void>;
302
+ onInvalid?: (errors: Record<string, string>, values: NativeFormValues, event?: SubmitEvent) => void;
303
+ }
304
+ /** @public */
305
+ interface RuntimeFormState {
306
+ dirty: boolean;
307
+ touched: boolean;
308
+ valid: boolean;
309
+ submitting: boolean;
310
+ validating: boolean;
311
+ errors: Record<string, string>;
312
+ fields: FieldState[];
313
+ values: NativeFormFlatValues;
314
+ }
315
+ /** @public */
316
+ interface RuntimePublicApi<TValues extends NativeFormValues = NativeFormValues> {
317
+ readonly fields: FieldState[];
318
+ readonly serializationMode: SerializationMode;
319
+ /**
320
+ * Preserved values from fields that have been unmounted from the DOM
321
+ * when `preserveUnmountedValues: true` is configured.
322
+ */
323
+ readonly preservedValues: Record<string, NativeFormValue>;
324
+ mount(form: HTMLFormElement): void;
325
+ unmount(): void;
326
+ serialize(): NativeFormFlatValues;
327
+ serializeFields(options?: SerializeFieldsOptions): NativeFormValues;
328
+ validate(): Promise<ValidationResult<TValues>>;
329
+ validateFields(fieldNames: readonly string[]): Promise<ValidationResult<TValues>>;
330
+ submit(event?: SubmitEvent): Promise<ValidationResult<TValues>>;
331
+ subscribe(listener: RuntimeListener): () => void;
332
+ unsubscribe(listener: RuntimeListener): void;
333
+ getFieldValue(name: string): NativeFormValue | undefined;
334
+ getFieldState(name: string): FieldState | undefined;
335
+ getFieldStates(): FieldState[];
336
+ getFormState(): RuntimeFormState;
337
+ setOptions(options: Partial<RuntimeOptions<TValues>>): void;
338
+ removeArrayItem(arrayName: string, index: number): void;
339
+ swapArrayItems(arrayName: string, indexA: number, indexB: number): void;
340
+ moveArrayItem(arrayName: string, fromIndex: number, toIndex: number): void;
341
+ insertArrayItem(arrayName: string, index: number): void;
342
+ }
343
+ /** @public */
344
+ declare class Runtime<TValues extends NativeFormValues = NativeFormValues> implements RuntimePublicApi<TValues> {
345
+ private readonly options;
346
+ private readonly registry;
347
+ private readonly discovery;
348
+ private readonly serializer;
349
+ private readonly fieldErrorRenderer;
350
+ private form?;
351
+ private readonly listeners;
352
+ private observer?;
353
+ private validationController?;
354
+ private readonly debounceTimers;
355
+ private readonly fieldValidationControllers;
356
+ private submitting;
357
+ private validating;
358
+ private errors;
359
+ private preservedValuesStore;
360
+ private isSyncingFields;
361
+ private pipeline;
362
+ constructor(options?: RuntimeOptions<TValues>);
363
+ mount(form: HTMLFormElement): void;
364
+ unmount(): void;
365
+ private clearDebounceTimers;
366
+ private abortAllValidations;
367
+ private getAsyncValidator;
368
+ serialize(): NativeFormFlatValues;
369
+ serializeFields(options?: SerializeFieldsOptions): NativeFormValues;
370
+ get fields(): FieldState[];
371
+ get serializationMode(): SerializationMode;
372
+ get preservedValues(): Record<string, NativeFormValue>;
373
+ private extractCurrentValues;
374
+ subscribe(listener: RuntimeListener): () => void;
375
+ unsubscribe(listener: RuntimeListener): void;
376
+ private notify;
377
+ private emitFieldEvent;
378
+ private emitValidationEvent;
379
+ private emitFormEvent;
380
+ submit(event?: SubmitEvent): Promise<ValidationResult<TValues>>;
381
+ validate(): Promise<ValidationResult<TValues>>;
382
+ validateFields(fieldNames: readonly string[]): Promise<ValidationResult<TValues>>;
383
+ private handleSubmit;
384
+ private processSubmitFlow;
385
+ private runValidation;
386
+ private handleFieldUpdate;
387
+ private processInputFlow;
388
+ private processChangeFlow;
389
+ private processUpdateFlow;
390
+ private prepareFieldFlow;
391
+ private triggerFieldValidation;
392
+ private executeFieldValidation;
393
+ private handleFieldBlur;
394
+ private runFieldValidation;
395
+ private handleReset;
396
+ private processResetFlow;
397
+ getFieldState(name: string): FieldState | undefined;
398
+ getFieldStates(): FieldState[];
399
+ setOptions(options: Partial<RuntimeOptions<TValues>>): void;
400
+ removeArrayItem(arrayName: string, index: number): void;
401
+ swapArrayItems(arrayName: string, indexA: number, indexB: number): void;
402
+ moveArrayItem(arrayName: string, fromIndex: number, toIndex: number): void;
403
+ insertArrayItem(arrayName: string, index: number): void;
404
+ getFormState(): RuntimeFormState;
405
+ private ensureField;
406
+ getFieldValue(name: string): NativeFormValue | undefined;
407
+ private getValidationFields;
408
+ private toValidationField;
409
+ private syncFields;
410
+ private handleMutation;
411
+ private applyFieldValidationResult;
412
+ private applyValidationResult;
413
+ private applyNativeErrors;
414
+ }
415
+
416
+ /** @public */
417
+ type FieldPathSegment = string | number;
418
+ /** @public */
419
+ interface ArrayItemPathInfo {
420
+ arrayName: string;
421
+ index: number;
422
+ subPath: string;
423
+ }
424
+ /** @public */
425
+ declare function formPath(...segments: FieldPathSegment[]): string;
426
+ /** @public */
427
+ declare function arrayItemPath(arrayName: string, index: number, ...segments: FieldPathSegment[]): string;
428
+ /**
429
+ * Splits any dot or bracket notation path into string segments.
430
+ *
431
+ * @example
432
+ * splitPath("user.name") // ["user", "name"]
433
+ * splitPath("user[profile][name]") // ["user", "profile", "name"]
434
+ * splitPath("items[0].title") // ["items", "0", "title"]
435
+ *
436
+ * @public
437
+ */
438
+ declare function splitPath(path: string): string[];
439
+ /**
440
+ * Normalizes any dot or bracket notation path into canonical dot notation.
441
+ *
442
+ * @example
443
+ * normalizePath("user[profile][name]") // "user.profile.name"
444
+ * normalizePath("tasks[0].title") // "tasks.0.title"
445
+ *
446
+ * @public
447
+ */
448
+ declare function normalizePath(path: string): string;
449
+ /** @public */
450
+ declare function parseArrayItemPath(path: string): ArrayItemPathInfo | null;
451
+ /** @public */
452
+ declare function isArrayItemPath(path: string, arrayName?: string): boolean;
453
+ /** @public */
454
+ declare function matchArrayItemPath(path: string, arrayName: string): {
455
+ index: number;
456
+ subPath: string;
457
+ } | null;
458
+ /** @public */
459
+ declare function shiftArrayItemIndex(path: string, arrayName: string, fromIndex: number, delta: number): string;
460
+ /** @public */
461
+ declare function remapArrayItemIndex(path: string, arrayName: string, oldIndex: number, newIndex: number): string;
462
+ /**
463
+ * Safely accesses a value at a nested path inside an object or array.
464
+ *
465
+ * @param target - The root object or array
466
+ * @param path - Dot or bracket path string or segment array
467
+ * @param defaultValue - Optional fallback if the resolved value is undefined
468
+ *
469
+ * @public
470
+ */
471
+ declare function getByPath(target: unknown, path: string | readonly string[], defaultValue?: unknown): unknown;
472
+ /**
473
+ * Safely sets a value at a nested path, automatically creating intermediate
474
+ * objects or arrays (for numeric integer segments).
475
+ * Protects against prototype pollution by skipping __proto__, prototype, and constructor.
476
+ *
477
+ * @param target - The root object to modify
478
+ * @param path - Dot or bracket path string or segment array
479
+ * @param value - The value to assign
480
+ *
481
+ * @public
482
+ */
483
+ declare function setByPath(target: Record<string, unknown>, path: string | readonly string[], value: unknown): void;
484
+ /**
485
+ * Transforms a flat key-value map into deeply nested objects and arrays.
486
+ *
487
+ * @param flatValues - Flat map of field names to values
488
+ * @returns Deeply nested object/array structure
489
+ *
490
+ * @public
491
+ */
492
+ declare function toNestedValues<TOutput extends Record<string, unknown> = Record<string, unknown>>(flatValues: Record<string, unknown>): TOutput;
493
+
494
+ export { FieldNode, Runtime, Serializer, arrayItemPath, createValidationPipeline, createValidator, formPath, getByPath, isArrayItemPath, matchArrayItemPath, normalizePath, parseArrayItemPath, remapArrayItemIndex, setByPath, shiftArrayItemIndex, splitPath, toNestedValues };
495
+ export type { ArrayItemPathInfo, AsyncFieldValidator, FieldEvents, FieldPathSegment, FieldState, FormEvents, InferSchemaOutput, NativeFormElement, NativeFormFlatValues, NativeFormNestedValue, NativeFormValue, NativeFormValues, RuntimeEvent, RuntimeEventType, RuntimeFormState, RuntimeListener, RuntimeOptions, RuntimePublicApi, SchemaLike, SerializationMode, SerializeFieldsOptions, StandardSchemaIssue, StandardSchemaResult, StandardSchemaV1, ValidationContext, ValidationEvents, ValidationFieldMeta, ValidationIssue, ValidationMode, ValidationPipeline, ValidationPipelineCapabilities, ValidationPipelineContext, ValidationPipelineOptions, ValidationResult, Validator };