@d3-maps/vue 0.3.0 → 0.5.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/README.md +6 -0
- package/dist/index.d.ts +69 -56
- package/dist/index.iife.js +1 -1
- package/dist/index.js +129 -133
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,6 +47,12 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
47
47
|
})
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## Styling
|
|
51
|
+
|
|
52
|
+
Importing `@d3-maps/vue` automatically includes `@d3-maps/core/index.css`
|
|
53
|
+
|
|
54
|
+
If you need strict stylesheet ordering, load your global reset/theme styles before importing the adapter entry
|
|
55
|
+
|
|
50
56
|
## License
|
|
51
57
|
|
|
52
58
|
MIT licensed. Copyright © 2020 Georgii Bukharov. See [LICENSE](./LICENSE) for more details.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@d3-maps/core/index.css";
|
|
2
|
-
import * as
|
|
3
|
-
import { App, StyleValue } from "vue";
|
|
4
|
-
import { ExtendedFeature, ExtendedFeatureCollection, GeoPath, GeoProjection } from "d3-geo";
|
|
2
|
+
import * as vue6 from "vue";
|
|
3
|
+
import { App, ComputedRef, InjectionKey, MaybeRef, StyleValue } from "vue";
|
|
4
|
+
import { ExtendedFeature, ExtendedFeatureCollection, GeoGraticuleGenerator, GeoPath, GeoProjection } from "d3-geo";
|
|
5
5
|
import { Topology } from "topojson-specification";
|
|
6
|
-
import
|
|
6
|
+
import "topojson-client";
|
|
7
7
|
import { D3ZoomEvent, ZoomBehavior } from "d3-zoom";
|
|
8
8
|
|
|
9
9
|
//#region ../core/src/lib/mapObject.d.ts
|
|
@@ -12,7 +12,7 @@ import { D3ZoomEvent, ZoomBehavior } from "d3-zoom";
|
|
|
12
12
|
*/
|
|
13
13
|
declare const mapObjectState: readonly ["default", "hover", "active"];
|
|
14
14
|
type MapObjectState = typeof mapObjectState[number];
|
|
15
|
-
type MapObjectStyles<TStyle> = Partial<Record<MapObjectState, TStyle>>;
|
|
15
|
+
type MapObjectStyles$1<TStyle> = Partial<Record<MapObjectState, TStyle>>;
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region ../core/src/lib/feature.d.ts
|
|
18
18
|
/**
|
|
@@ -26,9 +26,7 @@ type MapFeature = (ExtendedFeature & Record<string, unknown>) | ExtendedFeature;
|
|
|
26
26
|
*/
|
|
27
27
|
interface MapFeatureProps<TStyle = unknown> {
|
|
28
28
|
data: MapFeature;
|
|
29
|
-
styles?: MapObjectStyles<TStyle>;
|
|
30
|
-
fill?: string;
|
|
31
|
-
stroke?: string;
|
|
29
|
+
styles?: MapObjectStyles$1<TStyle>;
|
|
32
30
|
}
|
|
33
31
|
//#endregion
|
|
34
32
|
//#region ../core/src/lib/utils.d.ts
|
|
@@ -100,7 +98,6 @@ type ModifierArgs<P extends unknown[]> = P extends [infer Only] ? Only extends r
|
|
|
100
98
|
type MethodsToModifiers<T extends object> = { [K in OwnKeys<T> as Extract<T[K], AnyFn> extends never ? never : HasArgs<Extract<T[K], AnyFn>> extends true ? K : never]?: ModifierArgs<Extract<SetterArgs<Extract<T[K], AnyFn>>, unknown[]>> };
|
|
101
99
|
//#endregion
|
|
102
100
|
//#region ../core/src/lib/map.d.ts
|
|
103
|
-
type MapMesh = ReturnType<typeof mesh>;
|
|
104
101
|
type MapData = ExtendedFeatureCollection | Topology;
|
|
105
102
|
type DataTransformer = (features: MapFeature[]) => MapFeature[];
|
|
106
103
|
/**
|
|
@@ -124,7 +121,7 @@ interface MapConfig {
|
|
|
124
121
|
/**
|
|
125
122
|
* Projection factory from d3-geo (or a compatible implementation).
|
|
126
123
|
*
|
|
127
|
-
* Example: `
|
|
124
|
+
* Example: `geoNaturalEarth1`.
|
|
128
125
|
*/
|
|
129
126
|
projection?: () => GeoProjection;
|
|
130
127
|
/**
|
|
@@ -152,12 +149,21 @@ interface MapContext {
|
|
|
152
149
|
height: number;
|
|
153
150
|
projection?: GeoProjection;
|
|
154
151
|
features: MapFeature[];
|
|
155
|
-
mesh?: MapMesh;
|
|
156
152
|
path: GeoPath;
|
|
157
|
-
renderPath: (feature: MapFeature) => ReturnType<GeoPath>;
|
|
158
153
|
renderMesh: () => ReturnType<GeoPath>;
|
|
159
154
|
}
|
|
160
155
|
//#endregion
|
|
156
|
+
//#region ../core/src/lib/graticule.d.ts
|
|
157
|
+
/**
|
|
158
|
+
* Extra graticule generator method calls to apply before rendering.
|
|
159
|
+
*
|
|
160
|
+
* Uses d3-geo `geoGraticule()` setter method names as keys.
|
|
161
|
+
* Example: `{ step: [[10, 10]], precision: 2.5 }`
|
|
162
|
+
*
|
|
163
|
+
* @see https://d3js.org/d3-geo/shape#geoGraticule
|
|
164
|
+
*/
|
|
165
|
+
interface GraticuleConfig extends MethodsToModifiers<GeoGraticuleGenerator> {}
|
|
166
|
+
//#endregion
|
|
161
167
|
//#region ../core/src/lib/marker.d.ts
|
|
162
168
|
type MapMarkerCoordinates = [number, number];
|
|
163
169
|
/**
|
|
@@ -165,7 +171,7 @@ type MapMarkerCoordinates = [number, number];
|
|
|
165
171
|
*/
|
|
166
172
|
interface MapMarkerProps<TStyle = unknown> {
|
|
167
173
|
coordinates?: MapMarkerCoordinates;
|
|
168
|
-
styles?: MapObjectStyles<TStyle>;
|
|
174
|
+
styles?: MapObjectStyles$1<TStyle>;
|
|
169
175
|
}
|
|
170
176
|
//#endregion
|
|
171
177
|
//#region ../core/src/lib/zoom.d.ts
|
|
@@ -192,9 +198,9 @@ interface ZoomEvent extends D3ZoomEvent<SVGSVGElement, unknown> {}
|
|
|
192
198
|
type __VLS_Slots$3 = {
|
|
193
199
|
default?: (props: MapContext) => unknown;
|
|
194
200
|
};
|
|
195
|
-
declare const __VLS_base$3:
|
|
196
|
-
declare const __VLS_export$
|
|
197
|
-
declare const _default: typeof __VLS_export$
|
|
201
|
+
declare const __VLS_base$3: vue6.DefineComponent<MapConfig, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<MapConfig> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
202
|
+
declare const __VLS_export$6: __VLS_WithSlots$3<typeof __VLS_base$3, __VLS_Slots$3>;
|
|
203
|
+
declare const _default: typeof __VLS_export$6;
|
|
198
204
|
type __VLS_WithSlots$3<T, S> = T & {
|
|
199
205
|
new (): {
|
|
200
206
|
$slots: S;
|
|
@@ -203,19 +209,24 @@ type __VLS_WithSlots$3<T, S> = T & {
|
|
|
203
209
|
//#endregion
|
|
204
210
|
//#region src/components/MapFeature.vue.d.ts
|
|
205
211
|
type __VLS_Props$1 = MapFeatureProps<StyleValue>;
|
|
206
|
-
declare const __VLS_export$
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
declare const __VLS_export$5: vue6.DefineComponent<__VLS_Props$1, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props$1> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
213
|
+
declare const _default$1: typeof __VLS_export$5;
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/hooks/useMapObject.d.ts
|
|
216
|
+
type MapObjectStyles = MapObjectStyles$1<StyleValue>;
|
|
217
|
+
interface UseMapObjectResult {
|
|
218
|
+
style: ComputedRef<StyleValue | undefined>;
|
|
219
|
+
onMouseenter: (event: MouseEvent) => void;
|
|
220
|
+
onMouseleave: (event: MouseEvent) => void;
|
|
221
|
+
onMousedown: (event: MouseEvent) => void;
|
|
222
|
+
onMouseup: (event: MouseEvent) => void;
|
|
223
|
+
}
|
|
224
|
+
declare function useMapObject(styles: MaybeRef<MapObjectStyles | undefined>): UseMapObjectResult;
|
|
212
225
|
//#endregion
|
|
213
226
|
//#region src/components/MapFeatures.vue.d.ts
|
|
214
|
-
interface Props$
|
|
227
|
+
interface Props$2 {
|
|
215
228
|
idKey?: string;
|
|
216
|
-
|
|
217
|
-
stroke?: string;
|
|
218
|
-
styles?: MapObjectStyles<StyleValue>;
|
|
229
|
+
styles?: MapObjectStyles;
|
|
219
230
|
}
|
|
220
231
|
declare var __VLS_1$2: {
|
|
221
232
|
features: MapFeature[];
|
|
@@ -223,32 +234,38 @@ declare var __VLS_1$2: {
|
|
|
223
234
|
type __VLS_Slots$2 = {} & {
|
|
224
235
|
default?: (props: typeof __VLS_1$2) => any;
|
|
225
236
|
};
|
|
226
|
-
declare const __VLS_base$2:
|
|
237
|
+
declare const __VLS_base$2: vue6.DefineComponent<Props$2, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props$2> & Readonly<{}>, {
|
|
227
238
|
idKey: string;
|
|
228
|
-
}, {}, {}, {}, string,
|
|
229
|
-
declare const __VLS_export$
|
|
230
|
-
declare const _default$2: typeof __VLS_export$
|
|
239
|
+
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
240
|
+
declare const __VLS_export$4: __VLS_WithSlots$2<typeof __VLS_base$2, __VLS_Slots$2>;
|
|
241
|
+
declare const _default$2: typeof __VLS_export$4;
|
|
231
242
|
type __VLS_WithSlots$2<T, S> = T & {
|
|
232
243
|
new (): {
|
|
233
244
|
$slots: S;
|
|
234
245
|
};
|
|
235
246
|
};
|
|
236
247
|
//#endregion
|
|
248
|
+
//#region src/components/MapGraticule.vue.d.ts
|
|
249
|
+
interface Props$1 {
|
|
250
|
+
config?: GraticuleConfig;
|
|
251
|
+
background?: boolean | string;
|
|
252
|
+
border?: boolean | string;
|
|
253
|
+
styles?: MapObjectStyles;
|
|
254
|
+
}
|
|
255
|
+
declare const __VLS_export$3: vue6.DefineComponent<Props$1, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props$1> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
256
|
+
declare const _default$3: typeof __VLS_export$3;
|
|
257
|
+
//#endregion
|
|
237
258
|
//#region src/components/MapMarker.vue.d.ts
|
|
238
259
|
type __VLS_Props = MapMarkerProps<StyleValue>;
|
|
239
260
|
declare var __VLS_1$1: {};
|
|
240
261
|
type __VLS_Slots$1 = {} & {
|
|
241
262
|
default?: (props: typeof __VLS_1$1) => any;
|
|
242
263
|
};
|
|
243
|
-
declare const __VLS_base$1:
|
|
244
|
-
[x: string]: any;
|
|
245
|
-
}, string, vue4.PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
246
|
-
[x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
|
|
247
|
-
}>, {
|
|
264
|
+
declare const __VLS_base$1: vue6.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
248
265
|
coordinates: MapMarkerCoordinates;
|
|
249
|
-
}, {}, {}, {}, string,
|
|
266
|
+
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
250
267
|
declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
|
|
251
|
-
declare const _default$
|
|
268
|
+
declare const _default$4: typeof __VLS_export$2;
|
|
252
269
|
type __VLS_WithSlots$1<T, S> = T & {
|
|
253
270
|
new (): {
|
|
254
271
|
$slots: S;
|
|
@@ -257,32 +274,24 @@ type __VLS_WithSlots$1<T, S> = T & {
|
|
|
257
274
|
//#endregion
|
|
258
275
|
//#region src/components/MapMesh.vue.d.ts
|
|
259
276
|
interface Props {
|
|
260
|
-
|
|
261
|
-
stroke?: string;
|
|
262
|
-
styles?: MapObjectStyles<StyleValue>;
|
|
277
|
+
styles?: MapObjectStyles;
|
|
263
278
|
}
|
|
264
|
-
declare const __VLS_export$1:
|
|
265
|
-
|
|
266
|
-
}, string, vue4.PublicProps, Readonly<Props> & Readonly<{
|
|
267
|
-
[x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
|
|
268
|
-
}>, {
|
|
269
|
-
fill: string;
|
|
270
|
-
}, {}, {}, {}, string, vue4.ComponentProvideOptions, false, {}, any>;
|
|
271
|
-
declare const _default$4: typeof __VLS_export$1;
|
|
279
|
+
declare const __VLS_export$1: vue6.DefineComponent<Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
280
|
+
declare const _default$5: typeof __VLS_export$1;
|
|
272
281
|
//#endregion
|
|
273
282
|
//#region src/components/MapZoom.vue.d.ts
|
|
274
283
|
declare var __VLS_1: {};
|
|
275
284
|
type __VLS_Slots = {} & {
|
|
276
285
|
default?: (props: typeof __VLS_1) => any;
|
|
277
286
|
};
|
|
278
|
-
declare const __VLS_base:
|
|
279
|
-
container:
|
|
280
|
-
zoomBehavior:
|
|
281
|
-
}, {}, {}, {},
|
|
287
|
+
declare const __VLS_base: vue6.DefineComponent<ZoomProps, {
|
|
288
|
+
container: vue6.Ref<SVGGElement | null, SVGGElement | null>;
|
|
289
|
+
zoomBehavior: vue6.ComputedRef<DefaultZoomBehavior>;
|
|
290
|
+
}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {} & {
|
|
282
291
|
zoom: (payload: ZoomEvent) => any;
|
|
283
292
|
zoomstart: (payload: ZoomEvent) => any;
|
|
284
293
|
zoomend: (payload: ZoomEvent) => any;
|
|
285
|
-
}, string,
|
|
294
|
+
}, string, vue6.PublicProps, Readonly<ZoomProps> & Readonly<{
|
|
286
295
|
onZoom?: ((payload: ZoomEvent) => any) | undefined;
|
|
287
296
|
onZoomstart?: ((payload: ZoomEvent) => any) | undefined;
|
|
288
297
|
onZoomend?: ((payload: ZoomEvent) => any) | undefined;
|
|
@@ -291,15 +300,19 @@ declare const __VLS_base: vue4.DefineComponent<ZoomProps, {
|
|
|
291
300
|
zoom: number;
|
|
292
301
|
minZoom: number;
|
|
293
302
|
maxZoom: number;
|
|
294
|
-
}, {}, {}, {}, string,
|
|
303
|
+
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
295
304
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
296
|
-
declare const _default$
|
|
305
|
+
declare const _default$6: typeof __VLS_export;
|
|
297
306
|
type __VLS_WithSlots<T, S> = T & {
|
|
298
307
|
new (): {
|
|
299
308
|
$slots: S;
|
|
300
309
|
};
|
|
301
310
|
};
|
|
302
311
|
//#endregion
|
|
312
|
+
//#region src/hooks/useMapContext.d.ts
|
|
313
|
+
declare const mapContextKey: InjectionKey<ComputedRef<MapContext>>;
|
|
314
|
+
declare function useMapContext(): ComputedRef<MapContext> | undefined;
|
|
315
|
+
//#endregion
|
|
303
316
|
//#region src/plugin.d.ts
|
|
304
317
|
/**
|
|
305
318
|
* Vue plugin that registers all d3-maps components globally.
|
|
@@ -308,4 +321,4 @@ declare const plugin: {
|
|
|
308
321
|
install(app: App): void;
|
|
309
322
|
};
|
|
310
323
|
//#endregion
|
|
311
|
-
export { _default as Map, _default$1 as MapFeature, _default$2 as MapFeatures, _default$3 as
|
|
324
|
+
export { _default as Map, _default$1 as MapFeature, _default$2 as MapFeatures, _default$3 as MapGraticule, _default$4 as MapMarker, _default$5 as MapMesh, MapObjectStyles, _default$6 as MapZoom, UseMapObjectResult, mapContextKey, plugin, useMapContext, useMapObject };
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r){var i=Object.defineProperty,a=(e,t)=>{let n={};for(var r in e)i(n,r,{get:e[r],enumerable:!0});return t&&i(n,Symbol.toStringTag,{value:`Module`}),n};let o=Symbol(`MapContext`)
|
|
1
|
+
(function(e,t,n,r){var i=Object.defineProperty,a=(e,t)=>{let n={};for(var r in e)i(n,r,{get:e[r],enumerable:!0});return t&&i(n,Symbol.toStringTag,{value:`Module`}),n};let o=Symbol(`MapContext`);function s(){return(0,n.inject)(o)}let c=[`viewBox`];var l=(0,n.defineComponent)({__name:`Map`,props:{width:{},height:{},aspectRatio:{},projection:{type:Function},projectionConfig:{},data:{},dataTransformer:{type:Function}},setup(e){let t=e,i=(0,n.computed)(()=>(0,r.makeMapContext)({width:t.width,height:t.height,aspectRatio:t.aspectRatio,projection:t.projection,projectionConfig:t.projectionConfig,data:t.data,dataTransformer:t.dataTransformer}));return(0,n.provide)(o,i),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`svg`,(0,n.mergeProps)({viewBox:`0 0 ${i.value.width} ${i.value.height}`},e.$attrs,{class:`d3-map`}),[(0,n.renderSlot)(e.$slots,`default`,(0,n.normalizeProps)((0,n.guardReactiveProps)(i.value)))],16,c))}});function u(e){let t=(0,n.ref)(`default`),i=e=>()=>{t.value=(0,r.getObjectStateUpdate)(e)};return{style:(0,n.computed)(()=>(0,r.resolveObjectStyle)(t.value,(0,n.unref)(e))),onMouseenter:i(`mouseenter`),onMouseleave:i(`mouseleave`),onMousedown:i(`mousedown`),onMouseup:i(`mouseup`)}}let d=[`d`];var f=(0,n.defineComponent)({__name:`MapFeature`,props:{data:{},styles:{}},setup(e){let t=e,{style:r,...i}=u((0,n.toRef)(t,`styles`)),a=s(),o=(0,n.computed)(()=>a?.value.path(t.data)??void 0);return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`path`,(0,n.mergeProps)({d:o.value,style:(0,n.unref)(r)},i,{name:`feature`}),null,16,d))}});let p={name:`features`};var m=(0,n.defineComponent)({__name:`MapFeatures`,props:{idKey:{default:`id`},styles:{}},setup(e){let t=s(),i=(0,n.computed)(()=>t?.value.features??[]);return(t,a)=>((0,n.openBlock)(),(0,n.createElementBlock)(`g`,p,[(0,n.renderSlot)(t.$slots,`default`,{features:i.value},()=>[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(i.value,(t,i)=>((0,n.openBlock)(),(0,n.createBlock)(f,{key:(0,n.unref)(r.getFeatureKey)(t,e.idKey,i),data:t,styles:e.styles},null,8,[`data`,`styles`]))),128))])]))}});let h=[`d`,`fill`],g=[`d`],_=[`d`,`stroke`];var v=(0,n.defineComponent)({inheritAttrs:!1,__name:`MapGraticule`,props:{config:{},background:{type:[Boolean,String]},border:{type:[Boolean,String]},styles:{}},setup(e){let t=e,i=s(),a=(0,n.computed)(()=>{if(i?.value)return(0,r.renderGraticule)(i.value,t.config)??void 0}),o=(0,n.computed)(()=>{if(i?.value)return(0,r.renderOutline)(i.value)??void 0}),c=(0,n.computed)(()=>(0,r.isString)(t.background)?t.background:void 0),l=(0,n.computed)(()=>(0,r.isString)(t.border)?t.border:void 0),{style:d,...f}=u((0,n.toRef)(t,`styles`));return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`g`,null,[e.background?((0,n.openBlock)(),(0,n.createElementBlock)(`path`,{key:0,d:o.value,fill:c.value,"pointer-events":`none`,name:`background`},null,8,h)):(0,n.createCommentVNode)(`v-if`,!0),a.value?((0,n.openBlock)(),(0,n.createElementBlock)(`path`,(0,n.mergeProps)({key:1,d:a.value,fill:`none`,style:(0,n.unref)(d)},{...t.$attrs,...f},{name:`graticule`}),null,16,g)):(0,n.createCommentVNode)(`v-if`,!0),e.border?((0,n.openBlock)(),(0,n.createElementBlock)(`path`,{key:2,d:o.value,fill:`none`,stroke:l.value,"pointer-events":`none`,name:`border`},null,8,_)):(0,n.createCommentVNode)(`v-if`,!0)]))}});let y=[`transform`];var b=(0,n.defineComponent)({__name:`MapMarker`,props:{coordinates:{default:()=>[0,0]},styles:{}},setup(e){let t=e,i=s(),a=(0,n.computed)(()=>(0,r.getMarkerTransform)(i?.value,t.coordinates)),{style:o,...c}=u((0,n.toRef)(t,`styles`));return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`g`,(0,n.mergeProps)({transform:a.value,style:(0,n.unref)(o)},c,{name:`marker`}),[(0,n.renderSlot)(e.$slots,`default`)],16,y))}});let x=[`d`];var S=(0,n.defineComponent)({__name:`MapMesh`,props:{styles:{}},setup(e){let t=e,r=s(),i=(0,n.computed)(()=>r?.value.renderMesh()??void 0),{style:a,...o}=u((0,n.toRef)(t,`styles`));return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`path`,(0,n.mergeProps)({d:i.value,fill:`none`,style:(0,n.unref)(a)},o,{name:`mesh`}),null,16,x))}}),C=(0,n.defineComponent)({__name:`MapZoom`,props:{center:{default:()=>[0,0]},zoom:{default:1},minZoom:{default:1},maxZoom:{default:8},config:{}},emits:[`zoomstart`,`zoom`,`zoomend`],setup(e,{expose:t,emit:i}){let a=e,o=i,c=(0,n.ref)(null),l=s(),u=(0,n.computed)(()=>(0,r.createZoomBehavior)(l?.value,{minZoom:a.minZoom,maxZoom:a.maxZoom,config:a.config,onZoomStart:e=>o(`zoomstart`,e),onZoom:e=>{(0,r.applyZoomGroupTransform)(c.value,e.transform),o(`zoom`,e)},onZoomEnd:e=>o(`zoomend`,e)}));return(0,n.onMounted)(()=>{(0,n.watch)(u,e=>{c.value&&(0,r.setupZoom)({element:c.value,behavior:e,center:a.center,zoom:a.zoom})},{immediate:!0}),(0,n.watch)(()=>[u.value,a.center[0],a.center[1],a.zoom],()=>{c.value&&(0,r.applyZoomTransform)({element:c.value,behavior:u.value,center:a.center,zoom:a.zoom})})}),t({container:c,zoomBehavior:u}),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`g`,{ref_key:`container`,ref:c,name:`zoom`},[(0,n.renderSlot)(e.$slots,`default`)],512))}}),w=a({Map:()=>l,MapFeature:()=>f,MapFeatures:()=>m,MapGraticule:()=>v,MapMarker:()=>b,MapMesh:()=>S,MapZoom:()=>C});e.Map=l,e.MapFeature=f,e.MapFeatures=m,e.MapGraticule=v,e.MapMarker=b,e.MapMesh=S,e.MapZoom=C,e.mapContextKey=o,e.plugin={install(e){Object.entries(w).forEach(([t,n])=>{e.component(t,n)})}},e.useMapContext=s,e.useMapObject=u})(this.D3Maps=this.D3Maps||{},_d3_maps_core_index_css,Vue,D3Maps);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@d3-maps/core/index.css";
|
|
2
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps,
|
|
3
|
-
import { applyZoomTransform, createZoomBehavior, getFeatureKey, getMarkerTransform, getObjectStateUpdate, makeMapContext, resolveObjectStyle, setupZoom } from "@d3-maps/core";
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onMounted, openBlock, provide, ref, renderList, renderSlot, toRef, unref, watch } from "vue";
|
|
3
|
+
import { applyZoomGroupTransform, applyZoomTransform, createZoomBehavior, getFeatureKey, getMarkerTransform, getObjectStateUpdate, isString, makeMapContext, renderGraticule, renderOutline, resolveObjectStyle, setupZoom } from "@d3-maps/core";
|
|
4
4
|
|
|
5
5
|
//#region rolldown:runtime
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
@@ -19,32 +19,15 @@ var __exportAll = (all, symbols) => {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
|
-
//#region src/
|
|
22
|
+
//#region src/hooks/useMapContext.ts
|
|
23
23
|
const mapContextKey = Symbol("MapContext");
|
|
24
|
-
const MapProvider = defineComponent((props, { slots }) => {
|
|
25
|
-
provide(mapContextKey, props.context);
|
|
26
|
-
return () => slots.default?.() ?? null;
|
|
27
|
-
}, { props: { context: {
|
|
28
|
-
type: Object,
|
|
29
|
-
required: true
|
|
30
|
-
} } });
|
|
31
|
-
const MapConsumer = defineComponent({
|
|
32
|
-
name: "MapConsumer",
|
|
33
|
-
setup(_, { slots }) {
|
|
34
|
-
const context = inject(mapContextKey);
|
|
35
|
-
return () => {
|
|
36
|
-
if (!slots.default) return null;
|
|
37
|
-
return slots.default(context ?? {});
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
24
|
function useMapContext() {
|
|
42
25
|
return inject(mapContextKey);
|
|
43
26
|
}
|
|
44
27
|
|
|
45
28
|
//#endregion
|
|
46
29
|
//#region src/components/Map.vue?vue&type=script&setup=true&lang.ts
|
|
47
|
-
const _hoisted_1$
|
|
30
|
+
const _hoisted_1$5 = ["viewBox"];
|
|
48
31
|
var Map_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
49
32
|
__name: "Map",
|
|
50
33
|
props: {
|
|
@@ -67,11 +50,9 @@ var Map_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
67
50
|
data: props.data,
|
|
68
51
|
dataTransformer: props.dataTransformer
|
|
69
52
|
}));
|
|
53
|
+
provide(mapContextKey, context);
|
|
70
54
|
return (_ctx, _cache) => {
|
|
71
|
-
return openBlock(),
|
|
72
|
-
default: withCtx(() => [(openBlock(), createElementBlock("svg", mergeProps({ viewBox: `0 0 ${context.value.width} ${context.value.height}` }, _ctx.$attrs, { class: "d3-map" }), [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(context.value)))], 16, _hoisted_1$3))]),
|
|
73
|
-
_: 3
|
|
74
|
-
}, 8, ["context"]);
|
|
55
|
+
return openBlock(), createElementBlock("svg", mergeProps({ viewBox: `0 0 ${context.value.width} ${context.value.height}` }, _ctx.$attrs, { class: "d3-map" }), [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(context.value)))], 16, _hoisted_1$5);
|
|
75
56
|
};
|
|
76
57
|
}
|
|
77
58
|
});
|
|
@@ -81,61 +62,40 @@ var Map_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
81
62
|
var Map_default = Map_vue_vue_type_script_setup_true_lang_default;
|
|
82
63
|
|
|
83
64
|
//#endregion
|
|
84
|
-
//#region src/
|
|
85
|
-
function useMapObject(
|
|
65
|
+
//#region src/hooks/useMapObject.ts
|
|
66
|
+
function useMapObject(styles) {
|
|
86
67
|
const state = ref("default");
|
|
87
|
-
const eventCallbackFactory = (eventName) => (
|
|
68
|
+
const eventCallbackFactory = (eventName) => () => {
|
|
88
69
|
state.value = getObjectStateUpdate(eventName);
|
|
89
|
-
emit(eventName, event);
|
|
90
70
|
};
|
|
91
71
|
return {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
onFocus: eventCallbackFactory("focus"),
|
|
98
|
-
onBlur: eventCallbackFactory("blur")
|
|
72
|
+
style: computed(() => resolveObjectStyle(state.value, unref(styles))),
|
|
73
|
+
onMouseenter: eventCallbackFactory("mouseenter"),
|
|
74
|
+
onMouseleave: eventCallbackFactory("mouseleave"),
|
|
75
|
+
onMousedown: eventCallbackFactory("mousedown"),
|
|
76
|
+
onMouseup: eventCallbackFactory("mouseup")
|
|
99
77
|
};
|
|
100
78
|
}
|
|
101
79
|
|
|
102
80
|
//#endregion
|
|
103
81
|
//#region src/components/MapFeature.vue?vue&type=script&setup=true&lang.ts
|
|
104
|
-
const _hoisted_1$
|
|
105
|
-
"d",
|
|
106
|
-
"fill",
|
|
107
|
-
"stroke"
|
|
108
|
-
];
|
|
82
|
+
const _hoisted_1$4 = ["d"];
|
|
109
83
|
var MapFeature_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
110
84
|
__name: "MapFeature",
|
|
111
85
|
props: {
|
|
112
86
|
data: {},
|
|
113
|
-
styles: {}
|
|
114
|
-
fill: {},
|
|
115
|
-
stroke: {}
|
|
87
|
+
styles: {}
|
|
116
88
|
},
|
|
117
|
-
setup(__props
|
|
89
|
+
setup(__props) {
|
|
118
90
|
const props = __props;
|
|
119
|
-
const
|
|
91
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
120
92
|
const context = useMapContext();
|
|
121
|
-
const path = computed(() => context?.
|
|
122
|
-
const { computedStyle, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onFocus, onBlur } = useMapObject(emit, toRef(props, "styles"));
|
|
93
|
+
const path = computed(() => context?.value.path(props.data) ?? void 0);
|
|
123
94
|
return (_ctx, _cache) => {
|
|
124
|
-
return
|
|
125
|
-
key: 0,
|
|
95
|
+
return openBlock(), createElementBlock("path", mergeProps({
|
|
126
96
|
d: path.value,
|
|
127
|
-
style: unref(
|
|
128
|
-
|
|
129
|
-
stroke: __props.stroke
|
|
130
|
-
}, _ctx.$attrs, {
|
|
131
|
-
onMouseenter: _cache[0] || (_cache[0] = (...args) => unref(onMouseEnter) && unref(onMouseEnter)(...args)),
|
|
132
|
-
onMouseleave: _cache[1] || (_cache[1] = (...args) => unref(onMouseLeave) && unref(onMouseLeave)(...args)),
|
|
133
|
-
onMousedown: _cache[2] || (_cache[2] = (...args) => unref(onMouseDown) && unref(onMouseDown)(...args)),
|
|
134
|
-
onMouseup: _cache[3] || (_cache[3] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
135
|
-
onClick: _cache[4] || (_cache[4] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
136
|
-
onFocus: _cache[5] || (_cache[5] = (...args) => unref(onFocus) && unref(onFocus)(...args)),
|
|
137
|
-
onBlur: _cache[6] || (_cache[6] = (...args) => unref(onBlur) && unref(onBlur)(...args))
|
|
138
|
-
}), null, 16, _hoisted_1$2)) : createCommentVNode("v-if", true);
|
|
97
|
+
style: unref(style)
|
|
98
|
+
}, events, { name: "feature" }), null, 16, _hoisted_1$4);
|
|
139
99
|
};
|
|
140
100
|
}
|
|
141
101
|
});
|
|
@@ -146,31 +106,23 @@ var MapFeature_default = MapFeature_vue_vue_type_script_setup_true_lang_default;
|
|
|
146
106
|
|
|
147
107
|
//#endregion
|
|
148
108
|
//#region src/components/MapFeatures.vue?vue&type=script&setup=true&lang.ts
|
|
109
|
+
const _hoisted_1$3 = { name: "features" };
|
|
149
110
|
var MapFeatures_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
150
111
|
__name: "MapFeatures",
|
|
151
112
|
props: {
|
|
152
113
|
idKey: { default: "id" },
|
|
153
|
-
fill: {},
|
|
154
|
-
stroke: {},
|
|
155
114
|
styles: {}
|
|
156
115
|
},
|
|
157
116
|
setup(__props) {
|
|
158
117
|
const context = useMapContext();
|
|
159
|
-
const features = computed(() => context?.features ?? []);
|
|
118
|
+
const features = computed(() => context?.value.features ?? []);
|
|
160
119
|
return (_ctx, _cache) => {
|
|
161
|
-
return openBlock(), createElementBlock("g",
|
|
162
|
-
return openBlock(), createBlock(MapFeature_default,
|
|
120
|
+
return openBlock(), createElementBlock("g", _hoisted_1$3, [renderSlot(_ctx.$slots, "default", { features: features.value }, () => [(openBlock(true), createElementBlock(Fragment, null, renderList(features.value, (feature, index) => {
|
|
121
|
+
return openBlock(), createBlock(MapFeature_default, {
|
|
163
122
|
key: unref(getFeatureKey)(feature, __props.idKey, index),
|
|
164
123
|
data: feature,
|
|
165
|
-
fill: __props.fill,
|
|
166
|
-
stroke: __props.stroke,
|
|
167
124
|
styles: __props.styles
|
|
168
|
-
},
|
|
169
|
-
"data",
|
|
170
|
-
"fill",
|
|
171
|
-
"stroke",
|
|
172
|
-
"styles"
|
|
173
|
-
]);
|
|
125
|
+
}, null, 8, ["data", "styles"]);
|
|
174
126
|
}), 128))])]);
|
|
175
127
|
};
|
|
176
128
|
}
|
|
@@ -180,6 +132,69 @@ var MapFeatures_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
180
132
|
//#region src/components/MapFeatures.vue
|
|
181
133
|
var MapFeatures_default = MapFeatures_vue_vue_type_script_setup_true_lang_default;
|
|
182
134
|
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/components/MapGraticule.vue?vue&type=script&setup=true&lang.ts
|
|
137
|
+
const _hoisted_1$2 = ["d", "fill"];
|
|
138
|
+
const _hoisted_2 = ["d"];
|
|
139
|
+
const _hoisted_3 = ["d", "stroke"];
|
|
140
|
+
var MapGraticule_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
141
|
+
inheritAttrs: false,
|
|
142
|
+
__name: "MapGraticule",
|
|
143
|
+
props: {
|
|
144
|
+
config: {},
|
|
145
|
+
background: { type: [Boolean, String] },
|
|
146
|
+
border: { type: [Boolean, String] },
|
|
147
|
+
styles: {}
|
|
148
|
+
},
|
|
149
|
+
setup(__props) {
|
|
150
|
+
const props = __props;
|
|
151
|
+
const context = useMapContext();
|
|
152
|
+
const graticulePath = computed(() => {
|
|
153
|
+
if (!context?.value) return void 0;
|
|
154
|
+
return renderGraticule(context.value, props.config) ?? void 0;
|
|
155
|
+
});
|
|
156
|
+
const outlinePath = computed(() => {
|
|
157
|
+
if (!context?.value) return void 0;
|
|
158
|
+
return renderOutline(context.value) ?? void 0;
|
|
159
|
+
});
|
|
160
|
+
const backgroundColor = computed(() => isString(props.background) ? props.background : void 0);
|
|
161
|
+
const borderColor = computed(() => isString(props.border) ? props.border : void 0);
|
|
162
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
163
|
+
return (_ctx, _cache) => {
|
|
164
|
+
return openBlock(), createElementBlock("g", null, [
|
|
165
|
+
__props.background ? (openBlock(), createElementBlock("path", {
|
|
166
|
+
key: 0,
|
|
167
|
+
d: outlinePath.value,
|
|
168
|
+
fill: backgroundColor.value,
|
|
169
|
+
"pointer-events": "none",
|
|
170
|
+
name: "background"
|
|
171
|
+
}, null, 8, _hoisted_1$2)) : createCommentVNode("v-if", true),
|
|
172
|
+
graticulePath.value ? (openBlock(), createElementBlock("path", mergeProps({
|
|
173
|
+
key: 1,
|
|
174
|
+
d: graticulePath.value,
|
|
175
|
+
fill: "none",
|
|
176
|
+
style: unref(style)
|
|
177
|
+
}, {
|
|
178
|
+
..._ctx.$attrs,
|
|
179
|
+
...events
|
|
180
|
+
}, { name: "graticule" }), null, 16, _hoisted_2)) : createCommentVNode("v-if", true),
|
|
181
|
+
__props.border ? (openBlock(), createElementBlock("path", {
|
|
182
|
+
key: 2,
|
|
183
|
+
d: outlinePath.value,
|
|
184
|
+
fill: "none",
|
|
185
|
+
stroke: borderColor.value,
|
|
186
|
+
"pointer-events": "none",
|
|
187
|
+
name: "border"
|
|
188
|
+
}, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)
|
|
189
|
+
]);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/components/MapGraticule.vue
|
|
196
|
+
var MapGraticule_default = MapGraticule_vue_vue_type_script_setup_true_lang_default;
|
|
197
|
+
|
|
183
198
|
//#endregion
|
|
184
199
|
//#region src/components/MapMarker.vue?vue&type=script&setup=true&lang.ts
|
|
185
200
|
const _hoisted_1$1 = ["transform"];
|
|
@@ -189,26 +204,18 @@ var MapMarker_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
189
204
|
coordinates: { default: () => [0, 0] },
|
|
190
205
|
styles: {}
|
|
191
206
|
},
|
|
192
|
-
setup(__props
|
|
207
|
+
setup(__props) {
|
|
193
208
|
const props = __props;
|
|
194
|
-
const emit = __emit;
|
|
195
209
|
const context = useMapContext();
|
|
196
210
|
const transform = computed(() => {
|
|
197
|
-
return getMarkerTransform(context, props.coordinates);
|
|
211
|
+
return getMarkerTransform(context?.value, props.coordinates);
|
|
198
212
|
});
|
|
199
|
-
const {
|
|
213
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
200
214
|
return (_ctx, _cache) => {
|
|
201
|
-
return openBlock(), createElementBlock("g", {
|
|
215
|
+
return openBlock(), createElementBlock("g", mergeProps({
|
|
202
216
|
transform: transform.value,
|
|
203
|
-
style:
|
|
204
|
-
|
|
205
|
-
onMouseleave: _cache[1] || (_cache[1] = (...args) => unref(onMouseLeave) && unref(onMouseLeave)(...args)),
|
|
206
|
-
onMousedown: _cache[2] || (_cache[2] = (...args) => unref(onMouseDown) && unref(onMouseDown)(...args)),
|
|
207
|
-
onMouseup: _cache[3] || (_cache[3] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
208
|
-
onClick: _cache[4] || (_cache[4] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
209
|
-
onFocus: _cache[5] || (_cache[5] = (...args) => unref(onFocus) && unref(onFocus)(...args)),
|
|
210
|
-
onBlur: _cache[6] || (_cache[6] = (...args) => unref(onBlur) && unref(onBlur)(...args))
|
|
211
|
-
}, [renderSlot(_ctx.$slots, "default")], 44, _hoisted_1$1);
|
|
217
|
+
style: unref(style)
|
|
218
|
+
}, events, { name: "marker" }), [renderSlot(_ctx.$slots, "default")], 16, _hoisted_1$1);
|
|
212
219
|
};
|
|
213
220
|
}
|
|
214
221
|
});
|
|
@@ -219,40 +226,21 @@ var MapMarker_default = MapMarker_vue_vue_type_script_setup_true_lang_default;
|
|
|
219
226
|
|
|
220
227
|
//#endregion
|
|
221
228
|
//#region src/components/MapMesh.vue?vue&type=script&setup=true&lang.ts
|
|
222
|
-
const _hoisted_1 = [
|
|
223
|
-
"d",
|
|
224
|
-
"fill",
|
|
225
|
-
"stroke"
|
|
226
|
-
];
|
|
229
|
+
const _hoisted_1 = ["d"];
|
|
227
230
|
var MapMesh_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
228
231
|
__name: "MapMesh",
|
|
229
|
-
props: {
|
|
230
|
-
|
|
231
|
-
stroke: {},
|
|
232
|
-
styles: {}
|
|
233
|
-
},
|
|
234
|
-
setup(__props, { emit: __emit }) {
|
|
232
|
+
props: { styles: {} },
|
|
233
|
+
setup(__props) {
|
|
235
234
|
const props = __props;
|
|
236
|
-
const emit = __emit;
|
|
237
235
|
const context = useMapContext();
|
|
238
|
-
const path = computed(() => context?.renderMesh());
|
|
239
|
-
const {
|
|
236
|
+
const path = computed(() => context?.value.renderMesh() ?? void 0);
|
|
237
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
240
238
|
return (_ctx, _cache) => {
|
|
241
|
-
return
|
|
242
|
-
key: 0,
|
|
239
|
+
return openBlock(), createElementBlock("path", mergeProps({
|
|
243
240
|
d: path.value,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}, _ctx.$attrs, {
|
|
248
|
-
onMouseenter: _cache[0] || (_cache[0] = (...args) => unref(onMouseEnter) && unref(onMouseEnter)(...args)),
|
|
249
|
-
onMouseleave: _cache[1] || (_cache[1] = (...args) => unref(onMouseLeave) && unref(onMouseLeave)(...args)),
|
|
250
|
-
onMousedown: _cache[2] || (_cache[2] = (...args) => unref(onMouseDown) && unref(onMouseDown)(...args)),
|
|
251
|
-
onMouseup: _cache[3] || (_cache[3] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
252
|
-
onClick: _cache[4] || (_cache[4] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
253
|
-
onFocus: _cache[5] || (_cache[5] = (...args) => unref(onFocus) && unref(onFocus)(...args)),
|
|
254
|
-
onBlur: _cache[6] || (_cache[6] = (...args) => unref(onBlur) && unref(onBlur)(...args))
|
|
255
|
-
}), null, 16, _hoisted_1)) : createCommentVNode("v-if", true);
|
|
241
|
+
fill: "none",
|
|
242
|
+
style: unref(style)
|
|
243
|
+
}, events, { name: "mesh" }), null, 16, _hoisted_1);
|
|
256
244
|
};
|
|
257
245
|
}
|
|
258
246
|
});
|
|
@@ -283,35 +271,42 @@ var MapZoom_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
283
271
|
const container = ref(null);
|
|
284
272
|
const context = useMapContext();
|
|
285
273
|
const zoomBehavior = computed(() => {
|
|
286
|
-
return createZoomBehavior(context, {
|
|
274
|
+
return createZoomBehavior(context?.value, {
|
|
287
275
|
minZoom: props.minZoom,
|
|
288
276
|
maxZoom: props.maxZoom,
|
|
289
277
|
config: props.config,
|
|
290
278
|
onZoomStart: (event) => emit("zoomstart", event),
|
|
291
279
|
onZoom: (event) => {
|
|
292
|
-
|
|
280
|
+
applyZoomGroupTransform(container.value, event.transform);
|
|
293
281
|
emit("zoom", event);
|
|
294
282
|
},
|
|
295
283
|
onZoomEnd: (event) => emit("zoomend", event)
|
|
296
284
|
});
|
|
297
285
|
});
|
|
298
286
|
onMounted(() => {
|
|
299
|
-
watch(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
287
|
+
watch(zoomBehavior, (behavior) => {
|
|
288
|
+
if (!container.value) return;
|
|
289
|
+
setupZoom({
|
|
290
|
+
element: container.value,
|
|
291
|
+
behavior,
|
|
292
|
+
center: props.center,
|
|
293
|
+
zoom: props.zoom
|
|
294
|
+
});
|
|
295
|
+
}, { immediate: true });
|
|
305
296
|
watch(() => [
|
|
297
|
+
zoomBehavior.value,
|
|
306
298
|
props.center[0],
|
|
307
299
|
props.center[1],
|
|
308
300
|
props.zoom
|
|
309
|
-
], () =>
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
301
|
+
], () => {
|
|
302
|
+
if (!container.value) return;
|
|
303
|
+
applyZoomTransform({
|
|
304
|
+
element: container.value,
|
|
305
|
+
behavior: zoomBehavior.value,
|
|
306
|
+
center: props.center,
|
|
307
|
+
zoom: props.zoom
|
|
308
|
+
});
|
|
309
|
+
});
|
|
315
310
|
});
|
|
316
311
|
__expose({
|
|
317
312
|
container,
|
|
@@ -321,7 +316,7 @@ var MapZoom_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
321
316
|
return openBlock(), createElementBlock("g", {
|
|
322
317
|
ref_key: "container",
|
|
323
318
|
ref: container,
|
|
324
|
-
|
|
319
|
+
name: "zoom"
|
|
325
320
|
}, [renderSlot(_ctx.$slots, "default")], 512);
|
|
326
321
|
};
|
|
327
322
|
}
|
|
@@ -337,6 +332,7 @@ var components_exports = /* @__PURE__ */ __exportAll({
|
|
|
337
332
|
Map: () => Map_default,
|
|
338
333
|
MapFeature: () => MapFeature_default,
|
|
339
334
|
MapFeatures: () => MapFeatures_default,
|
|
335
|
+
MapGraticule: () => MapGraticule_default,
|
|
340
336
|
MapMarker: () => MapMarker_default,
|
|
341
337
|
MapMesh: () => MapMesh_default,
|
|
342
338
|
MapZoom: () => MapZoom_default
|
|
@@ -354,4 +350,4 @@ const plugin = { install(app) {
|
|
|
354
350
|
} };
|
|
355
351
|
|
|
356
352
|
//#endregion
|
|
357
|
-
export { Map_default as Map, MapFeature_default as MapFeature, MapFeatures_default as MapFeatures, MapMarker_default as MapMarker, MapMesh_default as MapMesh, MapZoom_default as MapZoom, plugin };
|
|
353
|
+
export { Map_default as Map, MapFeature_default as MapFeature, MapFeatures_default as MapFeatures, MapGraticule_default as MapGraticule, MapMarker_default as MapMarker, MapMesh_default as MapMesh, MapZoom_default as MapZoom, mapContextKey, plugin, useMapContext, useMapObject };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d3-maps/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Vue bindings for @d3-maps/core to build reactive D3 SVG maps",
|
|
7
7
|
"author": "Georgii Bukharov <souljorje@gmail.com>",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"vue": "3.5.25"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@d3-maps/core": "0.
|
|
47
|
+
"@d3-maps/core": "0.5.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/geojson": "^7946.0.16",
|