@goodie-forms/react 1.2.5-alpha → 1.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/README.md +61 -0
- package/dist/components/FieldRenderer.d.ts +9 -13
- package/dist/components/FieldRenderer.d.ts.map +1 -1
- package/dist/hooks/useFieldIssues.d.ts +4 -0
- package/dist/hooks/useFieldIssues.d.ts.map +1 -0
- package/dist/hooks/useFieldValue.d.ts +1 -1
- package/dist/hooks/useFieldValue.d.ts.map +1 -1
- package/dist/hooks/useForm.d.ts +18 -6
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/hooks/useFormField.d.ts +3 -2
- package/dist/hooks/useFormField.d.ts.map +1 -1
- package/dist/hooks/useSyncMutableStore.d.ts +2 -0
- package/dist/hooks/useSyncMutableStore.d.ts.map +1 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +140 -169
- package/dist/index.js.map +1 -1
- package/package.json +15 -2
- package/dist/hooks/useFieldErrors.d.ts +0 -4
- package/dist/hooks/useFieldErrors.d.ts.map +0 -1
- package/dist/hooks/useFormErrorObserver.d.ts +0 -7
- package/dist/hooks/useFormErrorObserver.d.ts.map +0 -1
- package/dist/hooks/useFormValuesObserver.d.ts +0 -7
- package/dist/hooks/useFormValuesObserver.d.ts.map +0 -1
- package/dist/hooks/useRenderControl.d.ts +0 -5
- package/dist/hooks/useRenderControl.d.ts.map +0 -1
- package/src/components/FieldRenderer.tsx +0 -166
- package/src/hooks/useFieldErrors.ts +0 -31
- package/src/hooks/useFieldValue.ts +0 -31
- package/src/hooks/useForm.tsx +0 -50
- package/src/hooks/useFormErrorObserver.ts +0 -45
- package/src/hooks/useFormField.tsx +0 -63
- package/src/hooks/useFormValuesObserver.ts +0 -50
- package/src/hooks/useRenderControl.tsx +0 -26
- package/src/index.ts +0 -9
- package/src/utils/composeFns.ts +0 -7
- package/src/utils/groupBy.ts +0 -13
- package/tsconfig.json +0 -8
- package/vite.config.ts +0 -23
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!-- Logo -->
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/iGoodie/goodie-forms/master/.github/assets/logo.svg" height="200px" alt="Logo"/>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<!-- Slogan -->
|
|
7
|
+
<p align="center">
|
|
8
|
+
An unopinionated modern form state and data management library
|
|
9
|
+
</p>
|
|
10
|
+
<!-- Badges -->
|
|
11
|
+
<p align="center">
|
|
12
|
+
|
|
13
|
+
<!-- Main Badges -->
|
|
14
|
+
<img src="https://raw.githubusercontent.com/iGoodie/paper-editor/master/.github/assets/main-badge.svg" height="20px"/>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@goodie-forms/react">
|
|
16
|
+
<img src="https://img.shields.io/npm/v/@goodie-forms/react"/>
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://github.com/iGoodie/goodie-forms/tags">
|
|
19
|
+
<img src="https://img.shields.io/github/v/tag/iGoodie/goodie-forms"/>
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://github.com/iGoodie/goodie-forms">
|
|
22
|
+
<img src="https://img.shields.io/github/languages/top/iGoodie/goodie-forms"/>
|
|
23
|
+
</a>
|
|
24
|
+
|
|
25
|
+
<br/>
|
|
26
|
+
|
|
27
|
+
<!-- Github Badges -->
|
|
28
|
+
<img src="https://raw.githubusercontent.com/iGoodie/paper-editor/master/.github/assets/github-badge.svg" height="20px"/>
|
|
29
|
+
<a href="https://github.com/iGoodie/goodie-forms/commits/master">
|
|
30
|
+
<img src="https://img.shields.io/github/last-commit/iGoodie/goodie-forms"/>
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://github.com/iGoodie/goodie-forms/issues">
|
|
33
|
+
<img src="https://img.shields.io/github/issues/iGoodie/goodie-forms"/>
|
|
34
|
+
</a>
|
|
35
|
+
<a href="https://github.com/iGoodie/goodie-forms/tree/master/src">
|
|
36
|
+
<img src="https://img.shields.io/github/languages/code-size/iGoodie/goodie-forms"/>
|
|
37
|
+
</a>
|
|
38
|
+
|
|
39
|
+
<br/>
|
|
40
|
+
|
|
41
|
+
<!-- Support Badges -->
|
|
42
|
+
<img src="https://raw.githubusercontent.com/iGoodie/paper-editor/master/.github/assets/support-badge.svg" height="20px"/>
|
|
43
|
+
<a href="https://discord.gg/KNxxdvN">
|
|
44
|
+
<img src="https://img.shields.io/discord/610497509437210624?label=discord"/>
|
|
45
|
+
</a>
|
|
46
|
+
<a href="https://www.patreon.com/iGoodie">
|
|
47
|
+
<img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3DiGoodie%26type%3Dpatrons"/>
|
|
48
|
+
</a>
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
# Description
|
|
52
|
+
|
|
53
|
+
React package of Goodie Forms.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
© 2026 Taha Anılcan Metinyurt (iGoodie)
|
|
58
|
+
|
|
59
|
+
For any part of this work for which the license is applicable, this work is licensed under the [Attribution-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/) license. (See LICENSE).
|
|
60
|
+
|
|
61
|
+
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a>
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
import { FieldPath, FormField,
|
|
1
|
+
import { DeepReadonly, FieldPath, FormField, Suppliable } from '../../../core/src';
|
|
2
2
|
import { ChangeEvent, ReactNode, Ref } from 'react';
|
|
3
3
|
import { UseForm } from '../hooks/useForm';
|
|
4
4
|
export interface RenderParams<TOutput extends object, TValue> {
|
|
5
5
|
fieldProps: {
|
|
6
6
|
ref: Ref<any | null>;
|
|
7
|
-
|
|
7
|
+
name: string;
|
|
8
|
+
value: DeepReadonly<TValue> | undefined;
|
|
8
9
|
onChange: (event: ChangeEvent<EventTarget> | TValue) => void;
|
|
9
10
|
onFocus: () => void;
|
|
10
11
|
onBlur: () => void;
|
|
11
12
|
};
|
|
12
|
-
field:
|
|
13
|
+
field: FormField<TOutput, TValue>;
|
|
13
14
|
form: UseForm<TOutput>;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
defaultValue?: TValue | (() => TValue);
|
|
17
|
-
} : {
|
|
18
|
-
defaultValue: TValue | (() => TValue);
|
|
19
|
-
};
|
|
20
|
-
export type FieldRendererProps<TOutput extends object, TPath extends FieldPath.Segments> = {
|
|
16
|
+
export interface FieldRendererProps<TOutput extends object, TPath extends FieldPath.Segments> {
|
|
21
17
|
form: UseForm<TOutput>;
|
|
22
18
|
path: TPath;
|
|
19
|
+
defaultValue?: Suppliable<FieldPath.Resolve<TOutput, TPath>>;
|
|
23
20
|
overrideInitialValue?: boolean;
|
|
24
|
-
|
|
25
|
-
render: (params: RenderParams<TOutput, FieldPath.Resolve<TOutput,
|
|
26
|
-
}
|
|
21
|
+
unregisterOnUnmount?: boolean;
|
|
22
|
+
render: (params: RenderParams<TOutput, FieldPath.Resolve<TOutput, TPath>>) => ReactNode;
|
|
23
|
+
}
|
|
27
24
|
export declare function FieldRenderer<TOutput extends object, const TPath extends FieldPath.Segments>(props: FieldRendererProps<TOutput, TPath>): import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export {};
|
|
29
25
|
//# sourceMappingURL=FieldRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/FieldRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/FieldRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAqB,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,MAAM,WAAW,YAAY,CAAC,OAAO,SAAS,MAAM,EAAE,MAAM;IAC1D,UAAU,EAAE;QACV,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QAErB,IAAI,EAAE,MAAM,CAAC;QAEb,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;QAExC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC;QAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;QACpB,MAAM,EAAE,MAAM,IAAI,CAAC;KACpB,CAAC;IAEF,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAElC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,SAAS,CAAC,QAAQ;IAEhC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7D,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,MAAM,EAAE,CACN,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,KAC7D,SAAS,CAAC;CAChB;AAED,wBAAgB,aAAa,CAC3B,OAAO,SAAS,MAAM,EACtB,KAAK,CAAC,KAAK,SAAS,SAAS,CAAC,QAAQ,EACtC,KAAK,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,2CAqF1C"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FieldPath } from '../../../core/src';
|
|
2
|
+
import { UseForm } from './useForm';
|
|
3
|
+
export declare function useFieldIssues<TOutput extends object, TPath extends FieldPath.Segments>(form: UseForm<TOutput>, path: TPath): import("@standard-schema/spec").StandardSchemaV1.Issue[];
|
|
4
|
+
//# sourceMappingURL=useFieldIssues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFieldIssues.d.ts","sourceRoot":"","sources":["../../src/hooks/useFieldIssues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,cAAc,CAC5B,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,SAAS,CAAC,QAAQ,EAChC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,4DAiCpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FieldPath } from '../../../core/src';
|
|
2
2
|
import { UseForm } from '../hooks/useForm';
|
|
3
|
-
export declare function useFieldValue<TOutput extends object, TPath extends FieldPath.Segments>(form: UseForm<TOutput>, path: TPath): FieldPath.Resolve<TOutput, TPath
|
|
3
|
+
export declare function useFieldValue<TOutput extends object, TPath extends FieldPath.Segments>(form: UseForm<TOutput>, path: TPath): import('../../../core/src').DeepReadonly<FieldPath.Resolve<TOutput, TPath>> | undefined;
|
|
4
4
|
//# sourceMappingURL=useFieldValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldValue.d.ts","sourceRoot":"","sources":["../../src/hooks/useFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useFieldValue.d.ts","sourceRoot":"","sources":["../../src/hooks/useFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,wBAAgB,aAAa,CAC3B,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,SAAS,CAAC,QAAQ,EAChC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,4FAoCpC"}
|
package/dist/hooks/useForm.d.ts
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FormController } from '../../../core/src';
|
|
2
2
|
export declare function useForm<TOutput extends object>(formConfigs: FormController.Configs<TOutput>, hookConfigs?: {
|
|
3
3
|
validateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
4
4
|
revalidateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
5
|
-
watchIssues?: boolean;
|
|
6
|
-
watchValues?: boolean;
|
|
7
5
|
}): {
|
|
8
6
|
formConfigs: FormController.Configs<TOutput>;
|
|
9
|
-
paths: FieldPathBuilder<TOutput>;
|
|
10
7
|
hookConfigs: {
|
|
11
8
|
validateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
12
9
|
revalidateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
13
|
-
watchIssues?: boolean;
|
|
14
|
-
watchValues?: boolean;
|
|
15
10
|
} | undefined;
|
|
16
11
|
controller: FormController<TOutput>;
|
|
12
|
+
path: import('../../../core/src').FieldPathBuilder<TOutput>;
|
|
13
|
+
watchValues: () => import('../../../core/src').DeepReadonly<import('../../../core/src').DeepPartial<TOutput>>;
|
|
14
|
+
watchIssues: () => readonly import("@standard-schema/spec").StandardSchemaV1.Issue[];
|
|
15
|
+
watchEvent: <E extends "fieldTouchUpdated" | "submissionStatusChange" | "validationStatusChange" | "fieldRegistered" | "fieldUnregistered" | "fieldDirtyUpdated" | "fieldIssuesUpdated" | "fieldReset" | "elementBound" | "elementUnbound" | "fieldValidationTriggered" | "fieldValueChanged">(eventName: E, listener?: NonNullable<Partial<{
|
|
16
|
+
submissionStatusChange: ((isSubmitting: boolean) => void)[];
|
|
17
|
+
validationStatusChange: ((isValidating: boolean) => void)[];
|
|
18
|
+
fieldRegistered: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
19
|
+
fieldUnregistered: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
20
|
+
fieldTouchUpdated: ((path: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
21
|
+
fieldDirtyUpdated: ((path: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
22
|
+
fieldIssuesUpdated: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
23
|
+
fieldReset: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
24
|
+
elementBound: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments, el: HTMLElement) => void)[];
|
|
25
|
+
elementUnbound: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
26
|
+
fieldValidationTriggered: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments) => void)[];
|
|
27
|
+
fieldValueChanged: ((fieldPath: import("@goodie-forms/core").FieldPath.Segments, newValue: {} | undefined, oldValue: {} | undefined) => void)[];
|
|
28
|
+
}>[E]>[number]) => undefined;
|
|
17
29
|
};
|
|
18
30
|
export type UseForm<TOutput extends object> = ReturnType<typeof useForm<TOutput>>;
|
|
19
31
|
//# sourceMappingURL=useForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,wBAAgB,OAAO,CAAC,OAAO,SAAS,MAAM,EAC5C,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,EAC5C,WAAW,CAAC,EAAE;IACZ,YAAY,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;IAClD,cAAc,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;CACrD;;;uBAFgB,UAAU,GAAG,QAAQ,GAAG,UAAU;yBAChC,UAAU,GAAG,QAAQ,GAAG,UAAU;;;;;;iBAgC9B,CAAC,4RACX,CAAC,aACD,WAAW;;;;;;;;;;;;;UAAsC,CAAC,MAAM,CAAC;EAqBvE;AAED,MAAM,MAAM,OAAO,CAAC,OAAO,SAAS,MAAM,IAAI,UAAU,CACtD,OAAO,OAAO,CAAC,OAAO,CAAC,CACxB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FieldPath } from '../../../core/src';
|
|
1
|
+
import { FieldPath, FormField } from '../../../core/src';
|
|
2
2
|
import { UseForm } from '../hooks/useForm';
|
|
3
|
-
export declare function useFormField<TOutput extends object, TPath extends FieldPath.Segments>(form: UseForm<TOutput>, path: TPath
|
|
3
|
+
export declare function useFormField<TOutput extends object, TPath extends FieldPath.Segments>(form: UseForm<TOutput>, path: TPath): FormField<TOutput, FieldPath.Resolve<TOutput, TPath>> | undefined;
|
|
4
|
+
export declare function useFormField<TOutput extends object, TPath extends FieldPath.Segments>(form: UseForm<TOutput>, path: TPath, registerConfig: Parameters<typeof form.controller.registerField<TPath>>[1]): FormField<TOutput, FieldPath.Resolve<TOutput, TPath>>;
|
|
4
5
|
//# sourceMappingURL=useFormField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"useFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,SAAS,CAAC,QAAQ,EAEhC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EACtB,IAAI,EAAE,KAAK,GACV,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC;AAErE,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,SAAS,CAAC,QAAQ,EAEhC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EACtB,IAAI,EAAE,KAAK,EACX,cAAc,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GACzE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSyncMutableStore.d.ts","sourceRoot":"","sources":["../../src/hooks/useSyncMutableStore.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,SAAS,EAAE,CAAC,eAAe,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,EACtD,QAAQ,EAAE,MAAM,CAAC,KAqBlB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export * from './hooks/useForm';
|
|
2
2
|
export * from './hooks/useFormField';
|
|
3
3
|
export * from './hooks/useFieldValue';
|
|
4
|
-
export * from './hooks/
|
|
5
|
-
export * from './hooks/useFormValuesObserver';
|
|
6
|
-
export * from './hooks/useFormErrorObserver';
|
|
7
|
-
export * from './hooks/useRenderControl';
|
|
4
|
+
export * from './hooks/useFieldIssues';
|
|
8
5
|
export * from './components/FieldRenderer';
|
|
9
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,200 +1,171 @@
|
|
|
1
|
-
import { FormController as
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as
|
|
4
|
-
function a() {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { FormController as V, FieldPath as i } from "@goodie-forms/core";
|
|
2
|
+
import { useRef as v, useCallback as d, useSyncExternalStore as f, useState as g, useEffect as m } from "react";
|
|
3
|
+
import { jsx as U, Fragment as I } from "react/jsx-runtime";
|
|
4
|
+
function a(u, n) {
|
|
5
|
+
const e = v(0), l = d(
|
|
6
|
+
(r) => u(() => {
|
|
7
|
+
e.current++, r();
|
|
8
|
+
}),
|
|
9
|
+
[u]
|
|
10
|
+
), o = d(() => e.current, []);
|
|
11
|
+
return f(l, o, o), n();
|
|
12
|
+
}
|
|
13
|
+
function M(u, n) {
|
|
14
|
+
const [e] = g(() => new V(u)), l = d(
|
|
15
|
+
(t) => e.events.on("submissionStatusChange", t),
|
|
16
|
+
[e]
|
|
17
|
+
);
|
|
18
|
+
a(l, () => e);
|
|
19
|
+
const o = () => f(
|
|
20
|
+
(t) => e.events.on("fieldValueChanged", t),
|
|
21
|
+
() => e.data,
|
|
22
|
+
() => e.data
|
|
23
|
+
), r = () => f(
|
|
24
|
+
(t) => e.events.on("fieldIssuesUpdated", t),
|
|
25
|
+
() => e.issues,
|
|
26
|
+
() => e.issues
|
|
27
|
+
), s = (t, F) => a(
|
|
28
|
+
(b) => e.events.on(t, (...q) => {
|
|
29
|
+
F?.(...q), b();
|
|
30
|
+
}),
|
|
31
|
+
() => {
|
|
32
|
+
}
|
|
33
|
+
);
|
|
14
34
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
35
|
+
formConfigs: u,
|
|
36
|
+
hookConfigs: n,
|
|
37
|
+
controller: e,
|
|
38
|
+
path: e.path,
|
|
39
|
+
watchValues: o,
|
|
40
|
+
watchIssues: r,
|
|
41
|
+
watchEvent: s
|
|
17
42
|
};
|
|
18
43
|
}
|
|
19
|
-
function
|
|
44
|
+
function c(...u) {
|
|
20
45
|
return () => {
|
|
21
|
-
for (const n of
|
|
46
|
+
for (const n of u)
|
|
22
47
|
n();
|
|
23
48
|
};
|
|
24
49
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return c(() => {
|
|
56
|
-
const { events: d } = e.controller;
|
|
57
|
-
return l(e.controller.getField(n)), i(
|
|
58
|
-
d.on("fieldBound", (s) => {
|
|
59
|
-
u.equals(s, n) && l(e.controller.getField(n));
|
|
60
|
-
}),
|
|
61
|
-
d.on("fieldUnbound", (s) => {
|
|
62
|
-
u.equals(s, n) && l(void 0);
|
|
63
|
-
}),
|
|
64
|
-
d.on("valueChanged", (s) => {
|
|
65
|
-
(u.equals(s, n) || u.isDescendant(s, n)) && o.forceRerender();
|
|
66
|
-
}),
|
|
67
|
-
d.on("fieldTouchUpdated", (s) => {
|
|
68
|
-
u.equals(s, n) && o.forceRerender();
|
|
69
|
-
}),
|
|
70
|
-
d.on("fieldDirtyUpdated", (s) => {
|
|
71
|
-
u.equals(s, n) && o.forceRerender();
|
|
72
|
-
}),
|
|
73
|
-
d.on("fieldIssuesUpdated", (s) => {
|
|
74
|
-
u.equals(s, n) && o.forceRerender();
|
|
75
|
-
})
|
|
76
|
-
);
|
|
77
|
-
}, []), r;
|
|
78
|
-
}
|
|
79
|
-
function w(e, n) {
|
|
80
|
-
const t = a(), o = e.controller.getField(n)?.value;
|
|
81
|
-
return c(() => i(
|
|
82
|
-
e.controller.events.on("fieldBound", (r) => {
|
|
83
|
-
u.equals(n, r) && t.forceRerender();
|
|
84
|
-
}),
|
|
85
|
-
e.controller.events.on("valueChanged", (r) => {
|
|
86
|
-
u.equals(n, r) && t.forceRerender();
|
|
87
|
-
})
|
|
88
|
-
), []), o;
|
|
89
|
-
}
|
|
90
|
-
function B(e, n) {
|
|
91
|
-
const t = a(), o = e.controller.getField(n)?.issues;
|
|
92
|
-
return c(() => i(
|
|
93
|
-
e.controller.events.on("fieldBound", (r) => {
|
|
94
|
-
u.equals(n, r) && t.forceRerender();
|
|
95
|
-
}),
|
|
96
|
-
e.controller.events.on("fieldIssuesUpdated", (r) => {
|
|
97
|
-
u.equals(n, r) && t.forceRerender();
|
|
98
|
-
})
|
|
99
|
-
), []), o;
|
|
100
|
-
}
|
|
101
|
-
function y(e, n) {
|
|
102
|
-
const t = a(), o = n?.include == null ? e.controller._data : n.include.reduce((r, l) => {
|
|
103
|
-
const d = u.getValue(
|
|
104
|
-
e.controller._data,
|
|
105
|
-
l
|
|
106
|
-
);
|
|
107
|
-
return u.setValue(r, l, d), r;
|
|
108
|
-
}, {});
|
|
109
|
-
return c(() => {
|
|
110
|
-
const { events: r } = e.controller;
|
|
111
|
-
return i(
|
|
112
|
-
r.on("valueChanged", (l) => {
|
|
113
|
-
(n?.include == null || n.include.some(
|
|
114
|
-
(s) => u.equals(s, l) || u.isDescendant(s, l)
|
|
115
|
-
)) && t.forceRerender();
|
|
116
|
-
})
|
|
117
|
-
);
|
|
118
|
-
}, []), o;
|
|
50
|
+
function R(u, n, e) {
|
|
51
|
+
const { controller: l } = u;
|
|
52
|
+
g(() => (!l.getField(n) && e && l.registerField(n, e), null));
|
|
53
|
+
const o = d(
|
|
54
|
+
(r) => {
|
|
55
|
+
const { events: s } = l;
|
|
56
|
+
return c(
|
|
57
|
+
s.on("fieldRegistered", (t) => {
|
|
58
|
+
i.equals(t, n) && r();
|
|
59
|
+
}),
|
|
60
|
+
s.on("fieldUnregistered", (t) => {
|
|
61
|
+
i.equals(t, n) && r();
|
|
62
|
+
}),
|
|
63
|
+
s.on("fieldValueChanged", (t) => {
|
|
64
|
+
(i.equals(t, n) || i.isDescendant(t, n)) && r();
|
|
65
|
+
}),
|
|
66
|
+
s.on("fieldTouchUpdated", (t) => {
|
|
67
|
+
i.equals(t, n) && r();
|
|
68
|
+
}),
|
|
69
|
+
s.on("fieldDirtyUpdated", (t) => {
|
|
70
|
+
i.equals(t, n) && r();
|
|
71
|
+
}),
|
|
72
|
+
s.on("fieldIssuesUpdated", (t) => {
|
|
73
|
+
i.equals(t, n) && r();
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
[l, n]
|
|
78
|
+
);
|
|
79
|
+
return a(o, () => l.getField(n));
|
|
119
80
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
81
|
+
function S(u, n) {
|
|
82
|
+
const { controller: e } = u, l = d(
|
|
83
|
+
(r) => {
|
|
84
|
+
const { events: s } = e;
|
|
85
|
+
return c(
|
|
86
|
+
s.on("fieldRegistered", (t) => {
|
|
87
|
+
i.equals(n, t) && r();
|
|
88
|
+
}),
|
|
89
|
+
s.on("fieldUnregistered", (t) => {
|
|
90
|
+
i.equals(n, t) && r();
|
|
91
|
+
}),
|
|
92
|
+
s.on("fieldValueChanged", (t) => {
|
|
93
|
+
(i.equals(t, n) || i.isDescendant(t, n)) && r();
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
[e, n]
|
|
98
|
+
), o = d(() => e.getField(n)?.value, [e, n]);
|
|
99
|
+
return f(l, o, o);
|
|
127
100
|
}
|
|
128
|
-
function
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
);
|
|
101
|
+
function k(u, n) {
|
|
102
|
+
const { controller: e } = u, l = d(
|
|
103
|
+
(r) => {
|
|
104
|
+
const { events: s } = e;
|
|
105
|
+
return c(
|
|
106
|
+
s.on("fieldRegistered", (t) => {
|
|
107
|
+
i.equals(n, t) && r();
|
|
108
|
+
}),
|
|
109
|
+
s.on("fieldUnregistered", (t) => {
|
|
110
|
+
i.equals(n, t) && r();
|
|
111
|
+
}),
|
|
112
|
+
s.on("fieldIssuesUpdated", (t) => {
|
|
113
|
+
i.equals(n, t) && r();
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
[e, n]
|
|
118
|
+
), o = d(() => e.getField(n)?.issues ?? [], [e, n]);
|
|
119
|
+
return f(l, o, o);
|
|
147
120
|
}
|
|
148
|
-
function
|
|
149
|
-
const n = v(null),
|
|
150
|
-
overrideInitialValue:
|
|
151
|
-
defaultValue:
|
|
152
|
-
}), o =
|
|
121
|
+
function w(u) {
|
|
122
|
+
const n = v(null), e = R(u.form, u.path, {
|
|
123
|
+
overrideInitialValue: u.overrideInitialValue ?? !0,
|
|
124
|
+
defaultValue: u.defaultValue
|
|
125
|
+
}), l = u.form.controller.triedSubmitting ? u.form.hookConfigs?.revalidateMode ?? u.form.hookConfigs?.validateMode : u.form.hookConfigs?.validateMode, o = u.render({
|
|
153
126
|
fieldProps: {
|
|
154
127
|
ref: n,
|
|
155
|
-
|
|
128
|
+
name: e.stringPath,
|
|
129
|
+
value: e.value,
|
|
156
130
|
onChange(r) {
|
|
157
|
-
let
|
|
131
|
+
let s;
|
|
158
132
|
if (typeof r == "object" && "target" in r) {
|
|
159
|
-
const { target:
|
|
160
|
-
if (
|
|
161
|
-
|
|
133
|
+
const { target: t } = r;
|
|
134
|
+
if (t !== e.boundElement || !("value" in t) || typeof t.value != "string") return;
|
|
135
|
+
s = t.value;
|
|
162
136
|
} else
|
|
163
|
-
|
|
164
|
-
|
|
137
|
+
s = r;
|
|
138
|
+
e.setValue(s, {
|
|
165
139
|
shouldTouch: !0,
|
|
166
140
|
shouldMarkDirty: !0
|
|
167
141
|
});
|
|
168
142
|
},
|
|
169
143
|
onFocus() {
|
|
170
|
-
|
|
144
|
+
e.touch();
|
|
171
145
|
},
|
|
172
146
|
onBlur() {
|
|
173
|
-
(e.
|
|
147
|
+
(e.issues.length !== 0 || l === "onBlur" || l === "onChange") && u.form.controller.validateField(u.path);
|
|
174
148
|
}
|
|
175
149
|
},
|
|
176
|
-
field:
|
|
177
|
-
form:
|
|
150
|
+
field: e,
|
|
151
|
+
form: u.form
|
|
178
152
|
});
|
|
179
|
-
return
|
|
180
|
-
const { events: r } =
|
|
181
|
-
return
|
|
182
|
-
r.on("
|
|
183
|
-
!
|
|
153
|
+
return m(() => {
|
|
154
|
+
const { events: r } = u.form.controller;
|
|
155
|
+
return c(
|
|
156
|
+
r.on("fieldValueChanged", (s) => {
|
|
157
|
+
!i.equals(s, u.path) && !i.isDescendant(s, u.path) || (e.issues.length !== 0 || l === "onChange") && u.form.controller.validateField(u.path);
|
|
184
158
|
})
|
|
185
159
|
);
|
|
186
|
-
}, []),
|
|
187
|
-
|
|
188
|
-
}), []), /* @__PURE__ */
|
|
160
|
+
}, [l]), m(() => (e.bindElement(n.current), () => {
|
|
161
|
+
u.unregisterOnUnmount && u.form.controller.unregisterField(u.path);
|
|
162
|
+
}), []), /* @__PURE__ */ U(I, { children: o });
|
|
189
163
|
}
|
|
190
164
|
export {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
h as useFormField,
|
|
197
|
-
y as useFormValuesObserver,
|
|
198
|
-
a as useRenderControl
|
|
165
|
+
w as FieldRenderer,
|
|
166
|
+
k as useFieldIssues,
|
|
167
|
+
S as useFieldValue,
|
|
168
|
+
M as useForm,
|
|
169
|
+
R as useFormField
|
|
199
170
|
};
|
|
200
171
|
//# sourceMappingURL=index.js.map
|