tg-map-vue3 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,13 @@
1
- import { type PropType, type Prop } from 'vue';
2
- import type { AbstractMap } from '../map/map/map';
3
- import { TgMapType } from '../map/map-factory';
4
1
  import { LatLng } from '../map/lat-lng';
5
- import { type InfoWindowMode, GestureHandlingOptions } from '../map/map/map-options';
2
+ import { TgMapType } from '../map/map-factory';
3
+ import type { AbstractMap } from '../map/map/map';
4
+ import { GestureHandlingOptions, type InfoWindowMode } from '../map/map/map-options';
5
+ import { BuildInMapTypeId } from '../map/map/map-type';
6
+ import { type StringEnumValue } from '../utils/mapped-types';
6
7
  declare const _default: import("vue").DefineComponent<{
7
8
  /** type没做响应式, 但外部可以把type作为tg-map的key, 让type修改时完全重建tg-map */
8
9
  type: {
9
- type: PropType<TgMapType>;
10
+ type: import("vue").PropType<StringEnumValue<typeof TgMapType>>;
10
11
  default: TgMapType;
11
12
  };
12
13
  /**
@@ -18,7 +19,7 @@ declare const _default: import("vue").DefineComponent<{
18
19
  * @see AbstractMapEventMap.center-changed
19
20
  * */
20
21
  center: {
21
- type: PropType<LatLng>;
22
+ type: import("vue").PropType<LatLng>;
22
23
  required: true;
23
24
  };
24
25
  /**
@@ -27,7 +28,7 @@ declare const _default: import("vue").DefineComponent<{
27
28
  * @see center
28
29
  */
29
30
  centerSyncDelay: {
30
- type: PropType<number>;
31
+ type: import("vue").PropType<number>;
31
32
  default: number;
32
33
  };
33
34
  /**
@@ -35,39 +36,40 @@ declare const _default: import("vue").DefineComponent<{
35
36
  * @see center
36
37
  * */
37
38
  currentCenter: {
38
- type: PropType<LatLng>;
39
+ type: import("vue").PropType<LatLng>;
39
40
  };
40
41
  /**
41
42
  * 仅用于获取tg-map销毁时的最后的center的值
42
43
  * @see center
43
44
  */
44
45
  lastCenter: {
45
- type: PropType<LatLng>;
46
+ type: import("vue").PropType<LatLng>;
46
47
  };
47
48
  zoom: {
48
- type: PropType<number>;
49
+ type: import("vue").PropType<number>;
49
50
  required: true;
50
51
  };
51
52
  infoWindowMode: {
52
- type: PropType<InfoWindowMode>;
53
+ type: import("vue").PropType<InfoWindowMode>;
54
+ };
55
+ gestureHandling: {
56
+ type: import("vue").PropType<StringEnumValue<typeof GestureHandlingOptions>>;
53
57
  };
54
- gestureHandling: Prop<"none" | GestureHandlingOptions | "auto" | "greedy" | "cooperative", "none" | GestureHandlingOptions | "auto" | "greedy" | "cooperative">;
55
58
  minZoom: {
56
- type: PropType<number>;
59
+ type: import("vue").PropType<number>;
57
60
  };
58
61
  maxZoom: {
59
- type: PropType<number>;
62
+ type: import("vue").PropType<number>;
60
63
  };
61
64
  mapStyle: {
62
- type: PropType<any>;
65
+ type: import("vue").PropType<any>;
63
66
  };
64
- /** 设置为除BuildInMapTypeId以外的值时, 无实际效果... */
65
67
  mapTypeId: {
66
- type: PropType<"normal" | "satellite" | "hybrid">;
68
+ type: import("vue").PropType<StringEnumValue<typeof BuildInMapTypeId>>;
67
69
  };
68
- /** 优先级比mapTypeId高 */
70
+ /** 地图类型对象, 优先级比mapTypeId高 */
69
71
  mapType: {
70
- type: PropType<any>;
72
+ type: import("vue").PropType<any>;
71
73
  };
72
74
  }, {
73
75
  attrs: {
@@ -83,7 +85,7 @@ declare const _default: import("vue").DefineComponent<{
83
85
  }, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
84
86
  /** type没做响应式, 但外部可以把type作为tg-map的key, 让type修改时完全重建tg-map */
85
87
  type: {
86
- type: PropType<TgMapType>;
88
+ type: import("vue").PropType<StringEnumValue<typeof TgMapType>>;
87
89
  default: TgMapType;
88
90
  };
89
91
  /**
@@ -95,7 +97,7 @@ declare const _default: import("vue").DefineComponent<{
95
97
  * @see AbstractMapEventMap.center-changed
96
98
  * */
97
99
  center: {
98
- type: PropType<LatLng>;
100
+ type: import("vue").PropType<LatLng>;
99
101
  required: true;
100
102
  };
101
103
  /**
@@ -104,7 +106,7 @@ declare const _default: import("vue").DefineComponent<{
104
106
  * @see center
105
107
  */
106
108
  centerSyncDelay: {
107
- type: PropType<number>;
109
+ type: import("vue").PropType<number>;
108
110
  default: number;
109
111
  };
110
112
  /**
@@ -112,42 +114,43 @@ declare const _default: import("vue").DefineComponent<{
112
114
  * @see center
113
115
  * */
114
116
  currentCenter: {
115
- type: PropType<LatLng>;
117
+ type: import("vue").PropType<LatLng>;
116
118
  };
117
119
  /**
118
120
  * 仅用于获取tg-map销毁时的最后的center的值
119
121
  * @see center
120
122
  */
121
123
  lastCenter: {
122
- type: PropType<LatLng>;
124
+ type: import("vue").PropType<LatLng>;
123
125
  };
124
126
  zoom: {
125
- type: PropType<number>;
127
+ type: import("vue").PropType<number>;
126
128
  required: true;
127
129
  };
128
130
  infoWindowMode: {
129
- type: PropType<InfoWindowMode>;
131
+ type: import("vue").PropType<InfoWindowMode>;
132
+ };
133
+ gestureHandling: {
134
+ type: import("vue").PropType<StringEnumValue<typeof GestureHandlingOptions>>;
130
135
  };
131
- gestureHandling: Prop<"none" | GestureHandlingOptions | "auto" | "greedy" | "cooperative", "none" | GestureHandlingOptions | "auto" | "greedy" | "cooperative">;
132
136
  minZoom: {
133
- type: PropType<number>;
137
+ type: import("vue").PropType<number>;
134
138
  };
135
139
  maxZoom: {
136
- type: PropType<number>;
140
+ type: import("vue").PropType<number>;
137
141
  };
138
142
  mapStyle: {
139
- type: PropType<any>;
143
+ type: import("vue").PropType<any>;
140
144
  };
141
- /** 设置为除BuildInMapTypeId以外的值时, 无实际效果... */
142
145
  mapTypeId: {
143
- type: PropType<"normal" | "satellite" | "hybrid">;
146
+ type: import("vue").PropType<StringEnumValue<typeof BuildInMapTypeId>>;
144
147
  };
145
- /** 优先级比mapTypeId高 */
148
+ /** 地图类型对象, 优先级比mapTypeId高 */
146
149
  mapType: {
147
- type: PropType<any>;
150
+ type: import("vue").PropType<any>;
148
151
  };
149
152
  }>>, {
150
- type: TgMapType;
153
+ type: StringEnumValue<typeof TgMapType>;
151
154
  centerSyncDelay: number;
152
155
  }>;
153
156
  export default _default;
@@ -1,7 +1,8 @@
1
+ import { type StringEnumValue } from '../../utils/mapped-types';
1
2
  import { ControlPosition, CustomControl } from '../../map/map/controls/control';
2
3
  declare const _default: import("vue").DefineComponent<{
3
4
  position: {
4
- type: import("vue").PropType<ControlPosition>;
5
+ type: import("vue").PropType<StringEnumValue<typeof ControlPosition>>;
5
6
  default: ControlPosition;
6
7
  };
7
8
  }, {
@@ -10,10 +11,10 @@ declare const _default: import("vue").DefineComponent<{
10
11
  recreate(): void;
11
12
  }, 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<{
12
13
  position: {
13
- type: import("vue").PropType<ControlPosition>;
14
+ type: import("vue").PropType<StringEnumValue<typeof ControlPosition>>;
14
15
  default: ControlPosition;
15
16
  };
16
17
  }>>, {
17
- position: ControlPosition;
18
+ position: StringEnumValue<typeof ControlPosition>;
18
19
  }>;
19
20
  export default _default;
@@ -2,11 +2,11 @@ import { MapTypeControlType, type MapTypeControl } from '../../map/map/controls/
2
2
  import { ControlPosition } from '../../map/map/controls/control';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  position: {
5
- type: import("vue").PropType<ControlPosition>;
5
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>>;
6
6
  default: ControlPosition;
7
7
  };
8
8
  type: {
9
- type: import("vue").PropType<MapTypeControlType>;
9
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof MapTypeControlType>>;
10
10
  };
11
11
  mapTypes: {
12
12
  type: import("vue").PropType<import("../../map/map/map-type").MapType[]>;
@@ -17,16 +17,16 @@ declare const _default: import("vue").DefineComponent<{
17
17
  recreate(): void;
18
18
  }, 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<{
19
19
  position: {
20
- type: import("vue").PropType<ControlPosition>;
20
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>>;
21
21
  default: ControlPosition;
22
22
  };
23
23
  type: {
24
- type: import("vue").PropType<MapTypeControlType>;
24
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof MapTypeControlType>>;
25
25
  };
26
26
  mapTypes: {
27
27
  type: import("vue").PropType<import("../../map/map/map-type").MapType[]>;
28
28
  };
29
29
  }>>, {
30
- position: ControlPosition;
30
+ position: import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>;
31
31
  }>;
32
32
  export default _default;
@@ -2,7 +2,7 @@ import { ControlPosition } from '../../map/map/controls/control';
2
2
  import type { ScaleControl } from '../../map/map/controls/scale.control';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  position: {
5
- type: import("vue").PropType<ControlPosition>;
5
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>>;
6
6
  default: ControlPosition;
7
7
  };
8
8
  }, {
@@ -11,10 +11,10 @@ declare const _default: import("vue").DefineComponent<{
11
11
  recreate(): void;
12
12
  }, 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<{
13
13
  position: {
14
- type: import("vue").PropType<ControlPosition>;
14
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>>;
15
15
  default: ControlPosition;
16
16
  };
17
17
  }>>, {
18
- position: ControlPosition;
18
+ position: import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>;
19
19
  }>;
20
20
  export default _default;
@@ -2,7 +2,7 @@ import type { ZoomControl } from '../../map/map/controls/zoom.control';
2
2
  import { ControlPosition } from '../../map/map/controls/control';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  position: {
5
- type: import("vue").PropType<ControlPosition>;
5
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>>;
6
6
  default: ControlPosition;
7
7
  };
8
8
  }, {
@@ -11,10 +11,10 @@ declare const _default: import("vue").DefineComponent<{
11
11
  recreate(): void;
12
12
  }, 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<{
13
13
  position: {
14
- type: import("vue").PropType<ControlPosition>;
14
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>>;
15
15
  default: ControlPosition;
16
16
  };
17
17
  }>>, {
18
- position: ControlPosition;
18
+ position: import("../../utils/mapped-types").StringEnumValue<typeof ControlPosition>;
19
19
  }>;
20
20
  export default _default;
@@ -12,7 +12,7 @@ declare class SimpleElementOverlay extends ElementOverlay {
12
12
  }
13
13
  declare const TgElementOverlay: import("vue").DefineComponent<{
14
14
  mapPane: {
15
- type: import("vue").PropType<MapPane>;
15
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof MapPane>>;
16
16
  default: MapPane;
17
17
  };
18
18
  position: {
@@ -27,7 +27,7 @@ declare const TgElementOverlay: import("vue").DefineComponent<{
27
27
  recreate(): void;
28
28
  }, 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<{
29
29
  mapPane: {
30
- type: import("vue").PropType<MapPane>;
30
+ type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof MapPane>>;
31
31
  default: MapPane;
32
32
  };
33
33
  position: {
@@ -35,7 +35,7 @@ declare const TgElementOverlay: import("vue").DefineComponent<{
35
35
  required: true;
36
36
  };
37
37
  }>>, {
38
- mapPane: MapPane;
38
+ mapPane: import("../../utils/mapped-types").StringEnumValue<typeof MapPane>;
39
39
  }>;
40
40
  type TgElementOverlay = InstanceType<typeof TgElementOverlay>;
41
41
  export default TgElementOverlay;
@@ -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, type GestureHandlingOptionsLiteral } from './map-options';
3
+ import { MapOptions, GestureHandlingOptions, type MapStyle } 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 | GestureHandlingOptionsLiteral): void;
26
+ setGestureHandling(gestureHandling?: GestureHandlingOptions): 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,14 +18,13 @@ export declare enum GestureHandlingOptions {
18
18
  /** 合作, 按住ctrl或者双指才能缩放地图 */
19
19
  cooperative = "cooperative"
20
20
  }
21
- export type GestureHandlingOptionsLiteral = keyof typeof GestureHandlingOptions;
22
21
  export interface MapOptions {
23
22
  /** 中心点 */
24
23
  center: LatLng;
25
24
  /** 缩放等级, 必须是整数 */
26
25
  zoom: number;
27
26
  infoWindowMode?: InfoWindowMode;
28
- gestureHandling?: GestureHandlingOptions | GestureHandlingOptionsLiteral;
27
+ gestureHandling?: GestureHandlingOptions;
29
28
  minZoom?: number;
30
29
  maxZoom?: number;
31
30
  mapStyle?: MapStyle;
@@ -13,7 +13,6 @@ export declare enum BuildInMapTypeId {
13
13
  satellite = "satellite",
14
14
  hybrid = "hybrid"
15
15
  }
16
- export type BuildInMapTypeIdLiteral = keyof typeof BuildInMapTypeId;
17
16
  /**
18
17
  * 包括不兼容的地图类型
19
18
  * - 'terrain': google中为地形图, baidu中为三维图
@@ -49,6 +49,27 @@ export type KeysMatching<T, V> = {
49
49
  export type StringEnumLike = {
50
50
  [k: string]: string;
51
51
  };
52
+ /**
53
+ * String枚举的值, 包括`string`类型
54
+ * @see https://stackoverflow.com/questions/52393730/typescript-string-literal-union-type-from-enum
55
+ */
56
+ export type StringEnumValue<E extends StringEnumLike> = ValueOf<E> | `${ValueOf<E>}`;
57
+ /**
58
+ * 包装`T`中的部分枚举字段的值为{@link StringEnumValue}
59
+ *
60
+ * 会校验{@link EnumObjects}中的类型是否书写正确, 若写错, 会推断成`never`
61
+ * */
62
+ export type WrapStringEnumValue<T, EnumObjects extends {
63
+ [k in keyof T]?: StringEnumLike;
64
+ }> = {
65
+ [P in keyof T]: P extends keyof EnumObjects ? EnumObjects[P] extends StringEnumLike ? T[P] extends ValueOf<EnumObjects[P]> | undefined ? StringEnumValue<EnumObjects[P]> : never : never : T[P];
66
+ };
67
+ /** 取消包装`T`中的{@link StringEnumValue}字段 */
68
+ export declare function unwrapStringEnumValue<T extends object>(value: T): {
69
+ [K in keyof T]: T[K] extends StringEnumValue<infer Enum> ? StringEnumLike extends Enum ? T[K] : Enum[keyof Enum] : Exclude<T[K], undefined> extends StringEnumValue<infer Enum> ? StringEnumLike extends Enum ? T[K] : Enum[keyof Enum] | undefined : T[K];
70
+ };
71
+ export declare function unwrapStringEnumValue<E extends StringEnumLike>(value: StringEnumValue<E>, enumObject?: E): E[keyof E];
72
+ export declare function unwrapStringEnumValue<E extends StringEnumLike>(value: StringEnumValue<E> | undefined, enumObject?: E): E[keyof E] | undefined;
52
73
  /**
53
74
  * 非空的值
54
75
  * @see https://github.com/microsoft/TypeScript/issues/7648#issuecomment-541625573
@@ -2,7 +2,8 @@ import type { StringEnumLike } from './mapped-types';
2
2
  export declare namespace Strings {
3
3
  /**
4
4
  * 将string转换成字符枚举, 转换失败返回undefined
5
- * @see import('./vue-utils.ts').stringEnumProp 由于使用了Object.values(enumObject), 应该避免在enumObject上添加其他属性/方法
5
+ * @see {@link import('./vue-utils.ts').stringEnumProp} 由于使用了Object.values(enumObject), 应该避免在enumObject上添加其他属性/方法
6
+ * @deprecated 使用{@link import('./mapped-types.ts').unwrapStringEnumValue}替代
6
7
  */
7
8
  function toEnumOrNull<E extends StringEnumLike>(value: string | undefined, enumObject: E): E[keyof E] | undefined;
8
9
  function trimIndent(str: string): string;
@@ -1,5 +1,5 @@
1
1
  import type { Component, ComponentOptions, ComponentPublicInstance, Prop, PropType, RendererElement, RendererNode, Slots, VNode, WritableComputedOptions } from 'vue';
2
- import type { AbstractConstructor, KeysMatching, StringEnumLike, Thing } from './mapped-types';
2
+ import type { AbstractConstructor, KeysMatching, StringEnumLike, StringEnumValue, Thing } from './mapped-types';
3
3
  /** 组件选项中的hook名 */
4
4
  export type VueHookName = ExcludeSubtype<KeysMatching<OmitStartsWith<RemoveIndex<ComponentOptions>, '_'>, {
5
5
  (): void;
@@ -39,11 +39,11 @@ type NotNullProp<T = any, D = T> = {
39
39
  default: D | (() => D);
40
40
  });
41
41
  export declare function stringEnumProp<E extends StringEnumLike>(enumObject: E, defaultValue: E[keyof E]): {
42
- type: PropType<E[keyof E]>;
42
+ type: PropType<StringEnumValue<E>>;
43
43
  default: E[keyof E];
44
44
  };
45
45
  export declare function stringEnumProp<E extends StringEnumLike>(enumObject: E): {
46
- type: PropType<E[keyof E]>;
46
+ type: PropType<StringEnumValue<E>>;
47
47
  };
48
48
  export declare function stringEnumPropFromArray<T extends string>(enums: T[], defaultValue: T): {
49
49
  type: PropType<T>;