@styzy/vue-amap 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-ctn[data-v-0a8871e0],.v-amap-c
32
32
 
33
33
  /***/ }),
34
34
 
35
- /***/ 905:
35
+ /***/ 554:
36
36
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
37
37
 
38
38
  "use strict";
@@ -46,28 +46,7 @@ __webpack_require__.r(__webpack_exports__);
46
46
 
47
47
  var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
48
48
  // Module
49
- ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-place-search-input input[data-v-01341cd6]{display:inline-block;box-sizing:border-box;padding:0 15px;width:100%;height:40px;outline:0;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;background-image:none;color:#606266;font-size:inherit;line-height:40px;transition:border-color .2s cubic-bezier(.645,.045,.355,1);-webkit-appearance:none}.v-amap-place-search-input input[data-v-01341cd6]::-webkit-input-placeholder{color:#c0c4cc}.v-amap-place-search-input input.is-disabled[data-v-01341cd6]{border-color:#e4e7ed;background-color:#f5f7fa;color:#c0c4cc;cursor:not-allowed}", ""]);
50
- // Exports
51
- /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
52
-
53
-
54
- /***/ }),
55
-
56
- /***/ 64:
57
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
58
-
59
- "use strict";
60
- __webpack_require__.r(__webpack_exports__);
61
- /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81);
62
- /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
63
- /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(645);
64
- /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
65
- // Imports
66
-
67
-
68
- var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
69
- // Module
70
- ___CSS_LOADER_EXPORT___.push([module.id, ".amap-sug-result{display:none}", ""]);
49
+ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-place-search-input[data-v-6fee8e59]{position:relative}.v-amap-place-search-input input[data-v-6fee8e59]{display:inline-block;box-sizing:border-box;padding:0 15px;width:100%;height:40px;outline:0;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;background-image:none;color:#606266;font-size:inherit;line-height:40px;transition:border-color .2s cubic-bezier(.645,.045,.355,1);-webkit-appearance:none}.v-amap-place-search-input input[data-v-6fee8e59]::-webkit-input-placeholder{color:#c0c4cc}.v-amap-place-search-input input.is-disabled[data-v-6fee8e59]{border-color:#e4e7ed;background-color:#f5f7fa;color:#c0c4cc;cursor:not-allowed}.v-amap-place-search-input .option-ctn[data-v-6fee8e59]{position:absolute;top:100%;right:0;left:0;z-index:1;overflow-y:auto;box-sizing:border-box;max-height:402px;border:1px solid #dcdfe6;background-color:#fff}.v-amap-place-search-input .option-ctn[data-v-6fee8e59]::-webkit-scrollbar{width:10px}.v-amap-place-search-input .option-ctn[data-v-6fee8e59]::-webkit-scrollbar-track-piece{background-color:transparent}.v-amap-place-search-input .option-ctn[data-v-6fee8e59]::-webkit-scrollbar-thumb{border-radius:10px;background-color:transparent}.v-amap-place-search-input .option-ctn[data-v-6fee8e59]:hover::-webkit-scrollbar-track-piece{background-color:hsla(0,0%,67%,.2)}.v-amap-place-search-input .option-ctn[data-v-6fee8e59]:hover::-webkit-scrollbar-thumb{background-color:#aaa}.v-amap-place-search-input .option-ctn[data-v-6fee8e59]:hover::-webkit-scrollbar-thumb:hover{background-color:#888}.v-amap-place-search-input .option-ctn .option[data-v-6fee8e59]{overflow:hidden;padding-right:5px;padding-left:15px;height:40px;text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:40px;cursor:pointer}.v-amap-place-search-input .option-ctn .option[data-v-6fee8e59]:hover{background-color:#f4f5f6}.v-amap-place-search-input .option-ctn .option .name[data-v-6fee8e59]{color:#424242}.v-amap-place-search-input .option-ctn .option .city[data-v-6fee8e59]{margin-left:5px;color:#c1c1c1}", ""]);
71
50
  // Exports
72
51
  /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
73
52
 
@@ -194,35 +173,19 @@ var update = add("1bf2dbec", content, true, {"sourceMap":false,"shadowMode":fals
194
173
 
195
174
  /***/ }),
196
175
 
197
- /***/ 244:
176
+ /***/ 75:
198
177
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
199
178
 
200
179
  // style-loader: Adds some css to the DOM by adding a <style> tag
201
180
 
202
181
  // load the styles
203
- var content = __webpack_require__(905);
182
+ var content = __webpack_require__(554);
204
183
  if(content.__esModule) content = content.default;
205
184
  if(typeof content === 'string') content = [[module.id, content, '']];
206
185
  if(content.locals) module.exports = content.locals;
207
186
  // add the styles to the DOM
208
187
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
209
- var update = add("e6e2b68c", content, true, {"sourceMap":false,"shadowMode":false});
210
-
211
- /***/ }),
212
-
213
- /***/ 107:
214
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
215
-
216
- // style-loader: Adds some css to the DOM by adding a <style> tag
217
-
218
- // load the styles
219
- var content = __webpack_require__(64);
220
- if(content.__esModule) content = content.default;
221
- if(typeof content === 'string') content = [[module.id, content, '']];
222
- if(content.locals) module.exports = content.locals;
223
- // add the styles to the DOM
224
- var add = (__webpack_require__(402)/* ["default"] */ .Z)
225
- var update = add("333431a0", content, true, {"sourceMap":false,"shadowMode":false});
188
+ var update = add("eb93a5d6", content, true, {"sourceMap":false,"shadowMode":false});
226
189
 
