oxform-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 (39) hide show
  1. package/dist/index.cjs +751 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +443 -0
  4. package/dist/index.d.ts +443 -0
  5. package/dist/index.js +747 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +20 -15
  8. package/export/index.ts +0 -7
  9. package/export/schema.ts +0 -1
  10. package/src/field-api.constants.ts +0 -15
  11. package/src/field-api.ts +0 -139
  12. package/src/form-api.ts +0 -84
  13. package/src/form-api.types.ts +0 -148
  14. package/src/form-array-field-api.ts +0 -233
  15. package/src/form-context-api.ts +0 -232
  16. package/src/form-field-api.ts +0 -174
  17. package/src/more-types.ts +0 -178
  18. package/src/tests/array/append.spec.ts +0 -138
  19. package/src/tests/array/insert.spec.ts +0 -182
  20. package/src/tests/array/move.spec.ts +0 -175
  21. package/src/tests/array/prepend.spec.ts +0 -138
  22. package/src/tests/array/remove.spec.ts +0 -174
  23. package/src/tests/array/swap.spec.ts +0 -152
  24. package/src/tests/array/update.spec.ts +0 -148
  25. package/src/tests/field/change.spec.ts +0 -226
  26. package/src/tests/field/reset.spec.ts +0 -617
  27. package/src/tests/field/set-errors.spec.ts +0 -254
  28. package/src/tests/field-api/field-api.spec.ts +0 -341
  29. package/src/tests/form-api/reset.spec.ts +0 -535
  30. package/src/tests/form-api/submit.spec.ts +0 -409
  31. package/src/types.ts +0 -5
  32. package/src/utils/get.ts +0 -5
  33. package/src/utils/testing/sleep.ts +0 -1
  34. package/src/utils/testing/tests.ts +0 -18
  35. package/src/utils/update.ts +0 -6
  36. package/src/utils/validate.ts +0 -8
  37. package/tsconfig.json +0 -3
  38. package/tsdown.config.ts +0 -10
  39. package/vitest.config.ts +0 -3
