dtable-ui-component 5.3.0-alpha1 → 5.3.1-beta

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 (223) hide show
  1. package/lib/CheckboxEditor/index.css +3 -20
  2. package/lib/CheckboxEditor/index.js +98 -35
  3. package/lib/CheckboxFormatter/index.js +6 -9
  4. package/lib/CollaboratorEditor/index.css +12 -35
  5. package/lib/CollaboratorEditor/index.js +18 -212
  6. package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +26 -29
  7. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
  8. package/lib/CollaboratorItem/index.css +1 -1
  9. package/lib/CollaboratorItem/index.js +6 -2
  10. package/lib/DTableFiltersPopover/utils/index.js +1 -7
  11. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  12. package/lib/DTableSelect/index.js +3 -1
  13. package/lib/DateEditor/index.js +14 -51
  14. package/lib/DateEditor/pc-date-editor-popover.js +145 -12
  15. package/lib/DeleteTip/index.js +50 -0
  16. package/lib/Department-editor/department-single-select.js +1 -1
  17. package/lib/Department-editor/index.js +3 -4
  18. package/lib/DepartmentSingleSelectFormatter/index.js +2 -1
  19. package/lib/DigitalSignEditor/constants.js +7 -0
  20. package/lib/DigitalSignEditor/index.css +69 -0
  21. package/lib/DigitalSignEditor/index.js +182 -0
  22. package/lib/DigitalSignEditor/service.js +38 -0
  23. package/lib/DigitalSignEditor/signature-board/index.css +35 -0
  24. package/lib/DigitalSignEditor/signature-board/index.js +135 -0
  25. package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
  26. package/lib/DigitalSignEditor/utils.js +29 -0
  27. package/lib/DurationEditor/index.js +111 -0
  28. package/lib/EmailEditor/index.js +59 -0
  29. package/lib/FileEditor/addition-previewer/index.css +1 -0
  30. package/lib/FileEditor/addition-previewer/index.js +52 -0
  31. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
  32. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
  33. package/lib/FileEditor/constants.js +7 -0
  34. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
  35. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
  36. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
  37. package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
  38. package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
  39. package/lib/FileEditor/files-previewer/index.css +56 -0
  40. package/lib/FileEditor/files-previewer/index.js +277 -0
  41. package/lib/FileEditor/index.css +6 -0
  42. package/lib/FileEditor/index.js +244 -11
  43. package/lib/FileEditor/utils.js +22 -0
  44. package/lib/FileItemFormatter/index.js +19 -20
  45. package/lib/FileUploader/index.css +9 -0
  46. package/lib/FileUploader/index.js +268 -14
  47. package/lib/FormulaFormatter/index.js +2 -1
  48. package/lib/FormulaFormatter/utils.js +0 -31
  49. package/lib/GeolocationEditor/country-editor.js +319 -0
  50. package/lib/GeolocationEditor/index.css +641 -0
  51. package/lib/GeolocationEditor/index.js +241 -0
  52. package/lib/GeolocationEditor/location-editor.js +368 -0
  53. package/lib/GeolocationEditor/map-editor/index.js +456 -0
  54. package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
  55. package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
  56. package/lib/GeolocationEditor/map-editor-utils.js +153 -0
  57. package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
  58. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
  59. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
  60. package/lib/GeolocationEditor/parse-geolocation.js +282 -0
  61. package/lib/GeolocationEditor/province-city-editor.js +292 -0
  62. package/lib/GeolocationEditor/province-editor.js +226 -0
  63. package/lib/GeolocationEditor/selector-header-item.js +28 -0
  64. package/lib/GeolocationEditor/selector-list.js +33 -0
  65. package/lib/GeolocationEditor/with-ref.js +27 -0
  66. package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
  67. package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
  68. package/lib/ImageEditor/addition-previewer/index.css +106 -0
  69. package/lib/ImageEditor/addition-previewer/index.js +63 -0
  70. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
  71. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
  72. package/lib/ImageEditor/constants.js +7 -0
  73. package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
  74. package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
  75. package/lib/ImageEditor/images-previewer/index.css +18 -0
  76. package/lib/ImageEditor/images-previewer/index.js +140 -0
  77. package/lib/ImageEditor/index.css +24 -0
  78. package/lib/ImageEditor/index.js +194 -0
  79. package/lib/ImageThumbnail/index.css +20 -0
  80. package/lib/ImageThumbnail/index.js +136 -0
  81. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  82. package/lib/MultipleSelectEditor/index.js +16 -177
  83. package/lib/NumberEditor/index.js +64 -77
  84. package/lib/RowExpandDialog/body/index.css +21 -0
  85. package/lib/RowExpandDialog/body/index.js +279 -0
  86. package/lib/RowExpandDialog/column-content/index.css +43 -0
  87. package/lib/RowExpandDialog/column-content/index.js +50 -0
  88. package/lib/RowExpandDialog/constants.js +114 -0
  89. package/lib/RowExpandDialog/header/index.css +31 -0
  90. package/lib/RowExpandDialog/header/index.js +33 -0
  91. package/lib/RowExpandDialog/index.css +24 -0
  92. package/lib/RowExpandDialog/index.js +268 -0
  93. package/lib/RowExpandDialog/utils.js +83 -0
  94. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
  95. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
  96. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
  97. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
  98. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
  99. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
  100. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
  101. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +129 -0
  102. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
  103. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
  104. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
  105. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
  106. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
  107. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
  108. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +146 -0
  109. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
  110. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
  111. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +6 -0
  112. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
  113. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
  114. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +124 -0
  115. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
  116. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +224 -0
  117. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
  118. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
  119. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
  120. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
  121. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +192 -0
  122. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
  123. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
  124. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
  125. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
  126. package/lib/RowExpandEditor/constants.js +44 -0
  127. package/lib/RowExpandEditor/index.css +0 -0
  128. package/lib/RowExpandEditor/index.js +32 -0
  129. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
  130. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
  131. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
  132. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
  133. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
  134. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +10 -11
  135. package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
  136. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
  137. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
  138. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  139. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  140. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +5 -5
  141. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/utils.js +1 -1
  142. package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
  143. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
  144. package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
  145. package/lib/RowExpandFormatter/constants.js +60 -0
  146. package/lib/RowExpandFormatter/index.css +26 -0
  147. package/lib/RowExpandFormatter/index.js +84 -100
  148. package/lib/SingleSelectEditor/index.js +16 -156
  149. package/lib/TextEditor/index.js +113 -42
  150. package/lib/UploadProgress/index.js +38 -0
  151. package/lib/UrlEditor/index.js +62 -0
  152. package/lib/common/editor-base.js +53 -0
  153. package/lib/constants/file.js +96 -0
  154. package/lib/constants/index.js +34 -2
  155. package/lib/constants/key-codes.js +109 -0
  156. package/lib/css/cell-editor.css +18 -2
  157. package/lib/hooks/index.js +16 -0
  158. package/lib/index.js +74 -46
  159. package/lib/lang/index.js +16 -14
  160. package/lib/locales/de.json +163 -0
  161. package/lib/locales/en.json +163 -0
  162. package/lib/locales/es.json +163 -0
  163. package/lib/locales/fr.json +163 -0
  164. package/lib/locales/pt.json +163 -0
  165. package/lib/locales/ru.json +163 -0
  166. package/lib/locales/zh-CN.json +163 -0
  167. package/lib/select-editor/index.js +6 -6
  168. package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
  169. package/lib/select-editor/pc-select-editor/index.css +85 -0
  170. package/lib/select-editor/pc-select-editor/index.js +290 -0
  171. package/lib/utils/cell-comparer.js +35 -0
  172. package/lib/utils/cell.js +55 -0
  173. package/lib/utils/column-utils.js +25 -0
  174. package/lib/utils/editor-utils.js +1 -6
  175. package/lib/utils/get-event-transfer.js +75 -0
  176. package/lib/utils/object-utils.js +61 -0
  177. package/lib/utils/url.js +119 -8
  178. package/lib/utils/utils.js +89 -2
  179. package/package.json +3 -2
  180. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
  181. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  182. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  183. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  184. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  185. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  186. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  187. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  188. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  189. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  190. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  191. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  192. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  193. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  194. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  195. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  196. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  197. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  198. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  199. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  200. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  201. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  202. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  203. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  204. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  205. package/lib/FileItemFormatter/utils.js +0 -99
  206. package/lib/MultipleSelectEditor/index.css +0 -9
  207. package/lib/RowExpandUrlFormatter/index.css +0 -1
  208. package/lib/SingleSelectEditor/index.css +0 -14
  209. package/lib/locals/de.js +0 -103
  210. package/lib/locals/en.js +0 -104
  211. package/lib/locals/es.js +0 -103
  212. package/lib/locals/fr.js +0 -103
  213. package/lib/locals/pt.js +0 -103
  214. package/lib/locals/ru.js +0 -103
  215. package/lib/locals/zh-CN.js +0 -104
  216. package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
  217. package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
  218. /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
  219. /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
  220. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +0 -0
  221. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
  222. /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
  223. /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
