@d3-maps/vue 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@d3-maps/core/index.css";
2
- import * as vue0 from "vue";
2
+ import * as vue6 from "vue";
3
3
  import { App, ComputedRef, InjectionKey, MaybeRef, StyleValue } from "vue";
4
4
  import { ExtendedFeature, ExtendedFeatureCollection, GeoGraticuleGenerator, GeoPath, GeoProjection } from "d3-geo";
5
5
  import { Topology } from "topojson-specification";
@@ -12,7 +12,9 @@ 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$1<TStyle> = Partial<Record<MapObjectState, TStyle>>;
15
+ interface MapObject<TStyle = unknown> {
16
+ styles?: Partial<Record<MapObjectState, TStyle>>;
17
+ }
16
18
  //#endregion
17
19
  //#region ../core/src/lib/feature.d.ts
18
20
  /**
@@ -24,9 +26,8 @@ type MapFeature = (ExtendedFeature & Record<string, unknown>) | ExtendedFeature;
24
26
  /**
25
27
  * Shared props contract for a single rendered feature.
26
28
  */
27
- interface MapFeatureProps<TStyle = unknown> {
29
+ interface MapFeatureProps<TStyle = unknown> extends MapObject<TStyle> {
28
30
  data: MapFeature;
29
- styles?: MapObjectStyles$1<TStyle>;
30
31
  }
31
32
  //#endregion
32
33
  //#region ../core/src/lib/utils.d.ts
@@ -169,9 +170,8 @@ type MapMarkerCoordinates = [number, number];
169
170
  /**
170
171
  * Shared props contract for marker layers.
171
172
  */
172
- interface MapMarkerProps<TStyle = unknown> {
173
+ interface MapMarkerProps<TStyle = unknown> extends MapObject<TStyle> {
173
174
  coordinates?: MapMarkerCoordinates;
174
- styles?: MapObjectStyles$1<TStyle>;
175
175
  }
176
176
  //#endregion
177
177
  //#region ../core/src/lib/zoom.d.ts
@@ -198,7 +198,7 @@ interface ZoomEvent extends D3ZoomEvent<SVGSVGElement, unknown> {}
198
198
  type __VLS_Slots$3 = {
199
199
  default?: (props: MapContext) => unknown;
200
200
  };
201
- declare const __VLS_base$3: vue0.DefineComponent<MapConfig, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<MapConfig> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
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
202
  declare const __VLS_export$6: __VLS_WithSlots$3<typeof __VLS_base$3, __VLS_Slots$3>;
203
203
  declare const _default: typeof __VLS_export$6;
204
204
  type __VLS_WithSlots$3<T, S> = T & {
@@ -209,24 +209,12 @@ type __VLS_WithSlots$3<T, S> = T & {
209
209
  //#endregion
210
210
  //#region src/components/MapFeature.vue.d.ts
211
211
  type __VLS_Props$1 = MapFeatureProps<StyleValue>;
212
- declare const __VLS_export$5: vue0.DefineComponent<__VLS_Props$1, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<__VLS_Props$1> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
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
213
  declare const _default$1: typeof __VLS_export$5;
214
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;
225
- //#endregion
226
215
  //#region src/components/MapFeatures.vue.d.ts
227
- interface Props$2 {
216
+ interface Props$2 extends MapObject<StyleValue> {
228
217
  idKey?: string;
229
- styles?: MapObjectStyles;
230
218
  }
231
219
  declare var __VLS_1$2: {
232
220
  features: MapFeature[];
@@ -234,9 +222,9 @@ declare var __VLS_1$2: {
234
222
  type __VLS_Slots$2 = {} & {
235
223
  default?: (props: typeof __VLS_1$2) => any;
236
224
  };
237
- declare const __VLS_base$2: vue0.DefineComponent<Props$2, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<Props$2> & Readonly<{}>, {
225
+ declare const __VLS_base$2: vue6.DefineComponent<Props$2, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props$2> & Readonly<{}>, {
238
226
  idKey: string;
239
- }, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
227
+ }, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
240
228
  declare const __VLS_export$4: __VLS_WithSlots$2<typeof __VLS_base$2, __VLS_Slots$2>;
241
229
  declare const _default$2: typeof __VLS_export$4;
242
230
  type __VLS_WithSlots$2<T, S> = T & {
@@ -246,13 +234,12 @@ type __VLS_WithSlots$2<T, S> = T & {
246
234
  };
247
235
  //#endregion
248
236
  //#region src/components/MapGraticule.vue.d.ts
249
- interface Props$1 {
237
+ interface Props$1 extends MapObject<StyleValue> {
250
238
  config?: GraticuleConfig;
251
239
  background?: boolean | string;
252
240
  border?: boolean | string;
253
- styles?: MapObjectStyles;
254
241
  }
255
- declare const __VLS_export$3: vue0.DefineComponent<Props$1, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<Props$1> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
242
+ 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
243
  declare const _default$3: typeof __VLS_export$3;
257
244
  //#endregion
258
245
  //#region src/components/MapMarker.vue.d.ts
@@ -261,9 +248,9 @@ declare var __VLS_1$1: {};
261
248
  type __VLS_Slots$1 = {} & {
262
249
  default?: (props: typeof __VLS_1$1) => any;
263
250
  };
264
- declare const __VLS_base$1: vue0.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
251
+ declare const __VLS_base$1: vue6.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
265
252
  coordinates: MapMarkerCoordinates;
266
- }, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
253
+ }, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
267
254
  declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
268
255
  declare const _default$4: typeof __VLS_export$2;
269
256
  type __VLS_WithSlots$1<T, S> = T & {
@@ -273,10 +260,8 @@ type __VLS_WithSlots$1<T, S> = T & {
273
260
  };
274
261
  //#endregion
275
262
  //#region src/components/MapMesh.vue.d.ts
276
- interface Props {
277
- styles?: MapObjectStyles;
278
- }
279
- declare const __VLS_export$1: vue0.DefineComponent<Props, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
263
+ interface Props extends MapObject<StyleValue> {}
264
+ declare const __VLS_export$1: vue6.DefineComponent<Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
280
265
  declare const _default$5: typeof __VLS_export$1;
281
266
  //#endregion
282
267
  //#region src/components/MapZoom.vue.d.ts
@@ -284,14 +269,14 @@ declare var __VLS_1: {};
284
269
  type __VLS_Slots = {} & {
285
270
  default?: (props: typeof __VLS_1) => any;
286
271
  };
287
- declare const __VLS_base: vue0.DefineComponent<ZoomProps, {
288
- container: vue0.Ref<SVGGElement | null, SVGGElement | null>;
289
- zoomBehavior: vue0.ComputedRef<DefaultZoomBehavior>;
290
- }, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {} & {
272
+ declare const __VLS_base: vue6.DefineComponent<ZoomProps, {
273
+ container: vue6.Ref<SVGGElement | null, SVGGElement | null>;
274
+ zoomBehavior: vue6.ComputedRef<DefaultZoomBehavior>;
275
+ }, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {} & {
291
276
  zoom: (payload: ZoomEvent) => any;
292
277
  zoomstart: (payload: ZoomEvent) => any;
293
278
  zoomend: (payload: ZoomEvent) => any;
294
- }, string, vue0.PublicProps, Readonly<ZoomProps> & Readonly<{
279
+ }, string, vue6.PublicProps, Readonly<ZoomProps> & Readonly<{
295
280
  onZoom?: ((payload: ZoomEvent) => any) | undefined;
296
281
  onZoomstart?: ((payload: ZoomEvent) => any) | undefined;
297
282
  onZoomend?: ((payload: ZoomEvent) => any) | undefined;
@@ -300,7 +285,7 @@ declare const __VLS_base: vue0.DefineComponent<ZoomProps, {
300
285
  zoom: number;
301
286
  minZoom: number;
302
287
  maxZoom: number;
303
- }, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
288
+ }, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
304
289
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
305
290
  declare const _default$6: typeof __VLS_export;
306
291
  type __VLS_WithSlots<T, S> = T & {
@@ -313,6 +298,16 @@ type __VLS_WithSlots<T, S> = T & {
313
298
  declare const mapContextKey: InjectionKey<ComputedRef<MapContext>>;
314
299
  declare function useMapContext(): ComputedRef<MapContext> | undefined;
315
300
  //#endregion
301
+ //#region src/hooks/useMapObject.d.ts
302
+ interface UseMapObjectResult {
303
+ style: ComputedRef<StyleValue | undefined>;
304
+ onMouseenter: (event: MouseEvent) => void;
305
+ onMouseleave: (event: MouseEvent) => void;
306
+ onMousedown: (event: MouseEvent) => void;
307
+ onMouseup: (event: MouseEvent) => void;
308
+ }
309
+ declare function useMapObject(styles: MaybeRef<Partial<Record<MapObjectState, StyleValue>> | undefined>): UseMapObjectResult;
310
+ //#endregion
316
311
  //#region src/plugin.d.ts
317
312
  /**
318
313
  * Vue plugin that registers all d3-maps components globally.
@@ -321,4 +316,4 @@ declare const plugin: {
321
316
  install(app: App): void;
322
317
  };
323
318
  //#endregion
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 };
319
+ export { _default as Map, _default$1 as MapFeature, _default$2 as MapFeatures, _default$3 as MapGraticule, _default$4 as MapMarker, _default$5 as MapMesh, _default$6 as MapZoom, UseMapObjectResult, mapContextKey, plugin, useMapContext, useMapObject };
@@ -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`);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.useAttrs)(),o=(0,n.computed)(()=>{if(i?.value)return(0,r.renderGraticule)(i.value,t.config)??void 0}),c=(0,n.computed)(()=>{if(i?.value)return(0,r.renderOutline)(i.value)??void 0}),l=(0,n.computed)(()=>(0,r.isString)(t.background)?t.background:void 0),d=(0,n.computed)(()=>(0,r.isString)(t.border)?t.border:void 0),{style:f,...p}=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:c.value,fill:l.value,"pointer-events":`none`,name:`background`},null,8,h)):(0,n.createCommentVNode)(`v-if`,!0),(0,n.createElementVNode)(`path`,(0,n.mergeProps)({d:o.value,fill:`none`,style:(0,n.unref)(f)},(0,n.mergeProps)(p,(0,n.unref)(a)),{name:`graticule`}),null,16,g),e.border?((0,n.openBlock)(),(0,n.createElementBlock)(`path`,{key:1,d:c.value,fill:`none`,stroke:d.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);
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))}});let u=Symbol(`InsideZoom`);function d(){return(0,n.inject)(u,!1)}function f(e){let t=(0,n.ref)(`default`),{onMouseenter:i,onMouseleave:a,onMouseup:o,onMousedown:s,dispose:c}=(0,r.useMapObjectEvents)(e=>{t.value=e},d());return(0,n.onBeforeUnmount)(()=>{c()}),{style:(0,n.computed)(()=>(0,r.resolveObjectStyle)(t.value,(0,n.unref)(e))),onMouseenter:i,onMouseleave:a,onMousedown:s,onMouseup:o}}let p=[`d`];var m=(0,n.defineComponent)({__name:`MapFeature`,props:{data:{},styles:{}},setup(e){let t=e,{style:r,...i}=f((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,p))}});let h={name:`features`};var g=(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`,h,[(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)(m,{key:(0,n.unref)(r.getFeatureKey)(t,e.idKey,i),data:t,styles:e.styles},null,8,[`data`,`styles`]))),128))])]))}});let _=[`d`,`fill`],v=[`d`],y=[`d`,`stroke`];var b=(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.useAttrs)(),o=(0,n.computed)(()=>{if(i?.value)return(0,r.renderGraticule)(i.value,t.config)??void 0}),c=(0,n.computed)(()=>{if(i?.value)return(0,r.renderOutline)(i.value)??void 0}),l=(0,n.computed)(()=>(0,r.isString)(t.background)?t.background:void 0),u=(0,n.computed)(()=>(0,r.isString)(t.border)?t.border:void 0),{style:d,...p}=f((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:c.value,fill:l.value,"pointer-events":`none`,name:`background`},null,8,_)):(0,n.createCommentVNode)(`v-if`,!0),(0,n.createElementVNode)(`path`,(0,n.mergeProps)({d:o.value,fill:`none`,style:(0,n.unref)(d)},(0,n.mergeProps)(p,(0,n.unref)(a)),{name:`graticule`}),null,16,v),e.border?((0,n.openBlock)(),(0,n.createElementBlock)(`path`,{key:1,d:c.value,fill:`none`,stroke:u.value,"pointer-events":`none`,name:`border`},null,8,y)):(0,n.createCommentVNode)(`v-if`,!0)]))}});let x=[`transform`];var S=(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}=f((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,x))}});let C=[`d`];var w=(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}=f((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,C))}}),T=(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();(0,n.provide)(u,!0);let d=(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)(d,e=>{c.value&&(0,r.setupZoom)({element:c.value,behavior:e,center:a.center,zoom:a.zoom})},{immediate:!0}),(0,n.watch)(()=>[d.value,a.center[0],a.center[1],a.zoom],()=>{c.value&&(0,r.applyZoomTransform)({element:c.value,behavior:d.value,center:a.center,zoom:a.zoom})})}),t({container:c,zoomBehavior:d}),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`g`,{ref_key:`container`,ref:c,name:`zoom`},[(0,n.renderSlot)(e.$slots,`default`)],512))}}),E=a({Map:()=>l,MapFeature:()=>m,MapFeatures:()=>g,MapGraticule:()=>b,MapMarker:()=>S,MapMesh:()=>w,MapZoom:()=>T});e.Map=l,e.MapFeature=m,e.MapFeatures=g,e.MapGraticule=b,e.MapMarker=S,e.MapMesh=w,e.MapZoom=T,e.mapContextKey=o,e.plugin={install(e){Object.entries(E).forEach(([t,n])=>{e.component(t,n)})}},e.useMapContext=s,e.useMapObject=f})(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, createElementVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onMounted, openBlock, provide, ref, renderList, renderSlot, toRef, unref, useAttrs, watch } from "vue";
3
- import { applyZoomGroupTransform, applyZoomTransform, createZoomBehavior, getFeatureKey, getMarkerTransform, getObjectStateUpdate, isString, makeMapContext, renderGraticule, renderOutline, resolveObjectStyle, setupZoom } from "@d3-maps/core";
2
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, provide, ref, renderList, renderSlot, toRef, unref, useAttrs, watch } from "vue";
3
+ import { applyZoomGroupTransform, applyZoomTransform, createZoomBehavior, getFeatureKey, getMarkerTransform, isString, makeMapContext, renderGraticule, renderOutline, resolveObjectStyle, setupZoom, useMapObjectEvents } from "@d3-maps/core";
4
4
 
5
5
  //#region rolldown:runtime
6
6
  var __defProp = Object.defineProperty;
@@ -61,19 +61,29 @@ var Map_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
61
61
  //#region src/components/Map.vue
62
62
  var Map_default = Map_vue_vue_type_script_setup_true_lang_default;
63
63
 
64
+ //#endregion
65
+ //#region src/hooks/useInsideZoom.ts
66
+ const insideZoomKey = Symbol("InsideZoom");
67
+ function useInsideZoom() {
68
+ return inject(insideZoomKey, false);
69
+ }
70
+
64
71
  //#endregion
65
72
  //#region src/hooks/useMapObject.ts
66
73
  function useMapObject(styles) {
67
74
  const state = ref("default");
68
- const eventCallbackFactory = (eventName) => () => {
69
- state.value = getObjectStateUpdate(eventName);
70
- };
75
+ const { onMouseenter, onMouseleave, onMouseup, onMousedown, dispose } = useMapObjectEvents((nextState) => {
76
+ state.value = nextState;
77
+ }, useInsideZoom());
78
+ onBeforeUnmount(() => {
79
+ dispose();
80
+ });
71
81
  return {
72
82
  style: computed(() => resolveObjectStyle(state.value, unref(styles))),
73
- onMouseenter: eventCallbackFactory("mouseenter"),
74
- onMouseleave: eventCallbackFactory("mouseleave"),
75
- onMousedown: eventCallbackFactory("mousedown"),
76
- onMouseup: eventCallbackFactory("mouseup")
83
+ onMouseenter,
84
+ onMouseleave,
85
+ onMousedown,
86
+ onMouseup
77
87
  };
78
88
  }
79
89
 
@@ -267,6 +277,7 @@ var MapZoom_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
267
277
  const emit = __emit;
268
278
  const container = ref(null);
269
279
  const context = useMapContext();
280
+ provide(insideZoomKey, true);
270
281
  const zoomBehavior = computed(() => {
271
282
  return createZoomBehavior(context?.value, {
272
283
  minZoom: props.minZoom,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d3-maps/vue",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.6.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.5.0"
47
+ "@d3-maps/core": "0.6.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/geojson": "^7946.0.16",