tg-map-vue3 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/src/components/TgMap.vue.d.ts +142 -33
  2. package/dist/src/components/TgMapWidget.vue.d.ts +3 -5
  3. package/dist/src/components/controls/TgCustomControl.vue.d.ts +14 -11
  4. package/dist/src/components/controls/TgMapTypeControl.vue.d.ts +29 -11
  5. package/dist/src/components/controls/TgScaleControl.vue.d.ts +17 -9
  6. package/dist/src/components/controls/TgZoomControl.vue.d.ts +17 -9
  7. package/dist/src/components/extra/TgMarkerClusterer.vue.d.ts +51 -39
  8. package/dist/src/components/index.d.ts +1 -1
  9. package/dist/src/components/layers/TgTrafficLayer.vue.d.ts +4 -6
  10. package/dist/src/components/map-mixin.d.ts +2 -4
  11. package/dist/src/components/overlays/TgCircle.vue.d.ts +76 -19
  12. package/dist/src/components/overlays/TgElementOverlay.vue.d.ts +25 -14
  13. package/dist/src/components/overlays/TgInfoBox.vue.d.ts +52 -20
  14. package/dist/src/components/overlays/TgInfoWindow.vue.d.ts +46 -19
  15. package/dist/src/components/overlays/TgLabel.vue.d.ts +32 -13
  16. package/dist/src/components/overlays/TgMarker.vue.d.ts +176 -50
  17. package/dist/src/components/overlays/TgPolygon.vue.d.ts +69 -18
  18. package/dist/src/components/overlays/TgPolyline.vue.d.ts +57 -16
  19. package/dist/src/map/event.d.ts +1 -2
  20. package/dist/src/map/map/baidu-map.d.ts +2 -2
  21. package/dist/src/map/map/map-options.d.ts +2 -1
  22. package/dist/src/map/map/map-type.d.ts +1 -0
  23. package/dist/src/map/map/overlay/baidu-info-box.d.ts +1 -0
  24. package/dist/src/map/map/overlay/element-overlay.d.ts +1 -0
  25. package/dist/src/utils/formatter.d.ts +1 -1
  26. package/dist/src/utils/lifecycle-log.d.ts +1 -1
  27. package/dist/src/utils/mapped-types.d.ts +3 -3
  28. package/dist/src/utils/vue-utils.d.ts +71 -19
  29. package/dist/style.css +1 -1
  30. package/dist/tg-map.js +1117 -1091
  31. package/dist/tg-map.js.map +1 -1
  32. package/dist/tg-map.umd.cjs +4 -4
  33. package/dist/tg-map.umd.cjs.map +1 -1
  34. package/package.json +7 -6
