dtable-ui-component 6.0.36 → 6.0.37-beta

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.
@@ -1,9 +1,12 @@
1
1
  .dtable-ui-mobile-geolocation-map-editor .dtable-ui-mobile-geolocation-map-editor-input-container {
2
- height: 60px;
3
- padding-top: 16px;
2
+ height: auto;
4
3
  width: 100%;
5
4
  }
6
5
 
6
+ .dtable-ui-mobile-geolocation-map-editor .dtable-ui-mobile-geolocation-map-editor-input-container .view-subtitle:first-child {
7
+ border-top: 0;
8
+ }
9
+
7
10
  .dtable-ui-mobile-geolocation-map-editor .dtable-ui-mobile-geolocation-map-editor-map {
8
11
  flex: 1;
9
12
  overflow: hidden;
@@ -184,8 +184,7 @@ class MapEditor extends _react.default.Component {
184
184
  value: {
185
185
  lng: point.lng,
186
186
  lat: point.lat
187
- },
188
- inputValue: _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? "".concat(point.lng, ", ").concat(point.lat) : "".concat(point.lat, ", ").concat(point.lng)
187
+ }
189
188
  });
190
189
  };
191
190
  this.addMarkerByPosition = (lng, lat) => {
@@ -329,8 +328,8 @@ class MapEditor extends _react.default.Component {
329
328
  this.renderMap = () => {
330
329
  const {
331
330
  isLoading,
332
- inputValue,
333
- mode
331
+ mode,
332
+ value
334
333
  } = this.state;
335
334
  if (isLoading) return /*#__PURE__*/_react.default.createElement("div", {
336
335
  className: "w-100 h-100 d-flex align-items-center justify-content-center"
@@ -343,18 +342,36 @@ class MapEditor extends _react.default.Component {
343
342
  }, (0, _lang.getLocale)('The_map_plugin_is_not_properly_configured_contact_the_administrator')));
344
343
  }
345
344
  const isEdit = mode === 'edit';
345
+ const {
346
+ lat,
347
+ lng
348
+ } = value;
346
349
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
347
350
  className: "dtable-ui-mobile-geolocation-map-editor-input-container"
348
- }, /*#__PURE__*/_react.default.createElement(_InputItem.default, {
351
+ }, /*#__PURE__*/_react.default.createElement("div", {
352
+ className: "view-subtitle"
353
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Latitude_abbr'))), /*#__PURE__*/_react.default.createElement(_InputItem.default, {
354
+ type: "text",
355
+ className: "dtable-ui-mobile-geolocation-map-editor-input",
356
+ style: {
357
+ marginTop: 0
358
+ },
359
+ value: lat,
360
+ editable: isEdit,
361
+ onChange: this.handleLatitudeChange,
362
+ placeholder: (0, _lang.getLocale)('Enter_latitude')
363
+ }), /*#__PURE__*/_react.default.createElement("div", {
364
+ className: "view-subtitle"
365
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Longitude_abbr'))), /*#__PURE__*/_react.default.createElement(_InputItem.default, {
349
366
  type: "text",
350
367
  className: "dtable-ui-mobile-geolocation-map-editor-input",
351
368
  style: {
352
369
  marginTop: 0
353
370
  },
354
- value: inputValue,
371
+ value: lng,
355
372
  editable: isEdit,
356
- onChange: this.onChange,
357
- placeholder: _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? (0, _lang.getLocale)('Enter_longitude_and_latitude') : (0, _lang.getLocale)('Enter_latitude_and_longitude')
373
+ onChange: this.handleLongitudeChange,
374
+ placeholder: (0, _lang.getLocale)('Enter_longitude')
358
375
  })), /*#__PURE__*/_react.default.createElement("div", {
359
376
  className: "dtable-ui-mobile-geolocation-map-editor-map"
360
377
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -384,23 +401,21 @@ class MapEditor extends _react.default.Component {
384
401
  className: "dtable-font dtable-icon-narrow"
385
402
  }))))));
386
403
  };
387
- const _value = props.value || {};
404
+ const _value = props.value || {
405
+ lng: '',
406
+ lat: ''
407
+ };
388
408
  const {
389
409
  mapType,
390
410
  mapKey
391
411
  } = (0, _mapEditorUtils.getMapInfo)(props.config);
392
412
  this.mapType = mapType;
393
413
  this.mapKey = mapKey;
394
- const {
395
- lng: _lng,
396
- lat: _lat
397
- } = _value;
398
414
  this.map = null;
399
415
  this.state = {
400
416
  mode: 'preview',
401
417
  isLoading: true,
402
- value: _value,
403
- inputValue: (0, _cell.isValidPosition)(_lng, _lat) ? _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? "".concat(_lng, ", ").concat(_lat) : "".concat(_lat, ", ").concat(_lng) : ''
418
+ value: _value
404
419
  };
405
420
  }
406
421
  componentDidMount() {
@@ -204,22 +204,22 @@
204
204
  width: 92%;
205
205
  }
206
206
 
