react-form-manage 1.1.0-beta.4 → 1.1.0-beta.5
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/CHANGELOG.md +24 -0
- package/dist/test/TestMuiReRender/TestModalReRenderUI.d.ts +3 -0
- package/dist/test/TestMuiReRender/TestModalReRenderUI.js +13 -0
- package/dist/test/TestMuiReRender/TestMuiReRenderForm.d.ts +3 -0
- package/dist/test/TestMuiReRender/TestMuiReRenderForm.js +25 -0
- package/dist/test/TestMuiReRender/index.d.ts +3 -0
- package/dist/test/TestMuiReRender/index.js +9 -0
- package/dist/types/public.d.ts +3 -2
- package/package.json +1 -1
- package/src/App.tsx +4 -2
- package/src/test/TestMuiReRender/TestModalReRenderUI.tsx +22 -0
- package/src/test/TestMuiReRender/TestMuiReRenderForm.tsx +37 -0
- package/src/test/TestMuiReRender/index.tsx +9 -0
- package/src/types/public.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.1.0-beta.5] - 2026-03-09
|
|
6
|
+
|
|
7
|
+
### Type Improvements
|
|
8
|
+
|
|
9
|
+
- **Enhanced Submit Methods**: Updated `submit` and `submitAsync` method signatures
|
|
10
|
+
- Changed from `submit(values?: T)` to `submit(props?: SubmitProps<T>)`
|
|
11
|
+
- Changed from `submitAsync(values?: T)` to `submitAsync(props?: SubmitProps<T>)`
|
|
12
|
+
- Now supports external callback functions for better submit flow control
|
|
13
|
+
|
|
14
|
+
### New Features
|
|
15
|
+
|
|
16
|
+
- **SubmitProps Interface**: New interface for submit method parameters
|
|
17
|
+
- `externalFinishCallback`: Called when form validation succeeds with form values
|
|
18
|
+
- `externalRejectCallback`: Called when form validation fails with error fields
|
|
19
|
+
- `externalFinallyCallback`: Called after submit completes with complete result info
|
|
20
|
+
- All callbacks support both synchronous and asynchronous execution
|
|
21
|
+
|
|
22
|
+
### Technical Details
|
|
23
|
+
|
|
24
|
+
- `SubmitProps<T>` interface exported from formStore
|
|
25
|
+
- Allows programmatic submit with custom callbacks without requiring Form component props
|
|
26
|
+
- Better separation of concerns between form state and submit handlers
|
|
27
|
+
- Enables more flexible submit workflows (e.g., submit via form instance methods)
|
|
28
|
+
|
|
5
29
|
## [1.1.0-beta.4] - 2026-03-04
|
|
6
30
|
|
|
7
31
|
### Performance & Code Quality
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog, DialogContent } from "@mui/material";
|
|
3
|
+
import { Button } from "antd";
|
|
4
|
+
import { useToggle } from "minh-custom-hooks-release";
|
|
5
|
+
import TestMuiReRenderForm from "./TestMuiReRenderForm";
|
|
6
|
+
function TestModalReRenderUI({}) {
|
|
7
|
+
const { state, on, off } = useToggle();
|
|
8
|
+
return _jsxs("div", { children: [_jsx(Button, { onClick: on, children: "Open Modal" }), _jsx(Dialog, { open: state, onClose: off, children: _jsx(DialogContent, { children: _jsx(TestMuiReRenderForm, {}) }) })] });
|
|
9
|
+
}
|
|
10
|
+
var stdin_default = TestModalReRenderUI;
|
|
11
|
+
export {
|
|
12
|
+
stdin_default as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TextField } from "@mui/material";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import Form from "../../providers/Form";
|
|
5
|
+
function TestMuiReRenderForm({}) {
|
|
6
|
+
const [form, isMounted] = Form.useForm("testMuiReRender");
|
|
7
|
+
const name = Form.useWatch("name", form);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (isMounted) {
|
|
10
|
+
form.setFieldValue("name", "John Doe");
|
|
11
|
+
}
|
|
12
|
+
}, [isMounted]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (name) {
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
form.setFieldValue("name2", "Hello " + name);
|
|
17
|
+
}, 1e3);
|
|
18
|
+
}
|
|
19
|
+
}, [name]);
|
|
20
|
+
return _jsxs(Form, { formName: "testMuiReRender", children: [_jsx(Form.Item, { controlAfterInit: true, initialValue: "", name: "name", children: _jsx(TextField, { label: "Name", disabled: true }) }), _jsx(Form.Item, { controlAfterInit: true, initialValue: "", name: "name2", children: _jsx(TextField, { label: "Greeting", disabled: true }) })] });
|
|
21
|
+
}
|
|
22
|
+
var stdin_default = TestMuiReRenderForm;
|
|
23
|
+
export {
|
|
24
|
+
stdin_default as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import TestModalReRenderUI from "./TestModalReRenderUI";
|
|
3
|
+
function TestMuiReRender({}) {
|
|
4
|
+
return _jsx(TestModalReRenderUI, {});
|
|
5
|
+
}
|
|
6
|
+
var stdin_default = TestMuiReRender;
|
|
7
|
+
export {
|
|
8
|
+
stdin_default as default
|
|
9
|
+
};
|
package/dist/types/public.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SUBMIT_STATE } from "../constants/form";
|
|
2
2
|
import { OnChangeOptions } from "../hooks/useFormItemControl";
|
|
3
3
|
import { SetFieldValueOptions } from "../providers/Form";
|
|
4
|
+
import { SubmitProps } from "../stores/formStore";
|
|
4
5
|
import type { GetConstantType } from "./util";
|
|
5
6
|
export type FormValues<T = any> = T;
|
|
6
7
|
export interface FormFieldError {
|
|
@@ -34,8 +35,8 @@ export interface ValidationRule<T = any, TValues = any> {
|
|
|
34
35
|
export interface PublicFormInstance<T = any> {
|
|
35
36
|
formName: string;
|
|
36
37
|
resetFields: (values?: Partial<T>) => void;
|
|
37
|
-
submit: (
|
|
38
|
-
submitAsync: (
|
|
38
|
+
submit: (props?: SubmitProps<T>) => void;
|
|
39
|
+
submitAsync: (props?: SubmitProps<T>) => Promise<void>;
|
|
39
40
|
setFieldValue: (name: keyof T | (string & {}), value: any, options?: SetFieldValueOptions) => void;
|
|
40
41
|
setFieldValues: (values: Partial<T>, options?: OnChangeOptions) => void;
|
|
41
42
|
getFieldValue: (name: keyof T | (string & {})) => any;
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Form from "./providers/Form";
|
|
2
2
|
|
|
3
3
|
import { Form as AntdForm } from "antd";
|
|
4
|
-
import
|
|
4
|
+
import TestMuiReRender from "./test/TestMuiReRender";
|
|
5
5
|
|
|
6
6
|
function TestFormWatch() {
|
|
7
7
|
const watchValue = Form.useWatch("numericCode");
|
|
@@ -48,7 +48,9 @@ const App = () => {
|
|
|
48
48
|
|
|
49
49
|
{/* <FormInstanceTestSuite /> */}
|
|
50
50
|
|
|
51
|
-
<SelfTestGetForm />
|
|
51
|
+
{/* <SelfTestGetForm /> */}
|
|
52
|
+
|
|
53
|
+
<TestMuiReRender />
|
|
52
54
|
</div>
|
|
53
55
|
);
|
|
54
56
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Dialog, DialogContent } from "@mui/material";
|
|
2
|
+
import { Button } from "antd";
|
|
3
|
+
import { useToggle } from "minh-custom-hooks-release";
|
|
4
|
+
import TestMuiReRenderForm from "./TestMuiReRenderForm";
|
|
5
|
+
|
|
6
|
+
type Props = {};
|
|
7
|
+
|
|
8
|
+
function TestModalReRenderUI({}: Props) {
|
|
9
|
+
const { state, on, off } = useToggle();
|
|
10
|
+
return (
|
|
11
|
+
<div>
|
|
12
|
+
<Button onClick={on}>Open Modal</Button>
|
|
13
|
+
<Dialog open={state} onClose={off}>
|
|
14
|
+
<DialogContent>
|
|
15
|
+
<TestMuiReRenderForm />
|
|
16
|
+
</DialogContent>
|
|
17
|
+
</Dialog>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default TestModalReRenderUI;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TextField } from "@mui/material";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import Form from "../../providers/Form";
|
|
4
|
+
|
|
5
|
+
type Props = {};
|
|
6
|
+
|
|
7
|
+
function TestMuiReRenderForm({}: Props) {
|
|
8
|
+
const [form, isMounted] = Form.useForm("testMuiReRender");
|
|
9
|
+
const name = Form.useWatch("name", form);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (isMounted) {
|
|
13
|
+
form.setFieldValue("name", "John Doe");
|
|
14
|
+
}
|
|
15
|
+
}, [isMounted]);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (name) {
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
form.setFieldValue("name2", "Hello " + name);
|
|
21
|
+
}, 1000);
|
|
22
|
+
}
|
|
23
|
+
}, [name]);
|
|
24
|
+
return (
|
|
25
|
+
<Form formName="testMuiReRender">
|
|
26
|
+
<Form.Item controlAfterInit initialValue={""} name="name">
|
|
27
|
+
<TextField label="Name" disabled />
|
|
28
|
+
</Form.Item>
|
|
29
|
+
|
|
30
|
+
<Form.Item controlAfterInit initialValue={""} name="name2">
|
|
31
|
+
<TextField label="Greeting" disabled />
|
|
32
|
+
</Form.Item>
|
|
33
|
+
</Form>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default TestMuiReRenderForm;
|
package/src/types/public.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SUBMIT_STATE } from "../constants/form";
|
|
2
2
|
import { OnChangeOptions } from "../hooks/useFormItemControl";
|
|
3
3
|
import { SetFieldValueOptions } from "../providers/Form";
|
|
4
|
+
import { SubmitProps } from "../stores/formStore";
|
|
4
5
|
import type { GetConstantType } from "./util";
|
|
5
6
|
|
|
6
7
|
export type FormValues<T = any> = T;
|
|
@@ -38,8 +39,8 @@ export interface ValidationRule<T = any, TValues = any> {
|
|
|
38
39
|
export interface PublicFormInstance<T = any> {
|
|
39
40
|
formName: string;
|
|
40
41
|
resetFields: (values?: Partial<T>) => void;
|
|
41
|
-
submit: (
|
|
42
|
-
submitAsync: (
|
|
42
|
+
submit: (props?: SubmitProps<T>) => void;
|
|
43
|
+
submitAsync: (props?: SubmitProps<T>) => Promise<void>;
|
|
43
44
|
setFieldValue: (
|
|
44
45
|
name: keyof T | (string & {}),
|
|
45
46
|
value: any,
|