dtable-ui-component 5.3.6 → 5.3.8
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/ButtonFormatter/index.js +8 -2
- package/lib/CheckboxEditor/index.css +8 -20
- package/lib/CheckboxEditor/index.js +98 -35
- package/lib/CheckboxFormatter/index.css +5 -0
- package/lib/CheckboxFormatter/index.js +9 -15
- package/lib/CollaboratorEditor/index.css +12 -35
- package/lib/CollaboratorEditor/index.js +18 -212
- package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +27 -30
- package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
- package/lib/CollaboratorItem/index.css +7 -1
- package/lib/CollaboratorItem/index.js +6 -2
- package/lib/Comment/body/comment.js +190 -0
- package/lib/Comment/body/index.css +95 -0
- package/lib/Comment/body/index.js +32 -0
- package/lib/Comment/footer/btns/index.css +40 -0
- package/lib/Comment/footer/btns/index.js +113 -0
- package/lib/Comment/footer/index.css +157 -0
- package/lib/Comment/footer/index.js +169 -0
- package/lib/Comment/footer/input/index.css +52 -0
- package/lib/Comment/footer/input/index.js +448 -0
- package/lib/Comment/footer/input/participant/index.css +0 -0
- package/lib/Comment/footer/input/participant/index.js +53 -0
- package/lib/Comment/footer/participants/index.css +22 -0
- package/lib/Comment/footer/participants/index.js +68 -0
- package/lib/Comment/footer/participants/participant/index.css +5 -0
- package/lib/Comment/footer/participants/participant/index.js +32 -0
- package/lib/Comment/footer/participants/participant-select/index.css +104 -0
- package/lib/Comment/footer/participants/participant-select/index.js +182 -0
- package/lib/Comment/index.css +19 -0
- package/lib/Comment/index.js +304 -0
- package/lib/Comment/model.js +25 -0
- package/lib/Comment/utils/common.js +62 -0
- package/lib/Comment/utils/index.js +27 -0
- package/lib/Comment/utils/utilities.js +176 -0
- package/lib/DTableCustomizeSelect/index.js +2 -2
- package/lib/DTableFiltersPopover/utils/index.js +1 -7
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
- package/lib/DTableGroupSelect/index.js +3 -3
- package/lib/DTableSelect/index.js +3 -1
- package/lib/DateEditor/index.js +14 -51
- package/lib/DateEditor/pc-date-editor-popover.js +149 -12
- package/lib/{common/delete-tip.js → DeleteTip/index.js} +12 -16
- package/lib/Department-editor/department-single-select.js +1 -1
- package/lib/Department-editor/index.js +3 -4
- package/lib/DepartmentSingleSelectFormatter/index.js +3 -2
- package/lib/DigitalSignEditor/constants.js +7 -0
- package/lib/DigitalSignEditor/index.css +69 -0
- package/lib/DigitalSignEditor/index.js +182 -0
- package/lib/DigitalSignEditor/service.js +39 -0
- package/lib/DigitalSignEditor/signature-board/index.css +35 -0
- package/lib/DigitalSignEditor/signature-board/index.js +135 -0
- package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
- package/lib/DigitalSignEditor/utils.js +29 -0
- package/lib/DurationEditor/index.js +110 -0
- package/lib/EmailEditor/index.js +58 -0
- package/lib/FileEditor/addition-previewer/index.css +1 -0
- package/lib/FileEditor/addition-previewer/index.js +52 -0
- package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
- package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
- package/lib/FileEditor/constants.js +7 -0
- package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
- package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
- package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
- package/lib/FileEditor/files-previewer/index.css +56 -0
- package/lib/FileEditor/files-previewer/index.js +277 -0
- package/lib/FileEditor/index.css +6 -0
- package/lib/FileEditor/index.js +258 -11
- package/lib/FileEditor/utils.js +22 -0
- package/lib/FileItemFormatter/index.js +19 -20
- package/lib/FileUploader/index.css +9 -0
- package/lib/FileUploader/index.js +268 -14
- package/lib/FormulaFormatter/cell-value-validator.js +17 -17
- package/lib/FormulaFormatter/index.js +2 -1
- package/lib/FormulaFormatter/utils.js +0 -31
- package/lib/GeolocationEditor/country-editor.js +319 -0
- package/lib/GeolocationEditor/index.css +641 -0
- package/lib/GeolocationEditor/index.js +240 -0
- package/lib/GeolocationEditor/location-editor.js +368 -0
- package/lib/GeolocationEditor/map-editor/index.js +456 -0
- package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
- package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
- package/lib/GeolocationEditor/map-editor-utils.js +153 -0
- package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
- package/lib/GeolocationEditor/parse-geolocation.js +282 -0
- package/lib/GeolocationEditor/province-city-editor.js +292 -0
- package/lib/GeolocationEditor/province-editor.js +226 -0
- package/lib/GeolocationEditor/selector-header-item.js +28 -0
- package/lib/GeolocationEditor/selector-list.js +33 -0
- package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
- package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
- package/lib/ImageEditor/addition-previewer/index.css +106 -0
- package/lib/ImageEditor/addition-previewer/index.js +63 -0
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
- package/lib/ImageEditor/constants.js +7 -0
- package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
- package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
- package/lib/ImageEditor/images-previewer/index.css +18 -0
- package/lib/ImageEditor/images-previewer/index.js +140 -0
- package/lib/ImageEditor/index.css +24 -0
- package/lib/ImageEditor/index.js +194 -0
- package/lib/ImageThumbnail/index.css +20 -0
- package/lib/ImageThumbnail/index.js +136 -0
- package/lib/LinkEditor/index.js +2 -3
- package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
- package/lib/MultipleSelectEditor/index.js +16 -177
- package/lib/NumberEditor/index.js +63 -77
- package/lib/RowExpandDialog/body/index.css +21 -0
- package/lib/RowExpandDialog/body/index.js +262 -0
- package/lib/RowExpandDialog/column-content/index.css +48 -0
- package/lib/RowExpandDialog/column-content/index.js +50 -0
- package/lib/RowExpandDialog/header/index.css +31 -0
- package/lib/RowExpandDialog/header/index.js +55 -0
- package/lib/RowExpandDialog/index.css +28 -0
- package/lib/RowExpandDialog/index.js +237 -0
- package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
- package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
- package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
- package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +106 -0
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
- package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
- package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
- package/lib/RowExpandEditor/RowExpandFileEditor/index.js +147 -0
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
- package/lib/RowExpandEditor/RowExpandImageEditor/index.css +6 -0
- package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +123 -0
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +224 -0
- package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
- package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
- package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +193 -0
- package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
- package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
- package/lib/RowExpandEditor/constants.js +44 -0
- package/lib/RowExpandEditor/index.css +0 -0
- package/lib/RowExpandEditor/index.js +32 -0
- package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
- package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
- package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +12 -13
- package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +5 -5
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +2 -2
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +20 -20
- package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
- package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
- package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
- package/lib/RowExpandFormatter/constants.js +61 -0
- package/lib/RowExpandFormatter/index.css +28 -3
- package/lib/RowExpandFormatter/index.js +113 -131
- package/lib/SingleSelectEditor/index.js +16 -156
- package/lib/SvgIcon/index.css +11 -0
- package/lib/SvgIcon/index.js +29 -0
- package/lib/TextEditor/index.js +112 -42
- package/lib/UploadProgress/index.js +38 -0
- package/lib/UrlEditor/index.js +61 -0
- package/lib/common/editor-base.js +52 -0
- package/lib/constants/file.js +96 -0
- package/lib/constants/index.js +27 -15
- package/lib/constants/key-codes.js +109 -0
- package/lib/css/cell-editor.css +18 -2
- package/lib/formatterConfig/base-formatter-config.js +23 -23
- package/lib/formatterConfig/index.js +3 -3
- package/lib/hooks/index.js +16 -0
- package/lib/index.js +81 -46
- package/lib/lang/index.js +19 -16
- package/lib/locales/de.json +167 -0
- package/lib/locales/en.json +167 -0
- package/lib/locales/es.json +167 -0
- package/lib/locales/fr.json +167 -0
- package/lib/locales/pt.json +167 -0
- package/lib/locales/ru.json +167 -0
- package/lib/locales/zh-CN.json +167 -0
- package/lib/select-editor/index.js +6 -6
- package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
- package/lib/select-editor/pc-select-editor/index.css +85 -0
- package/lib/select-editor/pc-select-editor/index.js +290 -0
- package/lib/utils/cell-comparer.js +35 -0
- package/lib/utils/cell.js +55 -0
- package/lib/utils/column-utils.js +25 -0
- package/lib/utils/editor-utils.js +1 -6
- package/lib/utils/get-event-transfer.js +75 -0
- package/lib/utils/hotkey.js +37 -0
- package/lib/utils/object-utils.js +61 -0
- package/lib/utils/url.js +121 -8
- package/lib/utils/utils.js +119 -2
- package/package.json +3 -2
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
- package/lib/FileEditor/pc-files-addition/index.js +0 -1
- package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
- package/lib/FileEditor/pc-files-preview/index.js +0 -1
- package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
- 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/utils.js +0 -99
- package/lib/MultipleSelectEditor/index.css +0 -9
- package/lib/RowExpandLinkFormatter/utils.js +0 -71
- package/lib/RowExpandUrlFormatter/index.css +0 -1
- package/lib/SingleSelectEditor/index.css +0 -14
- package/lib/common/modal-portal.js +0 -26
- package/lib/locals/de.js +0 -103
- package/lib/locals/en.js +0 -104
- package/lib/locals/es.js +0 -103
- package/lib/locals/fr.js +0 -103
- package/lib/locals/pt.js +0 -103
- package/lib/locals/ru.js +0 -103
- package/lib/locals/zh-CN.js +0 -104
- package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
- package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
- /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
- /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
- /package/lib/{common/delete-tip.css → DeleteTip/index.css} +0 -0
- /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
- /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
- /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const MUNICIPALITY = ['北京市', '天津市', '上海市', '重庆市', '香港', '澳门'];
|
|
8
|
+
let initProvince = null;
|
|
9
|
+
let initCity = null;
|
|
10
|
+
function getProvince(string, geoTree) {
|
|
11
|
+
if (string.length === 0) {
|
|
12
|
+
return {
|
|
13
|
+
province: '',
|
|
14
|
+
city: '',
|
|
15
|
+
district: '',
|
|
16
|
+
detail: ''
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
let startPoint = 0;
|
|
20
|
+
let endPoint = 2;
|
|
21
|
+
let subProvince = string.substring(startPoint, endPoint);
|
|
22
|
+
let province;
|
|
23
|
+
while (subProvince.length === 2) {
|
|
24
|
+
// eslint-disable-next-line no-loop-func
|
|
25
|
+
const selectedProvince = geoTree.children.find(provinceItem => {
|
|
26
|
+
if (provinceItem.name.indexOf(subProvince) === 0) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
});
|
|
31
|
+
if (selectedProvince) {
|
|
32
|
+
province = selectedProvince;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
startPoint++;
|
|
36
|
+
endPoint++;
|
|
37
|
+
subProvince = string.substring(startPoint, endPoint);
|
|
38
|
+
}
|
|
39
|
+
if (province) {
|
|
40
|
+
const name = province.name;
|
|
41
|
+
while (name.includes(string.substring(startPoint, endPoint)) && endPoint <= string.length) {
|
|
42
|
+
endPoint++;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
province,
|
|
46
|
+
string: string.substring(endPoint - 1)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
province,
|
|
51
|
+
string: string.substring(0)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function getCity(province, string, geoTree) {
|
|
55
|
+
let city;
|
|
56
|
+
let startPoint = 0;
|
|
57
|
+
let endPoint = 2;
|
|
58
|
+
if (string.length === 0) {
|
|
59
|
+
return {
|
|
60
|
+
province,
|
|
61
|
+
city: '',
|
|
62
|
+
district: '',
|
|
63
|
+
detail: ''
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
let subCity = string.substring(startPoint, endPoint);
|
|
67
|
+
if (province) {
|
|
68
|
+
if (MUNICIPALITY.includes(province.name)) {
|
|
69
|
+
city = province.children[0];
|
|
70
|
+
const name = city.name;
|
|
71
|
+
if (!name.includes(subCity)) {
|
|
72
|
+
return {
|
|
73
|
+
province,
|
|
74
|
+
city,
|
|
75
|
+
string: string.substring(startPoint)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
while (name.includes(string.substring(startPoint, endPoint)) && endPoint <= string.length) {
|
|
79
|
+
endPoint++;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
province,
|
|
83
|
+
city,
|
|
84
|
+
string: string.substring(endPoint - 1)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
while (subCity.length === 2) {
|
|
88
|
+
// eslint-disable-next-line no-loop-func
|
|
89
|
+
let selectedCity = province.children.find(cityItem => {
|
|
90
|
+
if (cityItem.name.indexOf(subCity) === 0) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
});
|
|
95
|
+
if (selectedCity) {
|
|
96
|
+
city = selectedCity;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
startPoint++;
|
|
100
|
+
endPoint++;
|
|
101
|
+
subCity = string.substring(startPoint, endPoint);
|
|
102
|
+
}
|
|
103
|
+
if (city) {
|
|
104
|
+
while (city.name.includes(string.substring(startPoint, endPoint)) && endPoint <= string.length) {
|
|
105
|
+
endPoint++;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
province,
|
|
109
|
+
city,
|
|
110
|
+
string: string.substring(endPoint - 1)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
province,
|
|
115
|
+
city,
|
|
116
|
+
string
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (!province) {
|
|
120
|
+
let city;
|
|
121
|
+
let newProvince;
|
|
122
|
+
while (subCity.length === 2) {
|
|
123
|
+
// eslint-disable-next-line no-loop-func
|
|
124
|
+
geoTree.children.find(provinceItem => {
|
|
125
|
+
let selectedCity = provinceItem.children.find(city => {
|
|
126
|
+
if (city.name.indexOf(subCity) === 0) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
});
|
|
131
|
+
if (selectedCity) {
|
|
132
|
+
city = selectedCity;
|
|
133
|
+
newProvince = provinceItem;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
});
|
|
138
|
+
if (city) {
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
startPoint++;
|
|
142
|
+
endPoint++;
|
|
143
|
+
subCity = string.substring(startPoint, endPoint);
|
|
144
|
+
}
|
|
145
|
+
if (city) {
|
|
146
|
+
const name = city.name;
|
|
147
|
+
while (name.includes(string.substring(startPoint, endPoint)) && endPoint <= string.length) {
|
|
148
|
+
endPoint++;
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
province: newProvince,
|
|
152
|
+
city,
|
|
153
|
+
string: string.substring(endPoint - 1)
|
|
154
|
+
};
|
|
155
|
+
} else {
|
|
156
|
+
return {
|
|
157
|
+
province,
|
|
158
|
+
city,
|
|
159
|
+
string
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const getDistrict = (province, city, string, geoTree) => {
|
|
165
|
+
if (!string) {
|
|
166
|
+
return {
|
|
167
|
+
province,
|
|
168
|
+
city,
|
|
169
|
+
district: '',
|
|
170
|
+
detail: ''
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
let startPoint = 0;
|
|
174
|
+
let endPoint = 2;
|
|
175
|
+
let subDistrict = string.substring(startPoint, endPoint);
|
|
176
|
+
let district;
|
|
177
|
+
if (province) {
|
|
178
|
+
if (city) {
|
|
179
|
+
while (subDistrict.length === 2) {
|
|
180
|
+
// eslint-disable-next-line no-loop-func
|
|
181
|
+
let selectedDistrict = city.children.find(item => {
|
|
182
|
+
if (item.name.indexOf(subDistrict) === 0) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
});
|
|
187
|
+
if (selectedDistrict) {
|
|
188
|
+
district = selectedDistrict;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
startPoint++;
|
|
192
|
+
endPoint++;
|
|
193
|
+
subDistrict = string.substring(startPoint, endPoint);
|
|
194
|
+
}
|
|
195
|
+
if (district) {
|
|
196
|
+
const name = district.name;
|
|
197
|
+
while (name.includes(string.substring(startPoint, endPoint)) && endPoint <= string.length) {
|
|
198
|
+
endPoint++;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
province,
|
|
202
|
+
city,
|
|
203
|
+
district,
|
|
204
|
+
string: string.substring(endPoint - 1)
|
|
205
|
+
};
|
|
206
|
+
} else {
|
|
207
|
+
return {
|
|
208
|
+
province: initProvince,
|
|
209
|
+
city: initCity,
|
|
210
|
+
district,
|
|
211
|
+
string: string.substring(0)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
let result = {
|
|
216
|
+
province,
|
|
217
|
+
city,
|
|
218
|
+
district: ''
|
|
219
|
+
};
|
|
220
|
+
for (let index = 0; index < province.children.length; index++) {
|
|
221
|
+
const city = province.children[index];
|
|
222
|
+
result = getDistrict(province, city, string, geoTree);
|
|
223
|
+
if (result.district) {
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
let result = {
|
|
231
|
+
province,
|
|
232
|
+
city
|
|
233
|
+
};
|
|
234
|
+
const provinces = geoTree.children;
|
|
235
|
+
for (let provinceIndex = 0; provinceIndex < provinces.length; provinceIndex++) {
|
|
236
|
+
const province = provinces[provinceIndex];
|
|
237
|
+
const cities = province.children;
|
|
238
|
+
for (let cityIndex = 0; cityIndex < cities.length; cityIndex++) {
|
|
239
|
+
result = getDistrict(province, cities[cityIndex], string, geoTree);
|
|
240
|
+
if (result.district) {
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (result.district) {
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const parseGeolocationString = (geoTree, geoString) => {
|
|
252
|
+
if (geoString === null || geoString.length < 2) {
|
|
253
|
+
return {
|
|
254
|
+
province: {},
|
|
255
|
+
city: {},
|
|
256
|
+
district: {},
|
|
257
|
+
detail: geoString
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
let string = geoString;
|
|
261
|
+
let provinceResult = getProvince(string, geoTree);
|
|
262
|
+
let province = provinceResult.province;
|
|
263
|
+
string = provinceResult.string;
|
|
264
|
+
const cityResult = getCity(province, string, geoTree);
|
|
265
|
+
province = cityResult.province;
|
|
266
|
+
let city = cityResult.city;
|
|
267
|
+
string = cityResult.string;
|
|
268
|
+
initProvince = province;
|
|
269
|
+
initCity = city;
|
|
270
|
+
let districtResult = getDistrict(province, city, string, geoTree);
|
|
271
|
+
let district = districtResult.district;
|
|
272
|
+
province = districtResult.province;
|
|
273
|
+
city = districtResult.city;
|
|
274
|
+
string = districtResult.string;
|
|
275
|
+
return {
|
|
276
|
+
province,
|
|
277
|
+
city,
|
|
278
|
+
district,
|
|
279
|
+
detail: string
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
var _default = exports.default = parseGeolocationString;
|
|
@@ -0,0 +1,292 @@
|
|
|
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 _selectorList = _interopRequireDefault(require("./selector-list"));
|
|
12
|
+
var _selectorHeaderItem = _interopRequireDefault(require("./selector-header-item"));
|
|
13
|
+
var _Loading = _interopRequireDefault(require("../Loading"));
|
|
14
|
+
var _parseGeolocation = _interopRequireDefault(require("./parse-geolocation"));
|
|
15
|
+
var _constants = require("../constants");
|
|
16
|
+
var _lang = require("../lang");
|
|
17
|
+
class ProvinceCityEditor extends _react.Component {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
this.getLocationText = function () {
|
|
21
|
+
let province = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
22
|
+
let city = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
23
|
+
return province + city;
|
|
24
|
+
};
|
|
25
|
+
this.initLocationSelecting = value => {
|
|
26
|
+
let selectedProvince = this.locations.children.find(province => {
|
|
27
|
+
return value.province && value.province.length > 0 && province.name.includes(value.province);
|
|
28
|
+
});
|
|
29
|
+
if (!selectedProvince) {
|
|
30
|
+
return {
|
|
31
|
+
selectedProvince: null,
|
|
32
|
+
selectedCity: null,
|
|
33
|
+
selectedItem: 'province'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
let selectedCity = selectedProvince.children.find(city => {
|
|
37
|
+
return value.city && value.city.length > 0 && city.name.includes(value.city);
|
|
38
|
+
});
|
|
39
|
+
if (!selectedCity) {
|
|
40
|
+
return {
|
|
41
|
+
selectedProvince,
|
|
42
|
+
selectedCity: null,
|
|
43
|
+
selectedItem: 'city'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
selectedProvince,
|
|
48
|
+
selectedCity,
|
|
49
|
+
selectedItem: 'city'
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
this.getLocationData = () => {
|
|
53
|
+
const {
|
|
54
|
+
mediaUrl
|
|
55
|
+
} = window.dtable;
|
|
56
|
+
|
|
57
|
+
// get locations from server
|
|
58
|
+
return fetch("".concat(mediaUrl, "geo-data/cn-location.json")).then(res => {
|
|
59
|
+
return res.json();
|
|
60
|
+
}).catch(() => {
|
|
61
|
+
// get locations from local
|
|
62
|
+
return fetch('./geo-data/cn-location.json').then(res => {
|
|
63
|
+
return res.json();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
this.onToggleSelector = () => {
|
|
68
|
+
this.setState({
|
|
69
|
+
isShowSelector: !this.state.isShowSelector,
|
|
70
|
+
errMessage: ''
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
this.selectProvince = province => {
|
|
74
|
+
this.setState({
|
|
75
|
+
selectedProvince: province,
|
|
76
|
+
selectedItem: 'city',
|
|
77
|
+
selectedCity: null,
|
|
78
|
+
location: this.getLocationText(province.name)
|
|
79
|
+
});
|
|
80
|
+
this.value = Object.assign({}, this.value, {
|
|
81
|
+
province: province.name,
|
|
82
|
+
city: '',
|
|
83
|
+
district: ''
|
|
84
|
+
});
|
|
85
|
+
this.props.setValue(this.value);
|
|
86
|
+
};
|
|
87
|
+
this.selectCity = city => {
|
|
88
|
+
this.setState({
|
|
89
|
+
selectedCity: city,
|
|
90
|
+
isShowSelector: false,
|
|
91
|
+
location: this.getLocationText(this.state.selectedProvince.name, city.name)
|
|
92
|
+
});
|
|
93
|
+
this.value = Object.assign({}, this.value, {
|
|
94
|
+
city: city.name,
|
|
95
|
+
district: ''
|
|
96
|
+
});
|
|
97
|
+
this.props.setValue(this.value);
|
|
98
|
+
};
|
|
99
|
+
this.selectSelectorType = type => {
|
|
100
|
+
const {
|
|
101
|
+
selectedProvince
|
|
102
|
+
} = this.state;
|
|
103
|
+
if (!selectedProvince) return;
|
|
104
|
+
this.setState({
|
|
105
|
+
selectedItem: type
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
this.onClick = e => {
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
111
|
+
};
|
|
112
|
+
this.onParseChange = () => {
|
|
113
|
+
if (this.timer) {
|
|
114
|
+
clearTimeout(this.timer);
|
|
115
|
+
this.timer = null;
|
|
116
|
+
}
|
|
117
|
+
this.timer = setTimeout(() => {
|
|
118
|
+
clearTimeout(this.timer);
|
|
119
|
+
this.timer = null;
|
|
120
|
+
const value = this.parseRef.value;
|
|
121
|
+
if (this.isComposing) return;
|
|
122
|
+
const {
|
|
123
|
+
province,
|
|
124
|
+
city
|
|
125
|
+
} = (0, _parseGeolocation.default)(this.locations, value);
|
|
126
|
+
this.value = Object.assign({}, this.value);
|
|
127
|
+
this.props.setValue(this.value);
|
|
128
|
+
if (!province) return;
|
|
129
|
+
this.selectProvince(province);
|
|
130
|
+
if (!city) return;
|
|
131
|
+
this.selectCity(city);
|
|
132
|
+
}, 100);
|
|
133
|
+
};
|
|
134
|
+
this.onCompositionStart = () => {
|
|
135
|
+
this.isComposing = true;
|
|
136
|
+
};
|
|
137
|
+
this.onCompositionEnd = () => {
|
|
138
|
+
this.isComposing = false;
|
|
139
|
+
};
|
|
140
|
+
this.onKeyDown = e => {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
143
|
+
if (e.keyCode === _constants.KeyCodes.Escape) {
|
|
144
|
+
this.props.onCancel();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
this.onSubmit = () => {
|
|
148
|
+
const {
|
|
149
|
+
province,
|
|
150
|
+
city
|
|
151
|
+
} = this.value;
|
|
152
|
+
if (!province || !city) {
|
|
153
|
+
const errMessage = (0, _lang.getLocale)('Province/City_must_be_filled_in');
|
|
154
|
+
this.setState({
|
|
155
|
+
errMessage
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.props.onSubmit();
|
|
160
|
+
};
|
|
161
|
+
this.createFooter = () => {
|
|
162
|
+
return /*#__PURE__*/_react.default.createElement(_reactstrap.ModalFooter, {
|
|
163
|
+
className: "dtable-ui-geolocation-editor-footer"
|
|
164
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
|
|
165
|
+
onClick: this.props.onCancel,
|
|
166
|
+
color: "secondary"
|
|
167
|
+
}, (0, _lang.getLocale)('Cancel')), /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
|
|
168
|
+
onClick: this.onSubmit,
|
|
169
|
+
color: "primary",
|
|
170
|
+
autoFocus: true
|
|
171
|
+
}, (0, _lang.getLocale)('Submit')));
|
|
172
|
+
};
|
|
173
|
+
this.value = props.value || {};
|
|
174
|
+
this.locations = {};
|
|
175
|
+
this.state = {
|
|
176
|
+
isShowSelector: false,
|
|
177
|
+
location: this.getLocationText(this.value.province, this.value.city, this.value.district),
|
|
178
|
+
selectedProvince: null,
|
|
179
|
+
selectedCity: null,
|
|
180
|
+
selectedItem: 'province',
|
|
181
|
+
isLoadingData: true,
|
|
182
|
+
errMessage: ''
|
|
183
|
+
};
|
|
184
|
+
this.timer = null;
|
|
185
|
+
this.isComposing = false;
|
|
186
|
+
}
|
|
187
|
+
componentDidMount() {
|
|
188
|
+
if (!window.app.location) {
|
|
189
|
+
this.getLocationData().then(data => {
|
|
190
|
+
this.locations = data;
|
|
191
|
+
window.app.location = data;
|
|
192
|
+
const {
|
|
193
|
+
selectedProvince,
|
|
194
|
+
selectedCity,
|
|
195
|
+
selectedItem
|
|
196
|
+
} = this.initLocationSelecting(this.value);
|
|
197
|
+
this.setState({
|
|
198
|
+
isLoadingData: false,
|
|
199
|
+
selectedProvince,
|
|
200
|
+
selectedCity,
|
|
201
|
+
selectedItem
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
this.locations = window.app.location;
|
|
206
|
+
const {
|
|
207
|
+
selectedProvince,
|
|
208
|
+
selectedCity,
|
|
209
|
+
selectedItem
|
|
210
|
+
} = this.initLocationSelecting(this.value);
|
|
211
|
+
this.setState({
|
|
212
|
+
isLoadingData: false,
|
|
213
|
+
selectedProvince,
|
|
214
|
+
selectedCity,
|
|
215
|
+
selectedItem
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
render() {
|
|
220
|
+
const {
|
|
221
|
+
selectedItem,
|
|
222
|
+
selectedCity,
|
|
223
|
+
selectedProvince,
|
|
224
|
+
isShowSelector,
|
|
225
|
+
isLoadingData,
|
|
226
|
+
location
|
|
227
|
+
} = this.state;
|
|
228
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !isLoadingData ? /*#__PURE__*/_react.default.createElement("div", {
|
|
229
|
+
onClick: this.onClick,
|
|
230
|
+
className: "dtable-ui-geolocation-editor-content"
|
|
231
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
232
|
+
className: "dtable-ui-geolocation-editor-item dtable-ui-geolocation-editor-selector-container"
|
|
233
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
234
|
+
className: "dtable-ui-geolocation-editor-item-left"
|
|
235
|
+
}, (0, _lang.getLocale)('Address_information') + ':'), /*#__PURE__*/_react.default.createElement("div", {
|
|
236
|
+
className: "dtable-ui-geolocation-editor-item-right"
|
|
237
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
238
|
+
onClick: this.onToggleSelector,
|
|
239
|
+
className: "dtable-ui-geolocation-editor-selector text-truncate ".concat(isShowSelector ? 'focus' : '')
|
|
240
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
241
|
+
className: "selected-option-show"
|
|
242
|
+
}, location ? location : (0, _lang.getLocale)('Select_province_city')), /*#__PURE__*/_react.default.createElement("span", {
|
|
243
|
+
"aria-hidden": "true",
|
|
244
|
+
className: "dtable-font dtable-icon-down3 dtable-ui-geolocation-editor-parameter-icon"
|
|
245
|
+
}))), isShowSelector && /*#__PURE__*/_react.default.createElement("div", {
|
|
246
|
+
className: "geolocation-selector-container"
|
|
247
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
248
|
+
className: "geolocation-selector-header"
|
|
249
|
+
}, /*#__PURE__*/_react.default.createElement(_selectorHeaderItem.default, {
|
|
250
|
+
type: "province",
|
|
251
|
+
clickHandler: this.selectSelectorType,
|
|
252
|
+
selectedType: selectedItem,
|
|
253
|
+
selectedItem: selectedProvince
|
|
254
|
+
}), /*#__PURE__*/_react.default.createElement(_selectorHeaderItem.default, {
|
|
255
|
+
type: "city",
|
|
256
|
+
clickHandler: this.selectSelectorType,
|
|
257
|
+
selectedType: selectedItem,
|
|
258
|
+
selectedItem: selectedCity
|
|
259
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
260
|
+
className: "geolocation-selector-body"
|
|
261
|
+
}, selectedItem === 'province' && /*#__PURE__*/_react.default.createElement(_selectorList.default, {
|
|
262
|
+
type: "province",
|
|
263
|
+
parent: this.locations,
|
|
264
|
+
selectedItem: selectedProvince,
|
|
265
|
+
clickHandler: this.selectProvince
|
|
266
|
+
}), selectedItem === 'city' && /*#__PURE__*/_react.default.createElement(_selectorList.default, {
|
|
267
|
+
type: "city",
|
|
268
|
+
parent: selectedProvince,
|
|
269
|
+
selectedItem: selectedCity,
|
|
270
|
+
clickHandler: this.selectCity
|
|
271
|
+
})))), /*#__PURE__*/_react.default.createElement("div", {
|
|
272
|
+
className: "dtable-ui-geolocation-editor-item dtable-ui-geolocation-editor-parse"
|
|
273
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
274
|
+
className: "dtable-ui-geolocation-editor-item-left"
|
|
275
|
+
}, (0, _lang.getLocale)('Auto_recognition') + ':'), /*#__PURE__*/_react.default.createElement("div", {
|
|
276
|
+
className: "dtable-ui-geolocation-editor-item-right"
|
|
277
|
+
}, /*#__PURE__*/_react.default.createElement("textarea", {
|
|
278
|
+
ref: ref => this.parseRef = ref,
|
|
279
|
+
placeholder: (0, _lang.getLocale)('Try_pasting_addresses_such_as_provinces/cities_information_to_quickly_identify_the_address_information'),
|
|
280
|
+
className: "dtable-ui-geolocation-editor-detail-info dtable-ui-geolocation-editor-recognition",
|
|
281
|
+
type: "text",
|
|
282
|
+
onChange: this.onParseChange,
|
|
283
|
+
onKeyDown: this.onKeyDown,
|
|
284
|
+
onCompositionEnd: this.onCompositionEnd,
|
|
285
|
+
onCompositionStart: this.onCompositionStart
|
|
286
|
+
})))) : /*#__PURE__*/_react.default.createElement(_Loading.default, null), this.state.errMessage && /*#__PURE__*/_react.default.createElement(_reactstrap.Alert, {
|
|
287
|
+
color: "danger",
|
|
288
|
+
className: "mt-2"
|
|
289
|
+
}, this.state.errMessage), this.createFooter());
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
var _default = exports.default = ProvinceCityEditor;
|