revdev-components 0.20.0 → 0.22.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
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?: 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
|
|
|
@@ -4814,7 +4797,7 @@ var InfoDialog = function (_a) {
|
|
|
4814
4797
|
var s$8 = {"root":"index-module_root__BQI-i","header":"index-module_header__OUCQj","title":"index-module_title__HPbDC","close":"index-module_close__-FN6K","content":"index-module_content__BpXha","footer":"index-module_footer__xqKte"};
|
|
4815
4798
|
|
|
4816
4799
|
var RegularDialog = function (_a) {
|
|
4817
|
-
var titleIcon = _a.titleIcon, titlePrefix = _a.titlePrefix, title = _a.title, children = _a.children, _b = _a.hideFooter, hideFooter = _b === void 0 ? false : _b, className = _a.className, width = _a.width, okText = _a.okText, cancelText = _a.cancelText, footerClassName = _a.footerClassName, contentClassName = _a.contentClassName,
|
|
4800
|
+
var titleIcon = _a.titleIcon, titlePrefix = _a.titlePrefix, title = _a.title, children = _a.children, _b = _a.hideFooter, hideFooter = _b === void 0 ? false : _b, className = _a.className, width = _a.width, okText = _a.okText, cancelText = _a.cancelText, footerClassName = _a.footerClassName, contentClassName = _a.contentClassName, okHide = _a.okHide, okDisabled = _a.okDisabled, onOk = _a.onOk, onClose = _a.onClose, _c = _a.open, open = _c === void 0 ? true : _c;
|
|
4818
4801
|
var close = React.useMemo(function () {
|
|
4819
4802
|
return React.createElement(RegularIcon, { name: "cross", className: s$8.close, onClick: onClose });
|
|
4820
4803
|
}, [onClose]);
|
|
@@ -4851,7 +4834,7 @@ var RegularDialog = function (_a) {
|
|
|
4851
4834
|
React.createElement("div", { className: classNames(s$8.content, contentClassName) }, children),
|
|
4852
4835
|
hideFooter ? null : (React.createElement("div", { className: classNames(s$8.footer, footerClassName) },
|
|
4853
4836
|
React.createElement(antd.Button, { onClick: onClose }, cancelText || "Cancel"),
|
|
4854
|
-
|
|
4837
|
+
okHide ? null : (React.createElement(antd.Button, { type: "primary", onClick: handleOk, disabled: okDisabled }, okText || "OK"))))));
|
|
4855
4838
|
};
|
|
4856
4839
|
|
|
4857
4840
|
var s$7 = {"root":"index-module_root__9mhio"};
|
|
@@ -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
|
}
|