@heycar/heycars-map 0.7.10 → 0.8.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.
package/dist/index.cjs CHANGED
@@ -9,7 +9,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  const Vue = require("vue");
10
10
  const style = "";
11
11
  const name = "@heycar/heycars-map";
12
- const version = "0.7.10";
12
+ const version = "0.8.0";
13
13
  const type = "module";
14
14
  const scripts = {
15
15
  dev: "vite -c vite.config.dev.ts",
@@ -655,15 +655,85 @@ function defineLagecySetup(setup) {
655
655
  const createElement = Vue.h;
656
656
  const LANGUAGE = "zh-CN";
657
657
  const AbsoluteAddressBox_css_ts_vanilla = "";
658
+ function _defineProperty(obj, key, value) {
659
+ if (key in obj) {
660
+ Object.defineProperty(obj, key, {
661
+ value,
662
+ enumerable: true,
663
+ configurable: true,
664
+ writable: true
665
+ });
666
+ } else {
667
+ obj[key] = value;
668
+ }
669
+ return obj;
670
+ }
671
+ function ownKeys(object, enumerableOnly) {
672
+ var keys2 = Object.keys(object);
673
+ if (Object.getOwnPropertySymbols) {
674
+ var symbols = Object.getOwnPropertySymbols(object);
675
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
676
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
677
+ })), keys2.push.apply(keys2, symbols);
678
+ }
679
+ return keys2;
680
+ }
681
+ function _objectSpread2(target) {
682
+ for (var i = 1; i < arguments.length; i++) {
683
+ var source = null != arguments[i] ? arguments[i] : {};
684
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
685
+ _defineProperty(target, key, source[key]);
686
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
687
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
688
+ });
689
+ }
690
+ return target;
691
+ }
692
+ var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
693
+ for (var key of Object.keys(compoundCheck)) {
694
+ var _selections$key;
695
+ if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
696
+ return false;
697
+ }
698
+ }
699
+ return true;
700
+ };
701
+ var createRuntimeFn = (config) => (options) => {
702
+ var className = config.defaultClassName;
703
+ var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
704
+ for (var variantName in selections) {
705
+ var _selections$variantNa;
706
+ var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
707
+ if (variantSelection != null) {
708
+ var selection = variantSelection;
709
+ if (typeof selection === "boolean") {
710
+ selection = selection === true ? "true" : "false";
711
+ }
712
+ var selectionClassName = (
713
+ // @ts-expect-error
714
+ config.variantClassNames[variantName][selection]
715
+ );
716
+ if (selectionClassName) {
717
+ className += " " + selectionClassName;
718
+ }
719
+ }
720
+ }
721
+ for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
722
+ if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
723
+ className += " " + compoundClassName;
724
+ }
725
+ }
726
+ return className;
727
+ };
658
728
  var absoluteAddressBox = "n8tgem1";
659
729
  var absoluteAddressBoxLayout = "n8tgem0";
660
- var arrowRight = "n8tgem6";
661
- var boxDescription = "n8tgem4";
662
- var boxTextLayout = "n8tgem2";
663
- var boxTitle = "n8tgem3";
664
- var imgDotLoading = "n8tgem5";
665
- var locatorIcon = "n8tgem8";
666
- var straightLine = "n8tgem7";
730
+ var arrowRight = "n8tgem8";
731
+ var boxDescription = "n8tgem6";
732
+ var boxTextLayout = createRuntimeFn({ defaultClassName: "n8tgem2", variantClassNames: { withArrow: { true: "n8tgem3", false: "n8tgem4" } }, defaultVariants: {}, compoundVariants: [] });
733
+ var boxTitle = "n8tgem5";
734
+ var imgDotLoading = "n8tgem7";
735
+ var locatorIcon = "n8tgema";
736
+ var straightLine = "n8tgem9";
667
737
  const MultilineTitle = defineSetup(function MultilineTitle2(props) {
668
738
  const linesRef = Vue.computed(() => {
669
739
  var _a;
@@ -679,7 +749,8 @@ const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox2(props, {
679
749
  const {
680
750
  type: type2,
681
751
  title,
682
- description
752
+ description,
753
+ withArrow = false
683
754
  } = props;
684
755
  if (type2 === "locator")
685
756
  return Vue.h("div", {
@@ -714,7 +785,9 @@ const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox2(props, {
714
785
  "click": handleClick
715
786
  }
716
787
  }, [Vue.h("div", {
717
- "class": boxTextLayout
788
+ "class": boxTextLayout({
789
+ withArrow
790
+ })
718
791
  }, [Vue.h(MultilineTitle, {
719
792
  "class": boxTitle,
720
793
  "attrs": {
@@ -722,7 +795,7 @@ const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox2(props, {
722
795
  }
723
796
  }), !!description && Vue.h("div", {
724
797
  "class": boxDescription
725
- }, [description])]), Vue.h("img", {
798
+ }, [description])]), withArrow && Vue.h("img", {
726
799
  "class": arrowRight,
727
800
  "attrs": {
728
801
  "src": imgArrowRight
@@ -1250,6 +1323,9 @@ function watchPostEffectForGMapEvent(targetRef, props, emit, propertyNames) {
1250
1323
  });
1251
1324
  });
1252
1325
  }
1326
+ const watchPostEffectOnce = (callback) => {
1327
+ Vue.watch(() => 0, callback, { immediate: true, flush: "post" });
1328
+ };
1253
1329
  const AmapMarker = defineSetup(function AmapMarker2(props, { emit }) {
1254
1330
  const { registerOverlay } = props;
1255
1331
  const markerRef = Vue.shallowRef();
@@ -2350,76 +2426,6 @@ const useResizeObserver = (props) => {
2350
2426
  });
2351
2427
  };
2352
2428
  const Gmap_css_ts_vanilla = "";
2353
- function _defineProperty(obj, key, value) {
2354
- if (key in obj) {
2355
- Object.defineProperty(obj, key, {
2356
- value,
2357
- enumerable: true,
2358
- configurable: true,
2359
- writable: true
2360
- });
2361
- } else {
2362
- obj[key] = value;
2363
- }
2364
- return obj;
2365
- }
2366
- function ownKeys(object, enumerableOnly) {
2367
- var keys2 = Object.keys(object);
2368
- if (Object.getOwnPropertySymbols) {
2369
- var symbols = Object.getOwnPropertySymbols(object);
2370
- enumerableOnly && (symbols = symbols.filter(function(sym) {
2371
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2372
- })), keys2.push.apply(keys2, symbols);
2373
- }
2374
- return keys2;
2375
- }
2376
- function _objectSpread2(target) {
2377
- for (var i = 1; i < arguments.length; i++) {
2378
- var source = null != arguments[i] ? arguments[i] : {};
2379
- i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
2380
- _defineProperty(target, key, source[key]);
2381
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
2382
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2383
- });
2384
- }
2385
- return target;
2386
- }
2387
- var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
2388
- for (var key of Object.keys(compoundCheck)) {
2389
- var _selections$key;
2390
- if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
2391
- return false;
2392
- }
2393
- }
2394
- return true;
2395
- };
2396
- var createRuntimeFn = (config) => (options) => {
2397
- var className = config.defaultClassName;
2398
- var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
2399
- for (var variantName in selections) {
2400
- var _selections$variantNa;
2401
- var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
2402
- if (variantSelection != null) {
2403
- var selection = variantSelection;
2404
- if (typeof selection === "boolean") {
2405
- selection = selection === true ? "true" : "false";
2406
- }
2407
- var selectionClassName = (
2408
- // @ts-expect-error
2409
- config.variantClassNames[variantName][selection]
2410
- );
2411
- if (selectionClassName) {
2412
- className += " " + selectionClassName;
2413
- }
2414
- }
2415
- }
2416
- for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
2417
- if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
2418
- className += " " + compoundClassName;
2419
- }
2420
- }
2421
- return className;
2422
- };
2423
2429
  var gmap = "_7anfuo0";
2424
2430
  const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
2425
2431
  const setMap = props.mapRef;
@@ -3373,6 +3379,19 @@ const BusinessQuotingMap = defineLagecySetup(function BusinessQuotingMap2(props)
3373
3379
  })]);