package/lib/utils/url.js CHANGED
@@ -3,15 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.needUseThumbnailImage = exports.isTargetUrl = exports.isInternalImg = exports.isDigitalSignsUrl = exports.isCustomAssetUrl = exports.getImageThumbnailUrl = exports.generateCurrentBaseImageUrl = exports.generateCurrentBaseImageThumbnailUrl = exports.checkSVGImage = void 0;
6
+ exports.needUseThumbnailImage = exports.isTargetUrl = exports.isInternalURL = exports.isInternalImg = exports.isDigitalSignsUrl = exports.isCustomAssetUrl = exports.isBase64 = exports.isAIUrl = exports.imageCheck = exports.getValidFileImageUrls = exports.getImageThumbnailUrl = exports.getFileThumbnailInfo = exports.getFileName = exports.getFileIconUrl = exports.generateCurrentBaseImageUrl = exports.generateCurrentBaseImageThumbnailUrl = exports.checkSVGImage = exports.checkImgExists = void 0;
7
+ var _file = require("../constants/file");
7
8
  const isTargetUrl = (target, url) => {
8
9
  if (!url || typeof url !== 'string') return false;
9
10
  return target && url ? url.indexOf(target) > -1 : false;
10
11
  };
11
12
  exports.isTargetUrl = isTargetUrl;
