@swr-data-lab/components 2.35.0 → 2.37.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.
@@ -4,7 +4,7 @@ import { createMapContext, MapContext } from '../context.svelte.js';
4
4
  import {} from '../types';
5
5
  import FallbackStyle from './FallbackStyle';
6
6
  import { de } from './locale';
7
- let { children, options, style = FallbackStyle, minZoom = 0, maxZoom = 14.99, zoom = $bindable(), center = $bindable(), pitch = $bindable(0), bearing = $bindable(0), loading = $bindable(true), projection = { type: 'mercator' }, allowRotation = false, allowZoom = true, showDebug = false, cursor, initialBounds, maxBounds, initialLocation: receivedInitialLocation,
7
+ let { children, options, style = FallbackStyle, minZoom = 0, maxZoom = 14.99, zoom = $bindable(), center = $bindable(), pitch = $bindable(0), bearing = $bindable(0), loading = $bindable(true), projection = { type: 'mercator' }, allowPan = true, allowRotation = false, allowZoom = true, showDebug = false, cursor, initialBounds, maxBounds, initialLocation: receivedInitialLocation,
8
8
  // Future: This should become bindable.readonly when that becomes
9
9
  // available, see: https://github.com/sveltejs/svelte/issues/7712
10
10
  mapContext = $bindable(), cooperativeGestures = false, onmoveend, onmovestart } = $props();
@@ -84,7 +84,15 @@ $effect(() => {
84
84
  mapContext.map?.scrollZoom.enable();
85
85
  }
86
86
  });
