dtable-ui-component 5.3.6 → 5.3.7

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 (256) hide show
  1. package/lib/ButtonFormatter/index.js +8 -2
  2. package/lib/CheckboxEditor/index.css +8 -20
  3. package/lib/CheckboxEditor/index.js +98 -35
  4. package/lib/CheckboxFormatter/index.css +5 -0
  5. package/lib/CheckboxFormatter/index.js +9 -15
  6. package/lib/CollaboratorEditor/index.css +12 -35
  7. package/lib/CollaboratorEditor/index.js +18 -212
  8. package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +27 -30
  9. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
  10. package/lib/CollaboratorItem/index.css +5 -1
  11. package/lib/CollaboratorItem/index.js +6 -2
  12. package/lib/Comment/body/comment.js +190 -0
  13. package/lib/Comment/body/index.css +95 -0
  14. package/lib/Comment/body/index.js +32 -0
  15. package/lib/Comment/footer/btns/index.css +40 -0
  16. package/lib/Comment/footer/btns/index.js +113 -0
  17. package/lib/Comment/footer/index.css +157 -0
  18. package/lib/Comment/footer/index.js +169 -0
  19. package/lib/Comment/footer/input/index.css +52 -0
  20. package/lib/Comment/footer/input/index.js +448 -0
  21. package/lib/Comment/footer/input/participant/index.css +0 -0
  22. package/lib/Comment/footer/input/participant/index.js +53 -0
  23. package/lib/Comment/footer/participants/index.css +22 -0
  24. package/lib/Comment/footer/participants/index.js +68 -0
  25. package/lib/Comment/footer/participants/participant/index.css +5 -0
  26. package/lib/Comment/footer/participants/participant/index.js +32 -0
  27. package/lib/Comment/footer/participants/participant-select/index.css +104 -0
  28. package/lib/Comment/footer/participants/participant-select/index.js +182 -0
  29. package/lib/Comment/index.css +19 -0
  30. package/lib/Comment/index.js +304 -0
  31. package/lib/Comment/model.js +25 -0
  32. package/lib/Comment/utils/common.js +62 -0
  33. package/lib/Comment/utils/index.js +27 -0
  34. package/lib/Comment/utils/utilities.js +176 -0
  35. package/lib/DTableCustomizeSelect/index.js +2 -2
  36. package/lib/DTableFiltersPopover/utils/index.js +1 -7
  37. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  38. package/lib/DTableGroupSelect/index.js +3 -3
  39. package/lib/DTableSelect/index.js +3 -1
  40. package/lib/DateEditor/index.js +14 -51
  41. package/lib/DateEditor/pc-date-editor-popover.js +149 -12
  42. package/lib/{common/delete-tip.js → DeleteTip/index.js} +12 -16
  43. package/lib/Department-editor/department-single-select.js +1 -1
  44. package/lib/Department-editor/index.js +3 -4
  45. package/lib/DepartmentSingleSelectFormatter/index.js +3 -2
  46. package/lib/DigitalSignEditor/constants.js +7 -0
  47. package/lib/DigitalSignEditor/index.css +69 -0
  48. package/lib/DigitalSignEditor/index.js +182 -0
  49. package/lib/DigitalSignEditor/service.js +39 -0
  50. package/lib/DigitalSignEditor/signature-board/index.css +35 -0
  51. package/lib/DigitalSignEditor/signature-board/index.js +135 -0
  52. package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
  53. package/lib/DigitalSignEditor/utils.js +29 -0
  54. package/lib/DurationEditor/index.js +110 -0
  55. package/lib/EmailEditor/index.js +58 -0
  56. package/lib/FileEditor/addition-previewer/index.css +1 -0
  57. package/lib/FileEditor/addition-previewer/index.js +52 -0
  58. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
  59. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
  60. package/lib/FileEditor/constants.js +7 -0
  61. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
  62. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
  63. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
  64. package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
  65. package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
  66. package/lib/FileEditor/files-previewer/index.css +56 -0
  67. package/lib/FileEditor/files-previewer/index.js +277 -0
  68. package/lib/FileEditor/index.css +6 -0
  69. package/lib/FileEditor/index.js +258 -11
  70. package/lib/FileEditor/utils.js +22 -0
  71. package/lib/FileItemFormatter/index.js +19 -20
  72. package/lib/FileUploader/index.css +9 -0
  73. package/lib/FileUploader/index.js +268 -14
  74. package/lib/FormulaFormatter/cell-value-validator.js +17 -17
  75. package/lib/FormulaFormatter/index.js +2 -1
  76. package/lib/FormulaFormatter/utils.js +0 -31
  77. package/lib/GeolocationEditor/country-editor.js +319 -0
  78. package/lib/GeolocationEditor/index.css +641 -0
  79. package/lib/GeolocationEditor/index.js +240 -0
  80. package/lib/GeolocationEditor/location-editor.js +368 -0
  81. package/lib/GeolocationEditor/map-editor/index.js +456 -0
  82. package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
  83. package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
  84. package/lib/GeolocationEditor/map-editor-utils.js +153 -0
  85. package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
  86. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
  87. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
  88. package/lib/GeolocationEditor/parse-geolocation.js +282 -0
  89. package/lib/GeolocationEditor/province-city-editor.js +292 -0
  90. package/lib/GeolocationEditor/province-editor.js +226 -0
  91. package/lib/GeolocationEditor/selector-header-item.js +28 -0
  92. package/lib/GeolocationEditor/selector-list.js +33 -0
  93. package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
  94. package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
  95. package/lib/ImageEditor/addition-previewer/index.css +106 -0
  96. package/lib/ImageEditor/addition-previewer/index.js +63 -0
  97. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
  98. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
  99. package/lib/ImageEditor/constants.js +7 -0
  100. package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
  101. package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
  102. package/lib/ImageEditor/images-previewer/index.css +18 -0
  103. package/lib/ImageEditor/images-previewer/index.js +140 -0
  104. package/lib/ImageEditor/index.css +24 -0
  105. package/lib/ImageEditor/index.js +194 -0
  106. package/lib/ImageThumbnail/index.css +20 -0
  107. package/lib/ImageThumbnail/index.js +136 -0
  108. package/lib/LinkEditor/index.js +2 -3
  109. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  110. package/lib/MultipleSelectEditor/index.js +16 -177
  111. package/lib/NumberEditor/index.js +63 -77
  112. package/lib/RowExpandDialog/body/index.css +21 -0
  113. package/lib/RowExpandDialog/body/index.js +262 -0
  114. package/lib/RowExpandDialog/column-content/index.css +48 -0
  115. package/lib/RowExpandDialog/column-content/index.js +50 -0
  116. package/lib/RowExpandDialog/header/index.css +31 -0
  117. package/lib/RowExpandDialog/header/index.js +55 -0
  118. package/lib/RowExpandDialog/index.css +28 -0
  119. package/lib/RowExpandDialog/index.js +237 -0
  120. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
  121. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
  122. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
  123. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
  124. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
  125. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
  126. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
  127. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +106 -0
  128. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
  129. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
  130. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
  131. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
  132. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
  133. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
  134. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +147 -0
  135. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
  136. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
  137. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +6 -0
  138. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
  139. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
  140. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +123 -0
  141. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
  142. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +224 -0
  143. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
  144. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
  145. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
  146. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
  147. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +193 -0
  148. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
  149. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
  150. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
  151. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
  152. package/lib/RowExpandEditor/constants.js +44 -0
  153. package/lib/RowExpandEditor/index.css +0 -0
  154. package/lib/RowExpandEditor/index.js +32 -0
  155. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
  156. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
  157. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
  158. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
  159. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
  160. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +12 -13
  161. package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
  162. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
  163. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
  164. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +5 -5
  165. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  166. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +2 -2
  167. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +20 -20
  168. package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
  169. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
  170. package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
  171. package/lib/RowExpandFormatter/constants.js +61 -0
  172. package/lib/RowExpandFormatter/index.css +28 -3
  173. package/lib/RowExpandFormatter/index.js +111 -130
  174. package/lib/SingleSelectEditor/index.js +16 -156
  175. package/lib/SvgIcon/index.css +11 -0
  176. package/lib/SvgIcon/index.js +29 -0
  177. package/lib/TextEditor/index.js +112 -42
  178. package/lib/UploadProgress/index.js +38 -0
  179. package/lib/UrlEditor/index.js +61 -0
  180. package/lib/common/editor-base.js +52 -0
  181. package/lib/constants/file.js +96 -0
  182. package/lib/constants/index.js +27 -15
  183. package/lib/constants/key-codes.js +109 -0
  184. package/lib/css/cell-editor.css +18 -2
  185. package/lib/formatterConfig/base-formatter-config.js +23 -23
  186. package/lib/formatterConfig/index.js +3 -3
  187. package/lib/hooks/index.js +16 -0
  188. package/lib/index.js +81 -46
  189. package/lib/lang/index.js +19 -16
  190. package/lib/locales/de.json +167 -0
  191. package/lib/locales/en.json +167 -0
  192. package/lib/locales/es.json +167 -0
  193. package/lib/locales/fr.json +167 -0
  194. package/lib/locales/pt.json +167 -0
  195. package/lib/locales/ru.json +167 -0
  196. package/lib/locales/zh-CN.json +167 -0
  197. package/lib/select-editor/index.js +6 -6
  198. package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
  199. package/lib/select-editor/pc-select-editor/index.css +85 -0
  200. package/lib/select-editor/pc-select-editor/index.js +290 -0
  201. package/lib/utils/cell-comparer.js +35 -0
  202. package/lib/utils/cell.js +55 -0
  203. package/lib/utils/column-utils.js +25 -0
  204. package/lib/utils/editor-utils.js +1 -6
  205. package/lib/utils/get-event-transfer.js +75 -0
  206. package/lib/utils/hotkey.js +37 -0
  207. package/lib/utils/object-utils.js +61 -0
  208. package/lib/utils/url.js +121 -8
  209. package/lib/utils/utils.js +119 -2
  210. package/package.json +3 -2
  211. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
  212. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  213. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  214. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  215. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  216. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  217. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  218. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  219. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  220. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  221. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  222. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  223. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  224. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  225. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  226. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  227. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  228. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  229. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  230. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  231. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  232. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  233. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  234. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  235. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  236. package/lib/FileItemFormatter/utils.js +0 -99
  237. package/lib/MultipleSelectEditor/index.css +0 -9
  238. package/lib/RowExpandLinkFormatter/utils.js +0 -71
  239. package/lib/RowExpandUrlFormatter/index.css +0 -1
  240. package/lib/SingleSelectEditor/index.css +0 -14
  241. package/lib/common/modal-portal.js +0 -26
  242. package/lib/locals/de.js +0 -103
  243. package/lib/locals/en.js +0 -104
  244. package/lib/locals/es.js +0 -103
  245. package/lib/locals/fr.js +0 -103
  246. package/lib/locals/pt.js +0 -103
  247. package/lib/locals/ru.js +0 -103
  248. package/lib/locals/zh-CN.js +0 -104
  249. package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
  250. package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
  251. /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
  252. /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
  253. /package/lib/{common/delete-tip.css → DeleteTip/index.css} +0 -0
  254. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
  255. /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
  256. /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
