@swr-data-lab/components 2.21.0 → 2.22.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.
@@ -1,7 +1,8 @@
1
- <script lang="ts">import { getMapContext } from '../context.svelte.js';
1
+ <script lang="ts">import {} from 'maplibre-gl';
2
+ import { getMapContext } from '../context.svelte.js';
2
3
  import { onDestroy } from 'svelte';
3
4
  import { resetLayerEventListener } from '../utils.js';
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
+ const { id, sourceId, sourceLayer, filter, visible = true, placeBelow = 'label-place-major-city', type, paint, layout, hovered = $bindable(), selected = $bindable(), minZoom = 0, maxZoom = 24, onclick, onmousemove, onmouseleave } = $props();
5
6
  const { map, styleLoaded } = $derived(getMapContext());
6
7
  let beforeId = $state();
7
8
  let prevSelected = $state();
@@ -9,6 +10,7 @@ let prevHovered = $state();
9
10
  const layerSpec = {
10
11
  id,
11
12
  type,
13
+ ...(filter ? { filter } : {}),
12
14
  source: sourceId,
13
15
  'source-layer': sourceLayer || '',
14
16
  layout: $state.snapshot(layout) ?? {},
@@ -1,8 +1,12 @@
1
- import type { CircleLayoutProps, CirclePaintProps, FillLayoutProps, FillPaintProps, LineLayoutProps, SymbolPaintProps, SymbolLayoutProps, LinePaintProps, MapGeoJSONFeature, MapLayerMouseEvent } from 'maplibre-gl';
1
+ import { type CircleLayoutProps, type CirclePaintProps, type FillLayoutProps, type FillPaintProps, type LineLayoutProps, type SymbolPaintProps, type SymbolLayoutProps, type LinePaintProps, type MapGeoJSONFeature, type MapLayerMouseEvent } from 'maplibre-gl';
2
2
  interface VectorLayerProps {
3
3
  id: string;
4
4
  sourceId: string;
5
5
  sourceLayer?: string;
6
+ /**
7
+ * Maplibre [filter expression](https://maplibre.org/maplibre-style-spec/layers/#filter)
8
+ */
9
+ filter?: any[];
6
10
  type: 'line' | 'fill' | 'circle' | 'symbol';
7
11
  placeBelow?: string;
8
12
  visible?: boolean;
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.21.0",
4
+ "version": "2.22.0",
5
5
  "author": "SWR Data Lab",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",