dtable-ui-component 5.3.1-beta1 → 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.
Files changed (223) hide show
  1. package/lib/CheckboxEditor/index.css +20 -3
  2. package/lib/CheckboxEditor/index.js +35 -98
  3. package/lib/CheckboxFormatter/index.js +9 -6
  4. package/lib/CollaboratorEditor/index.css +35 -12
  5. package/lib/CollaboratorEditor/index.js +212 -18
  6. package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.js +29 -26
  7. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +97 -0
  8. package/lib/CollaboratorItem/index.css +1 -1
  9. package/lib/CollaboratorItem/index.js +2 -6
  10. package/lib/DTableFiltersPopover/utils/index.js +7 -1
  11. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  12. package/lib/DTableSelect/index.js +1 -3
  13. package/lib/DateEditor/index.js +51 -14
  14. package/lib/DateEditor/pc-date-editor-popover.js +12 -145
  15. package/lib/Department-editor/department-single-select.js +1 -1
  16. package/lib/Department-editor/index.js +4 -3
  17. package/lib/DepartmentSingleSelectFormatter/index.js +1 -2
  18. package/lib/FileEditor/index.js +11 -244
  19. package/lib/FileEditor/pc-files-addition/index.js +1 -0
  20. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +1 -0
  21. package/lib/FileEditor/pc-files-preview/index.js +1 -0
  22. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +1 -0
  23. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  24. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  25. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  26. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  27. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  28. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  29. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  30. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  31. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  32. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  33. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  34. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  35. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  36. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  37. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  38. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  39. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  40. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  41. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  42. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  43. package/lib/FileItemFormatter/index.js +20 -19
  44. package/lib/FileItemFormatter/utils.js +99 -0
  45. package/lib/FileUploader/index.js +14 -268
  46. package/lib/FormulaFormatter/index.js +1 -2
  47. package/lib/FormulaFormatter/utils.js +31 -0
  48. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  49. package/lib/MultipleSelectEditor/index.css +9 -0
  50. package/lib/MultipleSelectEditor/index.js +177 -16
  51. package/lib/NumberEditor/index.js +77 -64
  52. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.css +1 -1
  53. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.js +1 -1
  54. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.css +6 -6
  55. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.js +1 -3
  56. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/row-expand-file-item-formatter.js +11 -10
  57. package/lib/RowExpandFormatter/index.css +0 -26
  58. package/lib/RowExpandFormatter/index.js +100 -84
  59. package/lib/{RowExpandFormatter/RowExpandFormulaFormatter → RowExpandFormulaFormatter}/index.js +10 -11
  60. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.css +6 -6
  61. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.js +1 -1
  62. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  63. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  64. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.js +5 -5
  65. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/utils.js +1 -1
  66. package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.css +1 -1
  67. package/lib/RowExpandUrlFormatter/index.css +1 -0
  68. package/lib/{RowExpandFormatter/RowExpandUrlFormatter → RowExpandUrlFormatter}/index.js +3 -4
  69. package/lib/SingleSelectEditor/index.css +14 -0
  70. package/lib/SingleSelectEditor/index.js +156 -16
  71. package/lib/TextEditor/index.js +42 -113
  72. package/lib/constants/index.js +2 -34
  73. package/lib/css/cell-editor.css +2 -18
  74. package/lib/index.js +46 -74
  75. package/lib/lang/index.js +14 -16
  76. package/lib/locals/de.js +103 -0
  77. package/lib/locals/en.js +104 -0
  78. package/lib/locals/es.js +103 -0
  79. package/lib/locals/fr.js +103 -0
  80. package/lib/locals/pt.js +103 -0
  81. package/lib/locals/ru.js +103 -0
  82. package/lib/locals/zh-CN.js +104 -0
  83. package/lib/select-editor/index.js +6 -6
  84. package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.js +3 -3
  85. package/lib/select-editor/pc-select-editor-popover/index.css +71 -0
  86. package/lib/select-editor/pc-select-editor-popover/index.js +122 -0
  87. package/lib/utils/editor-utils.js +6 -1
  88. package/lib/utils/url.js +8 -119
  89. package/lib/utils/utils.js +2 -89
  90. package/package.json +2 -3
  91. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +0 -257
  92. package/lib/DeleteTip/index.js +0 -50
  93. package/lib/DigitalSignEditor/constants.js +0 -7
  94. package/lib/DigitalSignEditor/index.css +0 -69
  95. package/lib/DigitalSignEditor/index.js +0 -182
  96. package/lib/DigitalSignEditor/service.js +0 -38
  97. package/lib/DigitalSignEditor/signature-board/index.css +0 -35
  98. package/lib/DigitalSignEditor/signature-board/index.js +0 -135
  99. package/lib/DigitalSignEditor/signature-board/signature-tool.js +0 -396
  100. package/lib/DigitalSignEditor/utils.js +0 -29
  101. package/lib/DurationEditor/index.js +0 -111
  102. package/lib/EmailEditor/index.js +0 -59
  103. package/lib/FileEditor/addition-previewer/index.css +0 -1
  104. package/lib/FileEditor/addition-previewer/index.js +0 -52
  105. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +0 -1
  106. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +0 -252
  107. package/lib/FileEditor/constants.js +0 -7
  108. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +0 -74
  109. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +0 -5
  110. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +0 -77
  111. package/lib/FileEditor/files-previewer/file-previewer/index.css +0 -88
  112. package/lib/FileEditor/files-previewer/file-previewer/index.js +0 -167
  113. package/lib/FileEditor/files-previewer/index.css +0 -56
  114. package/lib/FileEditor/files-previewer/index.js +0 -277
  115. package/lib/FileEditor/index.css +0 -6
  116. package/lib/FileEditor/utils.js +0 -22
  117. package/lib/FileUploader/index.css +0 -9
  118. package/lib/GeolocationEditor/country-editor.js +0 -319
  119. package/lib/GeolocationEditor/index.css +0 -641
  120. package/lib/GeolocationEditor/index.js +0 -241
  121. package/lib/GeolocationEditor/location-editor.js +0 -368
  122. package/lib/GeolocationEditor/map-editor/index.js +0 -456
  123. package/lib/GeolocationEditor/map-editor/large-editor/index.css +0 -137
  124. package/lib/GeolocationEditor/map-editor/large-editor/index.js +0 -461
  125. package/lib/GeolocationEditor/map-editor-utils.js +0 -153
  126. package/lib/GeolocationEditor/map-selection-editor/index.js +0 -455
  127. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +0 -1
  128. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +0 -447
  129. package/lib/GeolocationEditor/parse-geolocation.js +0 -282
  130. package/lib/GeolocationEditor/province-city-editor.js +0 -292
  131. package/lib/GeolocationEditor/province-editor.js +0 -226
  132. package/lib/GeolocationEditor/selector-header-item.js +0 -28
  133. package/lib/GeolocationEditor/selector-list.js +0 -33
  134. package/lib/GeolocationEditor/with-ref.js +0 -27
  135. package/lib/ImageEditor/addition-previewer/image-link/index.css +0 -45
  136. package/lib/ImageEditor/addition-previewer/image-link/index.js +0 -73
  137. package/lib/ImageEditor/addition-previewer/index.css +0 -106
  138. package/lib/ImageEditor/addition-previewer/index.js +0 -63
  139. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +0 -125
  140. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +0 -254
  141. package/lib/ImageEditor/constants.js +0 -7
  142. package/lib/ImageEditor/images-previewer/image-preview/index.css +0 -59
  143. package/lib/ImageEditor/images-previewer/image-preview/index.js +0 -155
  144. package/lib/ImageEditor/images-previewer/index.css +0 -18
  145. package/lib/ImageEditor/images-previewer/index.js +0 -140
  146. package/lib/ImageEditor/index.css +0 -24
  147. package/lib/ImageEditor/index.js +0 -194
  148. package/lib/ImageThumbnail/index.css +0 -20
  149. package/lib/ImageThumbnail/index.js +0 -136
  150. package/lib/RowExpandDialog/body/index.css +0 -21
  151. package/lib/RowExpandDialog/body/index.js +0 -279
  152. package/lib/RowExpandDialog/column-content/index.css +0 -43
  153. package/lib/RowExpandDialog/column-content/index.js +0 -50
  154. package/lib/RowExpandDialog/constants.js +0 -114
  155. package/lib/RowExpandDialog/header/index.css +0 -31
  156. package/lib/RowExpandDialog/header/index.js +0 -33
  157. package/lib/RowExpandDialog/index.css +0 -24
  158. package/lib/RowExpandDialog/index.js +0 -272
  159. package/lib/RowExpandDialog/utils.js +0 -83
  160. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +0 -22
  161. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +0 -24
  162. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +0 -18
  163. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +0 -43
  164. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +0 -5
  165. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +0 -232
  166. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +0 -130
  167. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +0 -129
  168. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +0 -13
  169. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +0 -208
  170. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +0 -105
  171. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +0 -2
  172. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +0 -125
  173. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +0 -1
  174. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +0 -146
  175. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +0 -17
  176. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +0 -165
  177. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +0 -6
  178. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +0 -170
  179. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +0 -6
  180. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +0 -124
  181. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +0 -44
  182. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +0 -224
  183. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +0 -105
  184. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +0 -13
  185. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +0 -152
  186. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +0 -58
  187. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +0 -192
  188. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +0 -4
  189. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +0 -127
  190. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +0 -31
  191. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +0 -130
  192. package/lib/RowExpandEditor/constants.js +0 -44
  193. package/lib/RowExpandEditor/index.css +0 -0
  194. package/lib/RowExpandEditor/index.js +0 -32
  195. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +0 -27
  196. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +0 -1
  197. package/lib/RowExpandFormatter/constants.js +0 -60
  198. package/lib/UploadProgress/index.js +0 -38
  199. package/lib/UrlEditor/index.js +0 -62
  200. package/lib/common/editor-base.js +0 -53
  201. package/lib/constants/file.js +0 -96
  202. package/lib/constants/key-codes.js +0 -109
  203. package/lib/hooks/index.js +0 -16
  204. package/lib/locales/de.json +0 -163
  205. package/lib/locales/en.json +0 -163
  206. package/lib/locales/es.json +0 -163
  207. package/lib/locales/fr.json +0 -163
  208. package/lib/locales/pt.json +0 -163
  209. package/lib/locales/ru.json +0 -163
  210. package/lib/locales/zh-CN.json +0 -163
  211. package/lib/select-editor/pc-select-editor/index.css +0 -85
  212. package/lib/select-editor/pc-select-editor/index.js +0 -290
  213. package/lib/utils/cell-comparer.js +0 -35
  214. package/lib/utils/cell.js +0 -55
  215. package/lib/utils/column-utils.js +0 -25
  216. package/lib/utils/get-event-transfer.js +0 -75
  217. package/lib/utils/object-utils.js +0 -61
  218. /package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.css +0 -0
  219. /package/lib/CollaboratorEditor/{pc-collaborator-editor → pc-collaborator-editor-popover}/index.css +0 -0
  220. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.css +0 -0
  221. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/value-display-utils.js +0 -0
  222. /package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.js +0 -0
  223. /package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.css +0 -0
@@ -1,282 +0,0 @@
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;
@@ -1,292 +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 _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;