3374
3380
  };
3375
3381
  }).props(["fallback", "from", "loading", "mapRef", "registerOverlay", "renderDescription", "to", "fromDescription", "log"]);
3382
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = "MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT";
3383
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT = 100 + 20;
3384
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY = 100 + 70;
3385
+ const patchMiniprogramRedirectTo = (wx2) => {
3386
+ const patchedRedirectTo = (props) => {
3387
+ const webviewCloseEvent = new Event(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT);
3388
+ dispatchEvent(webviewCloseEvent);
3389
+ setTimeout(() => {
3390
+ wx2.miniProgram.redirectTo(props);
3391
+ }, MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY);
3392
+ };
3393
+ return patchedRedirectTo;
3394
+ };
3376
3395
  const DEVICE_ORIENTATION_INTERVAL = 1e3;
3377
3396
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
3378
3397
  const useDeviceOrientation = (props) => {
@@ -3416,8 +3435,12 @@ function compatibaleAddEventListenerDeviceOrientation(handler) {
3416
3435
  if (isIOSDeviceOrientationPermissionGranted) {
3417
3436
  return addEventListener("deviceorientation", handler);
3418
3437
  }
3419
- const handleTouchEnd = () => {
3438
+ const handleTouchEnd = async () => {
3420
3439
  removeEventListener("touchend", handleTouchEnd);
3440
+ if (detectBrowserPlatform() === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM && await waitMiniProgramWebviewClose(MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT)) {
3441
+ addEventListener("touchend", handleTouchEnd);
3442
+ return;
3443
+ }
3421
3444
  DeviceOrientationEvent == null ? void 0 : DeviceOrientationEvent.requestPermission().then((permissionState) => {
3422
3445
  if (permissionState === "granted") {
3423
3446
  isIOSDeviceOrientationPermissionGranted = true;
@@ -3438,6 +3461,20 @@ function compatibleRemoveEventListenerDeviceOrientation(handler) {
3438
3461
  }
3439
3462
  return removeEventListener("deviceorientation", handler);
3440
3463
  }
3464
+ function waitMiniProgramWebviewClose(duration) {
3465
+ return new Promise((resolve) => {
3466
+ const handleMiniProgramWebviewClose = () => {
3467
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3468
+ clearTimeout(timer);
3469
+ resolve(true);
3470
+ };
3471
+ addEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3472
+ const timer = setTimeout(() => {
3473
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3474
+ resolve(false);
3475
+ }, duration);
3476
+ });
3477
+ }
3441
3478
  const watchVisibilityState = () => {
3442
3479
  const visibilityStateRef = Vue.ref(document.visibilityState);
3443
3480
  const handleVisibilityChange = () => {
@@ -6289,9 +6326,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6289
6326
  }
6290
6327
  },
6291
6328
  onChange: (v) => emit("changeGeoLocation", v),
6292
- onError: (e) => {
6293
- emit("geoError", e);
6294
- }
6329
+ onError: (e) => emit("geoError", e)
6295
6330
  });
6296
6331
  mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
6297
6332
  mapContext.setCenterPlaceByUserSpecifiedInZone = setCenterPlaceByUserSpecifiedInZone;
@@ -6361,14 +6396,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6361
6396
  });
6362
6397
  }
6363
6398
  });
6364
- Vue.watchEffect(() => {
6365
- mapContext.onChangeCenterPlace({
6366
- ...centerPlace
6367
- });
6368
- });
6369
- Vue.watchEffect(() => {
6370
- mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
6371
- });
6372
6399
  return () => {
6373
6400
  var _a2, _b2;
6374
6401
  const {
@@ -6408,7 +6435,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6408
6435
  "attrs": {
6409
6436
  "title": title,
6410
6437
  "description": description,
6411
- "type": isDragging.value ? "locator" : "box"
6438
+ "type": isDragging.value ? "locator" : "box",
6439
+ "withArrow": true
6412
6440
  },
6413
6441
  "on": {
6414
6442
  "click": () => emit("clickLocator")
@@ -6416,6 +6444,220 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6416
6444
  })]);
6417
6445
  };
6418
6446
  }).props(["log", "geoLoadingTitle", "unavailableTitle", "recomendDescription", "fallback", "geoDefaultPosition", "getRecomendPlace", "getDefaultCenterPlace", "loading", "mapContext"]);