13
+ const isBase64 = url => {
14
+ if (!url || typeof url !== 'string') return false;
15
+ const target = 'data:image/png;base64';
16
+ return url ? url.startsWith(target) : false;
17
+ };
18
+ exports.isBase64 = isBase64;
12
19
  const isInternalImg = (url, server) => {
20
+ var _window;
13
21
  if (!url || typeof url !== 'string') return false;
14
- const currentServer = server || window.dtable && window.dtable.server;
22
+ const currentServer = server || ((_window = window) === null || _window === void 0 ? void 0 : _window.dtable) && window.dtable.server;
15
23
  return url.indexOf(currentServer) > -1;
16
24
  };
17
25
  exports.isInternalImg = isInternalImg;
@@ -19,14 +27,33 @@ const isCustomAssetUrl = url => {
19
27
  return isTargetUrl('custom-asset://', url);
20
28
  };
21
29
  exports.isCustomAssetUrl = isCustomAssetUrl;
30
+ const checkImgExists = url => {
31
+ return new Promise(function (resolve, reject) {
32
+ let image = new Image();
33
+ image.src = url;
34
+ image.onload = function (res) {
35
+ resolve(res);
36
+ };
37
+ image.onerror = function (err) {
38
+ reject(err);
39
+ };
40
+ });
41
+ };
42
+ exports.checkImgExists = checkImgExists;
22
43
  const checkSVGImage = url => {
23
44
  if (!url || typeof url !== 'string') return false;
24
45
  const isSVGImage = url.substring(url.lastIndexOf('.')).toLowerCase() === '.svg';
25
46
  return isSVGImage;
26
47
  };
27
48
  exports.checkSVGImage = checkSVGImage;
49
+ const isAIUrl = url => {
50
+ if (!url || typeof url !== 'string') return false;
51
+ return isTargetUrl('/ai/asset/', url) && !url.includes('http');
52
+ };
53
+ exports.isAIUrl = isAIUrl;
28
54
  const isDigitalSignsUrl = url => {
29
55
  if (!url || typeof url !== 'string') return false;
56
+ if (isAIUrl(url)) return true;
30
57
  return isTargetUrl('/digital-signs/', url) && !url.includes('http');
31
58
  };
