@hw-component/form 1.9.70 → 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.
Files changed (63) hide show
  1. package/.eslintcache +1 -1
  2. package/es/Form/Basic.d.ts +1 -1
  3. package/es/Form/FormItem/index.js +2 -0
  4. package/es/Form/HFormConnect.d.ts +2 -3
  5. package/es/Form/HFormConnect.js +2 -32
  6. package/es/Form/config.d.ts +1 -0
  7. package/es/Form/config.js +4 -2
  8. package/es/Form/hooks/index.d.ts +1 -0
  9. package/es/Form/hooks/useAddFormat.d.ts +8 -0
  10. package/es/Form/hooks/useAddFormat.js +44 -0
  11. package/es/Form/modal.d.ts +5 -0
  12. package/es/RichEditor/hooks.d.ts +15 -0
  13. package/es/RichEditor/hooks.js +110 -0
  14. package/es/RichEditor/index.d.ts +4 -0
  15. package/es/RichEditor/index.js +96 -0
  16. package/es/RichEditor/modal.d.ts +11 -0
  17. package/es/config.js +27 -1
  18. package/es/index.css +22 -0
  19. package/es/index.d.ts +1 -0
  20. package/es/index.js +2 -1
  21. package/lib/Form/Basic.d.ts +1 -1
  22. package/lib/Form/FormItem/index.js +2 -0
  23. package/lib/Form/HFormConnect.d.ts +2 -3
  24. package/lib/Form/HFormConnect.js +2 -32
  25. package/lib/Form/config.d.ts +1 -0
  26. package/lib/Form/config.js +4 -2
  27. package/lib/Form/hooks/index.d.ts +1 -0
  28. package/lib/Form/hooks/useAddFormat.d.ts +8 -0
  29. package/lib/Form/hooks/useAddFormat.js +48 -0
  30. package/lib/Form/modal.d.ts +5 -0
  31. package/lib/RichEditor/hooks.d.ts +15 -0
  32. package/lib/RichEditor/hooks.js +114 -0
  33. package/lib/RichEditor/index.d.ts +4 -0
  34. package/lib/RichEditor/index.js +99 -0
  35. package/lib/RichEditor/modal.d.ts +11 -0
  36. package/lib/config.js +27 -1
  37. package/lib/index.css +22 -0
  38. package/lib/index.d.ts +1 -0
  39. package/lib/index.js +2 -0
  40. package/package.json +2 -1
  41. package/src/components/DialogForm/hooks.tsx +6 -6
  42. package/src/components/DialogForm/modal.ts +1 -1
  43. package/src/components/Form/Basic.tsx +5 -9
  44. package/src/components/Form/FormItem/BasicItem.tsx +5 -3
  45. package/src/components/Form/FormItem/index.tsx +2 -0
  46. package/src/components/Form/HFormConnect.tsx +3 -39
  47. package/src/components/Form/config.ts +4 -0
  48. package/src/components/Form/hooks/index.ts +4 -0
  49. package/src/components/Form/hooks/useAddFormat.tsx +44 -0
  50. package/src/components/Form/index.less +4 -3
  51. package/src/components/Form/modal.ts +9 -3
  52. package/src/components/InputGroup/index.tsx +2 -2
  53. package/src/components/RichEditor/hooks.ts +83 -0
  54. package/src/components/RichEditor/index.less +26 -0
  55. package/src/components/RichEditor/index.tsx +84 -0
  56. package/src/components/RichEditor/modal.ts +13 -0
  57. package/src/components/Upload/hooks/change.ts +4 -5
  58. package/src/components/config.ts +8 -0
  59. package/src/components/index.tsx +2 -0
  60. package/src/components/styles/index.less +1 -0
  61. package/src/pages/Form/index.tsx +34 -19
  62. package/src/pages/Input/index.tsx +1 -1
  63. package/src/pages/Select/index.tsx +2 -2
@@ -2,36 +2,12 @@
2
2
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
  import { useFormContext } from './Context/index.js';
5
- import React, { useEffect } from 'react';
5
+ import React from 'react';
6
+ import { formatMaker } from './hooks/useAddFormat.js';
6
7
 
7
8
  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; }
8
9
  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; }