227
190
  /***/ }),
228
191
 
@@ -1351,16 +1314,37 @@ var VAMapPolygon_component = normalizeComponent(
1351
1314
  )
1352
1315
 
1353
1316
  /* harmony default export */ var VAMapPolygon = (VAMapPolygon_component.exports);
1354
- ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/pug-plain-loader/index.js!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=template&id=01341cd6&scoped=true&lang=pug
1355
- var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"v-amap-place-search-input"},[_c('input',{ref:"input",class:{ 'is-disabled': _vm.disabled },attrs:{"disabled":_vm.disabled,"placeholder":_vm.placeholder},domProps:{"value":_vm.value},on:{"blur":function($event){return _vm.handleBlur()},"input":_vm.handleInput}})])
1317
+ ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/pug-plain-loader/index.js!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=template&id=6fee8e59&scoped=true&lang=pug
1318
+ var VAMapPlaceSearchInputvue_type_template_id_6fee8e59_scoped_true_lang_pug_render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"v-amap-place-search-input"},[_c('input',{class:{ 'is-disabled': _vm.disabled },attrs:{"disabled":_vm.disabled,"placeholder":_vm.placeholder},domProps:{"value":_vm.value},on:{"blur":function($event){return _vm.handleBlur()},"focus":function($event){return _vm.handleFocus()},"input":function($event){return _vm.handleInput($event)}}}),(_vm.placeList.length)?_c('div',{staticClass:"option-ctn"},_vm._l((_vm.placeList),function(place){return _c('div',{staticClass:"option",attrs:{"title":place.name + place.cityname},on:{"click":function($event){return _vm.handlePlaceSelect(place)}}},[_c('span',{staticClass:"name"},[_vm._v(_vm._s(place.name))]),_c('span',{staticClass:"city"},[_vm._v(_vm._s(place.cityname))])])}),0):_vm._e()])
1356
1319
  }
1357
- var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_staticRenderFns = []
1358
-
1320
+ var VAMapPlaceSearchInputvue_type_template_id_6fee8e59_scoped_true_lang_pug_staticRenderFns = []
1321
+
1322
+
1323
+ ;// CONCATENATED MODULE: ./src/utils/isParentNode.js
1324
+ // 是否是父节点
1325
+ const isParentNode = function (parentObj, obj) {
1326
+ if (parentObj === obj) return false
1327
+ while (
1328
+ obj != undefined &&
1329
+ obj != null &&
1330
+ obj.tagName &&
1331
+ obj.tagName.toUpperCase() != 'BODY'
1332
+ ) {
1333
+ if (obj == parentObj) {
1334
+ return true
1335
+ }
1336
+ obj = obj.parentNode
1337
+ }
1338
+ return false
1339
+ }
1340
+
1341
+ /* harmony default export */ var utils_isParentNode = (isParentNode);
1359
1342
 
