@swr-data-lab/components 1.11.2 → 1.12.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.
Files changed (66) hide show
  1. package/.storybook/blocks/Mermaid.jsx +9 -0
  2. package/.storybook/main.ts +23 -17
  3. package/.storybook/preview.ts +42 -13
  4. package/package.json +72 -68
  5. package/src/DesignTokens/Tokens.ts +15 -12
  6. package/src/Select/Select.stories.svelte +3 -3
  7. package/src/Switcher/Switcher.svelte +1 -0
  8. package/src/index.js +12 -0
  9. package/src/maplibre/AttributionControl/AttributionControl.stories.svelte +29 -0
  10. package/src/maplibre/AttributionControl/AttributionControl.svelte +45 -0
  11. package/src/maplibre/AttributionControl/index.js +2 -0
  12. package/src/maplibre/GeocoderControl/GeocoderAPIs.ts +49 -0
  13. package/src/maplibre/GeocoderControl/GeocoderControl.stories.svelte +78 -0
  14. package/src/maplibre/GeocoderControl/GeocoderControl.svelte +207 -0
  15. package/src/maplibre/GeocoderControl/index.js +2 -0
  16. package/src/maplibre/Map/FallbackStyle.ts +18 -0
  17. package/src/maplibre/Map/Map.stories.svelte +118 -0
  18. package/src/maplibre/Map/Map.svelte +283 -0
  19. package/src/maplibre/Map/index.js +2 -0
  20. package/src/maplibre/MapControl/MapControl.mdx +12 -0
  21. package/src/maplibre/MapControl/MapControl.stories.svelte +56 -0
  22. package/src/maplibre/MapControl/MapControl.svelte +41 -0
  23. package/src/maplibre/MapControl/index.js +2 -0
  24. package/src/maplibre/MapStyle/SWRDataLabLight.mdx +86 -0
  25. package/src/maplibre/MapStyle/SWRDataLabLight.stories.svelte +41 -0
  26. package/src/maplibre/MapStyle/SWRDataLabLight.ts +72 -0
  27. package/src/maplibre/MapStyle/components/Admin.ts +173 -0
  28. package/src/maplibre/MapStyle/components/Buildings.ts +23 -0
  29. package/src/maplibre/MapStyle/components/Landuse.ts +499 -0
  30. package/src/maplibre/MapStyle/components/Natural.ts +1 -0
  31. package/src/maplibre/MapStyle/components/PlaceLabels.ts +199 -0
  32. package/src/maplibre/MapStyle/components/Roads.ts +2345 -0
  33. package/src/maplibre/MapStyle/components/Transit.ts +507 -0
  34. package/src/maplibre/MapStyle/components/Walking.ts +1538 -0
  35. package/src/maplibre/MapStyle/index.js +2 -0
  36. package/src/maplibre/MapStyle/tokens.ts +21 -0
  37. package/src/maplibre/Maplibre.mdx +91 -0
  38. package/src/maplibre/NavigationControl/NavigationControl.stories.svelte +39 -0
  39. package/src/maplibre/NavigationControl/NavigationControl.svelte +36 -0
  40. package/src/maplibre/NavigationControl/index.js +2 -0
  41. package/src/maplibre/ScaleControl/ScaleControl.stories.svelte +71 -0
  42. package/src/maplibre/ScaleControl/ScaleControl.svelte +25 -0
  43. package/src/maplibre/ScaleControl/index.js +2 -0
  44. package/src/maplibre/Source/MapSource.stories.svelte +9 -0
  45. package/src/maplibre/Source/MapSource.svelte +61 -0
  46. package/src/maplibre/Source/index.js +2 -0
  47. package/src/maplibre/Source/source.ts +89 -0
  48. package/src/maplibre/Tooltip/Tooltip.stories.svelte +192 -0
  49. package/src/maplibre/Tooltip/Tooltip.svelte +175 -0
  50. package/src/maplibre/Tooltip/index.js +2 -0
  51. package/src/maplibre/VectorLayer/VectorLayer.stories.svelte +65 -0
  52. package/src/maplibre/VectorLayer/VectorLayer.svelte +142 -0
  53. package/src/maplibre/VectorLayer/index.js +2 -0
  54. package/src/maplibre/VectorTileSource/VectorTileSource.mdx +19 -0
  55. package/src/maplibre/VectorTileSource/VectorTileSource.stories.svelte +46 -0
  56. package/src/maplibre/VectorTileSource/VectorTileSource.svelte +24 -0
  57. package/src/maplibre/VectorTileSource/index.js +2 -0
  58. package/src/maplibre/WithLinkLocation/WithLinkLocation.mdx +11 -0
  59. package/src/maplibre/WithLinkLocation/WithLinkLocation.stories.svelte +29 -0
  60. package/src/maplibre/WithLinkLocation/WithLinkLocation.svelte +83 -0
  61. package/src/maplibre/WithLinkLocation/index.js +2 -0
  62. package/src/maplibre/context.svelte.ts +89 -0
  63. package/src/maplibre/types.ts +12 -0
  64. package/src/maplibre/utils.ts +52 -0
  65. package/tsconfig.json +1 -0
  66. package/src/events/clickOutside.js +0 -23
