dtable-ui-component 5.3.1-beta1 → 6.0.0

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 (226) hide show
  1. package/lib/CheckboxEditor/index.css +20 -3
  2. package/lib/CheckboxEditor/index.js +35 -98
  3. package/lib/CheckboxFormatter/index.js +9 -6
  4. package/lib/CollaboratorEditor/index.css +35 -12
  5. package/lib/CollaboratorEditor/index.js +212 -18
  6. package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.js +29 -26
  7. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +97 -0
  8. package/lib/CollaboratorItem/index.css +1 -1
  9. package/lib/CollaboratorItem/index.js +2 -6
  10. package/lib/DTableFiltersPopover/utils/index.js +7 -1
  11. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  12. package/lib/DTableSelect/index.js +1 -3
  13. package/lib/DateEditor/index.js +51 -14
  14. package/lib/DateEditor/pc-date-editor-popover.js +12 -145
  15. package/lib/Department-editor/department-single-select.js +1 -1
  16. package/lib/Department-editor/index.js +4 -3
  17. package/lib/DepartmentSingleSelectFormatter/index.js +1 -2
  18. package/lib/FileEditor/index.js +11 -244
  19. package/lib/FileEditor/pc-files-addition/index.js +1 -0
  20. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +1 -0
  21. package/lib/FileEditor/pc-files-preview/index.js +1 -0
  22. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +1 -0
  23. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  24. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  25. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  26. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  27. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  28. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  29. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  30. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  31. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  32. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  33. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  34. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  35. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  36. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  37. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  38. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  39. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  40. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  41. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  42. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  43. package/lib/FileItemFormatter/index.js +20 -19
  44. package/lib/FileItemFormatter/utils.js +99 -0
  45. package/lib/FileUploader/index.js +14 -268
  46. package/lib/FormulaFormatter/index.js +1 -2
  47. package/lib/FormulaFormatter/utils.js +31 -0
  48. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  49. package/lib/LongTextFormatter/index.js +4 -7
  50. package/lib/MultipleSelectEditor/index.css +9 -0
  51. package/lib/MultipleSelectEditor/index.js +177 -16
  52. package/lib/NumberEditor/index.js +77 -64
  53. package/lib/RoleStatusEditor/index.js +5 -4
  54. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.css +1 -1
  55. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.js +1 -1
  56. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.css +6 -6
  57. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.js +1 -3
  58. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/row-expand-file-item-formatter.js +11 -10
  59. package/lib/RowExpandFormatter/index.css +0 -26
  60. package/lib/RowExpandFormatter/index.js +100 -84
  61. package/lib/{RowExpandFormatter/RowExpandFormulaFormatter → RowExpandFormulaFormatter}/index.js +10 -11
  62. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.css +6 -6
  63. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.js +1 -1
  64. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  65. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  66. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.js +5 -5
  67. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/utils.js +1 -1
  68. package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.css +1 -1
  69. package/lib/RowExpandUrlFormatter/index.css +1 -0
  70. package/lib/{RowExpandFormatter/RowExpandUrlFormatter → RowExpandUrlFormatter}/index.js +3 -4
  71. package/lib/SingleSelectEditor/index.css +14 -0
  72. package/lib/SingleSelectEditor/index.js +156 -16
  73. package/lib/TextEditor/index.js +42 -113
  74. package/lib/constants/index.js +2 -34
  75. package/lib/css/cell-editor.css +2 -18
  76. package/lib/index.js +46 -74
  77. package/lib/lang/index.js +14 -16
  78. package/lib/locals/de.js +103 -0
  79. package/lib/locals/en.js +104 -0
  80. package/lib/locals/es.js +103 -0
  81. package/lib/locals/fr.js +103 -0
  82. package/lib/locals/pt.js +103 -0
  83. package/lib/locals/ru.js +103 -0
  84. package/lib/locals/zh-CN.js +104 -0
  85. package/lib/select-editor/index.js +6 -6
  86. package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.js +3 -3
  87. package/lib/select-editor/pc-select-editor-popover/index.css +71 -0
  88. package/lib/select-editor/pc-select-editor-popover/index.js +122 -0
  89. package/lib/toaster/toaster.js +4 -3
  90. package/lib/utils/editor-utils.js +6 -1
  91. package/lib/utils/url.js +8 -119
  92. package/lib/utils/utils.js +2 -89
  93. package/package.json +13 -14
  94. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +0 -257
  95. package/lib/DeleteTip/index.js +0 -50
  96. package/lib/DigitalSignEditor/constants.js +0 -7
  97. package/lib/DigitalSignEditor/index.css +0 -69
  98. package/lib/DigitalSignEditor/index.js +0 -182
  99. package/lib/DigitalSignEditor/service.js +0 -38
  100. package/lib/DigitalSignEditor/signature-board/index.css +0 -35
  101. package/lib/DigitalSignEditor/signature-board/index.js +0 -135
  102. package/lib/DigitalSignEditor/signature-board/signature-tool.js +0 -396
  103. package/lib/DigitalSignEditor/utils.js +0 -29
  104. package/lib/DurationEditor/index.js +0 -111
  105. package/lib/EmailEditor/index.js +0 -59
  106. package/lib/FileEditor/addition-previewer/index.css +0 -1
  107. package/lib/FileEditor/addition-previewer/index.js +0 -52
  108. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +0 -1
  109. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +0 -252
  110. package/lib/FileEditor/constants.js +0 -7
  111. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +0 -74
  112. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +0 -5
  113. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +0 -77
  114. package/lib/FileEditor/files-previewer/file-previewer/index.css +0 -88
  115. package/lib/FileEditor/files-previewer/file-previewer/index.js +0 -167
  116. package/lib/FileEditor/files-previewer/index.css +0 -56
  117. package/lib/FileEditor/files-previewer/index.js +0 -277
  118. package/lib/FileEditor/index.css +0 -6
  119. package/lib/FileEditor/utils.js +0 -22
  120. package/lib/FileUploader/index.css +0 -9
  121. package/lib/GeolocationEditor/country-editor.js +0 -319
  122. package/lib/GeolocationEditor/index.css +0 -641
  123. package/lib/GeolocationEditor/index.js +0 -241
  124. package/lib/GeolocationEditor/location-editor.js +0 -368
  125. package/lib/GeolocationEditor/map-editor/index.js +0 -456
  126. package/lib/GeolocationEditor/map-editor/large-editor/index.css +0 -137
  127. package/lib/GeolocationEditor/map-editor/large-editor/index.js +0 -461
  128. package/lib/GeolocationEditor/map-editor-utils.js +0 -153
  129. package/lib/GeolocationEditor/map-selection-editor/index.js +0 -455
  130. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +0 -1
  131. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +0 -447
  132. package/lib/GeolocationEditor/parse-geolocation.js +0 -282
  133. package/lib/GeolocationEditor/province-city-editor.js +0 -292
  134. package/lib/GeolocationEditor/province-editor.js +0 -226
  135. package/lib/GeolocationEditor/selector-header-item.js +0 -28
  136. package/lib/GeolocationEditor/selector-list.js +0 -33
  137. package/lib/GeolocationEditor/with-ref.js +0 -27
  138. package/lib/ImageEditor/addition-previewer/image-link/index.css +0 -45
  139. package/lib/ImageEditor/addition-previewer/image-link/index.js +0 -73
  140. package/lib/ImageEditor/addition-previewer/index.css +0 -106
  141. package/lib/ImageEditor/addition-previewer/index.js +0 -63
  142. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +0 -125
  143. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +0 -254
  144. package/lib/ImageEditor/constants.js +0 -7
  145. package/lib/ImageEditor/images-previewer/image-preview/index.css +0 -59
  146. package/lib/ImageEditor/images-previewer/image-preview/index.js +0 -155
  147. package/lib/ImageEditor/images-previewer/index.css +0 -18
  148. package/lib/ImageEditor/images-previewer/index.js +0 -140
  149. package/lib/ImageEditor/index.css +0 -24
  150. package/lib/ImageEditor/index.js +0 -194
  151. package/lib/ImageThumbnail/index.css +0 -20
  152. package/lib/ImageThumbnail/index.js +0 -136
  153. package/lib/RowExpandDialog/body/index.css +0 -21
  154. package/lib/RowExpandDialog/body/index.js +0 -279
  155. package/lib/RowExpandDialog/column-content/index.css +0 -43
  156. package/lib/RowExpandDialog/column-content/index.js +0 -50
  157. package/lib/RowExpandDialog/constants.js +0 -114
  158. package/lib/RowExpandDialog/header/index.css +0 -31
  159. package/lib/RowExpandDialog/header/index.js +0 -33
  160. package/lib/RowExpandDialog/index.css +0 -24
  161. package/lib/RowExpandDialog/index.js +0 -272
  162. package/lib/RowExpandDialog/utils.js +0 -83
  163. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +0 -22
  164. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +0 -24
  165. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +0 -18
  166. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +0 -43
  167. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +0 -5
  168. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +0 -232
  169. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +0 -130
  170. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +0 -129
  171. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +0 -13
  172. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +0 -208
  173. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +0 -105
  174. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +0 -2
  175. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +0 -125
  176. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +0 -1
  177. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +0 -146
  178. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +0 -17
  179. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +0 -165
  180. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +0 -6
  181. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +0 -170
  182. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +0 -6
  183. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +0 -124
  184. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +0 -44
  185. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +0 -224
  186. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +0 -105
  187. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +0 -13
  188. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +0 -152
  189. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +0 -58
  190. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +0 -192
  191. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +0 -4
  192. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +0 -127
  193. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +0 -31
  194. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +0 -130
  195. package/lib/RowExpandEditor/constants.js +0 -44
  196. package/lib/RowExpandEditor/index.css +0 -0
  197. package/lib/RowExpandEditor/index.js +0 -32
  198. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +0 -27
  199. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +0 -1
  200. package/lib/RowExpandFormatter/constants.js +0 -60
  201. package/lib/UploadProgress/index.js +0 -38
  202. package/lib/UrlEditor/index.js +0 -62
  203. package/lib/common/editor-base.js +0 -53
  204. package/lib/constants/file.js +0 -96
  205. package/lib/constants/key-codes.js +0 -109
  206. package/lib/hooks/index.js +0 -16
  207. package/lib/locales/de.json +0 -163
  208. package/lib/locales/en.json +0 -163
  209. package/lib/locales/es.json +0 -163
  210. package/lib/locales/fr.json +0 -163
  211. package/lib/locales/pt.json +0 -163
  212. package/lib/locales/ru.json +0 -163
  213. package/lib/locales/zh-CN.json +0 -163
  214. package/lib/select-editor/pc-select-editor/index.css +0 -85
  215. package/lib/select-editor/pc-select-editor/index.js +0 -290
  216. package/lib/utils/cell-comparer.js +0 -35
  217. package/lib/utils/cell.js +0 -55
  218. package/lib/utils/column-utils.js +0 -25
  219. package/lib/utils/get-event-transfer.js +0 -75
  220. package/lib/utils/object-utils.js +0 -61
  221. /package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.css +0 -0
  222. /package/lib/CollaboratorEditor/{pc-collaborator-editor → pc-collaborator-editor-popover}/index.css +0 -0
  223. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.css +0 -0
  224. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/value-display-utils.js +0 -0
  225. /package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.js +0 -0
  226. /package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.css +0 -0