6447
+ const emptyPlace = {
6448
+ lng: 0,
6449
+ lat: 0,
6450
+ name: "",
6451
+ displayName: ""
6452
+ };
6453
+ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlaceMap2(props, {
6454
+ emit,
6455
+ slots
6456
+ }) {
6457
+ const {
6458
+ getRecomendPlace,
6459
+ mapContext,
6460
+ defaultPlace = {
6461
+ ...emptyPlace
6462
+ }
6463
+ } = props;
6464
+ const pipedGetRecomendPlace = pipeOnlyLastEffect(getRecomendPlace);
6465
+ const {
6466
+ mapRef,
6467
+ mapElementRef,
6468
+ setMap,
6469
+ panTo
6470
+ } = useHeycarMap();
6471
+ const {
6472
+ zoomRef
6473
+ } = useMapZoom({
6474
+ mapRef,
6475
+ defaultValue: DEFAULT_ZOOM
6476
+ });
6477
+ const centerPlace = Vue.reactive({
6478
+ lng: defaultPlace.lng,
6479
+ lat: defaultPlace.lat,
6480
+ name: defaultPlace.name,
6481
+ displayName: defaultPlace.displayName
6482
+ });
6483
+ const centerPoint = Vue.computed(() => [centerPlace.lng, centerPlace.lat]);
6484
+ const centerSource = {
6485
+ source: "default"
6486
+ };
6487
+ const updateCenterPlaceByPoint = (point) => {
6488
+ centerSource.source = "api";
6489
+ updatePlace(point);
6490
+ };
6491
+ const setCenterPlaceByUserSpecified = async (input) => {
6492
+ centerSource.source = "api";
6493
+ const place = toPlaceType(input);
6494
+ centerPlace.lng = place.lng;
6495
+ centerPlace.lat = place.lat;
6496
+ centerPlace.name = place.name;
6497
+ centerPlace.displayName = place.displayName;
6498
+ emit("changePlace", {
6499
+ ...place
6500
+ });
6501
+ updateRecommendPlace(place);
6502
+ };
6503
+ const setCenterPlaceByUserSpecifiedInZone = ({
6504
+ place,
6505
+ recommends
6506
+ }) => {
6507
+ centerPlace.lng = place.lng;
6508
+ centerPlace.lat = place.lat;
6509
+ centerPlace.name = place.name;
6510
+ centerPlace.displayName = place.displayName;
6511
+ setPlaceCandidatesAndZone(recommends);
6512
+ emit("changePlace", {
6513
+ ...place
6514
+ });
6515
+ };
6516
+ const panToCenterByPlace = async (place) => {
6517
+ centerSource.source = "api";
6518
+ await panTo(place2point(place));
6519
+ centerPlace.lng = place.lng;
6520
+ centerPlace.lat = place.lat;
6521
+ centerPlace.name = place.name;
6522
+ centerPlace.displayName = place.displayName;
6523
+ emit("changePlace", {
6524
+ ...place
6525
+ });
6526
+ emit("changeRecomandPlace", {
6527
+ place: {
6528
+ ...place
6529
+ },
6530
+ inputPlace: {
6531
+ ...place
6532
+ },
6533
+ isInZone: !!zoneRef.value
6534
+ });
6535
+ };
6536
+ const {
6537
+ orientation
6538
+ } = useDeviceOrientation({
6539
+ elementRef: mapElementRef
6540
+ });
6541
+ const {
6542
+ geoPosition,
6543
+ geoError,
6544
+ geoLoading
6545
+ } = useGeoLocation({
6546
+ geoDefaultPosition: place2point(defaultPlace),
6547
+ onError: (e) => emit("geoError", e)
6548
+ });
6549
+ mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
6550
+ mapContext.setCenterPlaceByUserSpecifiedInZone = setCenterPlaceByUserSpecifiedInZone;
6551
+ mapContext.panToGeoPositionByRecomend = () => {
6552
+ if (geoError.value)
6553
+ return false;
6554
+ updateCenterPlaceByPoint(geoPosition.value);
6555
+ return true;
6556
+ };
6557
+ const {
6558
+ isDragging
6559
+ } = useMapDrag({
6560
+ mapRef,
6561
+ onChange: (point) => {
6562
+ centerSource.source = "drag";
6563
+ updatePlace(point);
6564
+ }
6565
+ });
6566
+ const {
6567
+ updatePlace,
6568
+ updateRecommendPlace,
6569
+ updatePlaceCandidates,
6570
+ setPlaceCandidatesAndZone,
6571
+ placeCandidates,
6572
+ zoneRef,
6573
+ availableRef,
6574
+ isElectedRef
6575
+ } = useMapRecomendPlace({
6576
+ pointRef: centerPoint,
6577
+ emptyPlaceName: DEFAULT_PLACE_NAME,
6578
+ context: centerSource,
6579
+ getRecomendPlace: pipedGetRecomendPlace,
6580
+ getLimit: (context2) => {
6581
+ const source = context2 == null ? void 0 : context2.source;
6582
+ switch (source) {
6583
+ case "drag":
6584
+ return RECOMMEND_PLACE_DRAG_LIMIT;
6585
+ case "api":
6586
+ case "geo":
6587
+ case "default":
6588
+ return RECOMMEND_PLACE_LARGE_LIMIT;
6589
+ default:
6590
+ throw new Error(`MyError: should not call getLimit on source: ${source}`);
6591
+ }
6592
+ },
6593
+ onChangePlace: (place) => {
6594
+ if (centerSource.source !== "recomend") {
6595
+ updateRecommendPlace(place);
6596
+ }
6597
+ emit("changePlace", place);
6598
+ },
6599
+ onChange: async ({
6600
+ place,
6601
+ inputPlace,
6602
+ isInZone
6603
+ }) => {
6604
+ centerSource.source = "recomend";
6605
+ if (isPlaceEqual(place, centerPlace))
6606
+ panTo(place2point(place));
6607
+ Object.assign(centerPlace, {
6608
+ ...place
6609
+ });
6610
+ emit("changeRecomandPlace", {
6611
+ place,
6612
+ inputPlace,
6613
+ isInZone
6614
+ });
6615
+ }
6616
+ });
6617
+ watchPostEffectOnce(() => updatePlaceCandidates(defaultPlace));
6618
+ return () => {
6619
+ var _a, _b;
6620
+ const {
6621
+ recomendDescription,
6622
+ unavailableTitle
6623
+ } = props;
6624
+ const title = !availableRef.value ? unavailableTitle : centerPlace.displayName;
6625
+ const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
6626
+ return Vue.h(HeycarMap, {
6627
+ "attrs": {
6628
+ "center": centerPoint.value,
6629
+ "zoom": zoomRef.value,
6630
+ "touchZoomCenter": true,
6631
+ "mapRef": setMap,
6632
+ "fallback": slots.fallback,
6633
+ "loading": slots.loading
6634
+ }
6635
+ }, [((_a = zoneRef.value) == null ? void 0 : _a.path.length) && Vue.h(GreenZone, {
6636
+ "attrs": {
6637
+ "path": (_b = zoneRef.value) == null ? void 0 : _b.path
6638
+ }
6639
+ }), !geoLoading.value && !geoError.value && Vue.h(PassengerCircle, {
6640
+ "attrs": {
6641
+ "position": geoPosition.value,
6642
+ "angle": orientation.cssRotationVariableName
6643
+ }
6644
+ }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && Vue.h(PickupPoints, {
6645
+ "attrs": {
6646
+ "places": placeCandidates.value,
6647
+ "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6648
+ },
6649
+ "on": {
6650
+ "click": panToCenterByPlace
6651
+ }
6652
+ }), geoLoading.value ? null : Vue.h(AbsoluteAddressBox, {
6653
+ "attrs": {
6654
+ "title": title,
6655
+ "description": description,
6656
+ "type": isDragging.value ? "locator" : "box"
6657
+ }
6658
+ })]);
6659
+ };
6660
+ }).props(["loading", "fallback", "log", "defaultPlace", "unavailableTitle", "recomendDescription", "getRecomendPlace", "mapContext"]);
6419
6661
  const useAmapGeometry = () => {
6420
6662
  const payload = useMapSupplier();
6421
6663
  const apiMapDistance = (from, to) => {
@@ -7548,12 +7790,6 @@ const useBusinessRecomendPlaceMap = () => {
7548
7790
  },
7549
7791
  setCenterPlaceByUserSpecifiedInZone: () => {
7550
7792
  throw new Error("MyError: setCenterPlaceByUserSpecifiedInZone used before assigned");
7551
- },
7552
- onChangeCenterPlace: (place) => {
7553
- Object.assign(centerPlace, { ...place });
7554
- },
7555
- onChangeRecomendPlaces: (places) => {
7556
- placeCandidates.value = [...places];
7557
7793
  }
7558
7794
  };
7559
7795
  return {
@@ -7567,6 +7803,9 @@ const useBusinessRecomendPlaceMap = () => {
7567
7803
  apiMapInChina: inChina
7568
7804
  };
7569
7805
  };
7806
+ const useBusinessReselectPlaceMap = () => {
7807
+ return useBusinessRecomendPlaceMap();
7808
+ };
7570
7809
  const useBusinessTaxiServiceMap = () => {
7571
7810
  const { mapRef, setMap } = useHeycarMap();
7572
7811
  const { registerFitVeiw, setFitView } = useMapFitView({
@@ -7581,11 +7820,14 @@ exports.AbsoluteAddressBox = AbsoluteAddressBox;
7581
7820
  exports.AddressBox = AddressBox;
7582
7821
  exports.BusinessQuotingMap = BusinessQuotingMap;
7583
7822
  exports.BusinessRecomendPlaceMap = BusinessRecomendPlaceMap;
7823
+ exports.BusinessReselectPlaceMap = BusinessReselectPlaceMap;
7584
7824
  exports.BusinessTaxiEndMap = BusinessTaxiEndMap;
7585
7825
  exports.BusinessTaxiServiceMap = BusinessTaxiServiceMap;
7586
7826
  exports.DrivingLine = DrivingLine;
7587
7827
  exports.DrivingRoute = DrivingRoute;
7588
7828
  exports.HeycarMap = HeycarMap;
7829
+ exports.MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT;
7830
+ exports.MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT = MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT;
7589
7831
  exports.MapProvider = MapProvider;
7590
7832
  exports.PassengerCircle = PassengerCircle;
7591
7833
  exports.PickupPoints = PickupPoints;
@@ -7595,9 +7837,11 @@ exports.TaxiCar = TaxiCar;
7595
7837
  exports.WalkingLine = WalkingLine;
7596
7838
  exports.WalkingRoute = WalkingRoute;
7597
7839
  exports.WaveCircle = WaveCircle;
7840
+ exports.patchMiniprogramRedirectTo = patchMiniprogramRedirectTo;
7598
7841
  exports.useBusinessAlarm = useBusinessAlarm;
7599
7842
  exports.useBusinessQuotingMap = useBusinessQuotingMap;
7600
7843
  exports.useBusinessRecomendPlaceMap = useBusinessRecomendPlaceMap;
7844
+ exports.useBusinessReselectPlaceMap = useBusinessReselectPlaceMap;
7601
7845
  exports.useBusinessTaxiServiceMap = useBusinessTaxiServiceMap;
7602
7846
  exports.useDrivingRoute = useDrivingRoute;
7603
7847
  exports.useGeoLocation = useGeoLocation;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  import Vue, { defineComponent, h, computed, inject, provide, watch, onMounted, onUnmounted, watchPostEffect, shallowRef, ref, watchEffect, reactive, toRefs, toRef } from "vue";
8
8
  const style = "";
9
9
  const name = "@heycar/heycars-map";
10
- const version = "0.7.10";
10
+ const version = "0.8.0";
11
11
  const type = "module";
12
12
  const scripts = {
13
13
  dev: "vite -c vite.config.dev.ts",
@@ -653,15 +653,85 @@ function defineLagecySetup(setup) {
653
653
  const createElement = h;
654
654
  const LANGUAGE = "zh-CN";
655
655
  const AbsoluteAddressBox_css_ts_vanilla = "";
656
+ function _defineProperty(obj, key, value) {
657
+ if (key in obj) {
658
+ Object.defineProperty(obj, key, {
659
+ value,
660
+ enumerable: true,
661
+ configurable: true,
662
+ writable: true
663
+ });
664
+ } else {
665
+ obj[key] = value;
666
+ }
667
+ return obj;
668
+ }
669
+ function ownKeys(object, enumerableOnly) {
670
+ var keys2 = Object.keys(object);
671
+ if (Object.getOwnPropertySymbols) {
672
+ var symbols = Object.getOwnPropertySymbols(object);
673
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
674
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
675
+ })), keys2.push.apply(keys2, symbols);
676
+ }
677
+ return keys2;
678
+ }
679
+ function _objectSpread2(target) {
680
+ for (var i = 1; i < arguments.length; i++) {
681
+ var source = null != arguments[i] ? arguments[i] : {};
682
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
683
+ _defineProperty(target, key, source[key]);
684
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
685
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
686
+ });
687
+ }
688
+ return target;
689
+ }
690
+ var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
691
+ for (var key of Object.keys(compoundCheck)) {
692
+ var _selections$key;
693
+ if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
694
+ return false;
695
+ }
696
+ }
697
+ return true;
698
+ };
699
+ var createRuntimeFn = (config) => (options) => {
700
+ var className = config.defaultClassName;
701
+ var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
702
+ for (var variantName in selections) {
703
+ var _selections$variantNa;
704
+ var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
705
+ if (variantSelection != null) {
706
+ var selection = variantSelection;
707
+ if (typeof selection === "boolean") {
708
+ selection = selection === true ? "true" : "false";
709
+ }
710
+ var selectionClassName = (
711
+ // @ts-expect-error
712
+ config.variantClassNames[variantName][selection]
713
+ );
714
+ if (selectionClassName) {
715
+ className += " " + selectionClassName;
716
+ }
717
+ }
718
+ }
719
+ for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
720
+ if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
721
+ className += " " + compoundClassName;
722
+ }
723
+ }
724
+ return className;
725
+ };
656
726
  var absoluteAddressBox = "n8tgem1";
