dtable-ui-component 6.0.2 → 6.0.4

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 (262) hide show
  1. package/lib/ButtonFormatter/index.js +8 -2
  2. package/lib/CheckboxEditor/index.css +8 -20
  3. package/lib/CheckboxEditor/index.js +98 -35
  4. package/lib/CheckboxFormatter/index.css +5 -0
  5. package/lib/CheckboxFormatter/index.js +9 -15
  6. package/lib/CollaboratorEditor/index.css +12 -35
  7. package/lib/CollaboratorEditor/index.js +18 -212
  8. package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +27 -30
  9. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
  10. package/lib/CollaboratorItem/index.css +7 -1
  11. package/lib/CollaboratorItem/index.js +6 -2
  12. package/lib/Comment/body/comment.js +190 -0
  13. package/lib/Comment/body/index.css +95 -0
  14. package/lib/Comment/body/index.js +32 -0
  15. package/lib/Comment/footer/btns/index.css +40 -0
  16. package/lib/Comment/footer/btns/index.js +113 -0
  17. package/lib/Comment/footer/index.css +157 -0
  18. package/lib/Comment/footer/index.js +169 -0
  19. package/lib/Comment/footer/input/index.css +52 -0
  20. package/lib/Comment/footer/input/index.js +448 -0
  21. package/lib/Comment/footer/input/participant/index.css +0 -0
  22. package/lib/Comment/footer/input/participant/index.js +53 -0
  23. package/lib/Comment/footer/participants/index.css +22 -0
  24. package/lib/Comment/footer/participants/index.js +68 -0
  25. package/lib/Comment/footer/participants/participant/index.css +5 -0
  26. package/lib/Comment/footer/participants/participant/index.js +32 -0
  27. package/lib/Comment/footer/participants/participant-select/index.css +104 -0
  28. package/lib/Comment/footer/participants/participant-select/index.js +182 -0
  29. package/lib/Comment/index.css +19 -0
  30. package/lib/Comment/index.js +304 -0
  31. package/lib/Comment/model.js +25 -0
  32. package/lib/Comment/utils/common.js +62 -0
  33. package/lib/Comment/utils/index.js +27 -0
  34. package/lib/Comment/utils/utilities.js +176 -0
  35. package/lib/DTableColorPicker/index.css +1 -1
  36. package/lib/DTableCustomizeSelect/index.js +2 -2
  37. package/lib/DTableFiltersPopover/utils/index.js +1 -7
  38. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  39. package/lib/DTableGroupSelect/index.js +3 -3
  40. package/lib/DTableSelect/index.js +3 -1
  41. package/lib/DateEditor/index.js +14 -51
  42. package/lib/DateEditor/pc-date-editor-popover.js +149 -12
  43. package/lib/{common/delete-tip.js → DeleteTip/index.js} +12 -16
  44. package/lib/Department-editor/department-single-select.js +1 -1
  45. package/lib/Department-editor/index.js +3 -4
  46. package/lib/DepartmentSingleSelectFormatter/index.js +3 -2
  47. package/lib/DigitalSignEditor/constants.js +7 -0
  48. package/lib/DigitalSignEditor/index.css +69 -0
  49. package/lib/DigitalSignEditor/index.js +182 -0
  50. package/lib/DigitalSignEditor/service.js +39 -0
  51. package/lib/DigitalSignEditor/signature-board/index.css +35 -0
  52. package/lib/DigitalSignEditor/signature-board/index.js +135 -0
  53. package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
  54. package/lib/DigitalSignEditor/utils.js +29 -0
  55. package/lib/DurationEditor/index.js +110 -0
  56. package/lib/EmailEditor/index.js +58 -0
  57. package/lib/FileEditor/addition-previewer/index.css +1 -0
  58. package/lib/FileEditor/addition-previewer/index.js +52 -0
  59. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
  60. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
  61. package/lib/FileEditor/constants.js +7 -0
  62. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
  63. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
  64. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
  65. package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
  66. package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
  67. package/lib/FileEditor/files-previewer/index.css +56 -0
  68. package/lib/FileEditor/files-previewer/index.js +277 -0
  69. package/lib/FileEditor/index.css +6 -0
  70. package/lib/FileEditor/index.js +258 -11
  71. package/lib/FileEditor/utils.js +22 -0
  72. package/lib/FileItemFormatter/index.js +19 -20
  73. package/lib/FileUploader/index.css +9 -0
  74. package/lib/FileUploader/index.js +268 -14
  75. package/lib/FormulaFormatter/cell-value-validator.js +17 -17
  76. package/lib/FormulaFormatter/index.js +2 -1
  77. package/lib/FormulaFormatter/utils.js +0 -31
  78. package/lib/GeolocationEditor/country-editor.js +319 -0
  79. package/lib/GeolocationEditor/index.css +641 -0
  80. package/lib/GeolocationEditor/index.js +240 -0
  81. package/lib/GeolocationEditor/location-editor.js +368 -0
  82. package/lib/GeolocationEditor/map-editor/index.js +456 -0
  83. package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
  84. package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
  85. package/lib/GeolocationEditor/map-editor-utils.js +153 -0
  86. package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
  87. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
  88. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
  89. package/lib/GeolocationEditor/parse-geolocation.js +282 -0
  90. package/lib/GeolocationEditor/province-city-editor.js +292 -0
  91. package/lib/GeolocationEditor/province-editor.js +226 -0
  92. package/lib/GeolocationEditor/selector-header-item.js +28 -0
  93. package/lib/GeolocationEditor/selector-list.js +33 -0
  94. package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
  95. package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
  96. package/lib/ImageEditor/addition-previewer/index.css +106 -0
  97. package/lib/ImageEditor/addition-previewer/index.js +63 -0
  98. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
  99. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
  100. package/lib/ImageEditor/constants.js +7 -0
  101. package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
  102. package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
  103. package/lib/ImageEditor/images-previewer/index.css +18 -0
  104. package/lib/ImageEditor/images-previewer/index.js +140 -0
  105. package/lib/ImageEditor/index.css +24 -0
  106. package/lib/ImageEditor/index.js +194 -0
  107. package/lib/ImageFormatter/images-lazy-load.js +4 -2
  108. package/lib/ImageFormatter/index.js +8 -3
  109. package/lib/ImageThumbnail/index.css +20 -0
  110. package/lib/ImageThumbnail/index.js +137 -0
  111. package/lib/LinkEditor/index.js +2 -3
  112. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  113. package/lib/MultipleSelectEditor/index.js +16 -177
  114. package/lib/NumberEditor/index.js +63 -77
  115. package/lib/RoleStatusEditor/index.css +0 -2
  116. package/lib/RowExpandDialog/body/index.css +21 -0
  117. package/lib/RowExpandDialog/body/index.js +262 -0
  118. package/lib/RowExpandDialog/column-content/index.css +48 -0
  119. package/lib/RowExpandDialog/column-content/index.js +50 -0
  120. package/lib/RowExpandDialog/header/index.css +31 -0
  121. package/lib/RowExpandDialog/header/index.js +55 -0
  122. package/lib/RowExpandDialog/index.css +28 -0
  123. package/lib/RowExpandDialog/index.js +237 -0
  124. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
  125. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
  126. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
  127. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
  128. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
  129. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
  130. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
  131. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +104 -0
  132. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
  133. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
  134. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
  135. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
  136. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
  137. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
  138. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +148 -0
  139. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
  140. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
  141. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +11 -0
  142. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
  143. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
  144. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +123 -0
  145. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
  146. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +247 -0
  147. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
  148. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
  149. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
  150. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
  151. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +206 -0
  152. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
  153. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
  154. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
  155. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
  156. package/lib/RowExpandEditor/constants.js +44 -0
  157. package/lib/RowExpandEditor/index.css +0 -0
  158. package/lib/RowExpandEditor/index.js +32 -0
  159. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
  160. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
  161. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
  162. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
  163. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
  164. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +12 -13
  165. package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
  166. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
  167. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
  168. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +5 -5
  169. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  170. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +2 -2
  171. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +20 -20
  172. package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
  173. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
  174. package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
  175. package/lib/RowExpandFormatter/constants.js +61 -0
  176. package/lib/RowExpandFormatter/index.css +28 -3
  177. package/lib/RowExpandFormatter/index.js +113 -131
  178. package/lib/SimpleLongTextFormatter/widgets/longTextEditor.css +2 -2
  179. package/lib/SingleSelectEditor/index.js +16 -156
  180. package/lib/SvgIcon/index.css +11 -0
  181. package/lib/SvgIcon/index.js +29 -0
  182. package/lib/TextEditor/index.js +112 -42
  183. package/lib/UploadProgress/index.js +38 -0
  184. package/lib/UrlEditor/index.js +61 -0
  185. package/lib/common/editor-base.js +52 -0
  186. package/lib/constants/file.js +96 -0
  187. package/lib/constants/index.js +27 -15
  188. package/lib/constants/key-codes.js +109 -0
  189. package/lib/css/cell-editor.css +18 -2
  190. package/lib/formatterConfig/base-formatter-config.js +23 -23
  191. package/lib/formatterConfig/index.js +3 -3
  192. package/lib/hooks/index.js +16 -0
  193. package/lib/index.js +81 -46
  194. package/lib/lang/index.js +19 -16
  195. package/lib/locales/de.json +167 -0
  196. package/lib/locales/en.json +167 -0
  197. package/lib/locales/es.json +167 -0
  198. package/lib/locales/fr.json +167 -0
  199. package/lib/locales/pt.json +167 -0
  200. package/lib/locales/ru.json +167 -0
  201. package/lib/locales/zh-CN.json +167 -0
  202. package/lib/select-editor/index.js +6 -6
  203. package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
  204. package/lib/select-editor/pc-select-editor/index.css +85 -0
  205. package/lib/select-editor/pc-select-editor/index.js +295 -0
  206. package/lib/toaster/toast.js +19 -15
  207. package/lib/utils/cell-comparer.js +35 -0
  208. package/lib/utils/cell.js +55 -0
  209. package/lib/utils/column-utils.js +25 -0
  210. package/lib/utils/editor-utils.js +1 -6
  211. package/lib/utils/get-event-transfer.js +75 -0
  212. package/lib/utils/hotkey.js +37 -0
  213. package/lib/utils/object-utils.js +61 -0
  214. package/lib/utils/url.js +127 -8
  215. package/lib/utils/utils.js +119 -2
  216. package/package.json +4 -3
  217. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
  218. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  219. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  220. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  221. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  222. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  223. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  224. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  225. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  226. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  227. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  228. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  229. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  230. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  231. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  232. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  233. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  234. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  235. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  236. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  237. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  238. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  239. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  240. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  241. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  242. package/lib/FileItemFormatter/utils.js +0 -99
  243. package/lib/MultipleSelectEditor/index.css +0 -9
  244. package/lib/RowExpandLinkFormatter/utils.js +0 -71
  245. package/lib/RowExpandUrlFormatter/index.css +0 -1
  246. package/lib/SingleSelectEditor/index.css +0 -14
  247. package/lib/common/modal-portal.js +0 -26
  248. package/lib/locals/de.js +0 -103
  249. package/lib/locals/en.js +0 -104
  250. package/lib/locals/es.js +0 -103
  251. package/lib/locals/fr.js +0 -103
  252. package/lib/locals/pt.js +0 -103
  253. package/lib/locals/ru.js +0 -103
  254. package/lib/locals/zh-CN.js +0 -104
  255. package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
  256. package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
  257. /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
  258. /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
  259. /package/lib/{common/delete-tip.css → DeleteTip/index.css} +0 -0
  260. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
  261. /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
  262. /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _dtableUtils = require("dtable-utils");
