dtable-ui-component 5.3.1-beta1 → 6.0.0

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 (226) 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/LongTextFormatter/index.js +4 -7
  50. package/lib/MultipleSelectEditor/index.css +9 -0
  51. package/lib/MultipleSelectEditor/index.js +177 -16
  52. package/lib/NumberEditor/index.js +77 -64
  53. package/lib/RoleStatusEditor/index.js +5 -4
  54. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.css +1 -1
  55. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.js +1 -1
  56. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.css +6 -6
  57. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.js +1 -3
  58. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/row-expand-file-item-formatter.js +11 -10
  59. package/lib/RowExpandFormatter/index.css +0 -26
  60. package/lib/RowExpandFormatter/index.js +100 -84
  61. package/lib/{RowExpandFormatter/RowExpandFormulaFormatter → RowExpandFormulaFormatter}/index.js +10 -11
  62. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.css +6 -6
  63. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.js +1 -1
  64. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  65. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  66. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.js +5 -5
  67. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/utils.js +1 -1
  68. package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.css +1 -1
  69. package/lib/RowExpandUrlFormatter/index.css +1 -0
  70. package/lib/{RowExpandFormatter/RowExpandUrlFormatter → RowExpandUrlFormatter}/index.js +3 -4
  71. package/lib/SingleSelectEditor/index.css +14 -0
  72. package/lib/SingleSelectEditor/index.js +156 -16
  73. package/lib/TextEditor/index.js +42 -113
  74. package/lib/constants/index.js +2 -34
  75. package/lib/css/cell-editor.css +2 -18
  76. package/lib/index.js +46 -74
  77. package/lib/lang/index.js +14 -16
  78. package/lib/locals/de.js +103 -0
  79. package/lib/locals/en.js +104 -0
  80. package/lib/locals/es.js +103 -0
  81. package/lib/locals/fr.js +103 -0
  82. package/lib/locals/pt.js +103 -0
  83. package/lib/locals/ru.js +103 -0
  84. package/lib/locals/zh-CN.js +104 -0
  85. package/lib/select-editor/index.js +6 -6
  86. package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.js +3 -3
  87. package/lib/select-editor/pc-select-editor-popover/index.css +71 -0
  88. package/lib/select-editor/pc-select-editor-popover/index.js +122 -0
  89. package/lib/toaster/toaster.js +4 -3
  90. package/lib/utils/editor-utils.js +6 -1
  91. package/lib/utils/url.js +8 -119
  92. package/lib/utils/utils.js +2 -89
  93. package/package.json +13 -14
  94. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +0 -257
  95. package/lib/DeleteTip/index.js +0 -50
  96. package/lib/DigitalSignEditor/constants.js +0 -7
  97. package/lib/DigitalSignEditor/index.css +0 -69
  98. package/lib/DigitalSignEditor/index.js +0 -182
  99. package/lib/DigitalSignEditor/service.js +0 -38
  100. package/lib/DigitalSignEditor/signature-board/index.css +0 -35
  101. package/lib/DigitalSignEditor/signature-board/index.js +0 -135
  102. package/lib/DigitalSignEditor/signature-board/signature-tool.js +0 -396
  103. package/lib/DigitalSignEditor/utils.js +0 -29
  104. package/lib/DurationEditor/index.js +0 -111
  105. package/lib/EmailEditor/index.js +0 -59
  106. package/lib/FileEditor/addition-previewer/index.css +0 -1
  107. package/lib/FileEditor/addition-previewer/index.js +0 -52
  108. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +0 -1
  109. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +0 -252
  110. package/lib/FileEditor/constants.js +0 -7
  111. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +0 -74
  112. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +0 -5
  113. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +0 -77
  114. package/lib/FileEditor/files-previewer/file-previewer/index.css +0 -88
  115. package/lib/FileEditor/files-previewer/file-previewer/index.js +0 -167
  116. package/lib/FileEditor/files-previewer/index.css +0 -56
  117. package/lib/FileEditor/files-previewer/index.js +0 -277
  118. package/lib/FileEditor/index.css +0 -6
  119. package/lib/FileEditor/utils.js +0 -22
  120. package/lib/FileUploader/index.css +0 -9
  121. package/lib/GeolocationEditor/country-editor.js +0 -319
  122. package/lib/GeolocationEditor/index.css +0 -641
  123. package/lib/GeolocationEditor/index.js +0 -241
  124. package/lib/GeolocationEditor/location-editor.js +0 -368
  125. package/lib/GeolocationEditor/map-editor/index.js +0 -456
  126. package/lib/GeolocationEditor/map-editor/large-editor/index.css +0 -137
  127. package/lib/GeolocationEditor/map-editor/large-editor/index.js +0 -461
  128. package/lib/GeolocationEditor/map-editor-utils.js +0 -153
  129. package/lib/GeolocationEditor/map-selection-editor/index.js +0 -455
  130. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +0 -1
  131. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +0 -447
  132. package/lib/GeolocationEditor/parse-geolocation.js +0 -282
  133. package/lib/GeolocationEditor/province-city-editor.js +0 -292
  134. package/lib/GeolocationEditor/province-editor.js +0 -226
  135. package/lib/GeolocationEditor/selector-header-item.js +0 -28
  136. package/lib/GeolocationEditor/selector-list.js +0 -33
  137. package/lib/GeolocationEditor/with-ref.js +0 -27
  138. package/lib/ImageEditor/addition-previewer/image-link/index.css +0 -45
  139. package/lib/ImageEditor/addition-previewer/image-link/index.js +0 -73
  140. package/lib/ImageEditor/addition-previewer/index.css +0 -106
  141. package/lib/ImageEditor/addition-previewer/index.js +0 -63
  142. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +0 -125
  143. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +0 -254
  144. package/lib/ImageEditor/constants.js +0 -7
  145. package/lib/ImageEditor/images-previewer/image-preview/index.css +0 -59
  146. package/lib/ImageEditor/images-previewer/image-preview/index.js +0 -155
  147. package/lib/ImageEditor/images-previewer/index.css +0 -18
  148. package/lib/ImageEditor/images-previewer/index.js +0 -140
  149. package/lib/ImageEditor/index.css +0 -24
  150. package/lib/ImageEditor/index.js +0 -194
  151. package/lib/ImageThumbnail/index.css +0 -20
  152. package/lib/ImageThumbnail/index.js +0 -136
  153. package/lib/RowExpandDialog/body/index.css +0 -21
  154. package/lib/RowExpandDialog/body/index.js +0 -279
  155. package/lib/RowExpandDialog/column-content/index.css +0 -43
  156. package/lib/RowExpandDialog/column-content/index.js +0 -50
  157. package/lib/RowExpandDialog/constants.js +0 -114
  158. package/lib/RowExpandDialog/header/index.css +0 -31
  159. package/lib/RowExpandDialog/header/index.js +0 -33
  160. package/lib/RowExpandDialog/index.css +0 -24
  161. package/lib/RowExpandDialog/index.js +0 -272
  162. package/lib/RowExpandDialog/utils.js +0 -83
  163. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +0 -22
  164. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +0 -24
  165. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +0 -18
  166. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +0 -43
  167. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +0 -5
  168. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +0 -232
  169. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +0 -130
  170. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +0 -129
  171. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +0 -13
  172. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +0 -208
  173. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +0 -105
  174. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +0 -2
  175. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +0 -125
  176. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +0 -1
  177. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +0 -146
  178. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +0 -17
  179. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +0 -165
  180. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +0 -6
  181. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +0 -170
  182. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +0 -6
  183. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +0 -124
  184. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +0 -44
  185. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +0 -224
  186. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +0 -105
  187. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +0 -13
  188. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +0 -152
  189. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +0 -58
  190. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +0 -192
  191. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +0 -4
  192. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +0 -127
  193. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +0 -31
  194. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +0 -130
  195. package/lib/RowExpandEditor/constants.js +0 -44
  196. package/lib/RowExpandEditor/index.css +0 -0
  197. package/lib/RowExpandEditor/index.js +0 -32
  198. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +0 -27
  199. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +0 -1
  200. package/lib/RowExpandFormatter/constants.js +0 -60
  201. package/lib/UploadProgress/index.js +0 -38
  202. package/lib/UrlEditor/index.js +0 -62
  203. package/lib/common/editor-base.js +0 -53
  204. package/lib/constants/file.js +0 -96
  205. package/lib/constants/key-codes.js +0 -109
  206. package/lib/hooks/index.js +0 -16
  207. package/lib/locales/de.json +0 -163
  208. package/lib/locales/en.json +0 -163
  209. package/lib/locales/es.json +0 -163
  210. package/lib/locales/fr.json +0 -163
  211. package/lib/locales/pt.json +0 -163
  212. package/lib/locales/ru.json +0 -163
  213. package/lib/locales/zh-CN.json +0 -163
  214. package/lib/select-editor/pc-select-editor/index.css +0 -85
  215. package/lib/select-editor/pc-select-editor/index.js +0 -290
  216. package/lib/utils/cell-comparer.js +0 -35
  217. package/lib/utils/cell.js +0 -55
  218. package/lib/utils/column-utils.js +0 -25
  219. package/lib/utils/get-event-transfer.js +0 -75
  220. package/lib/utils/object-utils.js +0 -61
  221. /package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.css +0 -0
  222. /package/lib/CollaboratorEditor/{pc-collaborator-editor → pc-collaborator-editor-popover}/index.css +0 -0
  223. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.css +0 -0
  224. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/value-display-utils.js +0 -0
  225. /package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.js +0 -0
  226. /package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.css +0 -0
