@para-ui/core 4.0.22 → 4.0.24

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 (110) hide show
  1. package/AutoTips/index.js +11 -0
  2. package/Button/index.js +1 -1
  3. package/ButtonGroup/index.js +1 -1
  4. package/Cascader/index.js +7 -6
  5. package/ComboSelect/index.js +2 -2
  6. package/CopyText/index.js +1 -1
  7. package/CycleSelector/index.js +1 -1
  8. package/DatePicker/index.js +1 -1
  9. package/Descriptions/index.js +1 -1
  10. package/Desktop/index.js +1 -1
  11. package/Drawer/index.js +1 -1
  12. package/Dropdown/index.js +1 -1
  13. package/DynamicMultiBox/index.js +2 -2
  14. package/Empty/index.js +0 -6
  15. package/Form/index.js +11 -8
  16. package/FormItem/index.js +3 -3
  17. package/FunctionModal/index.js +3 -3
  18. package/Image/PreviewGroup.d.ts +20 -0
  19. package/Image/index.d.ts +10 -0
  20. package/Image/index.js +1485 -0
  21. package/InputLang/index.js +1 -1
  22. package/Modal/index.js +1 -1
  23. package/MultiBox/index.js +1 -1
  24. package/OperateBtn/index.js +1 -1
  25. package/PageHeader/index.js +1 -1
  26. package/Pagination/index.js +3 -3
  27. package/PopConfirm/index.js +1 -1
  28. package/Popover/index.js +1 -1
  29. package/Querying/index.js +0 -12
  30. package/QuickReply/index.js +1 -1
  31. package/README.md +13 -0
  32. package/Search/index.js +1 -1
  33. package/Select/index.d.ts +2 -0
  34. package/Select/index.js +27 -10
  35. package/SelectInput/index.js +1 -1
  36. package/Selector/index.js +3 -326
  37. package/SelectorPicker/index.js +2 -1
  38. package/SingleBox/index.js +1 -1
  39. package/Slider/index.js +29 -14
  40. package/Slider/interface.d.ts +4 -0
  41. package/Table/index.js +9 -3
  42. package/Tabs/index.js +1 -1
  43. package/TextField/index.js +5 -4
  44. package/TimePicker/index.js +1 -1
  45. package/ToggleButton/index.js +1 -1
  46. package/Transfer/index.js +1 -1
  47. package/Tree/index.js +2 -2
  48. package/Upload/ImgCrop/EasyCrop.d.ts +2 -2
  49. package/Upload/ImgCrop/constants.d.ts +12 -0
  50. package/Upload/ImgCrop/interface.d.ts +10 -0
  51. package/Upload/index.js +1182 -527
  52. package/Upload/interface.d.ts +43 -0
  53. package/Upload/util.d.ts +7 -0
  54. package/_verture/Portal-5bd49559.js +1698 -0
  55. package/_verture/{index-066d47d4.js → index-2a6adf4d.js} +38 -1727
  56. package/_verture/index-8ac46bd9.js +327 -0
  57. package/_verture/{index-b892f976.js → index-bbe5660a.js} +2 -2
  58. package/_verture/{index-389675ab.js → index-bde7aabe.js} +1 -1
  59. package/index.d.ts +2 -0
  60. package/index.js +19 -12
  61. package/locale/index.js +2 -2
  62. package/package.json +3 -2
  63. package/umd/AutoBox.js +1 -1
  64. package/umd/AutoTips.js +1 -1
  65. package/umd/Breadcrumbs.js +1 -1
  66. package/umd/Button.js +1 -1
  67. package/umd/ButtonGroup.js +1 -1
  68. package/umd/ComboSelect.js +3 -3
  69. package/umd/CopyText.js +2 -2
  70. package/umd/CycleSelector.js +2 -2
  71. package/umd/DatePicker.js +1 -1
  72. package/umd/Descriptions.js +1 -1
  73. package/umd/Desktop.js +2 -2
  74. package/umd/Drawer.js +1 -1
  75. package/umd/Dropdown.js +1 -1
  76. package/umd/DynamicMultiBox.js +3 -3
  77. package/umd/Empty.js +1 -1
  78. package/umd/Form.js +4 -4
  79. package/umd/FormItem.js +3 -3
  80. package/umd/FunctionModal.js +6 -6
  81. package/umd/Image.js +42 -0
  82. package/umd/InputLang.js +2 -2
  83. package/umd/Modal.js +4 -4
  84. package/umd/MultiBox.js +2 -2
  85. package/umd/OperateBtn.js +4 -4
  86. package/umd/PageHeader.js +1 -1
  87. package/umd/Pagination.js +2 -2
  88. package/umd/PopConfirm.js +3 -3
  89. package/umd/PopMenu.js +1 -1
  90. package/umd/Popover.js +1 -1
  91. package/umd/Querying.js +1 -1
  92. package/umd/QuickReply.js +4 -4
  93. package/umd/Search.js +2 -2
  94. package/umd/Select.js +3 -3
  95. package/umd/SelectInput.js +2 -2
  96. package/umd/Selector.js +2 -2
  97. package/umd/SelectorPicker.js +5 -5
  98. package/umd/SingleBox.js +2 -2
  99. package/umd/Slider.js +2 -2
  100. package/umd/Table.js +6 -6
  101. package/umd/Tabs.js +4 -4
  102. package/umd/TextField.js +2 -2
  103. package/umd/TimePicker.js +1 -1
  104. package/umd/ToggleButton.js +1 -1
  105. package/umd/Transfer.js +2 -2
  106. package/umd/Tree.js +1 -1
  107. package/umd/Upload.js +6 -6
  108. package/umd/locale.js +1 -1
  109. /package/_verture/{index-4b965dd7.js → index-8cfd01fd.js} +0 -0
  110. /package/_verture/{modalContext-c8cc3107.js → modalContext-0c08a396.js} +0 -0
package/Upload/index.js CHANGED
@@ -1,158 +1,533 @@
1
1
  import { a as __awaiter, _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
2
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
- import { useState, useEffect, useRef, memo, forwardRef, useCallback, useImperativeHandle, useMemo } from 'react';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useState, useRef, useMemo, useEffect, memo, forwardRef, useCallback, useImperativeHandle } from 'react';
4
4
  import RcUpload from 'rc-upload';
5
+ import clsx from 'clsx';
5
6
  import UploadIcon from '@para-ui/icons/UploadFile';
6
7
  import LoadingIcon from '@para-ui/icons/Loading';
8
+ import { _ as _toConsumableArray } from '../_verture/toConsumableArray-8f4c9589.js';
9
+ import { _ as _typeof } from '../_verture/typeof-adeedc13.js';
10
+ import { _ as _slicedToArray } from '../_verture/slicedToArray-a8206399.js';
11
+ import { r as regenerator } from '../_verture/index-8ac46bd9.js';
12
+ import EditOutline from '@para-ui/icons/EditOutline';
7
13
  import Delete from '@para-ui/icons/Delete';
8
- import TextIcon from '@para-ui/icons/Text';
14
+ import FileOutlined from '@para-ui/icons/Document';
9
15
  import PhotoIcon from '@para-ui/icons/Photo';
10
- import clsx from 'clsx';
16
+ import PreviewOpen from '@para-ui/icons/PreviewOpen';
17
+ import InfoOutlined from '@para-ui/icons/WarningCircle';
18
+ import { Tooltip } from '../Tooltip/index.js';
19
+ import AutoTips from '../AutoTips/index.js';
20
+ import Image$1 from '../Image/index.js';
21
+ import OperateBtn from '../OperateBtn/index.js';
11
22
  import { $ as $prefixCls, a as $rcPrefixCls } from '../_verture/constant-5317fc89.js';
12
23
  import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
13
24
  import Forbid from '@para-ui/icons/Forbid';
14
25
  import { u as useFormatMessage } from '../_verture/useFormatMessage-1fc7c957.js';
15
- import EditOutline from '@para-ui/icons/EditOutline';
16
26
  import { Button } from '../Button/index.js';
17
- import { _ as _slicedToArray } from '../_verture/slicedToArray-a8206399.js';
18
- import { Slider } from '../Slider/index.js';
19
27
  import Cropper from 'react-easy-crop';
28
+ import PlusCircle from '@para-ui/icons/PlusCircle';
29
+ import MinusCircle from '@para-ui/icons/MinusCircle';
30
+ import TurnRight from '@para-ui/icons/TurnRight';
31
+ import TurnLeft from '@para-ui/icons/TurnLeft';
32
+ import { Slider } from '../Slider/index.js';
20
33
  import { Modal } from '../Modal/index.js';
21
- import '../_verture/index-ca413216.js';
22
- import '@paraview/lib';
23
- import '@para-ui/icons/LoadingF';
24
- import '../Tooltip/index.js';
34
+ import '../_verture/unsupportedIterableToArray-cb478f24.js';
35
+ import '../_verture/typeof-6ec38efd.js';
25
36
  import 'rc-tooltip';
26
37
  import 'rc-tooltip/lib/placements';
38
+ import '@paraview/lib';
39
+ import '../_verture/Portal-5bd49559.js';
40
+ import 'react-dom';
41
+ import '../_verture/defineProperty-6f62bb2a.js';
42
+ import 'rc-dialog';
43
+ import 'rc-motion';
44
+ import '@para-ui/icons/Sort';
45
+ import '@para-ui/icons/Switch';
46
+ import '@para-ui/icons/LeftCircleF';
47
+ import '@para-ui/icons/RightCircleF';
48
+ import '@para-ui/icons/CloseCircleF';
49
+ import '@para-ui/icons/More';
50
+ import '../Popover/index.js';
51
+ import '../_verture/usePopupContainer-635f66f4.js';
52
+ import '../PopConfirm/index.js';
53
+ import '@para-ui/icons/CheckCircleF';
54
+ import '@para-ui/icons/WarningCircleF';
55
+ import '@para-ui/icons/LoadingF';
27
56
  import '@para-ui/icons/Down';
28
- import '../_verture/index-389675ab.js';
57
+ import '../_verture/index-bde7aabe.js';
29
58
  import 'rc-dropdown';
30
- import '../_verture/usePopupContainer-635f66f4.js';
31
59
  import 'dayjs';
32
- import '../AutoTips/index.js';
33
- import '../_verture/unsupportedIterableToArray-cb478f24.js';
60
+ import '../_verture/index-ca413216.js';
34
61
  import 'rc-slider';
35
- import 'rc-dialog';
36
62
  import '@para-ui/icons/Close';
37
- import 'react-dom';
38
- import '@para-ui/icons/CheckCircleF';
39
- import '@para-ui/icons/WarningCircleF';
40
- import '@para-ui/icons/CloseCircleF';
41
63
 