657
727
  var absoluteAddressBoxLayout = "n8tgem0";
658
- var arrowRight = "n8tgem6";
659
- var boxDescription = "n8tgem4";
660
- var boxTextLayout = "n8tgem2";
661
- var boxTitle = "n8tgem3";
662
- var imgDotLoading = "n8tgem5";
663
- var locatorIcon = "n8tgem8";
664
- var straightLine = "n8tgem7";
728
+ var arrowRight = "n8tgem8";
729
+ var boxDescription = "n8tgem6";
730
+ var boxTextLayout = createRuntimeFn({ defaultClassName: "n8tgem2", variantClassNames: { withArrow: { true: "n8tgem3", false: "n8tgem4" } }, defaultVariants: {}, compoundVariants: [] });
731
+ var boxTitle = "n8tgem5";
732
+ var imgDotLoading = "n8tgem7";
733
+ var locatorIcon = "n8tgema";
734
+ var straightLine = "n8tgem9";
665
735
  const MultilineTitle = defineSetup(function MultilineTitle2(props) {
666
736
  const linesRef = computed(() => {
667
737
  var _a;
@@ -677,7 +747,8 @@ const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox2(props, {
677
747
  const {
678
748
  type: type2,
679
749
  title,
680
- description
750
+ description,
751
+ withArrow = false
681
752
  } = props;
682
753
  if (type2 === "locator")
683
754
  return h("div", {
@@ -712,7 +783,9 @@ const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox2(props, {
712
783
  "click": handleClick
713
784
  }
714
785
  }, [h("div", {
715
- "class": boxTextLayout
786
+ "class": boxTextLayout({
787
+ withArrow
788
+ })
716
789
  }, [h(MultilineTitle, {
717
790
  "class": boxTitle,
718
791
  "attrs": {
@@ -720,7 +793,7 @@ const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox2(props, {
720
793
  }
721
794
  }), !!description && h("div", {
722
795
  "class": boxDescription
723
- }, [description])]), h("img", {
796
+ }, [description])]), withArrow && h("img", {
724
797
  "class": arrowRight,
725
798
  "attrs": {
726
799
  "src": imgArrowRight
@@ -1248,6 +1321,9 @@ function watchPostEffectForGMapEvent(targetRef, props, emit, propertyNames) {
1248
1321
  });
1249
1322
  });
1250
1323
  }
1324
+ const watchPostEffectOnce = (callback) => {
1325
+ watch(() => 0, callback, { immediate: true, flush: "post" });
1326
+ };
1251
1327
  const AmapMarker = defineSetup(function AmapMarker2(props, { emit }) {
1252
1328
  const { registerOverlay } = props;
1253
1329
  const markerRef = shallowRef();
@@ -2348,76 +2424,6 @@ const useResizeObserver = (props) => {
2348
2424
  });
2349
2425
  };
2350
2426
  const Gmap_css_ts_vanilla = "";
2351
- function _defineProperty(obj, key, value) {
2352
- if (key in obj) {
2353
- Object.defineProperty(obj, key, {
2354
- value,
2355
- enumerable: true,
2356
- configurable: true,
2357
- writable: true
2358
- });
2359
- } else {
2360
- obj[key] = value;
2361
- }
2362
- return obj;
2363
- }
2364
- function ownKeys(object, enumerableOnly) {
2365
- var keys2 = Object.keys(object);
2366
- if (Object.getOwnPropertySymbols) {
2367
- var symbols = Object.getOwnPropertySymbols(object);
2368
- enumerableOnly && (symbols = symbols.filter(function(sym) {
2369
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2370
- })), keys2.push.apply(keys2, symbols);
2371
- }
2372
- return keys2;
2373
- }
2374
- function _objectSpread2(target) {
2375
- for (var i = 1; i < arguments.length; i++) {
2376
- var source = null != arguments[i] ? arguments[i] : {};
2377
- i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
2378
- _defineProperty(target, key, source[key]);
2379
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
2380
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2381
- });
2382
- }
2383
- return target;
2384
- }
2385
- var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
2386
- for (var key of Object.keys(compoundCheck)) {
2387
- var _selections$key;
2388
- if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
2389
- return false;
2390
- }
2391
- }
2392
- return true;
2393
- };
2394
- var createRuntimeFn = (config) => (options) => {
2395
- var className = config.defaultClassName;
2396
- var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
2397
- for (var variantName in selections) {
2398
- var _selections$variantNa;
2399
- var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
2400
- if (variantSelection != null) {
2401
- var selection = variantSelection;
2402
- if (typeof selection === "boolean") {
2403
- selection = selection === true ? "true" : "false";
2404
- }
2405
- var selectionClassName = (
2406
- // @ts-expect-error
2407
- config.variantClassNames[variantName][selection]
2408
- );
2409
- if (selectionClassName) {
2410
- className += " " + selectionClassName;
2411
- }
2412
- }
2413
- }
2414
- for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
2415
- if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
2416
- className += " " + compoundClassName;
2417
- }
2418
- }
2419
- return className;
2420
- };
2421
2427
  var gmap = "_7anfuo0";
2422
2428
  const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
2423
2429
  const setMap = props.mapRef;
@@ -3371,6 +3377,19 @@ const BusinessQuotingMap = defineLagecySetup(function BusinessQuotingMap2(props)
3371
3377
  })]);
