tg-map-vue3 3.0.9 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/TgMap.vue.d.ts +45 -8
- package/dist/src/components/layers/TgTrafficLayer.vue.d.ts +3 -9
- package/dist/src/components/overlays/TgCircle.vue.d.ts +3 -2
- package/dist/src/components/overlays/TgInfoBox.vue.d.ts +13 -4
- package/dist/src/components/overlays/TgInfoWindow.vue.d.ts +3 -2
- package/dist/src/components/overlays/TgLabel.vue.d.ts +3 -2
- package/dist/src/components/overlays/TgMarker.vue.d.ts +9 -6
- package/dist/src/components/overlays/TgPolygon.vue.d.ts +3 -2
- package/dist/src/components/overlays/TgPolyline.vue.d.ts +3 -2
- package/dist/src/map/map/map-options.d.ts +2 -1
- package/dist/src/utils/strings.d.ts +2 -0
- package/dist/src/utils/vue-utils.d.ts +65 -13
- package/dist/tg-map.js +724 -699
- package/dist/tg-map.js.map +1 -1
- package/dist/tg-map.umd.cjs +5 -5
- package/dist/tg-map.umd.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { LatLng } from '../map/lat-lng';
|
|
2
2
|
import { TgMapType } from '../map/map-factory';
|
|
3
3
|
import type { AbstractMap } from '../map/map/map';
|
|
4
|
-
import { GestureHandlingOptions
|
|
5
|
-
import { BuildInMapTypeId } from '../map/map/map-type';
|
|
4
|
+
import { GestureHandlingOptions } from '../map/map/map-options';
|
|
5
|
+
import { BuildInMapTypeId, MapType } from '../map/map/map-type';
|
|
6
6
|
import { type StringEnumValue } from '../utils/mapped-types';
|
|
7
|
+
import { type EventEmits } from '../utils/vue-utils';
|
|
8
|
+
type TgMapEmits = {
|
|
9
|
+
load: AbstractMap;
|
|
10
|
+
error: any;
|
|
11
|
+
'update:center': LatLng;
|
|
12
|
+
'update:current-center': LatLng;
|
|
13
|
+
'update:zoom': number;
|
|
14
|
+
'update:map-type': MapType;
|
|
15
|
+
'update:map-type-id': string;
|
|
16
|
+
'update:last-center': LatLng;
|
|
17
|
+
};
|
|
7
18
|
declare const _default: import("vue").DefineComponent<{
|
|
8
19
|
/** type没做响应式, 但外部可以把type作为tg-map的key, 让type修改时完全重建tg-map */
|
|
9
20
|
type: {
|
|
@@ -50,7 +61,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
50
61
|
required: true;
|
|
51
62
|
};
|
|
52
63
|
infoWindowMode: {
|
|
53
|
-
type: import("vue").PropType<
|
|
64
|
+
type: import("vue").PropType<"single" | "multi">;
|
|
54
65
|
};
|
|
55
66
|
gestureHandling: {
|
|
56
67
|
type: import("vue").PropType<StringEnumValue<typeof GestureHandlingOptions>>;
|
|
@@ -71,18 +82,27 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
71
82
|
mapType: {
|
|
72
83
|
type: import("vue").PropType<any>;
|
|
73
84
|
};
|
|
85
|
+
onLoad: import("vue").Prop<import("../utils/vue-utils").EventCallback<AbstractMap>, import("../utils/vue-utils").EventCallback<AbstractMap>>;
|
|
86
|
+
'onUpdate:center': import("vue").Prop<import("../utils/vue-utils").EventCallback<LatLng>, import("../utils/vue-utils").EventCallback<LatLng>>;
|
|
87
|
+
'onUpdate:current-center': import("vue").Prop<import("../utils/vue-utils").EventCallback<LatLng>, import("../utils/vue-utils").EventCallback<LatLng>>;
|
|
88
|
+
'onUpdate:last-center': import("vue").Prop<import("../utils/vue-utils").EventCallback<LatLng>, import("../utils/vue-utils").EventCallback<LatLng>>;
|
|
89
|
+
'onUpdate:map-type': import("vue").Prop<import("../utils/vue-utils").EventCallback<MapType>, import("../utils/vue-utils").EventCallback<MapType>>;
|
|
90
|
+
'onUpdate:map-type-id': import("vue").Prop<import("../utils/vue-utils").EventCallback<string>, import("../utils/vue-utils").EventCallback<string>>;
|
|
91
|
+
'onUpdate:zoom': import("vue").Prop<import("../utils/vue-utils").EventCallback<number>, import("../utils/vue-utils").EventCallback<number>>;
|
|
92
|
+
onError: import("vue").Prop<import("../utils/vue-utils").EventCallback<any>, import("../utils/vue-utils").EventCallback<any>>;
|
|
74
93
|
}, {
|
|
75
|
-
attrs: {
|
|
94
|
+
attrs: import("vue").ComputedRef<{
|
|
76
95
|
binds: Record<string, unknown>;
|
|
77
96
|
listeners: Record<string, unknown>;
|
|
78
|
-
|
|
97
|
+
listenerProps: Record<string, unknown>;
|
|
98
|
+
}>;
|
|
79
99
|
centerSyncTimeoutId: number;
|
|
80
100
|
}, {
|
|
81
101
|
map: AbstractMap | undefined;
|
|
82
102
|
isDestroyed: boolean;
|
|
83
103
|
}, {
|
|
84
104
|
propsJson(): string;
|
|
85
|
-
}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin,
|
|
105
|
+
}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, EventEmits<TgMapEmits>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
86
106
|
/** type没做响应式, 但外部可以把type作为tg-map的key, 让type修改时完全重建tg-map */
|
|
87
107
|
type: {
|
|
88
108
|
type: import("vue").PropType<StringEnumValue<typeof TgMapType>>;
|
|
@@ -128,7 +148,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
128
148
|
required: true;
|
|
129
149
|
};
|
|
130
150
|
infoWindowMode: {
|
|
131
|
-
type: import("vue").PropType<
|
|
151
|
+
type: import("vue").PropType<"single" | "multi">;
|
|
132
152
|
};
|
|
133
153
|
gestureHandling: {
|
|
134
154
|
type: import("vue").PropType<StringEnumValue<typeof GestureHandlingOptions>>;
|
|
@@ -149,7 +169,24 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
149
169
|
mapType: {
|
|
150
170
|
type: import("vue").PropType<any>;
|
|
151
171
|
};
|
|
152
|
-
|
|
172
|
+
onLoad: import("vue").Prop<import("../utils/vue-utils").EventCallback<AbstractMap>, import("../utils/vue-utils").EventCallback<AbstractMap>>;
|
|
173
|
+
'onUpdate:center': import("vue").Prop<import("../utils/vue-utils").EventCallback<LatLng>, import("../utils/vue-utils").EventCallback<LatLng>>;
|
|
174
|
+
'onUpdate:current-center': import("vue").Prop<import("../utils/vue-utils").EventCallback<LatLng>, import("../utils/vue-utils").EventCallback<LatLng>>;
|
|
175
|
+
'onUpdate:last-center': import("vue").Prop<import("../utils/vue-utils").EventCallback<LatLng>, import("../utils/vue-utils").EventCallback<LatLng>>;
|
|
176
|
+
'onUpdate:map-type': import("vue").Prop<import("../utils/vue-utils").EventCallback<MapType>, import("../utils/vue-utils").EventCallback<MapType>>;
|
|
177
|
+
'onUpdate:map-type-id': import("vue").Prop<import("../utils/vue-utils").EventCallback<string>, import("../utils/vue-utils").EventCallback<string>>;
|
|
178
|
+
'onUpdate:zoom': import("vue").Prop<import("../utils/vue-utils").EventCallback<number>, import("../utils/vue-utils").EventCallback<number>>;
|
|
179
|
+
onError: import("vue").Prop<import("../utils/vue-utils").EventCallback<any>, import("../utils/vue-utils").EventCallback<any>>;
|
|
180
|
+
}>> & {
|
|
181
|
+
onLoad?: ((event: AbstractMap) => any) | undefined;
|
|
182
|
+
onError?: ((event: any) => any) | undefined;
|
|
183
|
+
"onUpdate:center"?: ((event: LatLng) => any) | undefined;
|
|
184
|
+
"onUpdate:current-center"?: ((event: LatLng) => any) | undefined;
|
|
185
|
+
"onUpdate:zoom"?: ((event: number) => any) | undefined;
|
|
186
|
+
"onUpdate:map-type"?: ((event: MapType) => any) | undefined;
|
|
187
|
+
"onUpdate:map-type-id"?: ((event: string) => any) | undefined;
|
|
188
|
+
"onUpdate:last-center"?: ((event: LatLng) => any) | undefined;
|
|
189
|
+
}, {
|
|
153
190
|
type: StringEnumValue<typeof TgMapType>;
|
|
154
191
|
centerSyncDelay: number;
|
|
155
192
|
}>;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { TrafficLayer } from '../../map/map/map-type';
|
|
2
|
-
declare const _default: import("vue").DefineComponent<
|
|
3
|
-
[x: string]: unknown;
|
|
4
|
-
}>>, {
|
|
2
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
5
3
|
layer: TrafficLayer;
|
|
6
|
-
},
|
|
4
|
+
}, {}, {}, {}, import("vue").DefineComponent<{}, {}, {}, {}, {
|
|
7
5
|
recreate(): void;
|
|
8
|
-
}, 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,
|
|
9
|
-
[x: string]: unknown;
|
|
10
|
-
}>>>>, {
|
|
11
|
-
[x: number]: string;
|
|
12
|
-
} | {}>;
|
|
6
|
+
}, 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
7
|
export default _default;
|
|
@@ -34,10 +34,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
34
34
|
type: import("vue").PropType<number>;
|
|
35
35
|
};
|
|
36
36
|
}, {
|
|
37
|
-
attrs: {
|
|
37
|
+
attrs: import("vue").ComputedRef<{
|
|
38
38
|
binds: Record<string, unknown>;
|
|
39
39
|
listeners: Record<string, unknown>;
|
|
40
|
-
|
|
40
|
+
listenerProps: Record<string, unknown>;
|
|
41
|
+
}>;
|
|
41
42
|
overlay: CircleOverlay;
|
|
42
43
|
}, unknown, {}, {}, import("vue").DefineComponent<{}, {}, {}, {}, {
|
|
43
44
|
recreate(): void;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { type EventEmits } from '../../utils/vue-utils';
|
|
1
2
|
import { LatLng } from '../../map/lat-lng';
|
|
2
3
|
import { type TgMarkerPublicInstance } from './TgMarker.vue';
|
|
3
4
|
import type { InfoBoxOverlay, InfoBoxOptions } from '../../map/map/overlay/info-box';
|
|
4
5
|
import type { MarkerOverlay } from '../../map/map/overlay/marker';
|
|
6
|
+
type TgInfoBoxEmits = {
|
|
7
|
+
'update:show': boolean;
|
|
8
|
+
};
|
|
5
9
|
declare const TgInfoBox: import("vue").DefineComponent<{
|
|
6
10
|
show: {
|
|
7
11
|
type: import("vue").PropType<boolean>;
|
|
@@ -22,11 +26,13 @@ declare const TgInfoBox: import("vue").DefineComponent<{
|
|
|
22
26
|
zIndex: {
|
|
23
27
|
type: import("vue").PropType<number>;
|
|
24
28
|
};
|
|
29
|
+
'onUpdate:show': import("vue").Prop<import("../../utils/vue-utils").EventCallback<boolean>, import("../../utils/vue-utils").EventCallback<boolean>>;
|
|
25
30
|
}, {
|
|
26
|
-
attrs: {
|
|
31
|
+
attrs: import("vue").ComputedRef<{
|
|
27
32
|
binds: Record<string, unknown>;
|
|
28
33
|
listeners: Record<string, unknown>;
|
|
29
|
-
|
|
34
|
+
listenerProps: Record<string, unknown>;
|
|
35
|
+
}>;
|
|
30
36
|
overlay: InfoBoxOverlay;
|
|
31
37
|
}, unknown, {}, {
|
|
32
38
|
getOptions(): InfoBoxOptions;
|
|
@@ -36,7 +42,7 @@ declare const TgInfoBox: import("vue").DefineComponent<{
|
|
|
36
42
|
close(): void;
|
|
37
43
|
}, import("vue").DefineComponent<{}, {}, {}, {}, {
|
|
38
44
|
recreate(): void;
|
|
39
|
-
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>, import("vue").ComponentOptionsMixin,
|
|
45
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>, import("vue").ComponentOptionsMixin, EventEmits<TgInfoBoxEmits>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
40
46
|
show: {
|
|
41
47
|
type: import("vue").PropType<boolean>;
|
|
42
48
|
required: true;
|
|
@@ -56,6 +62,9 @@ declare const TgInfoBox: import("vue").DefineComponent<{
|
|
|
56
62
|
zIndex: {
|
|
57
63
|
type: import("vue").PropType<number>;
|
|
58
64
|
};
|
|
59
|
-
|
|
65
|
+
'onUpdate:show': import("vue").Prop<import("../../utils/vue-utils").EventCallback<boolean>, import("../../utils/vue-utils").EventCallback<boolean>>;
|
|
66
|
+
}>> & {
|
|
67
|
+
"onUpdate:show"?: ((event: boolean) => any) | undefined;
|
|
68
|
+
}, {}>;
|
|
60
69
|
type TgInfoBox = InstanceType<typeof TgInfoBox>;
|
|
61
70
|
export default TgInfoBox;
|
|
@@ -19,10 +19,11 @@ declare const TgInfoWindow: import("vue").DefineComponent<{
|
|
|
19
19
|
type: import("vue").PropType<boolean>;
|
|
20
20
|
};
|
|
21
21
|
}, {
|
|
22
|
-
attrs: {
|
|
22
|
+
attrs: import("vue").ComputedRef<{
|
|
23
23
|
binds: Record<string, unknown>;
|
|
24
24
|
listeners: Record<string, unknown>;
|
|
25
|
-
|
|
25
|
+
listenerProps: Record<string, unknown>;
|
|
26
|
+
}>;
|
|
26
27
|
overlay: InfoWindowOverlay;
|
|
27
28
|
}, unknown, {}, {
|
|
28
29
|
content(): HTMLElement;
|
|
@@ -13,10 +13,11 @@ declare const TgLabel: import("vue").DefineComponent<{
|
|
|
13
13
|
type: import("vue").PropType<number>;
|
|
14
14
|
};
|
|
15
15
|
}, {
|
|
16
|
-
attrs: {
|
|
16
|
+
attrs: import("vue").ComputedRef<{
|
|
17
17
|
binds: Record<string, unknown>;
|
|
18
18
|
listeners: Record<string, unknown>;
|
|
19
|
-
|
|
19
|
+
listenerProps: Record<string, unknown>;
|
|
20
|
+
}>;
|
|
20
21
|
overlay: LabelOverlay;
|
|
21
22
|
}, unknown, {}, {
|
|
22
23
|
content(): HTMLElement;
|
|
@@ -34,10 +34,11 @@ declare const TgMarker: import("vue").DefineComponent<{
|
|
|
34
34
|
type: import("vue").PropType<boolean>;
|
|
35
35
|
};
|
|
36
36
|
}, {
|
|
37
|
-
attrs: {
|
|
37
|
+
attrs: import("vue").ComputedRef<{
|
|
38
38
|
binds: Record<string, unknown>;
|
|
39
39
|
listeners: Record<string, unknown>;
|
|
40
|
-
|
|
40
|
+
listenerProps: Record<string, unknown>;
|
|
41
|
+
}>;
|
|
41
42
|
marker: MarkerOverlay;
|
|
42
43
|
label: ({
|
|
43
44
|
$: import("vue").ComponentInternalInstance;
|
|
@@ -77,10 +78,11 @@ declare const TgMarker: import("vue").DefineComponent<{
|
|
|
77
78
|
type: import("vue").PropType<number>;
|
|
78
79
|
};
|
|
79
80
|
}>>, {
|
|
80
|
-
attrs: {
|
|
81
|
+
attrs: import("vue").ComputedRef<{
|
|
81
82
|
binds: Record<string, unknown>;
|
|
82
83
|
listeners: Record<string, unknown>;
|
|
83
|
-
|
|
84
|
+
listenerProps: Record<string, unknown>;
|
|
85
|
+
}>;
|
|
84
86
|
overlay: import("../../map/map/overlay/label").LabelOverlay;
|
|
85
87
|
}, unknown, {}, {
|
|
86
88
|
content(): HTMLElement;
|
|
@@ -120,10 +122,11 @@ declare const TgMarker: import("vue").DefineComponent<{
|
|
|
120
122
|
type: import("vue").PropType<number>;
|
|
121
123
|
};
|
|
122
124
|
}>> & import("vue").ShallowUnwrapRef<{
|
|
123
|
-
attrs: {
|
|
125
|
+
attrs: import("vue").ComputedRef<{
|
|
124
126
|
binds: Record<string, unknown>;
|
|
125
127
|
listeners: Record<string, unknown>;
|
|
126
|
-
|
|
128
|
+
listenerProps: Record<string, unknown>;
|
|
129
|
+
}>;
|
|
127
130
|
overlay: import("../../map/map/overlay/label").LabelOverlay;
|
|
128
131
|
}> & {} & {
|
|
129
132
|
recreate(): void;
|
|
@@ -31,10 +31,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
31
31
|
type: PropType<number>;
|
|
32
32
|
};
|
|
33
33
|
}, {
|
|
34
|
-
attrs: {
|
|
34
|
+
attrs: import("vue").ComputedRef<{
|
|
35
35
|
binds: Record<string, unknown>;
|
|
36
36
|
listeners: Record<string, unknown>;
|
|
37
|
-
|
|
37
|
+
listenerProps: Record<string, unknown>;
|
|
38
|
+
}>;
|
|
38
39
|
polygon: PolygonOverlay;
|
|
39
40
|
}, unknown, {}, {}, import("vue").DefineComponent<{}, {}, {}, {}, {
|
|
40
41
|
recreate(): void;
|
|
@@ -25,10 +25,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
25
25
|
type: PropType<boolean>;
|
|
26
26
|
};
|
|
27
27
|
}, {
|
|
28
|
-
attrs: {
|
|
28
|
+
attrs: import("vue").ComputedRef<{
|
|
29
29
|
binds: Record<string, unknown>;
|
|
30
30
|
listeners: Record<string, unknown>;
|
|
31
|
-
|
|
31
|
+
listenerProps: Record<string, unknown>;
|
|
32
|
+
}>;
|
|
32
33
|
polyline: PolylineOverlay;
|
|
33
34
|
}, unknown, {}, {}, import("vue").DefineComponent<{}, {}, {}, {}, {
|
|
34
35
|
recreate(): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="googlemaps" />
|
|
2
2
|
import { LatLng } from '../lat-lng';
|
|
3
3
|
import type { BuildInMapTypeId } from './map-type';
|
|
4
|
-
export
|
|
4
|
+
export declare const InfoWindowModeValues: readonly ["single", "multi"];
|
|
5
|
+
export type InfoWindowMode = typeof InfoWindowModeValues[number];
|
|
5
6
|
/**
|
|
6
7
|
* 完全模仿google的模式, 合并如下配置:
|
|
7
8
|
* - draggable
|
|
@@ -7,4 +7,6 @@ export declare namespace Strings {
|
|
|
7
7
|
*/
|
|
8
8
|
function toEnumOrNull<E extends StringEnumLike>(value: string | undefined, enumObject: E): E[keyof E] | undefined;
|
|
9
9
|
function trimIndent(str: string): string;
|
|
10
|
+
/** 转换: `FuckYou` -> `fuck-you` */
|
|
11
|
+
function pascal2kebab(str: string): string;
|
|
10
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Component, type ComponentOptions, type ComponentPublicInstance, type Prop, type PropType, type RendererElement, type RendererNode, type Slots, type VNode, type WritableComputedOptions } from 'vue';
|
|
2
2
|
import type { AbstractConstructor, KeysMatching, StringEnumLike, StringEnumValue, Thing } from './mapped-types';
|
|
3
3
|
/** 组件选项中的hook名 */
|
|
4
4
|
export type VueHookName = ExcludeSubtype<KeysMatching<OmitStartsWith<RemoveIndex<ComponentOptions>, '_'>, {
|
|
@@ -45,12 +45,12 @@ export declare function stringEnumProp<E extends StringEnumLike>(enumObject: E,
|
|
|
45
45
|
export declare function stringEnumProp<E extends StringEnumLike>(enumObject: E): {
|
|
46
46
|
type: PropType<StringEnumValue<E>>;
|
|
47
47
|
};
|
|
48
|
-
export declare function
|
|
49
|
-
type: PropType<T>;
|
|
48
|
+
export declare function stringUnionPropFromValues<T extends string>(values: readonly T[], defaultValue: T): {
|
|
49
|
+
type: PropType<T[][number]>;
|
|
50
50
|
default: T;
|
|
51
51
|
};
|
|
52
|
-
export declare function
|
|
53
|
-
type: PropType<T>;
|
|
52
|
+
export declare function stringUnionPropFromValues<T extends string>(values: readonly T[]): {
|
|
53
|
+
type: PropType<T[][number]>;
|
|
54
54
|
};
|
|
55
55
|
export declare function requiredProp<T>(type: PropType<T>): {
|
|
56
56
|
type: PropType<T>;
|
|
@@ -99,7 +99,10 @@ export declare function createEmptyVNode(): VNode;
|
|
|
99
99
|
* @see https://github.com/vuejs/vue/blob/43b98fe25151b0b6bacd36f3ee27c5d61add5fdb/packages/weex-vue-framework/factory.js/#L2906
|
|
100
100
|
* */
|
|
101
101
|
export declare function callHook(vm: ComponentPublicInstance, hookName: VueHookName): void;
|
|
102
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* {@link import('./mapped-types.ts').safeAsComponent}
|
|
104
|
+
* @deprecated Vue3已经不能遍历子组件的实例了, 所以这个方法目前没用
|
|
105
|
+
*/
|
|
103
106
|
export declare function findByComponentType<T extends Component & AbstractConstructor>(arr: ComponentPublicInstance[], component: T): InstanceType<T> | undefined;
|
|
104
107
|
/**
|
|
105
108
|
* 通过构造slots内容的方式, 提取出slots中对应{@link component}的VNode, {@link VNode.props}就是当前给组件设置的属性值
|
|
@@ -110,20 +113,69 @@ export declare function findByComponentType<T extends Component & AbstractConstr
|
|
|
110
113
|
*/
|
|
111
114
|
export declare function extractVNodeFromSlotsByComponent<Props>(slots: Slots, component: ComponentOptions<Props>): VNode<RendererNode, RendererElement, Props> | undefined;
|
|
112
115
|
/**
|
|
113
|
-
* Vue3中 class/style/未声明的事件/未声明的属性
|
|
114
|
-
* 默认情况下(
|
|
116
|
+
* Vue3中 class/style/未声明的事件/未声明的属性 都会集合到`this.$attrs`中
|
|
117
|
+
* 默认情况下(`inheritAttrs`为true), 将被透传给组件的根节点
|
|
118
|
+
*
|
|
119
|
+
* 而Vue2, `this.$attrs`值包含 未声明的属性, 所有事件放到了`this.$listeners`中
|
|
120
|
+
*
|
|
121
|
+
* 这里模仿Vue2的行为, 从{@link attrs}中拆分出未声明的事件, 方便将他们透传给地图的对象
|
|
122
|
+
* 同时若传入{@link props}, 也会从它里面拆分出 声明的事件类型的属性
|
|
123
|
+
*
|
|
124
|
+
* ## 如何给事件添加类型信息
|
|
115
125
|
*
|
|
116
|
-
*
|
|
126
|
+
* - 声明在`emits`中的事件, 会给emit方法添加类型信息, 但没办法在运行时判断是否有被设置
|
|
127
|
+
* - 声明在`props`中的事件, 不会.................. , 但可以通过读取`this.$props`判断是否被设置
|
|
117
128
|
*
|
|
118
|
-
*
|
|
129
|
+
* 所有我们最终选择用{@link EventProps}在`props`中声明事件, 同时用{@link EventEmits}在`emits`上声明事件的类型,
|
|
130
|
+
* 达到既有类型信息, 又能判断是否存在的效果, 写法如下:
|
|
131
|
+
* ```
|
|
132
|
+
* {
|
|
133
|
+
* props: {...} satisfies EventProps<TgMapEmits>,
|
|
134
|
+
* emits: undefined as any as EventEmits<TgMapEmits>,
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
119
137
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
138
|
+
* ## 参考
|
|
139
|
+
* - https://cn.vuejs.org/guide/components/attrs.html#disabling-attribute-inheritance
|
|
140
|
+
* - https://v3-migration.vuejs.org/zh/breaking-changes/listeners-removed.html
|
|
141
|
+
* - https://eslint.vuejs.org/rules/require-explicit-emits.html#options
|
|
122
142
|
*/
|
|
123
|
-
export declare function splitAttrs(attrs: Record<string, unknown>): {
|
|
143
|
+
export declare function splitAttrs(attrs: Record<string, unknown>, props?: Record<string, unknown>): {
|
|
144
|
+
/** class/style/未声明的属性 等 */
|
|
124
145
|
binds: Record<string, unknown>;
|
|
146
|
+
/** 未声明的事件 */
|
|
125
147
|
listeners: Record<string, unknown>;
|
|
148
|
+
/** 声明在`props`中的事件 */
|
|
149
|
+
listenerProps: Record<string, unknown>;
|
|
150
|
+
};
|
|
151
|
+
/** 响应式的{@link splitAttrs} */
|
|
152
|
+
export declare function useSplittedAttrs(attrs: Record<string, unknown>, props?: Record<string, unknown>): import("vue").ComputedRef<{
|
|
153
|
+
/** class/style/未声明的属性 等 */
|
|
154
|
+
binds: Record<string, unknown>;
|
|
155
|
+
/** 未声明的事件 */
|
|
156
|
+
listeners: Record<string, unknown>;
|
|
157
|
+
/** 声明在`props`中的事件 */
|
|
158
|
+
listenerProps: Record<string, unknown>;
|
|
159
|
+
}>;
|
|
160
|
+
export type EventCallback<E = any> = (event: E) => void;
|
|
161
|
+
/**
|
|
162
|
+
* 事件类型的属性
|
|
163
|
+
* @see splitAttrs
|
|
164
|
+
* */
|
|
165
|
+
export type EventProps<Emits> = Emits extends string ? {
|
|
166
|
+
[K in Emits as `on${Capitalize<K>}`]: Prop<Function>;
|
|
167
|
+
} : {
|
|
168
|
+
[K in keyof Emits as K extends string ? `on${Capitalize<K>}` : never]: Prop<EventCallback<Emits[K]>>;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* 用来声明事件的类型信息
|
|
172
|
+
* @see splitAttrs
|
|
173
|
+
* */
|
|
174
|
+
export type EventEmits<T> = {
|
|
175
|
+
[K in keyof T]: (event: T[K]) => boolean;
|
|
126
176
|
};
|
|
177
|
+
/** 给事件类型的属性标注类型 */
|
|
178
|
+
export declare function eventProp<E = any>(): Prop<EventCallback<E>>;
|
|
127
179
|
export declare const eventLogMethods: {
|
|
128
180
|
/**
|
|
129
181
|
* @event 一般来说传{@link Tg.Event}对象, 但传其他对象也不会报错
|