@d3-maps/vue 0.4.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/dist/index.d.ts +43 -52
- package/dist/index.iife.js +1 -1
- package/dist/index.js +103 -95
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import "@d3-maps/core/index.css";
|
|
2
2
|
import * as vue6 from "vue";
|
|
3
3
|
import { App, ComputedRef, InjectionKey, MaybeRef, StyleValue } from "vue";
|
|
4
|
-
import { ExtendedFeature, ExtendedFeatureCollection, GeoPath, GeoProjection } from "d3-geo";
|
|
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
|
|
10
|
-
type MapObjectFocusEventType = 'focus' | 'blur';
|
|
11
|
-
type MapObjectMouseEventType = 'mouseenter' | 'mouseleave' | 'mousedown' | 'mouseup';
|
|
12
|
-
type MapObjectEventType = MapObjectFocusEventType | MapObjectMouseEventType;
|
|
13
|
-
type MapObjectEvent<E> = E extends MapObjectFocusEventType ? FocusEvent : MouseEvent;
|
|
14
10
|
/**
|
|
15
11
|
* Supported interaction states for map objects.
|
|
16
12
|
*/
|
|
@@ -31,8 +27,6 @@ type MapFeature = (ExtendedFeature & Record<string, unknown>) | ExtendedFeature;
|
|
|
31
27
|
interface MapFeatureProps<TStyle = unknown> {
|
|
32
28
|
data: MapFeature;
|
|
33
29
|
styles?: MapObjectStyles$1<TStyle>;
|
|
34
|
-
fill?: string;
|
|
35
|
-
stroke?: string;
|
|
36
30
|
}
|
|
37
31
|
//#endregion
|
|
38
32
|
//#region ../core/src/lib/utils.d.ts
|
|
@@ -104,7 +98,6 @@ type ModifierArgs<P extends unknown[]> = P extends [infer Only] ? Only extends r
|
|
|
104
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[]>> };
|
|
105
99
|
//#endregion
|
|
106
100
|
//#region ../core/src/lib/map.d.ts
|
|
107
|
-
type MapMesh = ReturnType<typeof mesh>;
|
|
108
101
|
type MapData = ExtendedFeatureCollection | Topology;
|
|
109
102
|
type DataTransformer = (features: MapFeature[]) => MapFeature[];
|
|
110
103
|
/**
|
|
@@ -156,12 +149,21 @@ interface MapContext {
|
|
|
156
149
|
height: number;
|
|
157
150
|
projection?: GeoProjection;
|
|
158
151
|
features: MapFeature[];
|
|
159
|
-
mesh?: MapMesh;
|
|
160
152
|
path: GeoPath;
|
|
161
|
-
renderPath: (feature: MapFeature) => ReturnType<GeoPath>;
|
|
162
153
|
renderMesh: () => ReturnType<GeoPath>;
|
|
163
154
|
}
|
|
164
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
|
|
165
167
|
//#region ../core/src/lib/marker.d.ts
|
|
166
168
|
type MapMarkerCoordinates = [number, number];
|
|
167
169
|
/**
|
|
@@ -197,8 +199,8 @@ type __VLS_Slots$3 = {
|
|
|
197
199
|
default?: (props: MapContext) => unknown;
|
|
198
200
|
};
|
|
199
201
|
declare const __VLS_base$3: vue6.DefineComponent<MapConfig, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<MapConfig> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
200
|
-
declare const __VLS_export$
|
|
201
|
-
declare const _default: typeof __VLS_export$
|
|
202
|
+
declare const __VLS_export$6: __VLS_WithSlots$3<typeof __VLS_base$3, __VLS_Slots$3>;
|
|
203
|
+
declare const _default: typeof __VLS_export$6;
|
|
202
204
|
type __VLS_WithSlots$3<T, S> = T & {
|
|
203
205
|
new (): {
|
|
204
206
|
$slots: S;
|
|
@@ -207,32 +209,23 @@ type __VLS_WithSlots$3<T, S> = T & {
|
|
|
207
209
|
//#endregion
|
|
208
210
|
//#region src/components/MapFeature.vue.d.ts
|
|
209
211
|
type __VLS_Props$1 = MapFeatureProps<StyleValue>;
|
|
210
|
-
declare const __VLS_export$
|
|
211
|
-
|
|
212
|
-
}, string, vue6.PublicProps, Readonly<__VLS_Props$1> & Readonly<{
|
|
213
|
-
[x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
|
|
214
|
-
}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
215
|
-
declare const _default$1: typeof __VLS_export$4;
|
|
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;
|
|
216
214
|
//#endregion
|
|
217
215
|
//#region src/hooks/useMapObject.d.ts
|
|
218
216
|
type MapObjectStyles = MapObjectStyles$1<StyleValue>;
|
|
219
|
-
type MapObjectEmit = <E extends MapObjectEventType>(event: E, payload: MapObjectEvent<E>) => void;
|
|
220
217
|
interface UseMapObjectResult {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
onFocus: (event: FocusEvent) => void;
|
|
227
|
-
onBlur: (event: FocusEvent) => void;
|
|
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;
|
|
228
223
|
}
|
|
229
|
-
declare function useMapObject(
|
|
224
|
+
declare function useMapObject(styles: MaybeRef<MapObjectStyles | undefined>): UseMapObjectResult;
|
|
230
225
|
//#endregion
|
|
231
226
|
//#region src/components/MapFeatures.vue.d.ts
|
|
232
|
-
interface Props$
|
|
227
|
+
interface Props$2 {
|
|
233
228
|
idKey?: string;
|
|
234
|
-
fill?: string;
|
|
235
|
-
stroke?: string;
|
|
236
229
|
styles?: MapObjectStyles;
|
|
237
230
|
}
|
|
238
231
|
declare var __VLS_1$2: {
|
|
@@ -241,32 +234,38 @@ declare var __VLS_1$2: {
|
|
|
241
234
|
type __VLS_Slots$2 = {} & {
|
|
242
235
|
default?: (props: typeof __VLS_1$2) => any;
|
|
243
236
|
};
|
|
244
|
-
declare const __VLS_base$2: vue6.DefineComponent<Props$
|
|
237
|
+
declare const __VLS_base$2: vue6.DefineComponent<Props$2, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props$2> & Readonly<{}>, {
|
|
245
238
|
idKey: string;
|
|
246
239
|
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
247
|
-
declare const __VLS_export$
|
|
248
|
-
declare const _default$2: typeof __VLS_export$
|
|
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;
|
|
249
242
|
type __VLS_WithSlots$2<T, S> = T & {
|
|
250
243
|
new (): {
|
|
251
244
|
$slots: S;
|
|
252
245
|
};
|
|
253
246
|
};
|
|
254
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
|
|
255
258
|
//#region src/components/MapMarker.vue.d.ts
|
|
256
259
|
type __VLS_Props = MapMarkerProps<StyleValue>;
|
|
257
260
|
declare var __VLS_1$1: {};
|
|
258
261
|
type __VLS_Slots$1 = {} & {
|
|
259
262
|
default?: (props: typeof __VLS_1$1) => any;
|
|
260
263
|
};
|
|
261
|
-
declare const __VLS_base$1: vue6.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {} & {
|
|
262
|
-
[x: string]: any;
|
|
263
|
-
}, string, vue6.PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
264
|
-
[x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
|
|
265
|
-
}>, {
|
|
264
|
+
declare const __VLS_base$1: vue6.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
266
265
|
coordinates: MapMarkerCoordinates;
|
|
267
266
|
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
268
267
|
declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
|
|
269
|
-
declare const _default$
|
|
268
|
+
declare const _default$4: typeof __VLS_export$2;
|
|
270
269
|
type __VLS_WithSlots$1<T, S> = T & {
|
|
271
270
|
new (): {
|
|
272
271
|
$slots: S;
|
|
@@ -275,18 +274,10 @@ type __VLS_WithSlots$1<T, S> = T & {
|
|
|
275
274
|
//#endregion
|
|
276
275
|
//#region src/components/MapMesh.vue.d.ts
|
|
277
276
|
interface Props {
|
|
278
|
-
fill?: string;
|
|
279
|
-
stroke?: string;
|
|
280
277
|
styles?: MapObjectStyles;
|
|
281
278
|
}
|
|
282
|
-
declare const __VLS_export$1: vue6.DefineComponent<Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {} & {
|
|
283
|
-
|
|
284
|
-
}, string, vue6.PublicProps, Readonly<Props> & Readonly<{
|
|
285
|
-
[x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
|
|
286
|
-
}>, {
|
|
287
|
-
fill: string;
|
|
288
|
-
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
289
|
-
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;
|
|
290
281
|
//#endregion
|
|
291
282
|
//#region src/components/MapZoom.vue.d.ts
|
|
292
283
|
declare var __VLS_1: {};
|
|
@@ -311,7 +302,7 @@ declare const __VLS_base: vue6.DefineComponent<ZoomProps, {
|
|
|
311
302
|
maxZoom: number;
|
|
312
303
|
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
313
304
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
314
|
-
declare const _default$
|
|
305
|
+
declare const _default$6: typeof __VLS_export;
|
|
315
306
|
type __VLS_WithSlots<T, S> = T & {
|
|
316
307
|
new (): {
|
|
317
308
|
$slots: S;
|
|
@@ -330,4 +321,4 @@ declare const plugin: {
|
|
|
330
321
|
install(app: App): void;
|
|
331
322
|
};
|
|
332
323
|
//#endregion
|
|
333
|
-
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`);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
|
|
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 { applyZoomGroupTransform, 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;
|
|
@@ -27,7 +27,7 @@ function useMapContext() {
|
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/components/Map.vue?vue&type=script&setup=true&lang.ts
|
|
30
|
-
const _hoisted_1$
|
|
30
|
+
const _hoisted_1$5 = ["viewBox"];
|
|
31
31
|
var Map_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
32
32
|
__name: "Map",
|
|
33
33
|
props: {
|
|
@@ -52,7 +52,7 @@ var Map_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
52
52
|
}));
|
|
53
53
|
provide(mapContextKey, context);
|
|
54
54
|
return (_ctx, _cache) => {
|
|
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$
|
|
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);
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
});
|
|
@@ -63,60 +63,39 @@ var Map_default = Map_vue_vue_type_script_setup_true_lang_default;
|
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/hooks/useMapObject.ts
|
|
66
|
-
function useMapObject(
|
|
66
|
+
function useMapObject(styles) {
|
|
67
67
|
const state = ref("default");
|
|
68
|
-
const eventCallbackFactory = (eventName) => (
|
|
68
|
+
const eventCallbackFactory = (eventName) => () => {
|
|
69
69
|
state.value = getObjectStateUpdate(eventName);
|
|
70
|
-
emit(eventName, event);
|
|
71
70
|
};
|
|
72
71
|
return {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
onFocus: eventCallbackFactory("focus"),
|
|
79
|
-
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")
|
|
80
77
|
};
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
//#endregion
|
|
84
81
|
//#region src/components/MapFeature.vue?vue&type=script&setup=true&lang.ts
|
|
85
|
-
const _hoisted_1$
|
|
86
|
-
"d",
|
|
87
|
-
"fill",
|
|
88
|
-
"stroke"
|
|
89
|
-
];
|
|
82
|
+
const _hoisted_1$4 = ["d"];
|
|
90
83
|
var MapFeature_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
91
84
|
__name: "MapFeature",
|
|
92
85
|
props: {
|
|
93
86
|
data: {},
|
|
94
|
-
styles: {}
|
|
95
|
-
fill: {},
|
|
96
|
-
stroke: {}
|
|
87
|
+
styles: {}
|
|
97
88
|
},
|
|
98
|
-
setup(__props
|
|
89
|
+
setup(__props) {
|
|
99
90
|
const props = __props;
|
|
100
|
-
const
|
|
91
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
101
92
|
const context = useMapContext();
|
|
102
|
-
const path = computed(() => context?.value.
|
|
103
|
-
const { computedStyle, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onFocus, onBlur } = useMapObject(emit, toRef(props, "styles"));
|
|
93
|
+
const path = computed(() => context?.value.path(props.data) ?? void 0);
|
|
104
94
|
return (_ctx, _cache) => {
|
|
105
|
-
return
|
|
106
|
-
key: 0,
|
|
95
|
+
return openBlock(), createElementBlock("path", mergeProps({
|
|
107
96
|
d: path.value,
|
|
108
|
-
style: unref(
|
|
109
|
-
|
|
110
|
-
stroke: __props.stroke
|
|
111
|
-
}, _ctx.$attrs, {
|
|
112
|
-
onMouseenter: _cache[0] || (_cache[0] = (...args) => unref(onMouseEnter) && unref(onMouseEnter)(...args)),
|
|
113
|
-
onMouseleave: _cache[1] || (_cache[1] = (...args) => unref(onMouseLeave) && unref(onMouseLeave)(...args)),
|
|
114
|
-
onMousedown: _cache[2] || (_cache[2] = (...args) => unref(onMouseDown) && unref(onMouseDown)(...args)),
|
|
115
|
-
onMouseup: _cache[3] || (_cache[3] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
116
|
-
onClick: _cache[4] || (_cache[4] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
117
|
-
onFocus: _cache[5] || (_cache[5] = (...args) => unref(onFocus) && unref(onFocus)(...args)),
|
|
118
|
-
onBlur: _cache[6] || (_cache[6] = (...args) => unref(onBlur) && unref(onBlur)(...args))
|
|
119
|
-
}), null, 16, _hoisted_1$2)) : createCommentVNode("v-if", true);
|
|
97
|
+
style: unref(style)
|
|
98
|
+
}, events, { name: "feature" }), null, 16, _hoisted_1$4);
|
|
120
99
|
};
|
|
121
100
|
}
|
|
122
101
|
});
|
|
@@ -127,31 +106,23 @@ var MapFeature_default = MapFeature_vue_vue_type_script_setup_true_lang_default;
|
|
|
127
106
|
|
|
128
107
|
//#endregion
|
|
129
108
|
//#region src/components/MapFeatures.vue?vue&type=script&setup=true&lang.ts
|
|
109
|
+
const _hoisted_1$3 = { name: "features" };
|
|
130
110
|
var MapFeatures_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
131
111
|
__name: "MapFeatures",
|
|
132
112
|
props: {
|
|
133
113
|
idKey: { default: "id" },
|
|
134
|
-
fill: {},
|
|
135
|
-
stroke: {},
|
|
136
114
|
styles: {}
|
|
137
115
|
},
|
|
138
116
|
setup(__props) {
|
|
139
117
|
const context = useMapContext();
|
|
140
118
|
const features = computed(() => context?.value.features ?? []);
|
|
141
119
|
return (_ctx, _cache) => {
|
|
142
|
-
return openBlock(), createElementBlock("g",
|
|
143
|
-
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, {
|
|
144
122
|
key: unref(getFeatureKey)(feature, __props.idKey, index),
|
|
145
123
|
data: feature,
|
|
146
|
-
fill: __props.fill,
|
|
147
|
-
stroke: __props.stroke,
|
|
148
124
|
styles: __props.styles
|
|
149
|
-
},
|
|
150
|
-
"data",
|
|
151
|
-
"fill",
|
|
152
|
-
"stroke",
|
|
153
|
-
"styles"
|
|
154
|
-
]);
|
|
125
|
+
}, null, 8, ["data", "styles"]);
|
|
155
126
|
}), 128))])]);
|
|
156
127
|
};
|
|
157
128
|
}
|
|
@@ -161,6 +132,69 @@ var MapFeatures_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
161
132
|
//#region src/components/MapFeatures.vue
|
|
162
133
|
var MapFeatures_default = MapFeatures_vue_vue_type_script_setup_true_lang_default;
|
|
163
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
|
+
|
|
164
198
|
//#endregion
|
|
165
199
|
//#region src/components/MapMarker.vue?vue&type=script&setup=true&lang.ts
|
|
166
200
|
const _hoisted_1$1 = ["transform"];
|
|
@@ -170,26 +204,18 @@ var MapMarker_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
170
204
|
coordinates: { default: () => [0, 0] },
|
|
171
205
|
styles: {}
|
|
172
206
|
},
|
|
173
|
-
setup(__props
|
|
207
|
+
setup(__props) {
|
|
174
208
|
const props = __props;
|
|
175
|
-
const emit = __emit;
|
|
176
209
|
const context = useMapContext();
|
|
177
210
|
const transform = computed(() => {
|
|
178
211
|
return getMarkerTransform(context?.value, props.coordinates);
|
|
179
212
|
});
|
|
180
|
-
const {
|
|
213
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
181
214
|
return (_ctx, _cache) => {
|
|
182
|
-
return openBlock(), createElementBlock("g", {
|
|
215
|
+
return openBlock(), createElementBlock("g", mergeProps({
|
|
183
216
|
transform: transform.value,
|
|
184
|
-
style:
|
|
185
|
-
|
|
186
|
-
onMouseleave: _cache[1] || (_cache[1] = (...args) => unref(onMouseLeave) && unref(onMouseLeave)(...args)),
|
|
187
|
-
onMousedown: _cache[2] || (_cache[2] = (...args) => unref(onMouseDown) && unref(onMouseDown)(...args)),
|
|
188
|
-
onMouseup: _cache[3] || (_cache[3] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
189
|
-
onClick: _cache[4] || (_cache[4] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
190
|
-
onFocus: _cache[5] || (_cache[5] = (...args) => unref(onFocus) && unref(onFocus)(...args)),
|
|
191
|
-
onBlur: _cache[6] || (_cache[6] = (...args) => unref(onBlur) && unref(onBlur)(...args))
|
|
192
|
-
}, [renderSlot(_ctx.$slots, "default")], 44, _hoisted_1$1);
|
|
217
|
+
style: unref(style)
|
|
218
|
+
}, events, { name: "marker" }), [renderSlot(_ctx.$slots, "default")], 16, _hoisted_1$1);
|
|
193
219
|
};
|
|
194
220
|
}
|
|
195
221
|
});
|
|
@@ -200,40 +226,21 @@ var MapMarker_default = MapMarker_vue_vue_type_script_setup_true_lang_default;
|
|
|
200
226
|
|
|
201
227
|
//#endregion
|
|
202
228
|
//#region src/components/MapMesh.vue?vue&type=script&setup=true&lang.ts
|
|
203
|
-
const _hoisted_1 = [
|
|
204
|
-
"d",
|
|
205
|
-
"fill",
|
|
206
|
-
"stroke"
|
|
207
|
-
];
|
|
229
|
+
const _hoisted_1 = ["d"];
|
|
208
230
|
var MapMesh_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
209
231
|
__name: "MapMesh",
|
|
210
|
-
props: {
|
|
211
|
-
|
|
212
|
-
stroke: {},
|
|
213
|
-
styles: {}
|
|
214
|
-
},
|
|
215
|
-
setup(__props, { emit: __emit }) {
|
|
232
|
+
props: { styles: {} },
|
|
233
|
+
setup(__props) {
|
|
216
234
|
const props = __props;
|
|
217
|
-
const emit = __emit;
|
|
218
235
|
const context = useMapContext();
|
|
219
|
-
const path = computed(() => context?.value.renderMesh());
|
|
220
|
-
const {
|
|
236
|
+
const path = computed(() => context?.value.renderMesh() ?? void 0);
|
|
237
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
221
238
|
return (_ctx, _cache) => {
|
|
222
|
-
return
|
|
223
|
-
key: 0,
|
|
239
|
+
return openBlock(), createElementBlock("path", mergeProps({
|
|
224
240
|
d: path.value,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}, _ctx.$attrs, {
|
|
229
|
-
onMouseenter: _cache[0] || (_cache[0] = (...args) => unref(onMouseEnter) && unref(onMouseEnter)(...args)),
|
|
230
|
-
onMouseleave: _cache[1] || (_cache[1] = (...args) => unref(onMouseLeave) && unref(onMouseLeave)(...args)),
|
|
231
|
-
onMousedown: _cache[2] || (_cache[2] = (...args) => unref(onMouseDown) && unref(onMouseDown)(...args)),
|
|
232
|
-
onMouseup: _cache[3] || (_cache[3] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
233
|
-
onClick: _cache[4] || (_cache[4] = (...args) => unref(onMouseUp) && unref(onMouseUp)(...args)),
|
|
234
|
-
onFocus: _cache[5] || (_cache[5] = (...args) => unref(onFocus) && unref(onFocus)(...args)),
|
|
235
|
-
onBlur: _cache[6] || (_cache[6] = (...args) => unref(onBlur) && unref(onBlur)(...args))
|
|
236
|
-
}), null, 16, _hoisted_1)) : createCommentVNode("v-if", true);
|
|
241
|
+
fill: "none",
|
|
242
|
+
style: unref(style)
|
|
243
|
+
}, events, { name: "mesh" }), null, 16, _hoisted_1);
|
|
237
244
|
};
|
|
238
245
|
}
|
|
239
246
|
});
|
|
@@ -309,7 +316,7 @@ var MapZoom_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
309
316
|
return openBlock(), createElementBlock("g", {
|
|
310
317
|
ref_key: "container",
|
|
311
318
|
ref: container,
|
|
312
|
-
|
|
319
|
+
name: "zoom"
|
|
313
320
|
}, [renderSlot(_ctx.$slots, "default")], 512);
|
|
314
321
|
};
|
|
315
322
|
}
|
|
@@ -325,6 +332,7 @@ var components_exports = /* @__PURE__ */ __exportAll({
|
|
|
325
332
|
Map: () => Map_default,
|
|
326
333
|
MapFeature: () => MapFeature_default,
|
|
327
334
|
MapFeatures: () => MapFeatures_default,
|
|
335
|
+
MapGraticule: () => MapGraticule_default,
|
|
328
336
|
MapMarker: () => MapMarker_default,
|
|
329
337
|
MapMesh: () => MapMesh_default,
|
|
330
338
|
MapZoom: () => MapZoom_default
|
|
@@ -342,4 +350,4 @@ const plugin = { install(app) {
|
|
|
342
350
|
} };
|
|
343
351
|
|
|
344
352
|
//#endregion
|
|
345
|
-
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, mapContextKey, plugin, useMapContext, useMapObject };
|
|
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",
|