dtable-ui-component 5.3.1-beta6 → 5.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CheckboxEditor/index.css +20 -3
- package/lib/CheckboxEditor/index.js +35 -98
- package/lib/CheckboxFormatter/index.js +9 -6
- package/lib/CollaboratorEditor/index.css +35 -12
- package/lib/CollaboratorEditor/index.js +212 -18
- package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.js +29 -26
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +97 -0
- package/lib/CollaboratorItem/index.css +1 -1
- package/lib/CollaboratorItem/index.js +2 -6
- package/lib/DTableFiltersPopover/utils/index.js +7 -1
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
- package/lib/DTableGroupSelect/select-option-group.css +17 -17
- package/lib/DTableGroupSelect/select-option-group.js +1 -1
- package/lib/DTableSelect/index.js +1 -3
- package/lib/DateEditor/index.js +51 -14
- package/lib/DateEditor/pc-date-editor-popover.js +12 -145
- package/lib/Department-editor/department-single-select.js +1 -1
- package/lib/Department-editor/index.js +4 -3
- package/lib/DepartmentSingleSelectFormatter/index.js +1 -2
- package/lib/FileEditor/index.js +11 -258
- package/lib/FileEditor/pc-files-addition/index.js +1 -0
- package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +1 -0
- package/lib/FileEditor/pc-files-preview/index.js +1 -0
- package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +1 -0
- package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
- package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
- package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
- package/lib/FileItemFormatter/index.js +20 -19
- package/lib/FileItemFormatter/utils.js +99 -0
- package/lib/FileUploader/index.js +14 -268
- package/lib/FormulaFormatter/index.js +1 -2
- package/lib/FormulaFormatter/utils.js +31 -0
- package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
- package/lib/MultipleSelectEditor/index.css +9 -0
- package/lib/MultipleSelectEditor/index.js +177 -16
- package/lib/NumberEditor/index.js +77 -64
- package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.css +1 -1
- package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.js +1 -1
- package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.css +6 -6
- package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.js +1 -3
- package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/row-expand-file-item-formatter.js +11 -10
- package/lib/RowExpandFormatter/index.css +1 -27
- package/lib/RowExpandFormatter/index.js +100 -83
- package/lib/{RowExpandFormatter/RowExpandFormulaFormatter → RowExpandFormulaFormatter}/index.js +10 -11
- package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.css +6 -6
- package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.js +1 -1
- package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
- package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
- package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.js +6 -6
- package/lib/RowExpandLinkFormatter/utils.js +71 -0
- package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.css +1 -1
- package/lib/RowExpandUrlFormatter/index.css +1 -0
- package/lib/{RowExpandFormatter/RowExpandUrlFormatter → RowExpandUrlFormatter}/index.js +3 -4
- package/lib/SingleSelectEditor/index.css +14 -0
- package/lib/SingleSelectEditor/index.js +156 -16
- package/lib/TextEditor/index.js +42 -113
- package/lib/constants/index.js +2 -34
- package/lib/css/cell-editor.css +2 -18
- package/lib/index.js +46 -74
- package/lib/lang/index.js +16 -19
- package/lib/locals/de.js +103 -0
- package/lib/locals/en.js +104 -0
- package/lib/locals/es.js +103 -0
- package/lib/locals/fr.js +103 -0
- package/lib/locals/pt.js +103 -0
- package/lib/locals/ru.js +103 -0
- package/lib/locals/zh-CN.js +104 -0
- package/lib/select-editor/index.js +6 -6
- package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.js +3 -3
- package/lib/select-editor/pc-select-editor-popover/index.css +71 -0
- package/lib/select-editor/pc-select-editor-popover/index.js +122 -0
- package/lib/utils/editor-utils.js +6 -1
- package/lib/utils/url.js +8 -121
- package/lib/utils/utils.js +2 -145
- package/package.json +2 -3
- package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +0 -257
- package/lib/Comment/body/comment.js +0 -190
- package/lib/Comment/body/index.css +0 -95
- package/lib/Comment/body/index.js +0 -32
- package/lib/Comment/footer/btns/index.css +0 -40
- package/lib/Comment/footer/btns/index.js +0 -113
- package/lib/Comment/footer/index.css +0 -157
- package/lib/Comment/footer/index.js +0 -170
- package/lib/Comment/footer/input/index.css +0 -52
- package/lib/Comment/footer/input/index.js +0 -448
- package/lib/Comment/footer/input/participant/index.css +0 -0
- package/lib/Comment/footer/input/participant/index.js +0 -53
- package/lib/Comment/footer/participants/index.css +0 -22
- package/lib/Comment/footer/participants/index.js +0 -68
- package/lib/Comment/footer/participants/participant/index.css +0 -5
- package/lib/Comment/footer/participants/participant/index.js +0 -32
- package/lib/Comment/footer/participants/participant-select/index.css +0 -104
- package/lib/Comment/footer/participants/participant-select/index.js +0 -182
- package/lib/Comment/index.css +0 -19
- package/lib/Comment/index.js +0 -305
- package/lib/Comment/model.js +0 -25
- package/lib/Comment/utils/common.js +0 -62
- package/lib/Comment/utils/index.js +0 -27
- package/lib/Comment/utils/utilities.js +0 -176
- package/lib/DeleteTip/index.js +0 -50
- package/lib/DigitalSignEditor/constants.js +0 -7
- package/lib/DigitalSignEditor/index.css +0 -69
- package/lib/DigitalSignEditor/index.js +0 -182
- package/lib/DigitalSignEditor/service.js +0 -38
- package/lib/DigitalSignEditor/signature-board/index.css +0 -35
- package/lib/DigitalSignEditor/signature-board/index.js +0 -135
- package/lib/DigitalSignEditor/signature-board/signature-tool.js +0 -396
- package/lib/DigitalSignEditor/utils.js +0 -29
- package/lib/DurationEditor/index.js +0 -111
- package/lib/EmailEditor/index.js +0 -59
- package/lib/FileEditor/addition-previewer/index.css +0 -1
- package/lib/FileEditor/addition-previewer/index.js +0 -52
- package/lib/FileEditor/addition-previewer/local-file-addition/index.css +0 -1
- package/lib/FileEditor/addition-previewer/local-file-addition/index.js +0 -252
- package/lib/FileEditor/constants.js +0 -7
- package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +0 -74
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +0 -5
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +0 -77
- package/lib/FileEditor/files-previewer/file-previewer/index.css +0 -88
- package/lib/FileEditor/files-previewer/file-previewer/index.js +0 -167
- package/lib/FileEditor/files-previewer/index.css +0 -56
- package/lib/FileEditor/files-previewer/index.js +0 -277
- package/lib/FileEditor/index.css +0 -6
- package/lib/FileEditor/utils.js +0 -22
- package/lib/FileUploader/index.css +0 -9
- package/lib/GeolocationEditor/country-editor.js +0 -319
- package/lib/GeolocationEditor/index.css +0 -641
- package/lib/GeolocationEditor/index.js +0 -241
- package/lib/GeolocationEditor/location-editor.js +0 -368
- package/lib/GeolocationEditor/map-editor/index.js +0 -456
- package/lib/GeolocationEditor/map-editor/large-editor/index.css +0 -137
- package/lib/GeolocationEditor/map-editor/large-editor/index.js +0 -461
- package/lib/GeolocationEditor/map-editor-utils.js +0 -153
- package/lib/GeolocationEditor/map-selection-editor/index.js +0 -455
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +0 -1
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +0 -447
- package/lib/GeolocationEditor/parse-geolocation.js +0 -282
- package/lib/GeolocationEditor/province-city-editor.js +0 -292
- package/lib/GeolocationEditor/province-editor.js +0 -226
- package/lib/GeolocationEditor/selector-header-item.js +0 -28
- package/lib/GeolocationEditor/selector-list.js +0 -33
- package/lib/GeolocationEditor/with-ref.js +0 -27
- package/lib/ImageEditor/addition-previewer/image-link/index.css +0 -45
- package/lib/ImageEditor/addition-previewer/image-link/index.js +0 -73
- package/lib/ImageEditor/addition-previewer/index.css +0 -106
- package/lib/ImageEditor/addition-previewer/index.js +0 -63
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +0 -125
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +0 -254
- package/lib/ImageEditor/constants.js +0 -7
- package/lib/ImageEditor/images-previewer/image-preview/index.css +0 -59
- package/lib/ImageEditor/images-previewer/image-preview/index.js +0 -155
- package/lib/ImageEditor/images-previewer/index.css +0 -18
- package/lib/ImageEditor/images-previewer/index.js +0 -140
- package/lib/ImageEditor/index.css +0 -24
- package/lib/ImageEditor/index.js +0 -194
- package/lib/ImageThumbnail/index.css +0 -20
- package/lib/ImageThumbnail/index.js +0 -136
- package/lib/RowExpandDialog/body/index.css +0 -21
- package/lib/RowExpandDialog/body/index.js +0 -262
- package/lib/RowExpandDialog/column-content/index.css +0 -44
- package/lib/RowExpandDialog/column-content/index.js +0 -50
- package/lib/RowExpandDialog/header/index.css +0 -31
- package/lib/RowExpandDialog/header/index.js +0 -55
- package/lib/RowExpandDialog/index.css +0 -24
- package/lib/RowExpandDialog/index.js +0 -252
- package/lib/RowExpandEditor/RowExpandAddBtn/index.css +0 -22
- package/lib/RowExpandEditor/RowExpandAddBtn/index.js +0 -24
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +0 -18
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +0 -43
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +0 -5
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +0 -232
- package/lib/RowExpandEditor/RowExpandDateEditor/index.js +0 -130
- package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +0 -129
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +0 -13
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +0 -208
- package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +0 -105
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +0 -2
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +0 -125
- package/lib/RowExpandEditor/RowExpandFileEditor/index.css +0 -1
- package/lib/RowExpandEditor/RowExpandFileEditor/index.js +0 -146
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +0 -17
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +0 -165
- package/lib/RowExpandEditor/RowExpandImageEditor/index.css +0 -6
- package/lib/RowExpandEditor/RowExpandImageEditor/index.js +0 -170
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +0 -6
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +0 -123
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +0 -44
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +0 -224
- package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +0 -105
- package/lib/RowExpandEditor/RowExpandRateEditor/index.css +0 -13
- package/lib/RowExpandEditor/RowExpandRateEditor/index.js +0 -152
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +0 -58
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +0 -192
- package/lib/RowExpandEditor/RowExpandTextEditor/index.css +0 -4
- package/lib/RowExpandEditor/RowExpandTextEditor/index.js +0 -127
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +0 -31
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +0 -130
- package/lib/RowExpandEditor/constants.js +0 -44
- package/lib/RowExpandEditor/index.css +0 -0
- package/lib/RowExpandEditor/index.js +0 -32
- package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +0 -27
- package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +0 -1
- package/lib/RowExpandFormatter/constants.js +0 -60
- package/lib/UploadProgress/index.js +0 -38
- package/lib/UrlEditor/index.js +0 -62
- package/lib/common/editor-base.js +0 -53
- package/lib/constants/file.js +0 -96
- package/lib/constants/key-codes.js +0 -109
- package/lib/hooks/index.js +0 -16
- package/lib/locales/de.json +0 -167
- package/lib/locales/en.json +0 -167
- package/lib/locales/es.json +0 -167
- package/lib/locales/fr.json +0 -167
- package/lib/locales/pt.json +0 -167
- package/lib/locales/ru.json +0 -167
- package/lib/locales/zh-CN.json +0 -167
- package/lib/select-editor/pc-select-editor/index.css +0 -85
- package/lib/select-editor/pc-select-editor/index.js +0 -290
- package/lib/utils/cell-comparer.js +0 -35
- package/lib/utils/cell.js +0 -55
- package/lib/utils/column-utils.js +0 -25
- package/lib/utils/get-event-transfer.js +0 -75
- package/lib/utils/hotkey.js +0 -37
- package/lib/utils/object-utils.js +0 -61
- /package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.css +0 -0
- /package/lib/CollaboratorEditor/{pc-collaborator-editor → pc-collaborator-editor-popover}/index.css +0 -0
- /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.css +0 -0
- /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/value-display-utils.js +0 -0
- /package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.js +0 -0
- /package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.css +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.initDateEditorLanguage = exports.getTrimmedString = exports.getSelectOptionItem = void 0;
|
|
6
|
+
exports.isValidUrl = exports.initDateEditorLanguage = exports.getTrimmedString = exports.getSelectOptionItem = void 0;
|
|
7
7
|
const zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
8
8
|
const zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
9
9
|
const enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
@@ -63,6 +63,11 @@ const getSelectOptionItem = (options, optionId) => {
|
|
|
63
63
|
return options.find(option => option.id === optionId);
|
|
64
64
|
};
|
|
65
65
|
exports.getSelectOptionItem = getSelectOptionItem;
|
|
66
|
+
const isValidUrl = url => {
|
|
67
|
+
const reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
|
|
68
|
+
return reg.test(url);
|
|
69
|
+
};
|
|
70
|
+
exports.isValidUrl = isValidUrl;
|
|
66
71
|
const getTrimmedString = value => {
|
|
67
72
|
return typeof value === 'string' ? value.trim() : '';
|
|
68
73
|
};
|
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.
|
|
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 ||
|
|
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,15 +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
|
-
|
|
81
|
-
if (url.indexOf('?') > -1) return "".concat(url, "&size=").concat(size);
|
|
82
|
-
return "".concat(url, "?size=").concat(size);
|
|
51
|
+
return "".concat(server, "/thumbnail/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl, "?size=").concat(size);
|
|
83
52
|
};
|
|
84
53
|
exports.generateCurrentBaseImageThumbnailUrl = generateCurrentBaseImageThumbnailUrl;
|
|
85
54
|
const generateCurrentBaseImageUrl = _ref2 => {
|
|
86
|
-
var _window3;
|
|
87
55
|
let {
|
|
88
56
|
server,
|
|
89
57
|
workspaceID,
|
|
@@ -91,9 +59,7 @@ const generateCurrentBaseImageUrl = _ref2 => {
|
|
|
91
59
|
partUrl
|
|
92
60
|
} = _ref2;
|
|
93
61
|
if (!partUrl || typeof partUrl !== 'string') return '';
|
|
94
|
-
|
|
95
|
-
const validServer = server || ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.dtable) && window.dtable.server || '';
|
|
96
|
-
return "".concat(validServer, "/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl);
|
|
62
|
+
return "".concat(server, "/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl);
|
|
97
63
|
};
|
|
98
64
|
exports.generateCurrentBaseImageUrl = generateCurrentBaseImageUrl;
|
|
99
65
|
const getImageThumbnailUrl = function (url) {
|
|
@@ -104,7 +70,6 @@ const getImageThumbnailUrl = function (url) {
|
|
|
104
70
|
size = 256
|
|
105
71
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
106
72
|
if (!url || typeof url !== 'string') return '';
|
|
107
|
-
if (isAIUrl(url) || checkSVGImage(url) || !isInternalImg(url) || isBase64(url)) return url;
|
|
108
73
|
if (server && dtableUuid && isCustomAssetUrl(url)) {
|
|
109
74
|
const assetUuid = url.slice(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
|
|
110
75
|
return server + '/dtable/' + dtableUuid + '/custom-asset-thumbnail/' + assetUuid + '?size=' + size;
|
|
@@ -118,87 +83,9 @@ const getImageThumbnailUrl = function (url) {
|
|
|
118
83
|
partUrl: url
|
|
119
84
|
});
|
|
120
85
|
}
|
|
121
|
-
if (url
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
exports.getImageThumbnailUrl = getImageThumbnailUrl;
|
|
125
|
-
const getFileName = url => {
|
|
126
|
-
if (!url) return null;
|
|
127
|
-
let lastIndex = url.lastIndexOf('/');
|
|
128
|
-
return url.slice(lastIndex + 1);
|
|
129
|
-
};
|
|
130
|
-
exports.getFileName = getFileName;
|
|
131
|
-
const imageCheck = filename => {
|
|
132
|
-
// no file ext
|
|
133
|
-
if (!filename || typeof filename !== 'string') return false;
|
|
134
|
-
if (filename.lastIndexOf('.') === -1) {
|
|
135
|
-
return false;
|
|
86
|
+
if (checkSVGImage(url) || !isInternalImg(url)) {
|
|
87
|
+
return url;
|
|
136
88
|
}
|
|
137
|
-
|
|
138
|
-
const image_exts = ['gif', 'jpeg', 'jpg', 'png', 'ico', 'bmp', 'tif', 'tiff', 'webp'];
|
|
139
|
-
return image_exts.includes(file_ext);
|
|
140
|
-
};
|
|
141
|
-
exports.imageCheck = imageCheck;
|
|
142
|
-
const isInternalURL = function (url) {
|
|
143
|
-
let {
|
|
144
|
-
server = ''
|
|
145
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
146
|
-
if (!url || typeof url !== 'string') return false;
|
|
147
|
-
return server && url.indexOf(server) > -1;
|
|
148
|
-
};
|
|
149
|
-
exports.isInternalURL = isInternalURL;
|
|
150
|
-
const getValidFileImageUrls = files => {
|
|
151
|
-
if (!Array.isArray(files)) return [];
|
|
152
|
-
return files.map(file => {
|
|
153
|
-
if (typeof file !== 'object') return null;
|
|
154
|
-
const {
|
|
155
|
-
url,
|
|
156
|
-
name
|
|
157
|
-
} = file;
|
|
158
|
-
if (!url || url.indexOf('/asset') < 0) return null;
|
|
159
|
-
return imageCheck(name) ? url : null;
|
|
160
|
-
}).filter(Boolean);
|
|
161
|
-
};
|
|
162
|
-
exports.getValidFileImageUrls = getValidFileImageUrls;
|
|
163
|
-
const getFileIconUrl = (filename, direntType) => {
|
|
164
|
-
const defaultIcon = _file.FILEEXT_ICON_MAP['default'];
|
|
165
|
-
const defaultIconUrl = _file.FILEEXT_ICON_URL_MAP[defaultIcon];
|
|
166
|
-
if (typeof direntType === 'string' && direntType === 'dir') {
|
|
167
|
-
const folder = _file.FILEEXT_ICON_MAP['folder'];
|
|
168
|
-
return _file.FILEEXT_ICON_URL_MAP[folder]['192'];
|
|
169
|
-
}
|
|
170
|
-
const identifierIndex = typeof filename === 'string' && filename.lastIndexOf('.');
|
|
171
|
-
if (identifierIndex === -1) return defaultIconUrl['192'];
|
|
172
|
-
const fileExt = typeof filename === 'string' && filename.slice(identifierIndex + 1).toLowerCase() || 'default';
|
|
173
|
-
const fileIcon = _file.FILEEXT_ICON_MAP[fileExt];
|
|
174
|
-
if (fileIcon) {
|
|
175
|
-
const iconUrl = _file.FILEEXT_ICON_URL_MAP[fileIcon];
|
|
176
|
-
return iconUrl['192'];
|
|
177
|
-
}
|
|
178
|
-
return defaultIconUrl['192'];
|
|
179
|
-
};
|
|
180
|
-
exports.getFileIconUrl = getFileIconUrl;
|
|
181
|
-
const getFileThumbnailInfo = function (file) {
|
|
182
|
-
let {
|
|
183
|
-
server
|
|
184
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
185
|
-
const defaultIcon = _file.FILEEXT_ICON_MAP['default'];
|
|
186
|
-
const defaultIconUrl = _file.FILEEXT_ICON_URL_MAP[defaultIcon];
|
|
187
|
-
if (!file || !file.name) return {
|
|
188
|
-
isImage: false,
|
|
189
|
-
fileIconUrl: defaultIconUrl['192']
|
|
190
|
-
};
|
|
191
|
-
const isImage = imageCheck(file.name);
|
|
192
|
-
if (isImage) return {
|
|
193
|
-
isImage,
|
|
194
|
-
fileIconUrl: getImageThumbnailUrl(file.url, {
|
|
195
|
-
server
|
|
196
|
-
})
|
|
197
|
-
};
|
|
198
|
-
const iconUrl = getFileIconUrl(file.name, file.type);
|
|
199
|
-
return {
|
|
200
|
-
fileIconUrl: iconUrl,
|
|
201
|
-
isImage: false
|
|
202
|
-
};
|
|
89
|
+
return url.replace('/workspace', '/thumbnail/workspace') + '?size=' + size;
|
|
203
90
|
};
|
|
204
|
-
exports.
|
|
91
|
+
exports.getImageThumbnailUrl = getImageThumbnailUrl;
|
package/lib/utils/utils.js
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.isArrayFormatColumn = isArrayFormatColumn;
|
|
8
|
-
exports.throttle = exports.openUrlLink = exports.isValidUrl = exports.isValidCellValue = exports.isMobile = exports.isMac = exports.isFunction = void 0;
|
|
9
|
-
var _constants = require("../constants");
|
|
10
|
-
var _url = require("./url");
|
|
6
|
+
exports.throttle = exports.isMac = exports.getEventClassName = exports.downloadFile = exports.debounce = void 0;
|
|
11
7
|
const debounce = (fn, wait) => {
|
|
12
8
|
let timeout = null;
|
|
13
9
|
return function () {
|
|
@@ -34,7 +30,6 @@ const throttle = (func, delay) => {
|
|
|
34
30
|
};
|
|
35
31
|
};
|
|
36
32
|
exports.throttle = throttle;
|
|
37
|
-
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);
|
|
38
33
|
const isMac = () => {
|
|
39
34
|
const platform = navigator.platform;
|
|
40
35
|
// eslint-disable-next-line eqeqeq
|
|
@@ -53,147 +48,9 @@ const downloadFile = downloadUrl => {
|
|
|
53
48
|
document.body.appendChild(iframe);
|
|
54
49
|
};
|
|
55
50
|
exports.downloadFile = downloadFile;
|
|
56
|
-
const downloadFiles = (downloadUrlList, config) => {
|
|
57
|
-
const downloadFrame = document.getElementById('dtableUiComponentDownloadFrame');
|
|
58
|
-
if (downloadFrame != null) {
|
|
59
|
-
document.body.removeChild(downloadFrame);
|
|
60
|
-
}
|
|
61
|
-
downloadUrlList.forEach((url, index) => {
|
|
62
|
-
if (!(0, _url.isInternalURL)(url, config) && (0, _url.imageCheck)(url.replace('?dl=1', ''))) {
|
|
63
|
-
window.open(url);
|
|
64
|
-
} else {
|
|
65
|
-
const path = url;
|
|
66
|
-
let timer1 = setTimeout(function (path) {
|
|
67
|
-
return function () {
|
|
68
|
-
let iframe = document.createElement('iframe');
|
|
69
|
-
iframe.setAttribute('id', 'dtableUiComponentDownloadFrame');
|
|
70
|
-
iframe.style.display = 'none';
|
|
71
|
-
iframe.src = path;
|
|
72
|
-
document.body.appendChild(iframe);
|
|
73
|
-
let timer2 = setTimeout(function () {
|
|
74
|
-
iframe.remove();
|
|
75
|
-
clearTimeout(timer2);
|
|
76
|
-
}, 5000);
|
|
77
|
-
clearTimeout(timer1);
|
|
78
|
-
};
|
|
79
|
-
}(path), 1000 * index);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
exports.downloadFiles = downloadFiles;
|
|
84
51
|
const getEventClassName = e => {
|
|
85
52
|
// svg mouseEvent event.target.className is an object
|
|
86
53
|
if (!e || !e.target) return '';
|
|
87
54
|
return e.target.getAttribute('class') || '';
|
|
88
55
|
};
|
|
89
|
-
exports.getEventClassName = getEventClassName;
|
|
90
|
-
const getTrimmedString = value => {
|
|
91
|
-
return typeof value === 'string' ? value.trim() : '';
|
|
92
|
-
};
|
|
93
|
-
exports.getTrimmedString = getTrimmedString;
|
|
94
|
-
const isFunction = functionToCheck => {
|
|
95
|
-
const getType = {};
|
|
96
|
-
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
97
|
-
};
|
|
98
|
-
exports.isFunction = isFunction;
|
|
99
|
-
const isValidCellValue = value => {
|
|
100
|
-
if (value === undefined) return false;
|
|
101
|
-
if (value === null) return false;
|
|
102
|
-
if (value === '') return false;
|
|
103
|
-
if (JSON.stringify(value) === '{}') return false;
|
|
104
|
-
if (JSON.stringify(value) === '[]') return false;
|
|
105
|
-
return true;
|
|
106
|
-
};
|
|
107
|
-
exports.isValidCellValue = isValidCellValue;
|
|
108
|
-
const isValidUrl = url => {
|
|
109
|
-
const reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
|
|
110
|
-
return reg.test(url);
|
|
111
|
-
};
|
|
112
|
-
exports.isValidUrl = isValidUrl;
|
|
113
|
-
const openUrlLink = url => {
|
|
114
|
-
let a = document.createElement('a');
|
|
115
|
-
document.body.appendChild(a);
|
|
116
|
-
a.href = url;
|
|
117
|
-
a.target = '_blank';
|
|
118
|
-
a.rel = 'noopener noreferrer';
|
|
119
|
-
a.click();
|
|
120
|
-
document.body.removeChild(a);
|
|
121
|
-
};
|
|
122
|
-
exports.openUrlLink = openUrlLink;
|
|
123
|
-
const getErrorMsg = error => {
|
|
124
|
-
let errorMsg = '';
|
|
125
|
-
if (error.response) {
|
|
126
|
-
if (error.response.status === 403) {
|
|
127
|
-
errorMsg = 'Permission_denied';
|
|
128
|
-
} else if (error.response.data && error.response.data['error_msg']) {
|
|
129
|
-
errorMsg = error.response.data['error_msg'];
|
|
130
|
-
} else if (error.response.data && error.response.data['error_message']) {
|
|
131
|
-
errorMsg = error.response.data['error_message'];
|
|
132
|
-
} else {
|
|
133
|
-
errorMsg = 'Error';
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
if (typeof error === 'object' && error.name) {
|
|
137
|
-
errorMsg = error.name;
|
|
138
|
-
} else {
|
|
139
|
-
errorMsg = 'Please_check_the_network';
|
|
140
|
-
}
|
|
141
|
-
// eslint-disable-next-line
|
|
142
|
-
console.log(error);
|
|
143
|
-
}
|
|
144
|
-
return errorMsg;
|
|
145
|
-
};
|
|
146
|
-
exports.getErrorMsg = getErrorMsg;
|
|
147
|
-
function isArrayFormatColumn(columnType) {
|
|
148
|
-
return _constants.ARRAY_FORMAT_COLUMNS.includes(columnType);
|
|
149
|
-
}
|
|
150
|
-
const getFormulaArrayValue = function (value) {
|
|
151
|
-
let isFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
152
|
-
if (!Array.isArray(value)) return [];
|
|
153
|
-
if (!isFlat) return getTwoDimensionArrayValue(value);
|
|
154
|
-
return value.map(item => {
|
|
155
|
-
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
156
|
-
return item;
|
|
157
|
-
}
|
|
158
|
-
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
|
|
159
|
-
const {
|
|
160
|
-
display_value
|
|
161
|
-
} = item;
|
|
162
|
-
if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
|
|
163
|
-
return display_value.map(i => {
|
|
164
|
-
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
165
|
-
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
|
|
166
|
-
const {
|
|
167
|
-
display_value
|
|
168
|
-
} = i;
|
|
169
|
-
return display_value;
|
|
170
|
-
}
|
|
171
|
-
return i;
|
|
172
|
-
});
|
|
173
|
-
}).flat().filter(item => isValidCellValue(item));
|
|
174
|
-
};
|
|
175
|
-
exports.getFormulaArrayValue = getFormulaArrayValue;
|
|
176
|
-
const getTwoDimensionArrayValue = value => {
|
|
177
|
-
if (!Array.isArray(value)) return [];
|
|
178
|
-
return value.map(item => {
|
|
179
|
-
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
180
|
-
return item;
|
|
181
|
-
}
|
|
182
|
-
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
|
|
183
|
-
const {
|
|
184
|
-
display_value
|
|
185
|
-
} = item;
|
|
186
|
-
if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
|
|
187
|
-
return display_value.map(i => {
|
|
188
|
-
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
189
|
-
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
|
|
190
|
-
const {
|
|
191
|
-
display_value
|
|
192
|
-
} = i;
|
|
193
|
-
return display_value;
|
|
194
|
-
}
|
|
195
|
-
return i;
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
};
|
|
199
|
-
exports.getTwoDimensionArrayValue = getTwoDimensionArrayValue;
|
|
56
|
+
exports.getEventClassName = getEventClassName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
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.
|
|
12
|
+
"dtable-utils": "5.0.15",
|
|
13
13
|
"is-hotkey": "0.2.0",
|
|
14
14
|
"prop-types": "^15.8.1",
|
|
15
15
|
"react": "17.0.2",
|
|
@@ -17,7 +17,6 @@
|
|
|
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",
|
|
21
20
|
"react-transition-group": "^4.4.1",
|
|
22
21
|
"reactstrap": "8.9.0"
|
|
23
22
|
},
|
|
@@ -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;
|