dtable-ui-component 5.3.1-beta → 5.3.1
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/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 -244
- 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 +0 -26
- package/lib/RowExpandFormatter/index.js +100 -84
- 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 +5 -5
- package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/utils.js +1 -1
- 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 +14 -16
- 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 -119
- package/lib/utils/utils.js +2 -89
- package/package.json +2 -3
- package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +0 -257
- 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 -279
- package/lib/RowExpandDialog/column-content/index.css +0 -43
- package/lib/RowExpandDialog/column-content/index.js +0 -50
- package/lib/RowExpandDialog/constants.js +0 -114
- package/lib/RowExpandDialog/header/index.css +0 -31
- package/lib/RowExpandDialog/header/index.js +0 -33
- package/lib/RowExpandDialog/index.css +0 -24
- package/lib/RowExpandDialog/index.js +0 -268
- package/lib/RowExpandDialog/utils.js +0 -83
- 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 -124
- 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 -163
- package/lib/locales/en.json +0 -163
- package/lib/locales/es.json +0 -163
- package/lib/locales/fr.json +0 -163
- package/lib/locales/pt.json +0 -163
- package/lib/locales/ru.json +0 -163
- package/lib/locales/zh-CN.json +0 -163
- 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/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
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
.dtable-ui-file-editor-previewer {
|
|
2
|
-
position: relative;
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
align-items: center;
|
|
6
|
-
justify-content: space-between;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-wrapper {
|
|
10
|
-
height: 390px;
|
|
11
|
-
width: 100%;
|
|
12
|
-
overflow: hidden;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-add-btn {
|
|
16
|
-
width: 100%;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/* header */
|
|
20
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-header {
|
|
21
|
-
height: 40px;
|
|
22
|
-
margin: 0 3% 0 3%;
|
|
23
|
-
position: relative;
|
|
24
|
-
flex-direction: row;
|
|
25
|
-
justify-content: space-between;
|
|
26
|
-
font-size: 14px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-header .dtable-ui-file-editor-count-content {
|
|
30
|
-
font-weight: 450;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-header .dtable-ui-file-editor-operation-content {
|
|
34
|
-
color: #FF8000;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-header .dtable-ui-file-editor-operation-content:hover {
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* content */
|
|
42
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-content {
|
|
43
|
-
margin-top: 10px;
|
|
44
|
-
height: 336px;
|
|
45
|
-
overflow-y: auto;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.dtable-ui-file-editor-previewer .dtable-ui-file-editor-previewer-content::after {
|
|
49
|
-
content: '';
|
|
50
|
-
width: 94%;
|
|
51
|
-
height: 1px;
|
|
52
|
-
position: absolute;
|
|
53
|
-
left: 3%;
|
|
54
|
-
top: 40px;
|
|
55
|
-
background-color: #e9ecef;
|
|
56
|
-
}
|
|
@@ -1,277 +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 _url = require("../../utils/url");
|
|
10
|
-
var _utils = require("../../utils/utils");
|
|
11
|
-
var _constants = require("../../constants");
|
|
12
|
-
var _lang = require("../../lang");
|
|
13
|
-
var _ImagePreviewerLightbox = _interopRequireDefault(require("../../ImagePreviewerLightbox"));
|
|
14
|
-
var _DTableCommonAddTool = _interopRequireDefault(require("../../DTableCommonAddTool"));
|
|
15
|
-
var _filePreviewer = _interopRequireDefault(require("./file-previewer"));
|
|
16
|
-
require("./index.css");
|
|
17
|
-
class FilesPreviewer extends _react.default.Component {
|
|
18
|
-
constructor(props) {
|
|
19
|
-
super(props);
|
|
20
|
-
this.getFileItemImageUrlList = value => {
|
|
21
|
-
this.setState({
|
|
22
|
-
fileImageUrlList: (0, _url.getValidFileImageUrls)(value)
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
this.showLargeImage = itemUrl => {
|
|
26
|
-
let {
|
|
27
|
-
fileImageUrlList
|
|
28
|
-
} = this.state;
|
|
29
|
-
this.setState({
|
|
30
|
-
isShowLargeImage: true,
|
|
31
|
-
largeImageIndex: fileImageUrlList.indexOf(itemUrl)
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
this.moveNext = () => {
|
|
35
|
-
let {
|
|
36
|
-
fileImageUrlList
|
|
37
|
-
} = this.state;
|
|
38
|
-
this.setState(prevState => ({
|
|
39
|
-
largeImageIndex: (prevState.largeImageIndex + 1) % fileImageUrlList.length
|
|
40
|
-
}));
|
|
41
|
-
};
|
|
42
|
-
this.movePrev = () => {
|
|
43
|
-
let {
|
|
44
|
-
fileImageUrlList
|
|
45
|
-
} = this.state;
|
|
46
|
-
this.setState(prevState => ({
|
|
47
|
-
largeImageIndex: (prevState.largeImageIndex + fileImageUrlList.length - 1) % fileImageUrlList.length
|
|
48
|
-
}));
|
|
49
|
-
};
|
|
50
|
-
this.hideLargeImage = () => {
|
|
51
|
-
this.setState({
|
|
52
|
-
isShowLargeImage: false,
|
|
53
|
-
largeImageIndex: -1
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
this.downloadImage = imageItemUrl => {
|
|
57
|
-
const {
|
|
58
|
-
value
|
|
59
|
-
} = this.props;
|
|
60
|
-
const file = value.find(v => v.url === imageItemUrl);
|
|
61
|
-
if (!file) return;
|
|
62
|
-
this.props.getDownLoadFiles([file], _ref => {
|
|
63
|
-
let [dFile] = _ref;
|
|
64
|
-
dFile && (0, _utils.downloadFile)(dFile);
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
this.onRotateImage = (imageIndex, degree) => {
|
|
68
|
-
let {
|
|
69
|
-
fileImageUrlList
|
|
70
|
-
} = this.state;
|
|
71
|
-
const imageUrl = fileImageUrlList[imageIndex];
|
|
72
|
-
this.props.onRotateImage && this.props.onRotateImage(imageUrl, degree);
|
|
73
|
-
};
|
|
74
|
-
this.deleteImage = (index, type) => {
|
|
75
|
-
const {
|
|
76
|
-
value
|
|
77
|
-
} = this.props;
|
|
78
|
-
let {
|
|
79
|
-
fileImageUrlList
|
|
80
|
-
} = this.state;
|
|
81
|
-
const imageUrl = fileImageUrlList[index];
|
|
82
|
-
let fileItemIndex = value.findIndex(fileItem => fileItem.url === imageUrl);
|
|
83
|
-
this.props.deleteFile(fileItemIndex, type);
|
|
84
|
-
if (index > fileImageUrlList.length - 2) {
|
|
85
|
-
if (fileImageUrlList.length - 2 < 0) {
|
|
86
|
-
this.hideLargeImage();
|
|
87
|
-
} else {
|
|
88
|
-
this.setState({
|
|
89
|
-
largeImageIndex: 0
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
this.togglePreviewer = () => {
|
|
95
|
-
this.props.togglePreviewer(_constants.FILE_EDITOR_STATUS.ADDITION);
|
|
96
|
-
this.props.resetFileValue();
|
|
97
|
-
};
|
|
98
|
-
this.freezeItem = () => {
|
|
99
|
-
this.setState({
|
|
100
|
-
isItemFreezed: true
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
this.unFreezeItem = () => {
|
|
104
|
-
this.setState({
|
|
105
|
-
isItemFreezed: false
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
this.onSelectFiles = name => {
|
|
109
|
-
const {
|
|
110
|
-
selectedFilesList
|
|
111
|
-
} = this.state;
|
|
112
|
-
let filesList = selectedFilesList.slice(0);
|
|
113
|
-
const selectedFileIndex = selectedFilesList.indexOf(name);
|
|
114
|
-
if (selectedFileIndex > -1) {
|
|
115
|
-
filesList.splice(selectedFileIndex, 1);
|
|
116
|
-
} else {
|
|
117
|
-
filesList.push(name);
|
|
118
|
-
}
|
|
119
|
-
this.setState({
|
|
120
|
-
selectedFilesList: filesList
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
this.onSelectAllFiles = () => {
|
|
124
|
-
const {
|
|
125
|
-
value
|
|
126
|
-
} = this.props;
|
|
127
|
-
const {
|
|
128
|
-
selectedFilesList
|
|
129
|
-
} = this.state;
|
|
130
|
-
if (value.length === 0) return;
|
|
131
|
-
let allFilesList = selectedFilesList.slice(0);
|
|
132
|
-
value.map(item => {
|
|
133
|
-
if (selectedFilesList.indexOf(item.name) === -1) {
|
|
134
|
-
allFilesList.push(item.name);
|
|
135
|
-
}
|
|
136
|
-
return null;
|
|
137
|
-
});
|
|
138
|
-
this.setState({
|
|
139
|
-
selectedFilesList: allFilesList
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
this.onChangeSelectMultipleFiles = state => {
|
|
143
|
-
this.setState({
|
|
144
|
-
isSelectMultipleFiles: state,
|
|
145
|
-
selectedFilesList: []
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
this.onDownloadAllSelectedFiles = () => {
|
|
149
|
-
const {
|
|
150
|
-
config
|
|
151
|
-
} = this.props;
|
|
152
|
-
const {
|
|
153
|
-
selectedFilesList
|
|
154
|
-
} = this.state;
|
|
155
|
-
if (selectedFilesList.length === 0) return;
|
|
156
|
-
this.props.getDownLoadFiles(selectedFilesList, downloadFilesUrlList => {
|
|
157
|
-
if (downloadFilesUrlList.length > 0) {
|
|
158
|
-
(0, _utils.downloadFiles)(downloadFilesUrlList, config);
|
|
159
|
-
}
|
|
160
|
-
this.onChangeSelectMultipleFiles(false);
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
this.onDeleteAllSelectedFiles = () => {
|
|
164
|
-
const {
|
|
165
|
-
selectedFilesList
|
|
166
|
-
} = this.state;
|
|
167
|
-
this.props.deleteFiles(selectedFilesList);
|
|
168
|
-
this.onChangeSelectMultipleFiles(false);
|
|
169
|
-
};
|
|
170
|
-
this.renderFilesOperation = () => {
|
|
171
|
-
const {
|
|
172
|
-
value,
|
|
173
|
-
deleteFiles,
|
|
174
|
-
getDownLoadFiles
|
|
175
|
-
} = this.props;
|
|
176
|
-
const {
|
|
177
|
-
isSelectMultipleFiles,
|
|
178
|
-
selectedFilesList
|
|
179
|
-
} = this.state;
|
|
180
|
-
if (value.length === 0) return null;
|
|
181
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
182
|
-
className: "dtable-ui-file-editor-operation-content"
|
|
183
|
-
}, !isSelectMultipleFiles ? /*#__PURE__*/_react.default.createElement("span", {
|
|
184
|
-
onClick: this.onChangeSelectMultipleFiles.bind(this, true)
|
|
185
|
-
}, (0, _lang.getLocale)('Select')) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, selectedFilesList.length > 0 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, deleteFiles && /*#__PURE__*/_react.default.createElement("span", {
|
|
186
|
-
onClick: this.onDeleteAllSelectedFiles
|
|
187
|
-
}, (0, _lang.getLocale)('Delete')), getDownLoadFiles && /*#__PURE__*/_react.default.createElement("span", {
|
|
188
|
-
className: "ml-2",
|
|
189
|
-
onClick: this.onDownloadAllSelectedFiles
|
|
190
|
-
}, (0, _lang.getLocale)('Download'))), /*#__PURE__*/_react.default.createElement("span", {
|
|
191
|
-
className: "ml-2",
|
|
192
|
-
onClick: this.onSelectAllFiles
|
|
193
|
-
}, (0, _lang.getLocale)('Select_all')), /*#__PURE__*/_react.default.createElement("span", {
|
|
194
|
-
className: "ml-2",
|
|
195
|
-
onClick: this.onChangeSelectMultipleFiles.bind(this, false)
|
|
196
|
-
}, (0, _lang.getLocale)('Cancel'))));
|
|
197
|
-
};
|
|
198
|
-
this.state = {
|
|
199
|
-
isShowRename: false,
|
|
200
|
-
value: props.value,
|
|
201
|
-
isItemFreezed: false,
|
|
202
|
-
isShowLargeImage: false,
|
|
203
|
-
isSelectMultipleFiles: false,
|
|
204
|
-
fileImageUrlList: [],
|
|
205
|
-
selectedFilesList: [],
|
|
206
|
-
largeImageIndex: -1
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
componentDidMount() {
|
|
210
|
-
this.getFileItemImageUrlList(this.props.value);
|
|
211
|
-
}
|
|
212
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
213
|
-
if (JSON.stringify(this.props.value) !== JSON.stringify(nextProps.value)) {
|
|
214
|
-
this.getFileItemImageUrlList(nextProps.value);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
render() {
|
|
218
|
-
let {
|
|
219
|
-
value,
|
|
220
|
-
getDownLoadFiles
|
|
221
|
-
} = this.props;
|
|
222
|
-
const {
|
|
223
|
-
isSelectMultipleFiles,
|
|
224
|
-
selectedFilesList
|
|
225
|
-
} = this.state;
|
|
226
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
227
|
-
className: "dtable-ui-file-editor-previewer"
|
|
228
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
229
|
-
className: "dtable-ui-file-editor-previewer-wrapper"
|
|
230
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
231
|
-
className: "dtable-ui-file-editor-previewer-header d-flex align-items-center"
|
|
232
|
-
}, selectedFilesList.length > 0 ? /*#__PURE__*/_react.default.createElement("span", {
|
|
233
|
-
className: "dtable-ui-file-editor-count-content"
|
|
234
|
-
}, selectedFilesList.length === 1 ? (0, _lang.getLocale)('1_file_selected') : (0, _lang.getLocale)('Selected_xxx_files', {
|
|
235
|
-
count: selectedFilesList.length
|
|
236
|
-
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
237
|
-
className: "dtable-ui-file-editor-count-content"
|
|
238
|
-
}, value.length <= 1 ? (0, _lang.getLocale)('xxx_existing_file', {
|
|
239
|
-
count: value.length
|
|
240
|
-
}) : (0, _lang.getLocale)('xxx_existing_files', {
|
|
241
|
-
count: value.length
|
|
242
|
-
})), this.renderFilesOperation()), /*#__PURE__*/_react.default.createElement("div", {
|
|
243
|
-
className: "dtable-ui-file-editor-previewer-content"
|
|
244
|
-
}, value.length > 0 && value.map((fileItem, index) => {
|
|
245
|
-
const isSelected = selectedFilesList.indexOf(fileItem.name) === -1 ? false : true;
|
|
246
|
-
return /*#__PURE__*/_react.default.createElement(_filePreviewer.default, {
|
|
247
|
-
key: fileItem.url,
|
|
248
|
-
fileItem: fileItem,
|
|
249
|
-
deleteFile: this.props.deleteFile,
|
|
250
|
-
renameFile: this.props.renameFile,
|
|
251
|
-
freezeItem: this.freezeItem,
|
|
252
|
-
unFreezeItem: this.unFreezeItem,
|
|
253
|
-
isItemFreezed: this.state.isItemFreezed,
|
|
254
|
-
itemIndex: index,
|
|
255
|
-
isSelected: isSelected,
|
|
256
|
-
showLargeImage: this.showLargeImage,
|
|
257
|
-
onSelectFiles: this.onSelectFiles,
|
|
258
|
-
isSelectMultipleFiles: isSelectMultipleFiles,
|
|
259
|
-
downloadFile: getDownLoadFiles ? this.downloadImage : null
|
|
260
|
-
});
|
|
261
|
-
}))), this.state.isShowLargeImage && /*#__PURE__*/_react.default.createElement(_ImagePreviewerLightbox.default, {
|
|
262
|
-
imageItems: this.state.fileImageUrlList,
|
|
263
|
-
imageIndex: this.state.largeImageIndex,
|
|
264
|
-
closeImagePopup: this.hideLargeImage,
|
|
265
|
-
moveToPrevImage: this.movePrev,
|
|
266
|
-
moveToNextImage: this.moveNext,
|
|
267
|
-
deleteImage: this.deleteImage,
|
|
268
|
-
downloadImage: this.downloadImage,
|
|
269
|
-
onRotateImage: this.onRotateImage
|
|
270
|
-
}), /*#__PURE__*/_react.default.createElement(_DTableCommonAddTool.default, {
|
|
271
|
-
className: "dtable-ui-file-editor-previewer-add-btn",
|
|
272
|
-
callBack: this.togglePreviewer,
|
|
273
|
-
footerName: (0, _lang.getLocale)('Add_files')
|
|
274
|
-
}));
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
var _default = exports.default = FilesPreviewer;
|
package/lib/FileEditor/index.css
DELETED
package/lib/FileEditor/utils.js
DELETED
|
@@ -1,22 +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.getFileUploadTime = exports.bytesToSize = void 0;
|
|
8
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
const getFileUploadTime = file => {
|
|
10
|
-
return file.upload_time ? (0, _dayjs.default)(file.upload_time).format('YYYY-MM-DD HH:mm') : '';
|
|
11
|
-
};
|
|
12
|
-
exports.getFileUploadTime = getFileUploadTime;
|
|
13
|
-
const bytesToSize = bytes => {
|
|
14
|
-
if (typeof bytes == 'undefined') return ' ';
|
|
15
|
-
if (bytes < 0) return '--';
|
|
16
|
-
const sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
17
|
-
if (bytes === 0) return bytes + ' ' + sizes[0];
|
|
18
|
-
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1000)), 10);
|
|
19
|
-
if (i === 0) return bytes + ' ' + sizes[i];
|
|
20
|
-
return (bytes / 1000 ** i).toFixed(1) + ' ' + sizes[i];
|
|
21
|
-
};
|
|
22
|
-
exports.bytesToSize = bytesToSize;
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactstrap = require("reactstrap");
|
|
11
|
-
var _constants = require("../constants");
|
|
12
|
-
var _Loading = _interopRequireDefault(require("../Loading"));
|
|
13
|
-
var _lang = require("../lang");
|
|
14
|
-
class CountryEditor extends _react.Component {
|
|
15
|
-
constructor(props) {
|
|
16
|
-
super(props);
|
|
17
|
-
this.onHotKey = e => {
|
|
18
|
-
if (e.keyCode === _constants.KeyCodes.Enter) {
|
|
19
|
-
this.onEnter(e);
|
|
20
|
-
} else if (e.keyCode === _constants.KeyCodes.UpArrow) {
|
|
21
|
-
this.onUpArrow(e);
|
|
22
|
-
} else if (e.keyCode === _constants.KeyCodes.DownArrow) {
|
|
23
|
-
this.onDownArrow(e);
|
|
24
|
-
} else if (e.keyCode === _constants.KeyCodes.Tab) {
|
|
25
|
-
if (this.props.onPressTab) {
|
|
26
|
-
this.props.onPressTab(e);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
this.onDownArrow = e => {
|
|
31
|
-
e.preventDefault();
|
|
32
|
-
e.stopPropagation();
|
|
33
|
-
let {
|
|
34
|
-
highlightIndexes
|
|
35
|
-
} = this.state;
|
|
36
|
-
const continents = Object.keys(this.filteredCountry);
|
|
37
|
-
if (continents.length === 0) return;
|
|
38
|
-
const continent = continents[highlightIndexes[0]];
|
|
39
|
-
if (highlightIndexes[1] < this.filteredCountry[continent].length - 1) {
|
|
40
|
-
highlightIndexes[1] = highlightIndexes[1] + 1;
|
|
41
|
-
} else if (highlightIndexes[1] === this.filteredCountry[continent].length - 1 && highlightIndexes[0] < continents.length - 1) {
|
|
42
|
-
highlightIndexes[0] = highlightIndexes[0] + 1;
|
|
43
|
-
highlightIndexes[1] = 0;
|
|
44
|
-
}
|
|
45
|
-
this.setState({
|
|
46
|
-
highlightIndexes: [...highlightIndexes]
|
|
47
|
-
}, () => {
|
|
48
|
-
let itemCount = this.getItemCount(highlightIndexes[0], highlightIndexes[1]);
|
|
49
|
-
if (itemCount >= this.maxItemNum) {
|
|
50
|
-
this.selectContainer.scrollTop += this.itemHeight * (highlightIndexes[1] === 0 ? 2 : 1);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
this.onUpArrow = e => {
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
e.stopPropagation();
|
|
57
|
-
let {
|
|
58
|
-
highlightIndexes
|
|
59
|
-
} = this.state;
|
|
60
|
-
const continents = Object.keys(this.filteredCountry);
|
|
61
|
-
if (continents.length === 0) return;
|
|
62
|
-
if (highlightIndexes[1] === 0 && highlightIndexes[0] !== 0) {
|
|
63
|
-
highlightIndexes[0] = highlightIndexes[0] - 1;
|
|
64
|
-
highlightIndexes[1] = this.filteredCountry[continents[highlightIndexes[0]]].length - 1;
|
|
65
|
-
} else if (highlightIndexes[1] === 0 && highlightIndexes[0] === 0) {
|
|
66
|
-
highlightIndexes = [0, 0];
|
|
67
|
-
} else {
|
|
68
|
-
highlightIndexes[1] = highlightIndexes[1] - 1;
|
|
69
|
-
}
|
|
70
|
-
this.setState({
|
|
71
|
-
highlightIndexes: [...highlightIndexes]
|
|
72
|
-
}, () => {
|
|
73
|
-
let itemCount = this.getItemCount(highlightIndexes[0], highlightIndexes[1]);
|
|
74
|
-
if (itemCount < this.getItemCount(continents.length - 1, this.filteredCountry[continents[continents.length - 1]].length - 1) - this.maxItemNum) {
|
|
75
|
-
this.selectContainer.scrollTop -= this.itemHeight * (highlightIndexes[1] === 0 ? 2 : 1);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
this.getItemCount = (continentIndex, countryIndex) => {
|
|
80
|
-
const continents = Object.keys(this.filteredCountry);
|
|
81
|
-
let count = continentIndex + 1;
|
|
82
|
-
for (let index = 0; index < continentIndex; index++) {
|
|
83
|
-
count += this.filteredCountry[continents[index]].length;
|
|
84
|
-
}
|
|
85
|
-
count = count + countryIndex;
|
|
86
|
-
return count;
|
|
87
|
-
};
|
|
88
|
-
this.onEnter = e => {
|
|
89
|
-
e.stopPropagation();
|
|
90
|
-
const cuntries = Object.values(this.filteredCountry).flat();
|
|
91
|
-
if (cuntries && cuntries.length === 1) {
|
|
92
|
-
this.props.setValue({
|
|
93
|
-
country_region: cuntries[0]
|
|
94
|
-
});
|
|
95
|
-
this.props.onSubmit();
|
|
96
|
-
} else {
|
|
97
|
-
const {
|
|
98
|
-
highlightIndexes
|
|
99
|
-
} = this.state;
|
|
100
|
-
const continents = Object.keys(this.filteredCountry);
|
|
101
|
-
if (continents.length > 0) {
|
|
102
|
-
const continent = continents[highlightIndexes[0]];
|
|
103
|
-
const country = this.filteredCountry[continent][highlightIndexes[1]];
|
|
104
|
-
if (!country) return;
|
|
105
|
-
this.props.setValue({
|
|
106
|
-
country_region: country
|
|
107
|
-
});
|
|
108
|
-
this.props.onSubmit();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
this.onMenuMouseEnter = (continentIndex, countryIndex) => {
|
|
113
|
-
this.setState({
|
|
114
|
-
highlightIndexes: [continentIndex, countryIndex]
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
this.onMenuMouseLeave = (continentIndex, countryIndex) => {
|
|
118
|
-
this.timer = setTimeout(() => {
|
|
119
|
-
const {
|
|
120
|
-
highlightIndexes
|
|
121
|
-
} = this.state;
|
|
122
|
-
if (highlightIndexes[0] === continentIndex && highlightIndexes[1] === countryIndex) {
|
|
123
|
-
this.setState({
|
|
124
|
-
highlightIndexes: [0, -1]
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}, 300);
|
|
128
|
-
};
|
|
129
|
-
this.getLocationData = () => {
|
|
130
|
-
const {
|
|
131
|
-
config
|
|
132
|
-
} = this.props;
|
|
133
|
-
const {
|
|
134
|
-
mediaUrl
|
|
135
|
-
} = {
|
|
136
|
-
...window.dtable,
|
|
137
|
-
...config
|
|
138
|
-
};
|
|
139
|
-
let geoFileName = 'en-region-location';
|
|
140
|
-
if (this.lang === 'cn') {
|
|
141
|
-
geoFileName = 'cn-region-location';
|
|
142
|
-
}
|
|
143
|
-
return fetch("".concat(mediaUrl, "geo-data/").concat(geoFileName, ".json")).then(res => {
|
|
144
|
-
return res.json();
|
|
145
|
-
}).catch(() => {
|
|
146
|
-
// get locations from local
|
|
147
|
-
return fetch("./geo-data/".concat(geoFileName, ".json")).then(res => {
|
|
148
|
-
return res.json();
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
this.createContinentList = () => {
|
|
153
|
-
let isSearchResultEmpty = true;
|
|
154
|
-
const continents = Object.keys(this.filteredCountry);
|
|
155
|
-
const continentsList = continents.map((continent, index) => {
|
|
156
|
-
const countryList = this.createCountryList(continent, index);
|
|
157
|
-
if (countryList.length > 0) {
|
|
158
|
-
isSearchResultEmpty = false;
|
|
159
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
160
|
-
key: continent
|
|
161
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
162
|
-
className: "geolocation-region-editor-continent"
|
|
163
|
-
}, continent), countryList);
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
});
|
|
167
|
-
if (isSearchResultEmpty) {
|
|
168
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
169
|
-
className: "country-list-empty"
|
|
170
|
-
}, (0, _lang.getLocale)('No_options'));
|
|
171
|
-
}
|
|
172
|
-
return continentsList;
|
|
173
|
-
};
|
|
174
|
-
this.createCountryList = (continent, continentIndex) => {
|
|
175
|
-
const {
|
|
176
|
-
value,
|
|
177
|
-
highlightIndexes
|
|
178
|
-
} = this.state;
|
|
179
|
-
let countryList = this.filteredCountry[continent].map((country, index) => {
|
|
180
|
-
const isHighlight = highlightIndexes[0] === continentIndex && highlightIndexes[1] === index;
|
|
181
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
182
|
-
className: "geolocation-region-editor-country ".concat(isHighlight ? 'geolocation-region-editor-province-highlight' : ''),
|
|
183
|
-
key: country,
|
|
184
|
-
onMouseEnter: () => this.onMenuMouseEnter(continentIndex, index),
|
|
185
|
-
onMouseLeave: () => this.onMenuMouseLeave(continentIndex, index),
|
|
186
|
-
title: country,
|
|
187
|
-
"aria-label": country,
|
|
188
|
-
onClick: () => this.onClick(country)
|
|
189
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
190
|
-
className: "icon ".concat(value === country ? 'dtable-font dtable-icon-check-mark' : '')
|
|
191
|
-
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
192
|
-
className: "country-name"
|
|
193
|
-
}, country));
|
|
194
|
-
});
|
|
195
|
-
return countryList;
|
|
196
|
-
};
|
|
197
|
-
this.onClick = country => {
|
|
198
|
-
this.props.setValue({
|
|
199
|
-
country_region: country
|
|
200
|
-
});
|
|
201
|
-
this.props.onSubmit();
|
|
202
|
-
};
|
|
203
|
-
this.onChange = e => {
|
|
204
|
-
const value = e.target.value.trim();
|
|
205
|
-
if (value.length === 0) {
|
|
206
|
-
this.countryReg = null;
|
|
207
|
-
}
|
|
208
|
-
if (value.length > 0) {
|
|
209
|
-
let regStr = '(.*)' + value.split('').join('(.*)') + '(.*)';
|
|
210
|
-
this.countryReg = new RegExp(regStr, 'i');
|
|
211
|
-
}
|
|
212
|
-
this.filteredCountry = this.filterCountry();
|
|
213
|
-
this.setState({
|
|
214
|
-
searchingCountry: e.target.value,
|
|
215
|
-
highlightIndexes: Object.keys(this.filteredCountry).length > 0 ? [0, 0] : [0, -1]
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
this.filterCountry = () => {
|
|
219
|
-
const continents = Object.keys(this.geolocationRegions);
|
|
220
|
-
const map = {};
|
|
221
|
-
for (let i = 0; i < continents.length; i++) {
|
|
222
|
-
const countries = this.geolocationRegions[continents[i]];
|
|
223
|
-
const continent = continents[i];
|
|
224
|
-
map[continent] = [];
|
|
225
|
-
countries.forEach(item => {
|
|
226
|
-
if (this.countryReg && this.countryReg.test(item)) {
|
|
227
|
-
map[continent].push(item);
|
|
228
|
-
} else if (!this.countryReg) {
|
|
229
|
-
map[continent].push(item);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
if (map[continent].length === 0) {
|
|
233
|
-
delete map[continent];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return map;
|
|
237
|
-
};
|
|
238
|
-
this.onKeyDown = e => {
|
|
239
|
-
if (e.keyCode === _constants.KeyCodes.ChineseInputMethod || e.keyCode === _constants.KeyCodes.Enter || e.keyCode === _constants.KeyCodes.LeftArrow || e.keyCode === _constants.KeyCodes.RightArrow) {
|
|
240
|
-
e.stopPropagation();
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
this.countryReg = null;
|
|
244
|
-
const {
|
|
245
|
-
column,
|
|
246
|
-
value: _value
|
|
247
|
-
} = props;
|
|
248
|
-
const columnData = column.data || {};
|
|
249
|
-
this.lang = columnData.lang === 'cn' ? 'cn' : 'en';
|
|
250
|
-
this.state = {
|
|
251
|
-
searchingCountry: '',
|
|
252
|
-
value: _value.country_region,
|
|
253
|
-
isLoadingData: true,
|
|
254
|
-
highlightIndexes: [0, -1]
|
|
255
|
-
};
|
|
256
|
-
this.filteredCountry = [];
|
|
257
|
-
this.timer = null;
|
|
258
|
-
this.maxItemNum = 6;
|
|
259
|
-
this.itemHeight = 30;
|
|
260
|
-
}
|
|
261
|
-
componentDidMount() {
|
|
262
|
-
document.addEventListener('keydown', this.onHotKey, true);
|
|
263
|
-
if (this.lang === 'cn' && window.app.countryListCn) {
|
|
264
|
-
this.geolocationRegions = window.app.countryListCn;
|
|
265
|
-
this.filteredCountry = this.geolocationRegions;
|
|
266
|
-
this.setState({
|
|
267
|
-
isLoadingData: false
|
|
268
|
-
});
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (this.lang !== 'cn' && window.app.countryListEn) {
|
|
272
|
-
this.geolocationRegions = window.app.countryListEn;
|
|
273
|
-
this.filteredCountry = this.geolocationRegions;
|
|
274
|
-
this.setState({
|
|
275
|
-
isLoadingData: false
|
|
276
|
-
});
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
this.getLocationData().then(data => {
|
|
280
|
-
this.geolocationRegions = data || {};
|
|
281
|
-
this.filteredCountry = this.geolocationRegions;
|
|
282
|
-
if (this.lang === 'cn') {
|
|
283
|
-
window.app.countryListCn = this.geolocationRegions;
|
|
284
|
-
} else {
|
|
285
|
-
window.app.countryListEn = this.geolocationRegions;
|
|
286
|
-
}
|
|
287
|
-
this.setState({
|
|
288
|
-
isLoadingData: false
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
componentWillUnmount() {
|
|
293
|
-
document.removeEventListener('keydown', this.onHotKey, true);
|
|
294
|
-
if (this.timer) {
|
|
295
|
-
clearTimeout(this.timer);
|
|
296
|
-
this.timer = null;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
render() {
|
|
300
|
-
const {
|
|
301
|
-
isLoadingData
|
|
302
|
-
} = this.state;
|
|
303
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
304
|
-
className: "dtable-ui-geolocation-country-editor"
|
|
305
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
306
|
-
className: "geolocation-region-list-header"
|
|
307
|
-
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
|
|
308
|
-
value: this.state.searchingCountry,
|
|
309
|
-
onChange: this.onChange,
|
|
310
|
-
autoFocus: true,
|
|
311
|
-
onKeyDown: this.onKeyDown,
|
|
312
|
-
placeholder: (0, _lang.getLocale)('Search_country')
|
|
313
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
314
|
-
className: "geolocation-region-list-container",
|
|
315
|
-
ref: ref => this.selectContainer = ref
|
|
316
|
-
}, isLoadingData ? /*#__PURE__*/_react.default.createElement(_Loading.default, null) : this.createContinentList()));
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
var _default = exports.default = CountryEditor;
|