@saas-ui/forms 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +11 -0
- package/dist/ajv/index.js +42 -14
- package/dist/ajv/index.js.map +1 -1
- package/dist/ajv/index.mjs +14 -6
- package/dist/ajv/index.mjs.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +539 -322
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +481 -165
- package/dist/index.mjs.map +1 -1
- package/dist/yup/index.d.ts +2 -2
- package/dist/yup/index.js +120 -82
- package/dist/yup/index.js.map +1 -1
- package/dist/yup/index.mjs +132 -38
- package/dist/yup/index.mjs.map +1 -1
- package/dist/zod/index.d.ts +2 -2
- package/dist/zod/index.js +116 -83
- package/dist/zod/index.js.map +1 -1
- package/dist/zod/index.mjs +124 -35
- package/dist/zod/index.mjs.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
package/dist/ajv/index.js
CHANGED
@@ -1,15 +1,45 @@
|
|
1
|
-
'use
|
1
|
+
'use client'
|
2
|
+
"use strict";
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
2
20
|
|
3
|
-
|
4
|
-
var
|
21
|
+
// ajv/src/index.ts
|
22
|
+
var src_exports = {};
|
23
|
+
__export(src_exports, {
|
24
|
+
Form: () => Form,
|
25
|
+
ajvFieldResolver: () => ajvFieldResolver,
|
26
|
+
ajvResolver: () => import_ajv.ajvResolver,
|
27
|
+
createAjvForm: () => createAjvForm
|
28
|
+
});
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
5
30
|
|
6
31
|
// ajv/src/ajv-resolver.ts
|
32
|
+
var import_ajv = require("@hookform/resolvers/ajv");
|
33
|
+
var import_forms = require("@saas-ui/forms");
|
7
34
|
var ajvFieldResolver = (schema) => {
|
8
|
-
return
|
35
|
+
return (0, import_forms.objectFieldResolver)(schema.properties);
|
9
36
|
};
|
37
|
+
|
38
|
+
// ajv/src/create-ajv-form.ts
|
39
|
+
var import_forms2 = require("@saas-ui/forms");
|
10
40
|
function createAjvForm(options) {
|
11
|
-
return
|
12
|
-
resolver: (schema) =>
|
41
|
+
return (0, import_forms2.createForm)({
|
42
|
+
resolver: (schema) => (0, import_ajv.ajvResolver)(schema, options == null ? void 0 : options.schemaOptions, options == null ? void 0 : options.resolverOptions),
|
13
43
|
fieldResolver: ajvFieldResolver,
|
14
44
|
...options
|
15
45
|
});
|
@@ -17,13 +47,11 @@ function createAjvForm(options) {
|
|
17
47
|
|
18
48
|
// ajv/src/index.ts
|
19
49
|
var Form = createAjvForm();
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
51
|
+
0 && (module.exports = {
|
52
|
+
Form,
|
53
|
+
ajvFieldResolver,
|
54
|
+
ajvResolver,
|
55
|
+
createAjvForm
|
24
56
|
});
|
25
|
-
exports.Form = Form;
|
26
|
-
exports.ajvFieldResolver = ajvFieldResolver;
|
27
|
-
exports.createAjvForm = createAjvForm;
|
28
|
-
//# sourceMappingURL=out.js.map
|
29
57
|
//# sourceMappingURL=index.js.map
|
package/dist/ajv/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../ajv/src/
|
1
|
+
{"version":3,"sources":["../../ajv/src/index.ts","../../ajv/src/ajv-resolver.ts","../../ajv/src/create-ajv-form.ts"],"sourcesContent":["export * from './ajv-resolver'\nexport { createAjvForm } from './create-ajv-form'\nexport type { CreateAjvFormProps } from './create-ajv-form'\nexport type { JTDDataType, JTDSchemaType } from 'ajv/dist/jtd'\n\nimport { createAjvForm } from './create-ajv-form'\n\nexport const Form = createAjvForm()\n","import { ajvResolver } from '@hookform/resolvers/ajv'\nimport { objectFieldResolver, FieldResolver } from '@saas-ui/forms'\n\nimport { JSONSchemaType } from 'ajv'\n\nexport { ajvResolver }\n\nexport const ajvFieldResolver = (schema: JSONSchemaType<unknown>) => {\n return objectFieldResolver(schema.properties)\n}\n","import {\n createForm,\n CreateFormProps,\n FieldValues,\n FormProps,\n WithFields,\n} from '@saas-ui/forms'\nimport { ajvFieldResolver, ajvResolver } from './ajv-resolver'\nimport { JTDDataType } from 'ajv/dist/jtd'\ntype ResolverArgs = Parameters<typeof ajvResolver>\n\nexport interface CreateAjvFormProps<FieldDefs>\n extends CreateFormProps<FieldDefs> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\ntype ParseJsonSchema<T> = T extends { type: 'object' }\n ? JTDDataType<T> extends infer R\n ? R extends object\n ? R\n : never\n : never\n : never\n\nexport type AjvFormType<\n FieldDefs,\n ExtraProps = object,\n JsonSchema extends Record<string, any> = Record<string, any>\n> = (<\n TSchema extends JsonSchema = JsonSchema,\n TFieldValues extends ParseJsonSchema<TSchema> = ParseJsonSchema<TSchema>,\n TContext extends object = object\n>(\n props: WithFields<FormProps<TSchema, TFieldValues, TContext>, FieldDefs> & {\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\n/**\n * Create a Form component with AJV validation that accepts JSON Type Definition schema\n *\n * @see Docs https://saas-ui.dev/docs/components/forms/form\n * @see https://ajv.js.org/json-type-definition.html\n */\nexport function createAjvForm<FieldDefs>(\n options?: CreateAjvFormProps<FieldDefs>\n) {\n return createForm({\n resolver: (schema: any) =>\n ajvResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: ajvFieldResolver,\n ...options,\n }) as AjvFormType<FieldDefs>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAA4B;AAC5B,mBAAmD;AAM5C,IAAM,mBAAmB,CAAC,WAAoC;AACnE,aAAO,kCAAoB,OAAO,UAAU;AAC9C;;;ACTA,IAAAA,gBAMO;AA0CA,SAAS,cACd,SACA;AACA,aAAO,0BAAW;AAAA,IAChB,UAAU,CAAC,eACT,wBAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AACH;;;AFlDO,IAAM,OAAO,cAAc;","names":["import_forms"]}
|
package/dist/ajv/index.mjs
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
|
2
|
-
export { ajvResolver } from '@hookform/resolvers/ajv';
|
3
|
-
import { objectFieldResolver, createForm } from '@saas-ui/forms';
|
1
|
+
'use client'
|
4
2
|
|
5
3
|
// ajv/src/ajv-resolver.ts
|
4
|
+
import { ajvResolver } from "@hookform/resolvers/ajv";
|
5
|
+
import { objectFieldResolver } from "@saas-ui/forms";
|
6
6
|
var ajvFieldResolver = (schema) => {
|
7
7
|
return objectFieldResolver(schema.properties);
|
8
8
|
};
|
9
|
+
|
10
|
+
// ajv/src/create-ajv-form.ts
|
11
|
+
import {
|
12
|
+
createForm
|
13
|
+
} from "@saas-ui/forms";
|
9
14
|
function createAjvForm(options) {
|
10
15
|
return createForm({
|
11
16
|
resolver: (schema) => ajvResolver(schema, options == null ? void 0 : options.schemaOptions, options == null ? void 0 : options.resolverOptions),
|
@@ -16,7 +21,10 @@ function createAjvForm(options) {
|
|
16
21
|
|
17
22
|
// ajv/src/index.ts
|
18
23
|
var Form = createAjvForm();
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
export {
|
25
|
+
Form,
|
26
|
+
ajvFieldResolver,
|
27
|
+
ajvResolver,
|
28
|
+
createAjvForm
|
29
|
+
};
|
22
30
|
//# sourceMappingURL=index.mjs.map
|
package/dist/ajv/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../ajv/src/ajv-resolver.ts","../../ajv/src/create-ajv-form.ts","../../ajv/src/index.ts"],"
|
1
|
+
{"version":3,"sources":["../../ajv/src/ajv-resolver.ts","../../ajv/src/create-ajv-form.ts","../../ajv/src/index.ts"],"sourcesContent":["import { ajvResolver } from '@hookform/resolvers/ajv'\nimport { objectFieldResolver, FieldResolver } from '@saas-ui/forms'\n\nimport { JSONSchemaType } from 'ajv'\n\nexport { ajvResolver }\n\nexport const ajvFieldResolver = (schema: JSONSchemaType<unknown>) => {\n return objectFieldResolver(schema.properties)\n}\n","import {\n createForm,\n CreateFormProps,\n FieldValues,\n FormProps,\n WithFields,\n} from '@saas-ui/forms'\nimport { ajvFieldResolver, ajvResolver } from './ajv-resolver'\nimport { JTDDataType } from 'ajv/dist/jtd'\ntype ResolverArgs = Parameters<typeof ajvResolver>\n\nexport interface CreateAjvFormProps<FieldDefs>\n extends CreateFormProps<FieldDefs> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\ntype ParseJsonSchema<T> = T extends { type: 'object' }\n ? JTDDataType<T> extends infer R\n ? R extends object\n ? R\n : never\n : never\n : never\n\nexport type AjvFormType<\n FieldDefs,\n ExtraProps = object,\n JsonSchema extends Record<string, any> = Record<string, any>\n> = (<\n TSchema extends JsonSchema = JsonSchema,\n TFieldValues extends ParseJsonSchema<TSchema> = ParseJsonSchema<TSchema>,\n TContext extends object = object\n>(\n props: WithFields<FormProps<TSchema, TFieldValues, TContext>, FieldDefs> & {\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\n/**\n * Create a Form component with AJV validation that accepts JSON Type Definition schema\n *\n * @see Docs https://saas-ui.dev/docs/components/forms/form\n * @see https://ajv.js.org/json-type-definition.html\n */\nexport function createAjvForm<FieldDefs>(\n options?: CreateAjvFormProps<FieldDefs>\n) {\n return createForm({\n resolver: (schema: any) =>\n ajvResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: ajvFieldResolver,\n ...options,\n }) as AjvFormType<FieldDefs>\n}\n","export * from './ajv-resolver'\nexport { createAjvForm } from './create-ajv-form'\nexport type { CreateAjvFormProps } from './create-ajv-form'\nexport type { JTDDataType, JTDSchemaType } from 'ajv/dist/jtd'\n\nimport { createAjvForm } from './create-ajv-form'\n\nexport const Form = createAjvForm()\n"],"mappings":";;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,2BAA0C;AAM5C,IAAM,mBAAmB,CAAC,WAAoC;AACnE,SAAO,oBAAoB,OAAO,UAAU;AAC9C;;;ACTA;AAAA,EACE;AAAA,OAKK;AA0CA,SAAS,cACd,SACA;AACA,SAAO,WAAW;AAAA,IAChB,UAAU,CAAC,WACT,YAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AACH;;;AClDO,IAAM,OAAO,cAAc;","names":[]}
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React$1 from 'react';
|
2
2
|
import React__default from 'react';
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
3
4
|
import * as react_hook_form from 'react-hook-form';
|
4
5
|
import { FieldValues, FieldPath, UseFieldArrayReturn, RegisterOptions, UseFormReturn as UseFormReturn$1, UseFormProps, WatchObserver, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult, FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
|
5
6
|
export { BatchFieldArrayUpdate, ChangeHandler, Control, Controller, ControllerFieldState, ControllerProps, ControllerRenderProps, CriteriaMode, CustomElement, DeepMap, DeepPartial, DeepPartialSkipArrayKey, DefaultValues, DelayCallback, EmptyObject, ErrorOption, EventType, FieldArray, FieldArrayMethodProps, FieldArrayWithId, Field as FieldDef, FieldElement, FieldError, FieldErrors, FieldName, FieldNamesMarkedBoolean, FieldRefs, FieldValue, FieldValues, FormProviderProps, FormState, FormStateProxy, FormStateSubjectRef, GetIsDirty, InternalFieldErrors, InternalFieldName, InternalNameSet, IsAny, IsFlatObject, KeepStateOptions, LiteralUnion, Message, Mode, MultipleFieldErrors, Names, NativeFieldValue, NestedValue, NonUndefined, Noop, Primitive, ReadFormState, Ref, RefCallBack, RegisterOptions, Resolver, ResolverError, ResolverOptions, ResolverResult, ResolverSuccess, SetFieldValue, SetValueConfig, Subjects, SubmitErrorHandler, SubmitHandler, TriggerConfig, UnpackNestedValue, UseControllerProps, UseControllerReturn, UseFieldArrayProps, UseFieldArrayReturn, UseFormClearErrors, UseFormGetValues, UseFormHandleSubmit, UseFormProps, UseFormRegister, UseFormRegisterReturn, UseFormReset, UseFormResetField, UseFormReturn, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormStateProps, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch, UseWatchProps, Validate, ValidateResult, ValidationMode, ValidationRule, ValidationValue, ValidationValueMessage, WatchInternal, WatchObserver, appendErrors, useController, useFieldArray, useForm, useFormState, useWatch } from 'react-hook-form';
|
@@ -203,7 +204,7 @@ interface ObjectFieldProps<TFieldValues extends FieldValues = FieldValues, TName
|
|
203
204
|
columns?: ResponsiveValue<number>;
|
204
205
|
spacing?: ResponsiveValue<string | number>;
|
205
206
|
}
|
206
|
-
declare const FormLegend: (props: FormLabelProps) => JSX.Element;
|
207
|
+
declare const FormLegend: (props: FormLabelProps) => react_jsx_runtime.JSX.Element;
|
207
208
|
/**
|
208
209
|
* The object field component.
|
209
210
|
*
|
@@ -223,7 +224,7 @@ interface FormLayoutProps extends SimpleGridProps {
|
|
223
224
|
* @see https://saas-ui.dev/docs/components/forms/form
|
224
225
|
*/
|
225
226
|
declare const FormLayout: {
|
226
|
-
({ children, ...props }: FormLayoutProps): JSX.Element;
|
227
|
+
({ children, ...props }: FormLayoutProps): react_jsx_runtime.JSX.Element;
|
227
228
|
displayName: string;
|
228
229
|
};
|
229
230
|
|
@@ -681,7 +682,7 @@ interface FormStepProps<TName extends string = string> extends FormStepOptions<T
|
|
681
682
|
* @see Docs https://saas-ui.dev/docs/components/forms/step-form
|
682
683
|
*/
|
683
684
|
declare const FormStep: {
|
684
|
-
<TName extends string = string>(props: FormStepProps<TName>): JSX.Element | null;
|
685
|
+
<TName extends string = string>(props: FormStepProps<TName>): react_jsx_runtime.JSX.Element | null;
|
685
686
|
displayName: string;
|
686
687
|
};
|
687
688
|
/**
|
@@ -804,7 +805,7 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
|
|
804
805
|
setFocus: react_hook_form.UseFormSetFocus<FieldValues>;
|
805
806
|
};
|
806
807
|
type UseFormReturn<TFieldValues extends FieldValues = FieldValues, TContext = any, TSchema = any> = ReturnType<typeof useFormContext>;
|
807
|
-
declare const FormProvider: <TFieldValues extends FieldValues = FieldValues, TContext = any, TSchema = any>(props: FormProviderProps<TFieldValues, TContext, TSchema>) => JSX.Element;
|
808
|
+
declare const FormProvider: <TFieldValues extends FieldValues = FieldValues, TContext = any, TSchema = any>(props: FormProviderProps<TFieldValues, TContext, TSchema>) => react_jsx_runtime.JSX.Element;
|
808
809
|
|
809
810
|
interface WatchFieldProps<Value = unknown, TFieldValues extends FieldValues = FieldValues> {
|
810
811
|
name: string;
|