@swr-data-lab/components 2.5.1 → 2.5.2

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.
@@ -4,9 +4,9 @@ import MapSource from '../Source/MapSource.svelte';
4
4
  const { maxZoom = 24, id, data, attribution = '' } = $props();
5
5
  const sourceSpec = {
6
6
  type: 'geojson',
7
- data,
8
7
  maxzoom: maxZoom,
9
- attribution
8
+ attribution,
9
+ data
10
10
  };
11
11
  </script>
12
12
 
@@ -19,7 +19,10 @@ $effect(() => {
19
19
  });
20
20
  // 2. Do extra stuff with the source object
21
21
  $effect(() => {
22
- if (source) {
22
+ if (source && sourceSpec.type === 'geojson') {
23
+ if (!firstRun) {
24
+ source.setData(sourceSpec.data);
25
+ }
23
26
  }
24
27
  });
25
28
  $effect(() => {
@@ -1,6 +1,6 @@
1
1
  import { type Snippet } from 'svelte';
2
2
  import { type Map, type SourceSpecification } from 'maplibre-gl';
3
- type Source = maplibregl.VectorTileSource;
3
+ type Source = maplibregl.VectorTileSource | maplibregl.GeoJSONSource;
4
4
  interface MapSourceProps {
5
5
  id: string;
6
6
  sourceSpec: SourceSpecification;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">import { getMapContext } from '../context.svelte.js';
2
2
  import { onDestroy } from 'svelte';
3
3
  import { resetLayerEventListener } from '../utils.js';
4
- const { id, sourceId, sourceLayer, visible = true, placeBelow = 'label-place-capital', type, paint, layout, hovered = $bindable(), selected = $bindable(), minZoom = 0, maxZoom = 24, onclick, onmousemove, onmouseleave } = $props();
4
+ const { id, sourceId, sourceLayer, visible = true, placeBelow = 'label-place-major-city', type, paint, layout, hovered = $bindable(), selected = $bindable(), minZoom = 0, maxZoom = 24, onclick, onmousemove, onmouseleave } = $props();
5
5
  const { map, styleLoaded } = $derived(getMapContext());
6
6
  let beforeId = $state();
7
7
  let prevSelected = $state();
@@ -4,7 +4,7 @@ interface VectorLayerProps {
4
4
  sourceId: string;
5
5
  sourceLayer?: string;
6
6
  type: 'line' | 'fill' | 'circle' | 'symbol';
7
- placeBelow: string;
7
+ placeBelow?: string;
8
8
  visible?: boolean;
9
9
  minZoom?: number;
10
10
  maxZoom?: number;
@@ -12,9 +12,9 @@ interface VectorLayerProps {
12
12
  layout?: LineLayoutProps | FillLayoutProps | CircleLayoutProps | SymbolLayoutProps;
13
13
  hovered?: MapGeoJSONFeature | undefined;
14
14
  selected?: MapGeoJSONFeature | undefined;
15
- onclick: (e: MapLayerMouseEvent) => any;
16
- onmousemove: (e: MapLayerMouseEvent) => any;
17
- onmouseleave: (e: MapLayerMouseEvent) => any;
15
+ onclick?: (e: MapLayerMouseEvent) => any;
16
+ onmousemove?: (e: MapLayerMouseEvent) => any;
17
+ onmouseleave?: (e: MapLayerMouseEvent) => any;
18
18
  }
19
19
  declare const VectorLayer: import("svelte").Component<VectorLayerProps, {}, "hovered" | "selected">;
20
20
  type VectorLayer = ReturnType<typeof VectorLayer>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swr-data-lab/components",
3
3
  "description": "SWR Data Lab component library",
4
- "version": "2.5.1",
4
+ "version": "2.5.2",
5
5
  "author": "SWR Data Lab",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",