@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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 2.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @saas-ui/core@2.4.2
9
+
10
+ ## 2.5.0
11
+
12
+ ### Minor Changes
13
+
14
+ - Improved forms to support a global base field override
15
+
3
16
  ## 2.4.1
4
17
 
5
18
  ### Patch Changes
@@ -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 };
@@ -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 };