@hw-component/form 1.9.69 → 1.9.71
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/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 +23 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- 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 +23 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/package.json +2 -1
- package/src/components/DialogForm/hooks.tsx +6 -6
- package/src/components/DialogForm/modal.ts +1 -1
- 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 +5 -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 +34 -14
- package/src/pages/Input/index.tsx +3 -5
- package/src/pages/Select/index.tsx +2 -2
|
@@ -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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IHRichEditorProps } from "src/components/RichEditor/modal";
|
|
2
|
+
export declare const useProps: ({ fileRequest, valueType }: IHRichEditorProps) => {
|
|
3
|
+
fileRequest: any;
|
|
4
|
+
valueType: any;
|
|
5
|
+
};
|
|
6
|
+
export declare const useFocusClassname: ({ bordered, onFocus: focusProps, onBlur: blurProps, }: IHRichEditorProps) => {
|
|
7
|
+
focusClassname: string;
|
|
8
|
+
onFocus: (editState: any) => void;
|
|
9
|
+
onBlur: (editState: any) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const useVC: ({ value, onChange, valueType }: IHRichEditorProps) => {
|
|
12
|
+
richValue: any;
|
|
13
|
+
change: (editorState: any) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const useUploadFn: ({ fileRequest }: IHRichEditorProps) => (params: any) => Promise<void>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
5
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
6
|
+
var FormConfigProvider = require('../Form/Context/FormConfigProvider.js');
|
|
7
|
+
var config = require('../config.js');
|
|
8
|
+
var index = require('../hooks/index.js');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var BraftEditor = require('braft-editor');
|
|
11
|
+
|
|
12
|
+
var useProps = function useProps(_ref) {
|
|
13
|
+
var _baseConfig$richEdito;
|
|
14
|
+
var fileRequest = _ref.fileRequest,
|
|
15
|
+
valueType = _ref.valueType;
|
|
16
|
+
var _useFormConfigContext = FormConfigProvider.useFormConfigContext("richEditorProps"),
|
|
17
|
+
_useFormConfigContext2 = _useFormConfigContext.fileRequest,
|
|
18
|
+
contextFileRequest = _useFormConfigContext2 === void 0 ? fileRequest : _useFormConfigContext2,
|
|
19
|
+
_useFormConfigContext3 = _useFormConfigContext.valueType,
|
|
20
|
+
contextValueType = _useFormConfigContext3 === void 0 ? valueType : _useFormConfigContext3;
|
|
21
|
+
var cuRequest = fileRequest === null ? (_baseConfig$richEdito = config.baseConfig.richEditorProps) === null || _baseConfig$richEdito === void 0 ? void 0 : _baseConfig$richEdito.fileRequest : contextFileRequest;
|
|
22
|
+
return {
|
|
23
|
+
fileRequest: cuRequest,
|
|
24
|
+
valueType: contextValueType
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
var useFocusClassname = function useFocusClassname(_ref2) {
|
|
28
|
+
var bordered = _ref2.bordered,
|
|
29
|
+
focusProps = _ref2.onFocus,
|
|
30
|
+
blurProps = _ref2.onBlur;
|
|
31
|
+
var styleFocusClassName = index.useClassName("hw-rich-editor-focus");
|
|
32
|
+
var _useState = React.useState(""),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
focusClassname = _useState2[0],
|
|
35
|
+
setFocusClassname = _useState2[1];
|
|
36
|
+
var onFocus = function onFocus(editState) {
|
|
37
|
+
focusProps === null || focusProps === void 0 || focusProps(editState);
|
|
38
|
+
if (!bordered) {
|
|
39
|
+
setFocusClassname("");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setFocusClassname(styleFocusClassName);
|
|
43
|
+
};
|
|
44
|
+
var onBlur = function onBlur(editState) {
|
|
45
|
+
setFocusClassname("");
|
|
46
|
+
blurProps === null || blurProps === void 0 || blurProps(editState);
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
focusClassname: focusClassname,
|
|
50
|
+
onFocus: onFocus,
|
|
51
|
+
onBlur: onBlur
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var useVC = function useVC(_ref3) {
|
|
55
|
+
var value = _ref3.value,
|
|
56
|
+
onChange = _ref3.onChange,
|
|
57
|
+
valueType = _ref3.valueType;
|
|
58
|
+
var richValue = valueType === "html" ? BraftEditor.createEditorState(value) : value;
|
|
59
|
+
var change = function change(editorState) {
|
|
60
|
+
var changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
61
|
+
var isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
62
|
+
if (isEmpty && editorState.isEmpty()) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
onChange === null || onChange === void 0 || onChange(changeVal);
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
richValue: richValue,
|
|
69
|
+
change: change
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
var useUploadFn = function useUploadFn(_ref4) {
|
|
73
|
+
var fileRequest = _ref4.fileRequest;
|
|
74
|
+
return /*#__PURE__*/function () {
|
|
75
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
|
|
76
|
+
var file, id, _yield$fileRequest, url;
|
|
77
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
78
|
+
while (1) switch (_context.prev = _context.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
file = params.file, id = params.id;
|
|
81
|
+
_context.next = 3;
|
|
82
|
+
return fileRequest === null || fileRequest === void 0 ? void 0 : fileRequest(file, params);
|
|
83
|
+
case 3:
|
|
84
|
+
_yield$fileRequest = _context.sent;
|
|
85
|
+
url = _yield$fileRequest.url;
|
|
86
|
+
params.success({
|
|
87
|
+
url: url,
|
|
88
|
+
meta: {
|
|
89
|
+
id: id,
|
|
90
|
+
title: file.name,
|
|
91
|
+
alt: "媒体资源",
|
|
92
|
+
loop: false,
|
|
93
|
+
autoPlay: false,
|
|
94
|
+
controls: true,
|
|
95
|
+
poster: url
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
case 6:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context.stop();
|
|
101
|
+
}
|
|
102
|
+
}, _callee);
|
|
103
|
+
}));
|
|
104
|
+
return function (_x) {
|
|
105
|
+
return _ref5.apply(this, arguments);
|
|
106
|
+
};
|
|
107
|
+
}();
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
exports.useFocusClassname = useFocusClassname;
|
|
111
|
+
exports.useProps = useProps;
|
|
112
|
+
exports.useUploadFn = useUploadFn;
|
|
113
|
+
exports.useVC = useVC;
|
|
114
|
+
// powered by h
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var BraftEditor = require('braft-editor');
|
|
9
|
+
require('braft-editor/dist/index.css');
|
|
10
|
+
var hooks = require('./hooks.js');
|
|
11
|
+
var index = require('../hooks/index.js');
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var HFormConnect = require('../Form/HFormConnect.js');
|
|
14
|
+
|
|
15
|
+
var _excluded = ["value", "onChange", "valueType", "fileRequest", "media", "contentStyle", "bordered", "onBlur", "onFocus", "addFormat"];
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
var defaultContentStyle = {
|
|
19
|
+
height: 400
|
|
20
|
+
};
|
|
21
|
+
var Index = function Index(_ref, ref) {
|
|
22
|
+
var value = _ref.value,
|
|
23
|
+
onChange = _ref.onChange,
|
|
24
|
+
valueType = _ref.valueType,
|
|
25
|
+
fileRequest = _ref.fileRequest,
|
|
26
|
+
media = _ref.media,
|
|
27
|
+
_ref$contentStyle = _ref.contentStyle,
|
|
28
|
+
contentStyle = _ref$contentStyle === void 0 ? defaultContentStyle : _ref$contentStyle,
|
|
29
|
+
_ref$bordered = _ref.bordered,
|
|
30
|
+
bordered = _ref$bordered === void 0 ? true : _ref$bordered,
|
|
31
|
+
onBlur = _ref.onBlur,
|
|
32
|
+
onFocus = _ref.onFocus,
|
|
33
|
+
addFormat = _ref.addFormat,
|
|
34
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
+
var _useProps = hooks.useProps({
|
|
36
|
+
fileRequest: fileRequest,
|
|
37
|
+
valueType: valueType
|
|
38
|
+
}),
|
|
39
|
+
fileReq = _useProps.fileRequest,
|
|
40
|
+
vType = _useProps.valueType;
|
|
41
|
+
var _useFocusClassname = hooks.useFocusClassname({
|
|
42
|
+
bordered: bordered,
|
|
43
|
+
onBlur: onBlur,
|
|
44
|
+
onFocus: onFocus
|
|
45
|
+
}),
|
|
46
|
+
focusClassname = _useFocusClassname.focusClassname,
|
|
47
|
+
selfFocus = _useFocusClassname.onFocus,
|
|
48
|
+
selfBlur = _useFocusClassname.onBlur;
|
|
49
|
+
var _useVC = hooks.useVC({
|
|
50
|
+
value: value,
|
|
51
|
+
onChange: onChange,
|
|
52
|
+
valueType: vType
|
|
53
|
+
}),
|
|
54
|
+
richValue = _useVC.richValue,
|
|
55
|
+
change = _useVC.change;
|
|
56
|
+
var uploadFn = hooks.useUploadFn({
|
|
57
|
+
fileRequest: fileReq
|
|
58
|
+
});
|
|
59
|
+
var bodyClassName = index.useClassName("hw-rich-editor");
|
|
60
|
+
var borderClassName = index.useClassName("hw-rich-editor-border");
|
|
61
|
+
addFormat === null || addFormat === void 0 || addFormat({
|
|
62
|
+
float: {
|
|
63
|
+
inputValue: function inputValue(item, initValue) {
|
|
64
|
+
var _item$name = item.name,
|
|
65
|
+
name = _item$name === void 0 ? "" : _item$name;
|
|
66
|
+
var keyName = name;
|
|
67
|
+
var itemVal = initValue[keyName];
|
|
68
|
+
var initVal = typeof itemVal === "string" ? BraftEditor.createEditorState(itemVal) : itemVal;
|
|
69
|
+
return _defineProperty({}, keyName, initVal);
|
|
70
|
+
},
|
|
71
|
+
outputValue: function outputValue(item, _outputValue) {
|
|
72
|
+
var _item$name2 = item.name,
|
|
73
|
+
name = _item$name2 === void 0 ? "" : _item$name2;
|
|
74
|
+
var keyName = name;
|
|
75
|
+
var itemVal = _outputValue[keyName];
|
|
76
|
+
var outputVal = typeof itemVal === "string" ? itemVal : itemVal === null || itemVal === void 0 ? void 0 : itemVal.toHTML();
|
|
77
|
+
return _defineProperty({}, keyName, outputVal);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return jsxRuntime.jsx("div", {
|
|
82
|
+
className: "".concat(bodyClassName, " ").concat(bordered ? borderClassName : "", " ").concat(focusClassname),
|
|
83
|
+
children: jsxRuntime.jsx(BraftEditor, _objectSpread({
|
|
84
|
+
contentStyle: contentStyle,
|
|
85
|
+
value: richValue,
|
|
86
|
+
onChange: change,
|
|
87
|
+
onFocus: selfFocus,
|
|
88
|
+
ref: ref,
|
|
89
|
+
onBlur: selfBlur,
|
|
90
|
+
media: _objectSpread({
|
|
91
|
+
uploadFn: uploadFn
|
|
92
|
+
}, media)
|
|
93
|
+
}, props))
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
var HRichEditor = HFormConnect.default(/*#__PURE__*/React.forwardRef(Index));
|
|
97
|
+
|
|
98
|
+
exports.default = HRichEditor;
|
|
99
|
+
// powered by h
|
|
@@ -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/lib/config.js
CHANGED
|
@@ -70,7 +70,33 @@ var baseConfig = {
|
|
|
70
70
|
},
|
|
71
71
|
defaultComponent: {},
|
|
72
72
|
formItemStyle: {},
|
|
73
|
-
itemProps: {}
|
|
73
|
+
itemProps: {},
|
|
74
|
+
richEditorProps: {
|
|
75
|
+
fileRequest: function () {
|
|
76
|
+
var _fileRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
|
|
77
|
+
var url;
|
|
78
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
79
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
_context2.next = 2;
|
|
82
|
+
return util.fileToBase64(file);
|
|
83
|
+
case 2:
|
|
84
|
+
url = _context2.sent;
|
|
85
|
+
return _context2.abrupt("return", {
|
|
86
|
+
url: url
|
|
87
|
+
});
|
|
88
|
+
case 4:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context2.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee2);
|
|
93
|
+
}));
|
|
94
|
+
function fileRequest(_x2) {
|
|
95
|
+
return _fileRequest.apply(this, arguments);
|
|
96
|
+
}
|
|
97
|
+
return fileRequest;
|
|
98
|
+
}()
|
|
99
|
+
}
|
|
74
100
|
};
|
|
75
101
|
|
|
76
102
|
exports.baseConfig = baseConfig;
|
package/lib/index.css
CHANGED
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
display: -ms-inline-flexbox;
|
|
55
55
|
display: inline-flex;
|
|
56
56
|
margin-left: 4px;
|
|
57
|
+
cursor: pointer;
|
|
57
58
|
}
|
|
58
59
|
.ant-hw-form-base-item {
|
|
59
60
|
display: -webkit-box;
|
|
@@ -289,3 +290,25 @@
|
|
|
289
290
|
.ant-form-item-has-error .ant-hw-input-group-body {
|
|
290
291
|
border-color: #ff4d4f !important;
|
|
291
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/lib/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/lib/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var index$3 = require('./DialogForm/DrawerForm/index.js');
|
|
|
14
14
|
|
|
15
15
|
var HSelect = config.default.select;
|
|
16
16
|
var HInput = config.default.input;
|
|
17
|
+
var HRichEditor = config.default.richEditor;
|
|
17
18
|
var HSelectInput = config.default.selectInput;
|
|
18
19
|
var HUpload = config.default.upload;
|
|
19
20
|
var HUrlUpload = config.default.urlUpload.Component;
|
|
@@ -58,6 +59,7 @@ exports.HModalForm = HModalForm;
|
|
|
58
59
|
exports.HPageHandler = HPageHandler;
|
|
59
60
|
exports.HRadioGroup = HRadioGroup;
|
|
60
61
|
exports.HRangePicker = HRangePicker;
|
|
62
|
+
exports.HRichEditor = HRichEditor;
|
|
61
63
|
exports.HSelect = HSelect;
|
|
62
64
|
exports.HSelectInput = HSelectInput;
|
|
63
65
|
exports.HSwitch = HSwitch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/form",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.71",
|
|
4
4
|
"description": "基于antd二次开发",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
38
38
|
"ahooks": "2.10.9",
|
|
39
|
+
"braft-editor": "^2.3.9",
|
|
39
40
|
"copy-to-clipboard": "3.3.1",
|
|
40
41
|
"react-color": "2.19.3"
|
|
41
42
|
},
|
|
@@ -72,9 +72,9 @@ export const useModifyProps = ({
|
|
|
72
72
|
setModalVisible(false);
|
|
73
73
|
};
|
|
74
74
|
}, [afterClose, autoClear]);
|
|
75
|
-
dialogForm.getParams=()=>{
|
|
76
|
-
return (formParams as Record<string, any>)||{};
|
|
77
|
-
}
|
|
75
|
+
dialogForm.getParams = () => {
|
|
76
|
+
return (formParams as Record<string, any>) || {};
|
|
77
|
+
};
|
|
78
78
|
return {
|
|
79
79
|
modalFormData,
|
|
80
80
|
modalVisible,
|
|
@@ -94,9 +94,9 @@ export const useHDialogForm = () => {
|
|
|
94
94
|
...hForm,
|
|
95
95
|
show: (params) => {},
|
|
96
96
|
hide: () => {},
|
|
97
|
-
getParams:()=>{
|
|
98
|
-
return {}
|
|
99
|
-
}
|
|
97
|
+
getParams: () => {
|
|
98
|
+
return {};
|
|
99
|
+
},
|
|
100
100
|
};
|
|
101
101
|
}, []);
|
|
102
102
|
};
|
|
@@ -28,7 +28,7 @@ export interface ShowParamsModal<P = any, T = any> {
|
|
|
28
28
|
export interface HDialogFormInstance<P = any, T = any> extends HFormInstance {
|
|
29
29
|
show: (data?: ShowParamsModal<P, T>) => void;
|
|
30
30
|
hide: VoidFunction;
|
|
31
|
-
getParams:()=>Record<string, any>;
|
|
31
|
+
getParams: () => Record<string, any>;
|
|
32
32
|
}
|
|
33
33
|
export type FooterRender = (
|
|
34
34
|
dialogForm?: HDialogFormInstance,
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
HFormProps,
|
|
3
|
-
HItemProps,
|
|
4
|
-
ItemPropsType,
|
|
5
|
-
} from "./modal";
|
|
1
|
+
import type { HFormProps, HItemProps, ItemPropsType } from "./modal";
|
|
6
2
|
import Item from "./FormItem";
|
|
7
3
|
import { Row } from "antd";
|
|
8
4
|
import { useFormContext } from "./Context";
|
|
@@ -15,8 +11,8 @@ export default ({
|
|
|
15
11
|
dismissOnPressEnter = true,
|
|
16
12
|
itemSpan,
|
|
17
13
|
labelWidth,
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
formItemStyle,
|
|
15
|
+
flexBox: formFlexBox,
|
|
20
16
|
}: HFormProps) => {
|
|
21
17
|
const {
|
|
22
18
|
form,
|
|
@@ -49,7 +45,7 @@ export default ({
|
|
|
49
45
|
colon: itemColon,
|
|
50
46
|
itemSpan: configItemSpan,
|
|
51
47
|
nameKey,
|
|
52
|
-
|
|
48
|
+
flexBox = formFlexBox,
|
|
53
49
|
} = itemData;
|
|
54
50
|
const defaultItemProps = {
|
|
55
51
|
onPressEnter: dismissOnPressEnter ? undefined : defaultOnPressEnter,
|
|
@@ -58,7 +54,7 @@ export default ({
|
|
|
58
54
|
};
|
|
59
55
|
const arrayName = Array.isArray(name) ? name.join(".") : name;
|
|
60
56
|
const key = arrayName || nameKey;
|
|
61
|
-
const itemStyle=style||formItemStyle;
|
|
57
|
+
const itemStyle = style || formItemStyle;
|
|
62
58
|
return (
|
|
63
59
|
<Item
|
|
64
60
|
{...itemData}
|
|
@@ -56,7 +56,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
56
56
|
noStyle = false,
|
|
57
57
|
hidden,
|
|
58
58
|
rowWrapper,
|
|
59
|
-
|
|
59
|
+
flexBox,
|
|
60
60
|
...oProps
|
|
61
61
|
} = props;
|
|
62
62
|
const { labelAlign: align = "right", itemProps, ...inProps } = props;
|
|
@@ -73,7 +73,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
73
73
|
{ ...inProps, itemProps: defaultItemProps },
|
|
74
74
|
defaultComponent
|
|
75
75
|
);
|
|
76
|
-
const rowClassname=useClassName("hw-form-item-row");
|
|
76
|
+
const rowClassname = useClassName("hw-form-item-row");
|
|
77
77
|
const className = usePositionClassName(align);
|
|
78
78
|
const hideItem = useHide({ hide, form });
|
|
79
79
|
const disHide = useHide({ hide: hidden, form });
|
|
@@ -87,7 +87,9 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
87
87
|
return (
|
|
88
88
|
<Col
|
|
89
89
|
{...itemSpan}
|
|
90
|
-
className={`${colClassName} ${itemClassName} ${
|
|
90
|
+
className={`${colClassName} ${itemClassName} ${
|
|
91
|
+
flexBox ? rowClassname : ""
|
|
92
|
+
}`}
|
|
91
93
|
style={colStyle}
|
|
92
94
|
>
|
|
93
95
|
<Form.Item
|
|
@@ -2,6 +2,7 @@ import { useFormItemDomControl } from "./hooks";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { HItemProps } from "../modal";
|
|
4
4
|
import { useFormContext } from "../Context";
|
|
5
|
+
import useAddFormat from "../hooks/useAddFormat";
|
|
5
6
|
|
|
6
7
|
export default (props: HItemProps) => {
|
|
7
8
|
const {
|
|
@@ -20,6 +21,7 @@ export default (props: HItemProps) => {
|
|
|
20
21
|
colon,
|
|
21
22
|
rowWrapper = formRowWrapper,
|
|
22
23
|
} = props;
|
|
24
|
+
useAddFormat(props);
|
|
23
25
|
const Component = useFormItemDomControl(props);
|
|
24
26
|
return (
|
|
25
27
|
<Component
|
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
import { useFormContext } from "./Context";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
6
|
-
import type { ConnectResultProps } from "@/components/Form/modal";
|
|
7
|
-
import type { argsFn } from "@/components/Form/modal";
|
|
8
|
-
interface ResultModal {
|
|
9
|
-
inputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
10
|
-
outputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
11
|
-
}
|
|
12
|
-
const formatMaker = (
|
|
13
|
-
itemProps: HFormItemProps,
|
|
14
|
-
formats?: addFormatItemModal
|
|
15
|
-
) => {
|
|
16
|
-
const { inputValue, outputValue } = formats || {};
|
|
17
|
-
const { initValueProvider = inputValue, subProvider = outputValue } =
|
|
18
|
-
itemProps;
|
|
19
|
-
const resultObj: ResultModal = {};
|
|
20
|
-
if (initValueProvider) {
|
|
21
|
-
resultObj.inputValue = (value) => {
|
|
22
|
-
return initValueProvider(itemProps, value);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (subProvider) {
|
|
26
|
-
resultObj.outputValue = (value) => {
|
|
27
|
-
return subProvider(itemProps, value);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const keysLen = Object.keys(resultObj).length;
|
|
31
|
-
return keysLen === 0 ? undefined : resultObj;
|
|
32
|
-
};
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { addFormatItemModal ,HFormItemProps,ConnectResultProps,argsFn} from "./modal";
|
|
4
|
+
import {formatMaker} from "./hooks/useAddFormat";
|
|
33
5
|
|
|
34
6
|
export default (
|
|
35
7
|
component:
|
|
36
8
|
| React.FunctionComponent
|
|
37
9
|
| React.ComponentClass
|
|
38
10
|
| React.ForwardRefRenderFunction<any, any>,
|
|
39
|
-
config: ConnectConfigModal = {}
|
|
40
11
|
) => {
|
|
41
|
-
const { format = {} } = config;
|
|
42
12
|
const Index: React.ForwardRefRenderFunction<any, HFormItemProps> = (
|
|
43
13
|
props: HFormItemProps,
|
|
44
14
|
ref
|
|
@@ -46,12 +16,6 @@ export default (
|
|
|
46
16
|
const { form, valueType = "float" } = useFormContext();
|
|
47
17
|
const { name } = props;
|
|
48
18
|
const relName = Array.isArray(name) ? name.join(".") : name;
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (!relName) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
form?.addFormat(relName, formatMaker(props, format[valueType]));
|
|
54
|
-
}, [valueType, props]);
|
|
55
19
|
const addFormat = (aFormat: Record<string, addFormatItemModal>) => {
|
|
56
20
|
if (!relName) {
|
|
57
21
|
return;
|
|
@@ -22,6 +22,8 @@ import TrimInput from "../Input/TrimInput";
|
|
|
22
22
|
import TrimTextArea from "../TextArea/TrimTextArea";
|
|
23
23
|
import HInputNumberGroup from "../Input/InputNumberGroup";
|
|
24
24
|
import HText from "../Text";
|
|
25
|
+
import HRichEditor from "../RichEditor";
|
|
26
|
+
|
|
25
27
|
export const placeholderConfig = {
|
|
26
28
|
inputType: [
|
|
27
29
|
"input",
|
|
@@ -32,6 +34,7 @@ export const placeholderConfig = {
|
|
|
32
34
|
"trimInput",
|
|
33
35
|
"urlUpload",
|
|
34
36
|
"textArea",
|
|
37
|
+
"richEditor",
|
|
35
38
|
],
|
|
36
39
|
selectType: [
|
|
37
40
|
"select",
|
|
@@ -66,6 +69,7 @@ const componentConfig = {
|
|
|
66
69
|
inputNumberGroup: HInputNumberGroup,
|
|
67
70
|
treeSelect: HTreeSelect,
|
|
68
71
|
text: HText,
|
|
72
|
+
richEditor: HRichEditor,
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
export default componentConfig;
|