@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.
@@ -22,7 +22,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-ctn[data-v-0a8871e0],.v-amap-c
22
22
 
23
23
  /***/ }),
24
24
 
25
- /***/ 83:
25
+ /***/ 774:
26
26
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
27
27
 
28
28
  "use strict";
@@ -36,28 +36,7 @@ __webpack_require__.r(__webpack_exports__);
36
36
 
37
37
  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()));
38
38
  // Module
39
- ___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}", ""]);
40
- // Exports
41
- /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
42
-
43
-
44
- /***/ }),
45
-
46
- /***/ 820:
47
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
48
-
49
- "use strict";
50
- __webpack_require__.r(__webpack_exports__);
51
- /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81);
52
- /* 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__);
53
- /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(645);
54
- /* 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__);
55
- // Imports
56
-
57
-
58
- 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()));
59
- // Module
60
- ___CSS_LOADER_EXPORT___.push([module.id, ".amap-sug-result{display:none}", ""]);
39
+ ___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}", ""]);
61
40
  // Exports
62
41
  /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
63
42
 
@@ -184,35 +163,19 @@ var update = add("7ebf2e0a", content, true, {"sourceMap":false,"shadowMode":fals
184
163
 
185
164
  /***/ }),
186
165
 
187
- /***/ 427:
166
+ /***/ 229:
188
167
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
189
168
 
190
169
  // style-loader: Adds some css to the DOM by adding a <style> tag
191
170
 
192
171
  // load the styles
193
- var content = __webpack_require__(83);
172
+ var content = __webpack_require__(774);
194
173
  if(content.__esModule) content = content.default;
195
174
  if(typeof content === 'string') content = [[module.id, content, '']];
196
175
  if(content.locals) module.exports = content.locals;
197
176
  // add the styles to the DOM
198
177
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
199
- var update = add("a0517e8c", content, true, {"sourceMap":false,"shadowMode":false});
200
-
201
- /***/ }),
202
-
203
- /***/ 641:
204
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
205
-
206
- // style-loader: Adds some css to the DOM by adding a <style> tag
207
-
208
- // load the styles
209
- var content = __webpack_require__(820);
210
- if(content.__esModule) content = content.default;
211
- if(typeof content === 'string') content = [[module.id, content, '']];
212
- if(content.locals) module.exports = content.locals;
213
- // add the styles to the DOM
214
- var add = (__webpack_require__(402)/* ["default"] */ .Z)
215
- var update = add("1cb88330", content, true, {"sourceMap":false,"shadowMode":false});
178
+ var update = add("a5026dd6", content, true, {"sourceMap":false,"shadowMode":false});
216
179
 
217
180
  /***/ }),
218
181
 
@@ -1341,16 +1304,37 @@ var VAMapPolygon_component = normalizeComponent(
1341
1304
  )
1342
1305
 
1343
1306
  /* harmony default export */ var VAMapPolygon = (VAMapPolygon_component.exports);
1344
- ;// 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
1345
- 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}})])
1307
+ ;// 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
1308
+ 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()])
1346
1309
  }
1347
- var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_staticRenderFns = []
1348
-
1310
+ var VAMapPlaceSearchInputvue_type_template_id_6fee8e59_scoped_true_lang_pug_staticRenderFns = []
1311
+
1312
+
1313
+ ;// CONCATENATED MODULE: ./src/utils/isParentNode.js
1314
+ // 是否是父节点
1315
+ const isParentNode = function (parentObj, obj) {
1316
+ if (parentObj === obj) return false
1317
+ while (
1318
+ obj != undefined &&
1319
+ obj != null &&
1320
+ obj.tagName &&
1321
+ obj.tagName.toUpperCase() != 'BODY'
1322
+ ) {
1323
+ if (obj == parentObj) {
1324
+ return true
1325
+ }
1326
+ obj = obj.parentNode
1327
+ }
1328
+ return false
1329
+ }
1330
+
1331
+ /* harmony default export */ var utils_isParentNode = (isParentNode);
1349
1332
 