3372
3378
  };
3373
3379
  }).props(["fallback", "from", "loading", "mapRef", "registerOverlay", "renderDescription", "to", "fromDescription", "log"]);
3380
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = "MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT";
3381
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT = 100 + 20;
3382
+ const MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY = 100 + 70;
3383
+ const patchMiniprogramRedirectTo = (wx2) => {
3384
+ const patchedRedirectTo = (props) => {
3385
+ const webviewCloseEvent = new Event(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT);
3386
+ dispatchEvent(webviewCloseEvent);
3387
+ setTimeout(() => {
3388
+ wx2.miniProgram.redirectTo(props);
3389
+ }, MINI_PROGRAM_WEB_VIEW_CLOSE_DELAY);
3390
+ };
3391
+ return patchedRedirectTo;
3392
+ };
3374
3393
  const DEVICE_ORIENTATION_INTERVAL = 1e3;
3375
3394
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
3376
3395
  const useDeviceOrientation = (props) => {
@@ -3414,8 +3433,12 @@ function compatibaleAddEventListenerDeviceOrientation(handler) {
3414
3433
  if (isIOSDeviceOrientationPermissionGranted) {
3415
3434
  return addEventListener("deviceorientation", handler);
3416
3435
  }
3417
- const handleTouchEnd = () => {
3436
+ const handleTouchEnd = async () => {
3418
3437
  removeEventListener("touchend", handleTouchEnd);
3438
+ if (detectBrowserPlatform() === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM && await waitMiniProgramWebviewClose(MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT)) {
3439
+ addEventListener("touchend", handleTouchEnd);
3440
+ return;
3441
+ }
3419
3442
  DeviceOrientationEvent == null ? void 0 : DeviceOrientationEvent.requestPermission().then((permissionState) => {
3420
3443
  if (permissionState === "granted") {
3421
3444
  isIOSDeviceOrientationPermissionGranted = true;
@@ -3436,6 +3459,20 @@ function compatibleRemoveEventListenerDeviceOrientation(handler) {
3436
3459
  }
3437
3460
  return removeEventListener("deviceorientation", handler);
3438
3461
  }
3462
+ function waitMiniProgramWebviewClose(duration) {
3463
+ return new Promise((resolve) => {
3464
+ const handleMiniProgramWebviewClose = () => {
3465
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3466
+ clearTimeout(timer);
3467
+ resolve(true);
3468
+ };
3469
+ addEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3470
+ const timer = setTimeout(() => {
3471
+ removeEventListener(MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, handleMiniProgramWebviewClose);
3472
+ resolve(false);
3473
+ }, duration);
3474
+ });
3475
+ }
3439
3476
  const watchVisibilityState = () => {
3440
3477
  const visibilityStateRef = ref(document.visibilityState);
3441
3478
  const handleVisibilityChange = () => {
@@ -6287,9 +6324,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6287
6324
  }
6288
6325
  },
6289
6326
  onChange: (v) => emit("changeGeoLocation", v),
6290
- onError: (e) => {
6291
- emit("geoError", e);
6292
- }
6327
+ onError: (e) => emit("geoError", e)
6293
6328
  });
6294
6329
  mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
6295
6330
  mapContext.setCenterPlaceByUserSpecifiedInZone = setCenterPlaceByUserSpecifiedInZone;
@@ -6359,14 +6394,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6359
6394
  });
6360
6395
  }
6361
6396
  });
6362
- watchEffect(() => {
6363
- mapContext.onChangeCenterPlace({
6364
- ...centerPlace
6365
- });
6366
- });
6367
- watchEffect(() => {
6368
- mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
6369
- });
6370
6397
  return () => {
6371
6398
  var _a2, _b2;
6372
6399
  const {
@@ -6406,7 +6433,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6406
6433
  "attrs": {
6407
6434
  "title": title,
6408
6435
  "description": description,
6409
- "type": isDragging.value ? "locator" : "box"
6436
+ "type": isDragging.value ? "locator" : "box",
6437
+ "withArrow": true
6410
6438
  },
6411
6439
  "on": {
6412
6440
  "click": () => emit("clickLocator")
@@ -6414,6 +6442,220 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6414
6442
  })]);
