@hw-component/form 0.0.3-beta-v5 → 0.0.3-beta-v7
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/es/DialogForm/DrawerForm/Footer.d.ts +1 -2
- package/es/DialogForm/DrawerForm/Title.d.ts +0 -1
- package/es/DialogForm/DrawerForm/index.d.ts +0 -1
- package/es/DialogForm/ModalForm.d.ts +0 -1
- package/es/DialogForm/ModalForm.js +3 -3
- package/es/DialogForm/hooks.d.ts +1 -1
- package/es/DialogForm/hooks.js +3 -3
- package/es/Form/FormItem/BasicItem.d.ts +2 -2
- package/es/Form/FormItem/BasicItem.js +19 -15
- package/es/Form/FormItem/RegularFormItem.d.ts +2 -3
- package/es/Form/FormItem/UpFormItem.d.ts +2 -3
- package/es/Form/FormItem/hooks.d.ts +2 -4
- package/es/Form/FormItem/index.d.ts +2 -3
- package/es/Form/InitSet.d.ts +0 -1
- package/es/Form/config.d.ts +5 -5
- package/es/Form/config.js +10 -10
- package/es/Form/hooks/index.d.ts +1 -0
- package/es/Form/hooks/index.js +20 -3
- package/es/Form/hooks/useDefaultRender.d.ts +3 -0
- package/es/Form/hooks/useDefaultRender.js +49 -0
- package/es/Form/hooks/useInitConfigData.d.ts +2 -2
- package/es/Form/hooks/useInitConfigData.js +26 -45
- package/es/Form/index.d.ts +0 -1
- package/es/Form/modal.d.ts +20 -13
- package/es/Input/ColorInput/Picker.d.ts +3 -0
- package/es/Input/ColorInput/Picker.js +22 -0
- package/es/Input/ColorInput/data.d.ts +1 -0
- package/es/Input/ColorInput/data.js +5 -0
- package/es/Input/ColorInput/index.d.ts +3 -0
- package/es/Input/ColorInput/index.js +76 -0
- package/es/Input/InputNumber.d.ts +0 -1
- package/es/Input/index.d.ts +0 -1
- package/es/Input/modal.d.ts +4 -1
- package/es/PageHandler/ErrorComponent.d.ts +0 -1
- package/es/PageHandler/LoadingComponent.d.ts +0 -1
- package/es/RadioGroup/index.d.ts +0 -1
- package/es/Select/components/NoFindItem.d.ts +0 -1
- package/es/Select/components/NotFoundContent.d.ts +0 -1
- package/es/Select/defaultConfig.d.ts +0 -1
- package/es/Select/index.d.ts +0 -1
- package/es/Submit/index.d.ts +3 -2
- package/es/Submit/index.js +16 -4
- package/es/TDPicker/TimePicker.d.ts +0 -1
- package/es/TDPicker/index.d.ts +3 -3
- package/es/TDPicker/index.js +6 -5
- package/es/TextArea/index.d.ts +0 -1
- package/es/Upload/Btn.d.ts +0 -1
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +0 -1
- package/es/Upload/MediaTypeEle/index.d.ts +0 -1
- package/es/Upload/Preview/index.d.ts +0 -1
- package/es/Upload/UrlUpload/index.d.ts +0 -1
- package/es/config.js +2 -1
- package/es/index.css +9 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +19 -18
- package/es/modal.d.ts +5 -4
- package/lib/DialogForm/DrawerForm/Footer.d.ts +1 -2
- package/lib/DialogForm/DrawerForm/Title.d.ts +0 -1
- package/lib/DialogForm/DrawerForm/index.d.ts +0 -1
- package/lib/DialogForm/ModalForm.d.ts +0 -1
- package/lib/DialogForm/ModalForm.js +3 -3
- package/lib/DialogForm/hooks.d.ts +1 -1
- package/lib/DialogForm/hooks.js +3 -3
- package/lib/Form/FormItem/BasicItem.d.ts +2 -2
- package/lib/Form/FormItem/BasicItem.js +21 -17
- package/lib/Form/FormItem/RegularFormItem.d.ts +2 -3
- package/lib/Form/FormItem/UpFormItem.d.ts +2 -3
- package/lib/Form/FormItem/hooks.d.ts +2 -4
- package/lib/Form/FormItem/index.d.ts +2 -3
- package/lib/Form/InitSet.d.ts +0 -1
- package/lib/Form/config.d.ts +5 -5
- package/lib/Form/config.js +6 -6
- package/lib/Form/hooks/index.d.ts +1 -0
- package/lib/Form/hooks/index.js +20 -2
- package/lib/Form/hooks/useDefaultRender.d.ts +3 -0
- package/lib/Form/hooks/useDefaultRender.js +50 -0
- package/lib/Form/hooks/useInitConfigData.d.ts +2 -2
- package/lib/Form/hooks/useInitConfigData.js +24 -43
- package/lib/Form/index.d.ts +0 -1
- package/lib/Form/modal.d.ts +20 -13
- package/lib/Input/ColorInput/Picker.d.ts +3 -0
- package/lib/Input/ColorInput/Picker.js +25 -0
- package/lib/Input/ColorInput/data.d.ts +1 -0
- package/lib/Input/ColorInput/data.js +6 -0
- package/lib/Input/ColorInput/index.d.ts +3 -0
- package/lib/Input/ColorInput/index.js +79 -0
- package/lib/Input/InputNumber.d.ts +0 -1
- package/lib/Input/index.d.ts +0 -1
- package/lib/Input/modal.d.ts +4 -1
- package/lib/PageHandler/ErrorComponent.d.ts +0 -1
- package/lib/PageHandler/LoadingComponent.d.ts +0 -1
- package/lib/RadioGroup/index.d.ts +0 -1
- package/lib/Select/components/NoFindItem.d.ts +0 -1
- package/lib/Select/components/NotFoundContent.d.ts +0 -1
- package/lib/Select/defaultConfig.d.ts +0 -1
- package/lib/Select/index.d.ts +0 -1
- package/lib/Submit/index.d.ts +3 -2
- package/lib/Submit/index.js +15 -3
- package/lib/TDPicker/TimePicker.d.ts +0 -1
- package/lib/TDPicker/index.d.ts +3 -3
- package/lib/TDPicker/index.js +6 -5
- package/lib/TextArea/index.d.ts +0 -1
- package/lib/Upload/Btn.d.ts +0 -1
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +0 -1
- package/lib/Upload/MediaTypeEle/index.d.ts +0 -1
- package/lib/Upload/Preview/index.d.ts +0 -1
- package/lib/Upload/UrlUpload/index.d.ts +0 -1
- package/lib/config.js +2 -1
- package/lib/index.css +9 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +4 -2
- package/lib/modal.d.ts +5 -4
- package/package.json +5 -3
- package/src/components/DialogForm/DrawerForm/Footer.tsx +5 -9
- package/src/components/DialogForm/DrawerForm/index.tsx +5 -5
- package/src/components/DialogForm/ModalForm.tsx +16 -11
- package/src/components/DialogForm/hooks.ts +12 -12
- package/src/components/DialogForm/modal.ts +2 -2
- package/src/components/Form/FormItem/BasicItem.tsx +22 -16
- package/src/components/Form/FormItem/RegularFormItem.tsx +2 -2
- package/src/components/Form/FormItem/UpFormItem.tsx +2 -2
- package/src/components/Form/FormItem/hooks.tsx +2 -6
- package/src/components/Form/FormItem/index.tsx +2 -2
- package/src/components/Form/config.ts +7 -5
- package/src/components/Form/hooks/index.ts +16 -9
- package/src/components/Form/hooks/useDefaultRender.tsx +42 -0
- package/src/components/Form/hooks/useHForm.ts +2 -2
- package/src/components/Form/hooks/useInitConfigData.tsx +44 -35
- package/src/components/Form/modal.ts +28 -17
- package/src/components/Input/ColorInput/Picker.tsx +18 -0
- package/src/components/Input/ColorInput/data.ts +102 -0
- package/src/components/Input/ColorInput/index.less +10 -0
- package/src/components/Input/ColorInput/index.tsx +48 -0
- package/src/components/Input/modal.ts +5 -2
- package/src/components/Select/hooks/changeHooks.tsx +1 -1
- package/src/components/Submit/index.tsx +23 -9
- package/src/components/TDPicker/RangePicker.tsx +1 -1
- package/src/components/TDPicker/index.tsx +6 -9
- package/src/components/config.ts +1 -0
- package/src/components/index.tsx +2 -1
- package/src/components/modal.ts +5 -3
- package/src/components/styles/index.less +1 -0
- package/src/pages/Form/index.tsx +16 -1
- package/src/pages/Input/index.tsx +2 -0
- package/src/pages/ModalForm/index.tsx +9 -9
package/lib/Submit/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var antd = require('antd');
|
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var index = require('../Form/Context/index.js');
|
|
10
10
|
|
|
11
|
-
var _excluded = ["text", "type", "form", "loading"];
|
|
11
|
+
var _excluded = ["text", "type", "form", "loading", "position", "reset"];
|
|
12
12
|
var HSubmit = (function (_ref) {
|
|
13
13
|
var _ref$text = _ref.text,
|
|
14
14
|
text = _ref$text === void 0 ? "提交" : _ref$text,
|
|
@@ -16,15 +16,27 @@ var HSubmit = (function (_ref) {
|
|
|
16
16
|
type = _ref$type === void 0 ? "primary" : _ref$type,
|
|
17
17
|
form = _ref.form,
|
|
18
18
|
loading = _ref.loading,
|
|
19
|
+
_ref$position = _ref.position,
|
|
20
|
+
position = _ref$position === void 0 ? "start" : _ref$position,
|
|
21
|
+
reset = _ref.reset,
|
|
19
22
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
23
|
var _useFormContext = index.useFormContext(),
|
|
21
24
|
_useFormContext$loadi = _useFormContext.loading,
|
|
22
25
|
formSubLoading = _useFormContext$loadi === void 0 ? loading : _useFormContext$loadi;
|
|
23
|
-
return /*#__PURE__*/React.createElement(antd.
|
|
26
|
+
return /*#__PURE__*/React.createElement(antd.Row, {
|
|
27
|
+
justify: position,
|
|
28
|
+
style: {
|
|
29
|
+
width: "100%"
|
|
30
|
+
}
|
|
31
|
+
}, reset && /*#__PURE__*/React.createElement(antd.Button, _extends({}, props, {
|
|
32
|
+
onClick: function onClick() {
|
|
33
|
+
form.resetFields();
|
|
34
|
+
}
|
|
35
|
+
}), "\u91CD\u5236"), /*#__PURE__*/React.createElement(antd.Button, _extends({}, props, {
|
|
24
36
|
type: type,
|
|
25
37
|
onClick: form.submit,
|
|
26
38
|
loading: formSubLoading
|
|
27
|
-
}), text);
|
|
39
|
+
}), text));
|
|
28
40
|
});
|
|
29
41
|
|
|
30
42
|
exports.default = HSubmit;
|
package/lib/TDPicker/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { HDatePickerProps } from "./modal";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
declare const Index: React.FC<HDatePickerProps>;
|
|
4
|
+
export default Index;
|
package/lib/TDPicker/index.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React = require('react');
|
|
6
5
|
var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
7
6
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
7
|
var antd = require('antd');
|
|
9
8
|
var hooks = require('./hooks.js');
|
|
9
|
+
var React = require('react');
|
|
10
10
|
|
|
11
11
|
var _excluded = ["value", "onChange", "showTime", "format"];
|
|
12
|
-
var
|
|
12
|
+
var Picker = antd.DatePicker;
|
|
13
|
+
var Index = function Index(_ref) {
|
|
13
14
|
var value = _ref.value,
|
|
14
15
|
onChange = _ref.onChange,
|
|
15
16
|
_ref$showTime = _ref.showTime,
|
|
@@ -25,12 +26,12 @@ var HDatePicker = (function (_ref) {
|
|
|
25
26
|
format: format,
|
|
26
27
|
onChange: onChange
|
|
27
28
|
});
|
|
28
|
-
return /*#__PURE__*/React.createElement(
|
|
29
|
+
return /*#__PURE__*/React.createElement(Picker, _extends({
|
|
29
30
|
value: timeVal,
|
|
30
31
|
onChange: change,
|
|
31
32
|
showTime: showTime
|
|
32
33
|
}, props));
|
|
33
|
-
}
|
|
34
|
+
};
|
|
34
35
|
|
|
35
|
-
exports.default =
|
|
36
|
+
exports.default = Index;
|
|
36
37
|
// powered by h
|
package/lib/TextArea/index.d.ts
CHANGED
package/lib/Upload/Btn.d.ts
CHANGED
package/lib/config.js
CHANGED
package/lib/index.css
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export { default as HForm } from "./Form";
|
|
|
4
4
|
export { default as useHForm } from "./Form/hooks/useHForm";
|
|
5
5
|
export { useHDialogForm } from "./DialogForm/hooks";
|
|
6
6
|
export { default as HFormConnect } from "./Form/HFormConnect";
|
|
7
|
+
export { default as HFormConfigProvider } from "./Form/Context/FormConfigProvider";
|
|
7
8
|
export declare const HSelect: ({ style, mode, options, modeConfig, value, onChange, fieldNames: propsFieldNames, request, manual, optionLabelProp, filterProvider, optionFilterProp, serviceSearch, onSearch: propsOnSearch, filterOption, showSearch, labelInValue, noMatchItemRender, allSelect, ...props }: import("./Select/modal").HSelectProps) => JSX.Element;
|
|
8
|
-
export declare const HInput: ({ ...props }: import("
|
|
9
|
+
export declare const HInput: ({ ...props }: import("./Input/modal").HInputProps<any>) => JSX.Element;
|
|
9
10
|
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
11
|
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
11
12
|
export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
@@ -19,7 +20,7 @@ export declare const HRadioGroup: ({ value, options, onChange, fieldNames: props
|
|
|
19
20
|
export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
20
21
|
export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
21
22
|
export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
|
|
22
|
-
export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
|
|
23
23
|
export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
24
|
+
export declare const HColorInput: ({ value, onChange, ...props }: import("./Input/modal").HInputProps<any>) => JSX.Element;
|
|
24
25
|
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, ...props }: import("./DialogForm/modal").DialogFormProps<any, any>) => JSX.Element;
|
|
25
26
|
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, ...props }: import("./DialogForm/modal").DialogFormProps<any, any>) => JSX.Element;
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var index = require('./Form/index.js');
|
|
|
6
6
|
var useHForm = require('./Form/hooks/useHForm.js');
|
|
7
7
|
var hooks = require('./DialogForm/hooks.js');
|
|
8
8
|
var HFormConnect = require('./Form/HFormConnect.js');
|
|
9
|
+
var FormConfigProvider = require('./Form/Context/FormConfigProvider.js');
|
|
9
10
|
var ModalForm = require('./DialogForm/ModalForm.js');
|
|
10
11
|
var index$2 = require('./DialogForm/DrawerForm/index.js');
|
|
11
12
|
|
|
@@ -24,8 +25,8 @@ var HRadioGroup = config.default.radioGroup;
|
|
|
24
25
|
var HTimePicker = config.default.timePicker;
|
|
25
26
|
var HInputNumber = config.default.inputNumber;
|
|
26
27
|
var HPageHandler = index$1.default;
|
|
27
|
-
var HFormConfigProvider = config.default.formConfigProvider;
|
|
28
28
|
var HTextArea = config.default.textArea;
|
|
29
|
+
var HColorInput = config.default.colorInput;
|
|
29
30
|
var HModalForm = ModalForm.default;
|
|
30
31
|
var HDrawerForm = index$2.default;
|
|
31
32
|
|
|
@@ -33,12 +34,13 @@ exports.HForm = index.default;
|
|
|
33
34
|
exports.useHForm = useHForm.default;
|
|
34
35
|
exports.useHDialogForm = hooks.useHDialogForm;
|
|
35
36
|
exports.HFormConnect = HFormConnect.default;
|
|
37
|
+
exports.HFormConfigProvider = FormConfigProvider.default;
|
|
36
38
|
exports.HButtonInput = HButtonInput;
|
|
37
39
|
exports.HCheckBox = HCheckBox;
|
|
38
40
|
exports.HCheckboxGroup = HCheckboxGroup;
|
|
41
|
+
exports.HColorInput = HColorInput;
|
|
39
42
|
exports.HDatePicker = HDatePicker;
|
|
40
43
|
exports.HDrawerForm = HDrawerForm;
|
|
41
|
-
exports.HFormConfigProvider = HFormConfigProvider;
|
|
42
44
|
exports.HInput = HInput;
|
|
43
45
|
exports.HInputNumber = HInputNumber;
|
|
44
46
|
exports.HModalForm = HModalForm;
|
package/lib/modal.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ export interface ValueSwitchMapModal {
|
|
|
7
7
|
open?: any;
|
|
8
8
|
close?: any;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
export interface DataFnProvider<P = any, R = any> {
|
|
11
|
+
(name: P): R;
|
|
12
|
+
}
|
|
11
13
|
export interface DateRangePickerValueMapModal {
|
|
12
|
-
start?: string |
|
|
13
|
-
end?: string |
|
|
14
|
+
start?: string | DataFnProvider<string, string>;
|
|
15
|
+
end?: string | DataFnProvider<string, string>;
|
|
14
16
|
}
|
|
15
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/form",
|
|
3
|
-
"version": "0.0.3-beta-
|
|
3
|
+
"version": "0.0.3-beta-v7",
|
|
4
4
|
"description": "基于antd二次开发",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ant-design/icons": "4.6.2",
|
|
31
|
+
"@types/react-color": "^3.0.9",
|
|
31
32
|
"ahooks": "2.10.9",
|
|
32
33
|
"antd": "4.20.7",
|
|
33
|
-
"react": "
|
|
34
|
+
"react": "17.0.0",
|
|
34
35
|
"react-dom": "17.0.2",
|
|
36
|
+
"react-color": "^2.19.3",
|
|
35
37
|
"react-router-dom": "^6.11.2"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
"@rollup/plugin-inject": "^5.0.3",
|
|
47
49
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
48
50
|
"@rollup/plugin-url": "^8.0.1",
|
|
49
|
-
"@types/react": "17.0.
|
|
51
|
+
"@types/react": "17.0.17",
|
|
50
52
|
"@types/react-dom": "17.0.9",
|
|
51
53
|
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
52
54
|
"@umijs/fabric": "^2.14.1",
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { Row, Space, Button } from "antd";
|
|
2
2
|
|
|
3
|
-
interface IProps{
|
|
4
|
-
onOk?:VoidFunction;
|
|
5
|
-
onCancel?:VoidFunction;
|
|
6
|
-
confirmLoading?:boolean;
|
|
3
|
+
interface IProps {
|
|
4
|
+
onOk?: VoidFunction;
|
|
5
|
+
onCancel?: VoidFunction;
|
|
6
|
+
confirmLoading?: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export default ({
|
|
10
|
-
onCancel,
|
|
11
|
-
onOk,
|
|
12
|
-
confirmLoading,
|
|
13
|
-
}: IProps) => {
|
|
9
|
+
export default ({ onCancel, onOk, confirmLoading }: IProps) => {
|
|
14
10
|
return (
|
|
15
11
|
<Row justify={"end"}>
|
|
16
12
|
<Space size={"middle"}>
|
|
@@ -31,13 +31,13 @@ export default ({
|
|
|
31
31
|
setModalVisible,
|
|
32
32
|
initValue,
|
|
33
33
|
onAfterClose,
|
|
34
|
-
formParams
|
|
34
|
+
formParams,
|
|
35
35
|
} = useModifyProps({
|
|
36
36
|
configData,
|
|
37
37
|
visible,
|
|
38
38
|
initialValues,
|
|
39
39
|
dialogForm: currentForm,
|
|
40
|
-
params
|
|
40
|
+
params,
|
|
41
41
|
});
|
|
42
42
|
const cancel = () => {
|
|
43
43
|
onAfterClose();
|
|
@@ -77,9 +77,9 @@ export default ({
|
|
|
77
77
|
{...props}
|
|
78
78
|
form={currentForm}
|
|
79
79
|
params={formParams}
|
|
80
|
-
onFinish={async (values,subParams) => {
|
|
81
|
-
const result = await run(values,subParams);
|
|
82
|
-
const close = onOk?.(result,subParams);
|
|
80
|
+
onFinish={async (values, subParams) => {
|
|
81
|
+
const result = await run(values, subParams);
|
|
82
|
+
const close = onOk?.(result, subParams);
|
|
83
83
|
if (close === false) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
@@ -18,14 +18,19 @@ export default ({
|
|
|
18
18
|
...props
|
|
19
19
|
}: DialogFormProps) => {
|
|
20
20
|
const currentForm = useCurrentForm(dialogForm);
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const {
|
|
22
|
+
modalVisible,
|
|
23
|
+
modalFormData,
|
|
24
|
+
setModalVisible,
|
|
25
|
+
initValue,
|
|
26
|
+
formParams,
|
|
27
|
+
} = useModifyProps({
|
|
28
|
+
configData,
|
|
29
|
+
visible,
|
|
30
|
+
initialValues,
|
|
31
|
+
dialogForm: currentForm,
|
|
32
|
+
params,
|
|
33
|
+
});
|
|
29
34
|
const cancel = () => {
|
|
30
35
|
if (onCancel) {
|
|
31
36
|
return onCancel?.();
|
|
@@ -50,9 +55,9 @@ export default ({
|
|
|
50
55
|
<HForm
|
|
51
56
|
configData={modalFormData}
|
|
52
57
|
initialValues={initValue}
|
|
53
|
-
onFinish={async (values,
|
|
54
|
-
const result = await run(values,
|
|
55
|
-
const close = onOk?.(result,
|
|
58
|
+
onFinish={async (values, outParams) => {
|
|
59
|
+
const result = await run(values, outParams);
|
|
60
|
+
const close = onOk?.(result, outParams);
|
|
56
61
|
if (close === false) {
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
@@ -13,12 +13,12 @@ export const useModifyProps = ({
|
|
|
13
13
|
initialValues,
|
|
14
14
|
dialogForm,
|
|
15
15
|
afterClose,
|
|
16
|
-
params
|
|
16
|
+
params,
|
|
17
17
|
}: ModifyPropsModal) => {
|
|
18
18
|
const [modalVisible, setModalVisible] = useState(visible);
|
|
19
19
|
const [modalFormData, setModalFormData] = useState(configData);
|
|
20
20
|
const [initValue, setInitValue] = useState(initialValues);
|
|
21
|
-
const [formParams,setFormParams]=useState(params);
|
|
21
|
+
const [formParams, setFormParams] = useState(params);
|
|
22
22
|
const onAfterClose = () => {
|
|
23
23
|
setTimeout(() => {
|
|
24
24
|
dialogForm.resetFields();
|
|
@@ -33,22 +33,22 @@ export const useModifyProps = ({
|
|
|
33
33
|
useEffect(() => {
|
|
34
34
|
setModalFormData(configData);
|
|
35
35
|
}, [configData]);
|
|
36
|
-
useEffect(()=>{
|
|
37
|
-
|
|
38
|
-
},[params])
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setFormParams(params);
|
|
38
|
+
}, [params]);
|
|
39
39
|
|
|
40
40
|
useEffect(() => {
|
|
41
41
|
dialogForm.show = (showParams = {}) => {
|
|
42
42
|
const {
|
|
43
43
|
configData: changeConfigData,
|
|
44
44
|
initialValues: changeInitialValues,
|
|
45
|
-
params
|
|
45
|
+
params: changeParams,
|
|
46
46
|
} = showParams;
|
|
47
47
|
if (!!changeConfigData) {
|
|
48
48
|
setModalFormData(changeConfigData);
|
|
49
49
|
}
|
|
50
|
-
if (!!
|
|
51
|
-
setFormParams(
|
|
50
|
+
if (!!changeParams) {
|
|
51
|
+
setFormParams(changeParams);
|
|
52
52
|
}
|
|
53
53
|
setInitValue(changeInitialValues);
|
|
54
54
|
setModalVisible(true);
|
|
@@ -66,7 +66,7 @@ export const useModifyProps = ({
|
|
|
66
66
|
initValue,
|
|
67
67
|
setInitValue,
|
|
68
68
|
onAfterClose,
|
|
69
|
-
formParams
|
|
69
|
+
formParams,
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
export const useHDialogForm = () => {
|
|
@@ -87,12 +87,12 @@ export const useCurrentForm = (hDialogForm?: HDialogFormInstance) => {
|
|
|
87
87
|
|
|
88
88
|
export const useSub = ({ request, onFinish }: Partial<DialogFormProps>) => {
|
|
89
89
|
return useRequest(
|
|
90
|
-
async (values,params) => {
|
|
90
|
+
async (values, params) => {
|
|
91
91
|
if (onFinish) {
|
|
92
|
-
return onFinish(values,params);
|
|
92
|
+
return onFinish(values, params);
|
|
93
93
|
}
|
|
94
94
|
if (request) {
|
|
95
|
-
return request(values,params);
|
|
95
|
+
return request(values, params);
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
{ manual: true }
|
|
@@ -27,8 +27,8 @@ export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
|
|
|
27
27
|
export interface DialogFormProps<P = any, T = any>
|
|
28
28
|
extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest"> {
|
|
29
29
|
dialogForm?: HDialogFormInstance;
|
|
30
|
-
onFinish?:(values:T,params:P)=>Promise<any>;
|
|
30
|
+
onFinish?: (values: T, params: P) => Promise<any>;
|
|
31
31
|
onCancel?: VoidFunction;
|
|
32
|
-
onOk?: (data: T,params:P) => boolean | undefined;
|
|
32
|
+
onOk?: (data: T, params: P) => boolean | undefined;
|
|
33
33
|
infoRequest?: (params: P) => Promise<T>;
|
|
34
34
|
}
|
|
@@ -5,7 +5,10 @@ import Helper from "./Helper";
|
|
|
5
5
|
import { useClassName } from "../../hooks";
|
|
6
6
|
import { useHide } from "./hooks";
|
|
7
7
|
import { useFormContext } from "../Context";
|
|
8
|
-
import type {
|
|
8
|
+
import type { HItemProps } from "../modal";
|
|
9
|
+
import { useDefaultRender } from "../hooks/useDefaultRender";
|
|
10
|
+
import type { HFormItemProps } from "../modal";
|
|
11
|
+
import { useDefaultComponents } from "../hooks";
|
|
9
12
|
|
|
10
13
|
interface ContentProps extends Omit<HItemProps, "name"> {
|
|
11
14
|
value?: any;
|
|
@@ -28,20 +31,23 @@ const Content: React.FC<ContentProps> = ({
|
|
|
28
31
|
);
|
|
29
32
|
};
|
|
30
33
|
|
|
31
|
-
const Index: React.FC<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
const Index: React.FC<HFormItemProps> = (props) => {
|
|
35
|
+
const {
|
|
36
|
+
hover,
|
|
37
|
+
labelWidth,
|
|
38
|
+
required,
|
|
39
|
+
colon = true,
|
|
40
|
+
label,
|
|
41
|
+
itemProps,
|
|
42
|
+
children,
|
|
43
|
+
helper,
|
|
44
|
+
hide,
|
|
45
|
+
render,
|
|
46
|
+
...oProps
|
|
47
|
+
} = props;
|
|
44
48
|
const { form } = useFormContext();
|
|
49
|
+
const defaultComponent = useDefaultComponents();
|
|
50
|
+
const defaultRender = useDefaultRender(props, defaultComponent);
|
|
45
51
|
const hideItem = useHide({ hide, form });
|
|
46
52
|
if (hideItem) {
|
|
47
53
|
return null;
|
|
@@ -58,11 +64,11 @@ const Index: React.FC<FormItemWithRender> = ({
|
|
|
58
64
|
{label}
|
|
59
65
|
</Label>
|
|
60
66
|
}
|
|
61
|
-
{...
|
|
67
|
+
{...oProps}
|
|
62
68
|
colon={false}
|
|
63
69
|
required={false}
|
|
64
70
|
>
|
|
65
|
-
<Content helper={helper}>{
|
|
71
|
+
<Content helper={helper}>{defaultRender(form)}</Content>
|
|
66
72
|
</Form.Item>
|
|
67
73
|
);
|
|
68
74
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BasicItem from "./BasicItem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HItemProps } from "../modal";
|
|
3
3
|
|
|
4
|
-
export default (props:
|
|
4
|
+
export default (props: HItemProps) => {
|
|
5
5
|
const { type, colon } = props;
|
|
6
6
|
return <BasicItem {...props} colon={type === "submit" ? false : colon} />;
|
|
7
7
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Form } from "antd";
|
|
2
|
-
import type { FormItemWithRender } from "../modal";
|
|
3
2
|
import BasicItem from "./BasicItem";
|
|
4
3
|
import { useShouldUpdate } from "./hooks";
|
|
4
|
+
import type { HFormItemProps } from "../modal";
|
|
5
5
|
const { Item } = Form;
|
|
6
6
|
export default ({
|
|
7
7
|
shouldUpdate,
|
|
8
8
|
dependencies,
|
|
9
9
|
hide,
|
|
10
10
|
...props
|
|
11
|
-
}:
|
|
11
|
+
}: HFormItemProps) => {
|
|
12
12
|
const resultShouldUpdate = useShouldUpdate({ shouldUpdate, hide });
|
|
13
13
|
return (
|
|
14
14
|
<Item shouldUpdate={resultShouldUpdate} dependencies={dependencies} noStyle>
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import UpFormItem from "./UpFormItem";
|
|
2
2
|
import RegularFormItem from "./RegularFormItem";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
import type {
|
|
5
|
-
FormItemWithRender,
|
|
6
|
-
HFormInstance,
|
|
7
|
-
} from "@/components/Form/modal";
|
|
8
|
-
import type { HItemProps } from "@/components/Form/modal";
|
|
4
|
+
import type { HFormInstance, HItemProps } from "../modal";
|
|
9
5
|
|
|
10
6
|
export const useFormItemDomControl = ({
|
|
11
7
|
shouldUpdate,
|
|
12
8
|
hide,
|
|
13
9
|
dependencies,
|
|
14
|
-
}:
|
|
10
|
+
}: HItemProps) => {
|
|
15
11
|
return useMemo(() => {
|
|
16
12
|
if (shouldUpdate || typeof hide === "function" || dependencies) {
|
|
17
13
|
return UpFormItem;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useFormItemDomControl } from "./hooks";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HItemProps } from "../modal";
|
|
4
4
|
|
|
5
|
-
export default (props:
|
|
5
|
+
export default (props: HItemProps) => {
|
|
6
6
|
const Component = useFormItemDomControl(props);
|
|
7
7
|
return <Component {...props} />;
|
|
8
8
|
};
|
|
@@ -13,14 +13,14 @@ import HTimePicker from "../TDPicker/TimePicker";
|
|
|
13
13
|
import HUpload from "../Upload";
|
|
14
14
|
import HUrlUpload from "../Upload/UrlUpload";
|
|
15
15
|
import HSubmit from "../Submit";
|
|
16
|
-
import FormConfigProvider from "../Form/Context/FormConfigProvider";
|
|
17
16
|
import TextArea from "../TextArea";
|
|
17
|
+
import ColorInput from "../Input/ColorInput";
|
|
18
|
+
|
|
18
19
|
export const placeholderConfig = {
|
|
19
20
|
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
20
|
-
selectType: ["select", "datePicker", "timePicker"],
|
|
21
|
+
selectType: ["select", "datePicker", "timePicker", "colorInput"],
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
export default {
|
|
23
|
+
const componentConfig = {
|
|
24
24
|
select: HSelect,
|
|
25
25
|
inputNumber: HInputNumber,
|
|
26
26
|
selectInput: HSelectInput,
|
|
@@ -36,6 +36,8 @@ export default {
|
|
|
36
36
|
upload: HUpload,
|
|
37
37
|
urlUpload: HUrlUpload,
|
|
38
38
|
submit: HSubmit,
|
|
39
|
-
formConfigProvider: FormConfigProvider,
|
|
40
39
|
textArea: TextArea,
|
|
40
|
+
colorInput: ColorInput,
|
|
41
41
|
};
|
|
42
|
+
|
|
43
|
+
export default componentConfig;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useRequest } from "ahooks";
|
|
2
2
|
import type { HFormProps, HFormInstance } from "../modal";
|
|
3
3
|
import useHForm from "./useHForm";
|
|
4
|
-
import {useEffect, useMemo} from "react";
|
|
4
|
+
import { useEffect, useMemo } from "react";
|
|
5
|
+
import FormConfig from "../config";
|
|
6
|
+
import { useFormConfigContext } from "../Context/FormConfigProvider";
|
|
5
7
|
export const useCurrentForm = (form?: HFormInstance) => {
|
|
6
8
|
const selfForm = useHForm();
|
|
7
9
|
return form || selfForm;
|
|
@@ -27,9 +29,9 @@ export const useInfoReq = ({
|
|
|
27
29
|
async (value) => {
|
|
28
30
|
const subVal = form?.outputValues(value);
|
|
29
31
|
if (request) {
|
|
30
|
-
await request(subVal,reqData.params);
|
|
32
|
+
await request(subVal, reqData.params);
|
|
31
33
|
}
|
|
32
|
-
onFinish?.(subVal,reqData.params);
|
|
34
|
+
onFinish?.(subVal, reqData.params);
|
|
33
35
|
},
|
|
34
36
|
{ manual: true }
|
|
35
37
|
);
|
|
@@ -45,17 +47,22 @@ export const useInfoReq = ({
|
|
|
45
47
|
form?.setFieldsValue(setValue);
|
|
46
48
|
return setValue || {};
|
|
47
49
|
});
|
|
48
|
-
const {run,mutate}=infoControl;
|
|
49
|
-
useEffect(()=>{
|
|
50
|
-
if (form){
|
|
51
|
-
form.reload=(
|
|
50
|
+
const { run, mutate } = infoControl;
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (form) {
|
|
53
|
+
form.reload = (reloadParams) => {
|
|
52
54
|
mutate(undefined);
|
|
53
|
-
return run(
|
|
55
|
+
return run(reloadParams);
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
|
-
},[]);
|
|
58
|
+
}, []);
|
|
57
59
|
return {
|
|
58
60
|
subControl,
|
|
59
61
|
infoControl,
|
|
60
62
|
};
|
|
61
63
|
};
|
|
64
|
+
|
|
65
|
+
export const useDefaultComponents = () => {
|
|
66
|
+
const defaultComponent = useFormConfigContext("defaultComponent");
|
|
67
|
+
return { ...FormConfig, ...defaultComponent };
|
|
68
|
+
};
|