@radiofrance/svelte-leaflet 0.1.0-alpha.9 → 1.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -7
- package/dist/DivIcon.svelte +64 -0
- package/dist/DivIcon.svelte.d.ts +27 -0
- package/dist/Icon.svelte +56 -0
- package/dist/Icon.svelte.d.ts +31 -0
- package/dist/LocateControl.svelte +57 -0
- package/dist/LocateControl.svelte.d.ts +9 -0
- package/dist/Map.svelte +128 -77
- package/dist/Map.svelte.d.ts +15 -64
- package/dist/Marker.svelte +68 -70
- package/dist/Marker.svelte.d.ts +11 -34
- package/dist/MarkerClusterGroup.svelte +73 -42
- package/dist/MarkerClusterGroup.svelte.d.ts +69 -21
- package/dist/Polygon.svelte +43 -0
- package/dist/Polygon.svelte.d.ts +9 -0
- package/dist/Polyline.svelte +42 -25
- package/dist/Polyline.svelte.d.ts +9 -22
- package/dist/Popup.svelte +69 -44
- package/dist/Popup.svelte.d.ts +10 -19
- package/dist/contexts.d.ts +4 -0
- package/dist/contexts.js +4 -0
- package/dist/events.d.ts +11 -0
- package/dist/events.js +31 -0
- package/dist/index.d.ts +18 -53
- package/dist/index.js +13 -53
- package/dist/map.svelte.d.ts +10 -0
- package/dist/map.svelte.js +117 -0
- package/dist/marker.svelte.d.ts +5 -0
- package/dist/marker.svelte.js +61 -0
- package/dist/markerClusterGroup.svelte.d.ts +9 -0
- package/dist/markerClusterGroup.svelte.js +7 -0
- package/dist/polygon.svelte.d.ts +1 -0
- package/dist/polygon.svelte.js +1 -0
- package/dist/polyline.svelte.d.ts +6 -0
- package/dist/polyline.svelte.js +56 -0
- package/dist/popup.svelte.d.ts +10 -0
- package/dist/popup.svelte.js +50 -0
- package/dist/private/GeolocationButton.svelte +36 -0
- package/dist/private/GeolocationButton.svelte.d.ts +18 -0
- package/dist/private/GeolocationIcon.svelte +25 -0
- package/dist/private/GeolocationIcon.svelte.d.ts +4 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +10 -0
- package/package.json +43 -59
- package/dist/Circle.svelte +0 -41
- package/dist/Circle.svelte.d.ts +0 -36
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Popup as LeafletPopup, PopupOptions } from 'leaflet';
|
|
2
|
+
import type { CreateSvelteEventsMap } from './utils.js';
|
|
3
|
+
export declare function updatePopupProps(instance: LeafletPopup, options: PopupOptions): void;
|
|
4
|
+
export declare const popupEvents: readonly ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "contextmenu", "add", "remove", "popupopen", "popupclose", "tooltipopen", "tooltipclose"];
|
|
5
|
+
export type PopupEvents = CreateSvelteEventsMap<typeof popupEvents, LeafletPopup>;
|
|
6
|
+
declare module 'leaflet' {
|
|
7
|
+
interface Popup {
|
|
8
|
+
_source: Layer;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { interactiveLayerEvents, layerEvents, popupSpecificEvents, tooltipEvents, } from './events.js';
|
|
2
|
+
export function updatePopupProps(instance, options) {
|
|
3
|
+
if (!options)
|
|
4
|
+
return;
|
|
5
|
+
for (const [key, value] of Object.entries(options)) {
|
|
6
|
+
// skip if the option value is unchanged
|
|
7
|
+
if (instance.options[key] === value)
|
|
8
|
+
continue;
|
|
9
|
+
// update the option value :
|
|
10
|
+
// - needed for future comparison (CF above)
|
|
11
|
+
// - handles simple cases
|
|
12
|
+
// bubblingMouseEvents riseOffset autoPanPadding
|
|
13
|
+
// autoPanSpeed
|
|
14
|
+
instance.options[key] = value;
|
|
15
|
+
switch (key) {
|
|
16
|
+
// unhandled
|
|
17
|
+
case 'className':
|
|
18
|
+
case 'interactive':
|
|
19
|
+
case 'closeButton':
|
|
20
|
+
case 'pane':
|
|
21
|
+
throw new Error(`mutation of ${key} option is not supported`);
|
|
22
|
+
// needs to reopen the popup
|
|
23
|
+
case 'keepInView':
|
|
24
|
+
case 'autoPan':
|
|
25
|
+
case 'autoClose':
|
|
26
|
+
case 'closeOnClick':
|
|
27
|
+
case 'closeOnEscapeKey':
|
|
28
|
+
case 'maxWidth':
|
|
29
|
+
case 'minWidth':
|
|
30
|
+
case 'maxHeight':
|
|
31
|
+
case 'offset':
|
|
32
|
+
if (instance.isOpen()) {
|
|
33
|
+
const source = instance._source;
|
|
34
|
+
source.closePopup();
|
|
35
|
+
source.openPopup();
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case 'content':
|
|
39
|
+
instance.setContent(value);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export const popupEvents = [
|
|
45
|
+
// 'contentupdate', // needs @types/leaflet PR ?
|
|
46
|
+
...interactiveLayerEvents,
|
|
47
|
+
...layerEvents,
|
|
48
|
+
...popupSpecificEvents,
|
|
49
|
+
...tooltipEvents,
|
|
50
|
+
];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import GeolocationIcon from './GeolocationIcon.svelte';
|
|
4
|
+
import { FOCUSABLE } from '../contexts.js';
|
|
5
|
+
|
|
6
|
+
const tabindex = getContext<-1 | null>(FOCUSABLE);
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div>
|
|
10
|
+
<button {tabindex}>
|
|
11
|
+
<GeolocationIcon width="1rem" />
|
|
12
|
+
</button>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<style>
|
|
16
|
+
button {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
width: 30px;
|
|
21
|
+
height: 30px;
|
|
22
|
+
background-color: white;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
border: none;
|
|
25
|
+
border-radius: 2px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
button:hover {
|
|
29
|
+
background-color: #f4f4f4;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
div {
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
border: 2px solid rgba(0, 0, 0, 0.2);
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const GeolocationButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type GeolocationButton = InstanceType<typeof GeolocationButton>;
|
|
18
|
+
export default GeolocationButton;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
width?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
let { width = '32px' }: Props = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<svg
|
|
10
|
+
{width}
|
|
11
|
+
viewBox="0 0 16 16"
|
|
12
|
+
version="1.1"
|
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
15
|
+
fill="#000000"
|
|
16
|
+
>
|
|
17
|
+
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
|
|
18
|
+
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
|
|
19
|
+
<g id="SVGRepo_iconCarrier">
|
|
20
|
+
<rect width="16" height="16" id="icon-bound" fill="none"></rect>
|
|
21
|
+
<path
|
|
22
|
+
d="M13.916,7C13.494,4.488,11.512,2.506,9,2.084V0H7v2.084C4.488,2.506,2.506,4.488,2.084,7H0v2h2.084 C2.506,11.512,4.488,13.494,7,13.916V16h2v-2.084c2.512-0.422,4.494-2.403,4.916-4.916H16V7H13.916z M10.828,10.828 C10.072,11.584,9.069,12,8,12s-2.072-0.416-2.828-1.172S4,9.069,4,8s0.416-2.072,1.172-2.828S6.931,4,8,4s2.072,0.416,2.828,1.172 S12,6.931,12,8S11.584,10.072,10.828,10.828z M8,6C6.897,6,6,6.897,6,8s0.897,2,2,2s2-0.897,2-2S9.103,6,8,6z"
|
|
23
|
+
></path>
|
|
24
|
+
</g>
|
|
25
|
+
</svg>
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LeafletEventHandlerFnMap } from 'leaflet';
|
|
2
|
+
export declare function capitalize<T extends string>(str: T): Capitalize<T>;
|
|
3
|
+
export declare function getFirstNonCommentChild(element: HTMLElement): HTMLElement | null;
|
|
4
|
+
export type PickOptionByType<Options, Type> = keyof {
|
|
5
|
+
[K in keyof Options as true extends UnionContainsType<Options[K], Type> ? K : never]: Options[K];
|
|
6
|
+
};
|
|
7
|
+
export type UnionContainsType<Union, Type> = Union extends Type ? true : never;
|
|
8
|
+
export type CreateSvelteEventsMap<EventNames extends readonly (keyof LeafletEventHandlerFnMap)[], SourceTarget = null> = {
|
|
9
|
+
[K in EventNames[number] as `on${K}`]?: SourceTarget extends null ? LeafletEventHandlerFnMap[K] : (e: Omit<Parameters<Exclude<LeafletEventHandlerFnMap[K], undefined>>[0], 'sourceTarget'> & {
|
|
10
|
+
sourceTarget: SourceTarget;
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function capitalize(str) {
|
|
2
|
+
return (str[0].toUpperCase() + str.slice(1));
|
|
3
|
+
}
|
|
4
|
+
export function getFirstNonCommentChild(element) {
|
|
5
|
+
let child = element.firstChild;
|
|
6
|
+
while (child && child.nodeType !== Node.ELEMENT_NODE) {
|
|
7
|
+
child = child.nextSibling;
|
|
8
|
+
}
|
|
9
|
+
return child;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,88 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radiofrance/svelte-leaflet",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A library that wraps leaflet classes in domless/renderless svelte components.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"svelte",
|
|
7
|
-
"leaflet",
|
|
8
|
-
"map",
|
|
9
|
-
"cartography",
|
|
10
|
-
"sveltekit"
|
|
11
|
-
],
|
|
12
|
-
"author": {
|
|
13
|
-
"email": "romain.durand@radiofrance.com",
|
|
14
|
-
"name": "Romain Durand"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "https://github.com/radiofrance/svelte-leaflet"
|
|
19
|
-
},
|
|
3
|
+
"version": "1.0.0-next.0",
|
|
20
4
|
"scripts": {
|
|
21
5
|
"dev": "vite dev",
|
|
22
6
|
"build": "vite build && npm run package",
|
|
23
7
|
"preview": "vite preview",
|
|
24
8
|
"package": "svelte-kit sync && svelte-package && publint",
|
|
25
9
|
"prepublishOnly": "npm run package",
|
|
26
|
-
"test": "npm run test:integration && npm run test:unit",
|
|
27
10
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
28
11
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
29
|
-
"lint": "prettier --check . && eslint .",
|
|
30
12
|
"format": "prettier --write .",
|
|
31
|
-
"
|
|
32
|
-
"test:unit": "vitest"
|
|
13
|
+
"lint": "prettier --check . && eslint .",
|
|
14
|
+
"test:unit": "vitest",
|
|
15
|
+
"test": "npm run test:unit -- --run && npm run test:e2e",
|
|
16
|
+
"test:e2e": "playwright test"
|
|
33
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"!dist/**/*.test.*",
|
|
21
|
+
"!dist/**/*.spec.*"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"**/*.css"
|
|
25
|
+
],
|
|
26
|
+
"svelte": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"type": "module",
|
|
34
29
|
"exports": {
|
|
35
30
|
".": {
|
|
36
31
|
"types": "./dist/index.d.ts",
|
|
37
32
|
"svelte": "./dist/index.js"
|
|
38
33
|
}
|
|
39
34
|
},
|
|
40
|
-
"files": [
|
|
41
|
-
"dist",
|
|
42
|
-
"!dist/**/*.test.*",
|
|
43
|
-
"!dist/**/*.spec.*"
|
|
44
|
-
],
|
|
45
35
|
"peerDependencies": {
|
|
46
|
-
"svelte": "^
|
|
36
|
+
"svelte": "^5.0.0"
|
|
47
37
|
},
|
|
48
38
|
"devDependencies": {
|
|
49
|
-
"@playwright/test": "^1.
|
|
39
|
+
"@playwright/test": "^1.45.3",
|
|
40
|
+
"@skeletonlabs/skeleton": "^3.0.0-next.7",
|
|
41
|
+
"@skeletonlabs/skeleton-svelte": "^1.0.0-next.12",
|
|
42
|
+
"@skeletonlabs/tw-plugin": "^0.4.0",
|
|
50
43
|
"@sveltejs/adapter-auto": "^3.0.0",
|
|
51
44
|
"@sveltejs/kit": "^2.0.0",
|
|
52
45
|
"@sveltejs/package": "^2.0.0",
|
|
53
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
54
|
-
"@types/
|
|
55
|
-
"@types/
|
|
56
|
-
"@types/
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"d3-scale-chromatic": "^3.0.0",
|
|
61
|
-
"eslint": "^8.56.0",
|
|
46
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
47
|
+
"@types/eslint": "^9.6.0",
|
|
48
|
+
"@types/leaflet": "^1.9.14",
|
|
49
|
+
"@types/leaflet.markercluster": "^1.5.5",
|
|
50
|
+
"@types/node": "^22.9.0",
|
|
51
|
+
"autoprefixer": "^10.4.20",
|
|
52
|
+
"eslint": "^9.7.0",
|
|
62
53
|
"eslint-config-prettier": "^9.1.0",
|
|
63
|
-
"eslint-plugin-svelte": "^2.
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"svelte": "^
|
|
68
|
-
"
|
|
69
|
-
"
|
|
54
|
+
"eslint-plugin-svelte": "^2.36.0",
|
|
55
|
+
"globals": "^15.0.0",
|
|
56
|
+
"leaflet": "^1.9.4",
|
|
57
|
+
"leaflet.markercluster": "^1.5.3",
|
|
58
|
+
"lucide-svelte": "^0.456.0",
|
|
59
|
+
"mdsvex": "^0.11.2",
|
|
60
|
+
"prettier": "^3.3.2",
|
|
61
|
+
"prettier-plugin-svelte": "^3.2.6",
|
|
62
|
+
"prettier-plugin-tailwindcss": "^0.6.5",
|
|
63
|
+
"publint": "^0.2.0",
|
|
64
|
+
"svelte": "^5.0.0",
|
|
65
|
+
"svelte-check": "^4.0.0",
|
|
66
|
+
"tailwindcss": "^3.4.9",
|
|
70
67
|
"typescript": "^5.0.0",
|
|
68
|
+
"typescript-eslint": "^8.0.0",
|
|
71
69
|
"vite": "^5.0.11",
|
|
72
|
-
"vitest": "^
|
|
73
|
-
},
|
|
74
|
-
"svelte": "./dist/index.js",
|
|
75
|
-
"types": "./dist/index.d.ts",
|
|
76
|
-
"type": "module",
|
|
77
|
-
"private": false,
|
|
78
|
-
"publishConfig": {
|
|
79
|
-
"access": "public",
|
|
80
|
-
"registry": "https://registry.npmjs.org/"
|
|
81
|
-
},
|
|
82
|
-
"dependencies": {
|
|
83
|
-
"@types/leaflet": "^1.9.12",
|
|
84
|
-
"@types/leaflet.markercluster": "^1.5.4",
|
|
85
|
-
"leaflet": "^1.9.4",
|
|
86
|
-
"leaflet.markercluster": "^1.5.3"
|
|
70
|
+
"vitest": "^2.0.4"
|
|
87
71
|
}
|
|
88
72
|
}
|
package/dist/Circle.svelte
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script>import { createEventDispatcher, getContext, onDestroy, onMount } from "svelte";
|
|
2
|
-
import {
|
|
3
|
-
bindEvents,
|
|
4
|
-
interactiveLayerEvents,
|
|
5
|
-
layerEvents,
|
|
6
|
-
popupEvents,
|
|
7
|
-
tooltipEvents
|
|
8
|
-
} from "./index.js";
|
|
9
|
-
export let center;
|
|
10
|
-
export let options = { radius: 100 };
|
|
11
|
-
export let instance = void 0;
|
|
12
|
-
const events = [
|
|
13
|
-
"move",
|
|
14
|
-
...interactiveLayerEvents,
|
|
15
|
-
...layerEvents,
|
|
16
|
-
...popupEvents,
|
|
17
|
-
...tooltipEvents
|
|
18
|
-
];
|
|
19
|
-
let map = getContext("map")();
|
|
20
|
-
const dispatch = createEventDispatcher();
|
|
21
|
-
$:
|
|
22
|
-
updateCircle(center, options);
|
|
23
|
-
function updateCircle(center2, options2) {
|
|
24
|
-
if (instance) {
|
|
25
|
-
instance.setLatLng(center2);
|
|
26
|
-
instance.setStyle(options2);
|
|
27
|
-
instance.setRadius(options2.radius);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
onMount(async () => {
|
|
31
|
-
const L = window.L;
|
|
32
|
-
instance = new L.Circle(center, options);
|
|
33
|
-
bindEvents(instance, dispatch, events);
|
|
34
|
-
instance.addTo(map);
|
|
35
|
-
});
|
|
36
|
-
onDestroy(() => {
|
|
37
|
-
instance?.remove();
|
|
38
|
-
});
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<slot />
|
package/dist/Circle.svelte.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Circle as LeafletCircle, LatLngExpression } from 'leaflet';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
center: LatLngExpression;
|
|
6
|
-
options?: import("leaflet").CircleMarkerOptions | undefined;
|
|
7
|
-
instance?: LeafletCircle | undefined;
|
|
8
|
-
};
|
|
9
|
-
events: {
|
|
10
|
-
click: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
11
|
-
dblclick: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
12
|
-
mousedown: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
13
|
-
mouseup: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
14
|
-
mouseover: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
15
|
-
mouseout: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
16
|
-
contextmenu: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
17
|
-
move: CustomEvent<import("leaflet").LeafletEvent>;
|
|
18
|
-
popupopen: CustomEvent<import("leaflet").PopupEvent>;
|
|
19
|
-
popupclose: CustomEvent<import("leaflet").PopupEvent>;
|
|
20
|
-
tooltipopen: CustomEvent<import("leaflet").TooltipEvent>;
|
|
21
|
-
tooltipclose: CustomEvent<import("leaflet").TooltipEvent>;
|
|
22
|
-
add: CustomEvent<import("leaflet").LeafletEvent>;
|
|
23
|
-
remove: CustomEvent<import("leaflet").LeafletEvent>;
|
|
24
|
-
} & {
|
|
25
|
-
[evt: string]: CustomEvent<any>;
|
|
26
|
-
};
|
|
27
|
-
slots: {
|
|
28
|
-
default: {};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export type CircleProps = typeof __propDef.props;
|
|
32
|
-
export type CircleEvents = typeof __propDef.events;
|
|
33
|
-
export type CircleSlots = typeof __propDef.slots;
|
|
34
|
-
export default class Circle extends SvelteComponent<CircleProps, CircleEvents, CircleSlots> {
|
|
35
|
-
}
|
|
36
|
-
export {};
|