1360
1343
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1361
1344
 
1362
1345
 
1363
1346
 
1347
+
1364
1348
  /* harmony default export */ var VAMapPlaceSearchInputvue_type_script_lang_js = ({
1365
1349
  name: 'VAMapPlaceSearchInput',
1366
1350
  model: {
@@ -1388,91 +1372,90 @@ var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_stat
1388
1372
  data() {
1389
1373
  return {
1390
1374
  AMap: null,
1391
- placeName: '',
1392
- autocompleteListener: null,
1393
- placeSearchListener: null
1375
+ placeSearch: null,
1376
+ placeList: [],
1377
+ place: null
1394
1378
  }
1395
1379
  },
1396
- async mounted() {
1397
- this.AMap = await loader.load()
1398
- this.addListener()
1380
+ watch: {
1381
+ place() {
1382
+ this.$emit('change', this.place ? this.place.name : '')
1383
+ this.$emit(
1384
+ 'locationChange',
1385
+ this.place
1386
+ ? [this.place.location.lng, this.place.location.lat]
1387
+ : null
1388
+ )
1389
+ this.$emit('placeChange', this.place)
1390
+ }
1399
1391
  },
1400
- destroyed() {
1401
- this.removeListener()
1392
+ mounted() {
1393
+ window.addEventListener('click', this.optionsHideListener, true)
1394
+ window.addEventListener('contextmenu', this.optionsHideListener, true)
1395
+ },
1396
+ beforeDestroy() {
1397
+ window.removeEventListener('click', this.optionsHideListener, true)
1398
+ window.removeEventListener(
1399
+ 'contextmenu',
1400
+ this.optionsHideListener,
1401
+ true
1402
+ )
1402
1403
  },
1403
1404
  methods: {
1404
- async addListener() {
1405
- const autocomplete = new this.AMap.Autocomplete({
1406
- input: this.$refs.input
1407
- }),
1408
- placeSearch = new this.AMap.PlaceSearch({})
1409
-
1410
- this.autocompleteListener = this.AMap.event.addListener(
1411
- autocomplete,
1412
- 'select',
1413
- event => {
1414
- this.placeName = event.poi.name
1415
- placeSearch.search(event.poi.name)
1416
- }
1417
- )
1418
-
1419
- this.placeSearchListener = this.AMap.event.addListener(
1420
- placeSearch,
1421
- 'complete',
1422
- event => {
1423
- var position = null
1424
- if (
1425
- event &&
1426
- event.poiList &&
1427
- event.poiList.pois &&
1428
- event.poiList.pois.length
1429
- ) {
1430
- position = [
1431
- event.poiList.pois[0].location.lng,
1432
- event.poiList.pois[0].location.lat
1433
- ]
1434
- }
1435
-
1436
- if (!position && !this.customEnable) {
1437
- this.clear()
1438
- } else {
1439
- this.$emit('change', this.placeName)
1440
- this.$emit('locationChange', position)
1441
- }
1405
+ async createPlaceSearch() {
1406
+ this.AMap = await loader.load()
1407
+ this.placeSearch = new this.AMap.PlaceSearch({
1408
+ extensions: 'all'
1409
+ })
1410
+ },
1411
+ async getPlaceList() {
1412
+ if (!this.placeSearch) {
1413
+ await this.createPlaceSearch()
1414
+ }
1415
+ this.placeSearch.search(this.value, (status, result) => {
1416
+ if (status === 'complete') {
1417
+ this.placeList = result?.poiList?.pois || []
1418
+ } else {
1419
+ this.placeList = []
1442
1420
  }
1443
- )
1421
+ })
1444
1422
  },
1445
- removeListener() {
1446
- this.AMap.event.removeListener(this.autocompleteListener)
1447
- this.AMap.event.removeListener(this.placeSearchListener)
1423
+ async handleInput(event) {
1424
+ this.$emit('change', event.target.value)
1425
+ await this.$nextTick()
1426
+ this.getPlaceList()
1448
1427
  },
1449
- clear() {
1450
- this.placeName = ''
1451
- this.$emit('change', '')
1452
- this.$emit('locationChange', null)
1428
+ handlePlaceSelect(place = null) {
1429
+ this.place = place
1430
+ this.placeList = []
1431
+ },
1432
+ handleFocus() {
1433
+ if (this.value?.trim()) {
1434
+ this.getPlaceList()
1435
+ }
1453
1436
  },
1454
1437
  handleBlur() {
1455
- if (this.value !== this.placeName) {
1456
- if (!this.customEnable) {
1457
- this.clear()
1458
- }
1438
+ if (this.customEnable) return
1439
+ if (this.value !== this.place?.name) {
1440
+ this.clear()
1459
1441
  }
1460
1442
  },
1461
- handleInput(event) {
1462
- this.$emit('change', event.target.value)
1443
+ optionsHideListener(event) {
1444
+ if (utils_isParentNode(this.$el, event.target)) return
1445
+ this.placeList = []
1446
+ },
1447
+ clear() {
1448
+ this.place = null
1449
+ this.$emit('change', '')
1463
1450
  }
1464
1451
  }
1465
1452
  });
1466
1453
 
1467
1454
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1468
1455
  /* harmony default export */ var Components_VAMapPlaceSearchInputvue_type_script_lang_js = (VAMapPlaceSearchInputvue_type_script_lang_js);
1469
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-76.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-76.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-76.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=01341cd6&prod&lang=stylus&scoped=true
1470
- var VAMapPlaceSearchInputvue_type_style_index_0_id_01341cd6_prod_lang_stylus_scoped_true = __webpack_require__(244);
1471
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=01341cd6&prod&lang=stylus&scoped=true
1472
-
1473
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-76.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-76.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-76.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=01341cd6&prod&lang=stylus
1474
- var VAMapPlaceSearchInputvue_type_style_index_1_id_01341cd6_prod_lang_stylus = __webpack_require__(107);
1475
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=01341cd6&prod&lang=stylus
1456
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-76.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-76.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-76.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=6fee8e59&prod&lang=stylus&scoped=true
1457
+ var VAMapPlaceSearchInputvue_type_style_index_0_id_6fee8e59_prod_lang_stylus_scoped_true = __webpack_require__(75);
1458
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=6fee8e59&prod&lang=stylus&scoped=true
1476
1459
 
1477
1460
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue
1478
1461
 
@@ -1481,16 +1464,15 @@ var VAMapPlaceSearchInputvue_type_style_index_1_id_01341cd6_prod_lang_stylus = _
1481
1464
  ;
1482
1465
 
1483
1466
 
1484
-
1485
1467
  /* normalize component */
1486
1468
 
1487
1469
  var VAMapPlaceSearchInput_component = normalizeComponent(
1488
1470
  Components_VAMapPlaceSearchInputvue_type_script_lang_js,
1489
- VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_render,
1490
- VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_staticRenderFns,
1471
+ VAMapPlaceSearchInputvue_type_template_id_6fee8e59_scoped_true_lang_pug_render,
1472
+ VAMapPlaceSearchInputvue_type_template_id_6fee8e59_scoped_true_lang_pug_staticRenderFns,
1491
1473
  false,
1492
1474
  null,
1493
- "01341cd6",
1475
+ "6fee8e59",
1494
1476
  null
1495
1477
 
1496
1478
  )
@@ -1512,7 +1494,7 @@ var VAMapPlaceSearchInput_component = normalizeComponent(
1512
1494
  ]);
1513
1495
 
1514
1496
  ;// CONCATENATED MODULE: ./package.json
1515
- var package_namespaceObject = {"i8":"1.2.1"};
1497
+ var package_namespaceObject = {"i8":"1.3.1"};
1516
1498
  ;// CONCATENATED MODULE: ./src/config/index.js
1517
1499
 
1518
1500