@ccs-ui/rc-pro 2.2.4-beta-1 → 2.2.4
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/color-picker/index.d.ts +2 -15
- package/es/color-picker/index.js +122 -51
- package/es/color-picker/index.less +5 -6
- package/es/dialog/HookModal.js +0 -1
- package/es/dialog/button.d.ts +1 -1
- package/es/upload/index.d.ts +21 -1
- package/es/upload/index.js +56 -9
- package/es/upload/upload-image.d.ts +1 -1
- package/es/upload/upload-image.js +42 -21
- package/package.json +2 -3
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PropsWithCss } from '../ccs';
|
|
1
|
+
import { ColorPickerProps } from 'antd';
|
|
3
2
|
import './index.less';
|
|
4
|
-
export
|
|
5
|
-
/** 指定选中项 */
|
|
6
|
-
value?: RGBColor;
|
|
7
|
-
/** 占位 */
|
|
8
|
-
placeholder?: string;
|
|
9
|
-
/** 选择完成后的回调 */
|
|
10
|
-
onChange?: (value: RGBColor) => void;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* 颜色选择组件
|
|
14
|
-
*/
|
|
15
|
-
declare const ColorPicker: ({ onChange, value, style }: PropsType) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export default ColorPicker;
|
|
3
|
+
export default function CcsColorPicker({ mode, children, onChange, ...otherProps }: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
|
package/es/color-picker/index.js
CHANGED
|
@@ -1,67 +1,138 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["mode", "children", "onChange"];
|
|
2
3
|
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; }
|
|
3
4
|
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; }
|
|
4
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
10
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
11
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
12
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
13
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
14
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import { useState } from 'react';
|
|
16
|
-
import { SketchPicker } from 'react-color';
|
|
16
|
+
import { blue, cyan, gray, green, magenta, orange, presetPalettes, red } from '@ant-design/colors';
|
|
17
|
+
import { Col, ColorPicker, Divider, Row, Select } from 'antd';
|
|
17
18
|
import "./index.less";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
+
function genPresets() {
|
|
23
|
+
var presets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : presetPalettes;
|
|
24
|
+
return Object.entries(presets).map(function (_ref) {
|
|
25
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
26
|
+
label = _ref2[0],
|
|
27
|
+
colors = _ref2[1];
|
|
28
|
+
return {
|
|
29
|
+
label: label,
|
|
30
|
+
colors: colors,
|
|
31
|
+
key: label
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var presets = genPresets({
|
|
36
|
+
blue: blue,
|
|
37
|
+
red: red,
|
|
38
|
+
green: green,
|
|
39
|
+
cyan: cyan,
|
|
40
|
+
orange: orange,
|
|
41
|
+
magenta: magenta,
|
|
42
|
+
gray: gray
|
|
43
|
+
});
|
|
44
|
+
presets.forEach(function (f) {
|
|
45
|
+
f.colors = f.colors.slice(0, 6);
|
|
46
|
+
});
|
|
47
|
+
export default function CcsColorPicker(_ref3) {
|
|
48
|
+
var _ref3$mode = _ref3.mode,
|
|
49
|
+
mode = _ref3$mode === void 0 ? 'single' : _ref3$mode,
|
|
50
|
+
children = _ref3.children,
|
|
51
|
+
_onChange = _ref3.onChange,
|
|
52
|
+
otherProps = _objectWithoutProperties(_ref3, _excluded);
|
|
53
|
+
var renderValueStr = function renderValueStr() {
|
|
54
|
+
var value = otherProps.value;
|
|
55
|
+
if (typeof value === 'string') {
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
return "linear-gradient(".concat(value.map(function (s) {
|
|
60
|
+
return "".concat(s.color, " ").concat(s.percent, "%");
|
|
61
|
+
}).join(','), ")");
|
|
62
|
+
}
|
|
33
63
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
children: /*#__PURE__*/_jsx(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
64
|
+
var customPanelRender = function customPanelRender(_, _ref4) {
|
|
65
|
+
var _ref4$components = _ref4.components,
|
|
66
|
+
Picker = _ref4$components.Picker,
|
|
67
|
+
Presets = _ref4$components.Presets;
|
|
68
|
+
return /*#__PURE__*/_jsxs(Row, {
|
|
69
|
+
justify: "space-between",
|
|
70
|
+
wrap: false,
|
|
71
|
+
style: {
|
|
72
|
+
width: 420
|
|
73
|
+
},
|
|
74
|
+
children: [/*#__PURE__*/_jsx(Col, {
|
|
75
|
+
span: 12,
|
|
76
|
+
children: /*#__PURE__*/_jsx(Presets, {})
|
|
77
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
|
78
|
+
type: "vertical",
|
|
79
|
+
style: {
|
|
80
|
+
height: 'auto'
|
|
81
|
+
}
|
|
82
|
+
}), /*#__PURE__*/_jsxs(Col, {
|
|
83
|
+
flex: "auto",
|
|
84
|
+
children: [/*#__PURE__*/_jsx(Picker, {}), /*#__PURE__*/_jsx("div", {
|
|
56
85
|
style: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
86
|
+
marginTop: 10,
|
|
87
|
+
color: 'rgba(0,0,0,0.65)'
|
|
88
|
+
},
|
|
89
|
+
children: renderValueStr()
|
|
90
|
+
})]
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var renderValue = function renderValue() {
|
|
95
|
+
if (!otherProps.value) {
|
|
96
|
+
return /*#__PURE__*/_jsx(Select, {
|
|
97
|
+
popupClassName: "ccs-color-picker-select",
|
|
98
|
+
placeholder: "\u8BF7\u9009\u62E9",
|
|
99
|
+
dropdownRender: function dropdownRender() {
|
|
100
|
+
return /*#__PURE__*/_jsx(_Fragment, {});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
};
|
|
106
|
+
return /*#__PURE__*/_jsx(ColorPicker, _objectSpread(_objectSpread({
|
|
107
|
+
className: "ccs-color-picker",
|
|
108
|
+
allowClear: true,
|
|
109
|
+
showText: true,
|
|
110
|
+
mode: mode,
|
|
111
|
+
onChange: function onChange(value, css) {
|
|
112
|
+
if (!_onChange) return;
|
|
113
|
+
var colors = value.getColors();
|
|
114
|
+
// 渐变色
|
|
115
|
+
if (colors.length > 1) {
|
|
116
|
+
var gradientColors = colors.map(function (c) {
|
|
117
|
+
return {
|
|
118
|
+
color: c.color.toRgbString(),
|
|
119
|
+
percent: c.percent
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
_onChange(gradientColors, css);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (colors.length === 1) {
|
|
126
|
+
_onChange(value.toCssString(), css);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
onClear: function onClear() {
|
|
131
|
+
if (_onChange) _onChange(undefined, '');
|
|
132
|
+
},
|
|
133
|
+
presets: presets,
|
|
134
|
+
panelRender: customPanelRender
|
|
135
|
+
}, otherProps), {}, {
|
|
136
|
+
children: children || renderValue()
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
padding: 0 !important;
|
|
1
|
+
.ccs-color-picker {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: start;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
|
-
.
|
|
8
|
-
|
|
6
|
+
.ccs-color-picker-select {
|
|
7
|
+
display: none !important;
|
|
9
8
|
}
|
package/es/dialog/HookModal.js
CHANGED
|
@@ -155,7 +155,6 @@ var HookModal = function HookModal(props) {
|
|
|
155
155
|
requestFieldNames: requestFieldNames
|
|
156
156
|
});
|
|
157
157
|
}, []);
|
|
158
|
-
console.log('footer', footer);
|
|
159
158
|
return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
|
|
160
159
|
onCancel: onHandleClose,
|
|
161
160
|
afterClose: afterClose
|
package/es/dialog/button.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
|
|
|
16
16
|
export type DialogButtonRef = {
|
|
17
17
|
onSetButtons: (e: React.ReactElement) => void;
|
|
18
18
|
};
|
|
19
|
-
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "
|
|
19
|
+
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onOk" | "onClose" | "auth" | "extraBtn" | "preventRequestHandle" | "requestFieldNames" | "request"> & {
|
|
20
20
|
formRef: React.RefObject<DialogFormRef<TParams>>;
|
|
21
21
|
formInitialValues: FormProps['initialValues'];
|
|
22
22
|
buttonRef: RefObject<DialogButtonRef>;
|
package/es/upload/index.d.ts
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import { UploadProps } from 'antd';
|
|
2
|
+
import { UploadChangeParam } from 'antd/es/upload';
|
|
2
3
|
import { RecordType } from '../ccs';
|
|
3
4
|
import { ImageUpload } from './upload-image';
|
|
5
|
+
type FileValue = {
|
|
6
|
+
/** 文件ID */
|
|
7
|
+
fileId: string;
|
|
8
|
+
/** 文件名称 */
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
4
11
|
export type CcsUploadProps = Pick<UploadProps, 'maxCount' | 'data' | 'multiple' | 'accept' | 'name' | 'headers'> & {
|
|
12
|
+
/** 最大文件数 */
|
|
5
13
|
maxFileSize?: number;
|
|
14
|
+
/** 上传按钮文本 */
|
|
6
15
|
uploadText?: string;
|
|
16
|
+
/** 图片下载地址 */
|
|
17
|
+
fileDownloadUrl?: string;
|
|
18
|
+
/** 文件id */
|
|
19
|
+
value?: string | string[] | FileValue[];
|
|
20
|
+
/** 上传change事件 */
|
|
7
21
|
onChange?: (value: any) => void;
|
|
22
|
+
/** 上传请求 */
|
|
8
23
|
uploadRequest: <T = any>(file: File, options?: RecordType) => Promise<T>;
|
|
9
24
|
};
|
|
10
|
-
|
|
25
|
+
export type FileUploadList = UploadChangeParam['fileList'][0] & {
|
|
26
|
+
fileId?: string;
|
|
27
|
+
};
|
|
28
|
+
/** 生成图片默认值 */
|
|
29
|
+
export declare function uploadDefaultFlies(value: CcsUploadProps['value'], fileDownloadUrl: string): FileUploadList[];
|
|
30
|
+
declare function CcsUpload({ value, uploadText, maxCount, maxFileSize, fileDownloadUrl, uploadRequest, onChange, ...otherProps }: CcsUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
11
31
|
declare namespace CcsUpload {
|
|
12
32
|
var Image: typeof ImageUpload;
|
|
13
33
|
}
|
package/es/upload/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var _excluded = ["uploadText", "maxCount", "maxFileSize", "uploadRequest", "onChange"];
|
|
1
|
+
var _excluded = ["value", "uploadText", "maxCount", "maxFileSize", "fileDownloadUrl", "uploadRequest", "onChange"];
|
|
3
2
|
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; }
|
|
4
3
|
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; }
|
|
5
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -16,21 +15,68 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
16
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
19
19
|
import { UploadOutlined } from '@ant-design/icons';
|
|
20
20
|
import { Button, Upload, message } from 'antd';
|
|
21
21
|
import { useState } from 'react';
|
|
22
22
|
import { ImageUpload } from "./upload-image";
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
/** 生成图片默认值 */
|
|
25
|
+
export function uploadDefaultFlies(value, fileDownloadUrl) {
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
return value.map(function (v) {
|
|
28
|
+
if (typeof v === 'string') {
|
|
29
|
+
return {
|
|
30
|
+
uid: v,
|
|
31
|
+
name: v,
|
|
32
|
+
url: "".concat(fileDownloadUrl).concat(v),
|
|
33
|
+
fileId: v
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 文件列表
|
|
38
|
+
if (_typeof(v) === 'object') {
|
|
39
|
+
return {
|
|
40
|
+
uid: v.fileId,
|
|
41
|
+
name: v.name,
|
|
42
|
+
url: "".concat(fileDownloadUrl).concat(v.fileId),
|
|
43
|
+
fileId: v.fileId
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}).filter(function (f) {
|
|
48
|
+
return f;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
return [{
|
|
53
|
+
uid: value,
|
|
54
|
+
name: value,
|
|
55
|
+
url: "".concat(fileDownloadUrl).concat(value),
|
|
56
|
+
fileId: value
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
24
61
|
function CcsUpload(_ref) {
|
|
25
|
-
var
|
|
62
|
+
var _ref$value = _ref.value,
|
|
63
|
+
value = _ref$value === void 0 ? [{
|
|
64
|
+
fileId: 'aaaa',
|
|
65
|
+
name: 'daaaa.txt'
|
|
66
|
+
}] : _ref$value,
|
|
67
|
+
uploadText = _ref.uploadText,
|
|
26
68
|
_ref$maxCount = _ref.maxCount,
|
|
27
69
|
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
28
70
|
_ref$maxFileSize = _ref.maxFileSize,
|
|
29
71
|
maxFileSize = _ref$maxFileSize === void 0 ? 10 : _ref$maxFileSize,
|
|
72
|
+
_ref$fileDownloadUrl = _ref.fileDownloadUrl,
|
|
73
|
+
fileDownloadUrl = _ref$fileDownloadUrl === void 0 ? '' : _ref$fileDownloadUrl,
|
|
30
74
|
uploadRequest = _ref.uploadRequest,
|
|
31
75
|
onChange = _ref.onChange,
|
|
32
76
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
-
var _useState = useState(
|
|
77
|
+
var _useState = useState(function () {
|
|
78
|
+
return uploadDefaultFlies(value, fileDownloadUrl);
|
|
79
|
+
}),
|
|
34
80
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
81
|
files = _useState2[0],
|
|
36
82
|
setFiles = _useState2[1];
|
|
@@ -43,17 +89,16 @@ function CcsUpload(_ref) {
|
|
|
43
89
|
if (fileList.find(function (f) {
|
|
44
90
|
return f.status === 'uploading';
|
|
45
91
|
})) return;
|
|
46
|
-
if (
|
|
92
|
+
if (maxCount === 1) {
|
|
47
93
|
var _fileList$;
|
|
48
94
|
// 只能上传一个文件
|
|
49
|
-
onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0
|
|
95
|
+
onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0 ? void 0 : _fileList$.fileId);
|
|
50
96
|
} else {
|
|
51
97
|
// 上传完成的文件,返回上传结果集
|
|
52
98
|
onChange(fileList.filter(function (f) {
|
|
53
|
-
return f.
|
|
99
|
+
return !!f.fileId;
|
|
54
100
|
}).map(function (f) {
|
|
55
|
-
|
|
56
|
-
return (_f$response = f.response) === null || _f$response === void 0 ? void 0 : _f$response.data;
|
|
101
|
+
return f.fileId;
|
|
57
102
|
}));
|
|
58
103
|
}
|
|
59
104
|
};
|
|
@@ -66,6 +111,8 @@ function CcsUpload(_ref) {
|
|
|
66
111
|
}
|
|
67
112
|
return isLt2M;
|
|
68
113
|
};
|
|
114
|
+
|
|
115
|
+
// 自定义上传
|
|
69
116
|
var onCustomRequest = /*#__PURE__*/function () {
|
|
70
117
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
|
|
71
118
|
var file, onSuccess, onError, result;
|
|
@@ -2,5 +2,5 @@ import { CcsUploadProps } from './index';
|
|
|
2
2
|
type CcsImageUploadProps = CcsUploadProps & {
|
|
3
3
|
crop?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare function ImageUpload({ uploadText, maxCount, maxFileSize, crop, uploadRequest, onChange, ...otherProps }: CcsImageUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function ImageUpload({ uploadText, maxCount, maxFileSize, crop, value, fileDownloadUrl, uploadRequest, onChange, ...otherProps }: CcsImageUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["uploadText", "maxCount", "maxFileSize", "crop", "uploadRequest", "onChange"];
|
|
2
|
+
var _excluded = ["uploadText", "maxCount", "maxFileSize", "crop", "value", "fileDownloadUrl", "uploadRequest", "onChange"];
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -21,6 +21,7 @@ import { message, Upload } from 'antd';
|
|
|
21
21
|
import ImgCrop from 'antd-img-crop';
|
|
22
22
|
import { useState } from 'react';
|
|
23
23
|
import CcsDialog from "../dialog";
|
|
24
|
+
import { uploadDefaultFlies } from "./index";
|
|
24
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
27
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -37,27 +38,35 @@ var getBase64 = function getBase64(file) {
|
|
|
37
38
|
});
|
|
38
39
|
};
|
|
39
40
|
export function ImageUpload(_ref) {
|
|
40
|
-
var uploadText = _ref.uploadText,
|
|
41
|
+
var _ref$uploadText = _ref.uploadText,
|
|
42
|
+
uploadText = _ref$uploadText === void 0 ? '上传' : _ref$uploadText,
|
|
41
43
|
_ref$maxCount = _ref.maxCount,
|
|
42
44
|
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
43
45
|
_ref$maxFileSize = _ref.maxFileSize,
|
|
44
46
|
maxFileSize = _ref$maxFileSize === void 0 ? 10 : _ref$maxFileSize,
|
|
45
47
|
crop = _ref.crop,
|
|
48
|
+
value = _ref.value,
|
|
49
|
+
_ref$fileDownloadUrl = _ref.fileDownloadUrl,
|
|
50
|
+
fileDownloadUrl = _ref$fileDownloadUrl === void 0 ? '' : _ref$fileDownloadUrl,
|
|
46
51
|
uploadRequest = _ref.uploadRequest,
|
|
47
52
|
onChange = _ref.onChange,
|
|
48
53
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
-
var _useState = useState(
|
|
54
|
+
var _useState = useState(function () {
|
|
55
|
+
return uploadDefaultFlies(value, fileDownloadUrl);
|
|
56
|
+
}),
|
|
50
57
|
_useState2 = _slicedToArray(_useState, 2),
|
|
51
58
|
files = _useState2[0],
|
|
52
59
|
setFiles = _useState2[1];
|
|
53
60
|
var _CcsDialog$useDialog = CcsDialog.useDialog(),
|
|
54
|
-
contextHolder = _CcsDialog$useDialog.contextHolder,
|
|
55
61
|
openModal = _CcsDialog$useDialog.openModal;
|
|
56
62
|
var handleOnChange = function handleOnChange(_ref2) {
|
|
57
63
|
var fileList = _ref2.fileList;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
fileList.forEach(function (f) {
|
|
65
|
+
if (!f.fileId && f.response) {
|
|
66
|
+
f.fileId = f.response.data;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
setFiles(fileList);
|
|
61
70
|
if (!onChange) return;
|
|
62
71
|
|
|
63
72
|
// 文件上传中,不更新结果
|
|
@@ -67,14 +76,13 @@ export function ImageUpload(_ref) {
|
|
|
67
76
|
if (maxCount === 1) {
|
|
68
77
|
var _fileList$;
|
|
69
78
|
// 只能上传一个文件
|
|
70
|
-
onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0
|
|
79
|
+
onChange((_fileList$ = fileList[0]) === null || _fileList$ === void 0 ? void 0 : _fileList$.fileId);
|
|
71
80
|
} else {
|
|
72
81
|
// 上传完成的文件,返回上传结果集
|
|
73
82
|
onChange(fileList.filter(function (f) {
|
|
74
|
-
return f.
|
|
83
|
+
return !!f.fileId;
|
|
75
84
|
}).map(function (f) {
|
|
76
|
-
|
|
77
|
-
return (_f$response = f.response) === null || _f$response === void 0 ? void 0 : _f$response.data;
|
|
85
|
+
return f.fileId;
|
|
78
86
|
}));
|
|
79
87
|
}
|
|
80
88
|
};
|
|
@@ -87,31 +95,42 @@ export function ImageUpload(_ref) {
|
|
|
87
95
|
}
|
|
88
96
|
return isLt2M;
|
|
89
97
|
};
|
|
98
|
+
|
|
99
|
+
// 预览
|
|
90
100
|
var handlePreview = /*#__PURE__*/function () {
|
|
91
101
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
|
|
92
102
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
93
103
|
while (1) switch (_context.prev = _context.next) {
|
|
94
104
|
case 0:
|
|
95
105
|
if (file.preview) {
|
|
96
|
-
_context.next =
|
|
106
|
+
_context.next = 8;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (!file.originFileObj) {
|
|
110
|
+
_context.next = 7;
|
|
97
111
|
break;
|
|
98
112
|
}
|
|
99
|
-
_context.next =
|
|
113
|
+
_context.next = 4;
|
|
100
114
|
return getBase64(file.originFileObj);
|
|
101
|
-
case 3:
|
|
102
|
-
file.preview = _context.sent;
|
|
103
115
|
case 4:
|
|
116
|
+
file.preview = _context.sent;
|
|
117
|
+
_context.next = 8;
|
|
118
|
+
break;
|
|
119
|
+
case 7:
|
|
120
|
+
file.preview = "".concat(fileDownloadUrl).concat(file.fileId);
|
|
121
|
+
case 8:
|
|
104
122
|
openModal({
|
|
105
123
|
title: file.name || file.url.substring(file.url.lastIndexOf('/') + 1),
|
|
106
124
|
content: /*#__PURE__*/_jsx("img", {
|
|
107
|
-
alt:
|
|
125
|
+
alt: file.name,
|
|
108
126
|
style: {
|
|
109
127
|
width: '100%'
|
|
110
128
|
},
|
|
111
129
|
src: file.preview
|
|
112
|
-
})
|
|
130
|
+
}),
|
|
131
|
+
footer: null
|
|
113
132
|
});
|
|
114
|
-
case
|
|
133
|
+
case 9:
|
|
115
134
|
case "end":
|
|
116
135
|
return _context.stop();
|
|
117
136
|
}
|
|
@@ -121,6 +140,8 @@ export function ImageUpload(_ref) {
|
|
|
121
140
|
return _ref3.apply(this, arguments);
|
|
122
141
|
};
|
|
123
142
|
}();
|
|
143
|
+
|
|
144
|
+
// 自定义上传
|
|
124
145
|
var onCustomRequest = /*#__PURE__*/function () {
|
|
125
146
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref4) {
|
|
126
147
|
var file, onSuccess, onError, result;
|
|
@@ -173,11 +194,11 @@ export function ImageUpload(_ref) {
|
|
|
173
194
|
})]
|
|
174
195
|
})
|
|
175
196
|
}));
|
|
176
|
-
return /*#__PURE__*/
|
|
177
|
-
children:
|
|
197
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
198
|
+
children: crop ? /*#__PURE__*/_jsx(ImgCrop, {
|
|
178
199
|
minZoom: 0.5,
|
|
179
200
|
rotationSlider: true,
|
|
180
201
|
children: renderUpload
|
|
181
|
-
}) : renderUpload
|
|
202
|
+
}) : renderUpload
|
|
182
203
|
});
|
|
183
204
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ccs-ui/rc-pro",
|
|
3
|
-
"version": "2.2.4
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@ant-design/colors": "^8.0.0",
|
|
53
54
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
54
55
|
"@codemirror/lang-json": "^6.0.1",
|
|
55
56
|
"@codemirror/lang-sql": "^6.7.0",
|
|
@@ -65,7 +66,6 @@
|
|
|
65
66
|
"lodash.isarray": "^4.0.0",
|
|
66
67
|
"lodash.isnil": "^4.0.0",
|
|
67
68
|
"lodash.uniqueid": "^4.0.1",
|
|
68
|
-
"react-color": "^2.19.3",
|
|
69
69
|
"react-custom-scrollbars": "^4.2.1",
|
|
70
70
|
"react-draggable": "^4.4.5",
|
|
71
71
|
"react-error-overlay": "^6.0.11",
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"@types/lodash.isnil": "^4.0.9",
|
|
85
85
|
"@types/lodash.uniqueid": "^4.0.9",
|
|
86
86
|
"@types/react": "^18.0.0",
|
|
87
|
-
"@types/react-color": "^3.0.6",
|
|
88
87
|
"@types/react-custom-scrollbars": "^4.0.10",
|
|
89
88
|
"@types/react-dom": "^18.0.0",
|
|
90
89
|
"@types/react-lines-ellipsis": "^0.15.6",
|