207
- .dtable-ui-geolocation-map-editor .search-tables-input {
207
+ .dtable-ui-geolocation-map-editor .selection-input {
208
208
  padding-right: 30px;
209
209
  border-bottom: 0;
210
210
  background: #fff;
211
- border-radius: 3px;
212
211
  border: 1px solid #dedede;
213
- box-shadow: 0 -0 12px rgb(0 0 0 / 30%);
214
- }
215
-
216
- .dtable-ui-geolocation-map-editor .search-tables-input.selection-input {
217
212
  width: 88%;
218
213
  box-shadow: 0 -0 2px rgb(0 0 0 / 30%);
219
214
  border-radius: 3px 0px 0px 3px;
220
215
  border-right: none;
221
216
  }
222
217
 
218
+ .dtable-ui-geolocation-map-editor .selection-input:focus {
219
+ border-color: #bdbdbd;
220
+ box-shadow: 0 -0 3px rgb(0 0 0 / 30%);
221
+ }
222
+
223
223
  .dtable-ui-geolocation-submit-map-editor {
224
224
  display: inline-block;
225
225
  height: 38px;
@@ -425,15 +425,6 @@
425
425
  text-align: center;
426
426
  }
427
427
 
428
- .dtable-ui-geolocation-map-editor .search-tables-input:focus {
429
- border-color: #bdbdbd;
430
- box-shadow: 0 -0 12px rgb(0 0 0 / 30%);
431
- }
432
-
433
- .dtable-ui-geolocation-map-editor .selection-input:focus {
434
- box-shadow: 0 -0 3px rgb(0 0 0 / 30%);
435
- }
436
-
437
428
  .dtable-ui-geolocation-map-editor-error-message {
438
429
  word-break: break-all;
439
430
  padding: 10px;
@@ -157,7 +157,8 @@ class PCGeolocationEditor extends _react.default.Component {
157
157
  config,
158
158
  column,
159
159
  getCountryData,
160
- getLocationData
160
+ getLocationData,
161
+ toggleLargeMap
161
162
  } = this.props;
162
163
  const props = {
163
164
  column,
@@ -171,12 +172,14 @@ class PCGeolocationEditor extends _react.default.Component {
171
172
  case _dtableUtils.GEOLOCATION_FORMAT.LNG_LAT:
172
173
  {
173
174
  return /*#__PURE__*/_react.default.createElement(_mapEditor.default, Object.assign({}, props, {
175
+ toggleLargeMap: toggleLargeMap,
174
176
  ref: ref => this.editor = ref
175
177
  }));
176
178
  }
177
179
  case _dtableUtils.GEOLOCATION_FORMAT.MAP_SELECTION:
178
180
  {
179
181
  return /*#__PURE__*/_react.default.createElement(_mapSelectionEditor.default, Object.assign({}, props, {
182
+ toggleLargeMap: toggleLargeMap,
180
183
  ref: ref => this.editor = ref
181
184
  }));
182
185
  }
@@ -0,0 +1,33 @@
1
+ .dtable-ui-geolocation-map-lng-lat-editor-header {
2
+ display: flex;
3
+ flex-direction: row;
4
+ gap: 8px;
5
+ padding: 1rem;
6
+ flex-shrink: 0;
7
+ }
8
+
9
+ .dtable-ui-geolocation-map-lng-lat-editor-header .dtable-ui-geolocation-map-lng-lat-input-container {
10
+ display: flex;
11
+ flex: 1 1;
12
+ }
13
+
14
+ .dtable-ui-geolocation-map-lng-lat-input-label {
15
+ align-items: center;
16
+ background-color: #f8f9fa;
17
+ border: 1px solid #0028641f;
18
+ border-bottom-left-radius: 3px;
19
+ border-right: none;
20
+ border-top-left-radius: 3px;
21
+ display: flex;
22
+ justify-content: center;
23
+ padding: .375rem .75rem;
24
+ }
25
+
26
+ .dtable-ui-geolocation-map-lng-lat-input-container input {
27
+ border-bottom-left-radius: 0;
28
+ border-top-left-radius: 0;
29
+ flex: 1 1;
30
+ position: relative;
31
+ z-index: 0;
32
+ }
33
+
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
+ var _dtableUtils = require("dtable-utils");
10
11
  var _toaster = _interopRequireDefault(require("../../../toaster"));
11
12
  var _Loading = _interopRequireDefault(require("../../../Loading"));
12
13
  var _constants = require("../../../constants");
@@ -14,9 +15,36 @@ var _cell = require("../../../utils/cell");
14
15
  var _mapEditorUtils = require("../../map-editor-utils");
15
16
  var _largeEditor = _interopRequireDefault(require("./large-editor"));
16
17
  var _lang = require("../../../lang");
18
+ require("./index.css");
17
19
  class MapEditor extends _react.Component {
18
20
  constructor(props) {
19
21
  super(props);
22
+ this.initMap = () => {
23
+ if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
24
+ if (!window.BMap) {
25
+ window.renderBaiduMap = () => this.renderBaiduMap();
26
+ (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
27
+ } else {
28
+ this.renderBaiduMap();
29
+ }
30
+ return;
31
+ } else if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP) {
32
+ if (!window.google) {
33
+ window.renderGoogleMap = () => this.renderGoogleMap();
34
+ (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
35
+ } else {
36
+ this.renderGoogleMap();
37
+ }
38
+ return;
39
+ } else if (this.mapType === _mapEditorUtils.MAP_TYPES.M_MAP) {
40
+ if (!window.minemap) {
41
+ (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey, this.loadMineMapCallBack);
42
+ } else {
43
+ this.renderMineMap();
44
+ }
45
+ return;
46
+ }
47
+ };
20
48
  this.loadMineMapCallBack = () => {
21
49
  if (!this.timer) {
22
50
  this.timer = setTimeout(() => {
@@ -175,12 +203,43 @@ class MapEditor extends _react.Component {
175
203
  value: {
176
204
  lng: point.lng,
177
205
  lat: point.lat
178
- },
179
- inputValue: _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? "".concat(point.lng, ", ").concat(point.lat) : "".concat(point.lat, ", ").concat(point.lng)
206
+ }
180
207
  }, () => {
181
- this.props.setValue(this.state.value);
208
+ const numericValue = this.getNumericValue(this.state.value);
209
+ this.setPropsValue(numericValue);
182
210
  });
183
211
  };
212
+ this.getNumericValue = value => {
213
+ const {
214
+ lng,
215
+ lat
216
+ } = value || {};
217
+ const numLng = typeof lng === 'string' ? parseFloat(lng.trim()) : lng;
218
+ const numLat = typeof lat === 'string' ? parseFloat(lat.trim()) : lat;
219
+ return {
220
+ lng: numLng,
221
+ lat: numLat
222
+ };
223
+ };
224
+ this.setPropsValue = _ref => {
225
+ let {
226
+ lng,
227
+ lat
228
+ } = _ref;
229
+ if (!(0, _dtableUtils.isNumber)(lng) || !(0, _dtableUtils.isNumber)(lat)) {
230
+ this.props.setValue(this.props.value);
231
+ return;
232
+ }
233
+ const newValue = {
234
+ lng,
235
+ lat
236
+ };
237
+ this.setState({
238
+ value: newValue
239
+ });
240
+ this.props.setValue(newValue);
241
+ this.rerenderMapMarker(newValue);
242
+ };
184
243
  this.addMarkerByPosition = (lng, lat) => {
185
244
  if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
186
245
  let point = new window.BMap.Point(lng, lat);
@@ -233,62 +292,60 @@ class MapEditor extends _react.Component {
233
292
  const {
234
293
  value
235
294
  } = this.state;
236
- this.props.setValue(value);
295
+ const numericValue = this.getNumericValue(value);
296
+ this.setPropsValue(numericValue);
237
297
  this.setState({
238
298
  isShowLargeEditor: !this.state.isShowLargeEditor
239
- });
240
- };
241
- this.clearSearchNumerical = () => {
242
- this.setState({
243
- inputValue: '',
244
- value: {}
299
+ }, () => {
300
+ const nextState = this.state.isShowLargeEditor;
301
+ if (!nextState) {
302
+ this.initMap();
303
+ }
304
+ this.props.toggleLargeMap && this.props.toggleLargeMap(nextState);
245
305
  });
246
306
  };
247
307
  this.onSubmit = () => {
248
- const {
249
- value
250
- } = this.state;
251
- this.props.setValue(value);
252
308
  this.props.onSubmit();
253
309
  };
254
- this.onChange = e => {
255
- const inputValue = e.target.value;
256
- this.setState({
257
- inputValue
258
- });
259
- const enSplitCodeIndex = inputValue.indexOf(',');
260
- const cnSplitCodeIndex = inputValue.indexOf(',');
261
- if (enSplitCodeIndex > 0 || cnSplitCodeIndex > 0) {
262
- let lng;
263
- let lat;
264
- const splitCodeIndex = enSplitCodeIndex > 0 ? enSplitCodeIndex : cnSplitCodeIndex;
265
- if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP) {
266
- lat = parseFloat(inputValue.slice(0, splitCodeIndex).trim());
267
- lng = parseFloat(inputValue.slice(splitCodeIndex + 1).trim());
268
- } else {
269
- lng = parseFloat(inputValue.slice(0, splitCodeIndex).trim());
270
- lat = parseFloat(inputValue.slice(splitCodeIndex + 1).trim());
271
- }
272
- if (!Number.isNaN(lng) && !Number.isNaN(lat)) {
273
- this.setState({
274
- value: {
275
- lng,
276
- lat
277
- }
310
+ this.rerenderMapMarker = _ref2 => {
311
+ let {
312
+ lng,
313
+ lat
314
+ } = _ref2;
315
+ if (!(0, _dtableUtils.isNumber)(lng) || !(0, _dtableUtils.isNumber)(lat)) return;
316
+ if (this.map) {
317
+ if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP || this.mapType === _mapEditorUtils.MAP_TYPES.M_MAP) {
318
+ this.map.setCenter({
319
+ lng,
320
+ lat
278
321
  });
279
- if (this.map) {
280
- if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP || this.mapType === _mapEditorUtils.MAP_TYPES.M_MAP) {
281
- this.map.setCenter({
282
- lng,
283
- lat
284
- });
285
- } else {
286
- this.map.setCenter(new window.BMap.Point(lng, lat));
287
- }
288
- }
289
- this.addMarkerByPosition(lng, lat);
322
+ } else {
323
+ this.map.setCenter(new window.BMap.Point(lng, lat));
290
324
  }
291
325
  }
326
+ this.addMarkerByPosition(lng, lat);
327
+ };
328
+ this.onChangeLatitude = event => {
329
+ this.setState({
330
+ value: {
331
+ ...this.state.value,
332
+ lat: event.target.value
333
+ }
334
+ }, () => {
335
+ const numericValue = this.getNumericValue(this.state.value);
336
+ this.setPropsValue(numericValue);
337
+ });
338
+ };
339
+ this.onChangeLongitude = event => {
340
+ this.setState({
341
+ value: {
342
+ ...this.state.value,
343
+ lng: event.target.value
344
+ }
345
+ }, () => {
346
+ const numericValue = this.getNumericValue(this.state.value);
347
+ this.setPropsValue(numericValue);
348
+ });
292
349
  };
293
350
  this.onKeyDown = event => {
294
351
  event.stopPropagation();
@@ -310,7 +367,10 @@ class MapEditor extends _react.Component {
310
367
  this.onLocateCurrentPosition = () => {
311
368
  (0, _mapEditorUtils.locateCurrentPosition)(this.map, this.mapType, this.geolocationCallback);
312
369
  };
313
- const _value = props.value || {};
370
+ const _value = props.value || {
371
+ lng: '',
372
+ lat: ''
373
+ };
314
374
  const {
315
375
  mapType,
316
376
  mapKey
@@ -318,44 +378,15 @@ class MapEditor extends _react.Component {
318
378
  this.mapType = mapType;
319
379
  this.mapKey = mapKey;
320
380
  this.readOnly = props.readOnly;
321
- const {
322
- lng: _lng,
323
- lat: _lat
324
- } = _value;
325
- const _inputValue = (0, _cell.isValidPosition)(_lng, _lat) ? _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? "".concat(_lng, ", ").concat(_lat) : "".concat(_lat, ", ").concat(_lng) : '';
326
381
  this.map = null;
327
382
  this.state = {
328
383
  isLoading: true,
329
- value: props.value,
330
- inputValue: _inputValue,
384
+ value: _value,
331
385
  isShowLargeEditor: false
332
386
  };
333
387
  }
334
388
  componentDidMount() {
335
- if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
336
- if (!window.BMap) {
337
- window.renderBaiduMap = () => this.renderBaiduMap();
338
- (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
339
- } else {
340
- this.renderBaiduMap();
341
- }
342
- return;
343
- } else if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP) {
344
- if (!window.google) {
345
- window.renderGoogleMap = () => this.renderGoogleMap();
346
- (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
347
- } else {
348
- this.renderGoogleMap();
349
- }
350
- return;
351
- } else if (this.mapType === _mapEditorUtils.MAP_TYPES.M_MAP) {
352
- if (!window.minemap) {
353
- (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey, this.loadMineMapCallBack);
354
- } else {
355
- this.renderMineMap();
356
- }
357
- return;
358
- }
389
+ this.initMap();
359
390
  }
360
391
  componentWillUnmount() {
361
392
  let center = {};
@@ -376,13 +407,16 @@ class MapEditor extends _react.Component {
376
407
  localStorage.setItem('geolocation-map-center', JSON.stringify(center));
377
408
  this.map = null;
378
409
  this.props.toggleLargeMap && this.props.toggleLargeMap(false);
410
+ this.onSubmit();
379
411
  }
380
412
  render() {
381
413
  const {
382
414
  isLoading,
383
- inputValue,
415
+ value,
384
416
  isShowLargeEditor
385
417
  } = this.state;
418
+ const lat = value ? value.lat : '';
419
+ const lng = value ? value.lng : '';
386
420
  if (!isShowLargeEditor) {
387
421
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
388
422
  className: "dtable-ui-geolocation-map-editor-header"
@@ -398,24 +432,31 @@ class MapEditor extends _react.Component {
398
432
  })), /*#__PURE__*/_react.default.createElement("div", {
399
433
  className: "dtable-ui-geolocation-map-editor"
400
434
  }, !this.readOnly && /*#__PURE__*/_react.default.createElement("div", {
401
- className: "map-editor-header"
435
+ className: "dtable-ui-geolocation-map-lng-lat-editor-header"
436
+ }, /*#__PURE__*/_react.default.createElement("div", {
437
+ className: "dtable-ui-geolocation-map-lng-lat-input-container map-lat-input-container"
402
438
  }, /*#__PURE__*/_react.default.createElement("div", {
403
- className: "search-tables-container"
404
- }, /*#__PURE__*/_react.default.createElement("input", {
439
+ className: "dtable-ui-geolocation-map-lng-lat-input-label"
440
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Latitude_abbr'))), /*#__PURE__*/_react.default.createElement("input", {
405
441
  type: "text",
406
- value: inputValue,
442
+ value: lat,
443
+ onChange: this.onChangeLatitude,
407
444
  onKeyDown: this.onKeyDown,
408
- onChange: this.onChange,
409
- className: "form-control search-tables-input",
410
- placeholder: _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? (0, _lang.getLocale)('Enter_longitude_and_latitude') : (0, _lang.getLocale)('Enter_latitude_and_longitude'),
445
+ className: "form-control",
446
+ placeholder: (0, _lang.getLocale)('Enter_latitude'),
411
447
  autoFocus: true
412
- }), inputValue && /*#__PURE__*/_react.default.createElement("span", {
413
- className: "clear-search-numerical dtable-font dtable-icon-x-",
414
- onClick: this.clearSearchNumerical
415
- })), /*#__PURE__*/_react.default.createElement("span", {
416
- className: "dtable-ui-geolocation-submit-map-editor",
417
- onClick: this.onSubmit
418
- }, (0, _lang.getLocale)('Submit'))), /*#__PURE__*/_react.default.createElement("div", {
448
+ })), /*#__PURE__*/_react.default.createElement("div", {
449
+ className: "dtable-ui-geolocation-map-lng-lat-input-container map-lng-input-container"
450
+ }, /*#__PURE__*/_react.default.createElement("div", {
451
+ className: "dtable-ui-geolocation-map-lng-lat-input-label"
452
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Longitude_abbr'))), /*#__PURE__*/_react.default.createElement("input", {
453
+ type: "text",
454
+ value: lng,
455
+ onChange: this.onChangeLongitude,
456
+ onKeyDown: this.onKeyDown,
457
+ className: "form-control",
458
+ placeholder: (0, _lang.getLocale)('Enter_longitude')
459
+ }))), /*#__PURE__*/_react.default.createElement("div", {
419
460
  className: this.readOnly ? 'geolocation-map-read-only-container' : 'geolocation-map-container'
420
461
  }, this.mapType && isLoading && /*#__PURE__*/_react.default.createElement(_Loading.default, null), !this.mapType && /*#__PURE__*/_react.default.createElement("div", {
421
462
  className: "error-message d-flex justify-content-center mt-9"
@@ -449,6 +490,8 @@ class MapEditor extends _react.Component {
449
490
  }))))));
450
491
  }
451
492
  return /*#__PURE__*/_react.default.createElement(_largeEditor.default, Object.assign({}, this.props, {
493
+ value: value,
494
+ setValue: this.setValue,
452
495
  toggleFullScreen: this.toggleFullScreen
453
496
  }));
454
497
  }
@@ -12,10 +12,13 @@
12
12
  width: 100%;
13
13
  flex: 1;
14
14
  position: relative;
15
+ display: flex;
16
+ flex-direction: column;
15
17
  }
16
18
 
17
19
  .dtable-ui-large-map-editor-dialog .geolocation-map-container-large {
18
- height: 100%;
20
+ flex: 1;
21
+ overflow: hidden;
19
22
  display: flex;
20
23
  align-items: center;
21
24
  text-align: center;
@@ -50,14 +53,19 @@
50
53
  position: relative;
51
54
  }
52
55
 
53
- .dtable-ui-large-map-editor-dialog .dtable-ui-geolocation-map-editor-large .search-tables-input {
54
- line-height: 38px;
56
+ .dtable-ui-large-map-editor-dialog .selection-input-large {
55
57
  padding-right: 30px;
56
58
  border-bottom: 0;
57
59
  background: #fff;
58
- border-radius: 3px;
59
60
  border: 1px solid #dedede;
60
- box-shadow: 0 -0 12px rgb(0 0 0 / 30%);
61
+ border-right: none;
62
+ border-radius: 2px 0 0 2px;
63
+ box-shadow: 0 -0 2px rgb(0 0 0 / 30%);
64
+ width: 415px;
65
+ }
66
+
67
+ .dtable-ui-large-map-editor-dialog .selection-input-large:focus {
68
+ box-shadow: 0 0 3px #0000004d;
61
69
  }
62
70
 
63
71
  .clear-search-numerical {
@@ -77,12 +85,6 @@
77
85
  box-shadow: 0 -0 12px rgb(0 0 0 / 30%);
78
86
  }
79
87
 
80
- .dtable-ui-geolocation-map-editor-large .search-tables-input.selection-input-large {
81
- width: 415px;
82
- box-shadow: 0 -0 2px rgb(0 0 0 / 30%);
83
- border-radius: 2px 0px 0px 2px;
84
- }
85
-
86
88
  .dtable-ui-geolocation-map-editor-large .selection-input-large:focus {
87
89
  box-shadow: 0 -0 3px rgb(0 0 0 / 30%);
88
90
  }
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactstrap = require("reactstrap");
10
+ var _dtableUtils = require("dtable-utils");
10
11
  var _toaster = _interopRequireDefault(require("../../../../toaster"));
11
12
  var _Loading = _interopRequireDefault(require("../../../../Loading"));
12
13
  var _constants = require("../../../../constants");
@@ -168,14 +169,42 @@ class LargeMapEditorDialog extends _react.default.Component {
168
169
  _toaster.default.danger((0, _lang.getLocale)('Positioning_failed'));
169
170
  }
170
171
  };
172
+ this.getNumericValue = value => {
173
+ const {
174
+ lng,
175
+ lat
176
+ } = value || {};
177
+ const numLng = typeof lng === 'string' ? parseFloat(lng.trim()) : lng;
178
+ const numLat = typeof lat === 'string' ? parseFloat(lat.trim()) : lat;
179
+ return {
180
+ lng: numLng,
181
+ lat: numLat
182
+ };
183
+ };
184
+ this.setPropsValue = _ref => {
185
+ let {
186
+ lng,
187
+ lat
188
+ } = _ref;
189
+ if (!(0, _dtableUtils.isNumber)(lng) || !(0, _dtableUtils.isNumber)(lat)) {
190
+ this.props.setValue(this.props.value);
191
+ return;
192
+ }
193
+ this.props.setValue({
194
+ lng,
195
+ lat
196
+ });
197
+ };
171
198
  this.setValue = point => {
172
199
  const value = {
173
200
  lng: point.lng,
174
201
  lat: point.lat
175
202
  };
176
203
  this.setState({
177
- value,
178
- inputValue: _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? "".concat(point.lng, ", ").concat(point.lat) : "".concat(point.lat, ", ").concat(point.lng)
204
+ value
205
+ }, () => {
206
+ const numericValue = this.getNumericValue(this.state.value);
207
+ this.setPropsValue(numericValue);
179
208
  });
180
209
  };
181
210
  this.addMarkerByPosition = (lng, lat) => {
@@ -223,46 +252,47 @@ class LargeMapEditorDialog extends _react.default.Component {
223
252
  }
224
253
  }
225
254
  };
226
- this.onChange = e => {
227
- const inputValue = e.target.value;
228
- this.setState({
229
- inputValue
230
- });
231
- const enSplitCodeIndex = inputValue.indexOf(',');
232
- const cnSplitCodeIndex = inputValue.indexOf(',');
233
- if (enSplitCodeIndex > 0 || cnSplitCodeIndex > 0) {
234
- let lng;
235
- let lat;
236
- const splitCodeIndex = enSplitCodeIndex > 0 ? enSplitCodeIndex : cnSplitCodeIndex;
237
- if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP) {
238
- lat = parseFloat(inputValue.slice(0, splitCodeIndex).trim());
239
- lng = parseFloat(inputValue.slice(splitCodeIndex + 1).trim());
240
- } else {
241
- lng = parseFloat(inputValue.slice(0, splitCodeIndex).trim());
242
- lat = parseFloat(inputValue.slice(splitCodeIndex + 1).trim());
243
- }
244
- if (!Number.isNaN(lng) && !Number.isNaN(lat)) {
245
- this.setState({
246
- value: {
247
- lng,
248
- lat
249
- }
250
- }, () => {
251
- this.props.setValue(this.state.value);
255
+ this.rerenderMapMarker = _ref2 => {
256
+ let {
257
+ lng,
258
+ lat
259
+ } = _ref2;
260
+ if (!(0, _dtableUtils.isNumber)(lng) || !(0, _dtableUtils.isNumber)(lat)) return;
261
+ if (this.map) {
262
+ if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP || this.mapType === _mapEditorUtils.MAP_TYPES.M_MAP) {
263
+ this.map.setCenter({
264
+ lng,
265
+ lat
252
266
  });
253
- if (this.map) {
254
- if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP || this.mapType === _mapEditorUtils.MAP_TYPES.M_MAP) {
255
- this.map.setCenter({
256
- lng,
257
- lat
258
- });
259
- } else {
260
- this.map.setCenter(new window.BMap.Point(lng, lat));
261
- }
262
- }
263
- this.addMarkerByPosition(lng, lat);
267
+ } else {
268
+ this.map.setCenter(new window.BMap.Point(lng, lat));
264
269
  }
265
270
  }
271
+ this.addMarkerByPosition(lng, lat);
272
+ };
273
+ this.onChangeLatitude = event => {
274
+ this.setState({
275
+ value: {
276
+ ...this.state.value,
277
+ lat: event.target.value
278
+ }
279
+ }, () => {
280
+ const numericValue = this.getNumericValue(this.state.value);
281
+ this.setPropsValue(numericValue);
282
+ this.rerenderMapMarker(numericValue);
283
+ });
284
+ };
285
+ this.onChangeLongitude = event => {
286
+ this.setState({
287
+ value: {
288
+ ...this.state.value,
289
+ lng: event.target.value
290
+ }
291
+ }, () => {
292
+ const numericValue = this.getNumericValue(this.state.value);
293
+ this.setPropsValue(numericValue);
294
+ this.rerenderMapMarker(numericValue);
295
+ });
266
296
  };
267
297
  this.onKeyDown = event => {
268
298
  event.stopPropagation();
@@ -271,12 +301,6 @@ class LargeMapEditorDialog extends _react.default.Component {
271
301
  this.onSubmit();
272
302
  }
273
303
  };
274
- this.clearSearchNumerical = () => {
275
- this.setState({
276
- inputValue: '',
277
- value: {}
278
- });
279
- };
280
304
  this.onSubmit = () => {
281
305
  const {
282
306
  value
@@ -316,7 +340,10 @@ class LargeMapEditorDialog extends _react.default.Component {
316
340
  readOnly,
317
341
  config
318
342
  } = props;
319
- const _value = props.value || {};
343
+ const _value = props.value || {
344
+ lng: '',
345
+ lat: ''
346
+ };
320
347
  this.readOnly = readOnly;
321
348
  const {
322
349
  mapType,
@@ -324,16 +351,10 @@ class LargeMapEditorDialog extends _react.default.Component {
324
351
  } = (0, _mapEditorUtils.getMapInfo)(config);
325
352
  this.mapType = mapType;
326
353
  this.mapKey = mapKey;
327
- const {
328
- lng: _lng,
329
- lat: _lat
330
- } = _value;
331
- const _inputValue = (0, _cell.isValidPosition)(_lng, _lat) ? _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? "".concat(_lng, ", ").concat(_lat) : "".concat(_lat, ", ").concat(_lng) : '';
332
354
  this.map = null;
333
355
  this.state = {
334
356
  isLoading: true,
335
- value: props.value,
336
- inputValue: _inputValue
357
+ value: _value
337
358
  };
338
359
  }
339
360
  componentDidMount() {
@@ -384,8 +405,10 @@ class LargeMapEditorDialog extends _react.default.Component {
384
405
  render() {
385
406
  const {
386
407
  isLoading,
387
- inputValue
408
+ value
388
409
  } = this.state;
410
+ const lat = value ? value.lat : '';
411
+ const lng = value ? value.lng : '';
389
412
  return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
390
413
  size: "lg",
391
414
  isOpen: true,
@@ -407,24 +430,31 @@ class LargeMapEditorDialog extends _react.default.Component {
407
430
  className: "dtable-ui-geolocation-map-editor-large",
408
431
  onClick: this.handlerClick
409
432
  }, !this.readOnly && /*#__PURE__*/_react.default.createElement("div", {
410
- className: "map-editor-header"
433
+ className: "dtable-ui-geolocation-map-lng-lat-editor-header"
411
434
  }, /*#__PURE__*/_react.default.createElement("div", {
412
- className: "search-tables-container"
413
- }, /*#__PURE__*/_react.default.createElement("input", {
435
+ className: "dtable-ui-geolocation-map-lng-lat-input-container dtable-ui-geolocation-map-lat-input-container"
436
+ }, /*#__PURE__*/_react.default.createElement("div", {
437
+ className: "dtable-ui-geolocation-map-lng-lat-input-label"
438
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Latitude_abbr'))), /*#__PURE__*/_react.default.createElement("input", {
414
439
  type: "text",
415
- value: inputValue,
440
+ value: lat,
441
+ onChange: this.onChangeLatitude,
416
442
  onKeyDown: this.onKeyDown,
417
- onChange: this.onChange,
418
- className: "form-control search-tables-input",
419
- placeholder: _mapEditorUtils.DOMESTIC_MAP_TYPE.includes(this.mapType) ? (0, _lang.getLocale)('Enter_longitude_and_latitude') : (0, _lang.getLocale)('Enter_latitude_and_longitude'),
443
+ className: "form-control",
444
+ placeholder: (0, _lang.getLocale)('Enter_latitude'),
420
445
  autoFocus: true
421
- }), inputValue && /*#__PURE__*/_react.default.createElement("span", {
422
- className: "clear-search-numerical dtable-font dtable-icon-x-",
423
- onClick: this.clearSearchNumerical
424
- })), /*#__PURE__*/_react.default.createElement("span", {
425
- className: "dtable-ui-geolocation-submit-map-editor",
426
- onClick: this.onSubmit
427
- }, (0, _lang.getLocale)('Submit'))), /*#__PURE__*/_react.default.createElement("div", {
446
+ })), /*#__PURE__*/_react.default.createElement("div", {
447
+ className: "dtable-ui-geolocation-map-lng-lat-input-container dtable-ui-geolocation-map-lng-input-container"
448
+ }, /*#__PURE__*/_react.default.createElement("div", {
449
+ className: "dtable-ui-geolocation-map-lng-lat-input-label"
450
+ }, /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Longitude_abbr'))), /*#__PURE__*/_react.default.createElement("input", {
451
+ type: "text",
452
+ value: lng,
453
+ onChange: this.onChangeLongitude,
454
+ onKeyDown: this.onKeyDown,
455
+ className: "form-control",
456
+ placeholder: (0, _lang.getLocale)('Enter_longitude')
457
+ }))), /*#__PURE__*/_react.default.createElement("div", {
428
458
  className: this.readOnly ? 'geolocation-map-read-only-container' : 'geolocation-map-container-large'
429
459
  }, this.mapType && isLoading && /*#__PURE__*/_react.default.createElement(_Loading.default, null), !this.mapType && /*#__PURE__*/_react.default.createElement("div", {
430
460
  className: "dtable-ui-geolocation-map-editor-error-message d-flex justify-content-center mt-9"
@@ -18,6 +18,18 @@ var _lang = require("../../../lang");
18
18
  class MapSelectionEditor extends _react.Component {
19
19
  constructor(props) {
20
20
  super(props);
21
+ this.initMap = () => {
22
+ if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
23
+ if (!window.BMap) {
24
+ window.renderBaiduMap = () => this.renderBaiduMap();
25
+ (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
26
+ } else {
27
+ this.renderBaiduMap();
28
+ }
29
+ window.onSubmitSelection = this.onSubmitSelection;
30
+ return;
31
+ }
32
+ };
21
33
  this.renderBaiduMap = () => {
22
34
  this.setState({
23
35
  isLoading: false
@@ -238,6 +250,12 @@ class MapSelectionEditor extends _react.Component {
238
250
  this.props.setValue(value);
239
251
  this.setState({
240
252
  isShowLargeEditor: !this.state.isShowLargeEditor
253
+ }, () => {
254
+ const nextState = this.state.isShowLargeEditor;
255
+ if (!nextState) {
256
+ this.initMap();
257
+ }
258
+ this.props.toggleLargeMap && this.props.toggleLargeMap(nextState);
241
259
  });
242
260
  };
243
261
  this.clearSearchNumerical = () => {
@@ -337,16 +355,7 @@ class MapSelectionEditor extends _react.Component {
337
355
  this.map = null;
338
356
  }
339
357
  componentDidMount() {
340
- if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
341
- if (!window.BMap) {
342
- window.renderBaiduMap = () => this.renderBaiduMap();
343
- (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
344
- } else {
345
- this.renderBaiduMap();
346
- }
347
- window.onSubmitSelection = this.onSubmitSelection;
348
- return;
349
- }
358
+ this.initMap();
350
359
  }
351
360
  componentWillUnmount() {
352
361
  if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
@@ -407,7 +416,7 @@ class MapSelectionEditor extends _react.Component {
407
416
  value: inputValue,
408
417
  onKeyDown: this.onKeyDown,
409
418
  onChange: this.onChange,
410
- className: "form-control search-tables-input selection-input",
419
+ className: "form-control selection-input",
411
420
  placeholder: (0, _lang.getLocale)('Please_enter_the_address'),
412
421
  autoFocus: true
413
422
  }), inputValue && /*#__PURE__*/_react.default.createElement("span", {
@@ -243,7 +243,7 @@ class LargeMapSelectionEditorDialog extends _react.default.Component {
243
243
  value
244
244
  } = this.state;
245
245
  this.props.setValue(value);
246
- this.props.toggleFullScreen();
246
+ this.props.toggleFullScreen(event);
247
247
  };
248
248
  this.renderSearchResults = () => {
249
249
  const {
@@ -399,7 +399,7 @@ class LargeMapSelectionEditorDialog extends _react.default.Component {
399
399
  value: inputValue,
400
400
  onChange: this.onChange,
401
401
  onKeyDown: this.onKeyDown,
402
- className: "form-control search-tables-input selection-input-large",
402
+ className: "form-control selection-input-large",
403
403
  placeholder: (0, _lang.getLocale)('Please_enter_the_address'),
404
404
  autoFocus: true
405
405
  }), inputValue && /*#__PURE__*/_react.default.createElement("span", {
@@ -23,13 +23,17 @@ class RowExpandPCGeolocationEditor extends _react.default.Component {
23
23
  }
24
24
  };
25
25
  this.hideEditor = event => {
26
- if (!this.state.isShowEditor || !event.target || this.editorContainer.contains(event.target)) return;
26
+ if (!this.state.isShowEditor || this.isLargeMapOpen || !event.target || this.editorContainer.contains(event.target)) return;
27
27
  this.setState({
28
28
  isShowEditor: false
29
29
  });
30
30
  };
31
+ this.toggleLargeMap = open => {
32
+ this.isLargeMapOpen = open;
33
+ };
31
34
  this.toggleEditor = () => {
32
35
  this.props.updateTabIndex(this.props.columnIndex);
36
+ this.isLargeMapOpen = false;
33
37
  this.setState({
34
38
  isShowEditor: !this.state.isShowEditor
35
39
  }, () => {
@@ -47,12 +51,21 @@ class RowExpandPCGeolocationEditor extends _react.default.Component {
47
51
  this.onFocus = () => {
48
52
  this.props.updateTabIndex(this.props.columnIndex);
49
53
  };
54
+ this.closeEditor = () => {
55
+ this.isLargeMapOpen = false;
56
+ this.setState({
57
+ isShowEditor: false
58
+ });
59
+ };
50
60
  this.onCommit = value => {
51
61
  this.props.onCommit(value);
52
62
  this.setState({
53
63
  value
54
64
  });
55
- this.toggleEditor();
65
+ this.isLargeMapOpen = false;
66
+ this.setState({
67
+ isShowEditor: false
68
+ });
56
69
  };
57
70
  this.renderGeoLocation = () => {
58
71
  let {
@@ -99,7 +112,7 @@ class RowExpandPCGeolocationEditor extends _react.default.Component {
99
112
  value: row[_column[valueKey]] || {}
100
113
  };
101
114
  this.addBtnRef = /*#__PURE__*/_react.default.createRef();
102
- this.isGeolocationLargeMapOpen = false;
115
+ this.isLargeMapOpen = false;
103
116
  }
104
117
  componentDidMount() {
105
118
  document.addEventListener('mousedown', this.hideEditor);
@@ -150,8 +163,9 @@ class RowExpandPCGeolocationEditor extends _react.default.Component {
150
163
  value: value,
151
164
  config: config,
152
165
  onCommit: this.onCommit,
153
- onToggle: this.toggleEditor,
154
- onPressTab: this.props.onPressTab
166
+ onToggle: this.closeEditor,
167
+ onPressTab: this.props.onPressTab,
168
+ toggleLargeMap: this.toggleLargeMap
155
169
  }));
156
170
  }
157
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.36",
3
+ "version": "6.0.37beta",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",