@hw-component/form 0.0.1-beta-v6 → 0.0.1-beta-v8
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/CheckboxGroup/index.d.ts +1 -1
- package/es/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Footer.js +23 -0
- package/es/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Title.js +18 -0
- package/es/DialogForm/DrawerForm/index.d.ts +4 -0
- package/es/DialogForm/DrawerForm/index.js +111 -0
- package/es/DialogForm/ModalForm.d.ts +4 -0
- package/es/{ModalForm/index.js → DialogForm/ModalForm.js} +39 -9
- package/es/DialogForm/hooks.d.ts +15 -0
- package/es/{ModalForm → DialogForm}/hooks.js +58 -13
- package/es/{ModalForm → DialogForm}/modal.d.ts +7 -4
- package/es/Form/HFormConnect.d.ts +1 -2
- package/es/Form/HFormConnect.js +8 -15
- package/es/Form/config.d.ts +4 -4
- package/es/Form/config.js +4 -4
- package/es/Form/modal.d.ts +7 -1
- package/es/Input/SelectInput.d.ts +1 -1
- package/es/TDPicker/RangePicker.d.ts +1 -1
- package/es/Upload/UrlUpload/index.d.ts +2 -2
- package/es/Upload/UrlUpload/index.js +3 -3
- package/es/Upload/index.d.ts +1 -2
- package/es/Upload/index.js +39 -5
- package/es/Upload/modal.d.ts +2 -0
- package/es/index.d.ts +7 -6
- package/es/index.js +5 -3
- package/lib/CheckboxGroup/index.d.ts +1 -1
- package/lib/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Footer.js +26 -0
- package/lib/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Title.js +21 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/index.js +114 -0
- package/lib/DialogForm/ModalForm.d.ts +4 -0
- package/lib/{ModalForm/index.js → DialogForm/ModalForm.js} +38 -8
- package/lib/DialogForm/hooks.d.ts +15 -0
- package/lib/{ModalForm → DialogForm}/hooks.js +59 -13
- package/lib/{ModalForm → DialogForm}/modal.d.ts +7 -4
- package/lib/Form/HFormConnect.d.ts +1 -2
- package/lib/Form/HFormConnect.js +8 -15
- package/lib/Form/config.d.ts +4 -4
- package/lib/Form/modal.d.ts +7 -1
- package/lib/Input/SelectInput.d.ts +1 -1
- package/lib/TDPicker/RangePicker.d.ts +1 -1
- package/lib/Upload/UrlUpload/index.d.ts +2 -2
- package/lib/Upload/UrlUpload/index.js +3 -3
- package/lib/Upload/index.d.ts +1 -2
- package/lib/Upload/index.js +39 -5
- package/lib/Upload/modal.d.ts +2 -0
- package/lib/index.d.ts +7 -6
- package/lib/index.js +7 -4
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/Footer.tsx +19 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +85 -0
- package/src/components/{ModalForm/index.tsx → DialogForm/ModalForm.tsx} +14 -6
- package/src/components/{ModalForm → DialogForm}/hooks.ts +36 -11
- package/src/components/{ModalForm → DialogForm}/modal.ts +7 -4
- package/src/components/Form/HFormConnect.tsx +21 -7
- package/src/components/Form/config.ts +2 -2
- package/src/components/Form/modal.ts +7 -1
- package/src/components/Input/SelectInput.tsx +1 -0
- package/src/components/TDPicker/modal.ts +0 -1
- package/src/components/Upload/UrlUpload/index.tsx +2 -2
- package/src/components/Upload/index.tsx +39 -7
- package/src/components/Upload/modal.ts +2 -0
- package/src/components/index.tsx +5 -4
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +3 -0
- package/src/pages/ModalForm/index.tsx +2 -2
- package/src/routes.tsx +7 -0
- package/es/ModalForm/hooks.d.ts +0 -12
- package/es/ModalForm/index.d.ts +0 -4
- package/lib/ModalForm/hooks.d.ts +0 -12
- package/lib/ModalForm/index.d.ts +0 -4
package/lib/Form/HFormConnect.js
CHANGED
|
@@ -2,20 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
|
|
7
|
-
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
|
|
8
|
-
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
|
|
9
|
-
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
10
|
-
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
|
|
11
|
-
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
|
|
12
|
-
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
|
|
13
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
5
|
+
var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
14
6
|
var index = require('./Context/index.js');
|
|
15
7
|
var React = require('react');
|
|
16
8
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
9
|
var formatMaker = function formatMaker(itemProps, formats) {
|
|
20
10
|
if (!formats) {
|
|
21
11
|
return formats;
|
|
@@ -31,11 +21,11 @@ var formatMaker = function formatMaker(itemProps, formats) {
|
|
|
31
21
|
}
|
|
32
22
|
};
|
|
33
23
|
};
|
|
34
|
-
var HFormConnect = (function (
|
|
24
|
+
var HFormConnect = (function (component) {
|
|
35
25
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
26
|
var _config$format = config.format,
|
|
37
27
|
format = _config$format === void 0 ? {} : _config$format;
|
|
38
|
-
|
|
28
|
+
var Index = function Index(props, ref) {
|
|
39
29
|
var _props$name = props.name,
|
|
40
30
|
name = _props$name === void 0 ? "" : _props$name;
|
|
41
31
|
var _useFormContext = index.useFormContext(),
|
|
@@ -54,11 +44,14 @@ var HFormConnect = (function (Component) {
|
|
|
54
44
|
name: name
|
|
55
45
|
}, fn);
|
|
56
46
|
};
|
|
57
|
-
|
|
47
|
+
var Component = component;
|
|
48
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
58
49
|
addFormat: addFormat,
|
|
59
|
-
addDispatchListener: addDispatchListener
|
|
50
|
+
addDispatchListener: addDispatchListener,
|
|
51
|
+
ref: ref
|
|
60
52
|
}));
|
|
61
53
|
};
|
|
54
|
+
return /*#__PURE__*/React.forwardRef(Index);
|
|
62
55
|
});
|
|
63
56
|
|
|
64
57
|
exports.default = HFormConnect;
|
package/lib/Form/config.d.ts
CHANGED
|
@@ -6,21 +6,21 @@ export declare const placeholderConfig: {
|
|
|
6
6
|
declare const _default: {
|
|
7
7
|
select: ({ 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
8
|
inputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
9
|
-
selectInput:
|
|
9
|
+
selectInput: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
buttonInput: import("react").FC<import("../Input/modal").HButtonInputProps>;
|
|
11
|
-
checkboxGroup:
|
|
11
|
+
checkboxGroup: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
12
12
|
checkBox: import("react").FC<import("../CheckboxGroup/modal").HCheckboxProps>;
|
|
13
13
|
radioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("../RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
14
14
|
switch: import("react").FC<import("../Switch").HSwitchProps>;
|
|
15
15
|
datePicker: ({ value, onChange, showTime, format, ...props }: import("../TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
16
16
|
rangePicker: {
|
|
17
|
-
Component:
|
|
17
|
+
Component: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
18
18
|
placeholder: ({ label }: import("./modal").HItemProps) => string[];
|
|
19
19
|
requiredErrMsg: ({ label }: import("./modal").HItemProps) => string;
|
|
20
20
|
};
|
|
21
21
|
timePicker: ({ value, format, onChange, ...props }: import("../TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
22
22
|
input: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
23
|
-
upload: import("react").ForwardRefExoticComponent<import("
|
|
23
|
+
upload: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
24
24
|
urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
25
25
|
submit: ({ text, type, form, loading, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
26
|
formConfigProvider: import("react").FC<import("./modal").IFormConfigContextProps>;
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { IUpLoadProps } from "@/components/Upload/modal";
|
|
|
12
12
|
import type { SelectProps } from "antd";
|
|
13
13
|
import type { RangePickerProps } from "antd/es/date-picker";
|
|
14
14
|
import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRangePickerValueMapModal } from "../modal";
|
|
15
|
+
import type { ForwardedRef } from "react";
|
|
15
16
|
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => void;
|
|
16
17
|
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps;
|
|
17
18
|
export interface HoverModal {
|
|
@@ -42,6 +43,8 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
|
|
|
42
43
|
}
|
|
43
44
|
export interface HFormItemProps extends HItemProps {
|
|
44
45
|
required?: boolean;
|
|
46
|
+
value?: any;
|
|
47
|
+
onChange?: (val: any, item: any) => void;
|
|
45
48
|
}
|
|
46
49
|
export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
|
|
47
50
|
render: (form: HFormInstance) => React.ReactNode;
|
|
@@ -91,8 +94,11 @@ export interface addFormatItemModal {
|
|
|
91
94
|
inputValue: addValueFormat;
|
|
92
95
|
outputValue: addValueFormat;
|
|
93
96
|
}
|
|
94
|
-
export interface ConnectResultProps {
|
|
97
|
+
export interface ConnectResultProps extends HFormItemProps {
|
|
95
98
|
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
96
99
|
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
100
|
+
ref?: ForwardedRef<any>;
|
|
101
|
+
value?: any;
|
|
102
|
+
onChange?: (value: any, item?: any) => void;
|
|
97
103
|
}
|
|
98
104
|
export {};
|
|
@@ -5,5 +5,5 @@ export declare enum SelectInputType {
|
|
|
5
5
|
select = 1
|
|
6
6
|
}
|
|
7
7
|
export declare const Index: ({ selectProps, value, onChange, valueName, addFormat, addDispatchListener, ...props }: HSelectInputProps) => JSX.Element;
|
|
8
|
-
declare const _default:
|
|
8
|
+
declare const _default: import("react").ForwardRefExoticComponent<import("@/components/Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
9
9
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { HItemProps } from "../Form/modal";
|
|
3
3
|
declare const _default: {
|
|
4
|
-
Component:
|
|
4
|
+
Component: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
5
5
|
placeholder: ({ label }: HItemProps) => string[];
|
|
6
6
|
requiredErrMsg: ({ label }: HItemProps) => string;
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IUrlUploadProps } from "../modal";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const Index: ({ placeholder, value, onChange, mediaType, ...props }: IUrlUploadProps) => JSX.Element;
|
|
4
|
+
export default Index;
|
|
@@ -16,7 +16,7 @@ var index = require('../index.js');
|
|
|
16
16
|
var TypeEle = require('../MediaTypeEle/TypeEle.js');
|
|
17
17
|
|
|
18
18
|
var _excluded = ["placeholder", "value", "onChange", "mediaType"];
|
|
19
|
-
var
|
|
19
|
+
var Index = function Index(_ref) {
|
|
20
20
|
var _ref$placeholder = _ref.placeholder,
|
|
21
21
|
placeholder = _ref$placeholder === void 0 ? "请输入文件地址" : _ref$placeholder,
|
|
22
22
|
_ref$value = _ref.value,
|
|
@@ -116,7 +116,7 @@ var HUrlUpload = (function (_ref) {
|
|
|
116
116
|
onReady: onReady,
|
|
117
117
|
onError: onError
|
|
118
118
|
})));
|
|
119
|
-
}
|
|
119
|
+
};
|
|
120
120
|
|
|
121
|
-
exports.default =
|
|
121
|
+
exports.default = Index;
|
|
122
122
|
// powered by h
|
package/lib/Upload/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
declare const _default: React.ForwardRefExoticComponent<IUpLoadProps & React.RefAttributes<IUploadRefModal>>;
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
4
3
|
export default _default;
|
package/lib/Upload/index.js
CHANGED
|
@@ -14,14 +14,16 @@ var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
|
14
14
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
15
15
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
16
16
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
17
|
-
var
|
|
18
|
-
var Btn = require('./Btn.js');
|
|
17
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
19
18
|
var React = require('react');
|
|
19
|
+
var propsMaker = require('./hooks/propsMaker.js');
|
|
20
20
|
var index = require('./Preview/index.js');
|
|
21
21
|
var change = require('./hooks/change.js');
|
|
22
|
-
var
|
|
22
|
+
var antd = require('antd');
|
|
23
|
+
var Btn = require('./Btn.js');
|
|
24
|
+
var HFormConnect = require('../Form/HFormConnect.js');
|
|
23
25
|
|
|
24
|
-
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize"];
|
|
26
|
+
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat"];
|
|
25
27
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
28
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
29
|
var Index = function Index(_ref, ref) {
|
|
@@ -38,6 +40,7 @@ var Index = function Index(_ref, ref) {
|
|
|
38
40
|
onPreview = _ref.onPreview,
|
|
39
41
|
request = _ref.request,
|
|
40
42
|
maxSize = _ref.maxSize,
|
|
43
|
+
addFormat = _ref.addFormat,
|
|
41
44
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
42
45
|
var matchProps = propsMaker.useProps({
|
|
43
46
|
request: request,
|
|
@@ -80,6 +83,37 @@ var Index = function Index(_ref, ref) {
|
|
|
80
83
|
var maxNum = maxCount === 1 ? maxCount : Number.MAX_VALUE;
|
|
81
84
|
var visible = previewModal.visible,
|
|
82
85
|
previewFile = previewModal.file;
|
|
86
|
+
addFormat === null || addFormat === void 0 ? void 0 : addFormat({
|
|
87
|
+
"float": {
|
|
88
|
+
inputValue: function inputValue(item, initValue) {
|
|
89
|
+
var _item$name = item.name,
|
|
90
|
+
name = _item$name === void 0 ? "" : _item$name;
|
|
91
|
+
var initFileList = initValue[name] || [];
|
|
92
|
+
var fileList = _mapInstanceProperty(initFileList).call(initFileList, function (url, index) {
|
|
93
|
+
return {
|
|
94
|
+
name: url,
|
|
95
|
+
response: {
|
|
96
|
+
url: url
|
|
97
|
+
},
|
|
98
|
+
status: "done",
|
|
99
|
+
uid: "init-".concat(index),
|
|
100
|
+
thumbUrl: url
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
return _defineProperty({}, name, fileList);
|
|
104
|
+
},
|
|
105
|
+
outputValue: function outputValue(item, _outputValue) {
|
|
106
|
+
var _item$name2 = item.name,
|
|
107
|
+
valueName = _item$name2 === void 0 ? "" : _item$name2;
|
|
108
|
+
var _outputValue$valueNam = _outputValue[valueName],
|
|
109
|
+
itemVal = _outputValue$valueNam === void 0 ? [] : _outputValue$valueNam;
|
|
110
|
+
var urls = _mapInstanceProperty(itemVal).call(itemVal, function (fileItem) {
|
|
111
|
+
return fileItem.response.url;
|
|
112
|
+
});
|
|
113
|
+
return _defineProperty({}, valueName, urls);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
83
117
|
return /*#__PURE__*/React.createElement("div", {
|
|
84
118
|
style: contentStyle
|
|
85
119
|
}, /*#__PURE__*/React.createElement(antd.Upload, _extends({
|
|
@@ -103,7 +137,7 @@ var Index = function Index(_ref, ref) {
|
|
|
103
137
|
}
|
|
104
138
|
}));
|
|
105
139
|
};
|
|
106
|
-
var HUpload = /*#__PURE__*/React.forwardRef(Index);
|
|
140
|
+
var HUpload = HFormConnect.default( /*#__PURE__*/React.forwardRef(Index));
|
|
107
141
|
|
|
108
142
|
exports.default = HUpload;
|
|
109
143
|
// powered by h
|
package/lib/Upload/modal.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { UploadFile } from "antd/es/upload/interface";
|
|
|
3
3
|
import type { BeforeUploadFileType, RcFile } from "rc-upload/lib/interface";
|
|
4
4
|
import type { UploadChangeParam } from "antd/lib/upload/interface";
|
|
5
5
|
import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
6
|
+
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
6
7
|
export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
7
8
|
exFiles?: string[];
|
|
8
9
|
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
@@ -13,6 +14,7 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
13
14
|
value?: UploadFile[];
|
|
14
15
|
maxRowNum?: number;
|
|
15
16
|
maxSize?: number;
|
|
17
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
16
18
|
}
|
|
17
19
|
export interface IMediaTypeEleProps {
|
|
18
20
|
file?: UploadFile;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
import "./styles/index.less";
|
|
3
3
|
export { default as HForm } from "./Form";
|
|
4
4
|
export { default as useHForm } from "./Form/hooks/useHForm";
|
|
5
|
-
export {
|
|
5
|
+
export { useHDialogForm } from "./DialogForm/hooks";
|
|
6
6
|
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;
|
|
7
7
|
export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
8
|
-
export declare const HSelectInput:
|
|
9
|
-
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./
|
|
8
|
+
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
9
|
+
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
11
11
|
export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
|
|
12
12
|
export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
|
|
13
13
|
export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
|
|
14
|
-
export declare const HCheckboxGroup:
|
|
14
|
+
export declare const HCheckboxGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
15
15
|
export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
16
|
-
export declare const HRangePicker:
|
|
16
|
+
export declare const HRangePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
17
17
|
export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
18
18
|
export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
19
19
|
export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
20
20
|
export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
|
|
21
21
|
export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
|
|
22
22
|
export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
23
|
-
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose,
|
|
23
|
+
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
|
24
|
+
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
package/lib/index.js
CHANGED
|
@@ -4,8 +4,9 @@ var config = require('./Form/config.js');
|
|
|
4
4
|
var index$1 = require('./PageHandler/index.js');
|
|
5
5
|
var index = require('./Form/index.js');
|
|
6
6
|
var useHForm = require('./Form/hooks/useHForm.js');
|
|
7
|
-
var hooks = require('./
|
|
8
|
-
var
|
|
7
|
+
var hooks = require('./DialogForm/hooks.js');
|
|
8
|
+
var ModalForm = require('./DialogForm/ModalForm.js');
|
|
9
|
+
var index$2 = require('./DialogForm/DrawerForm/index.js');
|
|
9
10
|
|
|
10
11
|
var HSelect = config.default.select;
|
|
11
12
|
var HInput = config.default.input;
|
|
@@ -24,15 +25,17 @@ var HInputNumber = config.default.inputNumber;
|
|
|
24
25
|
var HPageHandler = index$1.default;
|
|
25
26
|
var HFormConfigProvider = config.default.formConfigProvider;
|
|
26
27
|
var HTextArea = config.default.textArea;
|
|
27
|
-
var HModalForm =
|
|
28
|
+
var HModalForm = ModalForm.default;
|
|
29
|
+
var HDrawerForm = index$2.default;
|
|
28
30
|
|
|
29
31
|
exports.HForm = index.default;
|
|
30
32
|
exports.useHForm = useHForm.default;
|
|
31
|
-
exports.
|
|
33
|
+
exports.useHDialogForm = hooks.useHDialogForm;
|
|
32
34
|
exports.HButtonInput = HButtonInput;
|
|
33
35
|
exports.HCheckBox = HCheckBox;
|
|
34
36
|
exports.HCheckboxGroup = HCheckboxGroup;
|
|
35
37
|
exports.HDatePicker = HDatePicker;
|
|
38
|
+
exports.HDrawerForm = HDrawerForm;
|
|
36
39
|
exports.HFormConfigProvider = HFormConfigProvider;
|
|
37
40
|
exports.HInput = HInput;
|
|
38
41
|
exports.HInputNumber = HInputNumber;
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Row, Space, Button } from "antd";
|
|
2
|
+
import type { DialogFormProps } from "@/components/DialogForm/modal";
|
|
3
|
+
|
|
4
|
+
export default ({
|
|
5
|
+
onCancel,
|
|
6
|
+
onOk,
|
|
7
|
+
confirmLoading,
|
|
8
|
+
}: Omit<DialogFormProps, "configData">) => {
|
|
9
|
+
return (
|
|
10
|
+
<Row justify={"end"}>
|
|
11
|
+
<Space size={"middle"}>
|
|
12
|
+
<Button onClick={onCancel}>关闭</Button>
|
|
13
|
+
<Button type={"primary"} onClick={onOk} loading={confirmLoading}>
|
|
14
|
+
确定
|
|
15
|
+
</Button>
|
|
16
|
+
</Space>
|
|
17
|
+
</Row>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ModalProps} from "antd";
|
|
2
|
+
import { Row } from "antd";
|
|
3
|
+
import { CloseOutlined } from "@ant-design/icons";
|
|
4
|
+
|
|
5
|
+
export default ({ title, closable, onCancel }: ModalProps) => {
|
|
6
|
+
return (
|
|
7
|
+
<Row justify={"space-between"}>
|
|
8
|
+
<div>{title}</div>
|
|
9
|
+
{closable && <CloseOutlined onClick={onCancel} />}
|
|
10
|
+
</Row>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Drawer } from "antd";
|
|
2
|
+
import type { DialogFormProps } from "@/components/DialogForm/modal";
|
|
3
|
+
import { useCurrentForm, useModifyProps, useSub } from "../hooks";
|
|
4
|
+
import HForm from "../../Form";
|
|
5
|
+
import Title from "./Title";
|
|
6
|
+
import Footer from "./Footer";
|
|
7
|
+
export default ({
|
|
8
|
+
visible,
|
|
9
|
+
title,
|
|
10
|
+
onCancel,
|
|
11
|
+
configData,
|
|
12
|
+
infoRequest,
|
|
13
|
+
request,
|
|
14
|
+
afterClose,
|
|
15
|
+
dialogForm,
|
|
16
|
+
closable = true,
|
|
17
|
+
initialValues = {},
|
|
18
|
+
labelWidth,
|
|
19
|
+
onOk,
|
|
20
|
+
onFinish,
|
|
21
|
+
size,
|
|
22
|
+
form,
|
|
23
|
+
footer,
|
|
24
|
+
...props
|
|
25
|
+
}: DialogFormProps) => {
|
|
26
|
+
const currentForm = useCurrentForm(dialogForm);
|
|
27
|
+
const {
|
|
28
|
+
modalVisible,
|
|
29
|
+
modalFormData,
|
|
30
|
+
setModalVisible,
|
|
31
|
+
initValue,
|
|
32
|
+
onAfterClose,
|
|
33
|
+
} = useModifyProps({
|
|
34
|
+
configData,
|
|
35
|
+
visible,
|
|
36
|
+
initialValues,
|
|
37
|
+
dialogForm: currentForm,
|
|
38
|
+
});
|
|
39
|
+
const cancel = (e) => {
|
|
40
|
+
onAfterClose();
|
|
41
|
+
if (onCancel) {
|
|
42
|
+
return onCancel?.(e);
|
|
43
|
+
}
|
|
44
|
+
setModalVisible(false);
|
|
45
|
+
};
|
|
46
|
+
const { loading, run } = useSub({ request, onFinish });
|
|
47
|
+
const footerComponent = () => {
|
|
48
|
+
if (footer === null) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return (
|
|
52
|
+
footer || (
|
|
53
|
+
<Footer
|
|
54
|
+
onCancel={cancel}
|
|
55
|
+
onOk={currentForm.submit}
|
|
56
|
+
confirmLoading={loading}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
return (
|
|
62
|
+
<Drawer
|
|
63
|
+
visible={modalVisible}
|
|
64
|
+
title={<Title title={title} closable={closable} onCancel={cancel} />}
|
|
65
|
+
{...props}
|
|
66
|
+
onClose={cancel}
|
|
67
|
+
closable={false}
|
|
68
|
+
destroyOnClose={true}
|
|
69
|
+
footer={footerComponent()}
|
|
70
|
+
>
|
|
71
|
+
<HForm
|
|
72
|
+
configData={modalFormData}
|
|
73
|
+
initialValues={initValue}
|
|
74
|
+
{...props}
|
|
75
|
+
form={currentForm}
|
|
76
|
+
onFinish={async (values) => {
|
|
77
|
+
await run(values);
|
|
78
|
+
setModalVisible(false);
|
|
79
|
+
}}
|
|
80
|
+
infoRequest={infoRequest}
|
|
81
|
+
labelWidth={labelWidth}
|
|
82
|
+
/>
|
|
83
|
+
</Drawer>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Modal } from "antd";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DialogFormProps } from "@/components/DialogForm/modal";
|
|
3
3
|
import HForm from "../Form";
|
|
4
|
-
import { useCurrentForm, useModifyProps } from "./hooks";
|
|
4
|
+
import { useCurrentForm, useModifyProps, useSub } from "./hooks";
|
|
5
5
|
export default ({
|
|
6
6
|
visible,
|
|
7
7
|
title,
|
|
@@ -10,17 +10,18 @@ export default ({
|
|
|
10
10
|
infoRequest,
|
|
11
11
|
request,
|
|
12
12
|
afterClose,
|
|
13
|
-
|
|
13
|
+
dialogForm,
|
|
14
14
|
initialValues = {},
|
|
15
|
+
onFinish,
|
|
15
16
|
...props
|
|
16
|
-
}:
|
|
17
|
-
const currentForm = useCurrentForm(
|
|
17
|
+
}: DialogFormProps) => {
|
|
18
|
+
const currentForm = useCurrentForm(dialogForm);
|
|
18
19
|
const { modalVisible, modalFormData, setModalVisible, initValue } =
|
|
19
20
|
useModifyProps({
|
|
20
21
|
configData,
|
|
21
22
|
visible,
|
|
22
23
|
initialValues,
|
|
23
|
-
|
|
24
|
+
dialogForm: currentForm,
|
|
24
25
|
});
|
|
25
26
|
const cancel = (e) => {
|
|
26
27
|
if (onCancel) {
|
|
@@ -28,21 +29,28 @@ export default ({
|
|
|
28
29
|
}
|
|
29
30
|
setModalVisible(false);
|
|
30
31
|
};
|
|
32
|
+
const { loading, run } = useSub({ request, onFinish });
|
|
31
33
|
return (
|
|
32
34
|
<Modal
|
|
33
35
|
title={title}
|
|
34
36
|
visible={modalVisible}
|
|
35
37
|
onCancel={cancel}
|
|
38
|
+
confirmLoading={loading}
|
|
36
39
|
afterClose={() => {
|
|
37
40
|
currentForm.resetFields();
|
|
38
41
|
afterClose?.();
|
|
39
42
|
}}
|
|
40
43
|
{...props}
|
|
44
|
+
onOk={currentForm.submit}
|
|
41
45
|
destroyOnClose={true}
|
|
42
46
|
>
|
|
43
47
|
<HForm
|
|
44
48
|
configData={modalFormData}
|
|
45
49
|
initialValues={initValue}
|
|
50
|
+
onFinish={async (values) => {
|
|
51
|
+
await run(values);
|
|
52
|
+
setModalVisible(false);
|
|
53
|
+
}}
|
|
46
54
|
{...props}
|
|
47
55
|
form={currentForm}
|
|
48
56
|
infoRequest={infoRequest}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from "react";
|
|
2
2
|
import useHForm from "../Form/hooks/useHForm";
|
|
3
3
|
import type {
|
|
4
|
-
|
|
4
|
+
HDialogFormInstance,
|
|
5
5
|
ModifyPropsModal,
|
|
6
|
-
} from "@/components/
|
|
6
|
+
} from "@/components/DialogForm/modal";
|
|
7
|
+
import type { DialogFormProps } from "@/components/DialogForm/modal";
|
|
8
|
+
import { useRequest } from "ahooks";
|
|
7
9
|
|
|
8
10
|
export const useModifyProps = ({
|
|
9
11
|
visible,
|
|
10
12
|
configData,
|
|
11
13
|
initialValues,
|
|
12
|
-
|
|
14
|
+
dialogForm,
|
|
15
|
+
afterClose,
|
|
13
16
|
}: ModifyPropsModal) => {
|
|
14
17
|
const [modalVisible, setModalVisible] = useState(visible);
|
|
15
18
|
const [modalFormData, setModalFormData] = useState(configData);
|
|
16
19
|
const [initValue, setInitValue] = useState(initialValues);
|
|
20
|
+
const onAfterClose = () => {
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
dialogForm.resetFields();
|
|
23
|
+
afterClose?.();
|
|
24
|
+
}, 0);
|
|
25
|
+
};
|
|
17
26
|
useEffect(() => {
|
|
18
27
|
setModalVisible(visible);
|
|
19
28
|
}, [visible]);
|
|
@@ -21,7 +30,7 @@ export const useModifyProps = ({
|
|
|
21
30
|
setModalFormData(configData);
|
|
22
31
|
}, [configData]);
|
|
23
32
|
useEffect(() => {
|
|
24
|
-
|
|
33
|
+
dialogForm.show = ({
|
|
25
34
|
configData: changeConfigData,
|
|
26
35
|
initialValues: changeInitialValues,
|
|
27
36
|
}) => {
|
|
@@ -31,10 +40,11 @@ export const useModifyProps = ({
|
|
|
31
40
|
setInitValue(changeInitialValues);
|
|
32
41
|
setModalVisible(true);
|
|
33
42
|
};
|
|
34
|
-
|
|
43
|
+
dialogForm.hide = () => {
|
|
35
44
|
setModalVisible(false);
|
|
45
|
+
onAfterClose();
|
|
36
46
|
};
|
|
37
|
-
}, []);
|
|
47
|
+
}, [afterClose]);
|
|
38
48
|
return {
|
|
39
49
|
modalFormData,
|
|
40
50
|
modalVisible,
|
|
@@ -42,11 +52,12 @@ export const useModifyProps = ({
|
|
|
42
52
|
setModalFormData,
|
|
43
53
|
initValue,
|
|
44
54
|
setInitValue,
|
|
55
|
+
onAfterClose,
|
|
45
56
|
};
|
|
46
57
|
};
|
|
47
|
-
export const
|
|
58
|
+
export const useHDialogForm = () => {
|
|
48
59
|
const hForm = useHForm();
|
|
49
|
-
return useMemo<
|
|
60
|
+
return useMemo<HDialogFormInstance>(() => {
|
|
50
61
|
return {
|
|
51
62
|
...hForm,
|
|
52
63
|
show: (params) => {},
|
|
@@ -55,7 +66,21 @@ export const useHModalForm = () => {
|
|
|
55
66
|
}, []);
|
|
56
67
|
};
|
|
57
68
|
|
|
58
|
-
export const useCurrentForm = (
|
|
59
|
-
const defaultHModalForm =
|
|
60
|
-
return
|
|
69
|
+
export const useCurrentForm = (hDialogForm?: HDialogFormInstance) => {
|
|
70
|
+
const defaultHModalForm = useHDialogForm();
|
|
71
|
+
return hDialogForm || defaultHModalForm;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const useSub = ({ request, onFinish }: Partial<DialogFormProps>) => {
|
|
75
|
+
return useRequest(
|
|
76
|
+
async (values) => {
|
|
77
|
+
if (onFinish) {
|
|
78
|
+
return onFinish(values);
|
|
79
|
+
}
|
|
80
|
+
if (request) {
|
|
81
|
+
return request(values);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{ manual: true }
|
|
85
|
+
);
|
|
61
86
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HFormProps } from "@/components/Form/modal";
|
|
2
2
|
import type { ModalProps } from "antd";
|
|
3
3
|
import type { HFormInstance, HItemProps } from "@/components/Form/modal";
|
|
4
|
+
import type { PromiseFnResult } from "@/components/modal";
|
|
4
5
|
|
|
5
6
|
type RootProps = HFormProps & ModalProps;
|
|
6
7
|
|
|
@@ -8,7 +9,8 @@ export interface ModifyPropsModal {
|
|
|
8
9
|
configData: HItemProps[];
|
|
9
10
|
visible?: boolean;
|
|
10
11
|
initialValues?: Record<string, any>;
|
|
11
|
-
|
|
12
|
+
dialogForm: HDialogFormInstance;
|
|
13
|
+
afterClose?: VoidFunction;
|
|
12
14
|
}
|
|
13
15
|
export interface ShowParamsModal {
|
|
14
16
|
configData?: HItemProps[];
|
|
@@ -16,10 +18,11 @@ export interface ShowParamsModal {
|
|
|
16
18
|
initialValues?: Record<string, any>;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export interface
|
|
21
|
+
export interface HDialogFormInstance extends HFormInstance {
|
|
20
22
|
show: (data: ShowParamsModal) => void;
|
|
21
23
|
hide: VoidFunction;
|
|
22
24
|
}
|
|
23
|
-
export interface
|
|
24
|
-
|
|
25
|
+
export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
|
|
26
|
+
dialogForm?: HDialogFormInstance;
|
|
27
|
+
onFinish?: PromiseFnResult;
|
|
25
28
|
}
|