@@ -0,0 +1,9 @@
1
+ .dtable-ui-upload-image {
2
+ width: 1px;
3
+ height: 1px;
4
+ opacity: 0;
5
+ position: absolute;
6
+ top: 0;
7
+ font-size: 0;
8
+ cursor: pointer;
9
+ }
@@ -6,26 +6,280 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _dayjs = _interopRequireDefault(require("dayjs"));
10
+ var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
11
+ var _getEventTransfer = _interopRequireDefault(require("../utils/get-event-transfer"));
12
+ var _url = require("../utils/url");
13
+ require("./index.css");
14
+ _dayjs.default.extend(_utc.default);
15
+ const MAX_UPLOAD_FILES = 10;
9
16
  class FileUploader extends _react.default.Component {
10
17
  constructor(props) {
18
+ var _this2;
11
19
  super(props);
12
- this.onFilesChanged = () => {};
13
- this.uploadFiles = function (fileList) {
14
- let isMultiple = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
15
- };
16
- this.checkRepeat = () => {};
17
- this.cancelUploadFile = () => {};
18
- this.onFileUploadProgress = () => {};
19
- this.onFileUploadSuccss = () => {};
20
- this.onFileUploadFailed = () => {};
21
- this.state = {};
22
- this.uploadFiles = [];
20
+ _this2 = this;
21
+ this.onInputFile = e => {
22
+ e.nativeEvent.stopImmediatePropagation();
23
+ e.stopPropagation();
24
+ };
25
+ this.uploadFileClick = () => {
26
+ this.uploadFileRef.click();
27
+ };
28
+ this.onDragEnter = e => {
29
+ const {
30
+ isSupportDragDrop,
31
+ updateParentTips
32
+ } = this.props;
33
+ if (isSupportDragDrop) {
34
+ e.preventDefault();
35
+ this.enteredCounter++;
36
+ if (this.enteredCounter !== 0) {
37
+ updateParentTips(true);
38
+ }
39
+ }
40
+ };
41
+ this.onDragOver = e => {
42
+ const {
43
+ isSupportDragDrop
44
+ } = this.props;
45
+ if (isSupportDragDrop) {
46
+ e.stopPropagation();
47
+ e.preventDefault();
48
+ }
49
+ };
50
+ this.onDragLeave = e => {
51
+ const {
52
+ isSupportDragDrop,
53
+ updateParentTips
54
+ } = this.props;
55
+ if (isSupportDragDrop) {
56
+ this.enteredCounter--;
57
+ if (this.enteredCounter === 0) {
58
+ updateParentTips(false);
59
+ }
60
+ }
61
+ };
62
+ this.onDrop = event => {
63
+ const {
64
+ isSupportDragDrop,
65
+ updateParentTips,
66
+ onCellTipShow
67
+ } = this.props;
68
+ if (isSupportDragDrop) {
69
+ this.enteredCounter = 0;
70
+ updateParentTips(false);
71
+ let files = event.dataTransfer.files;
72
+ if (files.length === 0) {
73
+ if (onCellTipShow) onCellTipShow(-1);
74
+ return;
75
+ }
76
+ this.handleFilesChange(files);
77
+ event.preventDefault();
78
+ }
79
+ };
80
+ this.onPaste = event => {
81
+ const {
82
+ isSupportPaste
83
+ } = this.props;
84
+ if (isSupportPaste) {
85
+ event.stopPropagation();
86
+ let cliperData = (0, _getEventTransfer.default)(event);
87
+ if (cliperData.files) {
88
+ let files = cliperData.files;
89
+ this.handleFilesChange(files, true);
90
+ }
91
+ }
92
+ };
93
+ this.onMouseEnter = () => {
94
+ const {
95
+ updateParentTips,
96
+ uploadType
97
+ } = this.props;
98
+ if (uploadType === 'image') {
99
+ if (updateParentTips) updateParentTips(true, uploadType);
100
+ }
101
+ };
102
+ this.onMouseLeave = () => {
103
+ const {
104
+ updateParentTips,
105
+ uploadType
106
+ } = this.props;
107
+ if (uploadType === 'image') {
108
+ if (updateParentTips) updateParentTips(false, uploadType);
109
+ }
110
+ };
111
+ this.uploadFilesChange = event => {
112
+ this.handleFilesChange(event.target.files);
113
+ };
114
+ this.handleFilesChange = function (files) {
115
+ let isPasteUpload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
116
+ const _this = _this2;
117
+ const {
118
+ uploadType,
119
+ updateUploadFileList,
120
+ onCellTipShow
121
+ } = _this2.props;
122
+ let uploadFileList = [];
123
+ let dealFileCnt = 0;
124
+ let allFileLen = files.length;
125
+ function checkLoadFinish() {
126
+ if (dealFileCnt === allFileLen - 1) {
127
+ if (uploadFileList.length === 0) {
128
+ if (onCellTipShow) onCellTipShow(uploadFileList.length);
129
+ return;
130
+ }
131
+ if (updateUploadFileList) updateUploadFileList(uploadFileList);
132
+ _this.uploadFilesInBatch(uploadFileList);
133
+ }
134
+ dealFileCnt++;
135
+ }
136
+ for (let i = 0; i < allFileLen; i++) {
137
+ let file = files[i];
138
+ if (isPasteUpload && file.name === 'image.png') {
139
+ let newName = "image-".concat((0, _dayjs.default)().format('YYYY-MM-DD-HH-mm'), ".png");
140
+ file = new File([file], newName, {
141
+ type: file.type
142
+ });
143
+ }
144
+ try {
145
+ let fileReader = new FileReader();
146
+ fileReader.readAsDataURL(file);
147
+ fileReader.addEventListener('load', function (event) {
148
+ let isImage = /image/i.test(file.type);
149
+ if (uploadType === 'file' || isImage) {
150
+ let uploadFileItem = {
151
+ name: file.name,
152
+ fileIconUrl: isImage ? event.target.result : (0, _url.getFileIconUrl)(file.name, file.type),
153
+ isUploading: true,
154
+ isErrorTip: false,
155
+ file: file,
156
+ size: file.size,
157
+ url: '',
158
+ type: uploadType === 'file' ? 'file' : '',
159
+ percent: 0
160
+ };
161
+ uploadFileList.push(uploadFileItem);
162
+ }
163
+ checkLoadFinish();
164
+ }, false);
165
+ fileReader.addEventListener('error', function (e) {
166
+ checkLoadFinish();
167
+ }, false);
168
+ } catch (event) {
169
+ checkLoadFinish();
170
+ }
171
+ }
172
+ };
173
+ this.uploadFilesInBatch = files => {
174
+ const fileUploadPromises = [];
175
+ const length = MAX_UPLOAD_FILES + this.start > files.length ? files.length : MAX_UPLOAD_FILES + this.start;
176
+ for (let i = this.start; i < length; i++) {
177
+ let file = files[i];
178
+ fileUploadPromises.push(this.createPromise(file));
179
+ }
180
+ this.uploadFilesPromise(fileUploadPromises, files);
181
+ };
182
+ this.uploadFilesPromise = (fileUploadPromises, files) => {
183
+ Promise.all(fileUploadPromises).then(res => {
184
+ this.start += MAX_UPLOAD_FILES;
185
+ if (this.start + MAX_UPLOAD_FILES - files.length >= 10) {
186
+ this.start = 0;
187
+ return;
188
+ }
189
+ this.uploadFilesInBatch(files);
190
+ });
191
+ };
192
+ this.handleFileChange = (fileMessage, callback) => {
193
+ const {
194
+ onFileUploadFailed
195
+ } = this.props;
196
+ this.uploadFile(fileMessage).then(res => {
197
+ const data = res;
198
+ this.uploadFileMessage({
199
+ data,
200
+ fileMessage
201
+ });
202
+ callback && callback();
203
+ }).catch(error => {
204
+ fileMessage.isErrorTip = true;
205
+ fileMessage.error = error;
206
+ if (onFileUploadFailed) onFileUploadFailed(fileMessage);
207
+ });
208
+ };
209
+ this.createPromise = fileMessage => {
210
+ const _this = this;
211
+ return new Promise(function (resolve, reject) {
212
+ _this.handleFileChange(fileMessage, resolve);
213
+ });
214
+ };
215
+ this.uploadFileMessage = _ref => {
216
+ let {
217
+ data = {},
218
+ fileMessage
219
+ } = _ref;
220
+ fileMessage.name = data.name;
221
+ fileMessage.isUploading = false;
222
+ fileMessage.size = data.size;
223
+ fileMessage.url = data.url;
224
+ fileMessage.upload_time = (0, _dayjs.default)().utc().format('YYYY-MM-DDTHH:mm:ss.SSSZ');
225
+ this.props.onFileUploadSuccess(fileMessage);
226
+ };
227
+ this.uploadFile = fileMessage => {
228
+ return this.props.uploadFile(fileMessage.file, event => this.onUploadProgress(event, fileMessage));
229
+ };
230
+ this.reuploadFile = fileMessage => {
231
+ fileMessage.isErrorTip = false;
232
+ this.handleFileChange(fileMessage);
233
+ };
234
+ this.onUploadProgress = (event, fileMessage) => {
235
+ const {
236
+ onFileUploadProgress
237
+ } = this.props;
238
+ let uploadPercent = Math.floor(event.loaded / event.total * 100);
239
+ fileMessage.percent = uploadPercent;
240
+ if (onFileUploadProgress) onFileUploadProgress(fileMessage);
241
+ };
242
+ this.enteredCounter = 0; // Determine whether to enter the child element to avoid dragging bubbling bugs。
243
+ this.start = 0;
244
+ }
245
+ componentWillUnmount() {
246
+ // prevent async operation
247
+ this.setState = (state, callback) => {
248
+ return;
249
+ };
23
250
  }
24
251
  render() {
25
- return /*#__PURE__*/_react.default.createElement("input", {
252
+ const {
253
+ uploadType
254
+ } = this.props;
255
+ return /*#__PURE__*/_react.default.createElement("div", {
256
+ onDragEnter: this.onDragEnter,
257
+ onDragOver: this.onDragOver,
258
+ onDragLeave: this.onDragLeave,
259
+ onDrop: this.onDrop,
260
+ onPaste: this.onPaste,
261
+ onMouseEnter: this.onMouseEnter,
262
+ onMouseLeave: this.onMouseLeave,
263
+ onClick: this.uploadFileClick,
264
+ className: this.props.className
265
+ }, this.props.children, uploadType === 'file' && /*#__PURE__*/_react.default.createElement("input", {
266
+ type: "file",
267
+ className: "dtable-ui-upload-image",
268
+ ref: ref => this.uploadFileRef = ref,
269
+ onClick: this.onInputFile,
270
+ onChange: this.uploadFilesChange,
271
+ value: "",
272
+ multiple: true
273
+ }), uploadType === 'image' && /*#__PURE__*/_react.default.createElement("input", {
26
274
  type: "file",
27
- onChange: this.onFilesChanged
28
- });
275
+ className: "dtable-ui-upload-image",
276
+ accept: "image/*",
277
+ ref: ref => this.uploadFileRef = ref,
278
+ onClick: this.onInputFile,
279
+ onChange: this.uploadFilesChange,
280
+ value: "",
281
+ multiple: true
282
+ }));
29
283
  }
30
284
  }