@@ -0,0 +1,443 @@
1
+ import * as _tanstack_store0 from "@tanstack/store";
2
+ import { Derived, Store } from "@tanstack/store";
3
+ import * as _standard_schema_spec1 from "@standard-schema/spec";
4
+ import { StandardSchemaV1 } from "@standard-schema/spec";
5
+ import { PartialDeep, Simplify } from "type-fest";
6
+
7
+ //#region src/more-types.d.ts
8
+ /**
9
+ * @private
10
+ */
11
+ type UnwrapOneLevelOfArray<T> = T extends (infer U)[] ? U : T;
12
+ type Narrowable = string | number | bigint | boolean;
13
+ type NarrowRaw<A> = (A extends [] ? [] : never) | (A extends Narrowable ? A : never) | { [K in keyof A]: A[K] extends Function ? A[K] : NarrowRaw<A[K]> };
14
+ type Try<A1, A2, Catch = never> = A1 extends A2 ? A1 : Catch;
15
+ /**
16
+ * @private
17
+ */
18
+ type Narrow<A> = Try<A, [], NarrowRaw<A>>;
19
+ interface AnyDeepKeyAndValue<K$1 extends string = string, V extends any = any> {
20
+ key: K$1;
21
+ value: V;
22
+ }
23
+ type ArrayAccessor<TParent extends AnyDeepKeyAndValue> = `${TParent['key'] extends never ? '' : TParent['key']}.${number}`;
24
+ interface ArrayDeepKeyAndValue<in out TParent extends AnyDeepKeyAndValue, in out T extends ReadonlyArray<any>> extends AnyDeepKeyAndValue {
25
+ key: ArrayAccessor<TParent>;
26
+ value: T[number] | Nullable<TParent['value']>;
27
+ }
28
+ type DeepKeyAndValueArray<TParent extends AnyDeepKeyAndValue, T extends ReadonlyArray<any>, TAcc> = DeepKeysAndValuesImpl<NonNullable<T[number]>, ArrayDeepKeyAndValue<TParent, T>, TAcc | ArrayDeepKeyAndValue<TParent, T>>;
29
+ type TupleAccessor<TParent extends AnyDeepKeyAndValue, TKey extends string> = `${TParent['key'] extends never ? '' : TParent['key']}[${TKey}]`;
30
+ interface TupleDeepKeyAndValue<in out TParent extends AnyDeepKeyAndValue, in out T, in out TKey extends AllTupleKeys<T>> extends AnyDeepKeyAndValue {
31
+ key: TupleAccessor<TParent, TKey>;
32
+ value: T[TKey] | Nullable<TParent['value']>;
33
+ }
34
+ type AllTupleKeys<T> = T extends any ? keyof T & `${number}` : never;
35
+ type DeepKeyAndValueTuple<TParent extends AnyDeepKeyAndValue, T extends ReadonlyArray<any>, TAcc, TAllKeys extends AllTupleKeys<T> = AllTupleKeys<T>> = TAllKeys extends any ? DeepKeysAndValuesImpl<NonNullable<T[TAllKeys]>, TupleDeepKeyAndValue<TParent, T, TAllKeys>, TAcc | TupleDeepKeyAndValue<TParent, T, TAllKeys>> : never;
36
+ type AllObjectKeys<T> = T extends any ? keyof T & (string | number) : never;
37
+ type ObjectAccessor<TParent extends AnyDeepKeyAndValue, TKey extends string | number> = TParent['key'] extends never ? `${TKey}` : `${TParent['key']}.${TKey}`;
38
+ type Nullable<T> = T & (undefined | null);
39
+ type ObjectValue<TParent extends AnyDeepKeyAndValue, T, TKey extends AllObjectKeys<T>> = T[TKey] | Nullable<TParent['value']>;
40
+ interface ObjectDeepKeyAndValue<in out TParent extends AnyDeepKeyAndValue, in out T, in out TKey extends AllObjectKeys<T>> extends AnyDeepKeyAndValue {
41
+ key: ObjectAccessor<TParent, TKey>;
42
+ value: ObjectValue<TParent, T, TKey>;
43
+ }
44
+ type DeepKeyAndValueObject<TParent extends AnyDeepKeyAndValue, T, TAcc, TAllKeys extends AllObjectKeys<T> = AllObjectKeys<T>> = TAllKeys extends any ? DeepKeysAndValuesImpl<NonNullable<T[TAllKeys]>, ObjectDeepKeyAndValue<TParent, T, TAllKeys>, TAcc | ObjectDeepKeyAndValue<TParent, T, TAllKeys>> : never;
45
+ type UnknownAccessor<TParent extends AnyDeepKeyAndValue> = TParent['key'] extends never ? string : `${TParent['key']}.${string}`;
46
+ interface UnknownDeepKeyAndValue<TParent extends AnyDeepKeyAndValue> extends AnyDeepKeyAndValue {
47
+ key: UnknownAccessor<TParent>;
48
+ value: unknown;
49
+ }
50
+ type DeepKeysAndValues<T> = DeepKeysAndValuesImpl<T> extends AnyDeepKeyAndValue ? DeepKeysAndValuesImpl<T> : never;
51
+ type DeepKeysAndValuesImpl<T, TParent extends AnyDeepKeyAndValue = never, TAcc = never> = unknown extends T ? TAcc | UnknownDeepKeyAndValue<TParent> : unknown extends T ? T : T extends string | number | boolean | bigint | Date ? TAcc : T extends ReadonlyArray<any> ? number extends T['length'] ? DeepKeyAndValueArray<TParent, T, TAcc> : DeepKeyAndValueTuple<TParent, T, TAcc> : keyof T extends never ? TAcc | UnknownDeepKeyAndValue<TParent> : T extends object ? DeepKeyAndValueObject<TParent, T, TAcc> : TAcc;
52
+ type DeepRecord<T> = { [TRecord in DeepKeysAndValues<T> as TRecord['key']]: TRecord['value'] };
53
+ /**
54
+ * The keys of an object or array, deeply nested.
55
+ */
56
+ type DeepKeys<T> = unknown extends T ? string : DeepKeysAndValues<T>['key'];
57
+ /**
58
+ * Infer the type of a deeply nested property within an object or an array.
59
+ */
60
+ type DeepValue<TValue, TAccessor> = unknown extends TValue ? TValue : TAccessor extends DeepKeys<TValue> ? DeepRecord<TValue>[TAccessor] : never;
61
+ /**
62
+ * The keys of an object or array, deeply nested and only with a value of TValue
63
+ */
64
+ type DeepKeysOfType<TData, TValue> = Extract<DeepKeysAndValues<TData>, AnyDeepKeyAndValue<string, TValue>>['key'];
65
+ /**
66
+ * Maps the deep keys of TFormData to the shallow keys of TFieldGroupData.
67
+ * Since using template strings as keys is impractical, it relies on shallow keys only.
68
+ */
69
+ type FieldsMap<TFormData, TFieldGroupData> = TFieldGroupData extends any[] ? never : string extends keyof TFieldGroupData ? never : { [K in keyof TFieldGroupData]: DeepKeysOfType<TFormData, TFieldGroupData[K]> };
70
+ //#endregion
71
+ //#region src/types.d.ts
72
+ type EventLike = {
73
+ target?: {
74
+ value: any;
75
+ };
76
+ };
77
+ type ArrayLike = any[] | undefined | null;
78
+ //#endregion
79
+ //#region src/form-api.types.d.ts
80
+ type PersistedFormStatus = {
81
+ submits: number;
82
+ submitting: boolean;
83
+ validating: boolean;
84
+ successful: boolean;
85
+ dirty: boolean;
86
+ };
87
+ type FormStatus = Simplify<PersistedFormStatus & {
88
+ submitted: boolean;
89
+ valid: boolean;
90
+ }>;
91
+ type PersistedFieldMeta = {
92
+ blurred: boolean;
93
+ touched: boolean;
94
+ dirty: boolean;
95
+ };
96
+ type FieldMeta = Simplify<PersistedFieldMeta & {
97
+ touched: boolean;
98
+ default: boolean;
99
+ valid: boolean;
100
+ pristine: boolean;
101
+ }>;
102
+ type FormBaseStore<Values> = {
103
+ values: Values;
104
+ fields: Record<string, PersistedFieldMeta>;
105
+ refs: Record<string, HTMLElement | null>;
106
+ status: PersistedFormStatus;
107
+ errors: Record<string, FormIssue[]>;
108
+ };
109
+ type FormStore<Values> = {
110
+ values: Values;
111
+ fields: Record<string, FieldMeta>;
112
+ refs: Record<string, HTMLElement | null>;
113
+ status: FormStatus;
114
+ errors: Record<string, FormIssue[]>;
115
+ };
116
+ type FieldControl<Value> = {
117
+ focus: () => void;
118
+ blur: () => void;
119
+ change: (value: Value) => void;
120
+ register: (element: HTMLElement | null) => void;
121
+ };
122
+ type FormValidatorSchema<Values> = StandardSchemaV1<PartialDeep<Values>>;
123
+ type FormValidatorFunction<Values> = (store: FormStore<Values>) => FormValidatorSchema<Values>;
124
+ type FormValidator<Values> = FormValidatorSchema<Values> | FormValidatorFunction<Values>;
125
+ type FormOptions<Values> = {
126
+ schema: StandardSchemaV1<Values>;
127
+ values?: Values;
128
+ defaultValues: Values;
129
+ validate?: {
130
+ change?: FormValidator<Values>;
131
+ submit?: FormValidator<Values>;
132
+ blur?: FormValidator<Values>;
133
+ focus?: FormValidator<Values>;
134
+ };
135
+ related?: Record<DeepKeys<Values>, DeepKeys<Values>[]>;
136
+ };
137
+ type FormIssue = StandardSchemaV1.Issue;
138
+ type ValidationType = 'change' | 'submit' | 'blur' | 'focus';
139
+ type ValidateOptions = {
140
+ type?: ValidationType;
141
+ };
142
+ type FieldChangeOptions = {
143
+ should?: {
144
+ /** Whether to validate the field after changing its value. Defaults to true. */
145
+ validate?: boolean;
146
+ /** Whether to mark the field as dirty after changing its value. Defaults to true. */
147
+ dirty?: boolean;
148
+ /** Whether to mark the field as touched after changing its value. Defaults to true. */
149
+ touch?: boolean;
150
+ };
151
+ };
152
+ type FieldResetMeta = {
153
+ blurred?: boolean;
154
+ touched?: boolean;
155
+ dirty?: boolean;
156
+ };
157
+ type FieldResetKeepOptions = {
158
+ errors?: boolean;
159
+ refs?: boolean;
160
+ meta?: boolean;
161
+ };
162
+ type FormResetFieldOptions<Value> = {
163
+ value?: Value;
164
+ meta?: FieldResetMeta;
165
+ keep?: FieldResetKeepOptions;
166
+ };
167
+ type FormResetKeepOptions = {
168
+ /** Keep current field errors */
169
+ errors?: boolean;
170
+ /** Keep current references to html input elements */
171
+ refs?: boolean;
172
+ /** Keep current field metadata */
173
+ fields?: boolean;
174
+ };
175
+ type FormResetOptions<Values> = {
176
+ values?: Values;
177
+ status?: Partial<PersistedFormStatus>;
178
+ keep?: FormResetKeepOptions;
179
+ };
180
+ type FieldSetErrorsMode = 'replace' | 'append' | 'keep';
181
+ type FormSetErrorsOptions = {
182
+ mode?: FieldSetErrorsMode;
183
+ };
184
+ type FormSubmitSuccessHandler<Schema extends StandardSchemaV1> = (data: StandardSchemaV1.InferOutput<Schema>, form: FormApi<Schema>) => void | Promise<void>;
185
+ type FormSubmitErrorHandler<Schema extends StandardSchemaV1> = (issues: FormIssue[], form: FormApi<Schema>) => void | Promise<void>;
186
+ type FormSubmitHandlers<Schema extends StandardSchemaV1> = {
187
+ onSuccess: FormSubmitSuccessHandler<Schema>;
188
+ onError?: FormSubmitErrorHandler<Schema>;
189
+ };
190
+ //#endregion
191
+ //#region src/form-context-api.d.ts
192
+ declare class FormContextApi<Values> {
193
+ options: FormOptions<Values>;
194
+ persisted: Store<FormBaseStore<Values>>;
195
+ store: Derived<FormStore<Values>>;
196
+ constructor(options: FormOptions<Values>);
197
+ get status(): {
198
+ submits: number;
199
+ submitting: boolean;
200
+ validating: boolean;
201
+ successful: boolean;
202
+ dirty: boolean;
203
+ submitted: boolean;
204
+ valid: boolean;
205
+ };
206
+ get values(): Values;
207
+ private get validator();
208
+ buildFieldMeta: (fieldName: string, persistedMeta: PersistedFieldMeta | undefined, values: Values, errors: Record<string, FormIssue[]>) => FieldMeta;
209
+ setFieldMeta: (name: string, meta: Partial<PersistedFieldMeta>) => void;
210
+ resetFieldMeta: (name: string) => void;
211
+ recomputeFieldMeta: (name: string) => void;
212
+ setStatus: (status: Partial<PersistedFormStatus>) => void;
213
+ validate: (field?: FormFields<FormApi<Values>> | FormFields<FormApi<Values>>[], options?: ValidateOptions) => Promise<_standard_schema_spec1.StandardSchemaV1.Issue[]>;
214
+ }
215
+ //#endregion
216
+ //#region src/utils/update.d.ts
217
+ type UpdaterFn<TInput, TOutput = TInput> = (input: TInput) => TOutput;
218
+ type Updater<TInput, TOutput = TInput> = TOutput | UpdaterFn<TInput, TOutput>;
219
+ //#endregion
220
+ //#region src/form-field-api.d.ts
221
+ declare class FormFieldApi<Values> {
222
+ private context;
223
+ constructor(context: FormContextApi<Values>);
224
+ /**
225
+ * Changes the value of a specific field with optional control over side effects.
226
+ * @param name - The name of the field to change
227
+ * @param value - The new value to set for the field
228
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
229
+ */
230
+ change: <const Name extends FormFields<FormApi<Values>>>(name: Name, updater: Updater<DeepValue<Values, Name>>, options?: FieldChangeOptions) => void;
231
+ focus: <const Name extends FormFields<FormApi<Values>>>(name: Name) => void;
232
+ blur: <const Name extends FormFields<FormApi<Values>>>(name: Name) => void;
233
+ get: <const Name extends FormFields<FormApi<Values>>>(name: Name) => DeepValue<Values, Name>;
234
+ meta: <const Name extends FormFields<FormApi<Values>>>(name: Name) => {
235
+ blurred: boolean;
236
+ touched: boolean;
237
+ dirty: boolean;
238
+ default: boolean;
239
+ valid: boolean;
240
+ pristine: boolean;
241
+ };
242
+ register: <const Name extends FormFields<FormApi<Values>>>(name: Name) => (element: HTMLElement | null) => void;
243
+ errors: <const Name extends FormFields<FormApi<Values>>>(name: Name) => _standard_schema_spec1.StandardSchemaV1.Issue[];
244
+ setErrors: <const Name extends FormFields<FormApi<Values>>>(name: Name, errors: FormIssue[], options?: FormSetErrorsOptions) => void;
245
+ reset: <const Name extends FormFields<FormApi<Values>>>(name: Name, options?: FormResetFieldOptions<DeepValue<Values, Name>>) => void;
246
+ }
247
+ //#endregion
248
+ //#region src/form-array-field-api.d.ts
249
+ declare class FormArrayFieldApi<Values> {
250
+ private context;
251
+ private field;
252
+ constructor({
253
+ field,
254
+ context
255
+ }: {
256
+ field: FormFieldApi<Values>;
257
+ context: FormContextApi<Values>;
258
+ });
259
+ insert: <const Name extends FormArrayFields<FormApi<Values>>>(name: Name, index: number, value: Updater<UnwrapOneLevelOfArray<DeepValue<Values, Name>>>, options?: FieldChangeOptions) => void;
260
+ append: <const Name extends FormArrayFields<FormApi<Values>>>(name: Name, value: UnwrapOneLevelOfArray<DeepValue<Values, Name>>, options?: FieldChangeOptions) => void;
261
+ prepend: <const Name extends FormArrayFields<FormApi<Values>>>(name: Name, value: UnwrapOneLevelOfArray<DeepValue<Values, Name>>, options?: FieldChangeOptions) => void;
262
+ swap: <const Name extends FormArrayFields<FormApi<Values>>>(name: Name, from: number, to: number, options?: FieldChangeOptions) => void;
263
+ move<const Name extends FormArrayFields<FormApi<Values>>>(name: Name, _from: number, _to: number, options?: FieldChangeOptions): void;
264
+ update: <const Name extends FormArrayFields<FormApi<Values>>>(name: Name, index: number, value: Updater<UnwrapOneLevelOfArray<DeepValue<Values, Name>>>, options?: FieldChangeOptions) => void;
265
+ remove<const Name extends FormArrayFields<FormApi<Values>>>(name: Name, index: number, options?: FieldChangeOptions): void;
266
+ replace<const Name extends FormArrayFields<FormApi<Values>>>(name: Name, value: Updater<DeepValue<Values, Name>>, options?: FieldChangeOptions): void;
267
+ }
268
+ //#endregion
269
+ //#region src/form-api.d.ts
270
+ type AnyFormApi = FormApi<any>;
271
+ type FormValues<Form extends AnyFormApi> = Form extends FormApi<infer Values> ? Values : never;
272
+ type FormFields<Form extends AnyFormApi> = DeepKeys<FormValues<Form>>;
273
+ type FormArrayFields<Form extends AnyFormApi> = DeepKeysOfType<FormValues<Form>, ArrayLike>;
274
+ type FormFieldValue<Form extends AnyFormApi, Name extends FormFields<Form>> = DeepValue<FormValues<Form>, Name>;
275
+ declare class FormApi<Values> {
276
+ private context;
277
+ field: FormFieldApi<Values>;
278
+ array: FormArrayFieldApi<Values>;
279
+ constructor(options: FormOptions<Values>);
280
+ '~mount': () => () => void;
281
+ '~update': (options: FormOptions<Values>) => void;
282
+ store: () => _tanstack_store0.Derived<FormStore<Values>, readonly any[]>;
283
+ status: () => {
284
+ submits: number;
285
+ submitting: boolean;
286
+ validating: boolean;
287
+ successful: boolean;
288
+ dirty: boolean;
289
+ submitted: boolean;
290
+ valid: boolean;
291
+ };
292
+ values: () => Values;
293
+ options: () => FormOptions<Values>;
294
+ get validate(): (field?: DeepKeys<Values> | DeepKeys<Values>[] | undefined, options?: ValidateOptions) => Promise<StandardSchemaV1.Issue[]>;
295
+ submit: (onSuccess: FormSubmitSuccessHandler<StandardSchemaV1<Values>>, onError?: FormSubmitErrorHandler<StandardSchemaV1<Values>>) => () => Promise<void>;
296
+ reset: (options?: FormResetOptions<Values>) => void;
297
+ }
298
+ //#endregion
299
+ //#region src/field-api.d.ts
300
+ type FieldOptions<Form extends AnyFormApi, Name extends FormFields<Form>> = {
301
+ form: Form;
302
+ name: Name;
303
+ };
304
+ type FieldState<Value> = {
305
+ value: Value;
306
+ defaultValue: Value;
307
+ meta: FieldMeta;
308
+ errors: FormIssue[];
309
+ };
310
+ type AnyFieldApi = FieldApi<any>;
311
+ declare class FieldApi<Value> {
312
+ private _options;
313
+ private form;
314
+ private _store;
315
+ constructor(options: FieldOptions<AnyFormApi, string>);
316
+ '~mount': () => () => void;
317
+ '~update': (options: FieldOptions<AnyFormApi, string>) => void;
318
+ options: () => FieldOptions<AnyFormApi, string>;
319
+ store: () => Derived<FieldState<Value>, readonly any[]>;
320
+ state: () => FieldState<Value>;
321
+ focus: () => void;
322
+ blur: () => void;
323
+ /**
324
+ * Changes the value of this field with optional control over side effects.
325
+ * @param value - The new value to set for the field
326
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
327
+ */
328
+ change: (value: Updater<Value>, options?: FieldChangeOptions) => void;
329
+ register: () => (element: HTMLElement | null) => void;
330
+ /**
331
+ * Validates this specific field using the specified validation type.
332
+ * @param options - Optional validation options specifying the validation type ('change' | 'submit' | 'blur' | 'focus')
333
+ * @returns Promise resolving to an array of validation issues for this field
334
+ */
335
+ validate: (options?: ValidateOptions) => Promise<_standard_schema_spec1.StandardSchemaV1.Issue[]>;
336
+ /**
337
+ * Resets this field to its default value and optionally resets metadata and errors.
338
+ * @param options - Reset options for controlling what gets reset and what gets kept
339
+ */
340
+ reset: (options?: FormResetFieldOptions<Value>) => void;
341
+ /**
342
+ * Sets validation errors for this specific field.
343
+ * @param errors - Array of validation errors to set
344
+ * @param mode - How to handle existing errors: 'replace' (default), 'append', or 'keep'
345
+ */
346
+ setErrors: (errors: FormIssue[], options?: FormSetErrorsOptions) => void;
347
+ }
348
+ declare const createFieldApi: <Form extends AnyFormApi, const Name extends FormFields<Form>>(options: FieldOptions<Form, Name>) => FieldApi<FormFieldValue<Form, Name>>;
349
+ //#endregion
350
+ //#region src/array-field-api.d.ts
351
+ type ArrayFieldOptions<Form extends AnyFormApi, Name extends FormArrayFields<Form>> = {
352
+ form: Form;
353
+ name: Name;
354
+ };
355
+ type AnyArrayFieldApi = ArrayFieldApi<any>;
356
+ declare class ArrayFieldApi<Value extends ArrayLike> {
357
+ private field;
358
+ constructor(options: FieldOptions<AnyFormApi, string>);
359
+ private get _options();
360
+ '~mount': () => () => void;
361
+ '~update': (options: FieldOptions<AnyFormApi, string>) => void;
362
+ store: () => _tanstack_store0.Derived<FieldState<Value>, readonly any[]>;
363
+ state: () => FieldState<Value>;
364
+ /**
365
+ * Appends a new item to the end of the array.
366
+ * @param value - The value to append to the array
367
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
368
+ */
369
+ append: (value: UnwrapOneLevelOfArray<Value>, options?: FieldChangeOptions) => void;
370
+ /**
371
+ * Prepends a new item to the beginning of the array.
372
+ * @param value - The value to prepend to the array
373
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
374
+ */
375
+ prepend: (value: UnwrapOneLevelOfArray<Value>, options?: FieldChangeOptions) => void;
376
+ /**
377
+ * Inserts a new item at the specified index in the array.
378
+ * @param index - The index at which to insert the value
379
+ * @param value - The value to insert into the array
380
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
381
+ */
382
+ insert: (index: number, value: Updater<UnwrapOneLevelOfArray<Value>>, options?: FieldChangeOptions) => void;
383
+ /**
384
+ * Updates an item at the specified index in the array.
385
+ * @param index - The index of the item to update
386
+ * @param value - The new value or updater function
387
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
388
+ */
389
+ update: (index: number, value: Updater<UnwrapOneLevelOfArray<Value>>, options?: FieldChangeOptions) => void;
390
+ /**
391
+ * Removes an item at the specified index from the array.
392
+ * @param index - The index of the item to remove
393
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
394
+ */
395
+ remove: (index: number, options?: FieldChangeOptions) => void;
396
+ /**
397
+ * Swaps two items in the array by their indices.
398
+ * @param from - The index of the first item
399
+ * @param to - The index of the second item
400
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
401
+ */
402
+ swap: (from: number, to: number, options?: FieldChangeOptions) => void;
403
+ /**
404
+ * Moves an item from one index to another in the array.
405
+ * @param from - The index of the item to move
406
+ * @param to - The target index
407
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
408
+ */
409
+ move: (from: number, to: number, options?: FieldChangeOptions) => void;
410
+ /**
411
+ * Replaces the entire array with a new value.
412
+ * @param value - The new array value or updater function
413
+ * @param options - Optional configuration for controlling validation, dirty state, and touched state
414
+ */
415
+ replace: (value: Updater<Value>, options?: FieldChangeOptions) => void;
416
+ /**
417
+ * Validates this specific array field using the specified validation type.
418
+ * @param options - Optional validation options specifying the validation type ('change' | 'submit' | 'blur' | 'focus')
419
+ * @returns Promise resolving to an array of validation issues for this field
420
+ */
421
+ validate: (options?: ValidateOptions) => Promise<StandardSchemaV1.Issue[]>;
422
+ /**
423
+ * Resets this array field to its default value and optionally resets metadata and errors.
424
+ * @param options - Reset options for controlling what gets reset and what gets kept
425
+ */
426
+ reset: (options?: FormResetFieldOptions<Value>) => void;
427
+ /**
428
+ * Sets validation errors for this specific array field.
429
+ * @param errors - Array of validation errors to set
430
+ * @param mode - How to handle existing errors: 'replace' (default), 'append', or 'keep'
431
+ */
432
+ setErrors: (errors: FormIssue[], options?: FormSetErrorsOptions) => void;
433
+ }
434
+ declare const createArrayFieldApi: <FormApi$1 extends AnyFormApi, const Name extends FormArrayFields<FormApi$1>>(options: ArrayFieldOptions<FormApi$1, Name>) => ArrayFieldApi<FormFieldValue<FormApi$1, Name>>;
435
+ //#endregion
436
+ //#region src/types/any-form-like-api.d.ts
437
+ type AnyFormLikeApi = AnyFormApi | AnyArrayFieldApi | AnyFieldApi;
438
+ //#endregion
439
+ //#region src/types/api-selector.d.ts
440
+ type ApiSelector<Api extends AnyFormLikeApi, Selected> = (state: ReturnType<Api['store']>['state']) => Selected;
441
+ //#endregion
442
+ export { AllObjectKeys, AllTupleKeys, type AnyArrayFieldApi, AnyDeepKeyAndValue, type AnyFieldApi, type AnyFormApi, type AnyFormLikeApi, type ApiSelector, ArrayAccessor, ArrayDeepKeyAndValue, ArrayFieldApi, type ArrayFieldOptions, type ArrayLike, DeepKeyAndValueArray, DeepKeyAndValueObject, DeepKeyAndValueTuple, DeepKeys, DeepKeysAndValues, DeepKeysAndValuesImpl, DeepKeysOfType, DeepRecord, DeepValue, type EventLike, FieldApi, FieldChangeOptions, FieldControl, FieldMeta, type FieldOptions, FieldResetKeepOptions, FieldResetMeta, FieldSetErrorsMode, type FieldState, FieldsMap, FormApi, type FormArrayFields, FormBaseStore, type FormFieldValue, type FormFields, FormIssue, FormOptions, FormResetFieldOptions, FormResetKeepOptions, FormResetOptions, FormSetErrorsOptions, FormStatus, FormStore, FormSubmitErrorHandler, FormSubmitHandlers, FormSubmitSuccessHandler, type FormValues, Narrow, Nullable, ObjectAccessor, ObjectDeepKeyAndValue, ObjectValue, PersistedFieldMeta, PersistedFormStatus, type Simplify, type StandardSchemaV1 as StandardSchema, TupleAccessor, TupleDeepKeyAndValue, UnknownAccessor, UnknownDeepKeyAndValue, UnwrapOneLevelOfArray, ValidateOptions, ValidationType, createArrayFieldApi, createFieldApi };
443
+ //# sourceMappingURL=index.d.ts.map