42
- var css_248z$4 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午3:08\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload-list-text .upload-list-item {\n margin-top: 8px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info {\n display: flex;\n align-items: center;\n padding: 0 8px;\n line-height: 28px;\n font-size: 14px;\n color: rgb(29, 33, 38);\n border-radius: 4px;\n transition: background-color 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text {\n position: relative;\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon {\n line-height: 0;\n opacity: 1;\n transition: opacity 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon svg {\n color: inherit;\n font-size: inherit;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text-name {\n margin-left: 10px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions {\n position: absolute;\n left: 0;\n top: 50%;\n transform: translateY(-50%);\n z-index: -1;\n opacity: 0;\n visibility: hidden;\n line-height: 0;\n transition: opacity 0.3s;\n cursor: pointer;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions svg {\n color: rgb(244, 66, 66);\n font-size: inherit;\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover {\n background-color: rgb(247, 248, 250);\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-actions {\n visibility: visible;\n opacity: 1;\n z-index: 1;\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-fileicon-active {\n opacity: 0;\n}\n.paraui-v4-upload-list-picture {\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item {\n position: relative;\n display: inline-block;\n width: 100px;\n height: 100px;\n margin-right: 16px;\n border-radius: 4px;\n cursor: default;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item::before {\n content: \" \";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background-color: rgb(29, 33, 38);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n font-size: 12px;\n line-height: 24px;\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n background-color: rgb(29, 33, 38);\n border-radius: 0 0 4px 4px;\n color: rgb(255, 255, 255);\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n opacity: 0;\n line-height: 0;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly)::before {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-actions {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-picture-name {\n opacity: 0;\n}";
64
+ var extname = function extname() {
65
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
66
+ var temp = url.split('/');
67
+ var filename = temp[temp.length - 1];
68
+ var filenameWithoutSuffix = filename.split(/#|\?/)[0];
69
+ return (/\.[^./\\]*$/.exec(filenameWithoutSuffix) || [''])[0];
70
+ };
71
+ var isImageFileType = function isImageFileType(type) {
72
+ return type.indexOf('image/') === 0;
73
+ };
74
+ var isImageUrl = function isImageUrl(file) {
75
+ if (file.type && !file.thumbUrl) {
76
+ return isImageFileType(file.type);
77
+ }
78
+ var url = file.thumbUrl || file.url || '';
79
+ var extension = extname(url);
80
+ if (/^data:image\//.test(url) || /(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico|heic|heif)$/i.test(extension)) {
81
+ return true;
82
+ }
83
+ if (/^data:/.test(url)) {
84
+ // other file types of base64
85
+ return false;
86
+ }
87
+ if (extension) {
88
+ // other file types which have extension
89
+ return false;
90
+ }
91
+ return true;
92
+ };
93
+
94
+ var css_248z$4 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午3:08\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload-list-text .upload-list-item {\n margin-top: 10px;\n position: relative;\n}\n.paraui-v4-upload-list-text .upload-list-item-info {\n display: flex;\n align-items: center;\n line-height: 30px;\n font-size: 14px;\n color: rgb(29, 33, 38);\n border-radius: 4px;\n transition: background-color 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text {\n position: relative;\n display: inline-flex;\n align-items: center;\n width: 440px;\n height: 30px;\n background-color: rgb(247, 248, 250);\n border-radius: 4px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-text-item {\n display: flex;\n align-items: center;\n flex: 1;\n padding-left: 10px;\n max-width: 76%;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-text-item .upload-list-text-name {\n margin-left: 8px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-text-item .upload-list-text-name {\n color: rgb(29, 33, 38);\n text-decoration: none;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-text-item .upload-list-text-name:hover {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-text-item-error {\n color: rgb(244, 66, 66);\n cursor: pointer;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-text-item-error .upload-list-text-name,\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-text-item-error .upload-list-text-name:hover {\n color: rgb(244, 66, 66);\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon {\n line-height: 0;\n opacity: 1;\n transition: opacity 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon svg {\n color: inherit;\n font-size: 18px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions svg {\n font-size: 18px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions svg:hover {\n background-color: rgb(234, 236, 241);\n border-radius: 2px;\n}\n.paraui-v4-upload-list-text .upload-list-item .upload-list-actions {\n margin-left: auto;\n margin-right: 10px;\n}\n.paraui-v4-upload-list-text .upload-list-item .upload-list-actions > span {\n display: flex;\n align-items: center;\n}\n.paraui-v4-upload-list-picture {\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-error {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background: rgb(247, 248, 250);\n border: 1px dashed rgb(246, 103, 103);\n border-radius: 4px;\n color: rgb(246, 103, 103);\n}\n.paraui-v4-upload-list-picture .upload-list-picture-error > svg {\n font-size: 30px;\n color: rgb(244, 66, 66);\n margin-bottom: 6px;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-error-name {\n font-size: 14px;\n color: rgb(244, 66, 66);\n padding: 0 10px;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: center;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item {\n position: relative;\n display: inline-block;\n width: 100px;\n height: 100px;\n margin-right: 16px;\n border-radius: 4px;\n cursor: default;\n overflow: hidden;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item::before {\n content: \" \";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background-color: rgba(29, 33, 38, 0.9);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-file {\n font-size: 100px;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-filea {\n fill: none;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-fileb {\n opacity: 0.4;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-filec {\n fill: #2e65e6;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-filed {\n fill: #5783eb;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-filee {\n fill: #ffb900;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-filef {\n fill: #fff;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n font-size: 12px;\n line-height: 24px;\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n background-color: rgba(29, 33, 38, 0.9);\n border-radius: 0 0 4px 4px;\n color: rgb(255, 255, 255);\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n opacity: 0;\n line-height: 0;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions svg {\n color: rgb(255, 255, 255);\n transition: all 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions svg:hover {\n background-color: rgba(255, 255, 255, 0.3);\n border-radius: 2px;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly)::before {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-actions {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-picture-name {\n opacity: 0;\n}\n\n.paraui-v4-upload-drag .paraui-v4-upload-list-text .upload-list-item-info .upload-list-text {\n width: 590px;\n}";
43
95
  styleInject(css_248z$4);
44
96
 
97
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
98
+ 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); }
99
+ 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; }
100
+ var FileIcon = function FileIcon(props) {
101
+ props.className;
102
+ return jsxs("svg", Object.assign({
103
+ viewBox: "0 0 180 180",
104
+ className: 'upload-list-picture-file'
105
+ }, {
106
+ children: [jsx("rect", {
107
+ className: "upload-list-picture-filea",
108
+ width: "180",
109
+ height: "180"
110
+ }), jsxs("g", Object.assign({
111
+ className: "upload-list-picture-fileb",
112
+ transform: "matrix(0.985, -0.174, 0.174, 0.985, 10.889, 34.798)"
113
+ }, {
114
+ children: [jsx("path", {
115
+ className: "upload-list-picture-filec",
116
+ d: "M4.016,0h51.2c2.218,0,3.88,1.27,4.671,3.906L63,14.175H0V3.91A3.964,3.964,0,0,1,4.016,0Z",
117
+ transform: "translate(0 0)"
118
+ }), jsx("path", {
119
+ className: "upload-list-picture-filed",
120
+ d: "M0,0H122a4,4,0,0,1,4,4V116.15a4,4,0,0,1-4,4H4a4,4,0,0,1-4-4V0A0,0,0,0,1,0,0Z",
121
+ transform: "translate(0 14.175)"
122
+ }), jsx("rect", {
123
+ className: "upload-list-picture-filee",
124
+ width: "8.825",
125
+ height: "8.825",
126
+ rx: "4",
127
+ transform: "translate(23.533 32.805)"
128
+ }), jsx("rect", {
129
+ className: "upload-list-picture-filef",
130
+ width: "78.934",
131
+ height: "7.875",
132
+ rx: "3.938",
133
+ transform: "translate(23.533 48.984)"
134
+ }), jsx("rect", {
135
+ className: "upload-list-picture-filef",
136
+ width: "25.739",
137
+ height: "7.875",
138
+ rx: "3.938",
139
+ transform: "translate(23.533 65.163)"
140
+ }), jsx("rect", {
141
+ className: "upload-list-picture-filef",
142
+ width: "62.755",
143
+ height: "7.875",
144
+ rx: "3.938",
145
+ transform: "translate(39.712 32.805)"
146
+ })]
147
+ })), jsxs("g", Object.assign({
148
+ transform: "translate(36 23.151)"
149
+ }, {
150
+ children: [jsx("path", {
151
+ className: "upload-list-picture-filec",
152
+ d: "M4.016,0h51.2c2.218,0,3.88,1.27,4.671,3.906L63,14.175H0V3.91A3.964,3.964,0,0,1,4.016,0Z"
153
+ }), jsx("path", {
154
+ className: "upload-list-picture-filed",
155
+ d: "M0,0H122a4,4,0,0,1,4,4V121.55a4,4,0,0,1-4,4H4a4,4,0,0,1-4-4V0A0,0,0,0,1,0,0Z",
156
+ transform: "translate(0 14.175)"
157
+ }), jsx("rect", {
158
+ className: "upload-list-picture-filee",
159
+ width: "8.825",
160
+ height: "8.825",
161
+ rx: "4",
162
+ transform: "translate(23.533 32.805)"
163
+ }), jsx("rect", {
164
+ className: "upload-list-picture-filef",
165
+ width: "78.934",
166
+ height: "7.875",
167
+ rx: "3.938",
168
+ transform: "translate(23.533 48.984)"
169
+ }), jsx("rect", {
170
+ className: "upload-list-picture-filef",
171
+ width: "25.739",
172
+ height: "7.875",
173
+ rx: "3.938",
174
+ transform: "translate(23.533 65.163)"
175
+ }), jsx("rect", {
176
+ className: "upload-list-picture-filef",
177
+ width: "62.755",
178
+ height: "7.875",
179
+ rx: "3.938",
180
+ transform: "translate(39.712 32.805)"
181
+ })]
182
+ }))]
183
+ }));
184
+ };
45
185
  //UploadList
46
- const UploadList = props => {
47
- const {
48
- listType = 'text',
49
- items = [],
50
- onRemove,
51
- showRemoveIcon = true,
52
- removeIcon,
53
- itemRender,
54
- readonly
55
- } = props;
56
- const [uploadList, setUploadList] = useState([]);
186
+ var UploadList = function UploadList(props) {
187
+ var _props$listType = props.listType,
188
+ listType = _props$listType === void 0 ? 'text' : _props$listType,
189
+ _props$items = props.items,
190
+ items = _props$items === void 0 ? [] : _props$items,
191
+ _onRemove = props.onRemove,
192
+ _props$showRemoveIcon = props.showRemoveIcon,
193
+ showRemoveIcon = _props$showRemoveIcon === void 0 ? true : _props$showRemoveIcon,
194
+ _props$showPreviewIco = props.showPreviewIcon,
195
+ showPreviewIcon = _props$showPreviewIco === void 0 ? true : _props$showPreviewIco,
196
+ previewIcon = props.previewIcon,
197
+ removeIcon = props.removeIcon,
198
+ itemRender = props.itemRender,
199
+ readonly = props.readonly,
200
+ operateBtnProps = props.operateBtnProps,
201
+ actionRender = props.actionRender,
202
+ onPreview = props.onPreview;
203
+ var _useState = useState([]),
204
+ _useState2 = _slicedToArray(_useState, 2),
205
+ uploadList = _useState2[0],
206
+ setUploadList = _useState2[1];
207
+ var _useState3 = useState(false),
208
+ _useState4 = _slicedToArray(_useState3, 2),
209
+ visible = _useState4[0],
210
+ setVisible = _useState4[1];
211
+ var _useState5 = useState(0),
212
+ _useState6 = _slicedToArray(_useState5, 2),
213
+ current = _useState6[0],
214
+ setCurrent = _useState6[1];
215
+ useRef(null);
57
216
  //处理删除
58
- const handleRemove = (file, evt) => {
217
+ var handleRemove = function handleRemove(file, evt) {
59
218
  evt.stopPropagation();
60
- onRemove === null || onRemove === void 0 ? void 0 : onRemove(file);
219
+ _onRemove === null || _onRemove === void 0 ? void 0 : _onRemove(file);
220
+ };
221
+ var isError = function isError(file) {
222
+ return file.status === 'error';
223
+ };
224
+ var onImageError = function onImageError(file) {
225
+ if (file.status === 'error') return;
226
+ file.status = 'error';
227
+ setUploadList(_toConsumableArray(uploadList));
228
+ };
229
+ var previewItems = useMemo(function () {
230
+ var _a;
231
+ var originItems = items === null || items === void 0 ? void 0 : items.filter(function (item) {
232
+ return isImageUrl(item) && !isError(item);
233
+ });
234
+ return {
235
+ items: ((_a = originItems === null || originItems === void 0 ? void 0 : originItems.map(function (i) {
236
+ return i.url || i.thumbUrl;
237
+ })) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
238
+ return !!i;
239
+ })) || [],
240
+ originItems: originItems
241
+ };
242
+ }, [items]);
243
+ var getCurrent = function getCurrent(file) {
244
+ return previewItems.originItems.findIndex(function (i) {
245
+ return i.uid === file.uid;
246
+ });
247
+ };
248
+ // 处理预览
249
+ var handlePreview = function handlePreview(file, e) {
250
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
251
+ var shouldPreview, currentIndex;
252
+ return regenerator.wrap(function _callee$(_context) {
253
+ while (1) switch (_context.prev = _context.next) {
254
+ case 0:
255
+ _context.next = 2;
256
+ return onPreview === null || onPreview === void 0 ? void 0 : onPreview(file, e);
257
+ case 2:
258
+ shouldPreview = _context.sent;
259
+ if (!(shouldPreview === false)) {
260
+ _context.next = 5;
261
+ break;
262
+ }
263
+ return _context.abrupt("return");
264
+ case 5:
265
+ currentIndex = getCurrent(file);
266
+ if (!(currentIndex === -1)) {
267
+ _context.next = 8;
268
+ break;
269
+ }
270
+ return _context.abrupt("return");
271
+ case 8:
272
+ setCurrent(currentIndex);
273
+ setVisible(true);
274
+ case 10:
275
+ case "end":
276
+ return _context.stop();
277
+ }
278
+ }, _callee);
279
+ }));
280
+ };
281
+ // 图片墙操作按钮
282
+ var pictureCardAction = function pictureCardAction(file) {
283
+ var list = [];
284
+ if (isImageUrl(file) && !isError(file) && showPreviewIcon) list.push({
285
+ icon: previewIcon || jsx(PreviewOpen, {}),
286
+ key: 'view'
287
+ });
288
+ if (showRemoveIcon && !readonly) list.push({
289
+ icon: removeIcon || jsx(Delete, {}),
290
+ key: 'delete'
291
+ });
292
+ if (!list.length) return null;
293
+ var onClick = function onClick(item, e) {
294
+ if (item.key === 'view') handlePreview(file, e);
295
+ if (item.key === 'delete') handleRemove(file, e);
296
+ };
297
+ return jsx(OperateBtn, {
298
+ className: 'upload-list-actions',
299
+ showNum: 2,
300
+ list: list,
301
+ onClick: onClick
302
+ });
61
303
  };
62
304
  //渲染列表actions
63
- const renderActions = file => {
64
- return showRemoveIcon && !readonly && jsx("span", Object.assign({
305
+ var renderActions = function renderActions(file) {
306
+ var actions = {
307
+ onRemove: function onRemove() {
308
+ return _onRemove === null || _onRemove === void 0 ? void 0 : _onRemove(file);
309
+ },
310
+ onPreview: function onPreview() {
311
+ return handlePreview(file);
312
+ }
313
+ };
314
+ if (actionRender) return actionRender(file, actions);
315
+ if (operateBtnProps) return jsx(OperateBtn, Object.assign({
65
316
  className: 'upload-list-actions',
66
- onClick: evt => handleRemove(file, evt)
317
+ showNum: 2
318
+ }, operateBtnProps(file, actions)));
319
+ if (listType === 'picture-card') return pictureCardAction(file);
320
+ return !readonly && jsx("div", Object.assign({
321
+ className: 'upload-list-actions'
67
322
  }, {
68
- children: removeIcon || jsx(Delete, {})
323
+ children: showRemoveIcon && jsx("span", Object.assign({
324
+ onClick: function onClick(evt) {
325
+ return handleRemove(file, evt);
326
+ }
327
+ }, {
328
+ children: removeIcon || jsx(Delete, {})
329
+ }))
69
330
  }));
70
331
  };
332
+ // 渲染图标
333
+ var renderIcon = function renderIcon(file) {
334
+ var isImage = isImageUrl(file);
335
+ if (file.status === 'error') return jsx(InfoOutlined, {});
336
+ return isImage ? jsx(PhotoIcon, {}) : jsx(FileOutlined, {});
337
+ };
338
+ var renderTextItem = function renderTextItem(file) {
339
+ var listItemNameClass = 'upload-list-text-name';
340
+ var fileName = file.url && !isError(file) ? jsx("a", Object.assign({
341
+ target: "_blank",
342
+ rel: "noopener noreferrer",
343
+ className: listItemNameClass,
344
+ // title={file.name}
345
+ href: file.url,
346
+ onClick: function onClick(e) {
347
+ return onPreview === null || onPreview === void 0 ? void 0 : onPreview(file, e);
348
+ }
349
+ }, {
350
+ children: file.name
351
+ }), "view") : jsx("div", Object.assign({
352
+ className: listItemNameClass,
353
+ onClick: function onClick(e) {
354
+ return onPreview === null || onPreview === void 0 ? void 0 : onPreview(file, e);
355
+ },
356
+ title: file.name
357
+ }, {
358
+ children: file.name
359
+ }), "view");
360
+ var listItem = jsxs("div", Object.assign({
361
+ className: clsx('upload-list-text-item', isError(file) && 'upload-list-text-item-error')
362
+ }, {
363
+ children: [jsx("div", Object.assign({
364
+ className: clsx('upload-list-fileicon', showRemoveIcon && 'upload-list-fileicon-active')
365
+ }, {
366
+ children: renderIcon(file)
367
+ })), jsx(AutoTips, Object.assign({
368
+ placement: "top-start"
369
+ }, {
370
+ children: fileName
371
+ }))]
372
+ }));
373
+ if (isError(file) && typeof file.response === 'string') return jsx(Tooltip, Object.assign({
374
+ title: file.response
375
+ }, {
376
+ children: listItem
377
+ }));
378
+ return listItem;
379
+ };
71
380
  //文件列表 text
72
- const renderFileListText = () => {
381
+ var renderFileListText = function renderFileListText() {
73
382
  if (!(uploadList === null || uploadList === void 0 ? void 0 : uploadList.length)) return null;
74
- return uploadList.map((file, idx) => {
383
+ return uploadList.map(function (file, idx) {
75
384
  var _a;
76
385
  if (itemRender)
77
386
  //自定义渲染
78
387
  return itemRender(file, uploadList);
79
- const isImage = !!((_a = file.type) === null || _a === void 0 ? void 0 : _a.includes('image/'));
388
+ !!((_a = file.type) === null || _a === void 0 ? void 0 : _a.includes('image/'));
80
389
  return jsx("div", Object.assign({
81
390
  className: 'upload-list-item'
82
391
  }, {
83
392
  children: jsx("div", Object.assign({
84
393
  className: 'upload-list-item-info'
85
394
  }, {
86
- children: jsxs("span", Object.assign({
395
+ children: jsxs("div", Object.assign({
87
396
  className: 'upload-list-text'
88
397
  }, {
89
- children: [jsx("span", Object.assign({
90
- className: clsx('upload-list-fileicon', showRemoveIcon && 'upload-list-fileicon-active')
91
- }, {
92
- children: isImage ? jsx(PhotoIcon, {}) : jsx(TextIcon, {})
93
- })), renderActions(file), jsx("span", Object.assign({
94
- className: 'upload-list-text-name'
95
- }, {
96
- children: file.name
97
- }))]
398
+ children: [renderTextItem(file), renderActions(file)]
98
399
  }))
99
400
  }))
100
401
  }), idx);
101
402
  });
102
403
  };
103
404
  //文件列表 picture-card
104
- const renderFileListPicture = () => {
405
+ var renderFileListPicture = function renderFileListPicture() {
105
406
  if (!(uploadList === null || uploadList === void 0 ? void 0 : uploadList.length)) return null;
106
- return uploadList.map((file, idx) => {
107
- if (itemRender)
108
- //自定义渲染
109
- return itemRender(file, uploadList);
110
- return jsxs("div", Object.assign({
111
- className: "upload-list-picture-item ".concat(readonly ? 'upload-list-picture-item-readonly' : '')
112
- }, {
113
- children: [jsx("img", {
114
- src: file.dataUrl || file.url,
115
- alt: file.name
116
- }), jsx("span", Object.assign({
407
+ return uploadList.map(function (file, idx) {
408
+ /*自定义渲染*/
409
+ if (itemRender) return itemRender(file, uploadList);
410
+ var isImage = isImageUrl(file);
411
+ var pictureItem = jsxs(Fragment, {
412
+ children: [isImage ? jsx("img", {
413
+ src: file.thumbUrl || file.dataUrl || file.url,
414
+ alt: file.name,
415
+ onError: function onError() {
416
+ return onImageError(file);
417
+ }
418
+ }) : jsx(FileIcon, {
419
+ className: 'upload-list-picture-file'
420
+ })
421
+ // <Microsoft className={'upload-list-picture-file'} />
422
+ , jsx("div", Object.assign({
117
423
  className: 'upload-list-picture-name',
118
424
  title: file.name
119
425
  }, {
120
426
  children: file.name
121
427
  })), renderActions(file)]
428
+ });
429
+ if (isError(file)) {
430
+ pictureItem = jsxs("div", Object.assign({
431
+ className: 'upload-list-picture-error'
432
+ }, {
433
+ children: [jsx(PhotoIcon, {}), jsx("div", Object.assign({
434
+ className: 'upload-list-picture-error-name'
435
+ }, {
436
+ children: file.name
437
+ })), renderActions(file)]
438
+ }));
439
+ }
440
+ return jsx("div", Object.assign({
441
+ className: clsx('upload-list-picture-item', !pictureCardAction(file) && 'upload-list-picture-item-readonly')
442
+ }, {
443
+ children: pictureItem
122
444
  }), idx);
123
445
  });
124
446
  };
125
447
  //处理文件
126
- const handleFileFormat = () => __awaiter(void 0, void 0, void 0, function* () {
127
- if (!(items === null || items === void 0 ? void 0 : items.length)) return setUploadList([]);
128
- //读取file as DataUrl
129
- const readerFileAsDataUrl = file => __awaiter(void 0, void 0, void 0, function* () {
130
- return new Promise(resolve => {
131
- const fileReader = new FileReader();
132
- if (file.originFileObj) {
133
- fileReader.onload = () => {
134
- resolve(fileReader.result);
135
- };
136
- fileReader.readAsDataURL(file.originFileObj);
137
- } else resolve('');
138
- });
139
- });
140
- for (const file of items) {
141
- if (file.originFileObj) {
142
- const dataUrl = yield readerFileAsDataUrl(file);
143
- file.dataUrl = dataUrl;
144
- }
145
- }
146
- setUploadList([...items]);
147
- });
148
- useEffect(() => {
149
- if (listType === 'picture-card') handleFileFormat();else setUploadList(pre => {
150
- if (items) return [...items];
448
+ var handleFileFormat = function handleFileFormat() {
449
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee3() {
450
+ var readerFileAsDataUrl, _iterator, _step, file, dataUrl;
451
+ return regenerator.wrap(function _callee3$(_context3) {
452
+ while (1) switch (_context3.prev = _context3.next) {
453
+ case 0:
454
+ if (items === null || items === void 0 ? void 0 : items.length) {
455
+ _context3.next = 2;
456
+ break;
457
+ }
458
+ return _context3.abrupt("return", setUploadList([]));
459
+ case 2:
460
+ //读取file as DataUrl
461
+ readerFileAsDataUrl = function readerFileAsDataUrl(file) {
462
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
463
+ return regenerator.wrap(function _callee2$(_context2) {
464
+ while (1) switch (_context2.prev = _context2.next) {
465
+ case 0:
466
+ return _context2.abrupt("return", new Promise(function (resolve) {
467
+ var fileReader = new FileReader();
468
+ if (file.originFileObj) {
469
+ fileReader.onload = function () {
470
+ resolve(fileReader.result);
471
+ };
472
+ fileReader.readAsDataURL(file.originFileObj);
473
+ } else resolve('');
474
+ }));
475
+ case 1:
476
+ case "end":
477
+ return _context2.stop();
478
+ }
479
+ }, _callee2);
480
+ }));
481
+ };
482
+ _iterator = _createForOfIteratorHelper(items);
483
+ _context3.prev = 4;
484
+ _iterator.s();
485
+ case 6:
486
+ if ((_step = _iterator.n()).done) {
487
+ _context3.next = 15;
488
+ break;
489
+ }
490
+ file = _step.value;
491
+ if (!file.originFileObj) {
492
+ _context3.next = 13;
493
+ break;
494
+ }
495
+ _context3.next = 11;
496
+ return readerFileAsDataUrl(file);
497
+ case 11:
498
+ dataUrl = _context3.sent;
499
+ file.dataUrl = dataUrl;
500
+ case 13:
501
+ _context3.next = 6;
502
+ break;
503
+ case 15:
504
+ _context3.next = 20;
505
+ break;
506
+ case 17:
507
+ _context3.prev = 17;
508
+ _context3.t0 = _context3["catch"](4);
509
+ _iterator.e(_context3.t0);
510
+ case 20:
511
+ _context3.prev = 20;
512
+ _iterator.f();
513
+ return _context3.finish(20);
514
+ case 23:
515
+ setUploadList(_toConsumableArray(items));
516
+ case 24:
517
+ case "end":
518
+ return _context3.stop();
519
+ }
520
+ }, _callee3, null, [[4, 17, 20, 23]]);
521
+ }));
522
+ };
523
+ useEffect(function () {
524
+ if (listType === 'picture-card') handleFileFormat();else setUploadList(function (pre) {
525
+ if (items) return _toConsumableArray(items);
151
526
  return pre;
152
527
  });
153
528
  }, [items]);
154
- return jsx(Fragment, {
155
- children: listType === 'text' ? jsx("section", Object.assign({
529
+ return jsxs(Fragment, {
530
+ children: [listType === 'text' ? jsx("section", Object.assign({
156
531
  className: "".concat($prefixCls, "-upload-list-text")
157
532
  }, {
158
533
  children: renderFileListText()
@@ -160,7 +535,19 @@ const UploadList = props => {
160
535
  className: "".concat($prefixCls, "-upload-list-picture")
161
536
  }, {
162
537
  children: renderFileListPicture()
163
- }))
538
+ })), jsx(Image$1.PreviewGroup, {
539
+ preview: {
540
+ visible: visible,
541
+ onVisibleChange: function onVisibleChange(value) {
542
+ setVisible(value);
543
+ },
544
+ onChange: function onChange(value) {
545
+ setCurrent(value);
546
+ },
547
+ current: current
548
+ },
549
+ items: previewItems.items
550
+ })]
164
551
  });
165
552
  };
166
553
 
@@ -168,7 +555,7 @@ var css_248z$3 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/15
168
555
  styleInject(css_248z$3);
169
556
 
170
557
  //error tip
171
- const ErrorTip = props => {
558
+ var ErrorTip = function ErrorTip(props) {
172
559
  return jsxs("div", Object.assign({
173
560
  className: clsx("".concat($prefixCls, "-upload-error"), props.className)
174
561
  }, {
@@ -180,7 +567,7 @@ var en = {
180
567
  uploadError: 'Upload error',
181
568
  uploading: 'Uploading',
182
569
  clickUploadFile: 'Click to upload file',
183
- dragFileUpload: 'After downloading the template and completing the information, you can directly drag and drop the file here to upload it. Supported formats: XLS, XLSX...',
570
+ dragFileUpload: 'After downloading the template and completing the information, you can directly drag and drop the file here to upload it\nSupported formats: XLS, XLSX',
184
571
  add: 'Add',
185
572
  edit: 'Edit',
186
573
  disabled: 'Disabled',
@@ -192,7 +579,7 @@ var zh = {
192
579
  uploadError: '上传失败',
193
580
  uploading: '正在上传',
194
581
  clickUploadFile: '点击上传文件',
195
- dragFileUpload: '下载模板并完善信息后,可直接将文件拖拽到此处进行上传,支持格式:XLS、XLSX...',
582
+ dragFileUpload: '下载模板并完善信息后,可直接将文件拖拽到此处进行上传\n支持格式:XLS、XLSX',
196
583
  add: '新增',
197
584
  edit: '编辑',
198
585
  disabled: '禁用',
@@ -201,99 +588,160 @@ var zh = {
201
588
  };
202
589
 
203
590
  var localeJson = {
204
- zh,
205
- en
591
+ zh: zh,
592
+ en: en
206
593
  };
207
594
 
208
- var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午7:31\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload-image {\n display: inline-flex;\n align-items: center;\n /* &-border {\n .upload-image-select{\n border: 2px dashed $NA1;\n\n &:hover {\n border: 2px dashed $NPT8;\n }\n }\n } */\n}\n.paraui-v4-upload-image .upload-image-select {\n position: relative;\n width: 100px;\n height: 100px;\n cursor: pointer;\n background-color: rgb(247, 248, 250);\n border-radius: 4px;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-select-loading {\n pointer-events: none;\n}\n.paraui-v4-upload-image .upload-image-select .component-upload {\n display: inline-block;\n width: 100%;\n height: 100%;\n}\n.paraui-v4-upload-image .upload-image-select:hover .upload-image-picture-card {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-image .upload-image-picture-card {\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-size: 14px;\n color: rgb(29, 33, 38);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n cursor: default;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper::before {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n content: \" \";\n background-color: rgb(29, 33, 38);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n overflow: hidden;\n font-size: 12px;\n line-height: 24px;\n color: rgb(255, 255, 255);\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n background-color: rgb(29, 33, 38);\n border-radius: 0 0 4px 4px;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-action {\n position: absolute;\n top: 50%;\n left: 50%;\n line-height: 0;\n cursor: pointer;\n opacity: 0;\n transition: 0.3s;\n transform: translate(-50%, -50%);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-action svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover::before {\n opacity: 1;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-name {\n opacity: 0;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-action {\n opacity: 1;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-icon {\n font-size: 30px;\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-loading {\n font-size: 30px;\n color: rgb(46, 101, 230);\n animation: imageLoadingCircle 1s infinite linear;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-text {\n margin-top: 6px;\n color: inherit;\n text-align: center;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-text-loading {\n color: rgb(46, 101, 230);\n}\n@keyframes imageLoadingCircle {\n 100% {\n transform: rotate(360deg);\n }\n}";
595
+ var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午7:31\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload-image {\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-image .upload-image-select {\n position: relative;\n width: 100px;\n height: 100px;\n cursor: pointer;\n background-color: rgb(247, 248, 250);\n border-radius: 4px;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-select-loading {\n pointer-events: none;\n}\n.paraui-v4-upload-image .upload-image-select .component-upload {\n display: inline-block;\n width: 100%;\n height: 100%;\n}\n.paraui-v4-upload-image .upload-image-select .component-upload-disabled {\n color: rgb(92, 101, 115);\n cursor: not-allowed;\n}\n.paraui-v4-upload-image .upload-image-select .component-upload-disabled svg {\n color: rgb(92, 101, 115);\n}\n.paraui-v4-upload-image .upload-image-select .component-upload-disabled .upload-image-picture-card {\n color: rgb(92, 101, 115);\n}\n.paraui-v4-upload-image .upload-image-select:hover .component-upload:not(.component-upload-disabled) .upload-image-picture-card {\n color: rgb(46, 101, 230);\n border-color: rgb(87, 131, 235);\n}\n.paraui-v4-upload-image .upload-image-select:hover .component-upload:not(.component-upload-disabled) .upload-image-picture-card .upload-image-text {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-image .upload-image-picture-card {\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-size: 14px;\n color: rgb(29, 33, 38);\n border: 1px dashed rgb(212, 218, 227);\n border-radius: 4px;\n}\n.paraui-v4-upload-image .upload-image-picture-card.is-avatar {\n border: none;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-select-tooltip-wrapper {\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n cursor: default;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper::before {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n content: \" \";\n background-color: rgb(29, 33, 38);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n overflow: hidden;\n font-size: 12px;\n line-height: 24px;\n color: rgb(255, 255, 255);\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n background-color: rgb(29, 33, 38);\n border-radius: 0 0 4px 4px;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-action {\n position: absolute;\n top: 50%;\n left: 50%;\n line-height: 0;\n cursor: pointer;\n opacity: 0;\n transition: 0.3s;\n transform: translate(-50%, -50%);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-action svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover::before {\n opacity: 1;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-name {\n opacity: 0;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-action {\n opacity: 1;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-icon {\n font-size: 30px;\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-loading {\n font-size: 30px;\n color: rgb(46, 101, 230);\n animation: imageLoadingCircle 1s infinite linear;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-text {\n margin-top: 6px;\n color: inherit;\n text-align: center;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-text-loading {\n color: rgb(46, 101, 230);\n}\n@keyframes imageLoadingCircle {\n 100% {\n transform: rotate(360deg);\n }\n}";
209
596
  styleInject(css_248z$2);
210
597
 
211
598
  //ImageUpload
212
- const ImageUpload = props => {
213
- const {
214
- className,
215
- style,
216
- onStart,
217
- onSuccess,
218
- onError,
219
- onProgress,
220
- onRemove,
221
- beforeUpload,
222
- onChange,
223
- defaultFileList = [],
224
- fileList,
225
- showUploadList = true,
226
- maxCount,
227
- children = null,
228
- itemRender,
229
- showUploadError = true,
230
- stash = false,
231
- uploading = true,
232
- loading = false,
233
- showLoading: showLoadingProp = false,
234
- defaultImage,
235
- readonly
236
- } = props,
237
- restProps = __rest(props, ["className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "stash", "uploading", "loading", "showLoading", "defaultImage", "readonly"]);
238
- const intl = useFormatMessage('Upload', localeJson);
239
- const [uploadFileList, setUploadFileList] = useState(defaultFileList); //文件列表
240
- const [showLoading, setShowLoading] = useState(false); //upload loading
241
- const [errTip, setErrTip] = useState(false); //upload error tip
242
- const [avatar, setAvatar] = useState({
243
- imageUrl: ''
244
- }); //不显示列表时上传头像
245
- const {
246
- showRemoveIcon,
247
- removeIcon
248
- } = typeof showUploadList === 'boolean' ? {} : showUploadList; //显示上传列表
249
- const {
250
- uploadErrorMsg = intl({
251
- id: 'uploadError'
599
+ var ImageUpload = function ImageUpload(props) {
600
+ var className = props.className,
601
+ style = props.style,
602
+ _onStart = props.onStart,
603
+ _onSuccess = props.onSuccess,
604
+ _onError = props.onError,
605
+ _onProgress = props.onProgress,
606
+ onRemove = props.onRemove,
607
+ _beforeUpload = props.beforeUpload,
608
+ onChange = props.onChange,
609
+ _props$defaultFileLis = props.defaultFileList,
610
+ defaultFileList = _props$defaultFileLis === void 0 ? [] : _props$defaultFileLis,
611
+ fileList = props.fileList,
612
+ _props$showUploadList = props.showUploadList,
613
+ showUploadList = _props$showUploadList === void 0 ? true : _props$showUploadList,
614
+ maxCount = props.maxCount,
615
+ _props$children = props.children,
616
+ children = _props$children === void 0 ? null : _props$children,
617
+ itemRender = props.itemRender,
618
+ _props$showUploadErro = props.showUploadError,
619
+ showUploadError = _props$showUploadErro === void 0 ? false : _props$showUploadErro,
620
+ _props$stash = props.stash,
621
+ stash = _props$stash === void 0 ? false : _props$stash,
622
+ _props$uploading = props.uploading,
623
+ uploading = _props$uploading === void 0 ? true : _props$uploading,
624
+ _props$loading = props.loading,
625
+ loading = _props$loading === void 0 ? false : _props$loading,
626
+ _props$showLoading = props.showLoading,
627
+ showLoadingProp = _props$showLoading === void 0 ? false : _props$showLoading,
628
+ defaultImage = props.defaultImage,
629
+ readonly = props.readonly,
630
+ onPreview = props.onPreview,
631
+ actionRender = props.actionRender,
632
+ operateBtnProps = props.operateBtnProps,
633
+ disabledTooltip = props.disabledTooltip,
634
+ removeErrorTip = props.removeErrorTip,
635
+ restProps = __rest(props, ["className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "stash", "uploading", "loading", "showLoading", "defaultImage", "readonly", "onPreview", "actionRender", "operateBtnProps", "disabledTooltip", "removeErrorTip"]);
636
+ var intl = useFormatMessage('Upload', localeJson);
637
+ var _useState = useState(defaultFileList),
638
+ _useState2 = _slicedToArray(_useState, 2),
639
+ uploadFileList = _useState2[0],
640
+ setUploadFileList = _useState2[1]; //文件列表
641
+ var _useState3 = useState(false),
642
+ _useState4 = _slicedToArray(_useState3, 2),
643
+ showLoading = _useState4[0],
644
+ setShowLoading = _useState4[1]; //upload loading
645
+ var _useState5 = useState(false),
646
+ _useState6 = _slicedToArray(_useState5, 2),
647
+ errTip = _useState6[0],
648
+ setErrTip = _useState6[1]; //upload error tip
649
+ var _useState7 = useState({
650
+ imageUrl: ''
252
651
  }),
253
- leaveDelay = 2000
254
- } = typeof showUploadError === 'boolean' ? {} : showUploadError; //错误信息提示
255
- const cropFileRef = useRef(); //裁剪文件
256
- useEffect(() => {
652
+ _useState8 = _slicedToArray(_useState7, 2),
653
+ avatar = _useState8[0],
654
+ setAvatar = _useState8[1]; //不显示列表时上传头像
655
+ var _ref = typeof showUploadList === 'boolean' ? {} : showUploadList,
656
+ showRemoveIcon = _ref.showRemoveIcon,
657
+ removeIcon = _ref.removeIcon,
658
+ showPreviewIcon = _ref.showPreviewIcon,
659
+ previewIcon = _ref.previewIcon; //显示上传列表
660
+ var _ref2 = typeof showUploadError === 'boolean' ? {} : showUploadError,
661
+ _ref2$uploadErrorMsg = _ref2.uploadErrorMsg,
662
+ uploadErrorMsg = _ref2$uploadErrorMsg === void 0 ? intl({
663
+ id: 'uploadError'
664
+ }) : _ref2$uploadErrorMsg,
665
+ _ref2$leaveDelay = _ref2.leaveDelay,
666
+ leaveDelay = _ref2$leaveDelay === void 0 ? 2000 : _ref2$leaveDelay; //错误信息提示
667
+ var cropFileRef = useRef(); //裁剪文件
668
+ var isAvatarMode = useMemo(function () {
669
+ return !showUploadList && avatar.imageUrl && !showLoading;
670
+ }, [showUploadList, avatar.imageUrl, showLoading]);
671
+ useEffect(function () {
257
672
  setShowLoading(loading);
258
673
  }, [loading]);
259
674
  //复写属性
260
- const overrideProps = Object.assign(Object.assign({
675
+ var overrideProps = Object.assign(Object.assign({
261
676
  accept: 'image/*'
262
677
  }, restProps), {
263
- beforeUpload: (file, fileList) => __awaiter(void 0, void 0, void 0, function* () {
264
- if (restProps.action && showLoadingProp && uploading) setShowLoading(true);
265
- const result = yield beforeUpload === null || beforeUpload === void 0 ? void 0 : beforeUpload(file, fileList);
266
- if (result === false) {
267
- setShowLoading(false);
268
- return false;
269
- } else if (typeof result === 'object' && result) {
270
- if (result instanceof File || result instanceof Blob) return result;
271
- cropFileRef.current = result.cropFile;
272
- return result.isUpload;
273
- } else return true;
274
- }),
275
- onStart(file) {
276
- onStart === null || onStart === void 0 ? void 0 : onStart(file);
678
+ beforeUpload: function beforeUpload(file, fileList) {
679
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
680
+ var result;
681
+ return regenerator.wrap(function _callee$(_context) {
682
+ while (1) switch (_context.prev = _context.next) {
683
+ case 0:
684
+ if (restProps.action && showLoadingProp && uploading) setShowLoading(true);
685
+ _context.next = 3;
686
+ return _beforeUpload === null || _beforeUpload === void 0 ? void 0 : _beforeUpload(file, fileList);
687
+ case 3:
688
+ result = _context.sent;
689
+ if (!(result === false)) {
690
+ _context.next = 9;
691
+ break;
692
+ }
693
+ setShowLoading(false);
694
+ return _context.abrupt("return", false);
695
+ case 9:
696
+ if (!(_typeof(result) === 'object' && result)) {
697
+ _context.next = 16;
698
+ break;
699
+ }
700
+ if (!(result instanceof File || result instanceof Blob)) {
701
+ _context.next = 12;
702
+ break;
703
+ }
704
+ return _context.abrupt("return", result);
705
+ case 12:
706
+ cropFileRef.current = result.cropFile;
707
+ return _context.abrupt("return", result.isUpload);
708
+ case 16:
709
+ return _context.abrupt("return", true);
710
+ case 17:
711
+ case "end":
712
+ return _context.stop();
713
+ }
714
+ }, _callee);
715
+ }));
277
716
  },
278
- onSuccess(response, file, xhr) {
717
+ onStart: function onStart(file) {
718
+ _onStart === null || _onStart === void 0 ? void 0 : _onStart(file);
719
+ },
720
+ onSuccess: function onSuccess(response, file, xhr) {
279
721
  setShowLoading(false);
280
722
  errTip && showErrTip(false);
281
- const nextFileList = updateFileList(file);
723
+ var nextFileList = updateFileList(file);
282
724
  onInternalChange(nextFileList);
283
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(response, file, xhr);
725
+ _onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess(response, file, xhr);
284
726
  },
285
- onError(error, response, file) {
727
+ onError: function onError(error, response, file) {
286
728
  setShowLoading(false);
287
729
  showErrTip(!!showUploadError);
288
- onError === null || onError === void 0 ? void 0 : onError(error, response, file);
730
+ if (!showUploadError) {
731
+ file.status = 'error';
732
+ file.response = (error === null || error === void 0 ? void 0 : error.message) || uploadErrorMsg;
733
+ var nextFileList = updateFileList(file);
734
+ onInternalChange(nextFileList);
735
+ }
736
+ _onError === null || _onError === void 0 ? void 0 : _onError(error, response, file);
289
737
  },
290
- onProgress(e, file) {
291
- onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, file);
738
+ onProgress: function onProgress(e, file) {
739
+ _onProgress === null || _onProgress === void 0 ? void 0 : _onProgress(e, file);
292
740
  },
293
- onBatchStart(fileList) {
741
+ onBatchStart: function onBatchStart(fileList) {
294
742
  if (stash) {
295
743
  if (cropFileRef.current) {
296
- const idx = fileList.findIndex(_ => {
744
+ var idx = fileList.findIndex(function (_) {
297
745
  var _a;
298
746
  return _.file.uid === ((_a = cropFileRef.current) === null || _a === void 0 ? void 0 : _a.uid);
299
747
  });
@@ -304,40 +752,62 @@ const ImageUpload = props => {
304
752
  });
305
753
  }
306
754
  }
307
- const arr = fileList.map(_ => _.parsedFile || _.file);
308
- const mList = mergedFileList(arr);
755
+ var arr = fileList.map(function (_) {
756
+ return _.parsedFile || _.file;
757
+ });
758
+ var mList = mergedFileList(arr);
309
759
  onInternalChange(mList);
310
760
  }
311
761
  }
312
762
  });
313
763
  //内部变化
314
- const onInternalChange = changedFileList => __awaiter(void 0, void 0, void 0, function* () {
315
- let cloneList = [...changedFileList];
316
- if (!showUploadList) {
317
- //不显示上传列表
318
- const file = cloneList.slice(-1)[0];
319
- if (file) {
320
- const imageUrl = yield readerFileAsDataUrl(file);
321
- file.dataUrl = imageUrl;
322
- avatar.imageUrl = imageUrl;
323
- avatar.imageName = file.name;
324
- setAvatar(Object.assign({}, avatar));
325
- }
326
- onChange === null || onChange === void 0 ? void 0 : onChange([file]);
327
- return;
328
- }
329
- if (maxCount === 1) {
330
- cloneList = cloneList.slice(-1);
331
- } else if (maxCount) {
332
- cloneList = cloneList.slice(0, maxCount);
333
- }
334
- onChange === null || onChange === void 0 ? void 0 : onChange(cloneList);
335
- setUploadFileList(cloneList);
336
- });
764
+ var onInternalChange = function onInternalChange(changedFileList) {
765
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
766
+ var cloneList, file, imageUrl;
767
+ return regenerator.wrap(function _callee2$(_context2) {
768
+ while (1) switch (_context2.prev = _context2.next) {
769
+ case 0:
770
+ cloneList = _toConsumableArray(changedFileList);
771
+ if (showUploadList) {
772
+ _context2.next = 13;
773
+ break;
774
+ }
775
+ //不显示上传列表
776
+ file = cloneList.slice(-1)[0];
777
+ if (!file) {
778
+ _context2.next = 11;
779
+ break;
780
+ }
781
+ _context2.next = 6;
782
+ return readerFileAsDataUrl(file);
783
+ case 6:
784
+ imageUrl = _context2.sent;
785
+ file.dataUrl = imageUrl;
786
+ avatar.imageUrl = imageUrl;
787
+ avatar.imageName = file.name;
788
+ setAvatar(Object.assign({}, avatar));
789
+ case 11:
790
+ onChange === null || onChange === void 0 ? void 0 : onChange([file]);
791
+ return _context2.abrupt("return");
792
+ case 13:
793
+ if (maxCount === 1) {
794
+ cloneList = cloneList.slice(-1);
795
+ } else if (maxCount) {
796
+ cloneList = cloneList.slice(0, maxCount);
797
+ }
798
+ onChange === null || onChange === void 0 ? void 0 : onChange(cloneList);
799
+ setUploadFileList(cloneList);
800
+ case 16:
801
+ case "end":
802
+ return _context2.stop();
803
+ }
804
+ }, _callee2);
805
+ }));
806
+ };
337
807
  //更新文件列表
338
- const updateFileList = file => {
339
- const cloneList = [...uploadFileList];
340
- const fileObj = Object.assign(Object.assign({}, file), {
808
+ var updateFileList = function updateFileList(file) {
809
+ var cloneList = _toConsumableArray(uploadFileList);
810
+ var fileObj = Object.assign(Object.assign({}, file), {
341
811
  lastModified: file.lastModified,
342
812
  lastModifiedDate: file.lastModifiedDate,
343
813
  name: file.name,
@@ -349,9 +819,9 @@ const ImageUpload = props => {
349
819
  return cloneList.concat(fileObj);
350
820
  };
351
821
  //合并文件列表
352
- const mergedFileList = fileList => {
353
- const cloneList = [...uploadFileList];
354
- const newFileList = fileList.map(file => {
822
+ var mergedFileList = function mergedFileList(fileList) {
823
+ var cloneList = _toConsumableArray(uploadFileList);
824
+ var newFileList = fileList.map(function (file) {
355
825
  return Object.assign(Object.assign({}, file), {
356
826
  lastModified: file.lastModified,
357
827
  lastModifiedDate: file.lastModifiedDate,
@@ -365,77 +835,94 @@ const ImageUpload = props => {
365
835
  return cloneList.concat(newFileList);
366
836
  };
367
837
  //删除文件
368
- const handleRemove = file => {
369
- Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(ret => {
838
+ var handleRemove = function handleRemove(file) {
839
+ Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(function (ret) {
370
840
  // Prevent removing file
371
841
  if (ret === false) return;
372
- const idx = uploadFileList.findIndex(_ => _.uid === file.uid);
842
+ var idx = uploadFileList.findIndex(function (_) {
843
+ return _.uid === file.uid;
844
+ });
373
845
  if (idx > -1) uploadFileList.splice(idx, 1);
374
846
  onInternalChange(uploadFileList);
375
847
  });
376
848
  };
377
849
  //读取dataUrl
378
- const readerFileAsDataUrl = file => __awaiter(void 0, void 0, void 0, function* () {
379
- return new Promise(resolve => {
380
- const fileReader = new FileReader();
381
- if (file.originFileObj) {
382
- fileReader.onload = () => {
383
- resolve(fileReader.result);
384
- };
385
- fileReader.readAsDataURL(file.originFileObj);
386
- } else resolve('');
387
- });
388
- });
850
+ var readerFileAsDataUrl = function readerFileAsDataUrl(file) {
851
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee3() {
852
+ return regenerator.wrap(function _callee3$(_context3) {
853
+ while (1) switch (_context3.prev = _context3.next) {
854
+ case 0:
855
+ return _context3.abrupt("return", new Promise(function (resolve) {
856
+ var fileReader = new FileReader();
857
+ if (file.originFileObj) {
858
+ fileReader.onload = function () {
859
+ resolve(fileReader.result);
860
+ };
861
+ fileReader.readAsDataURL(file.originFileObj);
862
+ } else resolve('');
863
+ }));
864
+ case 1:
865
+ case "end":
866
+ return _context3.stop();
867
+ }
868
+ }, _callee3);
869
+ }));
870
+ };
389
871
  //显示错误提示
390
- const showErrTip = flag => {
872
+ var showErrTip = function showErrTip(flag) {
391
873
  setErrTip(flag);
392
874
  if (leaveDelay < 0) return;
393
- setTimeout(() => {
875
+ setTimeout(function () {
394
876
  setErrTip(false);
395
877
  }, leaveDelay);
396
878
  };
397
- useEffect(() => {
879
+ useEffect(function () {
398
880
  if (fileList) {
399
- setUploadFileList([...fileList]);
881
+ setUploadFileList(_toConsumableArray(fileList));
400
882
  }
401
883
  }, [fileList]);
402
- useEffect(() => {
884
+ useEffect(function () {
403
885
  if (defaultImage) {
404
886
  setAvatar(Object.assign({}, defaultImage));
405
887
  }
406
888
  }, [defaultImage]);
407
889
  //渲染上传列表
408
- const renderUploadList = () => showUploadList && jsx(UploadList, {
409
- listType: 'picture-card',
410
- readonly: readonly,
411
- items: uploadFileList,
412
- showRemoveIcon: showRemoveIcon,
413
- removeIcon: removeIcon,
414
- onRemove: handleRemove,
415
- itemRender: itemRender
416
- });
417
- //渲染内容
418
- const renderUploadContent = () => {
890
+ var renderUploadList = function renderUploadList() {
891
+ return showUploadList && jsx(UploadList, {
892
+ listType: 'picture-card',
893
+ readonly: readonly,
894
+ items: uploadFileList,
895
+ showRemoveIcon: showRemoveIcon,
896
+ removeIcon: removeIcon,
897
+ showPreviewIcon: showPreviewIcon,
898
+ previewIcon: previewIcon,
899
+ onRemove: handleRemove,
900
+ itemRender: itemRender,
901
+ onPreview: onPreview,
902
+ actionRender: actionRender,
903
+ operateBtnProps: operateBtnProps
904
+ });
905
+ };
906
+ //渲染内容 avatar
907
+ var renderUploadContent = function renderUploadContent() {
419
908
  var _a;
420
- if (!showUploadList && avatar.imageUrl && !showLoading) {
421
- return jsxs("div", Object.assign({
422
- className: 'upload-img-wrapper'
909
+ var avatarUploadNode = jsxs("div", Object.assign({
910
+ className: 'upload-img-wrapper'
911
+ }, {
912
+ children: [jsx("img", {
913
+ src: avatar.imageUrl,
914
+ alt: (_a = avatar.imageName) !== null && _a !== void 0 ? _a : ''
915
+ }), avatar.imageName && jsx("span", Object.assign({
916
+ className: 'upload-img-wrapper-name'
423
917
  }, {
424
- children: [jsx("img", {
425
- src: avatar.imageUrl,
426
- alt: (_a = avatar.imageName) !== null && _a !== void 0 ? _a : ''
427
- }), avatar.imageName && jsx("span", Object.assign({
428
- className: 'upload-img-wrapper-name'
429
- }, {
430
- children: avatar.imageName
431
- })), jsx("span", Object.assign({
432
- className: 'upload-img-wrapper-action'
433
- }, {
434
- children: jsx(EditOutline, {})
435
- }))]
436
- }));
437
- }
438
- return jsxs(Fragment, {
918
+ children: avatar.imageName
919
+ })), jsx("span", Object.assign({
920
+ className: 'upload-img-wrapper-action'
921
+ }, {
922
+ children: jsx(EditOutline, {})
923
+ }))]
924
+ }));
925
+ var uploadNode = jsxs(Fragment, {
439
926
  children: [showLoading ? jsx(LoadingIcon, {
440
927
  className: 'upload-image-loading'
441
928
  }) : jsx(UploadIcon, {
@@ -448,9 +935,26 @@ const ImageUpload = props => {
448
935
  }) : children
449
936
  }))]
450
937
  });
938
+ if (restProps.disabled && disabledTooltip && (disabledTooltip === null || disabledTooltip === void 0 ? void 0 : disabledTooltip.title)) return jsx(Tooltip, Object.assign({
939
+ followCursor: true
940
+ }, disabledTooltip || {}, {
941
+ disabled: true
942
+ }, {
943
+ children: jsx("div", Object.assign({
944
+ className: "upload-image-select-tooltip-wrapper"
945
+ }, {
946
+ children: uploadNode
947
+ }))
948
+ }));
949
+ if (isAvatarMode) {
950
+ return avatarUploadNode;
951
+ }
952
+ return jsx(Fragment, {
953
+ children: uploadNode
954
+ });
451
955
  };
452
956
  //渲染上传控件
453
- const renderUploadSelector = () => {
957
+ var renderUploadSelector = function renderUploadSelector() {
454
958
  if (readonly) return null;
455
959
  return jsxs("div", Object.assign({
456
960
  className: clsx('upload-image-select', showLoading && 'upload-image-select-loading')
@@ -459,11 +963,11 @@ const ImageUpload = props => {
459
963
  prefixCls: "".concat($rcPrefixCls, "-upload")
460
964
  }, {
461
965
  children: jsx("div", Object.assign({
462
- className: 'upload-image-picture-card'
966
+ className: "".concat(isAvatarMode ? 'is-avatar ' : '', "upload-image-picture-card")
463
967
  }, {
464
968
  children: renderUploadContent()
465
969
  }))
466
- })), errTip && jsx(ErrorTip, {
970
+ })), errTip && !removeErrorTip && jsx(ErrorTip, {
467
971
  message: uploadErrorMsg,
468
972
  className: "".concat($prefixCls, "-upload-error-image")
469
973
  })]
@@ -478,7 +982,7 @@ const ImageUpload = props => {
478
982
  };
479
983
 
480
984
  //Dragger upload
481
- const Dragger = props => {
985
+ var Dragger = function Dragger(props) {
482
986
  return jsx(Upload, Object.assign({}, props, {
483
987
  type: 'drag'
484
988
  }));
@@ -491,6 +995,18 @@ var INIT_ROTATE = 0;
491
995
  var ROTATE_STEP = 1;
492
996
  var MIN_ROTATE = -180;
493
997
  var MAX_ROTATE = 180;
998
+ var DEFAULT_ZOOM_MARKS = {
999
+ '0.5': '',
1000
+ '1': '',
1001
+ '1.5': '',
1002
+ '2': '',
1003
+ '2.5': ''
1004
+ };
1005
+ var DEFAULT_ROTATE_MARKS = {
1006
+ '-90': '',
1007
+ '0': '',
1008
+ '90': ''
1009
+ };
494
1010
 
495
1011
  var EasyCrop = /*#__PURE__*/forwardRef(function (props, ref) {
496
1012
  var cropperRef = props.cropperRef,
@@ -503,7 +1019,11 @@ var EasyCrop = /*#__PURE__*/forwardRef(function (props, ref) {
503
1019
  minZoom = props.minZoom,
504
1020
  maxZoom = props.maxZoom,
505
1021
  fixedCropSize = props.fixedCropSize,
506
- cropperProps = props.cropperProps;
1022
+ cropperProps = props.cropperProps,
1023
+ zoomMarks = props.zoomMarks,
1024
+ rotateMarks = props.rotateMarks,
1025
+ rotateTipFormatter = props.rotateTipFormatter,
1026
+ zoomTipFormatter = props.zoomTipFormatter;
507
1027
  var _useState = useState({
508
1028
  x: 0,
509
1029
  y: 0
@@ -554,6 +1074,11 @@ var EasyCrop = /*#__PURE__*/forwardRef(function (props, ref) {
554
1074
  var onCropComplete = useCallback(function (croppedArea, croppedAreaPixels) {
555
1075
  cropPixelsRef.current = croppedAreaPixels;
556
1076
  }, []);
1077
+ var genMarks = function genMarks(marks, defaultMarks) {
1078
+ if (marks === false || marks === undefined) return;
1079
+ if (marks === true) return defaultMarks;
1080
+ return marks;
1081
+ };
557
1082
  //ref 暴露方法
558
1083
  useImperativeHandle(ref, function () {
559
1084
  return {
@@ -584,331 +1109,430 @@ var EasyCrop = /*#__PURE__*/forwardRef(function (props, ref) {
584
1109
  onCropComplete: onCropComplete,
585
1110
  classes: {
586
1111
  containerClassName: "".concat(PREFIX, "-container"),
587
- mediaClassName: "".concat(PREFIX, "-media")
1112
+ mediaClassName: "".concat(PREFIX, "-media"),
1113
+ cropAreaClassName: "".concat(PREFIX, "-crop")
588
1114
  }
589
- })), zoom && jsxs("section", Object.assign({
1115
+ })), zoom && jsx("section", Object.assign({
590
1116
  className: "".concat(PREFIX, "-control ").concat(PREFIX, "-control-zoom")
591
1117
  }, {
592
- children: [jsx("button", Object.assign({
593
- onClick: function onClick() {
594
- return setZoomVal(zoomVal - ZOOM_STEP);
595
- },
596
- disabled: zoomVal - ZOOM_STEP < minZoom
597
- }, {
598
- children: "\uFF0D"
599
- })), jsx(Slider, {
1118
+ children: jsx(Slider, {
1119
+ marks: genMarks(zoomMarks, DEFAULT_ZOOM_MARKS),
1120
+ prefix: jsx(Button.IconButton, Object.assign({
1121
+ disabled: zoomVal - ZOOM_STEP < minZoom,
1122
+ variant: 'text',
1123
+ onClick: function onClick() {
1124
+ return setZoomVal(zoomVal - ZOOM_STEP);
1125
+ }
1126
+ }, {
1127
+ children: jsx(MinusCircle, {})
1128
+ })),
1129
+ suffix: jsx(Button.IconButton, Object.assign({
1130
+ variant: 'text',
1131
+ onClick: function onClick() {
1132
+ return setZoomVal(zoomVal + ZOOM_STEP);
1133
+ },
1134
+ disabled: zoomVal + ZOOM_STEP > maxZoom
1135
+ }, {
1136
+ children: jsx(PlusCircle, {})
1137
+ })),
600
1138
  min: minZoom,
601
1139
  max: maxZoom,
602
1140
  step: ZOOM_STEP,
603
1141
  value: zoomVal,
604
- onChange: setZoomVal
605
- }), jsx("button", Object.assign({
606
- onClick: function onClick() {
607
- return setZoomVal(zoomVal + ZOOM_STEP);
608
- },
609
- disabled: zoomVal + ZOOM_STEP > maxZoom
610
- }, {
611
- children: "\uFF0B"
612
- }))]
613
- })), rotate && jsxs("section", Object.assign({
1142
+ onChange: setZoomVal,
1143
+ tipFormatter: zoomTipFormatter
1144
+ })
1145
+ })), rotate && jsx("section", Object.assign({
614
1146
  className: "".concat(PREFIX, "-control ").concat(PREFIX, "-control-rotate")
615
1147
  }, {
616
- children: [jsx("button", Object.assign({
617
- onClick: function onClick() {
618
- return setRotateVal(rotateVal - ROTATE_STEP);
619
- },
620
- disabled: rotateVal === MIN_ROTATE
621
- }, {
622
- children: "\u21BA"
623
- })), jsx(Slider, {
1148
+ children: jsx(Slider, {
1149
+ marks: genMarks(rotateMarks, DEFAULT_ROTATE_MARKS),
624
1150
  min: MIN_ROTATE,
625
1151
  max: MAX_ROTATE,
626
1152
  step: ROTATE_STEP,
627
1153
  value: rotateVal,
628
- onChange: setRotateVal
629
- }), jsx("button", Object.assign({
630
- onClick: function onClick() {
631
- return setRotateVal(rotateVal + ROTATE_STEP);
632
- },
633
- disabled: rotateVal === MAX_ROTATE
634
- }, {
635
- children: "\u21BB"
636
- }))]
1154
+ onChange: setRotateVal,
1155
+ tipFormatter: rotateTipFormatter,
1156
+ prefix: jsx(Button.IconButton, Object.assign({
1157
+ variant: 'text',
1158
+ onClick: function onClick() {
1159
+ return setRotateVal(rotateVal - ROTATE_STEP);
1160
+ },
1161
+ disabled: rotateVal === MIN_ROTATE
1162
+ }, {
1163
+ children: jsx(TurnLeft, {})
1164
+ })),
1165
+ suffix: jsx(Button.IconButton, Object.assign({
1166
+ variant: 'text',
1167
+ onClick: function onClick() {
1168
+ return setRotateVal(rotateVal + ROTATE_STEP);
1169
+ },
1170
+ disabled: rotateVal === MAX_ROTATE
1171
+ }, {
1172
+ children: jsx(TurnRight, {})
1173
+ }))
1174
+ })
637
1175
  }))]
638
1176
  });
639
1177
  });
640
1178
  var EasyCrop$1 = /*#__PURE__*/memo(EasyCrop);
641
1179
 
642
- var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2022/4/20 下午4:44\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-container {\n position: relative;\n width: 100%;\n height: 40vh;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control {\n display: flex;\n align-items: center;\n width: 60%;\n margin-left: auto;\n margin-right: auto;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control:first-of-type {\n margin-top: 16px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control:last-of-type {\n margin-bottom: -8px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control button {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 34px;\n height: 34px;\n padding: 0;\n font-style: normal;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control button[disabled] {\n cursor: default;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control button + div:only-of-type {\n flex: 1;\n margin: 0 8px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control-zoom button {\n font-size: 18px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control-rotate button {\n font-size: 16px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control-rotate button:first-of-type {\n transform: rotate(-20deg);\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control-rotate button:last-of-type {\n transform: rotate(20deg);\n}";
1180
+ var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2022/4/20 下午4:44\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-container {\n position: relative;\n width: 100%;\n height: 40vh;\n border-radius: 4px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-container .paraui-v4-img-crop-crop {\n border-radius: 4px;\n border: none;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control {\n display: flex;\n align-items: center;\n width: 60%;\n margin-left: auto;\n margin-right: auto;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control:first-of-type {\n margin-top: 10px;\n margin-bottom: 10px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control button {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 0;\n font-style: normal;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control button[disabled] {\n cursor: default;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control button + div:only-of-type {\n flex: 1;\n margin: 0 8px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control-zoom, .paraui-v4-img-crop-modal .paraui-v4-img-crop-control-rotate {\n width: 100%;\n background-color: rgb(247, 248, 250);\n border-radius: 4px;\n height: 32px;\n padding: 0 10px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control-zoom button {\n font-size: 18px;\n}\n.paraui-v4-img-crop-modal .paraui-v4-img-crop-control-rotate button {\n font-size: 16px;\n}";
643
1181
  styleInject(css_248z$1);
644
1182
 
645
1183
  //图片裁剪组件
646
- const ImgCrop = /*#__PURE__*/forwardRef((props, ref) => {
647
- const {
648
- aspect = 1,
649
- shape = 'rect',
650
- grid = false,
651
- quality = 0.4,
652
- fillColor = 'transparent',
653
- zoom = true,
654
- rotate = false,
655
- minZoom = 1,
656
- maxZoom = 3,
657
- modalTitle,
658
- modalWidth,
659
- modalOk,
660
- modalCancel,
661
- onModalOk,
662
- onModalCancel,
663
- beforeCrop,
664
- onUploadFail,
665
- cropperProps,
666
- children,
667
- fixedCropSize = {
1184
+ var ImgCrop = /*#__PURE__*/forwardRef(function (props, ref) {
1185
+ var _props$aspect = props.aspect,
1186
+ aspect = _props$aspect === void 0 ? 1 : _props$aspect,
1187
+ _props$shape = props.shape,
1188
+ shape = _props$shape === void 0 ? 'rect' : _props$shape,
1189
+ _props$grid = props.grid,
1190
+ grid = _props$grid === void 0 ? false : _props$grid,
1191
+ _props$quality = props.quality,
1192
+ quality = _props$quality === void 0 ? 0.4 : _props$quality,
1193
+ _props$fillColor = props.fillColor,
1194
+ fillColor = _props$fillColor === void 0 ? 'transparent' : _props$fillColor,
1195
+ _props$zoom = props.zoom,
1196
+ zoom = _props$zoom === void 0 ? true : _props$zoom,
1197
+ _props$rotate = props.rotate,
1198
+ rotate = _props$rotate === void 0 ? false : _props$rotate,
1199
+ _props$minZoom = props.minZoom,
1200
+ minZoom = _props$minZoom === void 0 ? 1 : _props$minZoom,
1201
+ _props$maxZoom = props.maxZoom,
1202
+ maxZoom = _props$maxZoom === void 0 ? 3 : _props$maxZoom,
1203
+ modalTitle = props.modalTitle,
1204
+ modalWidth = props.modalWidth,
1205
+ modalOk = props.modalOk,
1206
+ modalCancel = props.modalCancel,
1207
+ onModalOk = props.onModalOk,
1208
+ onModalCancel = props.onModalCancel,
1209
+ beforeCrop = props.beforeCrop,
1210
+ onUploadFail = props.onUploadFail,
1211
+ cropperProps = props.cropperProps,
1212
+ children = props.children,
1213
+ _props$fixedCropSize = props.fixedCropSize,
1214
+ fixedCropSize = _props$fixedCropSize === void 0 ? {
668
1215
  width: 120,
669
1216
  height: 120
670
- }
671
- } = props;
672
- const intl = useFormatMessage('Upload', localeJson);
673
- const [image, setImage] = useState('');
674
- const fileRef = useRef();
675
- const beforeUploadRef = useRef();
676
- const resolveRef = useRef();
677
- const rejectRef = useRef();
1217
+ } : _props$fixedCropSize,
1218
+ _props$zoomTipFormatt = props.zoomTipFormatter,
1219
+ zoomTipFormatter = _props$zoomTipFormatt === void 0 ? function (val) {
1220
+ return "".concat(Number(val) * 10 * 10);
1221
+ } : _props$zoomTipFormatt,
1222
+ _props$zoomMarks = props.zoomMarks,
1223
+ zoomMarks = _props$zoomMarks === void 0 ? true : _props$zoomMarks,
1224
+ _props$rotateMarks = props.rotateMarks,
1225
+ rotateMarks = _props$rotateMarks === void 0 ? true : _props$rotateMarks,
1226
+ _props$rotateTipForma = props.rotateTipFormatter,
1227
+ rotateTipFormatter = _props$rotateTipForma === void 0 ? function (val) {
1228
+ return "".concat(val);
1229
+ } : _props$rotateTipForma;
1230
+ var intl = useFormatMessage('Upload', localeJson);
1231
+ var _useState = useState(''),
1232
+ _useState2 = _slicedToArray(_useState, 2),
1233
+ image = _useState2[0],
1234
+ setImage = _useState2[1];
1235
+ var fileRef = useRef();
1236
+ var beforeUploadRef = useRef();
1237
+ var resolveRef = useRef();
1238
+ var rejectRef = useRef();
678
1239
  //存储回调
679
- const cbRef = useRef({});
1240
+ var cbRef = useRef({});
680
1241
  cbRef.current.onModalOk = onModalOk;
681
1242
  cbRef.current.onModalCancel = onModalCancel;
682
1243
  cbRef.current.beforeCrop = beforeCrop;
683
1244
  cbRef.current.onUploadFail = onUploadFail;
684
- const easyCropRef = useRef({});
1245
+ var easyCropRef = useRef({});
685
1246
  //上传组件
686
- const uploadComponent = useMemo(() => {
687
- const upload = Array.isArray(children) ? children[0] : children;
688
- const _a = upload.props,
689
- {
690
- beforeUpload,
691
- accept
692
- } = _a,
1247
+ var uploadComponent = useMemo(function () {
1248
+ var upload = Array.isArray(children) ? children[0] : children;
1249
+ var _a = upload.props,
1250
+ beforeUpload = _a.beforeUpload,
1251
+ accept = _a.accept,
693
1252
  restUploadProps = __rest(_a, ["beforeUpload", "accept"]);
694
1253
  beforeUploadRef.current = beforeUpload;
695
1254
  return Object.assign(Object.assign({}, upload), {
696
1255
  props: Object.assign(Object.assign({}, restUploadProps), {
697
1256
  accept: accept || 'image/*',
698
- beforeUpload: (file, fileList) => {
699
- return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
700
- if (cbRef.current.beforeCrop && !(yield cbRef.current.beforeCrop(file, fileList))) {
701
- reject();
702
- return;
703
- }
704
- fileRef.current = file;
705
- resolveRef.current = function (newFile) {
706
- let flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
707
- var _a, _b;
708
- (_b = (_a = cbRef.current).onModalOk) === null || _b === void 0 ? void 0 : _b.call(_a, newFile);
709
- if (!flag) return resolve({
710
- cropFile: newFile,
711
- isUpload: flag
712
- });
713
- resolve(newFile);
714
- };
715
- rejectRef.current = uploadErr => {
716
- var _a, _b;
717
- (_b = (_a = cbRef.current).onUploadFail) === null || _b === void 0 ? void 0 : _b.call(_a, uploadErr);
718
- reject(uploadErr);
719
- };
720
- const reader = new FileReader();
721
- reader.addEventListener('load', () => typeof reader.result === 'string' && setImage(reader.result));
722
- reader.readAsDataURL(file);
723
- }));
1257
+ beforeUpload: function beforeUpload(file, fileList) {
1258
+ return new Promise(function (resolve, reject) {
1259
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
1260
+ var reader;
1261
+ return regenerator.wrap(function _callee$(_context) {
1262
+ while (1) switch (_context.prev = _context.next) {
1263
+ case 0:
1264
+ _context.t0 = cbRef.current.beforeCrop;
1265
+ if (!_context.t0) {
1266
+ _context.next = 5;
1267
+ break;
1268
+ }
1269
+ _context.next = 4;
1270
+ return cbRef.current.beforeCrop(file, fileList);
1271
+ case 4:
1272
+ _context.t0 = !_context.sent;
1273
+ case 5:
1274
+ if (!_context.t0) {
1275
+ _context.next = 8;
1276
+ break;
1277
+ }
1278
+ reject();
1279
+ return _context.abrupt("return");
1280
+ case 8:
1281
+ fileRef.current = file;
1282
+ resolveRef.current = function (newFile) {
1283
+ var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1284
+ var _a, _b;
1285
+ (_b = (_a = cbRef.current).onModalOk) === null || _b === void 0 ? void 0 : _b.call(_a, newFile);
1286
+ if (!flag) return resolve({
1287
+ cropFile: newFile,
1288
+ isUpload: flag
1289
+ });
1290
+ resolve(newFile);
1291
+ };
1292
+ rejectRef.current = function (uploadErr) {
1293
+ var _a, _b;
1294
+ (_b = (_a = cbRef.current).onUploadFail) === null || _b === void 0 ? void 0 : _b.call(_a, uploadErr);
1295
+ reject(uploadErr);
1296
+ };
1297
+ reader = new FileReader();
1298
+ reader.addEventListener('load', function () {
1299
+ return typeof reader.result === 'string' && setImage(reader.result);
1300
+ });
1301
+ reader.readAsDataURL(file);
1302
+ case 14:
1303
+ case "end":
1304
+ return _context.stop();
1305
+ }
1306
+ }, _callee);
1307
+ }));
1308
+ });
724
1309
  }
725
1310
  })
726
1311
  });
727
1312
  }, [children]);
728
1313
  //modal 关闭后操作
729
- const onClose = () => {
1314
+ var onClose = function onClose() {
730
1315
  setImage('');
731
1316
  easyCropRef.current.setZoomVal(INIT_ZOOM);
732
1317
  easyCropRef.current.setRotateVal(INIT_ROTATE);
733
1318
  };
734
1319
  //modal cancel
735
- const onCancel = useCallback(() => {
1320
+ var onCancel = useCallback(function () {
736
1321
  var _a, _b;
737
1322
  (_b = (_a = cbRef.current).onModalCancel) === null || _b === void 0 ? void 0 : _b.call(_a);
738
1323
  onClose();
739
1324
  }, []);
740
1325
  //modal ok
741
- const onOk = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
742
- onClose();
743
- const canvas = document.createElement('canvas');
744
- const ctx = canvas.getContext('2d');
745
- const imgSource = document.querySelector(".".concat(PREFIX, "-media"));
746
- const {
747
- width: cropWidth,
748
- height: cropHeight,
749
- x: cropX,
750
- y: cropY
751
- } = easyCropRef.current.cropPixelsRef.current;
752
- if (rotate && easyCropRef.current.rotateVal !== INIT_ROTATE) {
753
- const {
754
- naturalWidth: imgWidth,
755
- naturalHeight: imgHeight
756
- } = imgSource;
757
- const angle = easyCropRef.current.rotateVal * (Math.PI / 180);
758
- // get container for rotated image
759
- const sine = Math.abs(Math.sin(angle));
760
- const cosine = Math.abs(Math.cos(angle));
761
- const squareWidth = imgWidth * cosine + imgHeight * sine;
762
- const squareHeight = imgHeight * cosine + imgWidth * sine;
763
- canvas.width = squareWidth;
764
- canvas.height = squareHeight;
765
- ctx.fillStyle = fillColor;
766
- ctx.fillRect(0, 0, squareWidth, squareHeight);
767
- // rotate container
768
- const squareHalfWidth = squareWidth / 2;
769
- const squareHalfHeight = squareHeight / 2;
770
- ctx.translate(squareHalfWidth, squareHalfHeight);
771
- ctx.rotate(angle);
772
- ctx.translate(-squareHalfWidth, -squareHalfHeight);
773
- // draw rotated image
774
- const imgX = (squareWidth - imgWidth) / 2;
775
- const imgY = (squareHeight - imgHeight) / 2;
776
- ctx.drawImage(imgSource, 0, 0, imgWidth, imgHeight, imgX, imgY, imgWidth, imgHeight);
777
- // crop rotated image
778
- const imgData = ctx.getImageData(0, 0, squareWidth, squareHeight);
779
- canvas.width = cropWidth;
780
- canvas.height = cropHeight;
781
- ctx.putImageData(imgData, -cropX, -cropY);
782
- } else {
783
- canvas.width = cropWidth;
784
- canvas.height = cropHeight;
785
- ctx.fillStyle = fillColor;
786
- ctx.fillRect(0, 0, cropWidth, cropHeight);
787
- ctx.drawImage(imgSource, cropX, cropY, cropWidth, cropHeight, 0, 0, cropWidth, cropHeight);
788
- }
789
- //裁剪之后改变图片大小
790
- const changeImageSizeAfterCrop = newFile => {
791
- return new Promise(resolve => {
792
- const {
793
- name,
794
- type,
795
- uid
796
- } = newFile;
797
- const {
798
- width,
799
- height
800
- } = fixedCropSize; //固定裁剪大小
801
- const changeCanvas = document.createElement('canvas');
802
- const changeCtx = changeCanvas.getContext('2d');
803
- const img = new Image();
804
- img.onload = () => {
805
- changeCanvas.width = width;
806
- changeCanvas.height = height;
807
- changeCtx.drawImage(img, 0, 0, width, height);
808
- changeCanvas.toBlob(cBlob => {
809
- const changeFile = Object.assign(new File([cBlob], name, {
810
- type
811
- }), {
812
- uid
813
- });
814
- resolve(changeFile);
815
- }, type, quality);
816
- };
817
- img.onerror = () => {
818
- resolve(newFile);
819
- };
820
- const fileReader = new FileReader();
821
- fileReader.onload = () => {
822
- img.src = fileReader.result;
823
- };
824
- fileReader.onerror = () => {
825
- resolve(newFile);
826
- };
827
- fileReader.readAsDataURL(newFile);
828
- });
829
- };
830
- // get the new image
831
- let {
832
- type,
833
- name,
834
- uid
835
- } = fileRef.current;
836
- if (/svg/gi.test(type)) {
837
- //svg 转为 png
838
- type = 'image/png';
839
- const idx = name.lastIndexOf('.');
840
- if (idx > -1) name = "".concat(name.substring(0, idx), ".png");
841
- }
842
- //转为blob
843
- const onBlob = blob => __awaiter(void 0, void 0, void 0, function* () {
844
- var _a, _b, _c, _d, _e, _f;
845
- const newFile = Object.assign(new File([blob], name, {
846
- type
847
- }), {
848
- uid
849
- });
850
- const changeFile = yield changeImageSizeAfterCrop(newFile);
851
- if (typeof beforeUploadRef.current !== 'function') {
852
- return (_a = resolveRef.current) === null || _a === void 0 ? void 0 : _a.call(resolveRef, changeFile);
853
- }
854
- const res = beforeUploadRef.current(changeFile, [changeFile]);
855
- if (typeof res !== 'boolean' && !res) {
856
- console.error('beforeUpload must return a boolean or Promise');
857
- return;
858
- }
859
- if (res === true) return (_b = resolveRef.current) === null || _b === void 0 ? void 0 : _b.call(resolveRef, changeFile);
860
- if (res === false) return (_c = resolveRef.current) === null || _c === void 0 ? void 0 : _c.call(resolveRef, changeFile, false);
861
- if (res && res instanceof Promise) {
862
- try {
863
- const passedFile = yield res;
864
- if (passedFile instanceof File || passedFile instanceof Blob) {
865
- return (_d = resolveRef.current) === null || _d === void 0 ? void 0 : _d.call(resolveRef, passedFile);
866
- }
867
- (_e = resolveRef.current) === null || _e === void 0 ? void 0 : _e.call(resolveRef, changeFile, passedFile);
868
- } catch (err) {
869
- (_f = rejectRef.current) === null || _f === void 0 ? void 0 : _f.call(rejectRef, err);
1326
+ var onOk = useCallback(function () {
1327
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee3() {
1328
+ var canvas, ctx, imgSource, _easyCropRef$current$, cropWidth, cropHeight, cropX, cropY, imgWidth, imgHeight, angle, sine, cosine, squareWidth, squareHeight, squareHalfWidth, squareHalfHeight, imgX, imgY, imgData, changeImageSizeAfterCrop, _fileRef$current, type, name, uid, idx, onBlob;
1329
+ return regenerator.wrap(function _callee3$(_context3) {
1330
+ while (1) switch (_context3.prev = _context3.next) {
1331
+ case 0:
1332
+ onClose();
1333
+ canvas = document.createElement('canvas');
1334
+ ctx = canvas.getContext('2d');
1335
+ imgSource = document.querySelector(".".concat(PREFIX, "-media"));
1336
+ _easyCropRef$current$ = easyCropRef.current.cropPixelsRef.current, cropWidth = _easyCropRef$current$.width, cropHeight = _easyCropRef$current$.height, cropX = _easyCropRef$current$.x, cropY = _easyCropRef$current$.y;
1337
+ if (rotate && easyCropRef.current.rotateVal !== INIT_ROTATE) {
1338
+ imgWidth = imgSource.naturalWidth, imgHeight = imgSource.naturalHeight;
1339
+ angle = easyCropRef.current.rotateVal * (Math.PI / 180); // get container for rotated image
1340
+ sine = Math.abs(Math.sin(angle));
1341
+ cosine = Math.abs(Math.cos(angle));
1342
+ squareWidth = imgWidth * cosine + imgHeight * sine;
1343
+ squareHeight = imgHeight * cosine + imgWidth * sine;
1344
+ canvas.width = squareWidth;
1345
+ canvas.height = squareHeight;
1346
+ ctx.fillStyle = fillColor;
1347
+ ctx.fillRect(0, 0, squareWidth, squareHeight);
1348
+ // rotate container
1349
+ squareHalfWidth = squareWidth / 2;
1350
+ squareHalfHeight = squareHeight / 2;
1351
+ ctx.translate(squareHalfWidth, squareHalfHeight);
1352
+ ctx.rotate(angle);
1353
+ ctx.translate(-squareHalfWidth, -squareHalfHeight);
1354
+ // draw rotated image
1355
+ imgX = (squareWidth - imgWidth) / 2;
1356
+ imgY = (squareHeight - imgHeight) / 2;
1357
+ ctx.drawImage(imgSource, 0, 0, imgWidth, imgHeight, imgX, imgY, imgWidth, imgHeight);
1358
+ // crop rotated image
1359
+ imgData = ctx.getImageData(0, 0, squareWidth, squareHeight);
1360
+ canvas.width = cropWidth;
1361
+ canvas.height = cropHeight;
1362
+ ctx.putImageData(imgData, -cropX, -cropY);
1363
+ } else {
1364
+ canvas.width = cropWidth;
1365
+ canvas.height = cropHeight;
1366
+ ctx.fillStyle = fillColor;
1367
+ ctx.fillRect(0, 0, cropWidth, cropHeight);
1368
+ ctx.drawImage(imgSource, cropX, cropY, cropWidth, cropHeight, 0, 0, cropWidth, cropHeight);
1369
+ }
1370
+ //裁剪之后改变图片大小
1371
+ changeImageSizeAfterCrop = function changeImageSizeAfterCrop(newFile) {
1372
+ return new Promise(function (resolve) {
1373
+ var name = newFile.name,
1374
+ type = newFile.type,
1375
+ uid = newFile.uid;
1376
+ var width = fixedCropSize.width,
1377
+ height = fixedCropSize.height; //固定裁剪大小
1378
+ var changeCanvas = document.createElement('canvas');
1379
+ var changeCtx = changeCanvas.getContext('2d');
1380
+ var img = new Image();
1381
+ img.onload = function () {
1382
+ changeCanvas.width = width;
1383
+ changeCanvas.height = height;
1384
+ changeCtx.drawImage(img, 0, 0, width, height);
1385
+ changeCanvas.toBlob(function (cBlob) {
1386
+ var changeFile = Object.assign(new File([cBlob], name, {
1387
+ type: type
1388
+ }), {
1389
+ uid: uid
1390
+ });
1391
+ resolve(changeFile);
1392
+ }, type, quality);
1393
+ };
1394
+ img.onerror = function () {
1395
+ resolve(newFile);
1396
+ };
1397
+ var fileReader = new FileReader();
1398
+ fileReader.onload = function () {
1399
+ img.src = fileReader.result;
1400
+ };
1401
+ fileReader.onerror = function () {
1402
+ resolve(newFile);
1403
+ };
1404
+ fileReader.readAsDataURL(newFile);
1405
+ });
1406
+ }; // get the new image
1407
+ _fileRef$current = fileRef.current, type = _fileRef$current.type, name = _fileRef$current.name, uid = _fileRef$current.uid;
1408
+ if (/svg/gi.test(type)) {
1409
+ //svg 转为 png
1410
+ type = 'image/png';
1411
+ idx = name.lastIndexOf('.');
1412
+ if (idx > -1) name = "".concat(name.substring(0, idx), ".png");
1413
+ }
1414
+ //转为blob
1415
+ onBlob = function onBlob(blob) {
1416
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee2() {
1417
+ var _a, _b, _c, _d, _e, _f, newFile, changeFile, res, passedFile;
1418
+ return regenerator.wrap(function _callee2$(_context2) {
1419
+ while (1) switch (_context2.prev = _context2.next) {
1420
+ case 0:
1421
+ newFile = Object.assign(new File([blob], name, {
1422
+ type: type
1423
+ }), {
1424
+ uid: uid
1425
+ });
1426
+ _context2.next = 3;
1427
+ return changeImageSizeAfterCrop(newFile);
1428
+ case 3:
1429
+ changeFile = _context2.sent;
1430
+ if (!(typeof beforeUploadRef.current !== 'function')) {
1431
+ _context2.next = 6;
1432
+ break;
1433
+ }
1434
+ return _context2.abrupt("return", (_a = resolveRef.current) === null || _a === void 0 ? void 0 : _a.call(resolveRef, changeFile));
1435
+ case 6:
1436
+ res = beforeUploadRef.current(changeFile, [changeFile]);
1437
+ if (!(typeof res !== 'boolean' && !res)) {
1438
+ _context2.next = 10;
1439
+ break;
1440
+ }
1441
+ console.error('beforeUpload must return a boolean or Promise');
1442
+ return _context2.abrupt("return");
1443
+ case 10:
1444
+ if (!(res === true)) {
1445
+ _context2.next = 12;
1446
+ break;
1447
+ }
1448
+ return _context2.abrupt("return", (_b = resolveRef.current) === null || _b === void 0 ? void 0 : _b.call(resolveRef, changeFile));
1449
+ case 12:
1450
+ if (!(res === false)) {
1451
+ _context2.next = 14;
1452
+ break;
1453
+ }
1454
+ return _context2.abrupt("return", (_c = resolveRef.current) === null || _c === void 0 ? void 0 : _c.call(resolveRef, changeFile, false));
1455
+ case 14:
1456
+ if (!(res && res instanceof Promise)) {
1457
+ _context2.next = 27;
1458
+ break;
1459
+ }
1460
+ _context2.prev = 15;
1461
+ _context2.next = 18;
1462
+ return res;
1463
+ case 18:
1464
+ passedFile = _context2.sent;
1465
+ if (!(passedFile instanceof File || passedFile instanceof Blob)) {
1466
+ _context2.next = 21;
1467
+ break;
1468
+ }
1469
+ return _context2.abrupt("return", (_d = resolveRef.current) === null || _d === void 0 ? void 0 : _d.call(resolveRef, passedFile));
1470
+ case 21:
1471
+ (_e = resolveRef.current) === null || _e === void 0 ? void 0 : _e.call(resolveRef, changeFile, passedFile);
1472
+ _context2.next = 27;
1473
+ break;
1474
+ case 24:
1475
+ _context2.prev = 24;
1476
+ _context2.t0 = _context2["catch"](15);
1477
+ (_f = rejectRef.current) === null || _f === void 0 ? void 0 : _f.call(rejectRef, _context2.t0);
1478
+ case 27:
1479
+ case "end":
1480
+ return _context2.stop();
1481
+ }
1482
+ }, _callee2, null, [[15, 24]]);
1483
+ }));
1484
+ };
1485
+ canvas.toBlob(onBlob, type, quality);
1486
+ case 11:
1487
+ case "end":
1488
+ return _context3.stop();
870
1489
  }
871
- }
872
- });
873
- canvas.toBlob(onBlob, type, quality);
874
- }), [fillColor, quality, rotate]);
1490
+ }, _callee3);
1491
+ }));
1492
+ }, [fillColor, quality, rotate]);
875
1493
  //img crop 组件
876
- const getComponent = titleOfModal => jsxs(Fragment, {
877
- children: [uploadComponent, image && jsx(Modal, Object.assign({
878
- open: true,
879
- className: "".concat(PREFIX, "-modal"),
880
- size: 'md',
881
- title: titleOfModal !== null && titleOfModal !== void 0 ? titleOfModal : intl({
882
- id: 'editImage'
883
- }),
884
- onOk: onOk,
885
- onCancel: onCancel,
886
- okText: modalOk,
887
- cancelText: modalCancel,
888
- contentWidth: modalWidth
889
- }, {
890
- children: jsx(EasyCrop$1, {
891
- ref: easyCropRef,
892
- cropperRef: ref,
893
- image: image,
894
- aspect: aspect,
895
- shape: shape,
896
- grid: grid,
897
- zoom: zoom,
898
- rotate: rotate,
899
- minZoom: minZoom,
900
- maxZoom: maxZoom,
901
- fixedCropSize: fixedCropSize,
902
- cropperProps: cropperProps
903
- })
904
- }))]
905
- });
1494
+ var getComponent = function getComponent(titleOfModal) {
1495
+ return jsxs(Fragment, {
1496
+ children: [uploadComponent, image && jsx(Modal, Object.assign({
1497
+ open: true,
1498
+ className: "".concat(PREFIX, "-modal"),
1499
+ size: 'md',
1500
+ title: titleOfModal !== null && titleOfModal !== void 0 ? titleOfModal : intl({
1501
+ id: 'editImage'
1502
+ }),
1503
+ onOk: onOk,
1504
+ onCancel: onCancel,
1505
+ okText: modalOk,
1506
+ cancelText: modalCancel,
1507
+ contentWidth: modalWidth
1508
+ }, {
1509
+ children: jsx(EasyCrop$1, {
1510
+ ref: easyCropRef,
1511
+ cropperRef: ref,
1512
+ image: image,
1513
+ aspect: aspect,
1514
+ shape: shape,
1515
+ grid: grid,
1516
+ zoom: zoom,
1517
+ rotate: rotate,
1518
+ minZoom: minZoom,
1519
+ maxZoom: maxZoom,
1520
+ fixedCropSize: fixedCropSize,
1521
+ cropperProps: cropperProps,
1522
+ zoomTipFormatter: zoomTipFormatter,
1523
+ zoomMarks: zoomMarks,
1524
+ rotateMarks: rotateMarks,
1525
+ rotateTipFormatter: rotateTipFormatter
1526
+ })
1527
+ }))]
1528
+ });
1529
+ };
906
1530
  return jsx(Fragment, {
907
1531
  children: getComponent(modalTitle)
908
1532
  });
909
1533
  });
910
1534
 
911
- var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午1:40\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload .component-upload {\n position: relative;\n display: inline-block;\n}\n.paraui-v4-upload-loading {\n pointer-events: none;\n}\n.paraui-v4-upload-drag {\n position: relative;\n}\n.paraui-v4-upload-drag .component-upload {\n display: block;\n}\n.paraui-v4-upload-drag-loading {\n pointer-events: none;\n}\n.paraui-v4-upload-drag-hover .upload-drag-container {\n border-color: rgb(87, 131, 235);\n}\n.paraui-v4-upload-drag .upload-drag-container {\n display: inline-flex;\n width: 100%;\n max-width: 590px;\n height: 200px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n font-size: 14px;\n line-height: 1;\n border: 2px dashed rgb(212, 218, 227);\n background-color: rgb(247, 248, 250);\n border-radius: 4px;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v4-upload-drag .upload-drag-container:hover {\n border-color: rgb(87, 131, 235);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-icon {\n line-height: 0;\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-icon svg {\n font-size: 48px;\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-icon .upload-drag-loading {\n animation: uploadLoadingCircle 1s infinite linear;\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-text {\n margin: 20px 0 12px 0;\n color: rgb(29, 33, 38);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-text-loading {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-text-filename {\n margin-right: 5px;\n color: rgb(29, 33, 38);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-hint {\n color: rgb(92, 101, 115);\n padding: 0 20px;\n text-align: center;\n}\n@keyframes uploadLoadingCircle {\n 100% {\n transform: rotate(360deg);\n }\n}";
1535
+ var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午1:40\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload .component-upload {\n position: relative;\n display: inline-block;\n}\n.paraui-v4-upload-loading {\n pointer-events: none;\n}\n.paraui-v4-upload-drag {\n position: relative;\n}\n.paraui-v4-upload-drag-loading {\n pointer-events: none;\n}\n.paraui-v4-upload-drag-hover .upload-drag-container {\n border-color: rgb(87, 131, 235);\n}\n.paraui-v4-upload-drag .upload-drag-container {\n display: inline-flex;\n width: 100%;\n height: 200px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n font-size: 14px;\n line-height: 1;\n border: 1px dashed rgb(212, 218, 227);\n background-color: rgb(247, 248, 250);\n border-radius: 4px;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v4-upload-drag .upload-drag-container:hover {\n border-color: rgb(87, 131, 235);\n}\n.paraui-v4-upload-drag .upload-drag-container:hover .upload-drag-text {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-icon {\n line-height: 0;\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-icon svg {\n font-size: 48px;\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-icon .upload-drag-loading {\n animation: uploadLoadingCircle 1s infinite linear;\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-text {\n margin: 16px 0 10px 0;\n color: rgb(29, 33, 38);\n padding: 0 20px;\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-text-loading {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-text-filename {\n margin-right: 5px;\n color: rgb(29, 33, 38);\n word-break: break-all;\n}\n.paraui-v4-upload-drag .upload-drag-container .upload-drag-hint {\n color: rgb(92, 101, 115);\n padding: 0 20px;\n text-align: center;\n white-space: pre-wrap;\n line-height: 21px;\n}\n.paraui-v4-upload-drag .component-upload {\n display: block;\n max-width: 590px;\n}\n.paraui-v4-upload-drag .component-upload-disabled {\n color: rgb(92, 101, 115);\n cursor: not-allowed;\n}\n.paraui-v4-upload-drag .component-upload-disabled > div {\n width: 100%;\n}\n.paraui-v4-upload-drag .component-upload-disabled .upload-drag-container {\n cursor: not-allowed;\n}\n.paraui-v4-upload-drag .component-upload-disabled .upload-drag-container:hover {\n border-color: rgb(212, 218, 227);\n}\n.paraui-v4-upload-drag .component-upload-disabled .upload-drag-container .upload-drag-icon svg {\n color: rgb(161, 168, 179);\n}\n.paraui-v4-upload-drag .component-upload-disabled .upload-drag-container .upload-drag-text {\n color: rgb(92, 101, 115);\n}\n@keyframes uploadLoadingCircle {\n 100% {\n transform: rotate(360deg);\n }\n}";
912
1536
  styleInject(css_248z);
913
1537
 
914
1538
  //upload
@@ -931,23 +1555,29 @@ const InternalUpload = props => {
931
1555
  maxCount,
932
1556
  children = null,
933
1557
  itemRender,
934
- showUploadError = true,
1558
+ showUploadError = false,
935
1559
  size = 'large',
936
1560
  stash = false,
937
1561
  uploading = true,
938
1562
  showLoading: showLoadingProp = true,
939
1563
  loading = false,
940
1564
  dragArea,
941
- disabledTooltip
1565
+ disabledTooltip,
1566
+ operateBtnProps,
1567
+ actionRender,
1568
+ onPreview,
1569
+ removeErrorTip
942
1570
  } = props,
943
- restProps = __rest(props, ["type", "className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "onDrop", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "size", "stash", "uploading", "showLoading", "loading", "dragArea", "disabledTooltip"]);
1571
+ restProps = __rest(props, ["type", "className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "onDrop", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "size", "stash", "uploading", "showLoading", "loading", "dragArea", "disabledTooltip", "operateBtnProps", "actionRender", "onPreview", "removeErrorTip"]);
944
1572
  const intl = useFormatMessage('Upload', localeJson);
945
1573
  const [uploadFileList, setUploadFileList] = useState(defaultFileList); //文件列表
946
1574
  const [showLoading, setShowLoading] = useState(false); //upload loading
947
1575
  const [errTip, setErrTip] = useState(false); //upload error tip
948
1576
  const {
949
1577
  showRemoveIcon,
950
- removeIcon
1578
+ removeIcon,
1579
+ showPreviewIcon,
1580
+ previewIcon
951
1581
  } = typeof showUploadList === 'boolean' ? {} : showUploadList; //显示上传列表
952
1582
  const {
953
1583
  uploadErrorMsg = intl({
@@ -987,6 +1617,12 @@ const InternalUpload = props => {
987
1617
  setShowLoading(false);
988
1618
  curFileRef.current = null;
989
1619
  showErrTip(!!showUploadError);
1620
+ if (!showUploadError) {
1621
+ file.status = 'error';
1622
+ file.response = (error === null || error === void 0 ? void 0 : error.message) || uploadErrorMsg;
1623
+ const nextFileList = updateFileList(file);
1624
+ onInternalChange(nextFileList);
1625
+ }
990
1626
  onError === null || onError === void 0 ? void 0 : onError(error, response, file);
991
1627
  },
992
1628
  onProgress(e, file) {
@@ -1099,7 +1735,12 @@ const InternalUpload = props => {
1099
1735
  showRemoveIcon: showRemoveIcon,
1100
1736
  removeIcon: removeIcon,
1101
1737
  onRemove: handleRemove,
1102
- itemRender: itemRender
1738
+ itemRender: itemRender,
1739
+ operateBtnProps: operateBtnProps,
1740
+ actionRender: actionRender,
1741
+ onPreview: onPreview,
1742
+ showPreviewIcon: showPreviewIcon,
1743
+ previewIcon: previewIcon
1103
1744
  });
1104
1745
  //渲染上传按钮
1105
1746
  const renderButton = () => {
@@ -1153,9 +1794,7 @@ const InternalUpload = props => {
1153
1794
  }), "..."]
1154
1795
  }));
1155
1796
  }
1156
- return jsx("div", Object.assign({
1157
- className: 'upload-drag-container'
1158
- }, {
1797
+ const dragNode = jsx(Fragment, {
1159
1798
  children: children ? children : jsxs(Fragment, {
1160
1799
  children: [jsx("p", Object.assign({
1161
1800
  className: "upload-drag-icon"
@@ -1171,6 +1810,22 @@ const InternalUpload = props => {
1171
1810
  children: areaDesc
1172
1811
  }))]
1173
1812
  })
1813
+ });
1814
+ if (restProps.disabled && disabledTooltip && (disabledTooltip === null || disabledTooltip === void 0 ? void 0 : disabledTooltip.title)) return jsx(Tooltip, Object.assign({
1815
+ followCursor: true
1816
+ }, disabledTooltip || {}, {
1817
+ disabled: true
1818
+ }, {
1819
+ children: jsx("div", Object.assign({
1820
+ className: 'upload-drag-container'
1821
+ }, {
1822
+ children: dragNode
1823
+ }))
1824
+ }));
1825
+ return jsx("div", Object.assign({
1826
+ className: 'upload-drag-container'
1827
+ }, {
1828
+ children: dragNode
1174
1829
  }));
1175
1830
  };
1176
1831
  //拖拽上传
@@ -1189,7 +1844,7 @@ const InternalUpload = props => {
1189
1844
  prefixCls: "".concat($rcPrefixCls, "-upload")
1190
1845
  }, {
1191
1846
  children: renderDragArea()
1192
- })), renderUploadList(), errTip && jsx(ErrorTip, {
1847
+ })), renderUploadList(), errTip && !removeErrorTip && jsx(ErrorTip, {
1193
1848
  message: uploadErrorMsg,
1194
1849
  className: "".concat($prefixCls, "-upload-error-drag")
1195
1850
  })]