31
285
  var _default = exports.default = FileUploader;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _constants = require("../constants");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  const numberValidator = value => {
9
9
  return (value || value === 0) && Object.prototype.toString.call(value) === '[object Number]';
10
10
  };
@@ -15,22 +15,22 @@ const checkboxValidator = value => {
15
15
  return typeof value === 'boolean';
16
16
  };
17
17
  const validators = {
18
- [_constants.CellType.NUMBER]: numberValidator,
19
- [_constants.CellType.RATE]: numberValidator,
20
- [_constants.CellType.DURATION]: numberValidator,
21
- [_constants.CellType.CHECKBOX]: checkboxValidator,
22
- [_constants.CellType.TEXT]: textValidator,
23
- [_constants.CellType.DATE]: textValidator,
24
- [_constants.CellType.CTIME]: textValidator,
25
- [_constants.CellType.MTIME]: textValidator,
26
- [_constants.CellType.GEOLOCATION]: textValidator,
27
- [_constants.CellType.AUTO_NUMBER]: textValidator,
28
- [_constants.CellType.URL]: textValidator,
29
- [_constants.CellType.EMAIL]: textValidator,
30
- [_constants.FORMULA_RESULT_TYPE.DATE]: textValidator,
31
- [_constants.FORMULA_RESULT_TYPE.STRING]: textValidator,
32
- [_constants.FORMULA_RESULT_TYPE.NUMBER]: numberValidator,
33
- [_constants.FORMULA_RESULT_TYPE.BOOL]: checkboxValidator
18
+ [_dtableUtils.CellType.NUMBER]: numberValidator,
19
+ [_dtableUtils.CellType.RATE]: numberValidator,
20
+ [_dtableUtils.CellType.DURATION]: numberValidator,
21
+ [_dtableUtils.CellType.CHECKBOX]: checkboxValidator,
22
+ [_dtableUtils.CellType.TEXT]: textValidator,
23
+ [_dtableUtils.CellType.DATE]: textValidator,
24
+ [_dtableUtils.CellType.CTIME]: textValidator,
25
+ [_dtableUtils.CellType.MTIME]: textValidator,
26
+ [_dtableUtils.CellType.GEOLOCATION]: textValidator,
27
+ [_dtableUtils.CellType.AUTO_NUMBER]: textValidator,
28
+ [_dtableUtils.CellType.URL]: textValidator,
29
+ [_dtableUtils.CellType.EMAIL]: textValidator,
30
+ [_dtableUtils.FORMULA_RESULT_TYPE.DATE]: textValidator,
31
+ [_dtableUtils.FORMULA_RESULT_TYPE.STRING]: textValidator,
32
+ [_dtableUtils.FORMULA_RESULT_TYPE.NUMBER]: numberValidator,
33
+ [_dtableUtils.FORMULA_RESULT_TYPE.BOOL]: checkboxValidator
34
34
  };
