@form-os/react 0.1.1 → 0.3.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/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -60
- package/dist/index.d.ts +2 -60
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/abeleko/Documents/larven/formjs/packages/react/dist/index.cjs","../src/useFormConfig.ts","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACPA,8BAAwB;AACxB,
|
|
1
|
+
{"version":3,"sources":["/Users/abeleko/Documents/larven/formjs/packages/react/dist/index.cjs","../src/useFormConfig.ts","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACPA,8BAAwB;AACxB;AACE;AAAA,gDAIK;AACP,qCAAmE;AAE5D,SAAS,aAAA,CACd,MAAA,EACyD;AACzD,EAAA,MAAM,WAAA,EAAa,4BAAA,CAAQ,EAAA,GAAM,mCAAA,MAAsB,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAElE,EAAA,MAAM,cAAA,EAAgB,4BAAA;AAAA,IACpB,CAAA,EAAA,GACE,MAAA,CAAO,WAAA;AAAA,MACL,UAAA,CAAW,MAAA,CACR,MAAA,CAAO,CAAC,CAAA,EAAA,GAAM,CAAA,CAAE,aAAA,IAAiB,KAAA,CAAS,CAAA,CAC1C,GAAA,CAAI,CAAC,CAAA,EAAA,GAAM,CAAC,CAAA,CAAE,IAAA,EAAM,CAAA,CAAE,YAAY,CAAC;AAAA,IACxC,CAAA;AAAA,IACF,CAAC,UAAA,CAAW,MAAM;AAAA,EACpB,CAAA;AAEA,EAAA,MAAM,KAAA,EAAO,oCAAA;AAAsB,IACjC,aAAA;AAAA,IACA,IAAA,EAAM,UAAA,CAAW,cAAA;AAAA,IACjB,cAAA,EAAgB,UAAA,CAAW;AAAA,EAC7B,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,GAAG,IAAA,EAAM,MAAA,EAAQ,UAAA,CAAW,OAAO,CAAA;AAC9C;ADHA;AACA;AEtBA;AFwBA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,0ZAAC","file":"/Users/abeleko/Documents/larven/formjs/packages/react/dist/index.cjs","sourcesContent":[null,"import { useMemo } from 'react';\nimport {\n useForm,\n type DefaultValues,\n type FieldValues,\n type UseFormReturn,\n} from 'react-hook-form';\nimport { normalizeConfig, type FieldConfig, type FormConfig } from '@form-os/core';\n\nexport function useFormConfig<TFieldValues extends FieldValues = FieldValues>(\n config: FieldConfig[] | FormConfig\n): UseFormReturn<TFieldValues> & { fields: FieldConfig[] } {\n const normalized = useMemo(() => normalizeConfig(config), [config]);\n\n const defaultValues = useMemo(\n () =>\n Object.fromEntries(\n normalized.fields\n .filter((f) => f.defaultValue !== undefined)\n .map((f) => [f.name, f.defaultValue])\n ),\n [normalized.fields]\n );\n\n const form = useForm<TFieldValues>({\n defaultValues: defaultValues as DefaultValues<TFieldValues>,\n mode: normalized.validationMode,\n reValidateMode: normalized.reValidateMode,\n });\n\n return { ...form, fields: normalized.fields };\n}\n","export { useFormConfig } from './useFormConfig';\nexport { Field } from './Field';\nexport type { FieldProps } from './Field';\nexport { useField } from './useField';\nexport type { UseFieldOptions } from './useField';\nexport { FormFieldsProvider, useFieldComponents } from './FormFieldsContext';\nexport type { ComponentsMap, FormFieldsProviderProps } from './FormFieldsContext';\nexport { FormProvider, useFormContext, useForm } from 'react-hook-form';\nexport type { Control, RegisterOptions, UseFormProps } from 'react-hook-form';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_hook_form from 'react-hook-form';
|
|
2
|
-
import { RegisterOptions, Control } from 'react-hook-form';
|
|
2
|
+
import { FieldValues, UseFormReturn, RegisterOptions, Control } from 'react-hook-form';
|
|
3
3
|
export { Control, FormProvider, RegisterOptions, UseFormProps, useForm, useFormContext } from 'react-hook-form';
|
|
4
4
|
import * as _form_os_core from '@form-os/core';
|
|
5
5
|
import { FieldConfig, FormConfig } from '@form-os/core';
|
|
@@ -7,66 +7,8 @@ export { a as Field, F as FieldProps } from './Field-Bq9-eB99.cjs';
|
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import { ComponentType, ReactNode } from 'react';
|
|
9
9
|
|
|
10
|
-
declare function useFormConfig(config: FieldConfig[] | FormConfig): {
|
|
10
|
+
declare function useFormConfig<TFieldValues extends FieldValues = FieldValues>(config: FieldConfig[] | FormConfig): UseFormReturn<TFieldValues> & {
|
|
11
11
|
fields: FieldConfig[];
|
|
12
|
-
watch: react_hook_form.UseFormWatch<{
|
|
13
|
-
[k: string]: any;
|
|
14
|
-
}>;
|
|
15
|
-
getValues: react_hook_form.UseFormGetValues<{
|
|
16
|
-
[k: string]: any;
|
|
17
|
-
}>;
|
|
18
|
-
getFieldState: react_hook_form.UseFormGetFieldState<{
|
|
19
|
-
[k: string]: any;
|
|
20
|
-
}>;
|
|
21
|
-
setError: react_hook_form.UseFormSetError<{
|
|
22
|
-
[k: string]: any;
|
|
23
|
-
}>;
|
|
24
|
-
clearErrors: react_hook_form.UseFormClearErrors<{
|
|
25
|
-
[k: string]: any;
|
|
26
|
-
}>;
|
|
27
|
-
setValue: react_hook_form.UseFormSetValue<{
|
|
28
|
-
[k: string]: any;
|
|
29
|
-
}>;
|
|
30
|
-
setValues: react_hook_form.UseFormSetValues<{
|
|
31
|
-
[k: string]: any;
|
|
32
|
-
}>;
|
|
33
|
-
trigger: react_hook_form.UseFormTrigger<{
|
|
34
|
-
[k: string]: any;
|
|
35
|
-
}>;
|
|
36
|
-
formState: react_hook_form.FormState<{
|
|
37
|
-
[k: string]: any;
|
|
38
|
-
}>;
|
|
39
|
-
resetField: react_hook_form.UseFormResetField<{
|
|
40
|
-
[k: string]: any;
|
|
41
|
-
}>;
|
|
42
|
-
reset: react_hook_form.UseFormReset<{
|
|
43
|
-
[k: string]: any;
|
|
44
|
-
}>;
|
|
45
|
-
resetDefaultValues: react_hook_form.UseFormResetDefaultValues<{
|
|
46
|
-
[k: string]: any;
|
|
47
|
-
}>;
|
|
48
|
-
handleSubmit: react_hook_form.UseFormHandleSubmit<{
|
|
49
|
-
[k: string]: any;
|
|
50
|
-
}, {
|
|
51
|
-
[k: string]: any;
|
|
52
|
-
}>;
|
|
53
|
-
unregister: react_hook_form.UseFormUnregister<{
|
|
54
|
-
[k: string]: any;
|
|
55
|
-
}>;
|
|
56
|
-
control: react_hook_form.Control<{
|
|
57
|
-
[k: string]: any;
|
|
58
|
-
}, any, {
|
|
59
|
-
[k: string]: any;
|
|
60
|
-
}>;
|
|
61
|
-
register: react_hook_form.UseFormRegister<{
|
|
62
|
-
[k: string]: any;
|
|
63
|
-
}>;
|
|
64
|
-
setFocus: react_hook_form.UseFormSetFocus<{
|
|
65
|
-
[k: string]: any;
|
|
66
|
-
}>;
|
|
67
|
-
subscribe: react_hook_form.UseFormSubscribe<{
|
|
68
|
-
[k: string]: any;
|
|
69
|
-
}>;
|
|
70
12
|
};
|
|
71
13
|
|
|
72
14
|
interface UseFieldOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_hook_form from 'react-hook-form';
|
|
2
|
-
import { RegisterOptions, Control } from 'react-hook-form';
|
|
2
|
+
import { FieldValues, UseFormReturn, RegisterOptions, Control } from 'react-hook-form';
|
|
3
3
|
export { Control, FormProvider, RegisterOptions, UseFormProps, useForm, useFormContext } from 'react-hook-form';
|
|
4
4
|
import * as _form_os_core from '@form-os/core';
|
|
5
5
|
import { FieldConfig, FormConfig } from '@form-os/core';
|
|
@@ -7,66 +7,8 @@ export { a as Field, F as FieldProps } from './Field-Bq9-eB99.js';
|
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import { ComponentType, ReactNode } from 'react';
|
|
9
9
|
|
|
10
|
-
declare function useFormConfig(config: FieldConfig[] | FormConfig): {
|
|
10
|
+
declare function useFormConfig<TFieldValues extends FieldValues = FieldValues>(config: FieldConfig[] | FormConfig): UseFormReturn<TFieldValues> & {
|
|
11
11
|
fields: FieldConfig[];
|
|
12
|
-
watch: react_hook_form.UseFormWatch<{
|
|
13
|
-
[k: string]: any;
|
|
14
|
-
}>;
|
|
15
|
-
getValues: react_hook_form.UseFormGetValues<{
|
|
16
|
-
[k: string]: any;
|
|
17
|
-
}>;
|
|
18
|
-
getFieldState: react_hook_form.UseFormGetFieldState<{
|
|
19
|
-
[k: string]: any;
|
|
20
|
-
}>;
|
|
21
|
-
setError: react_hook_form.UseFormSetError<{
|
|
22
|
-
[k: string]: any;
|
|
23
|
-
}>;
|
|
24
|
-
clearErrors: react_hook_form.UseFormClearErrors<{
|
|
25
|
-
[k: string]: any;
|
|
26
|
-
}>;
|
|
27
|
-
setValue: react_hook_form.UseFormSetValue<{
|
|
28
|
-
[k: string]: any;
|
|
29
|
-
}>;
|
|
30
|
-
setValues: react_hook_form.UseFormSetValues<{
|
|
31
|
-
[k: string]: any;
|
|
32
|
-
}>;
|
|
33
|
-
trigger: react_hook_form.UseFormTrigger<{
|
|
34
|
-
[k: string]: any;
|
|
35
|
-
}>;
|
|
36
|
-
formState: react_hook_form.FormState<{
|
|
37
|
-
[k: string]: any;
|
|
38
|
-
}>;
|
|
39
|
-
resetField: react_hook_form.UseFormResetField<{
|
|
40
|
-
[k: string]: any;
|
|
41
|
-
}>;
|
|
42
|
-
reset: react_hook_form.UseFormReset<{
|
|
43
|
-
[k: string]: any;
|
|
44
|
-
}>;
|
|
45
|
-
resetDefaultValues: react_hook_form.UseFormResetDefaultValues<{
|
|
46
|
-
[k: string]: any;
|
|
47
|
-
}>;
|
|
48
|
-
handleSubmit: react_hook_form.UseFormHandleSubmit<{
|
|
49
|
-
[k: string]: any;
|
|
50
|
-
}, {
|
|
51
|
-
[k: string]: any;
|
|
52
|
-
}>;
|
|
53
|
-
unregister: react_hook_form.UseFormUnregister<{
|
|
54
|
-
[k: string]: any;
|
|
55
|
-
}>;
|
|
56
|
-
control: react_hook_form.Control<{
|
|
57
|
-
[k: string]: any;
|
|
58
|
-
}, any, {
|
|
59
|
-
[k: string]: any;
|
|
60
|
-
}>;
|
|
61
|
-
register: react_hook_form.UseFormRegister<{
|
|
62
|
-
[k: string]: any;
|
|
63
|
-
}>;
|
|
64
|
-
setFocus: react_hook_form.UseFormSetFocus<{
|
|
65
|
-
[k: string]: any;
|
|
66
|
-
}>;
|
|
67
|
-
subscribe: react_hook_form.UseFormSubscribe<{
|
|
68
|
-
[k: string]: any;
|
|
69
|
-
}>;
|
|
70
12
|
};
|
|
71
13
|
|
|
72
14
|
interface UseFieldOptions {
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
|
|
8
8
|
// src/useFormConfig.ts
|
|
9
9
|
import { useMemo } from "react";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useForm
|
|
12
|
+
} from "react-hook-form";
|
|
11
13
|
import { normalizeConfig } from "@form-os/core";
|
|
12
14
|
function useFormConfig(config) {
|
|
13
15
|
const normalized = useMemo(() => normalizeConfig(config), [config]);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useFormConfig.ts","../src/index.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/useFormConfig.ts","../src/index.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n useForm,\n type DefaultValues,\n type FieldValues,\n type UseFormReturn,\n} from 'react-hook-form';\nimport { normalizeConfig, type FieldConfig, type FormConfig } from '@form-os/core';\n\nexport function useFormConfig<TFieldValues extends FieldValues = FieldValues>(\n config: FieldConfig[] | FormConfig\n): UseFormReturn<TFieldValues> & { fields: FieldConfig[] } {\n const normalized = useMemo(() => normalizeConfig(config), [config]);\n\n const defaultValues = useMemo(\n () =>\n Object.fromEntries(\n normalized.fields\n .filter((f) => f.defaultValue !== undefined)\n .map((f) => [f.name, f.defaultValue])\n ),\n [normalized.fields]\n );\n\n const form = useForm<TFieldValues>({\n defaultValues: defaultValues as DefaultValues<TFieldValues>,\n mode: normalized.validationMode,\n reValidateMode: normalized.reValidateMode,\n });\n\n return { ...form, fields: normalized.fields };\n}\n","export { useFormConfig } from './useFormConfig';\nexport { Field } from './Field';\nexport type { FieldProps } from './Field';\nexport { useField } from './useField';\nexport type { UseFieldOptions } from './useField';\nexport { FormFieldsProvider, useFieldComponents } from './FormFieldsContext';\nexport type { ComponentsMap, FormFieldsProviderProps } from './FormFieldsContext';\nexport { FormProvider, useFormContext, useForm } from 'react-hook-form';\nexport type { Control, RegisterOptions, UseFormProps } from 'react-hook-form';\n"],"mappings":";;;;;;;;AAAA,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,OAIK;AACP,SAAS,uBAA0D;AAE5D,SAAS,cACd,QACyD;AACzD,QAAM,aAAa,QAAQ,MAAM,gBAAgB,MAAM,GAAG,CAAC,MAAM,CAAC;AAElE,QAAM,gBAAgB;AAAA,IACpB,MACE,OAAO;AAAA,MACL,WAAW,OACR,OAAO,CAAC,MAAM,EAAE,iBAAiB,MAAS,EAC1C,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC;AAAA,IACxC;AAAA,IACF,CAAC,WAAW,MAAM;AAAA,EACpB;AAEA,QAAM,OAAO,QAAsB;AAAA,IACjC;AAAA,IACA,MAAM,WAAW;AAAA,IACjB,gBAAgB,WAAW;AAAA,EAC7B,CAAC;AAED,SAAO,EAAE,GAAG,MAAM,QAAQ,WAAW,OAAO;AAC9C;;;ACxBA,SAAS,cAAc,gBAAgB,WAAAA,gBAAe;","names":["useForm"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-os/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"react-hook-form": ">=7.0.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@form-os/core": "0.
|
|
33
|
+
"@form-os/core": "0.3.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/react": "^18.2.0",
|