package/lib/utils/url.js CHANGED
@@ -3,23 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
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");
6
+ exports.needUseThumbnailImage = exports.isTargetUrl = exports.isInternalImg = exports.isDigitalSignsUrl = exports.isCustomAssetUrl = exports.getImageThumbnailUrl = exports.generateCurrentBaseImageUrl = exports.generateCurrentBaseImageThumbnailUrl = exports.checkSVGImage = void 0;
8
7
  const isTargetUrl = (target, url) => {
9
8
  if (!url || typeof url !== 'string') return false;
10
9
  return target && url ? url.indexOf(target) > -1 : false;
11
10
  };
12
11
  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;
19
12
  const isInternalImg = (url, server) => {
20
- var _window;
21
13
  if (!url || typeof url !== 'string') return false;
22
- const currentServer = server || ((_window = window) === null || _window === void 0 ? void 0 : _window.dtable) && window.dtable.server;
14
+ const currentServer = server || window.dtable && window.dtable.server;
23
15
  return url.indexOf(currentServer) > -1;
24
16
  };
25
17
  exports.isInternalImg = isInternalImg;
@@ -27,33 +19,14 @@ const isCustomAssetUrl = url => {
27
19
  return isTargetUrl('custom-asset://', url);
28
20
  };
29
21
  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;