35
35
  const cellValueValidator = (cellValue, type) => {
36
36
  const validator = validators[type];
@@ -10,6 +10,7 @@ var _dtableUtils = require("dtable-utils");
10
10
  var _baseFormatterConfig = _interopRequireDefault(require("../formatterConfig/base-formatter-config"));
11
11
  var _TextFormatter = _interopRequireDefault(require("../TextFormatter"));
12
12
  var _utils = require("./utils");
13
+ var _utils2 = require("../utils/utils");
13
14
  var _cellValueValidator = _interopRequireDefault(require("./cell-value-validator"));
14
15
  require("./index.css");
15
16
  class FormulaFormatter extends _react.default.Component {
@@ -114,7 +115,7 @@ class FormulaFormatter extends _react.default.Component {
114
115
  return /*#__PURE__*/_react.default.cloneElement(Formatter, {
115
116
  ...formatterProps
116
117
  });
117
- } else if ((0, _utils.isFunction)(Formatter)) {
118
+ } else if ((0, _utils2.isFunction)(Formatter)) {
118
119
  return /*#__PURE__*/_react.default.createElement(Formatter, formatterProps);
119
120
  }
120
121
  return /*#__PURE__*/_react.default.createElement(_TextFormatter.default, formatterProps);
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.convertValueToDtableLongTextValue = void 0;
8
8
  exports.isArrayFormatColumn = isArrayFormatColumn;
9
- exports.isFunction = void 0;
10
9
  exports.isSimpleCellFormatter = isSimpleCellFormatter;
11
- exports.openUrlLink = exports.isValidUrl = exports.isValidCellValue = void 0;
12
10
  var _constants = require("../constants");
13
11
  var _normalizeLongTextValue = _interopRequireDefault(require("../SimpleLongTextFormatter/normalize-long-text-value"));
14
12
  function isSimpleCellFormatter(type) {
@@ -17,35 +15,6 @@ function isSimpleCellFormatter(type) {
17
15
  function isArrayFormatColumn(columnType) {
18
16
  return _constants.ARRAY_FORMAT_COLUMNS.includes(columnType);
19
17
  }
20
- const isFunction = functionToCheck => {
21
- const getType = {};
22
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
23
- };
24
- exports.isFunction = isFunction;
25
- const isValidCellValue = value => {
26
- if (value === undefined) return false;
27
- if (value === null) return false;
28
- if (value === '') return false;
29
- if (JSON.stringify(value) === '{}') return false;
30
- if (JSON.stringify(value) === '[]') return false;
31
- return true;
32
- };
33
- exports.isValidCellValue = isValidCellValue;
34
- const isValidUrl = url => {
35
- const reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
36
- return reg.test(url);
37
- };
38
- exports.isValidUrl = isValidUrl;
39
- const openUrlLink = url => {
40
- let a = document.createElement('a');
41
- document.body.appendChild(a);
42
- a.href = url;
43
- a.target = '_blank';
44
- a.rel = 'noopener noreferrer';
45
- a.click();
46
- document.body.removeChild(a);
47
- };
48
- exports.openUrlLink = openUrlLink;
49
18
  const convertValueToDtableLongTextValue = value => {
50
19
  const valueType = Object.prototype.toString.call(value);
51
20
  if (value && valueType === '[object String]') {