10
+ var _constants = require("../constants");
11
+ var _objectUtils = _interopRequireDefault(require("../utils/object-utils"));
12
+ var _locationEditor = _interopRequireDefault(require("./location-editor"));
13
+ var _mapEditor = _interopRequireDefault(require("./map-editor"));
14
+ var _mapSelectionEditor = _interopRequireDefault(require("./map-selection-editor"));
15
+ var _countryEditor = _interopRequireDefault(require("./country-editor"));
16
+ var _provinceEditor = _interopRequireDefault(require("./province-editor"));
17
+ var _provinceCityEditor = _interopRequireDefault(require("./province-city-editor"));
18
+ require("./index.css");
19
+ class GeolocationEditor extends _react.default.Component {
20
+ constructor(_props) {
21
+ super(_props);
22
+ this.onHotKey = e => {
23
+ if (e.keyCode === _constants.KeyCodes.Enter && e.target.tagName !== 'TEXTAREA') {
24
+ this.onSubmit();
25
+ } else if (e.keyCode === _constants.KeyCodes.Escape) {
26
+ if (this.props.isInModal) {
27
+ e.stopPropagation();
28
+ this.onCancel();
29
+ }
30
+ }
31
+ };
32
+ this.getValue = () => {
33
+ return this.value;
34
+ };
35
+ this.setValue = value => {
36
+ this.value = value;
37
+ };
38
+ this.onSubmit = () => {
39
+ if (_objectUtils.default.isSameObject(this.initValue, this.value)) {
40
+ this.onCancel();
41
+ return;
42
+ }
43
+ this.props.onCommit(this.value);
44
+ };
45
+ this.onCancel = () => {
46
+ this.props.onCommitCancel && this.props.onCommitCancel();
47
+ };
48
+ this.setEditorPosition = () => {
49
+ const {
50
+ isInModal
51
+ } = this.props;
52
+ const editorFormat = this.getGeoFormat();
53
+ if (this.ref && (editorFormat === _dtableUtils.GEOLOCATION_FORMAT.COUNTRY_REGION || editorFormat === _dtableUtils.GEOLOCATION_FORMAT.PROVINCE)) {
54
+ let height = 240;
55
+ let width = 200;
56
+ let left = this.ref.parentNode.getBoundingClientRect().x;
57
+ let top = this.ref.parentNode.getBoundingClientRect().y;
58
+ if (isInModal) {
59
+ left = 220;
60
+ }
61
+ if (top + height > window.innerHeight) {
62
+ top = window.innerHeight - height - 35;
63
+ }
64
+ this.setState({
65
+ editorPosition: {
66
+ top,
67
+ left,
68
+ width,
69
+ zIndex: 1000,
70
+ position: 'fixed'
71
+ }
72
+ });
73
+ return;
74
+ }
75
+ if (this.ref && editorFormat === _dtableUtils.GEOLOCATION_FORMAT.PROVINCE_CITY) {
76
+ let height = 215;
77
+ let width = 400;
78
+ let left = this.ref.parentNode.getBoundingClientRect().x;
79
+ let top = this.ref.parentNode.getBoundingClientRect().y;
80
+ if (isInModal) {
81
+ left = 220;
82
+ if (top + height + 35 + 200 > window.innerHeight) {
83
+ top = window.innerHeight - height - 235;
84
+ }
85
+ } else {
86
+ if (top + height + 200 > window.innerHeight) {
87
+ top = window.innerHeight - height - 200 - 5;
88
+ }
89
+ if (left + width > window.innerWidth) {
90
+ left = window.innerWidth - width - 10;
91
+ }
92
+ }
93
+ this.setState({
94
+ editorPosition: {
95
+ top,
96
+ left,
97
+ width,
98
+ zIndex: 1000,
99
+ position: 'fixed'
100
+ }
101
+ });
102
+ return;
103
+ }
104
+ if (this.ref) {
105
+ const isMapTypeEditor = editorFormat === _dtableUtils.GEOLOCATION_FORMAT.LNG_LAT || editorFormat === _dtableUtils.GEOLOCATION_FORMAT.MAP_SELECTION;
106
+ let width = isMapTypeEditor ? 500 : 400;
107
+ let height = isMapTypeEditor ? 454 : 310;
108
+ let geoEditorTop = 0;
109
+ let geoEditorLeft = 0;
110
+ if (isInModal) {
111
+ let innerHeight = window.innerHeight;
112
+ const offsetTop = this.ref.parentNode.getBoundingClientRect().y;
113
+ geoEditorTop = offsetTop;
114
+ geoEditorTop = height + geoEditorTop > innerHeight ? innerHeight - height - 30 : geoEditorTop;
115
+ geoEditorLeft = -30;
116
+ } else {
117
+ let {
118
+ offsetLeft,
119
+ offsetTop
120
+ } = this.ref.parentNode;
121
+ geoEditorLeft = offsetLeft - width;
122
+ geoEditorTop = offsetTop;
123
+ if (offsetLeft < width) {
124
+ geoEditorLeft = offsetLeft + this.props.column.width;
125
+ }
126
+ if (geoEditorLeft + width > window.innerWidth) {
127
+ geoEditorLeft = window.innerWidth - width;
128
+ }
129
+ if (offsetTop + height > window.innerHeight) {
130
+ geoEditorTop = window.innerHeight - height;
131
+ }
132
+ }
133
+ this.setState({
134
+ editorPosition: {
135
+ top: geoEditorTop,
136
+ left: geoEditorLeft,
137
+ zIndex: 1000,
138
+ position: 'fixed'
139
+ }
140
+ });
141
+ }
142
+ };
143
+ this.getGeoFormat = () => {
144
+ const {
145
+ column
146
+ } = this.props;
147
+ let data = column.data || {};
148
+ return data.geo_format ? data.geo_format : _dtableUtils.DEFAULT_GEOLOCATION_FORMAT;
149
+ };
150
+ this.getLargeEditorState = () => {
151
+ var _this$editor, _this$editor$state;
152
+ return (_this$editor = this.editor) === null || _this$editor === void 0 ? void 0 : (_this$editor$state = _this$editor.state) === null || _this$editor$state === void 0 ? void 0 : _this$editor$state.isShowLargeEditor;
153
+ };
154
+ this.createEditor = () => {
155
+ const geoFormat = this.getGeoFormat();
156
+ const {
157
+ config,
158
+ column
159
+ } = this.props;
160
+ const props = {
161
+ column,
162
+ config,
163
+ value: this.value,
164
+ setValue: this.setValue,
165
+ onSubmit: this.onSubmit,
166
+ onCancel: this.onCancel
167
+ };
168
+ switch (geoFormat) {
169
+ case _dtableUtils.GEOLOCATION_FORMAT.LNG_LAT:
170
+ {
171
+ return /*#__PURE__*/_react.default.createElement(_mapEditor.default, Object.assign({}, props, {
172
+ ref: ref => this.editor = ref
173
+ }));
174
+ }
175
+ case _dtableUtils.GEOLOCATION_FORMAT.MAP_SELECTION:
176
+ {
177
+ return /*#__PURE__*/_react.default.createElement(_mapSelectionEditor.default, Object.assign({}, props, {
178
+ ref: ref => this.editor = ref
179
+ }));
180
+ }
181
+ case _dtableUtils.GEOLOCATION_FORMAT.COUNTRY_REGION:
182
+ {
183
+ return /*#__PURE__*/_react.default.createElement(_countryEditor.default, Object.assign({}, props, {
184
+ ref: ref => this.editor = ref
185
+ }));
186
+ }
187
+ case _dtableUtils.GEOLOCATION_FORMAT.PROVINCE:
188
+ {
189
+ return /*#__PURE__*/_react.default.createElement(_provinceEditor.default, Object.assign({}, props, {
190
+ onPressTab: this.props.onPressTab,
191
+ ref: ref => this.editor = ref
192
+ }));
193
+ }
194
+ case _dtableUtils.GEOLOCATION_FORMAT.PROVINCE_CITY:
195
+ {
196
+ return /*#__PURE__*/_react.default.createElement(_provinceCityEditor.default, Object.assign({}, props, {
197
+ ref: ref => this.editor = ref
198
+ }));
199
+ }
200
+ case _dtableUtils.GEOLOCATION_FORMAT.PROVINCE_CITY_DISTRICT:
201
+ {
202
+ return /*#__PURE__*/_react.default.createElement(_locationEditor.default, Object.assign({}, props, {
203
+ ref: ref => this.editor = ref
204
+ }));
205
+ }
206
+ default:
207
+ {
208
+ return /*#__PURE__*/_react.default.createElement(_locationEditor.default, Object.assign({}, props, {
209
+ isShowAddressDetail: true,
210
+ ref: ref => this.editor = ref
211
+ }));
212
+ }
213
+ }
214
+ };
215
+ this.value = _props.value || {};
216
+ this.initValue = this.value;
217
+ this.state = {
218
+ editorPosition: null
219
+ };
220
+ this.editor = null;
221
+ }
222
+ componentDidMount() {
223
+ this.setEditorPosition();
224
+ document.addEventListener('keydown', this.onHotKey, true);
225
+ }
226
+ componentWillUnmount() {
227
+ document.removeEventListener('keydown', this.onHotKey, true);
228
+ }
229
+ render() {
230
+ const {
231
+ editorPosition
232
+ } = this.state;
233
+ return /*#__PURE__*/_react.default.createElement("div", {
234
+ ref: ref => this.ref = ref,
235
+ style: editorPosition,
236
+ className: "dtable-ui-dtable-ui-geolocation-editor"
237
+ }, this.createEditor());
238
+ }
239
+ }
240
+ var _default = exports.default = GeolocationEditor;
@@ -0,0 +1,368 @@
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 _constants = require("../constants");
14
+ var _Loading = _interopRequireDefault(require("../Loading"));
15
+ var _parseGeolocation = _interopRequireDefault(require("./parse-geolocation"));
16
+ var _lang = require("../lang");
17
+ class LocationEditor extends _react.Component {
18
+ constructor(props) {
19
+ super(props);
20
+ this.getLocationText = (province, city, district) => {
21
+ return (province ? province.name : '') + (city ? city.name : '') + (district ? district.name : '');
22
+ };
23
+ this.initLocationSelecting = value => {
24
+ let selectedProvince = this.locations.children.find(province => {
25
+ return value.province && value.province.length > 0 && province.name.includes(value.province);
26
+ });
27
+ if (!selectedProvince) {
28
+ return {
29
+ selectedProvince: null,
30
+ selectedCity: null,
31
+ selectedCounty: null,
32
+ selectedItem: 'province'
33
+ };
34
+ }
35
+ let selectedCity = selectedProvince.children.find(city => {
36
+ return value.city && value.city.length > 0 && city.name.includes(value.city);
37
+ });
38
+ if (!selectedCity) {
39
+ return {
40
+ selectedProvince,
41
+ selectedCity: null,
42
+ selectedCounty: null,
43
+ selectedItem: 'city'
44
+ };
45
+ }
46
+ let selectedCounty = selectedCity.children.find(county => {
47
+ return value.district && value.district.length > 0 && county.name.includes(value.district);
48
+ });
49
+ if (!selectedCounty) {
50
+ return {
51
+ selectedProvince,
52
+ selectedCity,
53
+ selectedCounty: null,
54
+ selectedItem: 'county'
55
+ };
56
+ }
57
+ return {
58
+ selectedProvince,
59
+ selectedCity,
60
+ selectedCounty,
61
+ selectedItem: 'county'
62
+ };
63
+ };
64
+ this.getLocationData = () => {
65
+ const {
66
+ mediaUrl
67
+ } = window.dtable;
68
+
69
+ // get locations from server
70
+ return fetch("".concat(mediaUrl, "geo-data/cn-location.json")).then(res => {
71
+ return res.json();
72
+ }).catch(() => {
73
+ // get locations from local
74
+ return fetch('./geo-data/cn-location.json').then(res => {
75
+ return res.json();
76
+ });
77
+ });
78
+ };
79
+ this.onKeyDown = e => {
80
+ e.stopPropagation();
81
+ e.nativeEvent.stopImmediatePropagation();
82
+ if (e.keyCode === _constants.KeyCodes.Escape) {
83
+ this.props.onCancel();
84
+ }
85
+ };
86
+ this.onToggleSelector = () => {
87
+ this.setState({
88
+ isShowSelector: !this.state.isShowSelector,
89
+ errMessage: ''
90
+ });
91
+ };
92
+ this.selectProvince = province => {
93
+ this.setState({
94
+ selectedProvince: province,
95
+ selectedItem: province ? 'city' : 'province',
96
+ selectedCity: null,
97
+ selectedCounty: null,
98
+ location: this.getLocationText(province)
99
+ });
100
+ this.value = Object.assign({}, this.value, {
101
+ province: province ? province.name : '',
102
+ city: '',
103
+ district: ''
104
+ });
105
+ this.props.setValue(this.value);
106
+ };
107
+ this.selectCity = city => {
108
+ this.setState({
109
+ selectedCity: city,
110
+ selectedItem: city ? 'county' : 'city',
111
+ selectedCounty: null,
112
+ location: this.getLocationText(this.state.selectedProvince, city)
113
+ });
114
+ this.value = Object.assign({}, this.value, {
115
+ city: city ? city.name : '',
116
+ district: ''
117
+ });
118
+ this.props.setValue(this.value);
119
+ };
120
+ this.selectCounty = county => {
121
+ this.setState({
122
+ selectedCounty: county,
123
+ isShowSelector: false,
124
+ location: this.getLocationText(this.state.selectedProvince, this.state.selectedCity, county)
125
+ });
126
+ this.value = Object.assign({}, this.value, {
127
+ district: county ? county.name : ''
128
+ });
129
+ this.props.setValue(this.value);
130
+ };
131
+ this.selectSelectorType = type => {
132
+ const {
133
+ selectedProvince,
134
+ selectedCity
135
+ } = this.state;
136
+ if (!selectedProvince) return;
137
+ if (type === 'county' && !selectedCity) return;
138
+ this.setState({
139
+ selectedItem: type
140
+ });
141
+ };
142
+ this.onChange = () => {
143
+ this.value = Object.assign({}, this.value, {
144
+ detail: this.detailInfo.value
145
+ });
146
+ this.props.setValue(this.value);
147
+ };
148
+ this.onClick = e => {
149
+ e.stopPropagation();
150
+ e.nativeEvent.stopImmediatePropagation();
151
+ };
152
+ this.onParseChange = () => {
153
+ if (this.timer) {
154
+ clearTimeout(this.timer);
155
+ this.timer = null;
156
+ }
157
+ this.timer = setTimeout(() => {
158
+ clearTimeout(this.timer);
159
+ this.timer = null;
160
+ const value = this.parseRef.value;
161
+ if (this.isComposing) return;
162
+ const {
163
+ province,
164
+ city,
165
+ district,
166
+ detail
167
+ } = (0, _parseGeolocation.default)(this.locations, value);
168
+ if (this.detailInfo) {
169
+ this.detailInfo.value = detail || '';
170
+ this.value = Object.assign({}, this.value, {
171
+ detail: this.detailInfo.value
172
+ });
173
+ }
174
+ this.props.setValue(this.value);
175
+ this.selectProvince(province);
176
+ if (!province) return;
177
+ this.selectCity(city);
178
+ if (!city) return;
179
+ this.selectCounty(district);
180
+ }, 100);
181
+ };
182
+ this.onCompositionStart = () => {
183
+ this.isComposing = true;
184
+ };
185
+ this.onCompositionEnd = () => {
186
+ this.isComposing = false;
187
+ };
188
+ this.onSubmit = () => {
189
+ const {
190
+ province,
191
+ city,
192
+ district
193
+ } = this.value;
194
+ if (!province || !city || !district) {
195
+ const errMessage = (0, _lang.getLocale)('Province/City/District_must_be_filled_in');
196
+ this.setState({
197
+ errMessage
198
+ });
199
+ return;
200
+ }
201
+ this.props.onSubmit();
202
+ };
203
+ this.createFooter = () => {
204
+ return /*#__PURE__*/_react.default.createElement(_reactstrap.ModalFooter, {
205
+ className: "dtable-ui-geolocation-editor-footer"
206
+ }, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
207
+ onClick: this.props.onCancel,
208
+ color: "secondary"
209
+ }, (0, _lang.getLocale)('Cancel')), /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
210
+ onClick: this.onSubmit,
211
+ color: "primary"
212
+ }, (0, _lang.getLocale)('Submit')));
213
+ };
214
+ this.value = props.value;
215
+ this.locations = {};
216
+ this.state = {
217
+ isShowSelector: false,
218
+ location: "".concat(this.value.province || '').concat(this.value.city || '').concat(this.value.district || ''),
219
+ selectedProvince: null,
220
+ selectedCity: null,
221
+ selectedCounty: null,
222
+ selectedItem: 'province',
223
+ isLoadingData: true,
224
+ errMessage: ''
225
+ };
226
+ this.isComposing = false;
227
+ this.timer = null;
228
+ }
229
+ UNSAFE_componentWillMount() {
230
+ if (!window.app.location) {
231
+ this.getLocationData().then(data => {
232
+ this.locations = data;
233
+ window.app.location = data;
234
+ const {
235
+ selectedProvince,
236
+ selectedCity,
237
+ selectedCounty,
238
+ selectedItem
239
+ } = this.initLocationSelecting(this.value);
240
+ this.setState({
241
+ isLoadingData: false,
242
+ selectedProvince,
243
+ selectedCity,
244
+ selectedCounty,
245
+ selectedItem
246
+ });
247
+ });
248
+ } else {
249
+ this.locations = window.app.location;
250
+ const {
251
+ selectedProvince,
252
+ selectedCity,
253
+ selectedCounty,
254
+ selectedItem
255
+ } = this.initLocationSelecting(this.value);
256
+ this.setState({
257
+ isLoadingData: false,
258
+ selectedProvince,
259
+ selectedCity,
260
+ selectedCounty,
261
+ selectedItem
262
+ });
263
+ }
264
+ }
265
+ render() {
266
+ const {
267
+ selectedItem,
268
+ selectedCity,
269
+ selectedProvince,
270
+ selectedCounty,
271
+ isShowSelector,
272
+ isLoadingData,
273
+ location
274
+ } = this.state;
275
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !isLoadingData ? /*#__PURE__*/_react.default.createElement("div", {
276
+ onClick: this.onClick,
277
+ className: "dtable-ui-geolocation-editor-content"
278
+ }, /*#__PURE__*/_react.default.createElement("div", {
279
+ className: "dtable-ui-geolocation-editor-item dtable-ui-geolocation-editor-selector-container"
280
+ }, /*#__PURE__*/_react.default.createElement("div", {
281
+ className: "dtable-ui-geolocation-editor-item-left"
282
+ }, (0, _lang.getLocale)('Address_information') + ':'), /*#__PURE__*/_react.default.createElement("div", {
283
+ className: "dtable-ui-geolocation-editor-item-right"
284
+ }, /*#__PURE__*/_react.default.createElement("div", {
285
+ onClick: this.onToggleSelector,
286
+ className: "dtable-ui-geolocation-editor-selector text-truncate ".concat(isShowSelector ? 'focus' : '')
287
+ }, /*#__PURE__*/_react.default.createElement("span", {
288
+ className: "selected-option-show"
289
+ }, location ? location : (0, _lang.getLocale)('Select_province_city_district')), /*#__PURE__*/_react.default.createElement("span", {
290
+ "aria-hidden": "true",
291
+ className: "dtable-font dtable-icon-down3 dtable-ui-geolocation-editor-parameter-icon"
292
+ }))), isShowSelector && /*#__PURE__*/_react.default.createElement("div", {
293
+ className: "geolocation-selector-container"
294
+ }, /*#__PURE__*/_react.default.createElement("div", {
295
+ className: "geolocation-selector-header"
296
+ }, /*#__PURE__*/_react.default.createElement(_selectorHeaderItem.default, {
297
+ type: "province",
298
+ clickHandler: this.selectSelectorType,
299
+ selectedType: selectedItem,
300
+ selectedItem: selectedProvince
301
+ }), /*#__PURE__*/_react.default.createElement(_selectorHeaderItem.default, {
302
+ type: "city",
303
+ clickHandler: this.selectSelectorType,
304
+ selectedType: selectedItem,
305
+ selectedItem: selectedCity
306
+ }), /*#__PURE__*/_react.default.createElement(_selectorHeaderItem.default, {
307
+ type: "county",
308
+ clickHandler: this.selectSelectorType,
309
+ selectedType: selectedItem,
310
+ selectedItem: selectedCounty
311
+ })), /*#__PURE__*/_react.default.createElement("div", {
312
+ className: "geolocation-selector-body"
313
+ }, selectedItem === 'province' && /*#__PURE__*/_react.default.createElement(_selectorList.default, {
314
+ type: "province",
315
+ parent: this.locations,
316
+ selectedItem: selectedProvince,
317
+ clickHandler: this.selectProvince
318
+ }), selectedItem === 'city' && /*#__PURE__*/_react.default.createElement(_selectorList.default, {
319
+ type: "city",
320
+ parent: selectedProvince,
321
+ selectedItem: selectedCity,
322
+ clickHandler: this.selectCity
323
+ }), selectedItem === 'county' && /*#__PURE__*/_react.default.createElement(_selectorList.default, {
324
+ type: "county",
325
+ parent: selectedCity,
326
+ selectedItem: selectedCounty,
327
+ clickHandler: this.selectCounty
328
+ })))), this.props.isShowAddressDetail && /*#__PURE__*/_react.default.createElement("div", {
329
+ className: "dtable-ui-geolocation-editor-item dtable-ui-geolocation-editor-detail"
330
+ }, /*#__PURE__*/_react.default.createElement("div", {
331
+ className: "dtable-ui-geolocation-editor-item-left"
332
+ }, (0, _lang.getLocale)('Detailed_address') + ':'), /*#__PURE__*/_react.default.createElement("div", {
333
+ className: "dtable-ui-geolocation-editor-item-right"
334
+ }, /*#__PURE__*/_react.default.createElement("textarea", {
335
+ ref: ref => this.detailInfo = ref,
336
+ placeholder: (0, _lang.getLocale)('Detailed_address_placeholder'),
337
+ className: "dtable-ui-geolocation-editor-detail-info",
338
+ type: "text",
339
+ onChange: this.onChange,
340
+ defaultValue: this.value.detail,
341
+ onKeyDown: this.onKeyDown,
342
+ autoFocus: true
343
+ }))), /*#__PURE__*/_react.default.createElement("div", {
344
+ className: "dtable-ui-geolocation-editor-item dtable-ui-geolocation-editor-parse"
345
+ }, /*#__PURE__*/_react.default.createElement("div", {
346
+ className: "dtable-ui-geolocation-editor-item-left"
347
+ }, (0, _lang.getLocale)('Auto_recognition') + ':'), /*#__PURE__*/_react.default.createElement("div", {
348
+ className: "dtable-ui-geolocation-editor-item-right"
349
+ }, /*#__PURE__*/_react.default.createElement("textarea", {
350
+ ref: ref => this.parseRef = ref,
351
+ placeholder: (0, _lang.getLocale)('Try_pasting_addresses_such_as_provinces/cities/districts_roads_neighborhoods_etc_to_quickly_identify_the_address_information'),
352
+ className: "dtable-ui-geolocation-editor-detail-info dtable-ui-geolocation-editor-recognition",
353
+ type: "text",
354
+ onChange: this.onParseChange,
355
+ onKeyDown: this.onKeyDown,
356
+ onCompositionEnd: this.onCompositionEnd,
357
+ onCompositionStart: this.onCompositionStart
358
+ })))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Loading.default, null), /*#__PURE__*/_react.default.createElement("div", {
359
+ style: {
360
+ textAlign: 'center'
361
+ }
362
+ }, (0, _lang.getLocale)('Loading_geolocation_data'))), this.state.errMessage && /*#__PURE__*/_react.default.createElement(_reactstrap.Alert, {
363
+ color: "danger",
364
+ className: "mt-2"
365
+ }, this.state.errMessage), this.createFooter());
366
+ }
367
+ }
368
+ var _default = exports.default = LocationEditor;