@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
2
|
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
5
|
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -72,48 +72,56 @@ var Index = function Index(_ref) {
|
|
|
72
72
|
}),
|
|
73
73
|
loading = _useSub.loading,
|
|
74
74
|
run = _useSub.run;
|
|
75
|
+
var finish = /*#__PURE__*/function () {
|
|
76
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
77
|
+
var result, close;
|
|
78
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
79
|
+
while (1) switch (_context.prev = _context.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
_context.next = 2;
|
|
82
|
+
return run(values, subParams);
|
|
83
|
+
case 2:
|
|
84
|
+
result = _context.sent;
|
|
85
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
86
|
+
if (!(close === false)) {
|
|
87
|
+
_context.next = 6;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
return _context.abrupt("return");
|
|
91
|
+
case 6:
|
|
92
|
+
cancel();
|
|
93
|
+
case 7:
|
|
94
|
+
case "end":
|
|
95
|
+
return _context.stop();
|
|
96
|
+
}
|
|
97
|
+
}, _callee);
|
|
98
|
+
}));
|
|
99
|
+
return function finish(_x, _x2) {
|
|
100
|
+
return _ref2.apply(this, arguments);
|
|
101
|
+
};
|
|
102
|
+
}();
|
|
103
|
+
var footerOnOk = function footerOnOk() {
|
|
104
|
+
if (modalFormData) {
|
|
105
|
+
dialogForm === null || dialogForm === void 0 || dialogForm.submit();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
finish({}, formParams);
|
|
109
|
+
};
|
|
75
110
|
var defaultFooter = useFooterRender({
|
|
76
111
|
dialogForm: dialogForm,
|
|
77
112
|
footer: footer,
|
|
78
113
|
confirmLoading: loading,
|
|
79
|
-
params: formParams
|
|
114
|
+
params: formParams,
|
|
115
|
+
onOk: footerOnOk
|
|
80
116
|
});
|
|
81
|
-
var node = jsx(HForm, _objectSpread(_objectSpread({
|
|
117
|
+
var node = modalFormData && jsx(HForm, _objectSpread(_objectSpread({
|
|
82
118
|
configData: modalFormData,
|
|
83
119
|
initialValues: initValue,
|
|
84
120
|
onValuesChange: onValuesChange
|
|
85
121
|
}, props), {}, {
|
|
86
122
|
form: currentForm,
|
|
87
123
|
params: formParams,
|
|
88
|
-
onFinish:
|
|
89
|
-
var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
90
|
-
var result, close;
|
|
91
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
92
|
-
while (1) switch (_context.prev = _context.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
_context.next = 2;
|
|
95
|
-
return run(values, subParams);
|
|
96
|
-
case 2:
|
|
97
|
-
result = _context.sent;
|
|
98
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, subParams);
|
|
99
|
-
if (!(close === false)) {
|
|
100
|
-
_context.next = 6;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
return _context.abrupt("return");
|
|
104
|
-
case 6:
|
|
105
|
-
cancel();
|
|
106
|
-
case 7:
|
|
107
|
-
case "end":
|
|
108
|
-
return _context.stop();
|
|
109
|
-
}
|
|
110
|
-
}, _callee);
|
|
111
|
-
}));
|
|
112
|
-
function onFinish(_x, _x2) {
|
|
113
|
-
return _onFinish.apply(this, arguments);
|
|
114
|
-
}
|
|
115
|
-
return onFinish;
|
|
116
|
-
}(),
|
|
124
|
+
onFinish: finish,
|
|
117
125
|
infoRequest: infoRequest,
|
|
118
126
|
labelWidth: labelWidth
|
|
119
127
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
2
|
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
5
|
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -62,39 +62,46 @@ var Index = function Index(_ref) {
|
|
|
62
62
|
}),
|
|
63
63
|
loading = _useSub.loading,
|
|
64
64
|
run = _useSub.run;
|
|
65
|
-
var
|
|
65
|
+
var finish = /*#__PURE__*/function () {
|
|
66
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
67
|
+
var result, close;
|
|
68
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
69
|
+
while (1) switch (_context.prev = _context.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
_context.next = 2;
|
|
72
|
+
return run(values, outParams);
|
|
73
|
+
case 2:
|
|
74
|
+
result = _context.sent;
|
|
75
|
+
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
76
|
+
if (!(close === false)) {
|
|
77
|
+
_context.next = 6;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
return _context.abrupt("return");
|
|
81
|
+
case 6:
|
|
82
|
+
cancel();
|
|
83
|
+
case 7:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context.stop();
|
|
86
|
+
}
|
|
87
|
+
}, _callee);
|
|
88
|
+
}));
|
|
89
|
+
return function finish(_x, _x2) {
|
|
90
|
+
return _ref2.apply(this, arguments);
|
|
91
|
+
};
|
|
92
|
+
}();
|
|
93
|
+
var footerOnOk = function footerOnOk() {
|
|
94
|
+
if (modalFormData) {
|
|
95
|
+
dialogForm === null || dialogForm === void 0 || dialogForm.submit();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
finish({}, formParams);
|
|
99
|
+
};
|
|
100
|
+
var node = modalFormData && jsx(HForm, _objectSpread(_objectSpread({
|
|
66
101
|
configData: modalFormData,
|
|
67
102
|
initialValues: initValue,
|
|
68
103
|
onValuesChange: onValuesChange,
|
|
69
|
-
onFinish:
|
|
70
|
-
var _onFinish = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
71
|
-
var result, close;
|
|
72
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
73
|
-
while (1) switch (_context.prev = _context.next) {
|
|
74
|
-
case 0:
|
|
75
|
-
_context.next = 2;
|
|
76
|
-
return run(values, outParams);
|
|
77
|
-
case 2:
|
|
78
|
-
result = _context.sent;
|
|
79
|
-
close = onOk === null || onOk === void 0 ? void 0 : onOk(result, outParams);
|
|
80
|
-
if (!(close === false)) {
|
|
81
|
-
_context.next = 6;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
return _context.abrupt("return");
|
|
85
|
-
case 6:
|
|
86
|
-
cancel();
|
|
87
|
-
case 7:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
91
|
-
}, _callee);
|
|
92
|
-
}));
|
|
93
|
-
function onFinish(_x, _x2) {
|
|
94
|
-
return _onFinish.apply(this, arguments);
|
|
95
|
-
}
|
|
96
|
-
return onFinish;
|
|
97
|
-
}()
|
|
104
|
+
onFinish: finish
|
|
98
105
|
}, props), {}, {
|
|
99
106
|
params: formParams,
|
|
100
107
|
form: currentForm,
|
|
@@ -104,7 +111,8 @@ var Index = function Index(_ref) {
|
|
|
104
111
|
dialogForm: dialogForm,
|
|
105
112
|
footer: footer,
|
|
106
113
|
confirmLoading: loading,
|
|
107
|
-
params: formParams
|
|
114
|
+
params: formParams,
|
|
115
|
+
onOk: footerOnOk
|
|
108
116
|
});
|
|
109
117
|
return jsx(Modal, _objectSpread(_objectSpread({
|
|
110
118
|
title: modalTitle,
|
package/es/DialogForm/hooks.d.ts
CHANGED
|
@@ -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/es/DialogForm/hooks.js
CHANGED
|
@@ -154,7 +154,8 @@ var useFooterRender = function useFooterRender(_ref4) {
|
|
|
154
154
|
var footer = _ref4.footer,
|
|
155
155
|
confirmLoading = _ref4.confirmLoading,
|
|
156
156
|
dialogForm = _ref4.dialogForm,
|
|
157
|
-
params = _ref4.params
|
|
157
|
+
params = _ref4.params,
|
|
158
|
+
onOk = _ref4.onOk;
|
|
158
159
|
if (footer === null) {
|
|
159
160
|
return null;
|
|
160
161
|
}
|
|
@@ -165,9 +166,7 @@ var useFooterRender = function useFooterRender(_ref4) {
|
|
|
165
166
|
onCancel: function onCancel() {
|
|
166
167
|
dialogForm === null || dialogForm === void 0 || dialogForm.hide();
|
|
167
168
|
},
|
|
168
|
-
onOk:
|
|
169
|
-
dialogForm === null || dialogForm === void 0 || dialogForm.submit();
|
|
170
|
-
},
|
|
169
|
+
onOk: onOk,
|
|
171
170
|
confirmLoading: confirmLoading
|
|
172
171
|
});
|
|
173
172
|
};
|
package/es/DialogForm/modal.d.ts
CHANGED
|
@@ -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/es/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;
|
|
@@ -3,6 +3,7 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useFormItemDomControl } from './hooks.js';
|
|
5
5
|
import { useFormContext } from '../Context/index.js';
|
|
6
|
+
import useAddFormat 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; }
|
|
@@ -25,6 +26,7 @@ var Item = (function (props) {
|
|
|
25
26
|
colon = props.colon,
|
|
26
27
|
_props$rowWrapper = props.rowWrapper,
|
|
27
28
|
rowWrapper = _props$rowWrapper === void 0 ? formRowWrapper : _props$rowWrapper;
|
|
29
|
+
useAddFormat(props);
|
|
28
30
|
var Component = useFormItemDomControl(props);
|
|
29
31
|
return jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
|
|
30
32
|
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/es/Form/HFormConnect.js
CHANGED
|
@@ -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
|
|
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;
|
package/es/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/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 };
|
package/es/Form/hooks/index.d.ts
CHANGED
|
@@ -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
|
package/es/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,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
|