@saas-ui/forms 2.4.1 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -0
- package/dist/ajv/index.d.mts +34 -0
- package/dist/ajv/index.d.ts +1 -1
- package/dist/index.d.mts +908 -0
- package/dist/index.d.ts +53 -31
- package/dist/index.js +111 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -50
- package/dist/index.mjs.map +1 -1
- package/dist/yup/index.d.mts +254 -0
- package/dist/yup/index.d.ts +72 -476
- package/dist/yup/index.js.map +1 -1
- package/dist/yup/index.mjs.map +1 -1
- package/dist/zod/index.d.mts +279 -0
- package/dist/zod/index.d.ts +71 -474
- package/dist/zod/index.js.map +1 -1
- package/dist/zod/index.mjs.map +1 -1
- package/package.json +5 -3
- package/src/base-field.tsx +29 -7
- package/src/create-field.tsx +38 -32
- package/src/create-form.tsx +30 -12
- package/src/create-step-form.tsx +23 -9
- package/src/fields-context.tsx +17 -7
- package/src/form.tsx +31 -9
- package/src/index.ts +2 -1
- package/src/types.ts +66 -42
- package/src/use-array-field.tsx +3 -2
package/CHANGELOG.md
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
import { FieldResolver, CreateFormProps, WithFields, FormProps } from '@saas-ui/forms';
|
2
|
+
import { ajvResolver } from '@hookform/resolvers/ajv';
|
3
|
+
export { ajvResolver } from '@hookform/resolvers/ajv';
|
4
|
+
import { JTDDataType } from 'ajv/dist/jtd';
|
5
|
+
export { JTDDataType, JTDSchemaType } from 'ajv/dist/jtd';
|
6
|
+
import { JSONSchemaType } from 'ajv';
|
7
|
+
|
8
|
+
declare const ajvFieldResolver: (schema: JSONSchemaType<unknown>) => FieldResolver;
|
9
|
+
|
10
|
+
type ResolverArgs = Parameters<typeof ajvResolver>;
|
11
|
+
interface CreateAjvFormProps<FieldDefs> extends CreateFormProps<FieldDefs> {
|
12
|
+
schemaOptions?: ResolverArgs[1];
|
13
|
+
resolverOptions?: ResolverArgs[2];
|
14
|
+
}
|
15
|
+
type ParseJsonSchema<T> = T extends {
|
16
|
+
type: 'object';
|
17
|
+
} ? JTDDataType<T> extends infer R ? R extends object ? R : never : never : never;
|
18
|
+
type AjvFormType<FieldDefs, ExtraProps = object, JsonSchema extends Record<string, any> = Record<string, any>> = (<TSchema extends JsonSchema = JsonSchema, TFieldValues extends ParseJsonSchema<TSchema> = ParseJsonSchema<TSchema>, TContext extends object = object>(props: WithFields<FormProps<TSchema, TFieldValues, TContext>, FieldDefs> & {
|
19
|
+
ref?: React.ForwardedRef<HTMLFormElement>;
|
20
|
+
} & ExtraProps) => React.ReactElement) & {
|
21
|
+
displayName?: string;
|
22
|
+
id?: string;
|
23
|
+
};
|
24
|
+
/**
|
25
|
+
* Create a Form component with AJV validation that accepts JSON Type Definition schema
|
26
|
+
*
|
27
|
+
* @see Docs https://saas-ui.dev/docs/components/forms/form
|
28
|
+
* @see https://ajv.js.org/json-type-definition.html
|
29
|
+
*/
|
30
|
+
declare function createAjvForm<FieldDefs>(options?: CreateAjvFormProps<FieldDefs>): AjvFormType<FieldDefs, object, Record<string, any>>;
|
31
|
+
|
32
|
+
declare const Form: AjvFormType<unknown, object, Record<string, any>>;
|
33
|
+
|
34
|
+
export { type CreateAjvFormProps, Form, ajvFieldResolver, createAjvForm };
|
package/dist/ajv/index.d.ts
CHANGED
@@ -31,4 +31,4 @@ declare function createAjvForm<FieldDefs>(options?: CreateAjvFormProps<FieldDefs
|
|
31
31
|
|
32
32
|
declare const Form: AjvFormType<unknown, object, Record<string, any>>;
|
33
33
|
|
34
|
-
export { CreateAjvFormProps, Form, ajvFieldResolver, createAjvForm };
|
34
|
+
export { type CreateAjvFormProps, Form, ajvFieldResolver, createAjvForm };
|