@swr-data-lab/components 1.12.5 → 1.13.1
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/dist/Autocomplete/Autocomplete.stories.svelte.d.ts +27 -0
- package/dist/Autocomplete/Autocomplete.svelte +237 -0
- package/dist/Autocomplete/Autocomplete.svelte.d.ts +34 -0
- package/dist/Autocomplete/index.d.ts +2 -0
- package/dist/Button/Button.stories.svelte +19 -0
- package/dist/Button/Button.stories.svelte.d.ts +19 -0
- package/dist/Button/Button.svelte +38 -0
- package/dist/Button/Button.svelte.d.ts +10 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Caption/Caption.stories.svelte.d.ts +27 -0
- package/dist/Caption/Caption.svelte +21 -0
- package/dist/Caption/Caption.svelte.d.ts +8 -0
- package/dist/Caption/index.js +2 -0
- package/dist/Card/Card.stories.svelte +17 -0
- package/dist/Card/Card.stories.svelte.d.ts +19 -0
- package/dist/Card/Card.svelte +25 -0
- package/dist/Card/Card.svelte.d.ts +7 -0
- package/dist/Card/index.d.ts +2 -0
- package/dist/ChartFooter/ChartFooter.stories.svelte.d.ts +27 -0
- package/dist/ChartFooter/ChartFooter.svelte +38 -0
- package/dist/ChartFooter/ChartFooter.svelte.d.ts +8 -0
- package/dist/ChartFooter/index.d.ts +2 -0
- package/dist/ChartHeader/ChartHeader.stories.svelte.d.ts +27 -0
- package/{src → dist}/ChartHeader/ChartHeader.svelte +4 -12
- package/dist/ChartHeader/ChartHeader.svelte.d.ts +9 -0
- package/dist/ChartHeader/index.d.ts +2 -0
- package/dist/ChartList/ChartList.mdx +13 -0
- package/dist/ChartList/ChartList.stories.svelte +48 -0
- package/dist/ChartList/ChartList.stories.svelte.d.ts +27 -0
- package/dist/ChartList/ChartList.svelte +103 -0
- package/dist/ChartList/ChartList.svelte.d.ts +14 -0
- package/dist/ChartList/index.d.ts +2 -0
- package/dist/ChartList/index.js +2 -0
- package/dist/Copy/Copy.stories.svelte.d.ts +27 -0
- package/dist/Copy/Copy.svelte +21 -0
- package/dist/Copy/Copy.svelte.d.ts +8 -0
- package/dist/Copy/index.js +2 -0
- package/dist/DesignTokens/DesignTokens.svelte +58 -0
- package/dist/DesignTokens/DesignTokens.svelte.d.ts +7 -0
- package/dist/DesignTokens/Tokens.d.ts +26 -0
- package/dist/DesignTokens/Tokens.js +171 -0
- package/dist/DesignTokens/index.d.ts +8 -0
- package/dist/FormLabel/FormLabel.stories.svelte.d.ts +27 -0
- package/{src → dist}/FormLabel/FormLabel.svelte +2 -9
- package/dist/FormLabel/FormLabel.svelte.d.ts +9 -0
- package/dist/FormLabel/index.js +2 -0
- package/dist/Headline/Headline.stories.svelte.d.ts +27 -0
- package/{src → dist}/Headline/Headline.svelte +2 -7
- package/dist/Headline/Headline.svelte.d.ts +7 -0
- package/dist/Headline/index.js +2 -0
- package/{src → dist}/HighlightCard/HighlightCard.stories.svelte +7 -9
- package/dist/HighlightCard/HighlightCard.stories.svelte.d.ts +19 -0
- package/dist/HighlightCard/HighlightCard.svelte +54 -0
- package/dist/HighlightCard/HighlightCard.svelte.d.ts +9 -0
- package/dist/HighlightCard/index.d.ts +2 -0
- package/dist/Input/Input.svelte +32 -0
- package/dist/Input/Input.svelte.d.ts +23 -0
- package/dist/Input/index.d.ts +2 -0
- package/dist/Intro.mdx +7 -0
- package/dist/Logotype/Logotype.stories.svelte +14 -0
- package/dist/Logotype/Logotype.stories.svelte.d.ts +19 -0
- package/dist/Logotype/Logotype.svelte.d.ts +26 -0
- package/dist/Middot/Middot.stories.svelte +14 -0
- package/dist/Middot/Middot.stories.svelte.d.ts +19 -0
- package/dist/Middot/Middot.svelte.d.ts +26 -0
- package/dist/Middot/index.d.ts +2 -0
- package/dist/Note/Note.stories.svelte.d.ts +27 -0
- package/dist/Note/Note.svelte +28 -0
- package/dist/Note/Note.svelte.d.ts +7 -0
- package/dist/Note/index.js +2 -0
- package/{src → dist}/Select/Select.stories.svelte +12 -15
- package/dist/Select/Select.stories.svelte.d.ts +19 -0
- package/dist/Select/Select.svelte +39 -0
- package/dist/Select/Select.svelte.d.ts +4 -0
- package/{src/Select/Select.types.ts → dist/Select/Select.types.d.ts} +1 -2
- package/dist/Select/Select.types.js +1 -0
- package/dist/Select/SelectStoriesTemplate.svelte.d.ts +15 -0
- package/dist/Select/index.d.ts +2 -0
- package/dist/Switcher/Switcher.stories.svelte.d.ts +27 -0
- package/dist/Switcher/Switcher.svelte +111 -0
- package/dist/Switcher/Switcher.svelte.d.ts +21 -0
- package/dist/Switcher/index.d.ts +2 -0
- package/{src → dist}/app.d.ts +1 -1
- package/dist/assets/close-circle.svg.svelte.d.ts +26 -0
- package/dist/assets/grow.svg.svelte.d.ts +26 -0
- package/dist/assets/hand-pointer.svg.svelte.d.ts +26 -0
- package/dist/assets/shrink.svg.svelte.d.ts +26 -0
- package/dist/assets/tap.svg.svelte.d.ts +26 -0
- package/dist/assets/times-circle-solid.svg.svelte.d.ts +26 -0
- package/dist/index.d.ts +29 -0
- package/{src → dist}/index.js +3 -0
- package/dist/maplibre/AttributionControl/AttributionControl.stories.svelte +27 -0
- package/dist/maplibre/AttributionControl/AttributionControl.stories.svelte.d.ts +19 -0
- package/dist/maplibre/AttributionControl/AttributionControl.svelte +15 -0
- package/dist/maplibre/AttributionControl/AttributionControl.svelte.d.ts +8 -0
- package/dist/maplibre/AttributionControl/index.d.ts +2 -0
- package/dist/maplibre/GeocoderControl/GeocoderAPIs.d.ts +6 -0
- package/dist/maplibre/GeocoderControl/GeocoderAPIs.js +40 -0
- package/{src → dist}/maplibre/GeocoderControl/GeocoderControl.stories.svelte +10 -14
- package/dist/maplibre/GeocoderControl/GeocoderControl.stories.svelte.d.ts +19 -0
- package/dist/maplibre/GeocoderControl/GeocoderControl.svelte +25 -0
- package/dist/maplibre/GeocoderControl/GeocoderControl.svelte.d.ts +27 -0
- package/dist/maplibre/GeocoderControl/index.d.ts +2 -0
- package/dist/maplibre/Map/FallbackStyle.d.ts +3 -0
- package/dist/maplibre/Map/FallbackStyle.js +15 -0
- package/{src → dist}/maplibre/Map/Map.stories.svelte +19 -24
- package/dist/maplibre/Map/Map.stories.svelte.d.ts +19 -0
- package/dist/maplibre/Map/Map.svelte +91 -0
- package/dist/maplibre/Map/Map.svelte.d.ts +23 -0
- package/dist/maplibre/Map/index.d.ts +2 -0
- package/dist/maplibre/MapControl/MapControl.stories.svelte +46 -0
- package/dist/maplibre/MapControl/MapControl.stories.svelte.d.ts +19 -0
- package/dist/maplibre/MapControl/MapControl.svelte +29 -0
- package/dist/maplibre/MapControl/MapControl.svelte.d.ts +11 -0
- package/dist/maplibre/MapControl/index.d.ts +2 -0
- package/dist/maplibre/MapStyle/SWRDataLabLight.d.ts +3 -0
- package/dist/maplibre/MapStyle/SWRDataLabLight.js +60 -0
- package/{src → dist}/maplibre/MapStyle/SWRDataLabLight.stories.svelte +10 -12
- package/dist/maplibre/MapStyle/SWRDataLabLight.stories.svelte.d.ts +18 -0
- package/dist/maplibre/MapStyle/components/Admin.d.ts +1 -0
- package/dist/maplibre/MapStyle/components/Admin.js +170 -0
- package/dist/maplibre/MapStyle/components/Buildings.d.ts +1 -0
- package/dist/maplibre/MapStyle/components/Buildings.js +21 -0
- package/dist/maplibre/MapStyle/components/Landuse.d.ts +1 -0
- package/dist/maplibre/MapStyle/components/Landuse.js +497 -0
- package/dist/maplibre/MapStyle/components/Natural.d.ts +1 -0
- package/dist/maplibre/MapStyle/components/Natural.js +1 -0
- package/dist/maplibre/MapStyle/components/PlaceLabels.d.ts +4 -0
- package/dist/maplibre/MapStyle/components/PlaceLabels.js +194 -0
- package/dist/maplibre/MapStyle/components/Roads.d.ts +8 -0
- package/dist/maplibre/MapStyle/components/Roads.js +2327 -0
- package/dist/maplibre/MapStyle/components/Transit.d.ts +7 -0
- package/dist/maplibre/MapStyle/components/Transit.js +499 -0
- package/dist/maplibre/MapStyle/components/Walking.d.ts +1 -0
- package/dist/maplibre/MapStyle/components/Walking.js +1530 -0
- package/dist/maplibre/MapStyle/index.d.ts +2 -0
- package/dist/maplibre/MapStyle/tokens.d.ts +20 -0
- package/dist/maplibre/MapStyle/tokens.js +20 -0
- package/{src → dist}/maplibre/NavigationControl/NavigationControl.stories.svelte +9 -11
- package/dist/maplibre/NavigationControl/NavigationControl.stories.svelte.d.ts +19 -0
- package/dist/maplibre/NavigationControl/NavigationControl.svelte +9 -0
- package/dist/maplibre/NavigationControl/NavigationControl.svelte.d.ts +12 -0
- package/dist/maplibre/NavigationControl/index.d.ts +2 -0
- package/{src → dist}/maplibre/ScaleControl/ScaleControl.stories.svelte +10 -13
- package/dist/maplibre/ScaleControl/ScaleControl.stories.svelte.d.ts +19 -0
- package/dist/maplibre/ScaleControl/ScaleControl.svelte +9 -0
- package/dist/maplibre/ScaleControl/ScaleControl.svelte.d.ts +9 -0
- package/dist/maplibre/ScaleControl/index.d.ts +2 -0
- package/dist/maplibre/Source/MapSource.stories.svelte +7 -0
- package/dist/maplibre/Source/MapSource.stories.svelte.d.ts +19 -0
- package/dist/maplibre/Source/MapSource.svelte +43 -0
- package/dist/maplibre/Source/MapSource.svelte.d.ts +13 -0
- package/dist/maplibre/Source/index.d.ts +2 -0
- package/dist/maplibre/Source/source.d.ts +28 -0
- package/dist/maplibre/Source/source.js +76 -0
- package/{src → dist}/maplibre/Tooltip/Tooltip.stories.svelte +17 -23
- package/dist/maplibre/Tooltip/Tooltip.stories.svelte.d.ts +19 -0
- package/dist/maplibre/Tooltip/Tooltip.svelte +46 -0
- package/dist/maplibre/Tooltip/Tooltip.svelte.d.ts +25 -0
- package/dist/maplibre/Tooltip/index.d.ts +2 -0
- package/{src → dist}/maplibre/VectorLayer/VectorLayer.stories.svelte +11 -14
- package/dist/maplibre/VectorLayer/VectorLayer.stories.svelte.d.ts +19 -0
- package/dist/maplibre/VectorLayer/VectorLayer.svelte +73 -0
- package/dist/maplibre/VectorLayer/VectorLayer.svelte.d.ts +21 -0
- package/dist/maplibre/VectorLayer/index.d.ts +2 -0
- package/{src → dist}/maplibre/VectorTileSource/VectorTileSource.stories.svelte +11 -13
- package/dist/maplibre/VectorTileSource/VectorTileSource.stories.svelte.d.ts +19 -0
- package/dist/maplibre/VectorTileSource/VectorTileSource.svelte +13 -0
- package/dist/maplibre/VectorTileSource/VectorTileSource.svelte.d.ts +11 -0
- package/dist/maplibre/VectorTileSource/index.d.ts +2 -0
- package/dist/maplibre/WithLinkLocation/WithLinkLocation.stories.svelte +27 -0
- package/dist/maplibre/WithLinkLocation/WithLinkLocation.stories.svelte.d.ts +19 -0
- package/dist/maplibre/WithLinkLocation/WithLinkLocation.svelte +44 -0
- package/dist/maplibre/WithLinkLocation/WithLinkLocation.svelte.d.ts +19 -0
- package/dist/maplibre/WithLinkLocation/index.d.ts +2 -0
- package/dist/maplibre/context.svelte.d.ts +33 -0
- package/dist/maplibre/context.svelte.js +73 -0
- package/{src/maplibre/types.ts → dist/maplibre/types.d.ts} +3 -5
- package/dist/maplibre/types.js +1 -0
- package/dist/maplibre/utils.d.ts +4 -0
- package/dist/maplibre/utils.js +34 -0
- package/dist/utils/formatDate.d.ts +5 -0
- package/dist/utils/formatDate.js +17 -0
- package/dist/utils/formatNumber.d.ts +18 -0
- package/{src → dist}/utils/formatNumber.js +5 -5
- package/dist/utils/getColorsBetween.d.ts +9 -0
- package/dist/utils/getColorsBetween.js +25 -0
- package/dist/utils/getComparisonDiffs.d.ts +6 -0
- package/dist/utils/getComparisonDiffs.js +9 -0
- package/dist/utils/getEmbedContext.d.ts +7 -0
- package/dist/utils/getEmbedContext.js +27 -0
- package/dist/utils/getLaenderFromTopo.d.ts +10 -0
- package/dist/utils/getLaenderFromTopo.js +35 -0
- package/dist/utils/getLaenderNicenameFromAgs.d.ts +7 -0
- package/dist/utils/getLaenderNicenameFromAgs.js +27 -0
- package/dist/utils/isSvelteComponent.d.ts +7 -0
- package/{src → dist}/utils/isSvelteComponent.js +1 -1
- package/dist/utils/prepareSophoraModel.d.ts +2 -0
- package/dist/utils/prepareSophoraModel.js +37 -0
- package/dist/utils/scrollIntoViewWithOffset.d.ts +7 -0
- package/{src → dist}/utils/scrollIntoViewWithOffset.js +3 -3
- package/dist/utils/slugify.d.ts +1 -0
- package/dist/utils/slugify.js +11 -0
- package/dist/utils/topoToGeo.d.ts +7 -0
- package/{src → dist}/utils/topoToGeo.js +2 -2
- package/package.json +30 -7
- package/.storybook/blocks/Mermaid.jsx +0 -9
- package/.storybook/main.ts +0 -34
- package/.storybook/preview-head.html +0 -13
- package/.storybook/preview.ts +0 -47
- package/.storybook/vitest.setup.ts +0 -9
- package/src/Autocomplete/Autocomplete.svelte +0 -237
- package/src/Button/Button.stories.svelte +0 -21
- package/src/Button/Button.svelte +0 -52
- package/src/Caption/Caption.svelte +0 -29
- package/src/Card/Card.stories.svelte +0 -19
- package/src/Card/Card.svelte +0 -34
- package/src/ChartFooter/ChartFooter.svelte +0 -46
- package/src/Copy/Copy.svelte +0 -29
- package/src/DesignTokens/DesignTokens.svelte +0 -71
- package/src/DesignTokens/Tokens.ts +0 -186
- package/src/HighlightCard/HighlightCard.svelte +0 -65
- package/src/Input/Input.svelte +0 -21
- package/src/Intro.mdx +0 -7
- package/src/Logotype/Logotype.stories.svelte +0 -16
- package/src/Middot/Middot.stories.svelte +0 -16
- package/src/Note/Note.svelte +0 -38
- package/src/Select/Select.svelte +0 -76
- package/src/Switcher/Switcher.svelte +0 -130
- package/src/maplibre/AttributionControl/AttributionControl.stories.svelte +0 -29
- package/src/maplibre/AttributionControl/AttributionControl.svelte +0 -45
- package/src/maplibre/GeocoderControl/GeocoderAPIs.ts +0 -49
- package/src/maplibre/GeocoderControl/GeocoderControl.svelte +0 -211
- package/src/maplibre/Map/FallbackStyle.ts +0 -18
- package/src/maplibre/Map/Map.svelte +0 -287
- package/src/maplibre/MapControl/MapControl.stories.svelte +0 -56
- package/src/maplibre/MapControl/MapControl.svelte +0 -41
- package/src/maplibre/MapStyle/SWRDataLabLight.ts +0 -72
- package/src/maplibre/MapStyle/components/Admin.ts +0 -173
- package/src/maplibre/MapStyle/components/Buildings.ts +0 -23
- package/src/maplibre/MapStyle/components/Landuse.ts +0 -499
- package/src/maplibre/MapStyle/components/Natural.ts +0 -1
- package/src/maplibre/MapStyle/components/PlaceLabels.ts +0 -199
- package/src/maplibre/MapStyle/components/Roads.ts +0 -2345
- package/src/maplibre/MapStyle/components/Transit.ts +0 -507
- package/src/maplibre/MapStyle/components/Walking.ts +0 -1538
- package/src/maplibre/MapStyle/tokens.ts +0 -21
- package/src/maplibre/NavigationControl/NavigationControl.svelte +0 -36
- package/src/maplibre/ScaleControl/ScaleControl.svelte +0 -25
- package/src/maplibre/Source/MapSource.stories.svelte +0 -9
- package/src/maplibre/Source/MapSource.svelte +0 -61
- package/src/maplibre/Source/source.ts +0 -89
- package/src/maplibre/Tooltip/Tooltip.svelte +0 -183
- package/src/maplibre/VectorLayer/VectorLayer.svelte +0 -142
- package/src/maplibre/VectorTileSource/VectorTileSource.svelte +0 -24
- package/src/maplibre/WithLinkLocation/WithLinkLocation.stories.svelte +0 -29
- package/src/maplibre/WithLinkLocation/WithLinkLocation.svelte +0 -83
- package/src/maplibre/context.svelte.ts +0 -89
- package/src/maplibre/utils.ts +0 -52
- package/src/utils/formatDate.js +0 -17
- package/src/utils/getColorsBetween.js +0 -25
- package/src/utils/getComparisonDiffs.js +0 -9
- package/src/utils/getEmbedContext.js +0 -28
- package/src/utils/getLaenderFromTopo.js +0 -35
- package/src/utils/getLaenderNicenameFromAgs.js +0 -27
- package/src/utils/prepareSophoraModel.js +0 -31
- package/src/utils/slugify.ts +0 -12
- package/static/favicon.png +0 -0
- package/svelte.config.js +0 -18
- package/tsconfig.json +0 -19
- package/vite.config.ts +0 -6
- package/vitest.workspace.ts +0 -32
- /package/{src → dist}/Autocomplete/Autocomplete.stories.svelte +0 -0
- /package/{src → dist}/Autocomplete/index.js +0 -0
- /package/{src → dist}/Button/index.js +0 -0
- /package/{src → dist}/Caption/Caption.stories.svelte +0 -0
- /package/{src/Caption/index.ts → dist/Caption/index.d.ts} +0 -0
- /package/{src → dist}/Card/index.js +0 -0
- /package/{src → dist}/ChartFooter/ChartFooter.mdx +0 -0
- /package/{src → dist}/ChartFooter/ChartFooter.stories.svelte +0 -0
- /package/{src → dist}/ChartFooter/index.js +0 -0
- /package/{src → dist}/ChartHeader/ChartHeader.mdx +0 -0
- /package/{src → dist}/ChartHeader/ChartHeader.stories.svelte +0 -0
- /package/{src → dist}/ChartHeader/index.js +0 -0
- /package/{src → dist}/Copy/Copy.stories.svelte +0 -0
- /package/{src/Copy/index.ts → dist/Copy/index.d.ts} +0 -0
- /package/{src → dist}/DesignTokens/DesignTokens.mdx +0 -0
- /package/{src → dist}/DesignTokens/index.js +0 -0
- /package/{src → dist}/FormLabel/FormLabel.mdx +0 -0
- /package/{src → dist}/FormLabel/FormLabel.stories.svelte +0 -0
- /package/{src/FormLabel/index.ts → dist/FormLabel/index.d.ts} +0 -0
- /package/{src → dist}/Headline/Headline.stories.svelte +0 -0
- /package/{src/Headline/index.ts → dist/Headline/index.d.ts} +0 -0
- /package/{src → dist}/HighlightCard/index.js +0 -0
- /package/{src → dist}/Input/index.js +0 -0
- /package/{src → dist}/Logotype/Logotype.svelte +0 -0
- /package/{src → dist}/Middot/Middot.svelte +0 -0
- /package/{src → dist}/Middot/index.js +0 -0
- /package/{src → dist}/Note/Note.stories.svelte +0 -0
- /package/{src/Note/index.ts → dist/Note/index.d.ts} +0 -0
- /package/{src → dist}/Select/Select.mdx +0 -0
- /package/{src → dist}/Select/SelectStoriesTemplate.svelte +0 -0
- /package/{src → dist}/Select/index.js +0 -0
- /package/{src → dist}/Select/mock_data/jobs.json +0 -0
- /package/{src → dist}/Switcher/Switcher.mdx +0 -0
- /package/{src → dist}/Switcher/Switcher.stories.svelte +0 -0
- /package/{src → dist}/Switcher/index.js +0 -0
- /package/{src → dist}/app.html +0 -0
- /package/{src → dist}/assets/close-circle.svg.svelte +0 -0
- /package/{src → dist}/assets/grow.svg.svelte +0 -0
- /package/{src → dist}/assets/hand-pointer.svg.svelte +0 -0
- /package/{src → dist}/assets/shrink.svg.svelte +0 -0
- /package/{src → dist}/assets/tap.svg.svelte +0 -0
- /package/{src → dist}/assets/times-circle-solid.svg.svelte +0 -0
- /package/{src → dist}/maplibre/AttributionControl/index.js +0 -0
- /package/{src → dist}/maplibre/GeocoderControl/index.js +0 -0
- /package/{src → dist}/maplibre/Map/index.js +0 -0
- /package/{src → dist}/maplibre/MapControl/MapControl.mdx +0 -0
- /package/{src → dist}/maplibre/MapControl/index.js +0 -0
- /package/{src → dist}/maplibre/MapStyle/SWRDataLabLight.mdx +0 -0
- /package/{src → dist}/maplibre/MapStyle/index.js +0 -0
- /package/{src → dist}/maplibre/Maplibre.mdx +0 -0
- /package/{src → dist}/maplibre/NavigationControl/index.js +0 -0
- /package/{src → dist}/maplibre/ScaleControl/index.js +0 -0
- /package/{src → dist}/maplibre/Source/index.js +0 -0
- /package/{src → dist}/maplibre/Tooltip/index.js +0 -0
- /package/{src → dist}/maplibre/VectorLayer/index.js +0 -0
- /package/{src → dist}/maplibre/VectorTileSource/VectorTileSource.mdx +0 -0
- /package/{src → dist}/maplibre/VectorTileSource/index.js +0 -0
- /package/{src → dist}/maplibre/WithLinkLocation/WithLinkLocation.mdx +0 -0
- /package/{src → dist}/maplibre/WithLinkLocation/index.js +0 -0
- /package/{src → dist}/styles/base.scss +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts">import { getMapContext } from '../context.svelte.js';
|
|
2
|
+
import { onDestroy } from 'svelte';
|
|
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();
|
|
5
|
+
const { map, styleLoaded } = $derived(getMapContext());
|
|
6
|
+
let beforeId = $state();
|
|
7
|
+
let prevSelected = $state();
|
|
8
|
+
let prevHovered = $state();
|
|
9
|
+
const layerSpec = {
|
|
10
|
+
id,
|
|
11
|
+
type,
|
|
12
|
+
source: sourceId,
|
|
13
|
+
'source-layer': sourceLayer,
|
|
14
|
+
layout: $state.snapshot(layout) ?? {},
|
|
15
|
+
paint: $state.snapshot(paint) ?? {},
|
|
16
|
+
minzoom: minZoom,
|
|
17
|
+
maxzoom: maxZoom
|
|
18
|
+
};
|
|
19
|
+
$effect(() => {
|
|
20
|
+
if (map && styleLoaded) {
|
|
21
|
+
const style = map.getStyle();
|
|
22
|
+
beforeId = style.layers.find((l) => {
|
|
23
|
+
return l.id === placeBelow;
|
|
24
|
+
})?.id;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
$effect(() => {
|
|
28
|
+
if (map && styleLoaded && beforeId) {
|
|
29
|
+
map.addLayer(layerSpec, beforeId);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
$effect(() => resetLayerEventListener(map, 'click', id, onclick));
|
|
33
|
+
$effect(() => resetLayerEventListener(map, 'mousemove', id, onmousemove));
|
|
34
|
+
$effect(() => resetLayerEventListener(map, 'mouseleave', id, onmouseleave));
|
|
35
|
+
// Set hovered feature state
|
|
36
|
+
$effect(() => {
|
|
37
|
+
if (styleLoaded) {
|
|
38
|
+
if (hovered) {
|
|
39
|
+
if (prevHovered) {
|
|
40
|
+
map?.setFeatureState({ source: sourceId, sourceLayer: sourceLayer, id: prevHovered }, { hovered: false });
|
|
41
|
+
}
|
|
42
|
+
map?.setFeatureState({ source: sourceId, sourceLayer: sourceLayer, id: hovered.id }, { hovered: true });
|
|
43
|
+
prevHovered = hovered.id;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (prevHovered) {
|
|
47
|
+
map?.setFeatureState({ source: sourceId, sourceLayer: sourceLayer, id: prevHovered }, { hovered: false });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// Set selected feature state
|
|
53
|
+
$effect(() => {
|
|
54
|
+
if (styleLoaded) {
|
|
55
|
+
if (selected) {
|
|
56
|
+
if (prevSelected) {
|
|
57
|
+
map?.setFeatureState({ source: sourceId, sourceLayer: sourceLayer, id: prevSelected }, { selected: false });
|
|
58
|
+
}
|
|
59
|
+
map?.setFeatureState({ source: sourceId, sourceLayer: sourceLayer, id: selected.id }, { selected: true });
|
|
60
|
+
prevSelected = selected.id;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (prevSelected) {
|
|
64
|
+
map?.setFeatureState({ source: sourceId, sourceLayer: sourceLayer, id: prevSelected }, { selected: false });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
onDestroy(() => {
|
|
70
|
+
if (map && map.getLayer(id))
|
|
71
|
+
map.removeLayer(id);
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CircleLayoutProps, CirclePaintProps, FillLayoutProps, FillPaintProps, LineLayoutProps, SymbolPaintProps, SymbolLayoutProps, LinePaintProps, MapGeoJSONFeature, MapLayerMouseEvent } from 'maplibre-gl';
|
|
2
|
+
interface VectorLayerProps {
|
|
3
|
+
id: string;
|
|
4
|
+
sourceId: string;
|
|
5
|
+
sourceLayer: string;
|
|
6
|
+
type: 'line' | 'fill' | 'circle' | 'symbol';
|
|
7
|
+
placeBelow: string;
|
|
8
|
+
visible?: boolean;
|
|
9
|
+
minZoom?: number;
|
|
10
|
+
maxZoom?: number;
|
|
11
|
+
paint?: LinePaintProps | FillPaintProps | CirclePaintProps | SymbolPaintProps;
|
|
12
|
+
layout?: LineLayoutProps | FillLayoutProps | CircleLayoutProps | SymbolLayoutProps;
|
|
13
|
+
hovered?: MapGeoJSONFeature | undefined;
|
|
14
|
+
selected?: MapGeoJSONFeature | undefined;
|
|
15
|
+
onclick: (e: MapLayerMouseEvent) => any;
|
|
16
|
+
onmousemove: (e: MapLayerMouseEvent) => any;
|
|
17
|
+
onmouseleave: (e: MapLayerMouseEvent) => any;
|
|
18
|
+
}
|
|
19
|
+
declare const VectorLayer: import("svelte").Component<VectorLayerProps, {}, "hovered" | "selected">;
|
|
20
|
+
type VectorLayer = ReturnType<typeof VectorLayer>;
|
|
21
|
+
export default VectorLayer;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
component: VectorTileSource
|
|
13
|
-
});
|
|
1
|
+
<script context="module" lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import DesignTokens from '../../DesignTokens/DesignTokens.svelte';
|
|
3
|
+
import VectorTileSource from './VectorTileSource.svelte';
|
|
4
|
+
import VectorLayer from '../VectorLayer/VectorLayer.svelte';
|
|
5
|
+
import Map from '../Map/Map.svelte';
|
|
6
|
+
import { SWRDataLabLight } from '../MapStyle/';
|
|
7
|
+
import AttributionControl from '../AttributionControl';
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Maplibre/Source/VectorTileSource',
|
|
10
|
+
component: VectorTileSource
|
|
11
|
+
});
|
|
14
12
|
</script>
|
|
15
13
|
|
|
16
14
|
<Story asChild name="Default">
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import VectorTileSource from './VectorTileSource.svelte';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const VectorTileSource: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type VectorTileSource = InstanceType<typeof VectorTileSource>;
|
|
19
|
+
export default VectorTileSource;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">import {} from 'svelte';
|
|
2
|
+
import {} from 'maplibre-gl';
|
|
3
|
+
import MapSource from '../Source/MapSource.svelte';
|
|
4
|
+
const { minZoom = 0, maxZoom = 24, id, url } = $props();
|
|
5
|
+
const sourceSpec = {
|
|
6
|
+
type: 'vector',
|
|
7
|
+
tiles: [url],
|
|
8
|
+
maxzoom: maxZoom,
|
|
9
|
+
minzoom: minZoom
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<MapSource {id} {sourceSpec} />
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
interface VectorTileSourceProps {
|
|
3
|
+
id: string;
|
|
4
|
+
url: string;
|
|
5
|
+
minZoom?: number;
|
|
6
|
+
maxZoom?: number;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
}
|
|
9
|
+
declare const VectorTileSource: import("svelte").Component<VectorTileSourceProps, {}, "">;
|
|
10
|
+
type VectorTileSource = ReturnType<typeof VectorTileSource>;
|
|
11
|
+
export default VectorTileSource;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script context="module" lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import WithLinkLocation from './WithLinkLocation.svelte';
|
|
3
|
+
import DesignTokens from '../../DesignTokens/DesignTokens.svelte';
|
|
4
|
+
import Map from '../Map/Map.svelte';
|
|
5
|
+
import { SWRDataLabLight } from '../MapStyle';
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: 'Maplibre/Extras/WithLinkLocation',
|
|
8
|
+
component: WithLinkLocation
|
|
9
|
+
});
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Story asChild name="Default">
|
|
13
|
+
<DesignTokens>
|
|
14
|
+
<div class="container">
|
|
15
|
+
<WithLinkLocation countries="de" languages="de" service="maptiler" key="V32kPHZjMa0Mkn6YvSzA">
|
|
16
|
+
<Map style={SWRDataLabLight} initialLocation={{ lat: 51, lng: 10, zoom: 20 }}></Map>
|
|
17
|
+
</WithLinkLocation>
|
|
18
|
+
</div>
|
|
19
|
+
</DesignTokens>
|
|
20
|
+
</Story>
|
|
21
|
+
|
|
22
|
+
<style>
|
|
23
|
+
.container {
|
|
24
|
+
width: 500px;
|
|
25
|
+
height: 300px;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import WithLinkLocation from './WithLinkLocation.svelte';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const WithLinkLocation: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type WithLinkLocation = InstanceType<typeof WithLinkLocation>;
|
|
19
|
+
export default WithLinkLocation;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">import { onMount, setContext } from 'svelte';
|
|
2
|
+
import { MaptilerGeocoderAPI } from '../GeocoderControl/GeocoderAPIs';
|
|
3
|
+
import {} from '../types';
|
|
4
|
+
const { key, service = 'maptiler', countries = 'de', languages = 'de', urlParameter = 'location', children } = $props();
|
|
5
|
+
const countriesArr = Array.isArray(countries) ? countries : [countries];
|
|
6
|
+
const languagesArr = Array.isArray(languages) ? languages : [languages];
|
|
7
|
+
let geocoder;
|
|
8
|
+
if (service === 'maptiler') {
|
|
9
|
+
geocoder = new MaptilerGeocoderAPI(key);
|
|
10
|
+
}
|
|
11
|
+
let location = $state();
|
|
12
|
+
function bboxToArea(bbox) {
|
|
13
|
+
return (bbox[2] - bbox[0]) * (bbox[3] - bbox[1]);
|
|
14
|
+
}
|
|
15
|
+
onMount(async () => {
|
|
16
|
+
const params = new URLSearchParams(window.location.search);
|
|
17
|
+
if (params.has(urlParameter)) {
|
|
18
|
+
const config = {
|
|
19
|
+
countries: countriesArr.join(','),
|
|
20
|
+
language: languagesArr.join(','),
|
|
21
|
+
query: params.get(urlParameter)?.toString(),
|
|
22
|
+
limit: 1
|
|
23
|
+
};
|
|
24
|
+
const res = await geocoder.forwardGeocode(config);
|
|
25
|
+
if (res.features[0].bbox && res.features[0].geometry.type === 'Point') {
|
|
26
|
+
location = {
|
|
27
|
+
lat: res.features[0].geometry.coordinates[1],
|
|
28
|
+
lng: res.features[0].geometry.coordinates[0],
|
|
29
|
+
zoom: 11 - bboxToArea(res.features[0].bbox) * 5.5
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
location = false;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
$effect.pre(() => {
|
|
38
|
+
setContext('initialLocation', location);
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
{#if location !== undefined}
|
|
43
|
+
{@render children?.()}
|
|
44
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import { type GeocodingCountry, type GeocodingLanguage, type GeocodingService } from '../types';
|
|
3
|
+
interface WithLinkLocationProps {
|
|
4
|
+
service?: GeocodingService;
|
|
5
|
+
/**
|
|
6
|
+
* API key for selected geocoding `service`
|
|
7
|
+
*/
|
|
8
|
+
key: string;
|
|
9
|
+
/**
|
|
10
|
+
* Limit search to one or more countries
|
|
11
|
+
*/
|
|
12
|
+
countries?: GeocodingLanguage | GeocodingCountry[];
|
|
13
|
+
languages?: GeocodingLanguage | GeocodingLanguage[];
|
|
14
|
+
urlParameter?: string;
|
|
15
|
+
children: Snippet;
|
|
16
|
+
}
|
|
17
|
+
declare const WithLinkLocation: import("svelte").Component<WithLinkLocationProps, {}, "">;
|
|
18
|
+
type WithLinkLocation = ReturnType<typeof WithLinkLocation>;
|
|
19
|
+
export default WithLinkLocation;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Map as MapLibre, Marker, LayerSpecification } from 'maplibre-gl';
|
|
2
|
+
export declare class Box<T> {
|
|
3
|
+
value: T;
|
|
4
|
+
constructor(initialValue: T);
|
|
5
|
+
}
|
|
6
|
+
export declare class MapContext {
|
|
7
|
+
_map: MapLibre | null;
|
|
8
|
+
minzoom: number;
|
|
9
|
+
maxzoom: number;
|
|
10
|
+
styleLoaded: boolean;
|
|
11
|
+
private _listener?;
|
|
12
|
+
get map(): maplibregl.Map | null;
|
|
13
|
+
set map(value: maplibregl.Map | null);
|
|
14
|
+
private _onstyledata;
|
|
15
|
+
}
|
|
16
|
+
export declare class SourceContext {
|
|
17
|
+
_source: unknown;
|
|
18
|
+
loaded: boolean;
|
|
19
|
+
minzoom: number;
|
|
20
|
+
maxzoom: number;
|
|
21
|
+
get source(): unknown;
|
|
22
|
+
}
|
|
23
|
+
export declare class LayerContext {
|
|
24
|
+
layer: LayerSpecification;
|
|
25
|
+
}
|
|
26
|
+
export declare function setPopupTarget(value: Box<Marker | string | undefined>): void;
|
|
27
|
+
export declare function getPopupTarget(): Box<Marker | string> | undefined;
|
|
28
|
+
export declare function createMapContext(): MapContext;
|
|
29
|
+
export declare function getMapContext(): MapContext;
|
|
30
|
+
export declare function createSourceContext(): SourceContext;
|
|
31
|
+
export declare function getSourceContext(): SourceContext;
|
|
32
|
+
export declare function getLayerContext(): LayerContext;
|
|
33
|
+
export declare function setLayerContext(value: string): void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const MAP_CONTEXT_KEY = Symbol.for('map-context');
|
|
3
|
+
const SOURCE_CONTEXT_KEY = Symbol.for('source-context');
|
|
4
|
+
const LAYER_CONTEXT_KEY = Symbol.for('layer-context');
|
|
5
|
+
const POPUP_TARGET_KEY = Symbol.for('popup-target');
|
|
6
|
+
export class Box {
|
|
7
|
+
value = $state();
|
|
8
|
+
constructor(initialValue) {
|
|
9
|
+
this.value = initialValue;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class MapContext {
|
|
13
|
+
_map = $state(null);
|
|
14
|
+
minzoom = $state(0);
|
|
15
|
+
maxzoom = $state(24);
|
|
16
|
+
styleLoaded = $state(false);
|
|
17
|
+
_listener = undefined;
|
|
18
|
+
get map() {
|
|
19
|
+
return this._map;
|
|
20
|
+
}
|
|
21
|
+
set map(value) {
|
|
22
|
+
// Unbind any old event listeners
|
|
23
|
+
if (this._listener) {
|
|
24
|
+
this._map?.off('styledata', this._listener);
|
|
25
|
+
this._listener = undefined;
|
|
26
|
+
}
|
|
27
|
+
// Set new map instance and bind new event listeners
|
|
28
|
+
this._map = value;
|
|
29
|
+
if (this._map) {
|
|
30
|
+
this._listener = this._onstyledata.bind(this);
|
|
31
|
+
this._map.on('styledata', this._listener);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_onstyledata(e) {
|
|
35
|
+
this.styleLoaded = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class SourceContext {
|
|
39
|
+
_source = $state();
|
|
40
|
+
loaded = $state(false);
|
|
41
|
+
minzoom = $state(0);
|
|
42
|
+
maxzoom = $state(24);
|
|
43
|
+
get source() {
|
|
44
|
+
return this._source;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class LayerContext {
|
|
48
|
+
layer = $state();
|
|
49
|
+
}
|
|
50
|
+
export function setPopupTarget(value) {
|
|
51
|
+
setContext(POPUP_TARGET_KEY, value);
|
|
52
|
+
}
|
|
53
|
+
export function getPopupTarget() {
|
|
54
|
+
return getContext(POPUP_TARGET_KEY);
|
|
55
|
+
}
|
|
56
|
+
export function createMapContext() {
|
|
57
|
+
return setContext(MAP_CONTEXT_KEY, new MapContext());
|
|
58
|
+
}
|
|
59
|
+
export function getMapContext() {
|
|
60
|
+
return getContext(MAP_CONTEXT_KEY);
|
|
61
|
+
}
|
|
62
|
+
export function createSourceContext() {
|
|
63
|
+
return setContext(SOURCE_CONTEXT_KEY, new SourceContext());
|
|
64
|
+
}
|
|
65
|
+
export function getSourceContext() {
|
|
66
|
+
return getContext(SOURCE_CONTEXT_KEY);
|
|
67
|
+
}
|
|
68
|
+
export function getLayerContext() {
|
|
69
|
+
return getContext(LAYER_CONTEXT_KEY);
|
|
70
|
+
}
|
|
71
|
+
export function setLayerContext(value) {
|
|
72
|
+
setContext(LAYER_CONTEXT_KEY, value);
|
|
73
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { FillLayerSpecification, LineLayerSpecification } from 'maplibre-gl';
|
|
2
|
-
|
|
3
2
|
export type Layer = LineLayerSpecification | FillLayerSpecification;
|
|
4
3
|
export type GeocodingService = 'maptiler';
|
|
5
4
|
export type GeocodingCountry = 'de' | 'at';
|
|
6
5
|
export type GeocodingLanguage = 'de' | 'en';
|
|
7
|
-
|
|
8
6
|
export interface Location {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
lat: number;
|
|
8
|
+
lng: number;
|
|
9
|
+
zoom: number;
|
|
12
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Evented, Listener, Map, MapLayerEventType, Popup } from 'maplibre-gl';
|
|
2
|
+
export declare function resetEventListener(evented: Evented | null | undefined, type: string, listener: Listener | undefined): () => void;
|
|
3
|
+
export declare function resetLayerEventListener(map: Map | null, type: keyof MapLayerEventType, layer: string, listener: Listener | undefined): () => void;
|
|
4
|
+
export declare function resetPopupEventListener(popup: Popup | null, type: 'open' | 'close', listener: Listener | undefined): () => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Source: https://github.com/MIERUNE/svelte-maplibre-gl/blob/main/src/lib/maplibre/utils.ts
|
|
2
|
+
export function resetEventListener(evented, type, listener) {
|
|
3
|
+
if (listener) {
|
|
4
|
+
evented?.on(type, listener);
|
|
5
|
+
}
|
|
6
|
+
const prevListener = listener;
|
|
7
|
+
return () => {
|
|
8
|
+
if (prevListener) {
|
|
9
|
+
evented?.off(type, prevListener);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function resetLayerEventListener(map, type, layer, listener) {
|
|
14
|
+
if (listener) {
|
|
15
|
+
map?.on(type, layer, listener);
|
|
16
|
+
}
|
|
17
|
+
const prevListener = listener;
|
|
18
|
+
return () => {
|
|
19
|
+
if (prevListener) {
|
|
20
|
+
map?.off(type, layer, prevListener);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function resetPopupEventListener(popup, type, listener) {
|
|
25
|
+
if (listener) {
|
|
26
|
+
popup?.on(type, listener);
|
|
27
|
+
}
|
|
28
|
+
const prevListener = listener;
|
|
29
|
+
return () => {
|
|
30
|
+
if (prevListener) {
|
|
31
|
+
popup?.off(type, prevListener);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { timeFormat } from 'd3-time-format';
|
|
2
|
+
|
|
3
|
+
const formats = {
|
|
4
|
+
dayMonthYear: '%-d.%-m.%Y',
|
|
5
|
+
dayMonth: '%-d.%-m.',
|
|
6
|
+
dayMonthYearShort: '%-d.%-m.%y',
|
|
7
|
+
dayMonthHourMinute: '%-d.%-m., %-H.%M Uhr',
|
|
8
|
+
dayMonthYearHourMinute: '%-d.%-m.%Y, %-H.%M Uhr',
|
|
9
|
+
hourMinuteSophora: '%-H:%M Uhr',
|
|
10
|
+
hourMinute: '%-H.%M'
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const formatDate = ({ date, format = 'dayMonthYear' }) => {
|
|
14
|
+
return timeFormat(formats[format] || format)(new Date(date));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default formatDate;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const defaultFormat: ",.1f";
|
|
2
|
+
export namespace defaultLocale {
|
|
3
|
+
let decimal: string;
|
|
4
|
+
let thousands: string;
|
|
5
|
+
let grouping: number[];
|
|
6
|
+
let currency: string[];
|
|
7
|
+
}
|
|
8
|
+
declare function _default({ number, format, locale }: {
|
|
9
|
+
number: any;
|
|
10
|
+
format?: string | undefined;
|
|
11
|
+
locale?: {
|
|
12
|
+
decimal: string;
|
|
13
|
+
thousands: string;
|
|
14
|
+
grouping: number[];
|
|
15
|
+
currency: string[];
|
|
16
|
+
} | undefined;
|
|
17
|
+
}): string;
|
|
18
|
+
export default _default;
|
|
@@ -2,12 +2,12 @@ import { formatLocale } from 'd3-format';
|
|
|
2
2
|
|
|
3
3
|
export const defaultFormat = ',.1f';
|
|
4
4
|
export const defaultLocale = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
decimal: ',',
|
|
6
|
+
thousands: ' ',
|
|
7
|
+
grouping: [3],
|
|
8
|
+
currency: ['', '€']
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export default formatNumber = ({ number, format = defaultFormat, locale = defaultLocale }) => {
|
|
12
|
-
|
|
12
|
+
return formatLocale(locale).format(format)(number);
|
|
13
13
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Color from 'color';
|
|
2
|
+
import { range } from 'd3-array';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get color range of n colors
|
|
6
|
+
* @param {*} from
|
|
7
|
+
* @param {*} to
|
|
8
|
+
* @param {*} props
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const getColorsBetween = (from, to, props = { n: 1, includeFromTo: false }) => {
|
|
12
|
+
const step = 1 / (props.n + 1);
|
|
13
|
+
const fromColor = Color(from);
|
|
14
|
+
const toColor = Color(to);
|
|
15
|
+
const colorsBetween = range(1, props.n + 1)
|
|
16
|
+
.map((i) => fromColor.mix(toColor, i * step))
|
|
17
|
+
.map((c) => c.hex().toString());
|
|
18
|
+
if (props.includeFromTo) {
|
|
19
|
+
return [from, ...colorsBetween, to];
|
|
20
|
+
} else {
|
|
21
|
+
return colorsBetween;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default getColorsBetween;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get current url params or - if on production - params from embed url.
|
|
3
|
+
* @param {object} embed root dom element
|
|
4
|
+
* @returns {object} url params
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const getEmbedContext = (target) => {
|
|
8
|
+
let url;
|
|
9
|
+
if (
|
|
10
|
+
window.location.origin === 'https://d.swr.de' ||
|
|
11
|
+
window.location.origin === 'https://static.datenhub.net' ||
|
|
12
|
+
window.location.href.includes('apidata.googleusercontent.com') ||
|
|
13
|
+
window.location.href.includes('storage.googleapis.com')
|
|
14
|
+
) {
|
|
15
|
+
url = window.location.href;
|
|
16
|
+
} else {
|
|
17
|
+
const parent = target.parentNode || target.parentNode.parentNode;
|
|
18
|
+
url = parent.dataset.url;
|
|
19
|
+
}
|
|
20
|
+
const data = {};
|
|
21
|
+
for (const [key, value] of new URL(url).searchParams) {
|
|
22
|
+
data[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default getEmbedContext;
|