87
- const debugValues = $derived(Object.entries({ zoom, pitch, allowZoom, allowRotation }));
87
+ $effect(() => {
88
+ if (allowPan === false) {
89
+ mapContext.map?.dragPan.disable();
90
+ }
91
+ else {
92
+ mapContext.map?.dragPan.enable();
93
+ }
94
+ });
95
+ const debugValues = $derived(Object.entries({ zoom, pitch, allowZoom, allowPan, allowRotation }));
88
96
  const handleDebugValueClick = (e) => {
89
97
  if (e.target) {
90
98
  const t = e.target;
@@ -177,16 +185,16 @@ const handleDebugCopyLocationClick = (e) => {
177
185
  height: 100%;
178
186
  width: 100%;
179
187
  }
180
- :global(.maplibregl-canvas-container.maplibregl-interactive) {
188
+ :global(.maplibregl-canvas-container.maplibregl-touch-drag-pan) {
181
189
  cursor: grab;
182
190
  user-select: none;
183
191
  }
192
+ :global(.maplibregl-canvas-container.maplibregl-touch-drag-pan:active) {
193
+ cursor: grabbing;
194
+ }
184
195
  :global(.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer) {
185
196
  cursor: pointer;
186
197
  }
187
- :global(.maplibregl-canvas-container.maplibregl-interactive:active) {
188
- cursor: grabbing;
189
- }
190
198
  :global(.maplibregl-canvas-container.maplibregl-touch-zoom-rotate),
191
199
  :global(.maplibregl-canvas-container.maplibregl-touch-zoom-rotate) :global(.maplibregl-canvas) {
192
200
  touch-action: pan-x pan-y;
@@ -10,6 +10,7 @@ interface MapProps {
10
10
  initialBounds?: LngLatBoundsLike;
11
11
  maxBounds?: LngLatBoundsLike;
12
12
  initialLocation?: Location;
13
+ allowPan?: boolean;
13
14
  allowRotation?: boolean;
14
15
  allowZoom?: boolean;
15
16
  minZoom?: number;
@@ -45,7 +45,6 @@ const tokens = {
45
45
  };
46
46
  const { landuse } = makeLanduse(tokens);
47
47
  const { placeLabels, boundaryLabels } = makePlaceLabels(tokens);
48
- const { admin } = makeAdmin(tokens);
49
48
  const { airports, transitBridges, transitSurface, transitTunnels } = makeTransit(tokens);
50
49
  const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWalking(tokens);
51
50
  const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
@@ -56,6 +55,7 @@ const style = (opts) => {
56
55
  ...defaultOptions,
57
56
  ...opts
58
57
  };
58
+ const { admin } = makeAdmin(tokens, options?.admin);
59
59
  return {
60
60
  version: 8,
61
61
  name: 'swr-datalab-dark',
@@ -45,7 +45,6 @@ const tokens = {
45
45
  };
46
46
  const { landuse } = makeLanduse(tokens);
47
47
  const { placeLabels, boundaryLabels } = makePlaceLabels(tokens);
48
- const { admin } = makeAdmin(tokens);
49
48
  const { airports, transitBridges, transitSurface, transitTunnels } = makeTransit(tokens);
50
49
  const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWalking(tokens);
51
50
  const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
@@ -56,6 +55,7 @@ const style = (opts) => {
56
55
  ...defaultOptions,
57
56
  ...opts
58
57
  };
58
+ const { admin } = makeAdmin(tokens, options?.admin);
59
59
  return {
60
60
  version: 8,
61
61
  name: 'swr-datalab-light',
@@ -1 +1 @@
1
- export default function makeAdmin(tokens: any): any;
1
+ export default function makeAdmin(tokens: any, options: any): any;
@@ -1,5 +1,5 @@
1
1
  import {} from '../../types';
2
- export default function makeAdmin(tokens) {
2
+ export default function makeAdmin(tokens, options) {
3
3
  const admin = [
4
4
  {
5
5
  id: 'boundary-country:case',
@@ -133,7 +133,21 @@ export default function makeAdmin(tokens) {
133
133
  }
134
134
  }
135
135
  }
136
- ].map((el) => {
136
+ ]
137
+ .filter((el) => {
138
+ if (!options || options.show === true) {
139
+ return true;
140
+ }
141
+ else if (options.show === false) {
142
+ return false;
143
+ }
144
+ else {
145
+ return ((el.id.includes('country') && options.show.includes(2)) ||
146
+ (el.id.includes('state') && options.show.includes(4)));
147
+ }
148
+ return false;
149
+ })
150
+ .map((el) => {
137
151
  return {
138
152
  source: 'versatiles-osm',
139
153
  'source-layer': 'boundaries',
@@ -5,6 +5,9 @@ const opts = {
5
5
  },
6
6
  roads: {
7
7
  showLabels: true
8
+ },
9
+ admin: {
10
+ show: true
8
11
  }
9
12
  };
10
13
  export default opts;
@@ -1,9 +1,16 @@
1
+ declare enum AdminLevel {
2
+ COUNTRY = 2,
3
+ BUNDESLAND = 4
4
+ }
1
5
  interface StyleOptions {
2
6
  enableBuildingExtrusions?: boolean;
3
7
  enableHillshade?: boolean;
4
8
  places?: {
5
9
  showLabels?: boolean;
6
10
  };
11
+ admin?: {
12
+ show?: boolean | AdminLevel[];
13
+ };
7
14
  roads?: {
8
15
  showLabels?: boolean;
9
16
  };
@@ -1 +1,6 @@
1
+ var AdminLevel;
2
+ (function (AdminLevel) {
3
+ AdminLevel[AdminLevel["COUNTRY"] = 2] = "COUNTRY";
4
+ AdminLevel[AdminLevel["BUNDESLAND"] = 4] = "BUNDESLAND";
5
+ })(AdminLevel || (AdminLevel = {}));
1
6
  export {};
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.35.0",
4
+ "version": "2.37.0",
5
5
  "author": "SWR Data Lab",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "@storybook/test-runner": "^0.24.2",
50
50
  "@sveltejs/adapter-auto": "7.0.0",
51
51
  "@sveltejs/enhanced-img": "0.9.2",
52
- "@sveltejs/kit": "2.49.2",
52
+ "@sveltejs/kit": "2.49.5",
53
53
  "@sveltejs/package": "2.5.7",
54
54
  "@sveltejs/vite-plugin-svelte": "6.2.1",
55
55
  "@types/geojson": "7946.0.16",