@hw-component/form 1.9.76 → 1.9.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/TextArea/index.d.ts +1 -1
- package/es/TextArea/index.js +8 -4
- package/es/Upload/Btn.d.ts +1 -1
- package/es/Upload/Btn.js +15 -2
- package/es/Upload/index.js +9 -3
- package/es/Upload/modal.d.ts +4 -1
- package/lib/TextArea/index.d.ts +1 -1
- package/lib/TextArea/index.js +8 -4
- package/lib/Upload/Btn.d.ts +1 -1
- package/lib/Upload/Btn.js +14 -1
- package/lib/Upload/index.js +9 -3
- package/lib/Upload/modal.d.ts +4 -1
- package/package.json +1 -1
- package/src/components/TextArea/index.tsx +3 -1
- package/src/components/Upload/Btn.tsx +11 -4
- package/src/components/Upload/hooks/customRequest.ts +1 -1
- package/src/components/Upload/index.tsx +10 -2
- package/src/components/Upload/modal.ts +4 -1
- package/src/pages/Form/index.tsx +6 -2
- package/src/pages/ModalForm/index.tsx +11 -8
- package/src/pages/Upload/index.tsx +6 -2
package/es/TextArea/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { TextAreaProps } from "antd/es/input";
|
|
|
2
2
|
export interface HTextAreaProps extends TextAreaProps {
|
|
3
3
|
bordered?: boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: ({ autoSize, bordered, className, ...props }: HTextAreaProps) => JSX.Element;
|
|
5
|
+
declare const _default: ({ autoSize, bordered, className, style, ...props }: HTextAreaProps) => JSX.Element;
|
|
6
6
|
export default _default;
|
package/es/TextArea/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
5
5
|
import { Input } from 'antd';
|
|
6
6
|
import { useClassName } from '../hooks/index.js';
|
|
7
7
|
|
|
8
|
-
var _excluded = ["autoSize", "bordered", "className"];
|
|
8
|
+
var _excluded = ["autoSize", "bordered", "className", "style"];
|
|
9
9
|
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; }
|
|
10
10
|
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; }
|
|
11
11
|
var TextArea = (function (_ref) {
|
|
@@ -16,13 +16,17 @@ var TextArea = (function (_ref) {
|
|
|
16
16
|
} : _ref$autoSize,
|
|
17
17
|
_ref$bordered = _ref.bordered,
|
|
18
18
|
bordered = _ref$bordered === void 0 ? true : _ref$bordered,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
className = _ref.className,
|
|
20
|
+
_ref$style = _ref.style,
|
|
21
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
21
22
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
23
|
var noBorderClassName = useClassName("hw-text-area-no-border");
|
|
23
24
|
var borderClassName = !bordered ? noBorderClassName : "";
|
|
24
25
|
return jsx(Input.TextArea, _objectSpread(_objectSpread({
|
|
25
|
-
autoSize: autoSize
|
|
26
|
+
autoSize: autoSize,
|
|
27
|
+
style: _objectSpread({
|
|
28
|
+
width: "100%"
|
|
29
|
+
}, style)
|
|
26
30
|
}, props), {}, {
|
|
27
31
|
className: "".concat(borderClassName, " ").concat(className)
|
|
28
32
|
}));
|
package/es/Upload/Btn.d.ts
CHANGED
package/es/Upload/Btn.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useMemo } from 'react';
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
5
|
import { Button } from 'antd';
|
|
6
6
|
|
|
7
7
|
var Btn = (function (_ref) {
|
|
8
8
|
var value = _ref.value,
|
|
9
9
|
_ref$maxCount = _ref.maxCount,
|
|
10
10
|
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
11
|
-
listType = _ref.listType
|
|
11
|
+
listType = _ref.listType,
|
|
12
|
+
children = _ref.children;
|
|
12
13
|
var len = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
13
14
|
var text = useMemo(function () {
|
|
14
15
|
if (len === maxCount) {
|
|
@@ -26,8 +27,20 @@ var Btn = (function (_ref) {
|
|
|
26
27
|
})]
|
|
27
28
|
});
|
|
28
29
|
}
|
|
30
|
+
var loading = useMemo(function () {
|
|
31
|
+
return value === null || value === void 0 ? void 0 : value.some(function (_ref2) {
|
|
32
|
+
var status = _ref2.status;
|
|
33
|
+
return status === "uploading";
|
|
34
|
+
});
|
|
35
|
+
}, [value]);
|
|
36
|
+
if (children) {
|
|
37
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
38
|
+
loading: loading
|
|
39
|
+
});
|
|
40
|
+
}
|
|
29
41
|
return jsx(Button, {
|
|
30
42
|
icon: jsx(UploadOutlined, {}),
|
|
43
|
+
loading: loading,
|
|
31
44
|
children: text
|
|
32
45
|
});
|
|
33
46
|
});
|
package/es/Upload/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Upload } from 'antd';
|
|
|
11
11
|
import Btn from './Btn.js';
|
|
12
12
|
import HFormConnect from '../Form/HFormConnect.js';
|
|
13
13
|
|
|
14
|
-
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn"];
|
|
14
|
+
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn", "children"];
|
|
15
15
|
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; }
|
|
16
16
|
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; }
|
|
17
17
|
var Index = function Index(_ref, ref) {
|
|
@@ -31,6 +31,7 @@ var Index = function Index(_ref, ref) {
|
|
|
31
31
|
addFormat = _ref.addFormat,
|
|
32
32
|
thumbUrl = _ref.thumbUrl,
|
|
33
33
|
hideAddBtn = _ref.hideAddBtn,
|
|
34
|
+
children = _ref.children,
|
|
34
35
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
36
|
var matchProps = useProps({
|
|
36
37
|
request: request,
|
|
@@ -62,6 +63,9 @@ var Index = function Index(_ref, ref) {
|
|
|
62
63
|
};
|
|
63
64
|
}, [maxRowNum, listType]);
|
|
64
65
|
var preview = function preview(file) {
|
|
66
|
+
if (onPreview === null) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
65
69
|
if (onPreview) {
|
|
66
70
|
onPreview(file);
|
|
67
71
|
return;
|
|
@@ -110,10 +114,11 @@ var Index = function Index(_ref, ref) {
|
|
|
110
114
|
}
|
|
111
115
|
});
|
|
112
116
|
var relVal = Array.isArray(value) ? value : [];
|
|
117
|
+
var upListType = listType === null ? undefined : listType;
|
|
113
118
|
return jsxs("div", {
|
|
114
119
|
style: contentStyle,
|
|
115
120
|
children: [jsx(Upload, _objectSpread(_objectSpread({
|
|
116
|
-
listType:
|
|
121
|
+
listType: upListType,
|
|
117
122
|
maxCount: maxNum,
|
|
118
123
|
fileList: relVal,
|
|
119
124
|
onPreview: preview,
|
|
@@ -125,7 +130,8 @@ var Index = function Index(_ref, ref) {
|
|
|
125
130
|
children: hideAddBtn ? null : jsx(Btn, {
|
|
126
131
|
value: relVal,
|
|
127
132
|
maxCount: maxCount,
|
|
128
|
-
listType:
|
|
133
|
+
listType: upListType,
|
|
134
|
+
children: children
|
|
129
135
|
})
|
|
130
136
|
})), jsx(Preview, {
|
|
131
137
|
visible: visible,
|
package/es/Upload/modal.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
|
|
|
5
5
|
import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
6
6
|
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
7
7
|
import type React from "react";
|
|
8
|
-
|
|
8
|
+
import { UploadListType } from "antd/lib/upload/interface";
|
|
9
|
+
export interface IUpLoadProps extends Omit<UploadProps, "onChange" | "listType" | "onPreview"> {
|
|
9
10
|
exFiles?: string[] | null;
|
|
10
11
|
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
11
12
|
url: string;
|
|
@@ -19,6 +20,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
19
20
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
21
|
thumbUrl?: string;
|
|
21
22
|
hideAddBtn?: boolean;
|
|
23
|
+
listType?: UploadListType | null;
|
|
24
|
+
onPreview?: UploadProps["onPreview"] | null;
|
|
22
25
|
}
|
|
23
26
|
export interface IMediaTypeEleProps {
|
|
24
27
|
file?: UploadFile;
|
package/lib/TextArea/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { TextAreaProps } from "antd/es/input";
|
|
|
2
2
|
export interface HTextAreaProps extends TextAreaProps {
|
|
3
3
|
bordered?: boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: ({ autoSize, bordered, className, ...props }: HTextAreaProps) => JSX.Element;
|
|
5
|
+
declare const _default: ({ autoSize, bordered, className, style, ...props }: HTextAreaProps) => JSX.Element;
|
|
6
6
|
export default _default;
|
package/lib/TextArea/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
8
8
|
var antd = require('antd');
|
|
9
9
|
var index = require('../hooks/index.js');
|
|
10
10
|
|
|
11
|
-
var _excluded = ["autoSize", "bordered", "className"];
|
|
11
|
+
var _excluded = ["autoSize", "bordered", "className", "style"];
|
|
12
12
|
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; }
|
|
13
13
|
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; }
|
|
14
14
|
var TextArea = (function (_ref) {
|
|
@@ -19,13 +19,17 @@ var TextArea = (function (_ref) {
|
|
|
19
19
|
} : _ref$autoSize,
|
|
20
20
|
_ref$bordered = _ref.bordered,
|
|
21
21
|
bordered = _ref$bordered === void 0 ? true : _ref$bordered,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
_ref$style = _ref.style,
|
|
24
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
24
25
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
26
|
var noBorderClassName = index.useClassName("hw-text-area-no-border");
|
|
26
27
|
var borderClassName = !bordered ? noBorderClassName : "";
|
|
27
28
|
return jsxRuntime.jsx(antd.Input.TextArea, _objectSpread(_objectSpread({
|
|
28
|
-
autoSize: autoSize
|
|
29
|
+
autoSize: autoSize,
|
|
30
|
+
style: _objectSpread({
|
|
31
|
+
width: "100%"
|
|
32
|
+
}, style)
|
|
29
33
|
}, props), {}, {
|
|
30
34
|
className: "".concat(borderClassName, " ").concat(className)
|
|
31
35
|
}));
|
package/lib/Upload/Btn.d.ts
CHANGED
package/lib/Upload/Btn.js
CHANGED
|
@@ -11,7 +11,8 @@ var Btn = (function (_ref) {
|
|
|
11
11
|
var value = _ref.value,
|
|
12
12
|
_ref$maxCount = _ref.maxCount,
|
|
13
13
|
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
14
|
-
listType = _ref.listType
|
|
14
|
+
listType = _ref.listType,
|
|
15
|
+
children = _ref.children;
|
|
15
16
|
var len = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
16
17
|
var text = React.useMemo(function () {
|
|
17
18
|
if (len === maxCount) {
|
|
@@ -29,8 +30,20 @@ var Btn = (function (_ref) {
|
|
|
29
30
|
})]
|
|
30
31
|
});
|
|
31
32
|
}
|
|
33
|
+
var loading = React.useMemo(function () {
|
|
34
|
+
return value === null || value === void 0 ? void 0 : value.some(function (_ref2) {
|
|
35
|
+
var status = _ref2.status;
|
|
36
|
+
return status === "uploading";
|
|
37
|
+
});
|
|
38
|
+
}, [value]);
|
|
39
|
+
if (children) {
|
|
40
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
41
|
+
loading: loading
|
|
42
|
+
});
|
|
43
|
+
}
|
|
32
44
|
return jsxRuntime.jsx(antd.Button, {
|
|
33
45
|
icon: jsxRuntime.jsx(icons.UploadOutlined, {}),
|
|
46
|
+
loading: loading,
|
|
34
47
|
children: text
|
|
35
48
|
});
|
|
36
49
|
});
|
package/lib/Upload/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var antd = require('antd');
|
|
|
14
14
|
var Btn = require('./Btn.js');
|
|
15
15
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
16
16
|
|
|
17
|
-
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn"];
|
|
17
|
+
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn", "children"];
|
|
18
18
|
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; }
|
|
19
19
|
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; }
|
|
20
20
|
var Index = function Index(_ref, ref) {
|
|
@@ -34,6 +34,7 @@ var Index = function Index(_ref, ref) {
|
|
|
34
34
|
addFormat = _ref.addFormat,
|
|
35
35
|
thumbUrl = _ref.thumbUrl,
|
|
36
36
|
hideAddBtn = _ref.hideAddBtn,
|
|
37
|
+
children = _ref.children,
|
|
37
38
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
38
39
|
var matchProps = propsMaker.useProps({
|
|
39
40
|
request: request,
|
|
@@ -65,6 +66,9 @@ var Index = function Index(_ref, ref) {
|
|
|
65
66
|
};
|
|
66
67
|
}, [maxRowNum, listType]);
|
|
67
68
|
var preview = function preview(file) {
|
|
69
|
+
if (onPreview === null) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
68
72
|
if (onPreview) {
|
|
69
73
|
onPreview(file);
|
|
70
74
|
return;
|
|
@@ -113,10 +117,11 @@ var Index = function Index(_ref, ref) {
|
|
|
113
117
|
}
|
|
114
118
|
});
|
|
115
119
|
var relVal = Array.isArray(value) ? value : [];
|
|
120
|
+
var upListType = listType === null ? undefined : listType;
|
|
116
121
|
return jsxRuntime.jsxs("div", {
|
|
117
122
|
style: contentStyle,
|
|
118
123
|
children: [jsxRuntime.jsx(antd.Upload, _objectSpread(_objectSpread({
|
|
119
|
-
listType:
|
|
124
|
+
listType: upListType,
|
|
120
125
|
maxCount: maxNum,
|
|
121
126
|
fileList: relVal,
|
|
122
127
|
onPreview: preview,
|
|
@@ -128,7 +133,8 @@ var Index = function Index(_ref, ref) {
|
|
|
128
133
|
children: hideAddBtn ? null : jsxRuntime.jsx(Btn.default, {
|
|
129
134
|
value: relVal,
|
|
130
135
|
maxCount: maxCount,
|
|
131
|
-
listType:
|
|
136
|
+
listType: upListType,
|
|
137
|
+
children: children
|
|
132
138
|
})
|
|
133
139
|
})), jsxRuntime.jsx(index.default, {
|
|
134
140
|
visible: visible,
|
package/lib/Upload/modal.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
|
|
|
5
5
|
import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
6
6
|
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
7
7
|
import type React from "react";
|
|
8
|
-
|
|
8
|
+
import { UploadListType } from "antd/lib/upload/interface";
|
|
9
|
+
export interface IUpLoadProps extends Omit<UploadProps, "onChange" | "listType" | "onPreview"> {
|
|
9
10
|
exFiles?: string[] | null;
|
|
10
11
|
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
11
12
|
url: string;
|
|
@@ -19,6 +20,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
19
20
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
21
|
thumbUrl?: string;
|
|
21
22
|
hideAddBtn?: boolean;
|
|
23
|
+
listType?: UploadListType | null;
|
|
24
|
+
onPreview?: UploadProps["onPreview"] | null;
|
|
22
25
|
}
|
|
23
26
|
export interface IMediaTypeEleProps {
|
|
24
27
|
file?: UploadFile;
|
package/package.json
CHANGED
|
@@ -8,7 +8,8 @@ export interface HTextAreaProps extends TextAreaProps {
|
|
|
8
8
|
export default ({
|
|
9
9
|
autoSize = { minRows: 4, maxRows: 4 },
|
|
10
10
|
bordered = true,
|
|
11
|
-
className
|
|
11
|
+
className,
|
|
12
|
+
style={},
|
|
12
13
|
...props
|
|
13
14
|
}: HTextAreaProps) => {
|
|
14
15
|
const noBorderClassName = useClassName("hw-text-area-no-border");
|
|
@@ -16,6 +17,7 @@ export default ({
|
|
|
16
17
|
return (
|
|
17
18
|
<Input.TextArea
|
|
18
19
|
autoSize={autoSize}
|
|
20
|
+
style={{width:"100%",...style}}
|
|
19
21
|
{...props}
|
|
20
22
|
className={`${borderClassName} ${className}`}
|
|
21
23
|
/>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PlusOutlined, UploadOutlined } from "@ant-design/icons";
|
|
2
2
|
import type { IUpLoadProps } from "./modal";
|
|
3
|
-
import { useMemo } from "react";
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
4
|
import { Button } from "antd";
|
|
5
5
|
|
|
6
|
-
export default ({ value, maxCount = 1, listType }: IUpLoadProps) => {
|
|
6
|
+
export default ({ value, maxCount = 1, listType ,children}: IUpLoadProps) => {
|
|
7
7
|
const len = value?.length || 0;
|
|
8
8
|
const text = useMemo(() => {
|
|
9
9
|
if (len === maxCount) {
|
|
@@ -11,7 +11,6 @@ export default ({ value, maxCount = 1, listType }: IUpLoadProps) => {
|
|
|
11
11
|
}
|
|
12
12
|
return "上传";
|
|
13
13
|
}, [len, maxCount]);
|
|
14
|
-
|
|
15
14
|
if (listType === "picture-card") {
|
|
16
15
|
return (
|
|
17
16
|
<div>
|
|
@@ -20,5 +19,13 @@ export default ({ value, maxCount = 1, listType }: IUpLoadProps) => {
|
|
|
20
19
|
</div>
|
|
21
20
|
);
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
const loading=useMemo(()=>{
|
|
23
|
+
return value?.some(({status})=>{
|
|
24
|
+
return status==="uploading";
|
|
25
|
+
})
|
|
26
|
+
},[value]);
|
|
27
|
+
if (children){
|
|
28
|
+
return React.cloneElement<any>((children as any),{loading});
|
|
29
|
+
}
|
|
30
|
+
return <Button icon={<UploadOutlined />} loading={loading}>{text}</Button>;
|
|
24
31
|
};
|
|
@@ -4,6 +4,7 @@ import type { RcFile } from "antd/lib/upload";
|
|
|
4
4
|
import { useEffect, useMemo } from "react";
|
|
5
5
|
import type { UploadFileStatus } from "antd/es/upload/interface";
|
|
6
6
|
import { message } from "antd";
|
|
7
|
+
import {useRequest} from "ahooks";
|
|
7
8
|
|
|
8
9
|
interface SubReqParamsModal {
|
|
9
10
|
request?: IUpLoadProps["request"];
|
|
@@ -73,7 +74,6 @@ export const useCustomRequest = ({
|
|
|
73
74
|
useEffect(() => {
|
|
74
75
|
valObj.value = value;
|
|
75
76
|
}, [value]); //强制同步避免闭包问题
|
|
76
|
-
|
|
77
77
|
const sendFile = async (file: RcFile) => {
|
|
78
78
|
const { uid } = file;
|
|
79
79
|
const result = await subReq({ request, file });
|
|
@@ -22,6 +22,8 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
22
22
|
addFormat,
|
|
23
23
|
thumbUrl,
|
|
24
24
|
hideAddBtn,
|
|
25
|
+
children,
|
|
26
|
+
|
|
25
27
|
...props
|
|
26
28
|
},
|
|
27
29
|
ref
|
|
@@ -48,6 +50,9 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
48
50
|
}, [maxRowNum, listType]);
|
|
49
51
|
|
|
50
52
|
const preview = (file) => {
|
|
53
|
+
if (onPreview===null){
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
51
56
|
if (onPreview) {
|
|
52
57
|
onPreview(file);
|
|
53
58
|
return;
|
|
@@ -97,10 +102,11 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
97
102
|
},
|
|
98
103
|
});
|
|
99
104
|
const relVal = Array.isArray(value) ? value : [];
|
|
105
|
+
const upListType=listType===null?undefined:listType;
|
|
100
106
|
return (
|
|
101
107
|
<div style={contentStyle}>
|
|
102
108
|
<Upload
|
|
103
|
-
listType={
|
|
109
|
+
listType={upListType}
|
|
104
110
|
maxCount={maxNum}
|
|
105
111
|
fileList={relVal}
|
|
106
112
|
onPreview={preview}
|
|
@@ -111,7 +117,9 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
111
117
|
{...props}
|
|
112
118
|
>
|
|
113
119
|
{hideAddBtn ? null : (
|
|
114
|
-
|
|
120
|
+
<Btn value={relVal} maxCount={maxCount} listType={upListType} >
|
|
121
|
+
{children}
|
|
122
|
+
</Btn>
|
|
115
123
|
)}
|
|
116
124
|
</Upload>
|
|
117
125
|
<Preview
|
|
@@ -5,8 +5,9 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
|
|
|
5
5
|
import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
6
6
|
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
7
7
|
import type React from "react";
|
|
8
|
+
import {UploadListType} from "antd/lib/upload/interface";
|
|
8
9
|
|
|
9
|
-
export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
10
|
+
export interface IUpLoadProps extends Omit<UploadProps, "onChange"|"listType"|"onPreview"> {
|
|
10
11
|
exFiles?: string[] | null;
|
|
11
12
|
request?: (
|
|
12
13
|
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
@@ -19,6 +20,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
19
20
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
21
|
thumbUrl?: string;
|
|
21
22
|
hideAddBtn?: boolean;
|
|
23
|
+
listType?:UploadListType|null;
|
|
24
|
+
onPreview?:UploadProps["onPreview"]|null
|
|
22
25
|
}
|
|
23
26
|
export interface IMediaTypeEleProps {
|
|
24
27
|
file?: UploadFile;
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -90,8 +90,12 @@ export default () => {
|
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
label: "富文本",
|
|
93
|
-
type: "
|
|
94
|
-
name: "
|
|
93
|
+
type: "textArea",
|
|
94
|
+
name: "textArea",
|
|
95
|
+
itemProps:{
|
|
96
|
+
showCount:true,
|
|
97
|
+
maxLength:100
|
|
98
|
+
},
|
|
95
99
|
rules: [
|
|
96
100
|
{
|
|
97
101
|
validator: (rule, value, callback) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Button, Input} from "antd";
|
|
2
2
|
import {
|
|
3
3
|
HModalForm,
|
|
4
4
|
useHDialogForm,
|
|
@@ -11,18 +11,20 @@ import { ShowParamsModal } from "@/components/DialogForm/modal";
|
|
|
11
11
|
const Test = (props) => {
|
|
12
12
|
return <HUrlUpload {...props} />;
|
|
13
13
|
};
|
|
14
|
+
const ITest=()=>{
|
|
15
|
+
return <Input onPressEnter={(e)=>{
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
console.log("ITest")
|
|
18
|
+
}}/>
|
|
19
|
+
}
|
|
14
20
|
const data = [
|
|
15
21
|
{
|
|
16
22
|
label: "输入框",
|
|
17
23
|
name: "name",
|
|
18
24
|
hideLabel: true,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
required: true,
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
],
|
|
25
|
+
render:()=>{
|
|
26
|
+
return <ITest/>
|
|
27
|
+
},
|
|
26
28
|
},
|
|
27
29
|
// {
|
|
28
30
|
// label: "数字",
|
|
@@ -203,6 +205,7 @@ export default () => {
|
|
|
203
205
|
marginBottom: 100,
|
|
204
206
|
}}
|
|
205
207
|
onOk={() => {
|
|
208
|
+
console.log("fff")
|
|
206
209
|
return false;
|
|
207
210
|
}}
|
|
208
211
|
infoRequest={() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Space
|
|
1
|
+
import {Button, Space} from "antd";
|
|
2
2
|
import { HUpload, HUrlUpload } from "../../components";
|
|
3
3
|
import React, { useState } from "react";
|
|
4
4
|
import { MediaTypeEnum } from "../../components/Upload/enums";
|
|
@@ -26,11 +26,15 @@ export default () => {
|
|
|
26
26
|
value={files1}
|
|
27
27
|
hideAddBtn={false}
|
|
28
28
|
mediaType={MediaTypeEnum.file}
|
|
29
|
+
listType={null}
|
|
30
|
+
onPreview={false}
|
|
29
31
|
showUploadList={{
|
|
30
32
|
showPreviewIcon: false,
|
|
31
33
|
}}
|
|
32
34
|
onChange={setFiles1}
|
|
33
|
-
|
|
35
|
+
>
|
|
36
|
+
<Button>按钮</Button>
|
|
37
|
+
</HUpload>
|
|
34
38
|
<HUrlUpload
|
|
35
39
|
inputHelper="测试"
|
|
36
40
|
mediaType={MediaTypeEnum.video}
|