1350
1333
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1351
1334
 
1352
1335
 
1353
1336
 
1337
+
1354
1338
  /* harmony default export */ var VAMapPlaceSearchInputvue_type_script_lang_js = ({
1355
1339
  name: 'VAMapPlaceSearchInput',
1356
1340
  model: {
@@ -1378,91 +1362,90 @@ var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_stat
1378
1362
  data() {
1379
1363
  return {
1380
1364
  AMap: null,
1381
- placeName: '',
1382
- autocompleteListener: null,
1383
- placeSearchListener: null
1365
+ placeSearch: null,
1366
+ placeList: [],
1367
+ place: null
1384
1368
  }
1385
1369
  },
1386
- async mounted() {
1387
- this.AMap = await loader.load()
1388
- this.addListener()
1370
+ watch: {
1371
+ place() {
1372
+ this.$emit('change', this.place ? this.place.name : '')
1373
+ this.$emit(
1374
+ 'locationChange',
1375
+ this.place
1376
+ ? [this.place.location.lng, this.place.location.lat]
1377
+ : null
1378
+ )
1379
+ this.$emit('placeChange', this.place)
1380
+ }
1389
1381
  },
1390
- destroyed() {
1391
- this.removeListener()
1382
+ mounted() {
1383
+ window.addEventListener('click', this.optionsHideListener, true)
1384
+ window.addEventListener('contextmenu', this.optionsHideListener, true)
1385
+ },
1386
+ beforeDestroy() {
1387
+ window.removeEventListener('click', this.optionsHideListener, true)
1388
+ window.removeEventListener(
1389
+ 'contextmenu',
1390
+ this.optionsHideListener,
1391
+ true
1392
+ )
1392
1393
  },
1393
1394
  methods: {
1394
- async addListener() {
1395
- const autocomplete = new this.AMap.Autocomplete({
1396
- input: this.$refs.input
1397
- }),
1398
- placeSearch = new this.AMap.PlaceSearch({})
1399
-
1400
- this.autocompleteListener = this.AMap.event.addListener(
1401
- autocomplete,
1402
- 'select',
1403
- event => {
1404
- this.placeName = event.poi.name
1405
- placeSearch.search(event.poi.name)
1406
- }
1407
- )
1408
-
1409
- this.placeSearchListener = this.AMap.event.addListener(
1410
- placeSearch,
1411
- 'complete',
1412
- event => {
1413
- var position = null
1414
- if (
1415
- event &&
1416
- event.poiList &&
1417
- event.poiList.pois &&
1418
- event.poiList.pois.length
1419
- ) {
1420
- position = [
1421
- event.poiList.pois[0].location.lng,
1422
- event.poiList.pois[0].location.lat
1423
- ]
1424
- }
1425
-
1426
- if (!position && !this.customEnable) {
1427
- this.clear()
1428
- } else {
1429
- this.$emit('change', this.placeName)
1430
- this.$emit('locationChange', position)
1431
- }
1395
+ async createPlaceSearch() {
1396
+ this.AMap = await loader.load()
1397
+ this.placeSearch = new this.AMap.PlaceSearch({
1398
+ extensions: 'all'
1399
+ })
1400
+ },
1401
+ async getPlaceList() {
1402
+ if (!this.placeSearch) {
1403
+ await this.createPlaceSearch()
1404
+ }
1405
+ this.placeSearch.search(this.value, (status, result) => {
1406
+ if (status === 'complete') {
1407
+ this.placeList = result?.poiList?.pois || []
1408
+ } else {
1409
+ this.placeList = []
1432
1410
  }
1433
- )
1411
+ })
1434
1412
  },
1435
- removeListener() {
1436
- this.AMap.event.removeListener(this.autocompleteListener)
1437
- this.AMap.event.removeListener(this.placeSearchListener)
1413
+ async handleInput(event) {
1414
+ this.$emit('change', event.target.value)
1415
+ await this.$nextTick()
1416
+ this.getPlaceList()
1438
1417
  },
1439
- clear() {
1440
- this.placeName = ''
1441
- this.$emit('change', '')
1442
- this.$emit('locationChange', null)
1418
+ handlePlaceSelect(place = null) {
1419
+ this.place = place
1420
+ this.placeList = []
1421
+ },
1422
+ handleFocus() {
1423
+ if (this.value?.trim()) {
1424
+ this.getPlaceList()
1425
+ }
1443
1426
  },
1444
1427
  handleBlur() {
1445
- if (this.value !== this.placeName) {
1446
- if (!this.customEnable) {
1447
- this.clear()
1448
- }
1428
+ if (this.customEnable) return
1429
+ if (this.value !== this.place?.name) {
1430
+ this.clear()
1449
1431
  }
1450
1432
  },
1451
- handleInput(event) {
1452
- this.$emit('change', event.target.value)
1433
+ optionsHideListener(event) {
1434
+ if (utils_isParentNode(this.$el, event.target)) return
1435
+ this.placeList = []
1436
+ },
1437
+ clear() {
1438
+ this.place = null
1439
+ this.$emit('change', '')
1453
1440
  }
1454
1441
  }
1455
1442
  });
1456
1443
 
1457
1444
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1458
1445
  /* harmony default export */ var Components_VAMapPlaceSearchInputvue_type_script_lang_js = (VAMapPlaceSearchInputvue_type_script_lang_js);
1459
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.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
1460
- var VAMapPlaceSearchInputvue_type_style_index_0_id_01341cd6_prod_lang_stylus_scoped_true = __webpack_require__(427);
1461
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=01341cd6&prod&lang=stylus&scoped=true
1462
-
1463
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.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
1464
- var VAMapPlaceSearchInputvue_type_style_index_1_id_01341cd6_prod_lang_stylus = __webpack_require__(641);
1465
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=01341cd6&prod&lang=stylus
1446
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.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
1447
+ var VAMapPlaceSearchInputvue_type_style_index_0_id_6fee8e59_prod_lang_stylus_scoped_true = __webpack_require__(229);
1448
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=6fee8e59&prod&lang=stylus&scoped=true
1466
1449
 
1467
1450
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue
1468
1451
 
@@ -1471,16 +1454,15 @@ var VAMapPlaceSearchInputvue_type_style_index_1_id_01341cd6_prod_lang_stylus = _
1471
1454
  ;
1472
1455
 
1473
1456
 
1474
-
1475
1457
  /* normalize component */
1476
1458
 
1477
1459
  var VAMapPlaceSearchInput_component = normalizeComponent(
1478
1460
  Components_VAMapPlaceSearchInputvue_type_script_lang_js,
1479
- VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_render,
1480
- VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_staticRenderFns,
1461
+ VAMapPlaceSearchInputvue_type_template_id_6fee8e59_scoped_true_lang_pug_render,
1462
+ VAMapPlaceSearchInputvue_type_template_id_6fee8e59_scoped_true_lang_pug_staticRenderFns,
1481
1463
  false,
1482
1464
  null,
1483
- "01341cd6",
1465
+ "6fee8e59",
1484
1466
  null
1485
1467
 
1486
1468
  )
@@ -1502,7 +1484,7 @@ var VAMapPlaceSearchInput_component = normalizeComponent(
1502
1484
  ]);
1503
1485
 
1504
1486
  ;// CONCATENATED MODULE: ./package.json
1505
- var package_namespaceObject = {"i8":"1.2.1"};
1487
+ var package_namespaceObject = {"i8":"1.3.1"};
1506
1488
  ;// CONCATENATED MODULE: ./src/config/index.js
1507
1489
 
1508
1490