react-form-manage 1.0.6-beta.0 → 1.0.6-beta.1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/components/Form/FormCleanUp.js +46 -0
  3. package/dist/components/Form/FormItem.js +46 -0
  4. package/dist/components/Form/FormList.js +11 -0
  5. package/dist/components/Form/InputWrapper.js +7 -0
  6. package/dist/components/Input.d.ts +4 -5
  7. package/dist/components/Input.js +8 -0
  8. package/dist/constants/validation.js +33 -0
  9. package/dist/contexts/FormContext.js +2 -0
  10. package/dist/hooks/useFormItemControl.js +390 -0
  11. package/dist/hooks/useFormListControl.js +280 -0
  12. package/dist/index.d.ts +8 -185
  13. package/dist/index.js +9 -0
  14. package/dist/providers/Form.js +322 -0
  15. package/dist/stores/formStore.js +304 -0
  16. package/dist/types/index.d.ts +1 -0
  17. package/dist/types/index.js +1 -0
  18. package/dist/types/public.d.ts +51 -0
  19. package/dist/utils/obj.util.js +24 -0
  20. package/package.json +30 -45
  21. package/src/App.css +49 -0
  22. package/src/App.tsx +36 -0
  23. package/src/assets/react.svg +1 -0
  24. package/src/components/Form/FormCleanUp.tsx +57 -0
  25. package/src/components/Form/FormItem.tsx +60 -0
  26. package/src/components/Form/FormList.tsx +13 -0
  27. package/src/components/Form/InputWrapper.tsx +17 -0
  28. package/src/components/Input.jsx +13 -0
  29. package/src/components/Input.tsx +21 -0
  30. package/src/constants/validation.ts +63 -0
  31. package/src/contexts/FormContext.ts +3 -0
  32. package/src/hooks/useFormItemControl.ts +558 -0
  33. package/src/hooks/useFormListControl.ts +378 -0
  34. package/src/index.css +68 -0
  35. package/src/index.ts +30 -0
  36. package/src/main.tsx +10 -0
  37. package/src/providers/Form.tsx +429 -0
  38. package/src/stores/formStore.ts +477 -0
  39. package/src/types/index.ts +1 -0
  40. package/src/types/public.ts +50 -0
  41. package/src/utils/obj.util.ts +42 -0
  42. package/dist/App.d.ts +0 -2
  43. package/dist/index.cjs +0 -2
  44. package/dist/index.cjs.d.ts +0 -1
  45. package/dist/index.cjs.map +0 -1
  46. package/dist/index.esm.d.ts +0 -1
  47. package/dist/index.esm.js +0 -2
  48. package/dist/index.esm.js.map +0 -1
  49. package/src/types/components.d.ts +0 -135
  50. /package/dist/{main.d.ts → types/public.js} +0 -0
@@ -1,135 +0,0 @@
1
- import * as React from "react";
2
-
3
- // Generic types for top-level Form provider
4
- export interface FormProps<TValues = Record<string, any>> {
5
- children?: React.ReactNode;
6
- formName?: string;
7
- initialValues?: Partial<TValues>;
8
- onFinish?: (
9
- values: Partial<TValues>,
10
- allValues?: TValues,
11
- ) => void | Promise<void>;
12
- onReject?: (errors: any) => void | Promise<void>;
13
- onFinally?: (payload: {
14
- errorsField: any;
15
- values: Partial<TValues>;
16
- withUnRegisteredValues: TValues;
17
- }) => void | Promise<void>;
18
- FormElement?: React.ComponentType<any>;
19
- [key: string]: any;
20
- }
21
-
22
- declare function Form<TValues = Record<string, any>>(
23
- props: FormProps<TValues>,
24
- ): JSX.Element;
25
-
26
- // Standalone generic hooks (also attached to Form as static properties at runtime)
27
- export function useForm<TValues = Record<string, any>>(
28
- formNameOrFormInstance?: any,
29
- ): [any];
30
-
31
- export function useWatch<
32
- TValues = Record<string, any>,
33
- K extends keyof TValues = string & keyof TValues,
34
- >(
35
- name: K,
36
- formNameOrFormInstance?: any,
37
- ): K extends keyof TValues ? TValues[K] : any;
38
-
39
- export function useSubmitDataWatch<TValues = any>(opts: {
40
- formNameOrFormInstance?: any;
41
- triggerWhenChange?: boolean;
42
- mapFn?: (v: any, prev: any) => any;
43
- }): any;
44
-
45
- export function useFormStateWatch<TValues = any>(
46
- formNameOrFormInstance?: any,
47
- ): any;
48
-
49
- declare namespace Form {
50
- // expose same hook names on the Form object
51
- export { useForm, useWatch, useSubmitDataWatch, useFormStateWatch };
52
- }
53
-
54
- export default Form;
55
- export { Form };
56
-
57
- // FormItem (generic for the field value type)
58
- export interface FormItemProps<T = any> {
59
- children: React.ReactElement;
60
- name: string;
61
- formName?: string;
62
- initialValue?: T;
63
- formItemId?: string;
64
- rules?: any[];
65
- valuePropName?: string;
66
- getValueFromEvent?: (e: any) => T;
67
- [key: string]: any;
68
- }
69
-
70
- export function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
71
-
72
- // FormList (generic for item shape)
73
- export interface FormListProps<TItem = any> {
74
- name: string;
75
- initialValues?: TItem[];
76
- form?: any;
77
- formName?: string;
78
- children: (listFields: any[], actions: any) => React.ReactNode;
79
- }
80
-
81
- export function FormList<TItem = any>(props: FormListProps<TItem>): JSX.Element;
82
-
83
- // Input components
84
- export interface BasicInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
85
- onChange?: (value: any, ...args: any[]) => void;
86
- isValidating?: boolean;
87
- [key: string]: any;
88
- }
89
-
90
- // InputWrapper
91
- export interface InputWrapperProps {
92
- children: React.ReactElement;
93
- errors?: Array<{ ruleName?: string; message?: string }>;
94
- isDirty?: boolean;
95
- formState?: any;
96
- name?: string;
97
- formItemId?: string;
98
- [key: string]: any;
99
- }
100
-
101
- export function InputWrapper(props: InputWrapperProps): JSX.Element;
102
-
103
- // Cleanup component (internal)
104
- export function FormCleanUp(): JSX.Element;
105
-
106
- // Hooks in src/hooks
107
- export function useFormItemControl<T = any>(opts: {
108
- formName?: string;
109
- form?: any;
110
- name: string;
111
- initialValue?: T;
112
- formItemId?: string;
113
- rules?: any[];
114
- elementRef?: React.RefObject<any>;
115
- }): {
116
- value: T | undefined;
117
- onChange: (value: any, options?: any) => void;
118
- state: any;
119
- errors: any;
120
- onFocus: () => void;
121
- isDirty?: boolean;
122
- onReset?: (value?: any) => void;
123
- };
124
-
125
- export function useFormListControl<TItem = any>(opts: {
126
- name: string;
127
- form?: any;
128
- initialValues?: TItem[];
129
- formName?: string;
130
- }): {
131
- listFields: Array<{ name: string; key: string }>;
132
- add: (index?: number) => void;
133
- remove: (opts: { index?: number; key?: string }) => void;
134
- move: (opts: { from?: number; fromKey?: string; to: number }) => void;
135
- };
File without changes