@@ -1,18 +1,59 @@
1
- /// <reference path="../map-mixin.d.ts" />
2
- /// <reference types="@/global" />
3
- import { type Props } from '../../utils/vue-utils';
4
- import type { PolylineOptions, PolylineOverlay } from '../../map/map/overlay/polyline';
5
- declare const _sfc_main: import('./@vue/compat').DefineComponent<Props<PolylineOptions>, {
1
+ import { type PropType } from 'vue';
2
+ import type { PolylineOverlay } from '../../map/map/overlay/polyline';
3
+ import type { LatLng } from '../../map/lat-lng';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ path: {
6
+ type: PropType<LatLng[]>;
7
+ required: true;
8
+ };
9
+ clickable: {
10
+ type: PropType<boolean>;
11
+ };
12
+ editable: {
13
+ type: PropType<boolean>;
14
+ };
15
+ strokeColor: {
16
+ type: PropType<string>;
17
+ };
18
+ strokeOpacity: {
19
+ type: PropType<number>;
20
+ };
21
+ strokeWeight: {
22
+ type: PropType<number>;
23
+ };
24
+ visible: {
25
+ type: PropType<boolean>;
26
+ };
27
+ }, {
28
+ attrs: {
29
+ binds: Record<string, unknown>;
30
+ listeners: Record<string, unknown>;
31
+ };
6
32
  polyline: PolylineOverlay;
7
- }, unknown, {}, {}, import('./@vue/compat').DefineComponent<{}, {}, {}, {}, {
33
+ }, unknown, {}, {}, import("vue").DefineComponent<{}, {}, {}, {}, {
8
34
  recreate(): void;
9
- }, import('./@vue/compat').ComponentOptionsMixin, import('./@vue/compat').ComponentOptionsMixin, {}, string, import('./@vue/compat').VNodeProps & import('./@vue/compat').AllowedComponentProps & import('./@vue/compat').ComponentCustomProps, Readonly<import('./@vue/compat').ExtractPropTypes<{}>>, {}>, import('./@vue/compat').ComponentOptionsMixin, {}, string, import('./@vue/compat').VNodeProps & import('./@vue/compat').AllowedComponentProps & import('./@vue/compat').ComponentCustomProps, Readonly<import('./@vue/compat').ExtractPropTypes<Props<PolylineOptions>>>, {
10
- clickable?: any;
11
- editable?: any;
12
- strokeColor?: any;
13
- strokeOpacity?: any;
14
- strokeWeight?: any;
15
- visible?: any;
16
- path: any;
17
- }>;
18
- export default _sfc_main;
35
+ }, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
36
+ path: {
37
+ type: PropType<LatLng[]>;
38
+ required: true;
39
+ };
40
+ clickable: {
41
+ type: PropType<boolean>;
42
+ };
43
+ editable: {
44
+ type: PropType<boolean>;
45
+ };
46
+ strokeColor: {
47
+ type: PropType<string>;
48
+ };
49
+ strokeOpacity: {
50
+ type: PropType<number>;
51
+ };
52
+ strokeWeight: {
53
+ type: PropType<number>;
54
+ };
55
+ visible: {
56
+ type: PropType<boolean>;
57
+ };
58
+ }>>, {}>;
59
+ export default _default;
@@ -1,5 +1,4 @@
1
1
  import type { LatLng } from './lat-lng';
2
- import type { ComponentPublicInstance } from './@vue/compat';
3
2
  /**
4
3
  * ## 事件机制对比
5
4
  * - DOM: add/removeEventListener, Event {type, target}
@@ -39,7 +38,7 @@ export declare namespace Tg {
39
38
  removeEventListener<K extends keyof MAP>(type: K, listener: (this: THIS, event: MAP[K]) => void): void;
40
39
  }
41
40
  }
42
- export declare function bindEvents(this: ComponentPublicInstance, target: Tg.EventTarget, excludes?: string[]): void;
41
+ export declare function bindEvents(listeners: Record<string, unknown>, target: Tg.EventTarget, excludes?: string[]): void;
43
42
  export declare function generateNextEventListenerId(): number;
44
43
  /**
45
44
  * JS的Map/object的key都不支持自定义hashCode()/equals(), 故只能生成字符串当作key
@@ -1,6 +1,6 @@
1
1
  import { LatLng, LatLngBounds } from '../lat-lng';
2
2
  import { AbstractMap, type AbstractMapEventMap } from './map';
3
- import { MapOptions, GestureHandlingOptions, type MapStyle } from './map-options';
3
+ import { MapOptions, GestureHandlingOptions, type MapStyle, type GestureHandlingOptionsLiteral } from './map-options';
4
4
  import type { BaiduOverlay } from './overlay/overlay';
5
5
  import { BaiduMarkerClusterer, type MarkerClustererOptions } from './extra/marker-clusterer';
6
6
  import { BaiduPolyline } from './overlay/polyline';
@@ -23,7 +23,7 @@ export declare class BaiduMap extends AbstractMap {
23
23
  private baiduMapType2BIMT;
24
24
  private map;
25
25
  constructor(element: HTMLElement, mapOptions: MapOptions);
26
- setGestureHandling(gestureHandling?: GestureHandlingOptions): void;
26
+ setGestureHandling(gestureHandling?: GestureHandlingOptions | GestureHandlingOptionsLiteral): void;
27
27
  get innerMap(): BMap.Map;
28
28
  get coordType(): import("../lat-lng").CoordType;
29
29
  addEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
@@ -18,13 +18,14 @@ export declare enum GestureHandlingOptions {
18
18
  /** 合作, 按住ctrl或者双指才能缩放地图 */
