@hw-component/form 0.0.1-beta-v5 → 0.0.1-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/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} +36 -6
- package/es/{ModalForm → DiaLogForm}/hooks.d.ts +5 -2
- package/es/{ModalForm → DiaLogForm}/hooks.js +52 -7
- package/es/{ModalForm → DiaLogForm}/modal.d.ts +4 -1
- package/es/Form/HFormConnect.d.ts +1 -2
- package/es/Form/HFormConnect.js +8 -15
- package/es/Form/config.d.ts +5 -4
- package/es/Form/config.js +6 -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/TextArea/index.js +21 -0
- 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 +8 -6
- package/es/index.js +6 -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} +35 -5
- package/lib/{ModalForm → DiaLogForm}/hooks.d.ts +5 -2
- package/lib/{ModalForm → DiaLogForm}/hooks.js +52 -6
- package/lib/{ModalForm → DiaLogForm}/modal.d.ts +4 -1
- package/lib/Form/HFormConnect.d.ts +1 -2
- package/lib/Form/HFormConnect.js +8 -15
- package/lib/Form/config.d.ts +5 -4
- package/lib/Form/config.js +3 -1
- 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/TextArea/index.js +24 -0
- 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 +8 -6
- package/lib/index.js +8 -3
- 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} +10 -2
- package/src/components/{ModalForm → DiaLogForm}/hooks.ts +27 -2
- package/src/components/{ModalForm → DiaLogForm}/modal.ts +4 -1
- package/src/components/Form/HFormConnect.tsx +21 -7
- package/src/components/Form/config.ts +2 -1
- 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/config.ts +1 -1
- package/src/components/index.tsx +5 -3
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +3 -0
- package/src/routes.tsx +7 -0
- package/es/ModalForm/index.d.ts +0 -4
- package/lib/ModalForm/index.d.ts +0 -4
package/lib/Form/config.d.ts
CHANGED
|
@@ -6,23 +6,24 @@ 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<unknown>>;
|
|
10
10
|
buttonInput: import("react").FC<import("../Input/modal").HButtonInputProps>;
|
|
11
|
-
checkboxGroup:
|
|
11
|
+
checkboxGroup: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<unknown>>;
|
|
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<unknown>>;
|
|
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<unknown>>;
|
|
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>;
|
|
27
|
+
textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
27
28
|
};
|
|
28
29
|
export default _default;
|
package/lib/Form/config.js
CHANGED
|
@@ -18,6 +18,7 @@ var index$7 = require('../Upload/index.js');
|
|
|
18
18
|
var index$8 = require('../Upload/UrlUpload/index.js');
|
|
19
19
|
var index$9 = require('../Submit/index.js');
|
|
20
20
|
var FormConfigProvider = require('./Context/FormConfigProvider.js');
|
|
21
|
+
var index$a = require('../TextArea/index.js');
|
|
21
22
|
|
|
22
23
|
var placeholderConfig = {
|
|
23
24
|
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
@@ -39,7 +40,8 @@ var FormConfig = {
|
|
|
39
40
|
upload: index$7.default,
|
|
40
41
|
urlUpload: index$8.default,
|
|
41
42
|
submit: index$9.default,
|
|
42
|
-
formConfigProvider: FormConfigProvider.default
|
|
43
|
+
formConfigProvider: FormConfigProvider.default,
|
|
44
|
+
textArea: index$a.default
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
exports.default = FormConfig;
|
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
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
7
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
|
+
var antd = require('antd');
|
|
9
|
+
|
|
10
|
+
var _excluded = ["autoSize"];
|
|
11
|
+
var TextArea = (function (_ref) {
|
|
12
|
+
var _ref$autoSize = _ref.autoSize,
|
|
13
|
+
autoSize = _ref$autoSize === void 0 ? {
|
|
14
|
+
minRows: 4,
|
|
15
|
+
maxRows: 4
|
|
16
|
+
} : _ref$autoSize,
|
|
17
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
+
return /*#__PURE__*/React.createElement(antd.Input.TextArea, _extends({
|
|
19
|
+
autoSize: autoSize
|
|
20
|
+
}, props));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exports.default = TextArea;
|
|
24
|
+
// powered by h
|
|
@@ -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,21 +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 { useHModalForm } from "./
|
|
5
|
+
export { useHModalForm } 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<unknown>>;
|
|
9
|
+
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<unknown>>;
|
|
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<unknown>>;
|
|
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<unknown>>;
|
|
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
|
-
export declare const
|
|
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, modalForm, initialValues, onFinish, ...props }: import("./DiaLogForm/modal").ModalFormProps) => JSX.Element;
|
|
24
|
+
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, closable, initialValues, labelWidth, onOk, onFinish, ...props }: import("./DiaLogForm/modal").ModalFormProps) => 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;
|
|
@@ -23,7 +24,9 @@ var HTimePicker = config.default.timePicker;
|
|
|
23
24
|
var HInputNumber = config.default.inputNumber;
|
|
24
25
|
var HPageHandler = index$1.default;
|
|
25
26
|
var HFormConfigProvider = config.default.formConfigProvider;
|
|
26
|
-
var
|
|
27
|
+
var HTextArea = config.default.textArea;
|
|
28
|
+
var HModalForm = ModalForm.default;
|
|
29
|
+
var HDrawerForm = index$2.default;
|
|
27
30
|
|
|
28
31
|
exports.HForm = index.default;
|
|
29
32
|
exports.useHForm = useHForm.default;
|
|
@@ -32,6 +35,7 @@ exports.HButtonInput = HButtonInput;
|
|
|
32
35
|
exports.HCheckBox = HCheckBox;
|
|
33
36
|
exports.HCheckboxGroup = HCheckboxGroup;
|
|
34
37
|
exports.HDatePicker = HDatePicker;
|
|
38
|
+
exports.HDrawerForm = HDrawerForm;
|
|
35
39
|
exports.HFormConfigProvider = HFormConfigProvider;
|
|
36
40
|
exports.HInput = HInput;
|
|
37
41
|
exports.HInputNumber = HInputNumber;
|
|
@@ -42,6 +46,7 @@ exports.HRangePicker = HRangePicker;
|
|
|
42
46
|
exports.HSelect = HSelect;
|
|
43
47
|
exports.HSelectInput = HSelectInput;
|
|
44
48
|
exports.HSwitch = HSwitch;
|
|
49
|
+
exports.HTextArea = HTextArea;
|
|
45
50
|
exports.HTimePicker = HTimePicker;
|
|
46
51
|
exports.HUpload = HUpload;
|
|
47
52
|
exports.HUrlUpload = HUrlUpload;
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Row, Space, Button } from "antd";
|
|
2
|
+
import type { ModalFormProps } from "@/components/DiaLogForm/modal";
|
|
3
|
+
|
|
4
|
+
export default ({
|
|
5
|
+
onCancel,
|
|
6
|
+
onOk,
|
|
7
|
+
confirmLoading,
|
|
8
|
+
}: Omit<ModalFormProps, "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 { ModalFormProps } 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
|
+
modalForm,
|
|
16
|
+
closable = true,
|
|
17
|
+
initialValues = {},
|
|
18
|
+
labelWidth,
|
|
19
|
+
onOk,
|
|
20
|
+
onFinish,
|
|
21
|
+
size,
|
|
22
|
+
form,
|
|
23
|
+
footer,
|
|
24
|
+
...props
|
|
25
|
+
}: ModalFormProps) => {
|
|
26
|
+
const currentForm = useCurrentForm(modalForm);
|
|
27
|
+
const {
|
|
28
|
+
modalVisible,
|
|
29
|
+
modalFormData,
|
|
30
|
+
setModalVisible,
|
|
31
|
+
initValue,
|
|
32
|
+
onAfterClose,
|
|
33
|
+
} = useModifyProps({
|
|
34
|
+
configData,
|
|
35
|
+
visible,
|
|
36
|
+
initialValues,
|
|
37
|
+
modalForm: 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 { ModalFormProps } from "@/components/
|
|
2
|
+
import type { ModalFormProps } 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,
|
|
@@ -12,6 +12,7 @@ export default ({
|
|
|
12
12
|
afterClose,
|
|
13
13
|
modalForm,
|
|
14
14
|
initialValues = {},
|
|
15
|
+
onFinish,
|
|
15
16
|
...props
|
|
16
17
|
}: ModalFormProps) => {
|
|
17
18
|
const currentForm = useCurrentForm(modalForm);
|
|
@@ -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}
|
|
@@ -3,17 +3,26 @@ import useHForm from "../Form/hooks/useHForm";
|
|
|
3
3
|
import type {
|
|
4
4
|
HModalFormInstance,
|
|
5
5
|
ModifyPropsModal,
|
|
6
|
-
} from "@/components/
|
|
6
|
+
} from "@/components/DiaLogForm/modal";
|
|
7
|
+
import type { ModalFormProps } 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
|
modalForm,
|
|
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
|
+
modalForm.resetFields();
|
|
23
|
+
afterClose?.();
|
|
24
|
+
}, 0);
|
|
25
|
+
};
|
|
17
26
|
useEffect(() => {
|
|
18
27
|
setModalVisible(visible);
|
|
19
28
|
}, [visible]);
|
|
@@ -33,8 +42,9 @@ export const useModifyProps = ({
|
|
|
33
42
|
};
|
|
34
43
|
modalForm.hide = () => {
|
|
35
44
|
setModalVisible(false);
|
|
45
|
+
onAfterClose();
|
|
36
46
|
};
|
|
37
|
-
}, []);
|
|
47
|
+
}, [afterClose]);
|
|
38
48
|
return {
|
|
39
49
|
modalFormData,
|
|
40
50
|
modalVisible,
|
|
@@ -42,6 +52,7 @@ export const useModifyProps = ({
|
|
|
42
52
|
setModalFormData,
|
|
43
53
|
initValue,
|
|
44
54
|
setInitValue,
|
|
55
|
+
onAfterClose,
|
|
45
56
|
};
|
|
46
57
|
};
|
|
47
58
|
export const useHModalForm = () => {
|
|
@@ -59,3 +70,17 @@ export const useCurrentForm = (hModalForm?: HModalFormInstance) => {
|
|
|
59
70
|
const defaultHModalForm = useHModalForm();
|
|
60
71
|
return hModalForm || defaultHModalForm;
|
|
61
72
|
};
|
|
73
|
+
|
|
74
|
+
export const useSub = ({ request, onFinish }: Partial<ModalFormProps>) => {
|
|
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
|
+
);
|
|
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
|
|
|
@@ -9,6 +10,7 @@ export interface ModifyPropsModal {
|
|
|
9
10
|
visible?: boolean;
|
|
10
11
|
initialValues?: Record<string, any>;
|
|
11
12
|
modalForm: HModalFormInstance;
|
|
13
|
+
afterClose?: VoidFunction;
|
|
12
14
|
}
|
|
13
15
|
export interface ShowParamsModal {
|
|
14
16
|
configData?: HItemProps[];
|
|
@@ -20,6 +22,7 @@ export interface HModalFormInstance extends HFormInstance {
|
|
|
20
22
|
show: (data: ShowParamsModal) => void;
|
|
21
23
|
hide: VoidFunction;
|
|
22
24
|
}
|
|
23
|
-
export interface ModalFormProps extends RootProps {
|
|
25
|
+
export interface ModalFormProps extends Omit<RootProps, "onFinish"> {
|
|
24
26
|
modalForm?: HModalFormInstance;
|
|
27
|
+
onFinish?: PromiseFnResult;
|
|
25
28
|
}
|
|
@@ -25,11 +25,17 @@ const formatMaker = (
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export default (
|
|
28
|
-
|
|
28
|
+
component:
|
|
29
|
+
| React.FunctionComponent
|
|
30
|
+
| React.ComponentClass
|
|
31
|
+
| React.ForwardRefRenderFunction<any, any>,
|
|
29
32
|
config: ConnectConfigModal = {}
|
|
30
33
|
) => {
|
|
31
34
|
const { format = {} } = config;
|
|
32
|
-
|
|
35
|
+
const Index: React.ForwardRefRenderFunction<any, HFormItemProps> = (
|
|
36
|
+
props: HFormItemProps,
|
|
37
|
+
ref
|
|
38
|
+
) => {
|
|
33
39
|
const { name = "" } = props;
|
|
34
40
|
|
|
35
41
|
const { form, valueType = "float" } = useFormContext();
|
|
@@ -44,10 +50,18 @@ export default (
|
|
|
44
50
|
const addDispatchListener = (key: string, fn: argsFn) => {
|
|
45
51
|
form?.addDispatchListener({ key, name }, fn);
|
|
46
52
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const Component = component as React.ForwardRefRenderFunction<
|
|
54
|
+
any,
|
|
55
|
+
ConnectResultProps
|
|
56
|
+
>;
|
|
57
|
+
return (
|
|
58
|
+
<Component
|
|
59
|
+
{...props}
|
|
60
|
+
addFormat={addFormat}
|
|
61
|
+
addDispatchListener={addDispatchListener}
|
|
62
|
+
ref={ref}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
52
65
|
};
|
|
66
|
+
return React.forwardRef(Index);
|
|
53
67
|
};
|
|
@@ -14,7 +14,7 @@ import HUpload from "../Upload";
|
|
|
14
14
|
import HUrlUpload from "../Upload/UrlUpload";
|
|
15
15
|
import HSubmit from "../Submit";
|
|
16
16
|
import FormConfigProvider from "../Form/Context/FormConfigProvider";
|
|
17
|
-
|
|
17
|
+
import TextArea from "../TextArea";
|
|
18
18
|
export const placeholderConfig = {
|
|
19
19
|
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
20
20
|
selectType: ["select", "datePicker", "timePicker"],
|
|
@@ -37,4 +37,5 @@ export default {
|
|
|
37
37
|
urlUpload: HUrlUpload,
|
|
38
38
|
submit: HSubmit,
|
|
39
39
|
formConfigProvider: FormConfigProvider,
|
|
40
|
+
textArea: TextArea,
|
|
40
41
|
};
|