formstand 0.4.1 → 0.5.0
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.
- package/CHANGELOG.md +105 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -1
package/dist/index.d.cts
CHANGED
|
@@ -85,7 +85,7 @@ type SubmitResult<TOutput> = Readonly<{
|
|
|
85
85
|
kind: "error";
|
|
86
86
|
error: unknown;
|
|
87
87
|
}>;
|
|
88
|
-
type ArrayItemOf<T> = T extends readonly (infer U)[] ? U : never;
|
|
88
|
+
type ArrayItemOf$1<T> = T extends readonly (infer U)[] ? U : never;
|
|
89
89
|
type ErrorPath<TValues> = FieldPath<TValues> | "";
|
|
90
90
|
type ResetOptions = Readonly<{
|
|
91
91
|
keepErrors?: boolean;
|
|
@@ -129,9 +129,9 @@ type Form<TSchema extends z.ZodType> = Readonly<{
|
|
|
129
129
|
validateFieldAsync: (path: ErrorPath<z.input<TSchema>>) => Promise<FieldValidationResult>;
|
|
130
130
|
validateFieldsAsync: (paths: readonly FieldPath<z.input<TSchema>>[]) => Promise<boolean>;
|
|
131
131
|
submit: (onValid: SubmitHandler<TSchema>, onInvalid?: InvalidSubmitHandler, options?: SubmitOptions) => Promise<SubmitResult<z.output<TSchema>>>;
|
|
132
|
-
arrayPush: <P extends FieldPath<z.input<TSchema>>>(path: P, item: ArrayItemOf<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
132
|
+
arrayPush: <P extends FieldPath<z.input<TSchema>>>(path: P, item: ArrayItemOf$1<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
133
133
|
arrayRemove: (path: FieldPath<z.input<TSchema>>, index: number) => void;
|
|
134
|
-
arrayInsert: <P extends FieldPath<z.input<TSchema>>>(path: P, index: number, item: ArrayItemOf<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
134
|
+
arrayInsert: <P extends FieldPath<z.input<TSchema>>>(path: P, index: number, item: ArrayItemOf$1<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
135
135
|
arrayMove: (path: FieldPath<z.input<TSchema>>, from: number, to: number) => void;
|
|
136
136
|
arraySwap: (path: FieldPath<z.input<TSchema>>, a: number, b: number) => void;
|
|
137
137
|
handleSubmit: (onValid: SubmitHandler<TSchema>, onInvalid?: InvalidSubmitHandler, options?: SubmitOptions) => (event?: {
|
|
@@ -288,7 +288,12 @@ type UseFieldArrayReturn<TItem> = Readonly<{
|
|
|
288
288
|
move: (from: number, to: number) => void;
|
|
289
289
|
swap: (a: number, b: number) => void;
|
|
290
290
|
}>;
|
|
291
|
-
|
|
291
|
+
type ArrayItemOf<T> = [NonNullable<T>] extends [readonly (infer U)[]] ? U : never;
|
|
292
|
+
declare function useFieldArray<TSchema extends z.ZodType>(form: Form<TSchema>, pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
|
|
293
|
+
declare function useFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
|
|
294
|
+
readonly schema?: undefined;
|
|
295
|
+
}, path: string | ((state: FormState<unknown>) => string)): UseFieldArrayReturn<TItem>;
|
|
296
|
+
declare function useFieldArray<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>>>(form: Form<TSchema>, path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
|
|
292
297
|
|
|
293
298
|
type TextInputProps = Readonly<{
|
|
294
299
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ type SubmitResult<TOutput> = Readonly<{
|
|
|
85
85
|
kind: "error";
|
|
86
86
|
error: unknown;
|
|
87
87
|
}>;
|
|
88
|
-
type ArrayItemOf<T> = T extends readonly (infer U)[] ? U : never;
|
|
88
|
+
type ArrayItemOf$1<T> = T extends readonly (infer U)[] ? U : never;
|
|
89
89
|
type ErrorPath<TValues> = FieldPath<TValues> | "";
|
|
90
90
|
type ResetOptions = Readonly<{
|
|
91
91
|
keepErrors?: boolean;
|
|
@@ -129,9 +129,9 @@ type Form<TSchema extends z.ZodType> = Readonly<{
|
|
|
129
129
|
validateFieldAsync: (path: ErrorPath<z.input<TSchema>>) => Promise<FieldValidationResult>;
|
|
130
130
|
validateFieldsAsync: (paths: readonly FieldPath<z.input<TSchema>>[]) => Promise<boolean>;
|
|
131
131
|
submit: (onValid: SubmitHandler<TSchema>, onInvalid?: InvalidSubmitHandler, options?: SubmitOptions) => Promise<SubmitResult<z.output<TSchema>>>;
|
|
132
|
-
arrayPush: <P extends FieldPath<z.input<TSchema>>>(path: P, item: ArrayItemOf<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
132
|
+
arrayPush: <P extends FieldPath<z.input<TSchema>>>(path: P, item: ArrayItemOf$1<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
133
133
|
arrayRemove: (path: FieldPath<z.input<TSchema>>, index: number) => void;
|
|
134
|
-
arrayInsert: <P extends FieldPath<z.input<TSchema>>>(path: P, index: number, item: ArrayItemOf<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
134
|
+
arrayInsert: <P extends FieldPath<z.input<TSchema>>>(path: P, index: number, item: ArrayItemOf$1<NonNullable<FieldValue<z.input<TSchema>, P>>>) => void;
|
|
135
135
|
arrayMove: (path: FieldPath<z.input<TSchema>>, from: number, to: number) => void;
|
|
136
136
|
arraySwap: (path: FieldPath<z.input<TSchema>>, a: number, b: number) => void;
|
|
137
137
|
handleSubmit: (onValid: SubmitHandler<TSchema>, onInvalid?: InvalidSubmitHandler, options?: SubmitOptions) => (event?: {
|
|
@@ -288,7 +288,12 @@ type UseFieldArrayReturn<TItem> = Readonly<{
|
|
|
288
288
|
move: (from: number, to: number) => void;
|
|
289
289
|
swap: (a: number, b: number) => void;
|
|
290
290
|
}>;
|
|
291
|
-
|
|
291
|
+
type ArrayItemOf<T> = [NonNullable<T>] extends [readonly (infer U)[]] ? U : never;
|
|
292
|
+
declare function useFieldArray<TSchema extends z.ZodType>(form: Form<TSchema>, pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
|
|
293
|
+
declare function useFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
|
|
294
|
+
readonly schema?: undefined;
|
|
295
|
+
}, path: string | ((state: FormState<unknown>) => string)): UseFieldArrayReturn<TItem>;
|
|
296
|
+
declare function useFieldArray<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>>>(form: Form<TSchema>, path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
|
|
292
297
|
|
|
293
298
|
type TextInputProps = Readonly<{
|
|
294
299
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -1427,7 +1427,7 @@ var reconcileIds = (prev, nextItems) => {
|
|
|
1427
1427
|
counter: prev.counter + Math.max(0, unmatched - leftover.length)
|
|
1428
1428
|
};
|
|
1429
1429
|
};
|
|
1430
|
-
|
|
1430
|
+
function useFieldArray(form, pathArg) {
|
|
1431
1431
|
const path = useStore(
|
|
1432
1432
|
form.store,
|
|
1433
1433
|
(state) => typeof pathArg === "function" ? pathArg(state) : pathArg
|
|
@@ -1492,7 +1492,7 @@ var useFieldArray = (form, pathArg) => {
|
|
|
1492
1492
|
}),
|
|
1493
1493
|
[fields, items, error, push, remove, insert, move, swap]
|
|
1494
1494
|
);
|
|
1495
|
-
}
|
|
1495
|
+
}
|
|
1496
1496
|
|
|
1497
1497
|
export { CheckboxField, NumberField, SelectField, TextField, checkboxProps, createForm, createFormContext, emptyValueForSchema, flattenIssues, focusField, focusFirstError, getAtPath, isAsyncRequiredError, numberInputProps, numberToInputText, parseNumberText, parsePath, selectProps, setAtPath, shouldValidateOn, textInputProps, useField, useFieldArray, useForm, useFormError, useFormSelector, useFormSelectorShallow, useIsDirty, useIsSubmitting, useIsValid, useSubmitCount, validateAsync, validateSync };
|
|
1498
1498
|
//# sourceMappingURL=index.js.map
|