revdev-components 0.21.0 → 0.23.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/build/form/index.d.ts +5 -7
- package/build/index.js +4 -21
- package/build/interfaces/form.d.ts +5 -5
- package/package.json +1 -1
package/build/form/index.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FormInstance } from "antd/lib/form";
|
|
3
|
-
import { Store } from "antd/es/form/interface";
|
|
4
3
|
import { FieldData } from "../interfaces";
|
|
5
4
|
export interface FormOptions {
|
|
6
5
|
valid: boolean;
|
|
7
6
|
}
|
|
8
|
-
export interface AppFormProps {
|
|
7
|
+
export interface AppFormProps<T = any> {
|
|
9
8
|
children?: React.ReactNode | ((options: FormOptions) => React.ReactNode);
|
|
10
9
|
className?: string;
|
|
11
|
-
onFinish?: (values:
|
|
12
|
-
onValuesChange?: (changedValues:
|
|
13
|
-
onChange?: (values: any) => void;
|
|
10
|
+
onFinish?: (values: T) => void;
|
|
11
|
+
onValuesChange?: (changedValues: Partial<T>, values: T) => void;
|
|
14
12
|
onFieldsChange?: (changedFields: FieldData[], allFields: FieldData[]) => void;
|
|
15
13
|
form?: FormInstance;
|
|
16
14
|
onValid?: (valid: boolean) => void;
|
|
17
|
-
initialValues?:
|
|
15
|
+
initialValues?: Partial<T>;
|
|
18
16
|
}
|
|
19
|
-
export declare
|
|
17
|
+
export declare function AppForm<T = any>({ form: propForm, children, className, onFinish, onValuesChange, onFieldsChange, onValid, initialValues, }: AppFormProps<T>): React.ReactElement<AppFormProps<T>>;
|
package/build/index.js
CHANGED
|
@@ -4620,28 +4620,11 @@ function useForm(form) {
|
|
|
4620
4620
|
var newForm = antd.Form.useForm()[0];
|
|
4621
4621
|
return form ? form : newForm;
|
|
4622
4622
|
}
|
|
4623
|
-
|
|
4624
|
-
var propForm = _a.form, children = _a.children, className = _a.className, onFinish = _a.onFinish, onValuesChange = _a.onValuesChange,
|
|
4623
|
+
function AppForm(_a) {
|
|
4624
|
+
var propForm = _a.form, children = _a.children, className = _a.className, onFinish = _a.onFinish, onValuesChange = _a.onValuesChange, onFieldsChange = _a.onFieldsChange, onValid = _a.onValid, initialValues = _a.initialValues;
|
|
4625
4625
|
var form = useForm(propForm);
|
|
4626
4626
|
var _b = React.useState(false), valid = _b[0], setValid = _b[1];
|
|
4627
4627
|
var values = antd.Form.useWatch([], form);
|
|
4628
|
-
var handleValuesChange = React.useCallback(function (changedValues, values) {
|
|
4629
|
-
if (onValuesChange) {
|
|
4630
|
-
onValuesChange(changedValues, values);
|
|
4631
|
-
}
|
|
4632
|
-
}, [form, onValuesChange]);
|
|
4633
|
-
var handleFieldsChange = React.useCallback(function (changedFields, allFields) {
|
|
4634
|
-
if (onFieldsChange) {
|
|
4635
|
-
onFieldsChange(changedFields, allFields);
|
|
4636
|
-
}
|
|
4637
|
-
if (onChange) {
|
|
4638
|
-
var allValues_1 = {};
|
|
4639
|
-
allFields.forEach(function (x) {
|
|
4640
|
-
allValues_1[x.name] = x.value;
|
|
4641
|
-
});
|
|
4642
|
-
onChange(allValues_1);
|
|
4643
|
-
}
|
|
4644
|
-
}, [form, onFieldsChange, onChange]);
|
|
4645
4628
|
React.useEffect(function () {
|
|
4646
4629
|
form
|
|
4647
4630
|
.validateFields({ validateOnly: true })
|
|
@@ -4651,8 +4634,8 @@ var AppForm = function (_a) {
|
|
|
4651
4634
|
React.useEffect(function () {
|
|
4652
4635
|
onValid === null || onValid === void 0 ? void 0 : onValid(valid);
|
|
4653
4636
|
}, [onValid, valid]);
|
|
4654
|
-
return (React.createElement(antd.Form, { form: form, onFinish: onFinish, className: classNames(s$g.root, className), layout: "vertical", onValuesChange:
|
|
4655
|
-
}
|
|
4637
|
+
return (React.createElement(antd.Form, { form: form, onFinish: onFinish, className: classNames(s$g.root, className), layout: "vertical", onValuesChange: onValuesChange, onFieldsChange: onFieldsChange, initialValues: initialValues }, typeof children === "function" ? children({ valid: valid }) : children));
|
|
4638
|
+
}
|
|
4656
4639
|
|
|
4657
4640
|
var s$f = {"root":"index-module_root__2S1Jp"};
|
|
4658
4641
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface FieldData {
|
|
2
|
-
touched
|
|
3
|
-
validating
|
|
4
|
-
errors
|
|
5
|
-
warnings
|
|
2
|
+
touched?: boolean;
|
|
3
|
+
validating?: boolean;
|
|
4
|
+
errors?: string[];
|
|
5
|
+
warnings?: string[];
|
|
6
6
|
name: string;
|
|
7
|
-
validated
|
|
7
|
+
validated?: boolean;
|
|
8
8
|
value?: any;
|
|
9
9
|
}
|