6415
6443
  };
6416
6444
  }).props(["log", "geoLoadingTitle", "unavailableTitle", "recomendDescription", "fallback", "geoDefaultPosition", "getRecomendPlace", "getDefaultCenterPlace", "loading", "mapContext"]);
6445
+ const emptyPlace = {
6446
+ lng: 0,
6447
+ lat: 0,
6448
+ name: "",
6449
+ displayName: ""
6450
+ };
6451
+ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlaceMap2(props, {
6452
+ emit,
6453
+ slots
6454
+ }) {
6455
+ const {
6456
+ getRecomendPlace,
6457
+ mapContext,
6458
+ defaultPlace = {
6459
+ ...emptyPlace
6460
+ }
6461
+ } = props;
6462
+ const pipedGetRecomendPlace = pipeOnlyLastEffect(getRecomendPlace);
6463
+ const {
6464
+ mapRef,
6465
+ mapElementRef,
6466
+ setMap,
6467
+ panTo
6468
+ } = useHeycarMap();
6469
+ const {
6470
+ zoomRef
6471
+ } = useMapZoom({
6472
+ mapRef,
6473
+ defaultValue: DEFAULT_ZOOM
6474
+ });
6475
+ const centerPlace = reactive({
6476
+ lng: defaultPlace.lng,
6477
+ lat: defaultPlace.lat,
6478
+ name: defaultPlace.name,
6479
+ displayName: defaultPlace.displayName
6480
+ });
6481
+ const centerPoint = computed(() => [centerPlace.lng, centerPlace.lat]);
6482
+ const centerSource = {
6483
+ source: "default"
6484
+ };
6485
+ const updateCenterPlaceByPoint = (point) => {
6486
+ centerSource.source = "api";
6487
+ updatePlace(point);
6488
+ };
6489
+ const setCenterPlaceByUserSpecified = async (input) => {
6490
+ centerSource.source = "api";
6491
+ const place = toPlaceType(input);
6492
+ centerPlace.lng = place.lng;
6493
+ centerPlace.lat = place.lat;
6494
+ centerPlace.name = place.name;
6495
+ centerPlace.displayName = place.displayName;
6496
+ emit("changePlace", {
6497
+ ...place
6498
+ });
6499
+ updateRecommendPlace(place);
6500
+ };
6501
+ const setCenterPlaceByUserSpecifiedInZone = ({
6502
+ place,
6503
+ recommends
6504
+ }) => {
6505
+ centerPlace.lng = place.lng;
6506
+ centerPlace.lat = place.lat;
6507
+ centerPlace.name = place.name;
6508
+ centerPlace.displayName = place.displayName;
6509
+ setPlaceCandidatesAndZone(recommends);
6510
+ emit("changePlace", {
6511
+ ...place
6512
+ });
6513
+ };
6514
+ const panToCenterByPlace = async (place) => {
6515
+ centerSource.source = "api";
6516
+ await panTo(place2point(place));
6517
+ centerPlace.lng = place.lng;
6518
+ centerPlace.lat = place.lat;
6519
+ centerPlace.name = place.name;
6520
+ centerPlace.displayName = place.displayName;
6521
+ emit("changePlace", {
6522
+ ...place
6523
+ });
6524
+ emit("changeRecomandPlace", {
6525
+ place: {
6526
+ ...place
6527
+ },
6528
+ inputPlace: {
6529
+ ...place
6530
+ },
6531
+ isInZone: !!zoneRef.value
6532
+ });
6533
+ };
6534
+ const {
6535
+ orientation
6536
+ } = useDeviceOrientation({
6537
+ elementRef: mapElementRef
6538
+ });
6539
+ const {
6540
+ geoPosition,
6541
+ geoError,
6542
+ geoLoading
6543
+ } = useGeoLocation({
6544
+ geoDefaultPosition: place2point(defaultPlace),
6545
+ onError: (e) => emit("geoError", e)
6546
+ });
6547
+ mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
6548
+ mapContext.setCenterPlaceByUserSpecifiedInZone = setCenterPlaceByUserSpecifiedInZone;
6549
+ mapContext.panToGeoPositionByRecomend = () => {
6550
+ if (geoError.value)
6551
+ return false;
6552
+ updateCenterPlaceByPoint(geoPosition.value);
6553
+ return true;
6554
+ };
6555
+ const {
6556
+ isDragging
6557
+ } = useMapDrag({
6558
+ mapRef,
6559
+ onChange: (point) => {
6560
+ centerSource.source = "drag";
6561
+ updatePlace(point);
6562
+ }
6563
+ });
6564
+ const {
6565
+ updatePlace,
6566
+ updateRecommendPlace,
6567
+ updatePlaceCandidates,
6568
+ setPlaceCandidatesAndZone,
6569
+ placeCandidates,
6570
+ zoneRef,
6571
+ availableRef,
6572
+ isElectedRef
6573
+ } = useMapRecomendPlace({
6574
+ pointRef: centerPoint,
6575
+ emptyPlaceName: DEFAULT_PLACE_NAME,
6576
+ context: centerSource,
6577
+ getRecomendPlace: pipedGetRecomendPlace,
6578
+ getLimit: (context2) => {
6579
+ const source = context2 == null ? void 0 : context2.source;
6580
+ switch (source) {
6581
+ case "drag":
6582
+ return RECOMMEND_PLACE_DRAG_LIMIT;
6583
+ case "api":
6584
+ case "geo":
6585
+ case "default":
6586
+ return RECOMMEND_PLACE_LARGE_LIMIT;
6587
+ default:
6588
+ throw new Error(`MyError: should not call getLimit on source: ${source}`);
6589
+ }
6590
+ },
6591
+ onChangePlace: (place) => {
6592
+ if (centerSource.source !== "recomend") {
6593
+ updateRecommendPlace(place);
6594
+ }
6595
+ emit("changePlace", place);
6596
+ },
6597
+ onChange: async ({
6598
+ place,
6599
+ inputPlace,
6600
+ isInZone
6601
+ }) => {
6602
+ centerSource.source = "recomend";
6603
+ if (isPlaceEqual(place, centerPlace))
6604
+ panTo(place2point(place));
6605
+ Object.assign(centerPlace, {
6606
+ ...place
6607
+ });
6608
+ emit("changeRecomandPlace", {
6609
+ place,
6610
+ inputPlace,
6611
+ isInZone
6612
+ });
6613
+ }
6614
+ });
6615
+ watchPostEffectOnce(() => updatePlaceCandidates(defaultPlace));
6616
+ return () => {
6617
+ var _a, _b;
6618
+ const {
6619
+ recomendDescription,
6620
+ unavailableTitle
6621
+ } = props;
6622
+ const title = !availableRef.value ? unavailableTitle : centerPlace.displayName;
6623
+ const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
6624
+ return h(HeycarMap, {
6625
+ "attrs": {
6626
+ "center": centerPoint.value,
6627
+ "zoom": zoomRef.value,
6628
+ "touchZoomCenter": true,
6629
+ "mapRef": setMap,
6630
+ "fallback": slots.fallback,
6631
+ "loading": slots.loading
6632
+ }
6633
+ }, [((_a = zoneRef.value) == null ? void 0 : _a.path.length) && h(GreenZone, {
6634
+ "attrs": {
6635
+ "path": (_b = zoneRef.value) == null ? void 0 : _b.path
6636
+ }
6637
+ }), !geoLoading.value && !geoError.value && h(PassengerCircle, {
6638
+ "attrs": {
6639
+ "position": geoPosition.value,
6640
+ "angle": orientation.cssRotationVariableName
6641
+ }
6642
+ }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && h(PickupPoints, {
6643
+ "attrs": {
6644
+ "places": placeCandidates.value,
6645
+ "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6646
+ },
6647
+ "on": {
6648
+ "click": panToCenterByPlace
6649
+ }
6650
+ }), geoLoading.value ? null : h(AbsoluteAddressBox, {
6651
+ "attrs": {
6652
+ "title": title,
6653
+ "description": description,
6654
+ "type": isDragging.value ? "locator" : "box"
6655
+ }
6656
+ })]);
6657
+ };
6658
+ }).props(["loading", "fallback", "log", "defaultPlace", "unavailableTitle", "recomendDescription", "getRecomendPlace", "mapContext"]);
6417
6659
  const useAmapGeometry = () => {
6418
6660
  const payload = useMapSupplier();
6419
6661
  const apiMapDistance = (from, to) => {
@@ -7546,12 +7788,6 @@ const useBusinessRecomendPlaceMap = () => {
7546
7788
  },
7547
7789
  setCenterPlaceByUserSpecifiedInZone: () => {
7548
7790
  throw new Error("MyError: setCenterPlaceByUserSpecifiedInZone used before assigned");
7549
- },
7550
- onChangeCenterPlace: (place) => {
7551
- Object.assign(centerPlace, { ...place });
7552
- },
7553
- onChangeRecomendPlaces: (places) => {
7554
- placeCandidates.value = [...places];
7555
7791
  }
7556
7792
  };
7557
7793
  return {
@@ -7565,6 +7801,9 @@ const useBusinessRecomendPlaceMap = () => {
7565
7801
  apiMapInChina: inChina
7566
7802
  };
7567
7803
  };
7804
+ const useBusinessReselectPlaceMap = () => {
7805
+ return useBusinessRecomendPlaceMap();
7806
+ };
7568
7807
  const useBusinessTaxiServiceMap = () => {
7569
7808
  const { mapRef, setMap } = useHeycarMap();
7570
7809
  const { registerFitVeiw, setFitView } = useMapFitView({
@@ -7580,11 +7819,14 @@ export {
7580
7819
  AddressBox,
7581
7820
  BusinessQuotingMap,
7582
7821
  BusinessRecomendPlaceMap,
7822
+ BusinessReselectPlaceMap,
7583
7823
  BusinessTaxiEndMap,
7584
7824
  BusinessTaxiServiceMap,
7585
7825
  DrivingLine,
7586
7826
  DrivingRoute,
7587
7827
  HeycarMap,
7828
+ MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT,
7829
+ MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT,
7588
7830
  MapProvider,
7589
7831
  PassengerCircle,
7590
7832
  PickupPoints,
@@ -7594,9 +7836,11 @@ export {
7594
7836
  WalkingLine,
7595
7837
  WalkingRoute,
7596
7838
  WaveCircle,
7839
+ patchMiniprogramRedirectTo,
7597
7840
  useBusinessAlarm,
7598
7841
  useBusinessQuotingMap,
7599
7842
  useBusinessRecomendPlaceMap,
7843
+ useBusinessReselectPlaceMap,
7600
7844
  useBusinessTaxiServiceMap,
7601
7845
  useDrivingRoute,
7602
7846
  useGeoLocation,
@@ -0,0 +1 @@
1
+ export declare const DemoBusinessReselectPlace: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../types/helper").Empty, import("../types/helper").Empty, import("../types/helper").Empty, import("../types/helper").Empty, import("../types/helper").Empty, import("../types/helper").Empty, import("../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
@@ -1,6 +1,13 @@
1
1
  export declare const absoluteAddressBoxLayout: string;
2
2
  export declare const absoluteAddressBox: string;
3
- export declare const boxTextLayout: string;
3
+ export declare const boxTextLayout: import("@vanilla-extract/recipes").RuntimeFn<{
4
+ withArrow: {
5
+ true: {
6
+ paddingRight: "2.67vw";
7
+ };
8
+ false: {};
9
+ };
10
+ }>;
4
11
  export declare const boxTitle: string;
5
12
  export declare const boxDescription: string;
6
13
  export declare const imgDotLoading: string;
@@ -2,6 +2,7 @@ export interface AbsoluteAddressBoxProps {
2
2
  type: "box" | "locator" | "loading";
3
3
  title: string;
4
4
  description?: string;
5
+ withArrow?: boolean;
5
6
  onClick?: () => any;
6
7
  }
7
8
  export declare const AbsoluteAddressBox: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<AbsoluteAddressBoxProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<AbsoluteAddressBoxProps, Required<AbsoluteAddressBoxProps>>, "click", AbsoluteAddressBoxProps, {}>;
@@ -6,6 +6,11 @@ import type { UseMapPlaceProps } from "../../hooks/useMapPlace";
6
6
  import { UseMapRecomendPlaceProps } from "../../hooks/useMapRecomendPlace";
7
7
  import type { Place, Point } from "../../types/interface";
8
8
  import { AbsoluteAddressBoxProps } from "../AbsoluteAddressBox";
9
+ export declare const RECOMMEND_PLACE_DRAG_LIMIT = 10;
10
+ export declare const RECOMMEND_PLACE_LARGE_LIMIT = 100;
11
+ export declare const RECOMMEND_PLACE_ZOOM_MIN = 13;
12
+ export declare const DEFAULT_PLACE_NAME = "\u5F53\u524D\u4F4D\u7F6E";
13
+ export declare const DEFAULT_ZOOM = 17;
9
14
  export interface CenterPlaceSource {
10
15
  source: "default" | "geo" | "drag" | "recomend" | "api";
11
16
  }
@@ -0,0 +1,6 @@
1
+ import type { Place } from "../../types/interface";
2
+ import { type BusinessRecomendPlaceMapProps } from "../BusinessRecomendPlaceMap";
3
+ export interface BusinessReselectPlaceMapProps extends Pick<BusinessRecomendPlaceMapProps, "loading" | "fallback" | "log" | "getRecomendPlace" | "unavailableTitle" | "recomendDescription" | "mapContext" | "onChangePlace" | "onChangeRecomandPlace" | "onGeoError"> {
4
+ defaultPlace?: Place;
5
+ }
6
+ export declare const BusinessReselectPlaceMap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<BusinessReselectPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessReselectPlaceMapProps, Required<BusinessReselectPlaceMapProps>>, "changePlace" | "changeRecomandPlace" | "geoError", BusinessReselectPlaceMapProps, {}>;
@@ -0,0 +1 @@
1
+ export * from "./BusinessReselectPlaceMap";
@@ -7,8 +7,6 @@ export interface BusinessRecomendPlaceContext {
7
7
  panToGeoPositionByRecomend: (value: Point) => void;
8
8
  setCenterPlaceByUserSpecified: (value: Place) => void;
9
9
  setCenterPlaceByUserSpecifiedInZone: (value: SetCenterPlaceByUserSpecifiedInZoneProps) => void;
10
- onChangeCenterPlace: (value: Place) => void;
11
- onChangeRecomendPlaces: (value: Place[]) => void;
12
10
  }
13
11
  export declare const useBusinessRecomendPlaceMap: () => {
14
12
  mapContext: BusinessRecomendPlaceContext;
@@ -0,0 +1,20 @@
1
+ export declare const useBusinessReselectPlaceMap: () => {
2
+ mapContext: import("./useBusinessRecomendPlaceMap").BusinessRecomendPlaceContext;
3
+ centerPlace: {
4
+ lng: number;
5
+ lat: number;
6
+ name: string;
7
+ displayName: string;
8
+ };
9
+ placeCandidates: import("vue").Ref<{
10
+ lng: number;
11
+ lat: number;
12
+ name: string;
13
+ displayName: string;
14
+ }[]>;
15
+ panToGeoPositionByRecomend: (value: import("..").Point) => void;
16
+ setCenterPlaceByUserSpecified: (value: import("..").Place) => void;
17
+ setCenterPlaceByUserSpecifiedInZone: (value: import("./useBusinessRecomendPlaceMap").SetCenterPlaceByUserSpecifiedInZoneProps) => void;
18
+ apiMapDistance: (from: import("..").Point, to: import("..").Point) => number | undefined;
19
+ apiMapInChina: (point: import("..").Point) => boolean;
20
+ };
@@ -3,6 +3,7 @@ export { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox";
3
3
  export { AddressBox } from "./business-components/AddressBox";
4
4
  export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
5
5
  export { BusinessRecomendPlaceMap } from "./business-components/BusinessRecomendPlaceMap";
6
+ export { BusinessReselectPlaceMap } from "./business-components/BusinessReselectPlaceMap";
6
7
  export { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap";
7
8
  export { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap";
8
9
  export { DrivingLine } from "./business-components/DrivingLine";
@@ -19,6 +20,7 @@ export * from "./components/MapProvider";
19
20
  export * from "./hooks-business/useBusinessAlarm";
20
21
  export * from "./hooks-business/useBusinessQuotingMap";
21
22
  export * from "./hooks-business/useBusinessRecomendPlaceMap";
23
+ export * from "./hooks-business/useBusinessReselectPlaceMap";
22
24
  export * from "./hooks-business/useBusinessTaxiServiceMap";
23
25
  export { useDrivingRoute } from "./hooks/useDrivingRoute";
24
26
  export { useGeoLocation } from "./hooks/useGeoLocation";
@@ -31,3 +33,4 @@ export { useMapPlace } from "./hooks/useMapPlace";
31
33
  export { useMapRecomendPlace } from "./hooks/useMapRecomendPlace";
32
34
  export { useWalkingRoute } from "./hooks/useWalkingRoute";
33
35
  export * from "./types/interface";
36
+ export * from "./utils/patchMiniprogram";
@@ -7,6 +7,12 @@ export interface WxGetLocationSuccessResponse extends WxResponse {
7
7
  speed: string;
8
8
  accuracy: string;
9
9
  }
10
+ interface WxMiniProgramRedirectToProps {
11
+ url: string;
12
+ sucess?: () => void;
13
+ fail?: () => void;
14
+ complete?: () => void;
15
+ }
10
16
  interface WxGetLocationProps {
11
17
  type: "wgs84" | "gcj02";
12
18
  success: (response: WxGetLocationSuccessResponse) => void;
@@ -17,5 +23,8 @@ export interface Wx {
17
23
  ready: (callback: () => void) => void;
18
24
  error: (callback: (response: WxResponse) => void) => void;
19
25
  getLocation: (props: WxGetLocationProps) => void;
26
+ miniProgram: {
27
+ redirectTo: (props: WxMiniProgramRedirectToProps) => void;
28
+ };
20
29
  }
21
30
  export {};
@@ -19,4 +19,5 @@ export declare function watchNoneImmediatePostEffectForMapProperty<T, P>(targetR
19
19
  type NamesRestrict<N, S extends string> = N extends `on${string}` ? Lowercase<N> extends `on${S}` ? N : never : never;
20
20
  export declare function watchPostEffectForAMapEvent<T extends AMap.Event, P, E extends string = AMap.EventType>(targetRef: ShallowRef<T | undefined> | Ref<T | undefined> | undefined, props: P, emit: EmitFn<EmitByProps<P>>, propertyNames: NamesRestrict<keyof P, E>[]): void;
21
21
  export declare function watchPostEffectForGMapEvent<T extends google.maps.MVCObject | google.maps.marker.AdvancedMarkerView, P>(targetRef: ShallowRef<T | undefined> | Ref<T | undefined> | undefined, props: P, emit: EmitFn<EmitByProps<P>>, propertyNames: NamesRestrict<keyof P, string>[]): void;
22
+ export declare const watchPostEffectOnce: (callback: WatchCallback) => void;
22
23
  export {};
@@ -0,0 +1,4 @@
1
+ import type { Wx } from "../types/wx";
2
+ export declare const MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT = "MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT";
3
+ export declare const MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT: number;
4
+ export declare const patchMiniprogramRedirectTo: (wx: Wx) => Wx["miniProgram"]["redirectTo"];
package/dist/style.css CHANGED
@@ -20,10 +20,12 @@
20
20
  align-items: center;
21
21
  }
22
22
  .n8tgem2 {
23
- padding-right: 2.67vw;
24
23
  max-width: 41.33vw;
25
24
  }
26
25
  .n8tgem3 {
26
+ padding-right: 2.67vw;
27
+ }
28
+ .n8tgem5 {
27
29
  display: -webkit-box;
28
30
  font-size: 3.47vw;
29
31
  font-family: PingFangSC-Semibold, PingFang SC;
@@ -34,7 +36,7 @@
34
36
  -webkit-box-orient: vertical;
35
37
  overflow: hidden;
36
38
  }
37
- .n8tgem4 {
39
+ .n8tgem6 {
38
40
  margin-top: 0.53vw;
39
41
  font-size: 2.93vw;
40
42
  font-family: PingFangSC-Regular, PingFang SC;
@@ -43,22 +45,22 @@
43
45
  line-height: 4.27vw;
44
46
  opacity: 0.8;
45
47
  }
46
- .n8tgem5 {
48
+ .n8tgem7 {
47
49
  margin: 1.865vw 0;
48
50
  width: 7.467vw;
49
51
  height: 1.6vw;
50
52
  }
51
- .n8tgem6 {
53
+ .n8tgem8 {
52
54
  width: 1.758vw;
53
55
  height: 2.93vw;
54
56
  }
55
- .n8tgem7 {
57
+ .n8tgem9 {
56
58
  width: 0.8vw;
57
59
  height: 4vw;
58
60
  background: #4C80FF;
59
61
  border-radius: 0vw 0vw 26.67vw 26.67vw;
60
62
  }
61
- .n8tgem8 {
63
+ .n8tgema {
62
64
  width: 6.9355vw;
63
65
  height: 10.67vw;
64
66
  }.rgf09w0 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.7.10",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",