@@ -0,0 +1,507 @@
1
+ import tokens from '../tokens';
2
+ import type { Layer } from '../../types';
3
+
4
+ const rail = {
5
+ line_color: '#d3d3d3',
6
+ line_dasharray: [2, 2],
7
+ line_width: {
8
+ stops: [
9
+ [8, 1],
10
+ [13, 1],
11
+ [20, 2]
12
+ ]
13
+ },
14
+ line_opacity: {
15
+ stops: [
16
+ [12, 0],
17
+ [13, 1]
18
+ ]
19
+ }
20
+ };
21
+
22
+ const rail_overlay = {
23
+ line_width: {
24
+ stops: [
25
+ [8, 1],
26
+ [13, 6],
27
+ [20, 12]
28
+ ]
29
+ },
30
+ line_dasharray: [0.125, 6]
31
+ };
32
+
33
+ const rail_outline = {
34
+ line_color: tokens.background,
35
+ line_width: {
36
+ stops: [
37
+ [13, 2],
38
+ [20, 4]
39
+ ]
40
+ },
41
+ line_opacity: {
42
+ stops: [
43
+ [12, 0],
44
+ [13, 1]
45
+ ]
46
+ }
47
+ };
48
+
49
+ export default function makeTransit() {
50
+ const airports = [
51
+ {
52
+ id: 'airport-area',
53
+ type: 'fill',
54
+ 'source-layer': 'street_polygons',
55
+ filter: ['in', 'kind', 'runway', 'taxiway'],
56
+ paint: {
57
+ 'fill-color': 'hsl(0,0%,100%)',
58
+ 'fill-opacity': 0.5
59
+ }
60
+ },
61
+ {
62
+ id: 'airport-taxiway:outline',
63
+ filter: ['==', 'kind', 'taxiway'],
64
+ paint: {
65
+ 'line-color': 'hsl(36,0%,80%)',
66
+ 'line-width': {
67
+ stops: [
68
+ [13, 0],
69
+ [14, 2],
70
+ [15, 10],
71
+ [16, 14],
72
+ [18, 20],
73
+ [20, 40]
74
+ ]
75
+ }
76
+ },
77
+ layout: {
78
+ 'line-join': 'round'
79
+ }
80
+ },
81
+ {
82
+ id: 'airport-runway:outline',
83
+ filter: ['==', 'kind', 'runway'],
84
+ paint: {
85
+ 'line-color': 'hsl(36,0%,80%)',
86
+ 'line-width': {
87
+ stops: [
88
+ [11, 0],
89
+ [12, 6],
90
+ [13, 9],
91
+ [14, 16],
92
+ [15, 24],
93
+ [16, 40],
94
+ [17, 100],
95
+ [18, 160],
96
+ [20, 300]
97
+ ]
98
+ }
99
+ },
100
+ layout: {
101
+ 'line-join': 'round'
102
+ }
103
+ },
104
+ {
105
+ id: 'airport-taxiway',
106
+ filter: ['==', 'kind', 'taxiway'],
107
+ paint: {
108
+ 'line-color': 'hsl(0,0%,100%)',
109
+ 'line-width': {
110
+ stops: [
111
+ [13, 0],
112
+ [14, 1],
113
+ [15, 8],
114
+ [16, 12],
115
+ [18, 18],
116
+ [20, 36]
117
+ ]
118
+ },
119
+ 'line-opacity': {
120
+ stops: [
121
+ [13, 0],
122
+ [14, 1]
123
+ ]
124
+ }
125
+ },
126
+ layout: {
127
+ 'line-join': 'round'
128
+ }
129
+ },
130
+ {
131
+ id: 'airport-runway',
132
+ filter: ['==', 'kind', 'runway'],
133
+ paint: {
134
+ 'line-color': 'hsl(0,0%,100%)',
135
+ 'line-width': {
136
+ stops: [
137
+ [11, 0],
138
+ [12, 5],
139
+ [13, 8],
140
+ [14, 14],
141
+ [15, 22],
142
+ [16, 38],
143
+ [17, 98],
144
+ [18, 158],
145
+ [20, 298]
146
+ ]
147
+ },
148
+ 'line-opacity': {
149
+ stops: [
150
+ [11, 0],
151
+ [12, 1]
152
+ ]
153
+ }
154
+ },
155
+ layout: {
156
+ 'line-join': 'round'
157
+ }
158
+ }
159
+ ].map((el) => {
160
+ return {
161
+ type: 'line',
162
+ 'source-layer': 'streets',
163
+ source: 'versatiles-osm',
164
+ ...el
165
+ } as Layer;
166
+ });
167
+
168
+ const transitBridges = [
169
+ {
170
+ id: 'bridge-transport-monorail:outline',
171
+ filter: ['all', ['in', 'kind', 'monorail'], ['!has', 'service'], ['==', 'bridge', true]],
172
+ minzoom: 15,
173
+ paint: {
174
+ 'line-color': rail_outline.line_color,
175
+ 'line-width': rail_outline.line_width
176
+ }
177
+ },
178
+ {
179
+ id: 'bridge-transport-funicular:outline',
180
+ filter: ['all', ['in', 'kind', 'funicular'], ['!has', 'service'], ['==', 'bridge', true]],
181
+ minzoom: 15,
182
+ paint: {
183
+ 'line-color': rail_outline.line_color,
184
+ 'line-width': rail_outline.line_width
185
+ }
186
+ },
187
+ {
188
+ id: 'bridge-transport-tram:outline',
189
+ filter: ['all', ['in', 'kind', 'tram'], ['!has', 'service'], ['==', 'bridge', true]],
190
+ minzoom: 15,
191
+ paint: {
192
+ 'line-color': rail_outline.line_color,
193
+ 'line-width': rail_outline.line_width
194
+ }
195
+ },
196
+ {
197
+ id: 'bridge-transport-narrowgauge:outline',
198
+ filter: ['all', ['in', 'kind', 'narrow_gauge'], ['!has', 'service'], ['==', 'bridge', true]],
199
+ minzoom: 15,
200
+ paint: {
201
+ 'line-color': rail_outline.line_color,
202
+ 'line-width': rail_outline.line_width
203
+ }
204
+ },
205
+ {
206
+ id: 'bridge-transport-lightrail:outline',
207
+ filter: ['all', ['in', 'kind', 'light_rail'], ['!has', 'service'], ['==', 'bridge', true]],
208
+ paint: {
209
+ 'line-color': rail_outline.line_color,
210
+ 'line-width': rail_outline.line_width,
211
+ 'line-opacity': rail_outline.line_opacity
212
+ }
213
+ },
214
+ {
215
+ id: 'bridge-transport-rail:outline',
216
+ filter: ['all', ['in', 'kind', 'rail'], ['!has', 'service'], ['==', 'bridge', true]],
217
+ paint: {
218
+ 'line-color': rail_outline.line_color,
219
+ 'line-width': rail_outline.line_width,
220
+ 'line-opacity': rail_outline.line_opacity
221
+ }
222
+ },
223
+ {
224
+ id: 'bridge-transport-monorail',
225
+ filter: ['all', ['in', 'kind', 'monorail'], ['!has', 'service'], ['==', 'bridge', true]],
226
+ minzoom: 13,
227
+ paint: {
228
+ 'line-width': rail.line_width,
229
+ 'line-color': rail.line_color
230
+ }
231
+ },
232
+ {
233
+ id: 'bridge-transport-funicular',
234
+ filter: ['all', ['in', 'kind', 'funicular'], ['!has', 'service'], ['==', 'bridge', true]],
235
+ minzoom: 13,
236
+ paint: {
237
+ 'line-width': rail.line_width,
238
+ 'line-color': rail.line_color
239
+ }
240
+ },
241
+ {
242
+ id: 'bridge-transport-tram',
243
+ filter: ['all', ['in', 'kind', 'tram'], ['!has', 'service'], ['==', 'bridge', true]],
244
+ minzoom: 13,
245
+ paint: {
246
+ 'line-width': rail.line_width,
247
+ 'line-color': rail.line_color
248
+ }
249
+ },
250
+ {
251
+ id: 'bridge-transport-narrowgauge',
252
+ filter: ['all', ['in', 'kind', 'narrow_gauge'], ['!has', 'service'], ['==', 'bridge', true]],
253
+ minzoom: 13,
254
+ paint: {
255
+ 'line-width': rail.line_width,
256
+ 'line-color': rail.line_color
257
+ }
258
+ },
259
+ {
260
+ id: 'bridge-transport-lightrail',
261
+ filter: ['all', ['in', 'kind', 'light_rail'], ['!has', 'service'], ['==', 'bridge', true]],
262
+ paint: {
263
+ 'line-color': rail.line_color,
264
+ 'line-width': rail.line_width,
265
+ 'line-opacity': rail.line_opacity
266
+ }
267
+ },
268
+ {
269
+ id: 'bridge-transport-rail',
270
+ filter: ['all', ['in', 'kind', 'rail'], ['!has', 'service'], ['==', 'bridge', true]],
271
+ paint: {
272
+ 'line-color': rail.line_color,
273
+ 'line-width': rail.line_width,
274
+ 'line-opacity': rail.line_opacity
275
+ }
276
+ }
277
+ ].map((el) => {
278
+ return {
279
+ type: 'line',
280
+ 'source-layer': 'streets',
281
+ source: 'versatiles-osm',
282
+ ...el
283
+ } as Layer;
284
+ });
285
+
286
+ const transitTunnels: Layer[] = [
287
+ {
288
+ id: 'tunnel-transport-monorail',
289
+ filter: ['all', ['in', 'kind', 'monorail'], ['!has', 'service'], ['==', 'tunnel', true]],
290
+ minzoom: 13,
291
+ paint: {
292
+ 'line-width': rail.line_width,
293
+ 'line-color': rail.line_color
294
+ }
295
+ },
296
+ {
297
+ id: 'tunnel-transport-funicular',
298
+ filter: ['all', ['in', 'kind', 'funicular'], ['!has', 'service'], ['==', 'tunnel', true]],
299
+ minzoom: 13,
300
+ paint: {
301
+ 'line-width': rail.line_width,
302
+ 'line-color': rail.line_color
303
+ }
304
+ },
305
+ {
306
+ id: 'tunnel-transport-tram',
307
+ filter: ['all', ['in', 'kind', 'tram'], ['!has', 'service'], ['==', 'tunnel', true]],
308
+ minzoom: 13,
309
+ paint: {
310
+ 'line-width': rail.line_width,
311
+ 'line-color': rail.line_color
312
+ }
313
+ },
314
+ {
315
+ id: 'tunnel-transport-narrowgauge',
316
+ filter: ['all', ['in', 'kind', 'narrow_gauge'], ['!has', 'service'], ['==', 'tunnel', true]],
317
+ minzoom: 13,
318
+ paint: {
319
+ 'line-width': rail.line_width,
320
+ 'line-color': rail.line_color
321
+ }
322
+ },
323
+ {
324
+ id: 'tunnel-transport-lightrail',
325
+ filter: ['all', ['in', 'kind', 'light_rail'], ['!has', 'service'], ['==', 'tunnel', true]],
326
+ paint: {
327
+ 'line-color': rail.line_color,
328
+ 'line-width': rail.line_width,
329
+ 'line-opacity': rail.line_opacity
330
+ }
331
+ },
332
+ {
333
+ id: 'tunnel-transport-rail',
334
+ filter: ['all', ['in', 'kind', 'rail'], ['!has', 'service'], ['==', 'tunnel', true]],
335
+ paint: {
336
+ 'line-color': rail.line_color,
337
+ 'line-width': rail.line_width,
338
+ 'line-opacity': rail.line_opacity
339
+ }
340
+ }
341
+ ].map((el) => {
342
+ return {
343
+ type: 'line',
344
+ 'source-layer': 'streets',
345
+ source: 'versatiles-osm',
346
+ ...el
347
+ } as Layer;
348
+ });
349
+ const transitSurface: Layer[] = [
350
+ {
351
+ id: 'transport-rail:dashes',
352
+ filter: [
353
+ 'all',
354
+ ['in', 'kind', 'rail'],
355
+ ['!has', 'service'],
356
+ ['!=', 'bridge', true],
357
+ ['!=', 'tunnel', true]
358
+ ],
359
+ paint: {
360
+ 'line-color': rail.line_color,
361
+ 'line-opacity': rail.line_opacity,
362
+ 'line-width': rail_overlay.line_width,
363
+ 'line-dasharray': rail_overlay.line_dasharray
364
+ }
365
+ },
366
+ {
367
+ id: 'transport-monorail',
368
+ filter: [
369
+ 'all',
370
+ ['in', 'kind', 'monorail'],
371
+ ['!has', 'service'],
372
+ ['!=', 'bridge', true],
373
+ ['!=', 'tunnel', true]
374
+ ],
375
+ minzoom: 13,
376
+ paint: {
377
+ 'line-width': {
378
+ stops: [
379
+ [13, 0],
380
+ [16, 1],
381
+ [17, 2],
382
+ [18, 3],
383
+ [20, 5]
384
+ ]
385
+ },
386
+ 'line-color': 'hsl(208,0%,73%)'
387
+ }
388
+ },
389
+ {
390
+ id: 'transport-funicular',
391
+ filter: [
392
+ 'all',
393
+ ['in', 'kind', 'funicular'],
394
+ ['!has', 'service'],
395
+ ['!=', 'bridge', true],
396
+ ['!=', 'tunnel', true]
397
+ ],
398
+ minzoom: 13,
399
+ paint: {
400
+ 'line-width': {
401
+ stops: [
402
+ [13, 0],
403
+ [16, 1],
404
+ [17, 2],
405
+ [18, 3],
406
+ [20, 5]
407
+ ]
408
+ },
409
+ 'line-color': 'hsl(208,0%,73%)'
410
+ }
411
+ },
412
+ {
413
+ id: 'transport-tram',
414
+ filter: [
415
+ 'all',
416
+ ['in', 'kind', 'tram'],
417
+ ['!has', 'service'],
418
+ ['!=', 'bridge', true],
419
+ ['!=', 'tunnel', true]
420
+ ],
421
+ minzoom: 13,
422
+ paint: {
423
+ 'line-width': rail.line_width,
424
+ 'line-color': rail.line_color
425
+ }
426
+ },
427
+ {
428
+ id: 'transport-narrowgauge',
429
+ filter: [
430
+ 'all',
431
+ ['in', 'kind', 'narrow_gauge'],
432
+ ['!has', 'service'],
433
+ ['!=', 'bridge', true],
434
+ ['!=', 'tunnel', true]
435
+ ],
436
+ minzoom: 13,
437
+ paint: {
438
+ 'line-width': rail.line_width,
439
+ 'line-color': rail.line_color
440
+ }
441
+ },
442
+ {
443
+ id: 'transport-lightrail',
444
+ filter: [
445
+ 'all',
446
+ ['in', 'kind', 'light_rail'],
447
+ ['!has', 'service'],
448
+ ['!=', 'bridge', true],
449
+ ['!=', 'tunnel', true]
450
+ ],
451
+ paint: {
452
+ 'line-color': rail.line_color,
453
+ 'line-width': rail.line_width,
454
+ 'line-opacity': {
455
+ stops: [
456
+ [14, 0],
457
+ [15, 1]
458
+ ]
459
+ }
460
+ }
461
+ },
462
+ {
463
+ id: 'transport-rail',
464
+ filter: [
465
+ 'all',
466
+ ['in', 'kind', 'rail'],
467
+ ['!has', 'service'],
468
+ ['!=', 'bridge', true],
469
+ ['!=', 'tunnel', true]
470
+ ],
471
+ paint: {
472
+ 'line-color': rail.line_color,
473
+ 'line-width': rail.line_width,
474
+ 'line-opacity': rail.line_opacity
475
+ }
476
+ },
477
+ {
478
+ id: 'transport-ferry',
479
+ minzoom: 10,
480
+ paint: {
481
+ 'line-color': 'rgb(184, 189, 207)',
482
+ 'line-width': {
483
+ stops: [
484
+ [10, 1],
485
+ [13, 2],
486
+ [14, 3],
487
+ [16, 4],
488
+ [17, 6]
489
+ ]
490
+ },
491
+ 'line-opacity': {
492
+ stops: [[10, 0]]
493
+ },
494
+ 'line-dasharray': [1, 1]
495
+ }
496
+ }
497
+ ].map((el) => {
498
+ return {
499
+ type: 'line',
500
+ 'source-layer': 'streets',
501
+ source: 'versatiles-osm',
502
+ ...el
503
+ } as Layer;
504
+ });
505
+
506
+ return { airports, transitBridges, transitSurface, transitTunnels };
507
+ }