43
22
  const checkSVGImage = url => {
44
23
  if (!url || typeof url !== 'string') return false;
45
24
  const isSVGImage = url.substring(url.lastIndexOf('.')).toLowerCase() === '.svg';
46
25
  return isSVGImage;
47
26
  };
48
27
  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;
54
28
  const isDigitalSignsUrl = url => {
55
29
  if (!url || typeof url !== 'string') return false;
56
- if (isAIUrl(url)) return true;
57
30
  return isTargetUrl('/digital-signs/', url) && !url.includes('http');
58
31
  };
59
32
  exports.isDigitalSignsUrl = isDigitalSignsUrl;
@@ -67,7 +40,6 @@ const needUseThumbnailImage = url => {
67
40
  };
68
41
  exports.needUseThumbnailImage = needUseThumbnailImage;
69
42
  const generateCurrentBaseImageThumbnailUrl = _ref => {
70
- var _window2;
71
43
  let {
72
44
  server,
73
45
  workspaceID,
@@ -75,13 +47,11 @@ const generateCurrentBaseImageThumbnailUrl = _ref => {
75
47
  partUrl,
76
48
  size
77
49
  } = _ref;
78
- const validServer = server || ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.dtable) && window.dtable.server || '';
79
50
  if (!partUrl || typeof partUrl !== 'string') return '';
80
- return "".concat(validServer, "/thumbnail/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl, "?size=").concat(size);
51
+ return "".concat(server, "/thumbnail/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl, "?size=").concat(size);
81
52
  };
82
53
  exports.generateCurrentBaseImageThumbnailUrl = generateCurrentBaseImageThumbnailUrl;
83
54
  const generateCurrentBaseImageUrl = _ref2 => {
84
- var _window3;
85
55
  let {
86
56
  server,
87
57
  workspaceID,
@@ -89,9 +59,7 @@ const generateCurrentBaseImageUrl = _ref2 => {
89
59
  partUrl
90
60
  } = _ref2;
91
61
  if (!partUrl || typeof partUrl !== 'string') return '';
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);
62
+ return "".concat(server, "/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl);
95
63
  };
96
64
  exports.generateCurrentBaseImageUrl = generateCurrentBaseImageUrl;
97
65
  const getImageThumbnailUrl = function (url) {
@@ -102,7 +70,6 @@ const getImageThumbnailUrl = function (url) {
102
70
  size = 256
103
71
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
104
72
  if (!url || typeof url !== 'string') return '';
105
- if (isAIUrl(url) || checkSVGImage(url) || !isInternalImg(url) || isBase64(url)) return url;
106
73
  if (server && dtableUuid && isCustomAssetUrl(url)) {
107
74
  const assetUuid = url.slice(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
108
75
  return server + '/dtable/' + dtableUuid + '/custom-asset-thumbnail/' + assetUuid + '?size=' + size;
@@ -116,87 +83,9 @@ const getImageThumbnailUrl = function (url) {
116
83
  partUrl: url
117
84
  });
118
85
  }
119
- if (url.includes('/thumbnail/workspace')) return url;
120
- return url.replace('/workspace', '/thumbnail/workspace') + '?size=' + size;
121
- };
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;
86
+ if (checkSVGImage(url) || !isInternalImg(url)) {
87
+ return url;
134
88
  }
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
- };
89
+ return url.replace('/workspace', '/thumbnail/workspace') + '?size=' + size;
201
90
  };
202
- exports.getFileThumbnailInfo = getFileThumbnailInfo;
91
+ exports.getImageThumbnailUrl = getImageThumbnailUrl;
@@ -3,8 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
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");
6
+ exports.throttle = exports.isMac = exports.getEventClassName = exports.downloadFile = exports.debounce = void 0;
8
7
  const debounce = (fn, wait) => {
9
8
  let timeout = null;
10
9
  return function () {
@@ -31,7 +30,6 @@ const throttle = (func, delay) => {
31
30
  };
32
31
  };
33
32
  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);
35
33
  const isMac = () => {
36
34
  const platform = navigator.platform;
37
35
  // eslint-disable-next-line eqeqeq
@@ -50,94 +48,9 @@ const downloadFile = downloadUrl => {
50
48
  document.body.appendChild(iframe);
51
49
  };
52
50
  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;
81
51
  const getEventClassName = e => {
82
52
  // svg mouseEvent event.target.className is an object
83
53
  if (!e || !e.target) return '';
84
54
  return e.target.getAttribute('class') || '';
85
55
  };
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;
56
+ exports.getEventClassName = getEventClassName;
package/package.json CHANGED
@@ -1,25 +1,21 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "5.3.1beta1",
3
+ "version": "6.0.0",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
- "@seafile/react-image-lightbox": "3.0.1",
6
+ "@seafile/react-image-lightbox": "4.0.0",
7
7
  "@seafile/seafile-calendar": "0.0.24",
8
- "@seafile/seafile-editor": "~1.0.123",
8
+ "@seafile/seafile-editor": "2.0.0",
9
9
  "antd-mobile": "2.3.1",
10
10
  "classnames": "2.3.2",
11
11
  "dayjs": "1.10.7",
12
- "dtable-utils": "5.0.16",
12
+ "dtable-utils": "5.0.11",
13
13
  "is-hotkey": "0.2.0",
14
- "prop-types": "^15.8.1",
15
- "react": "17.0.2",
16
- "react-dom": "17.0.2",
17
- "react-responsive": "9.0.2",
18
14
  "react-color": "2.19.3",
19
- "react-select": "5.7.0",
20
- "react-sweet-progress": "^1.1.2",
21
- "react-transition-group": "^4.4.1",
22
- "reactstrap": "8.9.0"
15
+ "react-responsive": "10.0.0",
16
+ "react-select": "5.10.0",
17
+ "react-transition-group": "4.4.5",
18
+ "reactstrap": "9.2.3"
23
19
  },
24
20
  "scripts": {
25
21
  "lint": "./node_modules/.bin/eslint ./src/ --fix",
@@ -67,6 +63,7 @@
67
63
  "@babel/polyfill": "^7.10.1",
68
64
  "@babel/preset-env": "^7.9.5",
69
65
  "@babel/runtime": "7.22.11",
66
+ "@cfaester/enzyme-adapter-react-18": "0.8.0",
70
67
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
71
68
  "@storybook/addon-actions": "7.6.17",
72
69
  "@storybook/addon-docs": "7.6.17",
@@ -85,7 +82,6 @@
85
82
  "@testing-library/react": "^11.1.0",
86
83
  "@testing-library/user-event": "13.5.0",
87
84
  "@types/jest": "^29.5.10",
88
- "@wojtekmaj/enzyme-adapter-react-17": "0.8.0",
89
85
  "autoprefixer": "10.4.5",
90
86
  "babel-jest": "^27.4.2",
91
87
  "babel-loader": "^8.2.3",
@@ -127,9 +123,12 @@
127
123
  "postcss-normalize": "^10.0.1",
128
124
  "postcss-preset-env": "^7.0.1",
129
125
  "prompts": "^2.4.2",
126
+ "prop-types": "15.8.1",
127
+ "react": "18.3.1",
130
128
  "react-app-polyfill": "^3.0.0",
131
129
  "react-dev-utils": "^12.0.1",
132
- "react-element-to-jsx-string": "^14.3.1",
130
+ "react-dom": "18.3.1",
131
+ "react-element-to-jsx-string": "15.0.0",
133
132
  "react-i18next": "12.1.4",
134
133
  "react-refresh": "^0.11.0",
135
134
  "resolve": "^1.20.0",
@@ -1,257 +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 _dtableUtils = require("dtable-utils");
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _reactstrap = require("reactstrap");
12
- var _lang = require("../../lang");
13
- var _CollaboratorItem = _interopRequireDefault(require("../../CollaboratorItem"));
14
- var _DTableSearchInput = _interopRequireDefault(require("../../DTableSearchInput"));
15
- var _constants = require("../../constants");
16
- var _objectUtils = _interopRequireDefault(require("../../utils/object-utils"));
17
- require("./index.css");
18
- class PCCollaboratorEditor extends _react.default.Component {
19
- constructor(props) {
20
- super(props);
21
- this.onValueChanged = newSearchValue => {
22
- if (newSearchValue === this.state.searchValue) return;
23
- const {
24
- collaborators
25
- } = this.props;
26
- this.filteredCollaborators = (0, _dtableUtils.searchCollaborators)(collaborators, newSearchValue);
27
- this.setState({
28
- highlightIndex: this.filteredCollaborators.length > 0 ? 0 : -1,
29
- searchValue: newSearchValue
30
- });
31
- };
32
- this.onCollaboratorClick = collaborator => {
33
- this.props.onCommit(collaborator);
34
- };
35
- this.getFilterCollaborator = () => {
36
- const {
37
- collaborators
38
- } = this.props;
39
- const searchValue = this.state.searchValue.toLowerCase();
40
- if (!searchValue) return collaborators;
41
- return (0, _dtableUtils.searchCollaborators)(collaborators, searchValue);
42
- };
43
- this.getMaxItemNum = () => {
44
- let collaboratorContainerStyle = getComputedStyle(this.container, null);
45
- let collaboratorItemStyle = getComputedStyle(this.collaboratorItem, null);
46
- let maxContainerItemNum = Math.floor(parseInt(collaboratorContainerStyle.maxHeight) / parseInt(collaboratorItemStyle.height));
47
- return maxContainerItemNum - 1;
48
- };
49
- this.onHotKey = e => {
50
- if (e.keyCode === _constants.KeyCodes.Enter) {
51
- this.onEnter(e);
52
- } else if (e.keyCode === _constants.KeyCodes.UpArrow) {
53
- this.onUpArrow(e);
54
- } else if (e.keyCode === _constants.KeyCodes.DownArrow) {
55
- this.onDownArrow(e);
56
- } else if (e.keyCode === _constants.KeyCodes.Escape) {
57
- this.onEsc(e);
58
- } else if (e.keyCode === _constants.KeyCodes.Tab) {
59
- if (this.props.onPressTab) {
60
- this.props.onPressTab(e);
61
- }
62
- }
63
- };
64
- this.onEnter = e => {
65
- e.preventDefault();
66
- let collaborator;
67
- if (this.filteredCollaborators.length === 1) {
68
- collaborator = this.filteredCollaborators[0];
69
- } else if (this.state.highlightIndex > -1) {
70
- collaborator = this.filteredCollaborators[this.state.highlightIndex];
71
- }
72
- if (collaborator) {
73
- this.onCollaboratorClick(collaborator);
74
- }
75
- };
76
- this.onUpArrow = e => {
77
- e.preventDefault();
78
- e.stopPropagation();
79
- let {
80
- highlightIndex,
81
- maxItemNum,
82
- itemHeight
83
- } = this.state;
84
- if (highlightIndex > 0) {
85
- this.setState({
86
- highlightIndex: highlightIndex - 1
87
- }, () => {
88
- if (highlightIndex < this.filteredCollaborators.length - maxItemNum) {
89
- this.container.scrollTop -= itemHeight;
90
- }
91
- });
92
- } else {
93
- this.setState({
94
- highlightIndex: this.filteredCollaborators.length - 1
95
- }, () => {
96
- this.container.scrollTop = this.container.scrollHeight;
97
- });
98
- }
99
- };
100
- this.onDownArrow = e => {
101
- e.preventDefault();
102
- e.stopPropagation();
103
- let {
104
- highlightIndex,
105
- maxItemNum,
106
- itemHeight
107
- } = this.state;
108
- if (highlightIndex < this.filteredCollaborators.length - 1) {
109
- this.setState({
110
- highlightIndex: highlightIndex + 1
111
- }, () => {
112
- if (highlightIndex >= maxItemNum) {
113
- this.container.scrollTop += itemHeight;
114
- }
115
- });
116
- } else {
117
- this.setState({
118
- highlightIndex: 0
119
- }, () => {
120
- this.container.scrollTop = 0;
121
- });
122
- }
123
- };
124
- this.onEsc = e => {
125
- e.preventDefault();
126
- e.stopPropagation();
127
- const {
128
- isInModal,
129
- value,
130
- onCommitCancel,
131
- onClose
132
- } = this.props;
133
- if (isInModal) {
134
- onClose && onClose();
135
- return;
136
- }
137
- if (_objectUtils.default.isSameObject({
138
- 'value': this.state.value
139
- }, {
140
- value
141
- })) {
142
- onCommitCancel && onCommitCancel();
143
- return;
144
- }
145
- this.onCommit();
146
- };
147
- this.onCommit = () => {
148
- const value = this.getValue();
149
- this.props.onCommit(value);
150
- };
151
- this.getValue = () => {
152
- return this.state.value;
153
- };
154
- this.onKeyDown = e => {
155
- if (e.keyCode === _constants.KeyCodes.LeftArrow || e.keyCode === _constants.KeyCodes.RightArrow) {
156
- e.stopPropagation();
157
- }
158
- };
159
- this.state = {
160
- searchValue: '',
161
- highlightIndex: -1,
162
- maxItemNum: 0,
163
- itemHeight: 0
164
- };
165
- this.filteredCollaborators = props.collaborators || [];
166
- }
167
- componentDidMount() {
168
- if (this.props.isInModal && this.parent) {
169
- if (this.parent.getBoundingClientRect().top > 330) {
170
- this.ref.style.top = '-200px';
171
- }
172
- }
173
- if (!this.props.isInModal && this.ref) {
174
- const {
175
- bottom
176
- } = this.ref.getBoundingClientRect();
177
- if (bottom > window.innerHeight) {
178
- this.ref.style.top = "".concat(window.innerHeight - bottom, "px");
179
- }
180
- }
181
- if (this.container && this.collaboratorItem) {
182
- this.setState({
183
- maxItemNum: this.getMaxItemNum(),
184
- itemHeight: parseInt(getComputedStyle(this.collaboratorItem, null).height)
185
- });
186
- }
187
- document.addEventListener('keydown', this.onHotKey, true);
188
- }
189
- UNSAFE_componentWillReceiveProps(nextProps) {
190
- if (nextProps.isInModal && nextProps.value !== this.state.value && Array.isArray(nextProps.value)) {
191
- this.setState({
192
- value: nextProps.value
193
- });
194
- }
195
- }
196
- componentWillUnmount() {
197
- document.removeEventListener('keydown', this.onHotKey, true);
198
- }
199
- render() {
200
- const {
201
- searchValue,
202
- highlightIndex
203
- } = this.state;
204
- const {
205
- isInModal,
206
- value = [],
207
- target
208
- } = this.props;
209
- const dom = /*#__PURE__*/_react.default.createElement("div", {
210
- className: "dtable-ui-editor-container dtable-ui-collaborator-editor-container",
211
- ref: ref => this.ref = ref
212
- }, /*#__PURE__*/_react.default.createElement("div", {
213
- className: "collaborator-search-container"
214
- }, /*#__PURE__*/_react.default.createElement(_DTableSearchInput.default, {
215
- autoFocus: true,
216
- placeholder: (0, _lang.getLocale)('Search_collaborator'),
217
- value: searchValue,
218
- onChange: this.onValueChanged,
219
- onKeyDown: this.onKeyDown
220
- })), /*#__PURE__*/_react.default.createElement("div", {
221
- className: "collaborator-list-container",
222
- ref: ref => this.container = ref
223
- }, this.filteredCollaborators.length > 0 && this.filteredCollaborators.map((collaborator, index) => {
224
- const isSelected = value.includes(collaborator.email);
225
- return /*#__PURE__*/_react.default.createElement("div", {
226
- key: collaborator.email,
227
- className: (0, _classnames.default)('collaborator-item-container', {
228
- 'collaborator-item-container-highlight': index === highlightIndex
229
- }),
230
- ref: ref => this.collaboratorItem = ref,
231
- onClick: this.onCollaboratorClick.bind(this, collaborator)
232
- }, /*#__PURE__*/_react.default.createElement(_CollaboratorItem.default, {
233
- collaborator: collaborator
234
- }), /*#__PURE__*/_react.default.createElement("div", {
235
- className: "collaborator-checked"
236
- }, isSelected && /*#__PURE__*/_react.default.createElement("i", {
237
- className: "dtable-font dtable-icon-check-mark"
238
- })));
239
- }), this.filteredCollaborators.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
240
- className: "dtable-ui-editor-no-search-result"
241
- }, (0, _lang.getLocale)('No_collaborators_available'))));
242
- if (isInModal) {
243
- return /*#__PURE__*/_react.default.createElement("div", {
244
- ref: ref => this.parent = ref
245
- }, /*#__PURE__*/_react.default.createElement(_reactstrap.Popover, {
246
- placement: "bottom-start",
247
- isOpen: true,
248
- target: target,
249
- hideArrow: true,
250
- fade: false,
251
- className: "dtable-ui-row-expand-select-editor-popover"
252
- }, dom));
253
- }
254
- return dom;
255
- }
256
- }
257
- var _default = exports.default = PCCollaboratorEditor;
@@ -1,50 +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 _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
10
- var _ModalPortal = _interopRequireDefault(require("../ModalPortal"));
11
- var _lang = require("../lang");
12
- class DeleteTip extends _react.default.Component {
13
- constructor() {
14
- super(...arguments);
15
- this.handleOutsideClick = e => {
16
- if (this.tipContainer && !this.tipContainer.contains(e.target)) {
17
- this.props.toggle();
18
- }
19
- };
20
- }
21
- render() {
22
- const {
23
- toggle,
24
- deleteImage,
25
- position,
26
- deleteTip
27
- } = this.props;
28
- return /*#__PURE__*/_react.default.createElement(_ModalPortal.default, null, /*#__PURE__*/_react.default.createElement(_ClickOutside.default, {
29
- onClickOutside: this.handleOutsideClick
30
- }, /*#__PURE__*/_react.default.createElement("div", {
31
- ref: node => this.tipContainer = node,
32
- className: "dtable-tip tip-container",
33
- style: {
34
- top: position.top,
35
- left: position.left
36
- }
37
- }, /*#__PURE__*/_react.default.createElement("b", {
38
- className: "mb-4"
39
- }, deleteTip), /*#__PURE__*/_react.default.createElement("div", {
40
- className: "d-flex justify-content-end"
41
- }, /*#__PURE__*/_react.default.createElement("button", {
42
- className: "btn btn-secondary mr-2",
43
- onClick: toggle
44
- }, (0, _lang.getLocale)('Cancel')), /*#__PURE__*/_react.default.createElement("button", {
45
- className: "btn btn-primary",
46
- onClick: deleteImage
47
- }, (0, _lang.getLocale)('Delete'))))));
48
- }
49
- }
50
- var _default = exports.default = DeleteTip;
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DIGITAL_SIGNS_FOLDER = void 0;
7
- const DIGITAL_SIGNS_FOLDER = exports.DIGITAL_SIGNS_FOLDER = 'digital-signs';