@d3-maps/vue 0.7.0 → 0.8.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 +87 -21
- package/dist/index.iife.js +1 -1
- package/dist/index.js +178 -66
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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 { CurveFactory, CurveFactoryLineOnly } from "d3-shape";
|
|
4
5
|
import { ExtendedFeature, ExtendedFeatureCollection, GeoGraticuleGenerator, GeoPath, GeoProjection } from "d3-geo";
|
|
5
6
|
import { Topology } from "topojson-specification";
|
|
6
7
|
import "topojson-client";
|
|
@@ -154,12 +155,46 @@ interface MapProps {
|
|
|
154
155
|
interface MapContext {
|
|
155
156
|
width: number;
|
|
156
157
|
height: number;
|
|
157
|
-
projection
|
|
158
|
+
projection: GeoProjection;
|
|
158
159
|
features: MapFeature[];
|
|
159
160
|
path: GeoPath;
|
|
160
161
|
renderMesh: () => ReturnType<GeoPath>;
|
|
161
162
|
}
|
|
162
163
|
//#endregion
|
|
164
|
+
//#region ../core/src/lib/line.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* Geographic or cartesian line coordinates expressed as ordered `[x, y]` pairs
|
|
167
|
+
*/
|
|
168
|
+
type MapLineCoordinates = [number, number][];
|
|
169
|
+
/**
|
|
170
|
+
* D3 curve factory used by custom and cartesian line rendering
|
|
171
|
+
*/
|
|
172
|
+
type MapLineCurve = CurveFactory | CurveFactoryLineOnly;
|
|
173
|
+
/**
|
|
174
|
+
* Midpoint adjustment expressed as percentages of the segment length
|
|
175
|
+
*
|
|
176
|
+
* - first value: moves the generated midpoint along the segment direction
|
|
177
|
+
* - second value: moves the generated midpoint perpendicular to the segment direction
|
|
178
|
+
*/
|
|
179
|
+
type MapLineMidpoint = [number, number];
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region ../core/src/lib/annotation.d.ts
|
|
182
|
+
/**
|
|
183
|
+
* Geographic anchor coordinate for an annotation
|
|
184
|
+
*/
|
|
185
|
+
type MapAnnotationCoordinates = [number, number];
|
|
186
|
+
/**
|
|
187
|
+
* Public annotation props shared across adapters
|
|
188
|
+
*/
|
|
189
|
+
interface MapAnnotationProps<TStyle = unknown> extends MapObjectProps<TStyle> {
|
|
190
|
+
coordinates: MapAnnotationCoordinates;
|
|
191
|
+
length?: number;
|
|
192
|
+
angle?: number;
|
|
193
|
+
margin?: number;
|
|
194
|
+
curve?: MapLineCurve;
|
|
195
|
+
midpoint?: MapLineMidpoint;
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
163
198
|
//#region ../core/src/lib/graticule.d.ts
|
|
164
199
|
/**
|
|
165
200
|
* Extra graticule generator method calls to apply before rendering.
|
|
@@ -185,7 +220,7 @@ type MapMarkerCoordinates = [number, number];
|
|
|
185
220
|
* Shared props contract for marker layers.
|
|
186
221
|
*/
|
|
187
222
|
interface MapMarkerProps<TStyle = unknown> extends MapObjectProps<TStyle> {
|
|
188
|
-
coordinates
|
|
223
|
+
coordinates: MapMarkerCoordinates;
|
|
189
224
|
}
|
|
190
225
|
//#endregion
|
|
191
226
|
//#region ../core/src/lib/zoom.d.ts
|
|
@@ -208,13 +243,28 @@ interface ZoomProps {
|
|
|
208
243
|
}
|
|
209
244
|
interface ZoomEvent extends D3ZoomEvent<SVGSVGElement, unknown> {}
|
|
210
245
|
//#endregion
|
|
246
|
+
//#region src/components/MapAnnotation.vue.d.ts
|
|
247
|
+
type __VLS_Props$4 = MapAnnotationProps<StyleValue>;
|
|
248
|
+
declare var __VLS_13: {};
|
|
249
|
+
type __VLS_Slots$4 = {} & {
|
|
250
|
+
default?: (props: typeof __VLS_13) => any;
|
|
251
|
+
};
|
|
252
|
+
declare const __VLS_base$4: vue6.DefineComponent<__VLS_Props$4, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props$4> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
253
|
+
declare const __VLS_export$8: __VLS_WithSlots$4<typeof __VLS_base$4, __VLS_Slots$4>;
|
|
254
|
+
declare const _default: typeof __VLS_export$8;
|
|
255
|
+
type __VLS_WithSlots$4<T, S> = T & {
|
|
256
|
+
new (): {
|
|
257
|
+
$slots: S;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
//#endregion
|
|
211
261
|
//#region src/components/MapBase.vue.d.ts
|
|
212
262
|
type __VLS_Slots$3 = {
|
|
213
263
|
default?: (props: MapContext) => unknown;
|
|
214
264
|
};
|
|
215
265
|
declare const __VLS_base$3: vue6.DefineComponent<MapProps, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<MapProps> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
216
|
-
declare const __VLS_export$
|
|
217
|
-
declare const _default: typeof __VLS_export$
|
|
266
|
+
declare const __VLS_export$7: __VLS_WithSlots$3<typeof __VLS_base$3, __VLS_Slots$3>;
|
|
267
|
+
declare const _default$1: typeof __VLS_export$7;
|
|
218
268
|
type __VLS_WithSlots$3<T, S> = T & {
|
|
219
269
|
new (): {
|
|
220
270
|
$slots: S;
|
|
@@ -222,23 +272,23 @@ type __VLS_WithSlots$3<T, S> = T & {
|
|
|
222
272
|
};
|
|
223
273
|
//#endregion
|
|
224
274
|
//#region src/components/MapFeature.vue.d.ts
|
|
225
|
-
type __VLS_Props$
|
|
226
|
-
declare const __VLS_export$
|
|
227
|
-
declare const _default$
|
|
275
|
+
type __VLS_Props$3 = MapFeatureProps<StyleValue>;
|
|
276
|
+
declare const __VLS_export$6: vue6.DefineComponent<__VLS_Props$3, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props$3> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
277
|
+
declare const _default$2: typeof __VLS_export$6;
|
|
228
278
|
//#endregion
|
|
229
279
|
//#region src/components/MapFeatures.vue.d.ts
|
|
230
|
-
type __VLS_Props$
|
|
280
|
+
type __VLS_Props$2 = MapFeaturesProps<StyleValue>;
|
|
231
281
|
declare var __VLS_1$2: {
|
|
232
282
|
features: MapFeature[];
|
|
233
283
|
};
|
|
234
284
|
type __VLS_Slots$2 = {} & {
|
|
235
285
|
default?: (props: typeof __VLS_1$2) => any;
|
|
236
286
|
};
|
|
237
|
-
declare const __VLS_base$2: vue6.DefineComponent<__VLS_Props$
|
|
287
|
+
declare const __VLS_base$2: vue6.DefineComponent<__VLS_Props$2, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props$2> & Readonly<{}>, {
|
|
238
288
|
idKey: string;
|
|
239
289
|
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
240
|
-
declare const __VLS_export$
|
|
241
|
-
declare const _default$
|
|
290
|
+
declare const __VLS_export$5: __VLS_WithSlots$2<typeof __VLS_base$2, __VLS_Slots$2>;
|
|
291
|
+
declare const _default$3: typeof __VLS_export$5;
|
|
242
292
|
type __VLS_WithSlots$2<T, S> = T & {
|
|
243
293
|
new (): {
|
|
244
294
|
$slots: S;
|
|
@@ -246,21 +296,37 @@ type __VLS_WithSlots$2<T, S> = T & {
|
|
|
246
296
|
};
|
|
247
297
|
//#endregion
|
|
248
298
|
//#region src/components/MapGraticule.vue.d.ts
|
|
249
|
-
type __VLS_Props$
|
|
250
|
-
declare const __VLS_export$
|
|
251
|
-
declare const _default$
|
|
299
|
+
type __VLS_Props$1 = MapGraticuleProps<StyleValue>;
|
|
300
|
+
declare const __VLS_export$4: vue6.DefineComponent<__VLS_Props$1, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props$1> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
301
|
+
declare const _default$4: typeof __VLS_export$4;
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/components/MapLine.vue.d.ts
|
|
304
|
+
interface Props$1 extends MapObjectProps<StyleValue> {
|
|
305
|
+
coordinates: MapLineCoordinates;
|
|
306
|
+
cartesian?: boolean;
|
|
307
|
+
custom?: boolean;
|
|
308
|
+
curve?: MapLineCurve;
|
|
309
|
+
midpoint?: [number, number];
|
|
310
|
+
}
|
|
311
|
+
declare const __VLS_export$3: vue6.DefineComponent<Props$1, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props$1> & Readonly<{}>, {
|
|
312
|
+
cartesian: boolean;
|
|
313
|
+
custom: boolean;
|
|
314
|
+
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
315
|
+
declare const _default$5: typeof __VLS_export$3;
|
|
252
316
|
//#endregion
|
|
253
317
|
//#region src/components/MapMarker.vue.d.ts
|
|
254
|
-
|
|
318
|
+
interface Props extends MapMarkerProps<StyleValue> {
|
|
319
|
+
name?: string;
|
|
320
|
+
}
|
|
255
321
|
declare var __VLS_1$1: {};
|
|
256
322
|
type __VLS_Slots$1 = {} & {
|
|
257
323
|
default?: (props: typeof __VLS_1$1) => any;
|
|
258
324
|
};
|
|
259
|
-
declare const __VLS_base$1: vue6.DefineComponent<
|
|
260
|
-
|
|
325
|
+
declare const __VLS_base$1: vue6.DefineComponent<Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
326
|
+
name: string;
|
|
261
327
|
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
262
328
|
declare const __VLS_export$2: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
|
|
263
|
-
declare const _default$
|
|
329
|
+
declare const _default$6: typeof __VLS_export$2;
|
|
264
330
|
type __VLS_WithSlots$1<T, S> = T & {
|
|
265
331
|
new (): {
|
|
266
332
|
$slots: S;
|
|
@@ -270,7 +336,7 @@ type __VLS_WithSlots$1<T, S> = T & {
|
|
|
270
336
|
//#region src/components/MapMesh.vue.d.ts
|
|
271
337
|
type __VLS_Props = MapObjectProps<StyleValue>;
|
|
272
338
|
declare const __VLS_export$1: vue6.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
273
|
-
declare const _default$
|
|
339
|
+
declare const _default$7: typeof __VLS_export$1;
|
|
274
340
|
//#endregion
|
|
275
341
|
//#region src/components/MapZoom.vue.d.ts
|
|
276
342
|
declare var __VLS_1: {};
|
|
@@ -295,7 +361,7 @@ declare const __VLS_base: vue6.DefineComponent<ZoomProps, {
|
|
|
295
361
|
maxZoom: number;
|
|
296
362
|
}, {}, {}, {}, string, vue6.ComponentProvideOptions, false, {}, any>;
|
|
297
363
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
298
|
-
declare const _default$
|
|
364
|
+
declare const _default$8: typeof __VLS_export;
|
|
299
365
|
type __VLS_WithSlots<T, S> = T & {
|
|
300
366
|
new (): {
|
|
301
367
|
$slots: S;
|
|
@@ -324,4 +390,4 @@ declare const plugin: {
|
|
|
324
390
|
install(app: App): void;
|
|
325
391
|
};
|
|
326
392
|
//#endregion
|
|
327
|
-
export { _default as
|
|
393
|
+
export { _default as MapAnnotation, _default$1 as MapBase, _default$2 as MapFeature, _default$3 as MapFeatures, _default$4 as MapGraticule, _default$5 as MapLine, _default$6 as MapMarker, _default$7 as MapMesh, _default$8 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=[`
|
|
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=Symbol(`InsideZoom`);function l(){return(0,n.inject)(c,!1)}function u(e){let t=(0,n.ref)(`default`),{onMouseenter:i,onMouseleave:a,onMouseup:o,onMousedown:s,dispose:c}=(0,r.useMapObjectEvents)(e=>{t.value=e},l());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 d=[`d`];var f=(0,n.defineComponent)({inheritAttrs:!1,__name:`MapLine`,props:{coordinates:{},cartesian:{type:Boolean,default:!1},custom:{type:Boolean,default:!1},curve:{},midpoint:{},styles:{}},setup(e){let t=e,i=(0,n.useAttrs)(),a=s(),o=(0,n.computed)(()=>(0,r.getLinePath)(a?.value,{coordinates:t.coordinates,custom:t.custom,curve:t.curve,cartesian:t.cartesian,midpoint:t.midpoint})),c=(0,n.computed)(()=>i.name??`line`),{style:l,...f}=u((0,n.toRef)(t,`styles`)),p=(0,n.computed)(()=>({...i,...f,name:c.value}));return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`path`,(0,n.mergeProps)(p.value,{d:o.value,fill:`none`,style:(0,n.unref)(l)}),null,16,d))}});let p=[`transform`,`name`];var m=(0,n.defineComponent)({__name:`MapMarker`,props:{name:{default:`marker`},coordinates:{},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(t,r)=>a.value?((0,n.openBlock)(),(0,n.createElementBlock)(`g`,(0,n.mergeProps)({key:0,transform:a.value,style:(0,n.unref)(o),name:e.name},c),[(0,n.renderSlot)(t.$slots,`default`)],16,p)):(0,n.createCommentVNode)(`v-if`,!0)}});let h=[`transform`],g=[`transform`];var _=(0,n.defineComponent)({inheritAttrs:!1,__name:`MapAnnotation`,props:{coordinates:{},length:{},angle:{},margin:{},curve:{type:Function},midpoint:{},styles:{}},setup(e){let t=e,i=(0,n.computed)(()=>(0,r.getAnnotationGeometry)({length:t.length,angle:t.angle,margin:t.margin}));return(t,r)=>((0,n.openBlock)(),(0,n.createBlock)(m,{coordinates:e.coordinates,name:`annotation`},{default:(0,n.withCtx)(()=>[(0,n.createElementVNode)(`g`,{transform:i.value.lineTransform},[(0,n.createVNode)(f,(0,n.mergeProps)(t.$attrs,{coordinates:i.value.lineCoordinates,cartesian:``,curve:e.curve,midpoint:e.midpoint,styles:e.styles,fill:`none`,name:`annotation-line`}),null,16,[`coordinates`,`curve`,`midpoint`,`styles`])],8,h),(0,n.createElementVNode)(`g`,{transform:i.value.contentTransform,name:`annotation-content`},[(0,n.renderSlot)(t.$slots,`default`)],8,g)]),_:3},8,[`coordinates`]))}});let v=[`viewBox`];var y=(0,n.defineComponent)({__name:`MapBase`,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,v))}});let b=[`d`];var x=(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,b))}});let S={name:`features`};var C=(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`,S,[(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)(x,{key:(0,n.unref)(r.getFeatureKey)(t,e.idKey,i),data:t,styles:e.styles},null,8,[`data`,`styles`]))),128))])]))}});let w=[`d`,`fill`],T=[`d`],E=[`d`,`stroke`];var D=(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,w)):(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,T),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,E)):(0,n.createCommentVNode)(`v-if`,!0)]))}});let O=[`d`];var k=(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,O))}}),A=(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,l=(0,n.ref)(null),u=s();(0,n.provide)(c,!0);let d=(0,n.computed)(()=>(0,r.createZoomBehavior)(u?.value,{minZoom:a.minZoom,maxZoom:a.maxZoom,config:a.config,onZoomStart:e=>o(`zoomstart`,e),onZoom:e=>{(0,r.applyZoomGroupTransform)(l.value,e.transform),o(`zoom`,e)},onZoomEnd:e=>o(`zoomend`,e)}));return(0,n.onMounted)(()=>{(0,n.watch)(d,e=>{l.value&&(0,r.setupZoom)({element:l.value,behavior:e,center:a.center,zoom:a.zoom})},{immediate:!0}),(0,n.watch)(()=>[d.value,a.center[0],a.center[1],a.zoom],()=>{l.value&&(0,r.applyZoomTransform)({element:l.value,behavior:d.value,center:a.center,zoom:a.zoom})})}),t({container:l,zoomBehavior:d}),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`g`,{ref_key:`container`,ref:l,name:`zoom`},[(0,n.renderSlot)(e.$slots,`default`)],512))}}),j=a({MapAnnotation:()=>_,MapBase:()=>y,MapFeature:()=>x,MapFeatures:()=>C,MapGraticule:()=>D,MapLine:()=>f,MapMarker:()=>m,MapMesh:()=>k,MapZoom:()=>A});e.MapAnnotation=_,e.MapBase=y,e.MapFeature=x,e.MapFeatures=C,e.MapGraticule=D,e.MapLine=f,e.MapMarker=m,e.MapMesh=k,e.MapZoom=A,e.mapContextKey=o,e.plugin={install(e){Object.entries(j).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, 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";
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onBeforeUnmount, onMounted, openBlock, provide, ref, renderList, renderSlot, toRef, unref, useAttrs, watch, withCtx } from "vue";
|
|
3
|
+
import { applyZoomGroupTransform, applyZoomTransform, createZoomBehavior, getAnnotationGeometry, getFeatureKey, getLinePath, 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;
|
|
@@ -25,9 +25,174 @@ function useMapContext() {
|
|
|
25
25
|
return inject(mapContextKey);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/hooks/useInsideZoom.ts
|
|
30
|
+
const insideZoomKey = Symbol("InsideZoom");
|
|
31
|
+
function useInsideZoom() {
|
|
32
|
+
return inject(insideZoomKey, false);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/hooks/useMapObject.ts
|
|
37
|
+
function useMapObject(styles) {
|
|
38
|
+
const state = ref("default");
|
|
39
|
+
const { onMouseenter, onMouseleave, onMouseup, onMousedown, dispose } = useMapObjectEvents((nextState) => {
|
|
40
|
+
state.value = nextState;
|
|
41
|
+
}, useInsideZoom());
|
|
42
|
+
onBeforeUnmount(() => {
|
|
43
|
+
dispose();
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
style: computed(() => resolveObjectStyle(state.value, unref(styles))),
|
|
47
|
+
onMouseenter,
|
|
48
|
+
onMouseleave,
|
|
49
|
+
onMousedown,
|
|
50
|
+
onMouseup
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/components/MapLine.vue?vue&type=script&setup=true&lang.ts
|
|
56
|
+
const _hoisted_1$7 = ["d"];
|
|
57
|
+
var MapLine_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
58
|
+
inheritAttrs: false,
|
|
59
|
+
__name: "MapLine",
|
|
60
|
+
props: {
|
|
61
|
+
coordinates: {},
|
|
62
|
+
cartesian: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false
|
|
65
|
+
},
|
|
66
|
+
custom: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false
|
|
69
|
+
},
|
|
70
|
+
curve: {},
|
|
71
|
+
midpoint: {},
|
|
72
|
+
styles: {}
|
|
73
|
+
},
|
|
74
|
+
setup(__props) {
|
|
75
|
+
const props = __props;
|
|
76
|
+
const attrs = useAttrs();
|
|
77
|
+
const context = useMapContext();
|
|
78
|
+
const path = computed(() => {
|
|
79
|
+
return getLinePath(context?.value, {
|
|
80
|
+
coordinates: props.coordinates,
|
|
81
|
+
custom: props.custom,
|
|
82
|
+
curve: props.curve,
|
|
83
|
+
cartesian: props.cartesian,
|
|
84
|
+
midpoint: props.midpoint
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
const pathName = computed(() => attrs.name ?? "line");
|
|
88
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
89
|
+
const pathAttrs = computed(() => ({
|
|
90
|
+
...attrs,
|
|
91
|
+
...events,
|
|
92
|
+
name: pathName.value
|
|
93
|
+
}));
|
|
94
|
+
return (_ctx, _cache) => {
|
|
95
|
+
return openBlock(), createElementBlock("path", mergeProps(pathAttrs.value, {
|
|
96
|
+
d: path.value,
|
|
97
|
+
fill: "none",
|
|
98
|
+
style: unref(style)
|
|
99
|
+
}), null, 16, _hoisted_1$7);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/components/MapLine.vue
|
|
106
|
+
var MapLine_default = MapLine_vue_vue_type_script_setup_true_lang_default;
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/components/MapMarker.vue?vue&type=script&setup=true&lang.ts
|
|
110
|
+
const _hoisted_1$6 = ["transform", "name"];
|
|
111
|
+
var MapMarker_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
112
|
+
__name: "MapMarker",
|
|
113
|
+
props: {
|
|
114
|
+
name: { default: "marker" },
|
|
115
|
+
coordinates: {},
|
|
116
|
+
styles: {}
|
|
117
|
+
},
|
|
118
|
+
setup(__props) {
|
|
119
|
+
const props = __props;
|
|
120
|
+
const context = useMapContext();
|
|
121
|
+
const transform = computed(() => getMarkerTransform(context?.value, props.coordinates));
|
|
122
|
+
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
123
|
+
return (_ctx, _cache) => {
|
|
124
|
+
return transform.value ? (openBlock(), createElementBlock("g", mergeProps({
|
|
125
|
+
key: 0,
|
|
126
|
+
transform: transform.value,
|
|
127
|
+
style: unref(style),
|
|
128
|
+
name: __props.name
|
|
129
|
+
}, events), [renderSlot(_ctx.$slots, "default")], 16, _hoisted_1$6)) : createCommentVNode("v-if", true);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/components/MapMarker.vue
|
|
136
|
+
var MapMarker_default = MapMarker_vue_vue_type_script_setup_true_lang_default;
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/components/MapAnnotation.vue?vue&type=script&setup=true&lang.ts
|
|
140
|
+
const _hoisted_1$5 = ["transform"];
|
|
141
|
+
const _hoisted_2$1 = ["transform"];
|
|
142
|
+
var MapAnnotation_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
143
|
+
inheritAttrs: false,
|
|
144
|
+
__name: "MapAnnotation",
|
|
145
|
+
props: {
|
|
146
|
+
coordinates: {},
|
|
147
|
+
length: {},
|
|
148
|
+
angle: {},
|
|
149
|
+
margin: {},
|
|
150
|
+
curve: { type: Function },
|
|
151
|
+
midpoint: {},
|
|
152
|
+
styles: {}
|
|
153
|
+
},
|
|
154
|
+
setup(__props) {
|
|
155
|
+
const props = __props;
|
|
156
|
+
const geometry = computed(() => getAnnotationGeometry({
|
|
157
|
+
length: props.length,
|
|
158
|
+
angle: props.angle,
|
|
159
|
+
margin: props.margin
|
|
160
|
+
}));
|
|
161
|
+
return (_ctx, _cache) => {
|
|
162
|
+
return openBlock(), createBlock(MapMarker_default, {
|
|
163
|
+
coordinates: __props.coordinates,
|
|
164
|
+
name: "annotation"
|
|
165
|
+
}, {
|
|
166
|
+
default: withCtx(() => [createElementVNode("g", { transform: geometry.value.lineTransform }, [createVNode(MapLine_default, mergeProps(_ctx.$attrs, {
|
|
167
|
+
coordinates: geometry.value.lineCoordinates,
|
|
168
|
+
cartesian: "",
|
|
169
|
+
curve: __props.curve,
|
|
170
|
+
midpoint: __props.midpoint,
|
|
171
|
+
styles: __props.styles,
|
|
172
|
+
fill: "none",
|
|
173
|
+
name: "annotation-line"
|
|
174
|
+
}), null, 16, [
|
|
175
|
+
"coordinates",
|
|
176
|
+
"curve",
|
|
177
|
+
"midpoint",
|
|
178
|
+
"styles"
|
|
179
|
+
])], 8, _hoisted_1$5), createElementVNode("g", {
|
|
180
|
+
transform: geometry.value.contentTransform,
|
|
181
|
+
name: "annotation-content"
|
|
182
|
+
}, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_2$1)]),
|
|
183
|
+
_: 3
|
|
184
|
+
}, 8, ["coordinates"]);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/components/MapAnnotation.vue
|
|
191
|
+
var MapAnnotation_default = MapAnnotation_vue_vue_type_script_setup_true_lang_default;
|
|
192
|
+
|
|
28
193
|
//#endregion
|
|
29
194
|
//#region src/components/MapBase.vue?vue&type=script&setup=true&lang.ts
|
|
30
|
-
const _hoisted_1$
|
|
195
|
+
const _hoisted_1$4 = ["viewBox"];
|
|
31
196
|
var MapBase_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
32
197
|
__name: "MapBase",
|
|
33
198
|
props: {
|
|
@@ -52,7 +217,7 @@ var MapBase_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
52
217
|
}));
|
|
53
218
|
provide(mapContextKey, context);
|
|
54
219
|
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$
|
|
220
|
+
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$4);
|
|
56
221
|
};
|
|
57
222
|
}
|
|
58
223
|
});
|
|
@@ -61,35 +226,9 @@ var MapBase_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
61
226
|
//#region src/components/MapBase.vue
|
|
62
227
|
var MapBase_default = MapBase_vue_vue_type_script_setup_true_lang_default;
|
|
63
228
|
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/hooks/useInsideZoom.ts
|
|
66
|
-
const insideZoomKey = Symbol("InsideZoom");
|
|
67
|
-
function useInsideZoom() {
|
|
68
|
-
return inject(insideZoomKey, false);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/hooks/useMapObject.ts
|
|
73
|
-
function useMapObject(styles) {
|
|
74
|
-
const state = ref("default");
|
|
75
|
-
const { onMouseenter, onMouseleave, onMouseup, onMousedown, dispose } = useMapObjectEvents((nextState) => {
|
|
76
|
-
state.value = nextState;
|
|
77
|
-
}, useInsideZoom());
|
|
78
|
-
onBeforeUnmount(() => {
|
|
79
|
-
dispose();
|
|
80
|
-
});
|
|
81
|
-
return {
|
|
82
|
-
style: computed(() => resolveObjectStyle(state.value, unref(styles))),
|
|
83
|
-
onMouseenter,
|
|
84
|
-
onMouseleave,
|
|
85
|
-
onMousedown,
|
|
86
|
-
onMouseup
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
229
|
//#endregion
|
|
91
230
|
//#region src/components/MapFeature.vue?vue&type=script&setup=true&lang.ts
|
|
92
|
-
const _hoisted_1$
|
|
231
|
+
const _hoisted_1$3 = ["d"];
|
|
93
232
|
var MapFeature_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
94
233
|
__name: "MapFeature",
|
|
95
234
|
props: {
|
|
@@ -105,7 +244,7 @@ var MapFeature_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
105
244
|
return openBlock(), createElementBlock("path", mergeProps({
|
|
106
245
|
d: path.value,
|
|
107
246
|
style: unref(style)
|
|
108
|
-
}, events, { name: "feature" }), null, 16, _hoisted_1$
|
|
247
|
+
}, events, { name: "feature" }), null, 16, _hoisted_1$3);
|
|
109
248
|
};
|
|
110
249
|
}
|
|
111
250
|
});
|
|
@@ -116,7 +255,7 @@ var MapFeature_default = MapFeature_vue_vue_type_script_setup_true_lang_default;
|
|
|
116
255
|
|
|
117
256
|
//#endregion
|
|
118
257
|
//#region src/components/MapFeatures.vue?vue&type=script&setup=true&lang.ts
|
|
119
|
-
const _hoisted_1$
|
|
258
|
+
const _hoisted_1$2 = { name: "features" };
|
|
120
259
|
var MapFeatures_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
121
260
|
__name: "MapFeatures",
|
|
122
261
|
props: {
|
|
@@ -127,7 +266,7 @@ var MapFeatures_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
127
266
|
const context = useMapContext();
|
|
128
267
|
const features = computed(() => context?.value.features ?? []);
|
|
129
268
|
return (_ctx, _cache) => {
|
|
130
|
-
return openBlock(), createElementBlock("g", _hoisted_1$
|
|
269
|
+
return openBlock(), createElementBlock("g", _hoisted_1$2, [renderSlot(_ctx.$slots, "default", { features: features.value }, () => [(openBlock(true), createElementBlock(Fragment, null, renderList(features.value, (feature, index) => {
|
|
131
270
|
return openBlock(), createBlock(MapFeature_default, {
|
|
132
271
|
key: unref(getFeatureKey)(feature, __props.idKey, index),
|
|
133
272
|
data: feature,
|
|
@@ -144,7 +283,7 @@ var MapFeatures_default = MapFeatures_vue_vue_type_script_setup_true_lang_defaul
|
|
|
144
283
|
|
|
145
284
|
//#endregion
|
|
146
285
|
//#region src/components/MapGraticule.vue?vue&type=script&setup=true&lang.ts
|
|
147
|
-
const _hoisted_1$
|
|
286
|
+
const _hoisted_1$1 = ["d", "fill"];
|
|
148
287
|
const _hoisted_2 = ["d"];
|
|
149
288
|
const _hoisted_3 = ["d", "stroke"];
|
|
150
289
|
var MapGraticule_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
@@ -179,7 +318,7 @@ var MapGraticule_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
179
318
|
fill: backgroundColor.value,
|
|
180
319
|
"pointer-events": "none",
|
|
181
320
|
name: "background"
|
|
182
|
-
}, null, 8, _hoisted_1$
|
|
321
|
+
}, null, 8, _hoisted_1$1)) : createCommentVNode("v-if", true),
|
|
183
322
|
createElementVNode("path", mergeProps({
|
|
184
323
|
d: graticulePath.value,
|
|
185
324
|
fill: "none",
|
|
@@ -202,35 +341,6 @@ var MapGraticule_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
202
341
|
//#region src/components/MapGraticule.vue
|
|
203
342
|
var MapGraticule_default = MapGraticule_vue_vue_type_script_setup_true_lang_default;
|
|
204
343
|
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/components/MapMarker.vue?vue&type=script&setup=true&lang.ts
|
|
207
|
-
const _hoisted_1$1 = ["transform"];
|
|
208
|
-
var MapMarker_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
209
|
-
__name: "MapMarker",
|
|
210
|
-
props: {
|
|
211
|
-
coordinates: { default: () => [0, 0] },
|
|
212
|
-
styles: {}
|
|
213
|
-
},
|
|
214
|
-
setup(__props) {
|
|
215
|
-
const props = __props;
|
|
216
|
-
const context = useMapContext();
|
|
217
|
-
const transform = computed(() => {
|
|
218
|
-
return getMarkerTransform(context?.value, props.coordinates);
|
|
219
|
-
});
|
|
220
|
-
const { style, ...events } = useMapObject(toRef(props, "styles"));
|
|
221
|
-
return (_ctx, _cache) => {
|
|
222
|
-
return openBlock(), createElementBlock("g", mergeProps({
|
|
223
|
-
transform: transform.value,
|
|
224
|
-
style: unref(style)
|
|
225
|
-
}, events, { name: "marker" }), [renderSlot(_ctx.$slots, "default")], 16, _hoisted_1$1);
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/components/MapMarker.vue
|
|
232
|
-
var MapMarker_default = MapMarker_vue_vue_type_script_setup_true_lang_default;
|
|
233
|
-
|
|
234
344
|
//#endregion
|
|
235
345
|
//#region src/components/MapMesh.vue?vue&type=script&setup=true&lang.ts
|
|
236
346
|
const _hoisted_1 = ["d"];
|
|
@@ -337,10 +447,12 @@ var MapZoom_default = MapZoom_vue_vue_type_script_setup_true_lang_default;
|
|
|
337
447
|
//#endregion
|
|
338
448
|
//#region src/components/index.ts
|
|
339
449
|
var components_exports = /* @__PURE__ */ __exportAll({
|
|
450
|
+
MapAnnotation: () => MapAnnotation_default,
|
|
340
451
|
MapBase: () => MapBase_default,
|
|
341
452
|
MapFeature: () => MapFeature_default,
|
|
342
453
|
MapFeatures: () => MapFeatures_default,
|
|
343
454
|
MapGraticule: () => MapGraticule_default,
|
|
455
|
+
MapLine: () => MapLine_default,
|
|
344
456
|
MapMarker: () => MapMarker_default,
|
|
345
457
|
MapMesh: () => MapMesh_default,
|
|
346
458
|
MapZoom: () => MapZoom_default
|
|
@@ -358,4 +470,4 @@ const plugin = { install(app) {
|
|
|
358
470
|
} };
|
|
359
471
|
|
|
360
472
|
//#endregion
|
|
361
|
-
export { MapBase_default as MapBase, 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 };
|
|
473
|
+
export { MapAnnotation_default as MapAnnotation, MapBase_default as MapBase, MapFeature_default as MapFeature, MapFeatures_default as MapFeatures, MapGraticule_default as MapGraticule, MapLine_default as MapLine, 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.8.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.8.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/geojson": "^7946.0.16",
|