@hw-component/form 1.9.70 → 1.9.72
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/.eslintcache +1 -1
- package/es/DialogForm/DrawerForm/index.js +40 -32
- package/es/DialogForm/ModalForm.js +40 -32
- package/es/DialogForm/hooks.d.ts +7 -3
- package/es/DialogForm/hooks.js +3 -4
- package/es/DialogForm/modal.d.ts +3 -2
- package/es/Form/Basic.d.ts +1 -1
- package/es/Form/FormItem/index.js +2 -0
- package/es/Form/HFormConnect.d.ts +2 -3
- package/es/Form/HFormConnect.js +2 -32
- package/es/Form/config.d.ts +1 -0
- package/es/Form/config.js +4 -2
- package/es/Form/hooks/index.d.ts +1 -0
- package/es/Form/hooks/useAddFormat.d.ts +8 -0
- package/es/Form/hooks/useAddFormat.js +44 -0
- package/es/Form/modal.d.ts +5 -0
- package/es/RichEditor/hooks.d.ts +15 -0
- package/es/RichEditor/hooks.js +110 -0
- package/es/RichEditor/index.d.ts +4 -0
- package/es/RichEditor/index.js +96 -0
- package/es/RichEditor/modal.d.ts +11 -0
- package/es/config.js +27 -1
- package/es/index.css +22 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/lib/DialogForm/DrawerForm/index.js +40 -32
- package/lib/DialogForm/ModalForm.js +40 -32
- package/lib/DialogForm/hooks.d.ts +7 -3
- package/lib/DialogForm/hooks.js +3 -4
- package/lib/DialogForm/modal.d.ts +3 -2
- package/lib/Form/Basic.d.ts +1 -1
- package/lib/Form/FormItem/index.js +2 -0
- package/lib/Form/HFormConnect.d.ts +2 -3
- package/lib/Form/HFormConnect.js +2 -32
- package/lib/Form/config.d.ts +1 -0
- package/lib/Form/config.js +4 -2
- package/lib/Form/hooks/index.d.ts +1 -0
- package/lib/Form/hooks/useAddFormat.d.ts +8 -0
- package/lib/Form/hooks/useAddFormat.js +48 -0
- package/lib/Form/modal.d.ts +5 -0
- package/lib/RichEditor/hooks.d.ts +15 -0
- package/lib/RichEditor/hooks.js +114 -0
- package/lib/RichEditor/index.d.ts +4 -0
- package/lib/RichEditor/index.js +99 -0
- package/lib/RichEditor/modal.d.ts +11 -0
- package/lib/config.js +27 -1
- package/lib/index.css +22 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/package.json +2 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +18 -10
- package/src/components/DialogForm/ModalForm.tsx +18 -9
- package/src/components/DialogForm/hooks.tsx +12 -10
- package/src/components/DialogForm/modal.ts +4 -3
- package/src/components/Form/Basic.tsx +5 -9
- package/src/components/Form/FormItem/BasicItem.tsx +5 -3
- package/src/components/Form/FormItem/index.tsx +2 -0
- package/src/components/Form/HFormConnect.tsx +3 -39
- package/src/components/Form/config.ts +4 -0
- package/src/components/Form/hooks/index.ts +4 -0
- package/src/components/Form/hooks/useAddFormat.tsx +44 -0
- package/src/components/Form/index.less +4 -3
- package/src/components/Form/modal.ts +9 -3
- package/src/components/InputGroup/index.tsx +2 -2
- package/src/components/RichEditor/hooks.ts +83 -0
- package/src/components/RichEditor/index.less +26 -0
- package/src/components/RichEditor/index.tsx +84 -0
- package/src/components/RichEditor/modal.ts +13 -0
- package/src/components/Upload/hooks/change.ts +4 -5
- package/src/components/config.ts +8 -0
- package/src/components/index.tsx +2 -0
- package/src/components/styles/index.less +1 -0
- package/src/pages/Form/index.tsx +31 -19
- package/src/pages/Input/index.tsx +1 -1
- package/src/pages/ModalForm/index.tsx +1 -0
- package/src/pages/Select/index.tsx +2 -2
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
import BraftEditor from 'braft-editor';
|
|
6
|
+
import 'braft-editor/dist/index.css';
|
|
7
|
+
import { useProps, useFocusClassname, useVC, useUploadFn } from './hooks.js';
|
|
8
|
+
import { useClassName } from '../hooks/index.js';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import HFormConnect from '../Form/HFormConnect.js';
|
|
11
|
+
|
|
12
|
+
var _excluded = ["value", "onChange", "valueType", "fileRequest", "media", "contentStyle", "bordered", "onBlur", "onFocus", "addFormat"];
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
var defaultContentStyle = {
|
|
16
|
+
height: 400
|
|
17
|
+
};
|
|
18
|
+
var Index = function Index(_ref, ref) {
|
|
19
|
+
var value = _ref.value,
|
|
20
|
+
onChange = _ref.onChange,
|
|
21
|
+
valueType = _ref.valueType,
|
|
22
|
+
fileRequest = _ref.fileRequest,
|
|
23
|
+
media = _ref.media,
|
|
24
|
+
_ref$contentStyle = _ref.contentStyle,
|
|
25
|
+
contentStyle = _ref$contentStyle === void 0 ? defaultContentStyle : _ref$contentStyle,
|
|
26
|
+
_ref$bordered = _ref.bordered,
|
|
27
|
+
bordered = _ref$bordered === void 0 ? true : _ref$bordered,
|
|
28
|
+
onBlur = _ref.onBlur,
|
|
29
|
+
onFocus = _ref.onFocus,
|
|
30
|
+
addFormat = _ref.addFormat,
|
|
31
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
var _useProps = useProps({
|
|
33
|
+
fileRequest: fileRequest,
|
|
34
|
+
valueType: valueType
|
|
35
|
+
}),
|
|
36
|
+
fileReq = _useProps.fileRequest,
|
|
37
|
+
vType = _useProps.valueType;
|
|
38
|
+
var _useFocusClassname = useFocusClassname({
|
|
39
|
+
bordered: bordered,
|
|
40
|
+
onBlur: onBlur,
|
|
41
|
+
onFocus: onFocus
|
|
42
|
+
}),
|
|
43
|
+
focusClassname = _useFocusClassname.focusClassname,
|
|
44
|
+
selfFocus = _useFocusClassname.onFocus,
|
|
45
|
+
selfBlur = _useFocusClassname.onBlur;
|
|
46
|
+
var _useVC = useVC({
|
|
47
|
+
value: value,
|
|
48
|
+
onChange: onChange,
|
|
49
|
+
valueType: vType
|
|
50
|
+
}),
|
|
51
|
+
richValue = _useVC.richValue,
|
|
52
|
+
change = _useVC.change;
|
|
53
|
+
var uploadFn = useUploadFn({
|
|
54
|
+
fileRequest: fileReq
|
|
55
|
+
});
|
|
56
|
+
var bodyClassName = useClassName("hw-rich-editor");
|
|
57
|
+
var borderClassName = useClassName("hw-rich-editor-border");
|
|
58
|
+
addFormat === null || addFormat === void 0 || addFormat({
|
|
59
|
+
float: {
|
|
60
|
+
inputValue: function inputValue(item, initValue) {
|
|
61
|
+
var _item$name = item.name,
|
|
62
|
+
name = _item$name === void 0 ? "" : _item$name;
|
|
63
|
+
var keyName = name;
|
|
64
|
+
var itemVal = initValue[keyName];
|
|
65
|
+
var initVal = typeof itemVal === "string" ? BraftEditor.createEditorState(itemVal) : itemVal;
|
|
66
|
+
return _defineProperty({}, keyName, initVal);
|
|
67
|
+
},
|
|
68
|
+
outputValue: function outputValue(item, _outputValue) {
|
|
69
|
+
var _item$name2 = item.name,
|
|
70
|
+
name = _item$name2 === void 0 ? "" : _item$name2;
|
|
71
|
+
var keyName = name;
|
|
72
|
+
var itemVal = _outputValue[keyName];
|
|
73
|
+
var outputVal = typeof itemVal === "string" ? itemVal : itemVal === null || itemVal === void 0 ? void 0 : itemVal.toHTML();
|
|
74
|
+
return _defineProperty({}, keyName, outputVal);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return jsx("div", {
|
|
79
|
+
className: "".concat(bodyClassName, " ").concat(bordered ? borderClassName : "", " ").concat(focusClassname),
|
|
80
|
+
children: jsx(BraftEditor, _objectSpread({
|
|
81
|
+
contentStyle: contentStyle,
|
|
82
|
+
value: richValue,
|
|
83
|
+
onChange: change,
|
|
84
|
+
onFocus: selfFocus,
|
|
85
|
+
ref: ref,
|
|
86
|
+
onBlur: selfBlur,
|
|
87
|
+
media: _objectSpread({
|
|
88
|
+
uploadFn: uploadFn
|
|
89
|
+
}, media)
|
|
90
|
+
}, props))
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
var HRichEditor = HFormConnect(/*#__PURE__*/React.forwardRef(Index));
|
|
94
|
+
|
|
95
|
+
export { HRichEditor as default };
|
|
96
|
+
// powered by hdj
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BraftEditorProps, EditorState } from "braft-editor";
|
|
2
|
+
import { PromiseFnResult } from "../modal";
|
|
3
|
+
import { addFormatItemModal } from "../Form/modal";
|
|
4
|
+
export interface IHRichEditorProps extends Omit<BraftEditorProps, "value" | "onChange"> {
|
|
5
|
+
value?: string | EditorState;
|
|
6
|
+
onChange?: (value: string | EditorState) => void;
|
|
7
|
+
fileRequest?: PromiseFnResult;
|
|
8
|
+
valueType?: "html" | "state";
|
|
9
|
+
bordered?: boolean;
|
|
10
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
11
|
+
}
|
package/es/config.js
CHANGED
|
@@ -69,7 +69,33 @@ var baseConfig = {
|
|
|
69
69
|
},
|
|
70
70
|
defaultComponent: {},
|
|
71
71
|
formItemStyle: {},
|
|
72
|
-
itemProps: {}
|
|
72
|
+
itemProps: {},
|
|
73
|
+
richEditorProps: {
|
|
74
|
+
fileRequest: function () {
|
|
75
|
+
var _fileRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
|
|
76
|
+
var url;
|
|
77
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
78
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
_context2.next = 2;
|
|
81
|
+
return fileToBase64(file);
|
|
82
|
+
case 2:
|
|
83
|
+
url = _context2.sent;
|
|
84
|
+
return _context2.abrupt("return", {
|
|
85
|
+
url: url
|
|
86
|
+
});
|
|
87
|
+
case 4:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context2.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee2);
|
|
92
|
+
}));
|
|
93
|
+
function fileRequest(_x2) {
|
|
94
|
+
return _fileRequest.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
return fileRequest;
|
|
97
|
+
}()
|
|
98
|
+
}
|
|
73
99
|
};
|
|
74
100
|
|
|
75
101
|
export { baseConfig };
|
package/es/index.css
CHANGED
|
@@ -290,3 +290,25 @@
|
|
|
290
290
|
.ant-form-item-has-error .ant-hw-input-group-body {
|
|
291
291
|
border-color: #ff4d4f !important;
|
|
292
292
|
}
|
|
293
|
+
.ant-hw-rich-editor {
|
|
294
|
+
box-sizing: border-box;
|
|
295
|
+
width: 100%;
|
|
296
|
+
}
|
|
297
|
+
.ant-hw-rich-editor .bf-container .public-DraftEditorPlaceholder-root {
|
|
298
|
+
color: #bfbfbf;
|
|
299
|
+
font-size: 14px;
|
|
300
|
+
}
|
|
301
|
+
.ant-hw-rich-editor-border {
|
|
302
|
+
border: 1px solid #d9d9d9;
|
|
303
|
+
border-radius: 2px;
|
|
304
|
+
}
|
|
305
|
+
.ant-hw-rich-editor-border:hover {
|
|
306
|
+
border-color: #40a9ff;
|
|
307
|
+
}
|
|
308
|
+
.ant-hw-rich-editor-focus {
|
|
309
|
+
border-color: #40a9ff;
|
|
310
|
+
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
311
|
+
}
|
|
312
|
+
.ant-form-item-has-error .ant-hw-rich-editor-border {
|
|
313
|
+
border-color: #ff4d4f !important;
|
|
314
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { default as HBasicForm } from "./Form/Basic";
|
|
|
8
8
|
export { default as HInputGroup } from "./InputGroup";
|
|
9
9
|
export declare const HSelect: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
export declare const HInput: ({ copy: copyProps, value, addonAfter, ...props }: import("./Input/modal").HInputProps) => JSX.Element;
|
|
11
|
+
export declare const HRichEditor: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
11
12
|
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
12
13
|
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
13
14
|
export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, inputHelper, style, exFiles, spaceSize, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
|
package/es/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import Index$2 from './DialogForm/DrawerForm/index.js';
|
|
|
13
13
|
|
|
14
14
|
var HSelect = componentConfig.select;
|
|
15
15
|
var HInput = componentConfig.input;
|
|
16
|
+
var HRichEditor = componentConfig.richEditor;
|
|
16
17
|
var HSelectInput = componentConfig.selectInput;
|
|
17
18
|
var HUpload = componentConfig.upload;
|
|
18
19
|
var HUrlUpload = componentConfig.urlUpload.Component;
|
|
@@ -36,5 +37,5 @@ var HTrimInput = componentConfig.trimInput;
|
|
|
36
37
|
var HTrimTextArea = componentConfig.trimTextArea;
|
|
37
38
|
var HInputNumberGroup = componentConfig.inputNumberGroup.Component;
|
|
38
39
|
|
|
39
|
-
export { HButtonInput, HCascader, HCheckBox, HCheckboxGroup, HColorInput, HDatePicker, HDrawerForm, HInput, HInputNumber, HInputNumberGroup, HModalForm, HPageHandler, HRadioGroup, HRangePicker, HSelect, HSelectInput, HSwitch, HTextArea, HTimePicker, HTrimInput, HTrimTextArea, HUpload, HUrlUpload, HVerificationCodeInput };
|
|
40
|
+
export { HButtonInput, HCascader, HCheckBox, HCheckboxGroup, HColorInput, HDatePicker, HDrawerForm, HInput, HInputNumber, HInputNumberGroup, HModalForm, HPageHandler, HRadioGroup, HRangePicker, HRichEditor, HSelect, HSelectInput, HSwitch, HTextArea, HTimePicker, HTrimInput, HTrimTextArea, HUpload, HUrlUpload, HVerificationCodeInput };
|
|
40
41
|
// powered by hdj
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
6
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
7
7
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
8
|
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
9
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -75,48 +75,56 @@ var Index = function Index(_ref) {
|
|
|
75
75
|
}),
|
|
76
76
|
loading = _useSub.loading,
|
|
77
77
|
run = _useSub.run;
|
|
78
|
+
var finish = /*#__PURE__*/function () {
|
|
79
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
80
|
+
var result, close;
|
|
81
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
82
|
+
while (1) switch (_context.prev = _context.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
_context.next = 2;
|
|
85
|
+
return run(values, subParams);
|
|
86
|
+
case 2:
|
|
87
|
+
result = _context.sent;
|
|
88
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
89
|
+
if (!(close === false)) {
|
|
90
|
+
_context.next = 6;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
return _context.abrupt("return");
|
|
94
|
+
case 6:
|
|
95
|
+
cancel();
|
|
96
|
+
case 7:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee);
|
|
101
|
+
}));
|
|
102
|
+
return function finish(_x, _x2) {
|
|
103
|
+
return _ref2.apply(this, arguments);
|
|
104
|
+
};
|
|
105
|
+
}();
|
|
106
|
+
var footerOnOk = function footerOnOk() {
|
|
107
|
+
if (modalFormData) {
|
|
108
|
+
dialogForm === null || dialogForm === void 0 || dialogForm.submit();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
finish({}, formParams);
|
|
112
|
+
};
|
|
78
113
|
var defaultFooter = hooks.useFooterRender({
|
|
79
114
|
dialogForm: dialogForm,
|
|
80
115
|
footer: footer,
|
|
81
116
|
confirmLoading: loading,
|
|
82
|
-
params: formParams
|
|
117
|
+
params: formParams,
|
|
118
|
+
onOk: footerOnOk
|
|
83
119
|
});
|
|
84
|
-
var node = jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
|
|
120
|
+
var node = modalFormData && jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
|
|
85
121
|
configData: modalFormData,
|
|
86
122
|
initialValues: initValue,
|
|
87
123
|
onValuesChange: onValuesChange
|
|
88
124
|
}, props), {}, {
|
|
89
125
|
form: currentForm,
|
|
90
126
|
params: formParams,
|
|
91
|
-
onFinish:
|
|
92
|
-
var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
93
|
-
var result, close;
|
|
94
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
95
|
-
while (1) switch (_context.prev = _context.next) {
|
|
96
|
-
case 0:
|
|
97
|
-
_context.next = 2;
|
|
98
|
-
return run(values, subParams);
|
|
99
|
-
case 2:
|
|
100
|
-
result = _context.sent;
|
|
101
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
102
|
-
if (!(close === false)) {
|
|
103
|
-
_context.next = 6;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
return _context.abrupt("return");
|
|
107
|
-
case 6:
|
|
108
|
-
cancel();
|
|
109
|
-
case 7:
|
|
110
|
-
case "end":
|
|
111
|
-
return _context.stop();
|
|
112
|
-
}
|
|
113
|
-
}, _callee);
|
|
114
|
-
}));
|
|
115
|
-
function onFinish(_x, _x2) {
|
|
116
|
-
return _onFinish.apply(this, arguments);
|
|
117
|
-
}
|
|
118
|
-
return onFinish;
|
|
119
|
-
}(),
|
|
127
|
+
onFinish: finish,
|
|
120
128
|
infoRequest: infoRequest,
|
|
121
129
|
labelWidth: labelWidth
|
|
122
130
|
}));
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
6
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
7
7
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
8
|
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
9
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -65,39 +65,46 @@ var Index = function Index(_ref) {
|
|
|
65
65
|
}),
|
|
66
66
|
loading = _useSub.loading,
|
|
67
67
|
run = _useSub.run;
|
|
68
|
-
var
|
|
68
|
+
var finish = /*#__PURE__*/function () {
|
|
69
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
70
|
+
var result, close;
|
|
71
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
72
|
+
while (1) switch (_context.prev = _context.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
_context.next = 2;
|
|
75
|
+
return run(values, outParams);
|
|
76
|
+
case 2:
|
|
77
|
+
result = _context.sent;
|
|
78
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
79
|
+
if (!(close === false)) {
|
|
80
|
+
_context.next = 6;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
return _context.abrupt("return");
|
|
84
|
+
case 6:
|
|
85
|
+
cancel();
|
|
86
|
+
case 7:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
89
|
+
}
|
|
90
|
+
}, _callee);
|
|
91
|
+
}));
|
|
92
|
+
return function finish(_x, _x2) {
|
|
93
|
+
return _ref2.apply(this, arguments);
|
|
94
|
+
};
|
|
95
|
+
}();
|
|
96
|
+
var footerOnOk = function footerOnOk() {
|
|
97
|
+
if (modalFormData) {
|
|
98
|
+
dialogForm === null || dialogForm === void 0 || dialogForm.submit();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
finish({}, formParams);
|
|
102
|
+
};
|
|
103
|
+
var node = modalFormData && jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
|
|
69
104
|
configData: modalFormData,
|
|
70
105
|
initialValues: initValue,
|
|
71
106
|
onValuesChange: onValuesChange,
|
|
72
|
-
onFinish:
|
|
73
|
-
var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
74
|
-
var result, close;
|
|
75
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
76
|
-
while (1) switch (_context.prev = _context.next) {
|
|
77
|
-
case 0:
|
|
78
|
-
_context.next = 2;
|
|
79
|
-
return run(values, outParams);
|
|
80
|
-
case 2:
|
|
81
|
-
result = _context.sent;
|
|
82
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
83
|
-
if (!(close === false)) {
|
|
84
|
-
_context.next = 6;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
return _context.abrupt("return");
|
|
88
|
-
case 6:
|
|
89
|
-
cancel();
|
|
90
|
-
case 7:
|
|
91
|
-
case "end":
|
|
92
|
-
return _context.stop();
|
|
93
|
-
}
|
|
94
|
-
}, _callee);
|
|
95
|
-
}));
|
|
96
|
-
function onFinish(_x, _x2) {
|
|
97
|
-
return _onFinish.apply(this, arguments);
|
|
98
|
-
}
|
|
99
|
-
return onFinish;
|
|
100
|
-
}()
|
|
107
|
+
onFinish: finish
|
|
101
108
|
}, props), {}, {
|
|
102
109
|
params: formParams,
|
|
103
110
|
form: currentForm,
|
|
@@ -107,7 +114,8 @@ var Index = function Index(_ref) {
|
|
|
107
114
|
dialogForm: dialogForm,
|
|
108
115
|
footer: footer,
|
|
109
116
|
confirmLoading: loading,
|
|
110
|
-
params: formParams
|
|
117
|
+
params: formParams,
|
|
118
|
+
onOk: footerOnOk
|
|
111
119
|
});
|
|
112
120
|
return jsxRuntime.jsx(antd.Modal, _objectSpread(_objectSpread({
|
|
113
121
|
title: modalTitle,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
|
|
3
3
|
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, autoClear, }: ModifyPropsModal) => {
|
|
4
|
-
modalFormData: import("../Form/modal").HItemProps[];
|
|
4
|
+
modalFormData: import("../Form/modal").HItemProps[] | undefined;
|
|
5
5
|
modalVisible: boolean | undefined;
|
|
6
6
|
setModalVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
7
|
-
setModalFormData: React.Dispatch<React.SetStateAction<import("../Form/modal").HItemProps[]>>;
|
|
7
|
+
setModalFormData: React.Dispatch<React.SetStateAction<import("../Form/modal").HItemProps[] | undefined>>;
|
|
8
8
|
initValue: Record<string, any> | undefined;
|
|
9
9
|
setInitValue: React.Dispatch<React.SetStateAction<Record<string, any> | undefined>>;
|
|
10
10
|
formParams: any;
|
|
@@ -14,4 +14,8 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
|
|
|
14
14
|
export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
|
|
15
15
|
export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
|
|
16
16
|
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any, params: any]>;
|
|
17
|
-
|
|
17
|
+
interface FooterRenderParamsModal extends Omit<DialogFormProps, "configData"> {
|
|
18
|
+
onOk: VoidFunction;
|
|
19
|
+
}
|
|
20
|
+
export declare const useFooterRender: ({ footer, confirmLoading, dialogForm, params, onOk }: FooterRenderParamsModal) => any;
|
|
21
|
+
export {};
|
package/lib/DialogForm/hooks.js
CHANGED
|
@@ -155,7 +155,8 @@ var useFooterRender = function useFooterRender(_ref4) {
|
|
|
155
155
|
var footer = _ref4.footer,
|
|
156
156
|
confirmLoading = _ref4.confirmLoading,
|
|
157
157
|
dialogForm = _ref4.dialogForm,
|
|
158
|
-
params = _ref4.params
|
|
158
|
+
params = _ref4.params,
|
|
159
|
+
onOk = _ref4.onOk;
|
|
159
160
|
if (footer === null) {
|
|
160
161
|
return null;
|
|
161
162
|
}
|
|
@@ -166,9 +167,7 @@ var useFooterRender = function useFooterRender(_ref4) {
|
|
|
166
167
|
onCancel: function onCancel() {
|
|
167
168
|
dialogForm === null || dialogForm === void 0 || dialogForm.hide();
|
|
168
169
|
},
|
|
169
|
-
onOk:
|
|
170
|
-
dialogForm === null || dialogForm === void 0 || dialogForm.submit();
|
|
171
|
-
},
|
|
170
|
+
onOk: onOk,
|
|
172
171
|
confirmLoading: confirmLoading
|
|
173
172
|
});
|
|
174
173
|
};
|
|
@@ -4,7 +4,7 @@ import type { PromiseFnResult } from "../modal";
|
|
|
4
4
|
import type React from "react";
|
|
5
5
|
type RootProps = HFormProps & ModalProps;
|
|
6
6
|
export interface ModifyPropsModal<P = any> {
|
|
7
|
-
configData
|
|
7
|
+
configData?: HItemProps[];
|
|
8
8
|
visible?: boolean;
|
|
9
9
|
initialValues?: Record<string, any>;
|
|
10
10
|
dialogForm: HDialogFormInstance;
|
|
@@ -28,8 +28,9 @@ export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
|
|
|
28
28
|
getParams: () => Record<string, any>;
|
|
29
29
|
}
|
|
30
30
|
export type FooterRender = (dialogForm?: HDialogFormInstance, loading?: boolean, params?: Record<string, any>) => React.ReactNode;
|
|
31
|
-
export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer"> {
|
|
31
|
+
export interface DialogFormProps<P = any, T = any> extends Omit<RootProps, "onFinish" | "onCancel" | "onOk" | "infoRequest" | "title" | "footer" | "configData"> {
|
|
32
32
|
dialogForm?: HDialogFormInstance;
|
|
33
|
+
configData?: HFormProps["configData"];
|
|
33
34
|
onFinish?: (values: T, params: P) => Promise<any>;
|
|
34
35
|
onCancel?: VoidFunction;
|
|
35
36
|
onOk?: (data: T, params: P) => boolean | void;
|
package/lib/Form/Basic.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, gutter, dismissOnPressEnter, itemSpan, labelWidth, formItemStyle, flexBox: formFlexBox }: HFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, gutter, dismissOnPressEnter, itemSpan, labelWidth, formItemStyle, flexBox: formFlexBox, }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -6,6 +6,7 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var hooks = require('./hooks.js');
|
|
8
8
|
var index = require('../Context/index.js');
|
|
9
|
+
var useAddFormat = require('../hooks/useAddFormat.js');
|
|
9
10
|
|
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -28,6 +29,7 @@ var Item = (function (props) {
|
|
|
28
29
|
colon = props.colon,
|
|
29
30
|
_props$rowWrapper = props.rowWrapper,
|
|
30
31
|
rowWrapper = _props$rowWrapper === void 0 ? formRowWrapper : _props$rowWrapper;
|
|
32
|
+
useAddFormat.default(props);
|
|
31
33
|
var Component = hooks.useFormItemDomControl(props);
|
|
32
34
|
return jsxRuntime.jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
|
|
33
35
|
labelAlign: labelAlign,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { HFormItemProps } from "@/components/Form/modal";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import type {
|
|
4
|
-
declare const _default: (component: React.FunctionComponent | React.ComponentClass | React.ForwardRefRenderFunction<any, any
|
|
2
|
+
import type { HFormItemProps } from "./modal";
|
|
3
|
+
declare const _default: (component: React.FunctionComponent | React.ComponentClass | React.ForwardRefRenderFunction<any, any>) => React.ForwardRefExoticComponent<HFormItemProps & React.RefAttributes<any>>;
|
|
5
4
|
export default _default;
|
package/lib/Form/HFormConnect.js
CHANGED
|
@@ -6,35 +6,11 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var index = require('./Context/index.js');
|
|
8
8
|
var React = require('react');
|
|
9
|
+
var useAddFormat = require('./hooks/useAddFormat.js');
|
|
9
10
|
|
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
var formatMaker = function formatMaker(itemProps, formats) {
|
|
13
|
-
var _ref = formats || {},
|
|
14
|
-
inputValue = _ref.inputValue,
|
|
15
|
-
outputValue = _ref.outputValue;
|
|
16
|
-
var _itemProps$initValueP = itemProps.initValueProvider,
|
|
17
|
-
initValueProvider = _itemProps$initValueP === void 0 ? inputValue : _itemProps$initValueP,
|
|
18
|
-
_itemProps$subProvide = itemProps.subProvider,
|
|
19
|
-
subProvider = _itemProps$subProvide === void 0 ? outputValue : _itemProps$subProvide;
|
|
20
|
-
var resultObj = {};
|
|
21
|
-
if (initValueProvider) {
|
|
22
|
-
resultObj.inputValue = function (value) {
|
|
23
|
-
return initValueProvider(itemProps, value);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (subProvider) {
|
|
27
|
-
resultObj.outputValue = function (value) {
|
|
28
|
-
return subProvider(itemProps, value);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
var keysLen = Object.keys(resultObj).length;
|
|
32
|
-
return keysLen === 0 ? undefined : resultObj;
|
|
33
|
-
};
|
|
34
13
|
var HFormConnect = (function (component) {
|
|
35
|
-
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
|
-
var _config$format = config.format,
|
|
37
|
-
format = _config$format === void 0 ? {} : _config$format;
|
|
38
14
|
var Index = function Index(props, ref) {
|
|
39
15
|
var _useFormContext = index.useFormContext(),
|
|
40
16
|
form = _useFormContext.form,
|
|
@@ -42,17 +18,11 @@ var HFormConnect = (function (component) {
|
|
|
42
18
|
valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
|
|
43
19
|
var name = props.name;
|
|
44
20
|
var relName = Array.isArray(name) ? name.join(".") : name;
|
|
45
|
-
React.useEffect(function () {
|
|
46
|
-
if (!relName) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
form === null || form === void 0 || form.addFormat(relName, formatMaker(props, format[valueType]));
|
|
50
|
-
}, [valueType, props]);
|
|
51
21
|
var addFormat = function addFormat(aFormat) {
|
|
52
22
|
if (!relName) {
|
|
53
23
|
return;
|
|
54
24
|
}
|
|
55
|
-
form === null || form === void 0 || form.addFormat(relName, formatMaker(props, aFormat[valueType]));
|
|
25
|
+
form === null || form === void 0 || form.addFormat(relName, useAddFormat.formatMaker(props, aFormat[valueType]));
|
|
56
26
|
};
|
|
57
27
|
var addDispatchListener = function addDispatchListener(key, fn) {
|
|
58
28
|
var dispatch = props.dispatch;
|
package/lib/Form/config.d.ts
CHANGED
|
@@ -37,5 +37,6 @@ declare const componentConfig: {
|
|
|
37
37
|
};
|
|
38
38
|
treeSelect: ({ request, onlyCheckChild, multiple, treeCheckable, treeData, fieldNames, ...props }: import("../Select/TreeSelect").HTreeSelectProps) => JSX.Element;
|
|
39
39
|
text: ({ value, addonBefore, addonAfter, size, ...props }: import("../Text").HFormTextProps) => JSX.Element;
|
|
40
|
+
richEditor: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
40
41
|
};
|
|
41
42
|
export default componentConfig;
|
package/lib/Form/config.js
CHANGED
|
@@ -26,9 +26,10 @@ var TrimInput = require('../Input/TrimInput.js');
|
|
|
26
26
|
var TrimTextArea = require('../TextArea/TrimTextArea.js');
|
|
27
27
|
var InputNumberGroup = require('../Input/InputNumberGroup.js');
|
|
28
28
|
var index$e = require('../Text/index.js');
|
|
29
|
+
var index$f = require('../RichEditor/index.js');
|
|
29
30
|
|
|
30
31
|
var placeholderConfig = {
|
|
31
|
-
inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea"],
|
|
32
|
+
inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea", "richEditor"],
|
|
32
33
|
selectType: ["select", "datePicker", "timePicker", "colorInput", "treeSelect"]
|
|
33
34
|
};
|
|
34
35
|
var componentConfig = {
|
|
@@ -55,7 +56,8 @@ var componentConfig = {
|
|
|
55
56
|
trimTextArea: TrimTextArea.default,
|
|
56
57
|
inputNumberGroup: InputNumberGroup.default,
|
|
57
58
|
treeSelect: TreeSelect.default,
|
|
58
|
-
text: index$e.default
|
|
59
|
+
text: index$e.default,
|
|
60
|
+
richEditor: index$f.default
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
exports.default = componentConfig;
|
|
@@ -13,4 +13,5 @@ export declare const useInfoReq: ({ initialValues, infoRequest, form, params, re
|
|
|
13
13
|
};
|
|
14
14
|
export declare const useDefaultComponents: () => any;
|
|
15
15
|
export declare const useValuesChange: ({ onValuesChange, dispatch, form, }: UseValuesChangeModal) => (changedValues: any, values: any) => void;
|
|
16
|
+
export declare const useAddFormat: () => void;
|
|
16
17
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { addFormatItemModal, HFormItemProps } from "../modal";
|
|
2
|
+
interface ResultModal {
|
|
3
|
+
inputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
4
|
+
outputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
export declare const formatMaker: (itemProps: HFormItemProps, formats?: addFormatItemModal) => ResultModal | undefined;
|
|
7
|
+
declare const _default: (props: HFormItemProps) => void;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var index = require('../Context/index.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
var formatMaker = function formatMaker(itemProps, formats) {
|
|
9
|
+
var _ref = formats || {},
|
|
10
|
+
inputValue = _ref.inputValue,
|
|
11
|
+
outputValue = _ref.outputValue;
|
|
12
|
+
var _itemProps$initValueP = itemProps.initValueProvider,
|
|
13
|
+
initValueProvider = _itemProps$initValueP === void 0 ? inputValue : _itemProps$initValueP,
|
|
14
|
+
_itemProps$subProvide = itemProps.subProvider,
|
|
15
|
+
subProvider = _itemProps$subProvide === void 0 ? outputValue : _itemProps$subProvide;
|
|
16
|
+
var resultObj = {};
|
|
17
|
+
if (initValueProvider) {
|
|
18
|
+
resultObj.inputValue = function (value) {
|
|
19
|
+
return initValueProvider(itemProps, value);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (subProvider) {
|
|
23
|
+
resultObj.outputValue = function (value) {
|
|
24
|
+
return subProvider(itemProps, value);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var keysLen = Object.keys(resultObj).length;
|
|
28
|
+
return keysLen === 0 ? undefined : resultObj;
|
|
29
|
+
};
|
|
30
|
+
var useAddFormat = (function (props) {
|
|
31
|
+
var name = props.name,
|
|
32
|
+
itemProps = props.itemProps;
|
|
33
|
+
var _useFormContext = index.useFormContext(),
|
|
34
|
+
form = _useFormContext.form,
|
|
35
|
+
_useFormContext$value = _useFormContext.valueType,
|
|
36
|
+
valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
|
|
37
|
+
var relName = Array.isArray(name) ? name.join(".") : name;
|
|
38
|
+
React.useEffect(function () {
|
|
39
|
+
if (!relName || !itemProps) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
form === null || form === void 0 || form.addFormat(relName, formatMaker(itemProps));
|
|
43
|
+
}, [valueType, props]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
exports.default = useAddFormat;
|
|
47
|
+
exports.formatMaker = formatMaker;
|
|
48
|
+
// powered by h
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -109,6 +109,10 @@ interface ConfigUploadProps {
|
|
|
109
109
|
maxSize?: number;
|
|
110
110
|
request?: PromiseFnResult;
|
|
111
111
|
}
|
|
112
|
+
interface ConfigRichEditorProps {
|
|
113
|
+
fileRequest?: PromiseFnResult;
|
|
114
|
+
valueType?: "html" | "state";
|
|
115
|
+
}
|
|
112
116
|
export type ComponentModal = React.FunctionComponent<any> | React.ComponentClass<any> | React.ForwardRefExoticComponent<any>;
|
|
113
117
|
export interface ConfigComponentModal {
|
|
114
118
|
Component: ComponentModal;
|
|
@@ -127,6 +131,7 @@ export interface IFormConfigContextProps {
|
|
|
127
131
|
defaultComponent?: DefaultComponentModal;
|
|
128
132
|
formItemStyle?: React.CSSProperties;
|
|
129
133
|
itemProps?: ItemPropsType;
|
|
134
|
+
richEditorProps?: ConfigRichEditorProps;
|
|
130
135
|
}
|
|
131
136
|
interface ActionModal {
|
|
132
137
|
key: string;
|