@@ -1,241 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _dtableUtils = require("dtable-utils");
10
- var _constants = require("../constants");
11
- var _withRef = _interopRequireDefault(require("./with-ref"));
12
- var _objectUtils = _interopRequireDefault(require("../utils/object-utils"));
13
- var _locationEditor = _interopRequireDefault(require("./location-editor"));
14
- var _mapEditor = _interopRequireDefault(require("./map-editor"));
15
- var _mapSelectionEditor = _interopRequireDefault(require("./map-selection-editor"));
16
- var _countryEditor = _interopRequireDefault(require("./country-editor"));
17
- var _provinceEditor = _interopRequireDefault(require("./province-editor"));
18
- var _provinceCityEditor = _interopRequireDefault(require("./province-city-editor"));
19
- require("./index.css");
20
- class GeolocationEditor extends _react.default.Component {
21
- constructor(_props) {
22
- super(_props);
23
- this.onHotKey = e => {
24
- if (e.keyCode === _constants.KeyCodes.Enter && e.target.tagName !== 'TEXTAREA') {
25
- this.onSubmit();
26
- } else if (e.keyCode === _constants.KeyCodes.Escape) {
27
- if (this.props.isInModal) {
28
- e.stopPropagation();
29
- this.onCancel();
30
- }
31
- }
32
- };
33
- this.getValue = () => {
34
- return this.value;
35
- };
36
- this.setValue = value => {
37
- this.value = value;
38
- };
39
- this.onSubmit = () => {
40
- if (_objectUtils.default.isSameObject(this.initValue, this.value)) {
41
- this.onCancel();
42
- return;
43
- }
44
- this.props.onCommit(this.value);
45
- };
46
- this.onCancel = () => {
47
- this.props.onCommitCancel && this.props.onCommitCancel();
48
- };
49
- this.setEditorPosition = () => {
50
- const {
51
- isInModal
52
- } = this.props;
53
- const editorFormat = this.getGeoFormat();
54
- if (this.ref && (editorFormat === _dtableUtils.GEOLOCATION_FORMAT.COUNTRY_REGION || editorFormat === _dtableUtils.GEOLOCATION_FORMAT.PROVINCE)) {
55
- let height = 240;
56
- let width = 200;
57
- let left = this.ref.parentNode.getBoundingClientRect().x;
58
- let top = this.ref.parentNode.getBoundingClientRect().y;
59
- if (isInModal) {
60
- left = 220;
61
- }
62
- if (top + height > window.innerHeight) {
63
- top = window.innerHeight - height - 35;
64
- }
65
- this.setState({
66
- editorPosition: {
67
- top,
68
- left,
69
- width,
70
- zIndex: 1000,
71
- position: 'fixed'
72
- }
73
- });
74
- return;
75
- }
76
- if (this.ref && editorFormat === _dtableUtils.GEOLOCATION_FORMAT.PROVINCE_CITY) {
77
- let height = 215;
78
- let width = 400;
79
- let left = this.ref.parentNode.getBoundingClientRect().x;
80
- let top = this.ref.parentNode.getBoundingClientRect().y;
81
- if (isInModal) {
82
- left = 220;
83
- if (top + height + 35 + 200 > window.innerHeight) {
84
- top = window.innerHeight - height - 235;
85
- }
86
- } else {
87
- if (top + height + 200 > window.innerHeight) {
88
- top = window.innerHeight - height - 200 - 5;
89
- }
90
- if (left + width > window.innerWidth) {
91
- left = window.innerWidth - width - 10;
92
- }
93
- }
94
- this.setState({
95
- editorPosition: {
96
- top,
97
- left,
98
- width,
99
- zIndex: 1000,
100
- position: 'fixed'
101
- }
102
- });
103
- return;
104
- }
105
- if (this.ref) {
106
- const isMapTypeEditor = editorFormat === _dtableUtils.GEOLOCATION_FORMAT.LNG_LAT || editorFormat === _dtableUtils.GEOLOCATION_FORMAT.MAP_SELECTION;
107
- let width = isMapTypeEditor ? 500 : 400;
108
- let height = isMapTypeEditor ? 454 : 310;
109
- let geoEditorTop = 0;
110
- let geoEditorLeft = 0;
111
- if (isInModal) {
112
- let innerHeight = window.innerHeight;
113
- const offsetTop = this.ref.parentNode.getBoundingClientRect().y;
114
- geoEditorTop = offsetTop;
115
- geoEditorTop = height + geoEditorTop > innerHeight ? innerHeight - height - 30 : geoEditorTop;
116
- geoEditorLeft = -30;
117
- } else {
118
- let {
119
- offsetLeft,
120
- offsetTop
121
- } = this.ref.parentNode;
122
- geoEditorLeft = offsetLeft - width;
123
- geoEditorTop = offsetTop;
124
- if (offsetLeft < width) {
125
- geoEditorLeft = offsetLeft + this.props.column.width;
126
- }
127
- if (geoEditorLeft + width > window.innerWidth) {
128
- geoEditorLeft = window.innerWidth - width;
129
- }
130
- if (offsetTop + height > window.innerHeight) {
131
- geoEditorTop = window.innerHeight - height;
132
- }
133
- }
134
- this.setState({
135
- editorPosition: {
136
- top: geoEditorTop,
137
- left: geoEditorLeft,
138
- zIndex: 1000,
139
- position: 'fixed'
140
- }
141
- });
142
- }
143
- };
144
- this.getGeoFormat = () => {
145
- const {
146
- column
147
- } = this.props;
148
- let data = column.data || {};
149
- return data.geo_format ? data.geo_format : _dtableUtils.DEFAULT_GEOLOCATION_FORMAT;
150
- };
151
- this.getLargeEditorState = () => {
152
- var _this$editor, _this$editor$state;
153
- 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;
154
- };
155
- this.createEditor = () => {
156
- const geoFormat = this.getGeoFormat();
157
- const {
158
- config,
159
- column
160
- } = this.props;
161
- const props = {
162
- column,
163
- config,
164
- value: this.value,
165
- setValue: this.setValue,
166
- onSubmit: this.onSubmit,
167
- onCancel: this.onCancel
168
- };
169
- switch (geoFormat) {
170
- case _dtableUtils.GEOLOCATION_FORMAT.LNG_LAT:
171
- {
172
- return /*#__PURE__*/_react.default.createElement(_mapEditor.default, Object.assign({}, props, {
173
- ref: ref => this.editor = ref
174
- }));
175
- }
176
- case _dtableUtils.GEOLOCATION_FORMAT.MAP_SELECTION:
177
- {
178
- return /*#__PURE__*/_react.default.createElement(_mapSelectionEditor.default, Object.assign({}, props, {
179
- ref: ref => this.editor = ref
180
- }));
181
- }
182
- case _dtableUtils.GEOLOCATION_FORMAT.COUNTRY_REGION:
183
- {
184
- return /*#__PURE__*/_react.default.createElement(_countryEditor.default, Object.assign({}, props, {
185
- ref: ref => this.editor = ref
186
- }));
187
- }
188
- case _dtableUtils.GEOLOCATION_FORMAT.PROVINCE:
189
- {
190
- return /*#__PURE__*/_react.default.createElement(_provinceEditor.default, Object.assign({}, props, {
191
- onPressTab: this.props.onPressTab,
192
- ref: ref => this.editor = ref
193
- }));
194
- }
195
- case _dtableUtils.GEOLOCATION_FORMAT.PROVINCE_CITY:
196
- {
197
- return /*#__PURE__*/_react.default.createElement(_provinceCityEditor.default, Object.assign({}, props, {
198
- ref: ref => this.editor = ref
199
- }));
200
- }
201
- case _dtableUtils.GEOLOCATION_FORMAT.PROVINCE_CITY_DISTRICT:
202
- {
203
- return /*#__PURE__*/_react.default.createElement(_locationEditor.default, Object.assign({}, props, {
204
- ref: ref => this.editor = ref
205
- }));
206
- }
207
- default:
208
- {
209
- return /*#__PURE__*/_react.default.createElement(_locationEditor.default, Object.assign({}, props, {
210
- isShowAddressDetail: true,
211
- ref: ref => this.editor = ref
212
- }));
213
- }
214
- }
215
- };
216
- this.value = _props.value || {};
217
- this.initValue = this.value;
218
- this.state = {
219
- editorPosition: null
220
- };
221
- this.editor = null;
222
- }
223
- componentDidMount() {
224
- this.setEditorPosition();
225
- document.addEventListener('keydown', this.onHotKey, true);
226
- }
227
- componentWillUnmount() {
228
- document.removeEventListener('keydown', this.onHotKey, true);
229
- }
230
- render() {
231
- const {
232
- editorPosition
233
- } = this.state;
234
- return /*#__PURE__*/_react.default.createElement("div", {
235
- ref: ref => this.ref = ref,
236
- style: editorPosition,
237
- className: "dtable-ui-dtable-ui-geolocation-editor"
238
- }, this.createEditor());
239
- }
240
- }
241
- var _default = exports.default = (0, _withRef.default)(GeolocationEditor);
@@ -1,368 +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 _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;