19
19
  cooperative = "cooperative"
20
20
  }
21
+ export type GestureHandlingOptionsLiteral = keyof typeof GestureHandlingOptions;
21
22
  export interface MapOptions {
22
23
  /** 中心点 */
23
24
  center: LatLng;
24
25
  /** 缩放等级, 必须是整数 */
25
26
  zoom: number;
26
27
  infoWindowMode?: InfoWindowMode;
27
- gestureHandling?: GestureHandlingOptions;
28
+ gestureHandling?: GestureHandlingOptions | GestureHandlingOptionsLiteral;
28
29
  minZoom?: number;
29
30
  maxZoom?: number;
30
31
  mapStyle?: MapStyle;
@@ -13,6 +13,7 @@ export declare enum BuildInMapTypeId {
13
13
  satellite = "satellite",
14
14
  hybrid = "hybrid"
15
15
  }
16
+ export type BuildInMapTypeIdLiteral = keyof typeof BuildInMapTypeId;
16
17
  /**
17
18
  * 包括不兼容的地图类型
18
19
  * - 'terrain': google中为地形图, baidu中为三维图
@@ -1,6 +1,7 @@
1
1
  /// <reference types="baidumap-web-sdk" />
2
2
  import { Point } from '../../types';
3
3
  import type { BMarker } from './marker';
4
+ import './baidu-info-box.scss';
4
5
  export type BaiduInfoBox = InstanceType<ReturnType<typeof createBaiduInfoBoxClass>>;
5
6
  export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: String): {
6
7
  container: HTMLElement;
@@ -2,6 +2,7 @@
2
2
  import { LatLng } from '../../lat-lng';
3
3
  import type { Point } from '../../types';
4
4
  import type { AbstractMap } from '../map';
5
+ import './element-overlay.scss';
5
6
  export declare enum MapPane {
6
7
  map = "map",
7
8
  overlay = "overlay",
@@ -1 +1 @@
1
- export declare function dimen(value: string | number | null | undefined): string | null;
1
+ export declare function dimen(value: string | number | null | undefined): string | undefined;
@@ -1,4 +1,4 @@
1
- import { type App } from './@vue/compat';
1
+ import { type App } from 'vue';
2
2
  import type { VueHookName } from './vue-utils';
3
3
  export interface LifecycleLogOptions {
4
4
  /** @default /^[A-Z]/ 匹配大写字母开头的组件名 */
@@ -1,11 +1,11 @@
1
- import type { Component, ComponentPublicInstance } from './@vue/compat';
1
+ import type { Component, ComponentPublicInstance } from "vue";
2
2
  /** deep版的 `Partial` */
3
3
  export type DeepPartial<T> = {
4
4
  [U in keyof T]?: T[U] extends object ? DeepPartial<T[U]> : T[U];
5
5
  };
6
6
  /**
7
7
  * 表示一个构造器
8
- * {@link import('./@vue/compat/types/options').Constructor}
8
+ * {@link import('vue/types/options').Constructor}
9
9
  * */
10
10
  export type Constructor<T = {}> = new (...args: any[]) => T;
11
11
  /**
@@ -22,7 +22,7 @@ export type WrapperToPrimitive<T> = T extends Boolean ? boolean : T extends Stri
22
22
  * 模仿了kotlin的lateinit关键字
23
23
  * */
24
24
  export declare function lateinit<T>(): T;
25
- /** 用来给纯对象的成员加上类型验证 */
25
+ export declare function typed<T>(): T | undefined;
26
26
  export declare function typed<T>(t: T): T;
27
27
  /**
28
28
  * `vue instanceof VueConstructor`时`vue`并不会自动转换成`VueConstructor`的子类, 用该方法可以实现这种转换
@@ -1,5 +1,4 @@
1
- import type { VNode, ComponentPublicInstance, Component } from './@vue/compat';
2
- import type { ComponentOptions, PropType, PropOptions, PropValidator, WritableComputedOptions } from './@vue/compat';
1
+ import type { Component, ComponentOptions, ComponentPublicInstance, Prop, PropType, RendererElement, RendererNode, Slots, VNode, WritableComputedOptions } from 'vue';
3
2
  import type { AbstractConstructor, KeysMatching, StringEnumLike, Thing } from './mapped-types';
4
3
  /** 组件选项中的hook名 */
5
4
  export type VueHookName = ExcludeSubtype<KeysMatching<OmitStartsWith<RemoveIndex<ComponentOptions>, '_'>, {
@@ -16,31 +15,53 @@ export type Property<T> = T | {
16
15
  set?(value: T): void;
17
16
  };
18
17
  /**
18
+ * ## Vue2
19
19
  * 和typed()联合使用, 写成: `props: typed<Props<Options>>({...})`, 可以将`Options`作为属性的类型声明,
20
20
  * ### 注意
21
21
  * 1. 对于`Options`中可选的属性, 漏了VSCode不会报错...要小心
22
22
  * 2. `...`中理论上来说只要写Vue的纯js式的类型验证信息(Boolean/Number/String/Object/...)就行了, 并且还有ts的类型检查
23
23
  * 3. 对于`Options`中可选的`boolean`属性, 若将类型验证信息写为`Boolean`时, 该属性的默认值并不是`undefined`而是`false`, 这和它的类型声明(`boolean | undefined`)不匹配, 推荐写成`optionalProp(Boolean)`
24
24
  * 4. 因为存在上述特殊情况, 推荐使用{@link requiredProp},{@link optionalProp}等快捷方法写类型验证信息, 方法的传入参数直接写Vue的纯js式的类型验证信息, 就行了
25
+ *
26
+ * ## Vue3
27
+ * 需要用`props: {...} satisfies Props<Options>`替代`typed()`, 防止{@link NotNullProp}被Vue看成必选的属性
25
28
  * */
26
29
  export type Props<T> = {
27
- [K in keyof T]: PropValidator<T[K]>;
30
+ [K in keyof T]-?: T[K] extends {} ? NotNullProp<T[K]> : Prop<Exclude<T[K], undefined>>;
31
+ };
32
+ /** 表示一个非空的Prop, `required`为true 或者 设置了`default`的{@link Prop}, 才是非空的Prop */
33
+ type NotNullProp<T = any, D = T> = {
34
+ type: PropType<T>;
35
+ } & ({
36
+ required: true;
37
+ } | {
38
+ default: D | (() => D);
39
+ });
40
+ export declare function stringEnumProp<E extends StringEnumLike>(enumObject: E, defaultValue: E[keyof E]): {
41
+ type: PropType<E[keyof E]>;
42
+ default: E[keyof E];
43
+ };
44
+ export declare function stringEnumProp<E extends StringEnumLike>(enumObject: E): {
45
+ type: PropType<E[keyof E]>;
46
+ };
47
+ export declare function stringEnumPropFromArray<T extends string>(enums: T[], defaultValue: T): {
48
+ type: PropType<T>;
49
+ default: T;
50
+ };
51
+ export declare function stringEnumPropFromArray<T extends string>(enums: T[]): {
52
+ type: PropType<T>;
53
+ };
54
+ export declare function requiredProp<T>(type: PropType<T>): {
55
+ type: PropType<T>;
56
+ required: true;
57
+ };
58
+ export declare function optionalProp<T>(type: PropType<T>, defaultValue: T | (() => T)): {
59
+ type: PropType<T>;
60
+ default: T;
61
+ };
62
+ export declare function optionalProp<T>(type: PropType<T>): {
63
+ type: PropType<T>;
28
64
  };
29
- /**
30
- * 注意: 由于使用了`Object.values(enumObject)`来获取所有枚举值
31
- * - 若enumObject为数字枚举, 获取出来的值会同时包含枚举名和枚举值, 故不支持
32
- * - 若enumObject同时是命名空间名, 获取出来的值会包含命名空间上的方法, 应当避免
33
- *
34
- * @param enumObject 枚举对象
35
- * @param defaultValue 默认值
36
- * @see https://frontendsociety.com/using-a-typescript-interfaces-and-types-as-a-prop-type-in-vuejs-508ab3f83480
37
- * */
38
- export declare function stringEnumProp<E extends StringEnumLike>(enumObject: E, defaultValue?: E[keyof E]): PropOptions<E[keyof E]>;
39
- export declare function stringEnumPropFromArray<T extends string>(enums: T[], defaultValue: T): PropOptions<T>;
40
- export declare function stringEnumPropFromArray<T extends string>(enums: T[]): PropOptions<T | undefined>;
41
- export declare function requiredProp<T>(type: PropType<T>): PropOptions<T>;
42
- export declare function optionalProp<T>(type: PropType<T>, defaultValue: T | (() => T)): PropOptions<T>;
43
- export declare function optionalProp<T>(type: PropType<T>): PropOptions<T | undefined>;
44
65
  /**
45
66
  * 保存在this上的属性
46
67
  * @param defaultValues 属性的默认值
@@ -65,13 +86,43 @@ export declare function createPropertyObject(obj: any): any;
65
86
  export declare function createPropertyObjectTyped<T>(obj: {
66
87
  [K in keyof T]: Property<T[K]>;
67
88
  }): T;
68
- export declare function createEmptyVNode(h: any, context: any): VNode;
89
+ /**
90
+ * 创建空节点
91
+ *
92
+ * Vue2中使用`this._e()`创建空节点: https://github.com/vuejs/vue/blob/b6247fc9d7442c50d60ccf366a7cb183a4d02129/src/core/instance/render-helpers/index.js#L28
93
+ *
94
+ * Vue3中等价的实现是{@link createCommentVNode}: https://github.com/vuejs/core/blob/650f5c26f464505d9e865bdb0eafb24350859528/packages/runtime-core/src/compat/instance.ts#L162
95
+ */
96
+ export declare function createEmptyVNode(): VNode;
69
97
  /**
70
98
  * @see https://github.com/vuejs/vue/blob/43b98fe25151b0b6bacd36f3ee27c5d61add5fdb/packages/weex-vue-framework/factory.js/#L2906
71
99
  * */
72
100
  export declare function callHook(vm: ComponentPublicInstance, hookName: VueHookName): void;
73
101
  /** {@link import('./mapped-types.ts').safeAsComponent} */
74
102
  export declare function findByComponentType<T extends Component & AbstractConstructor>(arr: ComponentPublicInstance[], component: T): InstanceType<T> | undefined;
103
+ /**
104
+ * 通过构造slots内容的方式, 提取出slots中对应{@link component}的VNode, {@link VNode.props}就是当前给组件设置的属性值
105
+ *
106
+ * 注意, 该方法并无法获取到{@link component}的实例
107
+ *
108
+ * @see https://stackoverflow.com/questions/64154002/vue-3-how-to-get-information-about-children
109
+ */
110
+ export declare function extractVNodeFromSlotsByComponent<Props>(slots: Slots, component: ComponentOptions<Props>): VNode<RendererNode, RendererElement, Props> | undefined;
111
+ /**
112
+ * Vue3中 class/style/未声明的事件/未声明的属性 都会集合到{@link SetupContext.attrs}中
113
+ * 默认情况下({@link ComponentOptions.inheritAttrs}为true), 将被透传给组件的根节点
114
+ *
115
+ * 而Vue2, 默认只会透传 未声明的属性, 事件通过`$listeners`暴露
116
+ *
117
+ * 这里模仿Vue2的行为, 拆分出未声明的事件, 方便将他们透传给地图的对象
118
+ *
119
+ * @see https://cn.vuejs.org/guide/components/attrs.html#disabling-attribute-inheritance
120
+ * @see https://v3-migration.vuejs.org/zh/breaking-changes/listeners-removed.html
121
+ */
122
+ export declare function splitAttrs(attrs: Record<string, unknown>): {
123
+ binds: Record<string, unknown>;
124
+ listeners: Record<string, unknown>;
125
+ };
75
126
  export declare const eventLogMethods: {
76
127
  /**
77
128
  * @event 一般来说传{@link Tg.Event}对象, 但传其他对象也不会报错
@@ -80,3 +131,4 @@ export declare const eventLogMethods: {
80
131
  /** @see eventLog */
81
132
  eventLogLess(this: any, event: Thing | null | undefined): void;
82
133
  };
134
+ export {};
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .baidu-info-box-container{transform:translateY(-11px);font-size:13px;font-weight:300;width:100vw}.baidu-info-box-container__border{position:absolute;padding:12px;background-color:#fff;box-shadow:0 2px 7px 1px #0000004d;border-radius:8px;transform:translate(-50%,-100%)}.baidu-info-box-container__inner{overflow:auto}.baidu-info-box-container__close{position:absolute;right:-6px;top:-6px;width:14px;height:14px;margin:8px;opacity:.6;cursor:pointer}.baidu-info-box-container__close:hover{opacity:1}.baidu-info-box-container:after{position:absolute;background-color:#fff;content:"";width:15px;height:15px;left:0px;top:0px;box-shadow:-2px 2px 2px #b2b2b266;transform:translate(-50%,-50%) rotate(-45deg)}.tg-map{height:100vh;position:relative}.tg-map__map{width:100%;height:100%}.tg-map-widget{position:absolute}.tg-map>.tg-custom-control{display:none}.tg-map .tg-label{display:none}.tg-map__map .tg-label{display:block}.tg-map .tg-info-box{display:none}.tg-map__map .tg-info-box{display:block}.element-overlay{position:absolute}.tg-map .tg-element-overlay{display:none}.tg-map__map .tg-element-overlay{display:block}
1
+ .baidu-info-box-container{transform:translateY(-11px);font-size:13px;font-weight:300;width:100vw}.baidu-info-box-container__border{position:absolute;padding:12px;background-color:#fff;box-shadow:0 2px 7px 1px #0000004d;border-radius:8px;transform:translate(-50%,-100%)}.baidu-info-box-container__inner{overflow:auto}.baidu-info-box-container__close{position:absolute;right:-6px;top:-6px;width:14px;height:14px;margin:8px;opacity:.6;cursor:pointer}.baidu-info-box-container__close:hover{opacity:1}.baidu-info-box-container:after{position:absolute;background-color:#fff;content:"";width:15px;height:15px;left:0px;top:0px;box-shadow:-2px 2px 2px #b2b2b266;transform:translate(-50%,-50%) rotate(-45deg)}.tg-map{height:100vh;position:relative}.tg-map__map{width:100%;height:100%}.tg-map-widget{position:absolute}.tg-map>.tg-custom-control{display:none}.element-overlay{position:absolute}.tg-map .tg-element-overlay{display:none}.tg-map__map .tg-element-overlay{display:block}.tg-map .tg-info-box{display:none}.tg-map__map .tg-info-box{display:block}.tg-map .tg-label{display:none}.tg-map__map .tg-label{display:block}