9
- var formatMaker = function formatMaker(itemProps, formats) {
10
- var _ref = formats || {},
11
- inputValue = _ref.inputValue,
12
- outputValue = _ref.outputValue;
13
- var _itemProps$initValueP = itemProps.initValueProvider,
14
- initValueProvider = _itemProps$initValueP === void 0 ? inputValue : _itemProps$initValueP,
15
- _itemProps$subProvide = itemProps.subProvider,
16
- subProvider = _itemProps$subProvide === void 0 ? outputValue : _itemProps$subProvide;
17
- var resultObj = {};
18
- if (initValueProvider) {
19
- resultObj.inputValue = function (value) {
20
- return initValueProvider(itemProps, value);
21
- };
22
- }
23
- if (subProvider) {
24
- resultObj.outputValue = function (value) {
25
- return subProvider(itemProps, value);
26
- };
27
- }
28
- var keysLen = Object.keys(resultObj).length;
29
- return keysLen === 0 ? undefined : resultObj;
30
- };
31
10
  var HFormConnect = (function (component) {
32
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
33
- var _config$format = config.format,
34
- format = _config$format === void 0 ? {} : _config$format;
35
11
  var Index = function Index(props, ref) {
36
12
  var _useFormContext = useFormContext(),
37
13
  form = _useFormContext.form,
@@ -39,12 +15,6 @@ var HFormConnect = (function (component) {
39
15
  valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
40
16
  var name = props.name;
41
17
  var relName = Array.isArray(name) ? name.join(".") : name;
42
- useEffect(function () {
43
- if (!relName) {
44
- return;
45
- }
46
- form === null || form === void 0 || form.addFormat(relName, formatMaker(props, format[valueType]));
47
- }, [valueType, props]);
48
18
  var addFormat = function addFormat(aFormat) {
49
19
  if (!relName) {
50
20
  return;
@@ -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/es/Form/config.js CHANGED
@@ -23,9 +23,10 @@ import TrimInput from '../Input/TrimInput.js';
23
23
  import TrimTextArea from '../TextArea/TrimTextArea.js';
24
24
  import HInputNumberGroup from '../Input/InputNumberGroup.js';
25
25
  import HText from '../Text/index.js';
26
+ import HRichEditor from '../RichEditor/index.js';
26
27
 
27
28
  var placeholderConfig = {
28
- inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea"],
29
+ inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea", "richEditor"],
29
30
  selectType: ["select", "datePicker", "timePicker", "colorInput", "treeSelect"]
30
31
  };
31
32
  var componentConfig = {
@@ -52,7 +53,8 @@ var componentConfig = {
52
53
  trimTextArea: TrimTextArea,
53
54
  inputNumberGroup: HInputNumberGroup,
54
55
  treeSelect: HTreeSelect,
55
- text: HText
56
+ text: HText,
57
+ richEditor: HRichEditor
56
58
  };
57
59
 
58
60
  export { componentConfig as default, placeholderConfig };
@@ -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,44 @@
1
+ // welcome to hoo hoo hoo
2
+ import { useFormContext } from '../Context/index.js';
3
+ import { useEffect } from 'react';
4
+
5
+ var formatMaker = function formatMaker(itemProps, formats) {
6
+ var _ref = formats || {},
7
+ inputValue = _ref.inputValue,
8
+ outputValue = _ref.outputValue;
9
+ var _itemProps$initValueP = itemProps.initValueProvider,
10
+ initValueProvider = _itemProps$initValueP === void 0 ? inputValue : _itemProps$initValueP,
11
+ _itemProps$subProvide = itemProps.subProvider,
12
+ subProvider = _itemProps$subProvide === void 0 ? outputValue : _itemProps$subProvide;
13
+ var resultObj = {};
14
+ if (initValueProvider) {
15
+ resultObj.inputValue = function (value) {
16
+ return initValueProvider(itemProps, value);
17
+ };
18
+ }
19
+ if (subProvider) {
20
+ resultObj.outputValue = function (value) {
21
+ return subProvider(itemProps, value);
22
+ };
23
+ }
24
+ var keysLen = Object.keys(resultObj).length;
25
+ return keysLen === 0 ? undefined : resultObj;
26
+ };
27
+ var useAddFormat = (function (props) {
28
+ var name = props.name,
29
+ itemProps = props.itemProps;
30
+ var _useFormContext = useFormContext(),
31
+ form = _useFormContext.form,
32
+ _useFormContext$value = _useFormContext.valueType,
33
+ valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
34
+ var relName = Array.isArray(name) ? name.join(".") : name;
35
+ useEffect(function () {
36
+ if (!relName || !itemProps) {
37
+ return;
38
+ }
39
+ form === null || form === void 0 || form.addFormat(relName, formatMaker(itemProps));
40
+ }, [valueType, props]);
41
+ });
42
+
43
+ export { useAddFormat as default, formatMaker };
44
+ // powered by hdj
@@ -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,110 @@
1
+ // welcome to hoo hoo hoo
2
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
3
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
4
+ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
5
+ import { useFormConfigContext } from '../Form/Context/FormConfigProvider.js';
6
+ import { baseConfig } from '../config.js';
7
+ import { useClassName } from '../hooks/index.js';
8
+ import { useState } from 'react';
9
+ import BraftEditor from 'braft-editor';
10
+
11
+ var useProps = function useProps(_ref) {
12
+ var _baseConfig$richEdito;
13
+ var fileRequest = _ref.fileRequest,
14
+ valueType = _ref.valueType;
15
+ var _useFormConfigContext = useFormConfigContext("richEditorProps"),
16
+ _useFormConfigContext2 = _useFormConfigContext.fileRequest,
17
+ contextFileRequest = _useFormConfigContext2 === void 0 ? fileRequest : _useFormConfigContext2,
18
+ _useFormConfigContext3 = _useFormConfigContext.valueType,
19
+ contextValueType = _useFormConfigContext3 === void 0 ? valueType : _useFormConfigContext3;
20
+ var cuRequest = fileRequest === null ? (_baseConfig$richEdito = baseConfig.richEditorProps) === null || _baseConfig$richEdito === void 0 ? void 0 : _baseConfig$richEdito.fileRequest : contextFileRequest;
21
+ return {
22
+ fileRequest: cuRequest,
23
+ valueType: contextValueType
24
+ };
25
+ };
26
+ var useFocusClassname = function useFocusClassname(_ref2) {
27
+ var bordered = _ref2.bordered,
28
+ focusProps = _ref2.onFocus,
29
+ blurProps = _ref2.onBlur;
30
+ var styleFocusClassName = useClassName("hw-rich-editor-focus");
31
+ var _useState = useState(""),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ focusClassname = _useState2[0],
34
+ setFocusClassname = _useState2[1];
35
+ var onFocus = function onFocus(editState) {
36
+ focusProps === null || focusProps === void 0 || focusProps(editState);
37
+ if (!bordered) {
38
+ setFocusClassname("");
39
+ return;
40
+ }
41
+ setFocusClassname(styleFocusClassName);
42
+ };
43
+ var onBlur = function onBlur(editState) {
44
+ setFocusClassname("");
45
+ blurProps === null || blurProps === void 0 || blurProps(editState);
46
+ };
47
+ return {
48
+ focusClassname: focusClassname,
49
+ onFocus: onFocus,
50
+ onBlur: onBlur
51
+ };
52
+ };
53
+ var useVC = function useVC(_ref3) {
54
+ var value = _ref3.value,
55
+ onChange = _ref3.onChange,
56
+ valueType = _ref3.valueType;
57
+ var richValue = valueType === "html" ? BraftEditor.createEditorState(value) : value;
58
+ var change = function change(editorState) {
59
+ var changeVal = valueType === "html" ? editorState.toHTML() : editorState;
60
+ var isEmpty = !!richValue ? richValue.isEmpty() : true;
61
+ if (isEmpty && editorState.isEmpty()) {
62
+ return;
63
+ }
64
+ onChange === null || onChange === void 0 || onChange(changeVal);
65
+ };
66
+ return {
67
+ richValue: richValue,
68
+ change: change
69
+ };
70
+ };
71
+ var useUploadFn = function useUploadFn(_ref4) {
72
+ var fileRequest = _ref4.fileRequest;
73
+ return /*#__PURE__*/function () {
74
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
75
+ var file, id, _yield$fileRequest, url;
76
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
77
+ while (1) switch (_context.prev = _context.next) {
78
+ case 0:
79
+ file = params.file, id = params.id;
80
+ _context.next = 3;
81
+ return fileRequest === null || fileRequest === void 0 ? void 0 : fileRequest(file, params);
82
+ case 3:
83
+ _yield$fileRequest = _context.sent;
84
+ url = _yield$fileRequest.url;
85
+ params.success({
86
+ url: url,
87
+ meta: {
88
+ id: id,
89
+ title: file.name,
90
+ alt: "媒体资源",
91
+ loop: false,
92
+ autoPlay: false,
93
+ controls: true,
94
+ poster: url
95
+ }
96
+ });
97
+ case 6:
98
+ case "end":
99
+ return _context.stop();
100
+ }
101
+ }, _callee);
102
+ }));
103
+ return function (_x) {
104
+ return _ref5.apply(this, arguments);
105
+ };
106
+ }();
107
+ };
108
+
109
+ export { useFocusClassname, useProps, useUploadFn, useVC };
110
+ // powered by hdj
@@ -0,0 +1,4 @@
1
+ import "braft-editor/dist/index.css";
2
+ import React from "react";
3
+ declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
4
+ export default _default;
@@ -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
@@ -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 { ConnectConfigModal } from "@/components/Form/modal";
4
- declare const _default: (component: React.FunctionComponent | React.ComponentClass | React.ForwardRefRenderFunction<any, any>, config?: ConnectConfigModal) => React.ForwardRefExoticComponent<HFormItemProps & React.RefAttributes<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;
@@ -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;
@@ -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;
@@ -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;