32
59
  exports.isDigitalSignsUrl = isDigitalSignsUrl;
@@ -40,6 +67,7 @@ const needUseThumbnailImage = url => {
40
67
  };
41
68
  exports.needUseThumbnailImage = needUseThumbnailImage;
42
69
  const generateCurrentBaseImageThumbnailUrl = _ref => {
70
+ var _window2;
43
71
  let {
44
72
  server,
45
73
  workspaceID,
@@ -47,11 +75,13 @@ const generateCurrentBaseImageThumbnailUrl = _ref => {
47
75
  partUrl,
48
76
  size
49
77
  } = _ref;
78
+ const validServer = server || ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.dtable) && window.dtable.server || '';
50
79
  if (!partUrl || typeof partUrl !== 'string') return '';
51
- return "".concat(server, "/thumbnail/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl, "?size=").concat(size);
80
+ return "".concat(validServer, "/thumbnail/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl, "?size=").concat(size);
52
81
  };
53
82
  exports.generateCurrentBaseImageThumbnailUrl = generateCurrentBaseImageThumbnailUrl;
54
83
  const generateCurrentBaseImageUrl = _ref2 => {
84
+ var _window3;
55
85
  let {
56
86
  server,
57
87
  workspaceID,
@@ -59,7 +89,9 @@ const generateCurrentBaseImageUrl = _ref2 => {
59
89
  partUrl
60
90
  } = _ref2;
61
91
  if (!partUrl || typeof partUrl !== 'string') return '';
62
- return "".concat(server, "/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl);
92
+ if (partUrl.startsWith('http')) return partUrl;
93
+ const validServer = server || ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.dtable) && window.dtable.server || '';
94
+ return "".concat(validServer, "/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl);
63
95
  };
64
96
  exports.generateCurrentBaseImageUrl = generateCurrentBaseImageUrl;
65
97
  const getImageThumbnailUrl = function (url) {
@@ -70,6 +102,7 @@ const getImageThumbnailUrl = function (url) {
70
102
  size = 256
71
103
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
72
104
  if (!url || typeof url !== 'string') return '';
105
+ if (isAIUrl(url) || checkSVGImage(url) || !isInternalImg(url) || isBase64(url)) return url;
73
106
  if (server && dtableUuid && isCustomAssetUrl(url)) {
74
107
  const assetUuid = url.slice(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
75
108
  return server + '/dtable/' + dtableUuid + '/custom-asset-thumbnail/' + assetUuid + '?size=' + size;
@@ -83,9 +116,87 @@ const getImageThumbnailUrl = function (url) {
83
116
  partUrl: url
84
117
  });
85
118
  }
86
- if (checkSVGImage(url) || !isInternalImg(url)) {
87
- return url;
88
- }
119
+ if (url.includes('/thumbnail/workspace')) return url;
89
120
  return url.replace('/workspace', '/thumbnail/workspace') + '?size=' + size;
90
121
  };
91
- exports.getImageThumbnailUrl = getImageThumbnailUrl;
122
+ exports.getImageThumbnailUrl = getImageThumbnailUrl;
123
+ const getFileName = url => {
124
+ if (!url) return null;
125
+ let lastIndex = url.lastIndexOf('/');
126
+ return url.slice(lastIndex + 1);
127
+ };
128
+ exports.getFileName = getFileName;
129
+ const imageCheck = filename => {
130
+ // no file ext
131
+ if (!filename || typeof filename !== 'string') return false;
132
+ if (filename.lastIndexOf('.') === -1) {
133
+ return false;
134
+ }
135
+ const file_ext = filename.substr(filename.lastIndexOf('.') + 1).toLowerCase();
136
+ const image_exts = ['gif', 'jpeg', 'jpg', 'png', 'ico', 'bmp', 'tif', 'tiff', 'webp'];
137
+ return image_exts.includes(file_ext);
138
+ };
139
+ exports.imageCheck = imageCheck;
140
+ const isInternalURL = function (url) {
141
+ let {
142
+ server = ''
143
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
144
+ if (!url || typeof url !== 'string') return false;
145
+ return server && url.indexOf(server) > -1;
146
+ };
147
+ exports.isInternalURL = isInternalURL;
148
+ const getValidFileImageUrls = files => {
149
+ if (!Array.isArray(files)) return [];
150
+ return files.map(file => {
151
+ if (typeof file !== 'object') return null;
152
+ const {
153
+ url,
154
+ name
155
+ } = file;
156
+ if (!url || url.indexOf('/asset') < 0) return null;
157
+ return imageCheck(name) ? url : null;
158
+ }).filter(Boolean);
159
+ };
160
+ exports.getValidFileImageUrls = getValidFileImageUrls;
161
+ const getFileIconUrl = (filename, direntType) => {
162
+ const defaultIcon = _file.FILEEXT_ICON_MAP['default'];
163
+ const defaultIconUrl = _file.FILEEXT_ICON_URL_MAP[defaultIcon];
164
+ if (typeof direntType === 'string' && direntType === 'dir') {
165
+ const folder = _file.FILEEXT_ICON_MAP['folder'];
166
+ return _file.FILEEXT_ICON_URL_MAP[folder]['192'];
167
+ }
168
+ const identifierIndex = typeof filename === 'string' && filename.lastIndexOf('.');
169
+ if (identifierIndex === -1) return defaultIconUrl['192'];
170
+ const fileExt = typeof filename === 'string' && filename.slice(identifierIndex + 1).toLowerCase() || 'default';
171
+ const fileIcon = _file.FILEEXT_ICON_MAP[fileExt];
172
+ if (fileIcon) {
173
+ const iconUrl = _file.FILEEXT_ICON_URL_MAP[fileIcon];
174
+ return iconUrl['192'];
175
+ }
176
+ return defaultIconUrl['192'];
177
+ };
178
+ exports.getFileIconUrl = getFileIconUrl;
179
+ const getFileThumbnailInfo = function (file) {
180
+ let {
181
+ server
182
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
183
+ const defaultIcon = _file.FILEEXT_ICON_MAP['default'];
184
+ const defaultIconUrl = _file.FILEEXT_ICON_URL_MAP[defaultIcon];
185
+ if (!file || !file.name) return {
186
+ isImage: false,
187
+ fileIconUrl: defaultIconUrl['192']
188
+ };
189
+ const isImage = imageCheck(file.name);
190
+ if (isImage) return {
191
+ isImage,
192
+ fileIconUrl: getImageThumbnailUrl(file.url, {
193
+ server
194
+ })
195
+ };
196
+ const iconUrl = getFileIconUrl(file.name, file.type);
197
+ return {
198
+ fileIconUrl: iconUrl,
199
+ isImage: false
200
+ };
201
+ };
202
+ exports.getFileThumbnailInfo = getFileThumbnailInfo;
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.throttle = exports.isMac = exports.getEventClassName = exports.downloadFile = exports.debounce = void 0;
6
+ exports.throttle = exports.openUrlLink = exports.isValidUrl = exports.isValidCellValue = exports.isMobile = exports.isMac = exports.isFunction = exports.getTrimmedString = exports.getEventClassName = exports.getErrorMsg = exports.downloadFiles = exports.downloadFile = exports.debounce = void 0;
7
+ var _url = require("./url");
7
8
  const debounce = (fn, wait) => {
8
9
  let timeout = null;
9
10
  return function () {
@@ -30,6 +31,7 @@ const throttle = (func, delay) => {
30
31
  };
31
32
  };
32
33
  exports.throttle = throttle;
34
+ const isMobile = exports.isMobile = typeof window !== 'undefined' && (window.innerWidth < 768 || navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null);
33
35
  const isMac = () => {
34
36
  const platform = navigator.platform;
35
37
  // eslint-disable-next-line eqeqeq
@@ -48,9 +50,94 @@ const downloadFile = downloadUrl => {
48
50
  document.body.appendChild(iframe);
49
51
  };
50
52
  exports.downloadFile = downloadFile;
53
+ const downloadFiles = (downloadUrlList, config) => {
54
+ const downloadFrame = document.getElementById('dtableUiComponentDownloadFrame');
55
+ if (downloadFrame != null) {
56
+ document.body.removeChild(downloadFrame);
57
+ }
58
+ downloadUrlList.forEach((url, index) => {
59
+ if (!(0, _url.isInternalURL)(url, config) && (0, _url.imageCheck)(url.replace('?dl=1', ''))) {
60
+ window.open(url);
61
+ } else {
62
+ const path = url;
63
+ let timer1 = setTimeout(function (path) {
64
+ return function () {
65
+ let iframe = document.createElement('iframe');
66
+ iframe.setAttribute('id', 'dtableUiComponentDownloadFrame');
67
+ iframe.style.display = 'none';
68
+ iframe.src = path;
69
+ document.body.appendChild(iframe);
70
+ let timer2 = setTimeout(function () {
71
+ iframe.remove();
72
+ clearTimeout(timer2);
73
+ }, 5000);
74
+ clearTimeout(timer1);
75
+ };
76
+ }(path), 1000 * index);
77
+ }
78
+ });
79
+ };
80
+ exports.downloadFiles = downloadFiles;
51
81
  const getEventClassName = e => {
52
82
  // svg mouseEvent event.target.className is an object
53
83
  if (!e || !e.target) return '';
54
84
  return e.target.getAttribute('class') || '';
55
85
  };
56
- exports.getEventClassName = getEventClassName;
86
+ exports.getEventClassName = getEventClassName;
87
+ const getTrimmedString = value => {
88
+ return typeof value === 'string' ? value.trim() : '';
89
+ };
90
+ exports.getTrimmedString = getTrimmedString;
91
+ const isFunction = functionToCheck => {
92
+ const getType = {};
93
+ return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
94
+ };
95
+ exports.isFunction = isFunction;
96
+ const isValidCellValue = value => {
97
+ if (value === undefined) return false;
98
+ if (value === null) return false;
99
+ if (value === '') return false;
100
+ if (JSON.stringify(value) === '{}') return false;
101
+ if (JSON.stringify(value) === '[]') return false;
102
+ return true;
103
+ };
104
+ exports.isValidCellValue = isValidCellValue;
105
+ const isValidUrl = url => {
106
+ const reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
107
+ return reg.test(url);
108
+ };
109
+ exports.isValidUrl = isValidUrl;
110
+ const openUrlLink = url => {
111
+ let a = document.createElement('a');
112
+ document.body.appendChild(a);
113
+ a.href = url;
114
+ a.target = '_blank';
115
+ a.rel = 'noopener noreferrer';
116
+ a.click();
117
+ document.body.removeChild(a);
118
+ };
119
+ exports.openUrlLink = openUrlLink;
120
+ const getErrorMsg = error => {
121
+ let errorMsg = '';
122
+ if (error.response) {
123
+ if (error.response.status === 403) {
124
+ errorMsg = 'Permission_denied';
125
+ } else if (error.response.data && error.response.data['error_msg']) {
126
+ errorMsg = error.response.data['error_msg'];
127
+ } else if (error.response.data && error.response.data['error_message']) {
128
+ errorMsg = error.response.data['error_message'];
129
+ } else {
130
+ errorMsg = 'Error';
131
+ }
132
+ } else {
133
+ if (typeof error === 'object' && error.name) {
134
+ errorMsg = error.name;
135
+ } else {
136
+ errorMsg = 'Please_check_the_network';
137
+ }
138
+ // eslint-disable-next-line
139
+ console.log(error);
140
+ }
141
+ return errorMsg;
142
+ };
143
+ exports.getErrorMsg = getErrorMsg;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "5.3.0-alpha1",
3
+ "version": "5.3.1beta",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "3.0.1",
@@ -9,7 +9,7 @@
9
9
  "antd-mobile": "2.3.1",
10
10
  "classnames": "2.3.2",
11
11
  "dayjs": "1.10.7",
12
- "dtable-utils": "5.0.11",
12
+ "dtable-utils": "5.0.16",
13
13
  "is-hotkey": "0.2.0",
14
14
  "prop-types": "^15.8.1",
15
15
  "react": "17.0.2",
@@ -17,6 +17,7 @@
17
17
  "react-responsive": "9.0.2",
18
18
  "react-color": "2.19.3",
19
19
  "react-select": "5.7.0",
20
+ "react-sweet-progress": "^1.1.2",
20
21
  "react-transition-group": "^4.4.1",
21
22
  "reactstrap": "8.9.0"
22
23
  },
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _lang = require("../../lang");
10
- var _CollaboratorItem = _interopRequireDefault(require("../../CollaboratorItem"));
11
- require("./index.css");
12
- class PCCollaboratorEditorPopover extends _react.default.Component {
13
- constructor(props) {
14
- super(props);
15
- this.onValueChanged = event => {
16
- let value = event.target.value;
17
- this.setState({
18
- searchValue: value
19
- });
20
- };
21
- this.onInputClick = event => {
22
- event.nativeEvent.stopImmediatePropagation();
23
- event.stopPropagation();
24
- };
25
- this.onCollaboratorItemToggle = item => {
26
- this.props.onCollaboratorItemToggle(item);
27
- };
28
- this.getFilterCollaborator = () => {
29
- let {
30
- collaborators
31
- } = this.props;
32
- let filter = this.state.searchValue.toLowerCase();
33
- if (!filter) {
34
- return collaborators;
35
- }
36
- return collaborators.filter(collaborator => {
37
- return collaborator.name.toString().toLowerCase().indexOf(filter) > -1;
38
- });
39
- };
40
- this.state = {
41
- searchValue: ''
42
- };
43
- this.editorInputRef = /*#__PURE__*/_react.default.createRef();
44
- }
45
- componentDidMount() {
46
- this.editorInputRef.current.focus();
47
- }
48
- render() {
49
- let {
50
- searchValue
51
- } = this.state;
52
- let {
53
- selectedCollaborators,
54
- popoverPosition
55
- } = this.props;
56
- let collaborators = this.getFilterCollaborator();
57
- let popoverStyle = Object.assign({}, {
58
- ...popoverPosition
59
- }, {
60
- position: 'absolute'
61
- });
62
- return /*#__PURE__*/_react.default.createElement("div", {
63
- className: "dtable-ui-editor-popover dtable-ui-collaborator-editor-popover",
64
- style: popoverStyle,
65
- ref: this.props.setPopoverRef
66
- }, /*#__PURE__*/_react.default.createElement("div", {
67
- className: "collaborator-search-container"
68
- }, /*#__PURE__*/_react.default.createElement("input", {
69
- className: "form-control",
70
- value: searchValue,
71
- onChange: this.onValueChanged,
72
- onClick: this.onInputClick,
73
- placeholder: (0, _lang.getLocale)('Search_collaborator'),
74
- ref: this.editorInputRef
75
- })), /*#__PURE__*/_react.default.createElement("div", {
76
- className: "collaborator-list-container"
77
- }, collaborators.length > 0 && collaborators.map((collaborator, index) => {
78
- const isSelect = selectedCollaborators.some(selectedCollaborator => {
79
- return selectedCollaborator.email === collaborator.email;
80
- });
81
- return /*#__PURE__*/_react.default.createElement("div", {
82
- key: index,
83
- className: "collaborator-item-container",
84
- onClick: this.onCollaboratorItemToggle.bind(this, collaborator)
85
- }, /*#__PURE__*/_react.default.createElement(_CollaboratorItem.default, {
86
- collaborator: collaborator
87
- }), /*#__PURE__*/_react.default.createElement("div", {
88
- className: "collaborator-checked"
89
- }, isSelect && /*#__PURE__*/_react.default.createElement("i", {
90
- className: "dtable-font dtable-icon-check-mark"
91
- })));
92
- }), collaborators.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
93
- className: "no-search-result"
94
- }, (0, _lang.getLocale)('No_collaborators_available'))));
95
- }
96
- }
97
- var _default = exports.default = PCCollaboratorEditorPopover;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,99 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.imageCheck = exports.getFileThumbnailInfo = exports.getFileIconUrl = void 0;
7
- var _url = require("../utils/url");
8
- const FILEEXT_ICON_MAP = {
9
- // text file
10
- md: 'txt.png',
11
- txt: 'txt.png',
12
- // pdf file
13
- pdf: 'pdf.png',
14
- // document file
15
- doc: 'word.png',
16
- docx: 'word.png',
17
- odt: 'word.png',
18
- fodt: 'word.png',
19
- ppt: 'ppt.png',
20
- pptx: 'ppt.png',
21
- odp: 'ppt.png',
22
- fodp: 'ppt.png',
23
- xls: 'excel.png',
24
- xlsx: 'excel.png',
25
- ods: 'excel.png',
26
- fods: 'excel.png',
27
- // video
28
- mp4: 'video.png',
29
- ogv: 'video.png',
30
- webm: 'video.png',
31
- mov: 'video.png',
32
- flv: 'video.png',
33
- wmv: 'video.png',
34
- rmvb: 'video.png',
35
- // music file
36
- mp3: 'music.png',
37
- oga: 'music.png',
38
- ogg: 'music.png',
39
- flac: 'music.png',
40
- aac: 'music.png',
41
- ac3: 'music.png',
42
- wma: 'music.png',
43
- // image file
44
- jpg: 'pic.png',
45
- jpeg: 'pic.png',
46
- png: 'pic.png',
47
- svg: 'pic.png',
48
- gif: 'pic.png',
49
- bmp: 'pic.png',
50
- ico: 'pic.png',
51
- // folder dir
52
- folder: 'folder-192.png',
53
- // default
54
- default: 'file.png'
55
- };
56
- const getFileThumbnailInfo = fileItem => {
57
- let fileIconUrl;
58
- let isImage;
59
- if (!fileItem.name) {
60
- fileIconUrl = FILEEXT_ICON_MAP['default'];
61
- isImage = false;
62
- } else {
63
- isImage = imageCheck(fileItem.name);
64
- if (isImage) {
65
- fileIconUrl = (0, _url.getImageThumbnailUrl)(fileItem.url);
66
- } else {
67
- fileIconUrl = require('./' + getFileIconUrl(fileItem.name, fileItem.type));
68
- }
69
- }
70
- return {
71
- fileIconUrl,
72
- isImage
73
- };
74
- };
75
- exports.getFileThumbnailInfo = getFileThumbnailInfo;
76
- const getFileIconUrl = (filename, direntType) => {
77
- if (typeof direntType === 'string' && direntType === 'dir') {
78
- return 'assets/folder/' + FILEEXT_ICON_MAP['folder'];
79
- }
80
- const identifierIndex = typeof filename === 'string' && filename.lastIndexOf('.');
81
- if (identifierIndex === -1) {
82
- return 'assets/file/192/' + FILEEXT_ICON_MAP['default'];
83
- }
84
- const file_ext = typeof filename === 'string' && filename.slice(identifierIndex + 1).toLowerCase() || 'default';
85
- const iconUrl = FILEEXT_ICON_MAP[file_ext] ? 'assets/file/192/' + FILEEXT_ICON_MAP[file_ext] : 'assets/file/192/' + FILEEXT_ICON_MAP['default'];
86
- return iconUrl;
87
- };
88
- exports.getFileIconUrl = getFileIconUrl;
89
- const imageCheck = filename => {
90
- // no file ext
91
- if (!filename || typeof filename !== 'string') return false;
92
- if (filename.lastIndexOf('.') === -1) {
93
- return false;
94
- }
95
- const file_ext = filename.substr(filename.lastIndexOf('.') + 1).toLowerCase();
96
- const image_exts = ['gif', 'jpeg', 'jpg', 'png', 'ico', 'bmp', 'tif', 'tiff', 'webp'];
97
- return image_exts.includes(file_ext);
98
- };
99
- exports.imageCheck = imageCheck;
@@ -1,9 +0,0 @@
1
- .dtable-ui-multiple-select-editor {
2
- position: relative;
3
- }
4
-
5
- .dtable-ui-select-editor-container {
6
- display: inline-block;
7
- height: 30px;
8
- padding: 0 10px;
9
- }
@@ -1 +0,0 @@
1
- @import url('../css/cell-formatter.css');
@@ -1,14 +0,0 @@
1
- .dtable-ui-single-select-editor {
2
- position: relative;
3
- }
4
-
5
- .dtable-ui-single-select-option-container {
6
- height: 40px;
7
- padding: 10px 5px;
8
- border-radius: 3px;
9
- cursor: pointer;
10
- }
11
-
12
- .dtable-ui-single-select-option-container:hover {
13
- background-color: #f5f5f5;
14
- }