@swr-data-lab/components 1.13.0 → 1.13.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.
- 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.svelte +38 -0
- package/dist/Button/Button.svelte.d.ts +10 -0
- package/dist/Button/index.d.ts +2 -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.svelte +25 -0
- package/dist/Card/Card.svelte.d.ts +7 -0
- package/dist/Card/index.d.ts +2 -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/{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/{src → dist}/ChartList/ChartList.svelte +2 -16
- package/dist/ChartList/ChartList.svelte.d.ts +14 -0
- package/dist/ChartList/index.js +2 -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/{src → dist}/FormLabel/FormLabel.svelte +2 -9
- package/dist/FormLabel/FormLabel.svelte.d.ts +9 -0
- package/dist/FormLabel/index.js +2 -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/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/Logotype/Logotype.svelte.d.ts +26 -0
- package/dist/Middot/Middot.svelte.d.ts +26 -0
- package/dist/Middot/index.d.ts +2 -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/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/index.d.ts +2 -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/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/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/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/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.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/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/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/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.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/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/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/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.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/formatNumber.d.ts +18 -0
- package/dist/utils/getColorsBetween.d.ts +9 -0
- package/dist/utils/getComparisonDiffs.d.ts +6 -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/getLaenderNicenameFromAgs.d.ts +7 -0
- package/dist/utils/isSvelteComponent.d.ts +7 -0
- package/dist/utils/prepareSophoraModel.d.ts +2 -0
- package/dist/utils/scrollIntoViewWithOffset.d.ts +7 -0
- package/dist/utils/slugify.d.ts +1 -0
- package/dist/utils/slugify.js +11 -0
- package/dist/utils/topoToGeo.d.ts +7 -0
- package/package.json +28 -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.stories.svelte +0 -61
- 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.stories.svelte +0 -24
- 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.stories.svelte +0 -32
- package/src/ChartFooter/ChartFooter.svelte +0 -46
- package/src/ChartHeader/ChartHeader.stories.svelte +0 -31
- package/src/ChartList/ChartList.stories.svelte +0 -48
- package/src/Copy/Copy.stories.svelte +0 -32
- package/src/Copy/Copy.svelte +0 -29
- package/src/DesignTokens/DesignTokens.svelte +0 -71
- package/src/DesignTokens/Tokens.ts +0 -186
- package/src/FormLabel/FormLabel.stories.svelte +0 -52
- package/src/Headline/Headline.stories.svelte +0 -17
- package/src/HighlightCard/HighlightCard.stories.svelte +0 -57
- package/src/HighlightCard/HighlightCard.svelte +0 -65
- package/src/Input/Input.svelte +0 -21
- package/src/Logotype/Logotype.stories.svelte +0 -16
- package/src/Middot/Middot.stories.svelte +0 -16
- package/src/Note/Note.stories.svelte +0 -23
- package/src/Note/Note.svelte +0 -38
- package/src/Select/Select.stories.svelte +0 -205
- package/src/Select/Select.svelte +0 -76
- package/src/Select/SelectStoriesTemplate.svelte +0 -31
- package/src/Switcher/Switcher.stories.svelte +0 -44
- 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.stories.svelte +0 -78
- package/src/maplibre/GeocoderControl/GeocoderControl.svelte +0 -211
- package/src/maplibre/Map/FallbackStyle.ts +0 -18
- package/src/maplibre/Map/Map.stories.svelte +0 -118
- 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.stories.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.stories.svelte +0 -39
- package/src/maplibre/NavigationControl/NavigationControl.svelte +0 -36
- package/src/maplibre/ScaleControl/ScaleControl.stories.svelte +0 -71
- 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.stories.svelte +0 -192
- package/src/maplibre/Tooltip/Tooltip.svelte +0 -183
- package/src/maplibre/VectorLayer/VectorLayer.stories.svelte +0 -65
- package/src/maplibre/VectorLayer/VectorLayer.svelte +0 -146
- package/src/maplibre/VectorTileSource/VectorTileSource.stories.svelte +0 -46
- 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/getEmbedContext.js +0 -28
- 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/index.js +0 -0
- /package/{src → dist}/Button/index.js +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/index.js +0 -0
- /package/{src → dist}/ChartHeader/ChartHeader.mdx +0 -0
- /package/{src → dist}/ChartHeader/index.js +0 -0
- /package/{src → dist}/ChartList/ChartList.mdx +0 -0
- /package/{src/ChartList/index.ts → dist/ChartList/index.d.ts} +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/FormLabel/index.ts → dist/FormLabel/index.d.ts} +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}/Intro.mdx +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/Note/index.ts → dist/Note/index.d.ts} +0 -0
- /package/{src → dist}/Select/Select.mdx +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/index.js +0 -0
- /package/{src → dist}/app.d.ts +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}/index.js +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
- /package/{src → dist}/utils/formatDate.js +0 -0
- /package/{src → dist}/utils/formatNumber.js +0 -0
- /package/{src → dist}/utils/getColorsBetween.js +0 -0
- /package/{src → dist}/utils/getComparisonDiffs.js +0 -0
- /package/{src → dist}/utils/getLaenderFromTopo.js +0 -0
- /package/{src → dist}/utils/getLaenderNicenameFromAgs.js +0 -0
- /package/{src → dist}/utils/isSvelteComponent.js +0 -0
- /package/{src → dist}/utils/prepareSophoraModel.js +0 -0
- /package/{src → dist}/utils/scrollIntoViewWithOffset.js +0 -0
- /package/{src → dist}/utils/topoToGeo.js +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Select from './Select.svelte';
|
|
4
|
-
import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
5
|
-
import StoryTemplate from './SelectStoriesTemplate.svelte';
|
|
6
|
-
import jobsData from './mock_data/jobs.json';
|
|
7
|
-
|
|
8
|
-
const { Story } = defineMeta({
|
|
9
|
-
title: 'Form/Select',
|
|
10
|
-
component: Select
|
|
11
|
-
});
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<script lang="ts">
|
|
15
|
-
import { userEvent, within, expect } from 'storybook/test';
|
|
16
|
-
import { type SelectItem } from './Select.types';
|
|
17
|
-
let selectedItem: SelectItem | undefined = undefined;
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<Story
|
|
21
|
-
name="Simple"
|
|
22
|
-
asChild
|
|
23
|
-
play={async ({ canvasElement, step }) => {
|
|
24
|
-
const canvas = within(canvasElement);
|
|
25
|
-
const select = canvas.getByLabelText('Select');
|
|
26
|
-
|
|
27
|
-
await step('Clicking an option selects that item', async () => {
|
|
28
|
-
await userEvent.click(select);
|
|
29
|
-
await userEvent.click(canvas.getByText('Cake'));
|
|
30
|
-
expect(selectedItem).toEqual({ value: 'cake', label: 'Cake' });
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
await step('Entering a complete label selects that item', async () => {
|
|
34
|
-
await userEvent.type(select, 'Chocolate{enter}');
|
|
35
|
-
expect(selectedItem).toEqual({ value: 'chocolate', label: 'Chocolate' });
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
await step('Entering a unique part of a label selects the matching item', async () => {
|
|
39
|
-
await userEvent.type(select, 'Ice{enter}');
|
|
40
|
-
expect(selectedItem).toEqual({ value: 'ice-cream', label: 'Ice Cream' });
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
await step('Tapping the clear button clears the input', async () => {
|
|
44
|
-
const clearButton = document.querySelector('.clear-select');
|
|
45
|
-
await userEvent.click(clearButton);
|
|
46
|
-
expect(selectedItem).toEqual(undefined);
|
|
47
|
-
});
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
<StoryTemplate
|
|
51
|
-
bind:selectedItem
|
|
52
|
-
args={{
|
|
53
|
-
inputId: 'select',
|
|
54
|
-
clearable: true,
|
|
55
|
-
items: [
|
|
56
|
-
{ value: 'chocolate', label: 'Chocolate' },
|
|
57
|
-
{ value: 'cake', label: 'Cake' },
|
|
58
|
-
{ value: 'ice-cream', label: 'Ice Cream' }
|
|
59
|
-
]
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
</Story>
|
|
63
|
-
|
|
64
|
-
<Story name="Grouped" asChild>
|
|
65
|
-
<StoryTemplate
|
|
66
|
-
bind:selectedItem
|
|
67
|
-
args={{
|
|
68
|
-
items: [
|
|
69
|
-
{ value: 'chocolate', label: 'Chocolate', group: 'Sweet' },
|
|
70
|
-
{ value: 'pizza', label: 'Pizza', group: 'Savory' },
|
|
71
|
-
{ value: 'cake', label: 'Cake', group: 'Sweet' },
|
|
72
|
-
{ value: 'chips', label: 'Chips', group: 'Savory' },
|
|
73
|
-
{ value: 'ice-cream', label: 'Ice Cream', group: 'Sweet' }
|
|
74
|
-
]
|
|
75
|
-
}}
|
|
76
|
-
/>
|
|
77
|
-
</Story>
|
|
78
|
-
|
|
79
|
-
<Story
|
|
80
|
-
name="Grouped (group header selectable)"
|
|
81
|
-
asChild
|
|
82
|
-
play={async ({ canvasElement, step }) => {
|
|
83
|
-
const canvas = within(canvasElement);
|
|
84
|
-
const select = canvas.getByLabelText('Select');
|
|
85
|
-
|
|
86
|
-
await step('Clicking an option header selects that header item', async () => {
|
|
87
|
-
await userEvent.click(select);
|
|
88
|
-
await userEvent.click(canvas.getByText('Savory'));
|
|
89
|
-
expect(selectedItem).toEqual({
|
|
90
|
-
groupHeader: true,
|
|
91
|
-
id: 'Savory',
|
|
92
|
-
label: 'Savory',
|
|
93
|
-
selectable: true,
|
|
94
|
-
value: 'Savory'
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
await step('Entering a label text selects its group header', async () => {
|
|
99
|
-
await userEvent.type(select, 'Chocolate{enter}');
|
|
100
|
-
expect(selectedItem).toEqual({
|
|
101
|
-
groupHeader: true,
|
|
102
|
-
id: 'Sweet',
|
|
103
|
-
label: 'Sweet',
|
|
104
|
-
selectable: true,
|
|
105
|
-
value: 'Sweet'
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
}}
|
|
109
|
-
>
|
|
110
|
-
<StoryTemplate
|
|
111
|
-
bind:selectedItem
|
|
112
|
-
args={{
|
|
113
|
-
inputId: 'job-select',
|
|
114
|
-
placeholder: 'Ihr Beruf',
|
|
115
|
-
groupHeaderSelectable: true,
|
|
116
|
-
items: [
|
|
117
|
-
{ value: 'chocolate', label: 'Chocolate', group: 'Sweet' },
|
|
118
|
-
{ value: 'pizza', label: 'Pizza', group: 'Savory' },
|
|
119
|
-
{ value: 'cake', label: 'Cake', group: 'Sweet' },
|
|
120
|
-
{ value: 'chips', label: 'Chips', group: 'Savory' },
|
|
121
|
-
{ value: 'ice-cream', label: 'Ice Cream', group: 'Sweet' }
|
|
122
|
-
]
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
125
|
-
</Story>
|
|
126
|
-
|
|
127
|
-
<Story
|
|
128
|
-
name="Custom items"
|
|
129
|
-
asChild
|
|
130
|
-
play={async ({ canvasElement, step }) => {
|
|
131
|
-
const canvas = within(canvasElement);
|
|
132
|
-
const select = canvas.getByLabelText('Berufe');
|
|
133
|
-
|
|
134
|
-
await step('Render custom list item with the supplied data', async () => {
|
|
135
|
-
await userEvent.type(select, 'Journalismus');
|
|
136
|
-
expect(canvas.getByTestId('custom-item-title').innerText).toEqual('Journalismus');
|
|
137
|
-
expect(canvas.getByTestId('custom-item-addon').innerText).toContain('Redakteur/in');
|
|
138
|
-
await userEvent.type(select, '{enter}');
|
|
139
|
-
expect(selectedItem?.details.title).toEqual('Journalismus');
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
await step('Entering an item\'s "title" selects that item', async () => {
|
|
143
|
-
await userEvent.type(select, 'Tierpflege{enter}');
|
|
144
|
-
expect(selectedItem?.details.title).toEqual('Tierpflege');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
await step('Entering an item\'s "addon" selects that item', async () => {
|
|
148
|
-
await userEvent.type(select, 'Zirkuskünstler{enter}');
|
|
149
|
-
expect(selectedItem?.details.title).toEqual('Schauspiel und Tanz');
|
|
150
|
-
});
|
|
151
|
-
}}
|
|
152
|
-
>
|
|
153
|
-
<StoryTemplate>
|
|
154
|
-
{#snippet demoComponent()}
|
|
155
|
-
<FormLabel htmlFor="job-select">Berufe</FormLabel>
|
|
156
|
-
<Select
|
|
157
|
-
bind:value={selectedItem}
|
|
158
|
-
inputId="job-select"
|
|
159
|
-
placeholder="z.B. Taxifahrer/in"
|
|
160
|
-
items={jobsData
|
|
161
|
-
.sort((a, b) => a.label.localeCompare(b.label))
|
|
162
|
-
.map((item) => ({
|
|
163
|
-
value: item.value,
|
|
164
|
-
label: `${item.label}: ${item.add_on}`, // used for filtering
|
|
165
|
-
details: {
|
|
166
|
-
title: item.label, // used for display
|
|
167
|
-
addon: item.add_on // used for display
|
|
168
|
-
}
|
|
169
|
-
}))}
|
|
170
|
-
groupHeaderSelectable={false}
|
|
171
|
-
>
|
|
172
|
-
<div slot="item" let:item class="custom-item">
|
|
173
|
-
<h4 class="custom-item-title" data-testid="custom-item-title">
|
|
174
|
-
{item.details.title}
|
|
175
|
-
</h4>
|
|
176
|
-
<p class="custom-item-addon" data-testid="custom-item-addon">{item.details.addon}</p>
|
|
177
|
-
</div>
|
|
178
|
-
<div slot="selection" let:selection class="selection">
|
|
179
|
-
{selection.details.title}
|
|
180
|
-
</div>
|
|
181
|
-
</Select>
|
|
182
|
-
{/snippet}
|
|
183
|
-
</StoryTemplate>
|
|
184
|
-
</Story>
|
|
185
|
-
|
|
186
|
-
<style>
|
|
187
|
-
.custom-item {
|
|
188
|
-
font-size: 0.9rem;
|
|
189
|
-
margin-top: 0.2rem;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.custom-item-title {
|
|
193
|
-
margin: 0 0 0 -0.8rem;
|
|
194
|
-
padding: 0;
|
|
195
|
-
line-height: 1.4;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.custom-item-addon {
|
|
199
|
-
margin: 0 0 0 -0.8rem;
|
|
200
|
-
padding: 0;
|
|
201
|
-
line-height: 1;
|
|
202
|
-
opacity: 0.6;
|
|
203
|
-
font-size: 0.8rem;
|
|
204
|
-
}
|
|
205
|
-
</style>
|
package/src/Select/Select.svelte
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Select from 'svelte-select';
|
|
3
|
-
import { type SelectItem } from './Select.types';
|
|
4
|
-
|
|
5
|
-
interface SelectProps {
|
|
6
|
-
/**
|
|
7
|
-
* The input field's ID. Should be unique across the page.
|
|
8
|
-
*/
|
|
9
|
-
inputId: string;
|
|
10
|
-
/**
|
|
11
|
-
* The input field's placeholder text
|
|
12
|
-
*/
|
|
13
|
-
placeholder: string;
|
|
14
|
-
/**
|
|
15
|
-
* The list of select options
|
|
16
|
-
*/
|
|
17
|
-
items: SelectItem[];
|
|
18
|
-
/**
|
|
19
|
-
* Define custom item groupings. By default items are grouped by their `group` key
|
|
20
|
-
*/
|
|
21
|
-
groupBy?: ((item: SelectItem) => string) | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Whether group names should be selectable
|
|
24
|
-
*/
|
|
25
|
-
groupHeaderSelectable?: boolean;
|
|
26
|
-
clearable?: boolean;
|
|
27
|
-
value: SelectItem | undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let {
|
|
31
|
-
inputId = 'select',
|
|
32
|
-
placeholder = 'Bitte auswählen',
|
|
33
|
-
items = [],
|
|
34
|
-
groupBy,
|
|
35
|
-
groupHeaderSelectable = false,
|
|
36
|
-
clearable = true,
|
|
37
|
-
value = $bindable(undefined)
|
|
38
|
-
}: SelectProps = $props();
|
|
39
|
-
|
|
40
|
-
const groupByFn = groupBy || ((item: SelectItem) => item.group as string);
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<div class="container">
|
|
44
|
-
<Select
|
|
45
|
-
{items}
|
|
46
|
-
groupBy={items.length > 0 && items.every((item) => item.group) ? groupByFn : undefined}
|
|
47
|
-
id={inputId}
|
|
48
|
-
{placeholder}
|
|
49
|
-
{groupHeaderSelectable}
|
|
50
|
-
{clearable}
|
|
51
|
-
class="container"
|
|
52
|
-
bind:value
|
|
53
|
-
>
|
|
54
|
-
<div class="item" slot="item" let:item>
|
|
55
|
-
<slot name="item" {item}>
|
|
56
|
-
{item.label}
|
|
57
|
-
</slot>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="selection" slot="selection" let:selection>
|
|
60
|
-
<slot name="selection" {selection}>
|
|
61
|
-
{selection.label}
|
|
62
|
-
</slot>
|
|
63
|
-
</div>
|
|
64
|
-
</Select>
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
<style lang="scss">
|
|
68
|
-
.item {
|
|
69
|
-
font-family: var(--swr-sans);
|
|
70
|
-
color: var(--violet-dark-5);
|
|
71
|
-
}
|
|
72
|
-
.selection {
|
|
73
|
-
font-family: var(--swr-sans);
|
|
74
|
-
color: var(--violet-dark-5);
|
|
75
|
-
}
|
|
76
|
-
</style>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Select from './Select.svelte';
|
|
3
|
-
import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
4
|
-
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
5
|
-
|
|
6
|
-
let { args = null, selectedItem = $bindable(), demoComponent = null } = $props();
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<DesignTokens>
|
|
10
|
-
{#if demoComponent}
|
|
11
|
-
{@render demoComponent()}
|
|
12
|
-
{:else}
|
|
13
|
-
<FormLabel htmlFor={args.inputId}>Select</FormLabel>
|
|
14
|
-
<Select {...args} bind:value={selectedItem} />
|
|
15
|
-
{/if}
|
|
16
|
-
</DesignTokens>
|
|
17
|
-
|
|
18
|
-
{#if selectedItem}
|
|
19
|
-
<pre class="output">
|
|
20
|
-
value = {JSON.stringify(selectedItem, null, ' ')}</pre>
|
|
21
|
-
{/if}
|
|
22
|
-
|
|
23
|
-
<style>
|
|
24
|
-
.output {
|
|
25
|
-
display: block;
|
|
26
|
-
margin-top: 1rem;
|
|
27
|
-
padding: 1rem;
|
|
28
|
-
background: #fcfaff;
|
|
29
|
-
color: rgb(18, 69, 139);
|
|
30
|
-
}
|
|
31
|
-
</style>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Switcher from './Switcher.svelte';
|
|
4
|
-
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
5
|
-
import { userEvent, within, expect } from 'storybook/test';
|
|
6
|
-
|
|
7
|
-
const { Story } = defineMeta({
|
|
8
|
-
title: 'Form/Switcher',
|
|
9
|
-
component: Switcher
|
|
10
|
-
});
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<Story name="Two Options" asChild>
|
|
14
|
-
<DesignTokens>
|
|
15
|
-
<Switcher options={['Option A', 'Option B']} value="Option A" size="default" label="Label" />
|
|
16
|
-
</DesignTokens>
|
|
17
|
-
</Story>
|
|
18
|
-
|
|
19
|
-
<Story
|
|
20
|
-
name="Four Options"
|
|
21
|
-
asChild
|
|
22
|
-
play={async ({ canvasElement, step }) => {
|
|
23
|
-
const canvas = within(canvasElement);
|
|
24
|
-
await step('Clicking selects the expected option', async () => {
|
|
25
|
-
const optionA = canvas.getByLabelText('Apples');
|
|
26
|
-
const optionB = canvas.getByLabelText('Bananas');
|
|
27
|
-
await userEvent.click(optionA);
|
|
28
|
-
expect(optionA).toBeChecked();
|
|
29
|
-
expect(optionB).not.toBeChecked();
|
|
30
|
-
await userEvent.click(optionB);
|
|
31
|
-
expect(optionB).toBeChecked();
|
|
32
|
-
expect(optionA).not.toBeChecked();
|
|
33
|
-
});
|
|
34
|
-
}}
|
|
35
|
-
>
|
|
36
|
-
<DesignTokens>
|
|
37
|
-
<Switcher
|
|
38
|
-
options={['Apples', 'Oranges', 'Bananas', 'Peaches']}
|
|
39
|
-
value="Oranges"
|
|
40
|
-
label="Label"
|
|
41
|
-
size="small"
|
|
42
|
-
/>
|
|
43
|
-
</DesignTokens>
|
|
44
|
-
</Story>
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
3
|
-
|
|
4
|
-
interface SwitcherProps {
|
|
5
|
-
/**
|
|
6
|
-
* Human-readable label
|
|
7
|
-
*/
|
|
8
|
-
label: string;
|
|
9
|
-
/**
|
|
10
|
-
* Available options
|
|
11
|
-
*/
|
|
12
|
-
options: string[];
|
|
13
|
-
/**
|
|
14
|
-
* Display size
|
|
15
|
-
*/
|
|
16
|
-
size?: 'default' | 'small';
|
|
17
|
-
/**
|
|
18
|
-
* The currently-selected option
|
|
19
|
-
*/
|
|
20
|
-
value: string | null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let { label, options, size = 'default', value = $bindable(null) }: SwitcherProps = $props();
|
|
24
|
-
|
|
25
|
-
const groupId = $props.id();
|
|
26
|
-
const groupName = 'select-' + groupId;
|
|
27
|
-
|
|
28
|
-
function optionToID(o: string) {
|
|
29
|
-
return `${groupName}-option-${o.replace(/ /g, '-').toLowerCase()}`;
|
|
30
|
-
}
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<fieldset class="container" class:small={size === 'small'}>
|
|
34
|
-
<FormLabel as="legend">{label}</FormLabel>
|
|
35
|
-
<ul>
|
|
36
|
-
{#each options as o (o)}
|
|
37
|
-
<li class:is-selected={o === value}>
|
|
38
|
-
<label for={optionToID(o)}>
|
|
39
|
-
{o}
|
|
40
|
-
</label>
|
|
41
|
-
<input id={optionToID(o)} name={groupName} value={o} type="radio" bind:group={value} />
|
|
42
|
-
</li>
|
|
43
|
-
{/each}
|
|
44
|
-
</ul>
|
|
45
|
-
</fieldset>
|
|
46
|
-
|
|
47
|
-
<style lang="scss">
|
|
48
|
-
@use '../styles/base.scss';
|
|
49
|
-
|
|
50
|
-
fieldset {
|
|
51
|
-
border: 0;
|
|
52
|
-
font-family: var(--swr-sans);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
ul {
|
|
56
|
-
width: 100%;
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-direction: column;
|
|
59
|
-
overflow: hidden;
|
|
60
|
-
padding: 0;
|
|
61
|
-
margin: 0;
|
|
62
|
-
border: 1px solid currentColor;
|
|
63
|
-
background: white;
|
|
64
|
-
border-radius: var(--br-small);
|
|
65
|
-
|
|
66
|
-
@media (min-width: base.$bp-s) {
|
|
67
|
-
flex-flow: row;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
&:focus-within,
|
|
71
|
-
&:active {
|
|
72
|
-
outline: 2px solid var(--blue-light-2);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
li {
|
|
76
|
-
display: contents;
|
|
77
|
-
&:last-child label {
|
|
78
|
-
border-right: 0;
|
|
79
|
-
border-bottom: 0;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
input {
|
|
83
|
-
position: absolute;
|
|
84
|
-
left: -999px;
|
|
85
|
-
}
|
|
86
|
-
.small label {
|
|
87
|
-
font-size: var(--fs-small-1);
|
|
88
|
-
height: 2.25em;
|
|
89
|
-
padding: 0 0.65em;
|
|
90
|
-
}
|
|
91
|
-
label {
|
|
92
|
-
font-size: var(--fs-base);
|
|
93
|
-
line-height: 1;
|
|
94
|
-
white-space: nowrap;
|
|
95
|
-
padding: 0 1em;
|
|
96
|
-
cursor: pointer;
|
|
97
|
-
margin: 0;
|
|
98
|
-
align-items: center;
|
|
99
|
-
display: flex;
|
|
100
|
-
color: currentColor;
|
|
101
|
-
position: relative;
|
|
102
|
-
transition: var(--fast);
|
|
103
|
-
text-underline-offset: 0.2em;
|
|
104
|
-
border-bottom: 1px solid currentColor;
|
|
105
|
-
height: 2.25em;
|
|
106
|
-
@media (min-width: base.$bp-s) {
|
|
107
|
-
justify-content: center;
|
|
108
|
-
padding: 0 1em;
|
|
109
|
-
flex-basis: 0;
|
|
110
|
-
flex-grow: 1;
|
|
111
|
-
border-right: 1px solid currentColor;
|
|
112
|
-
border-bottom: 0;
|
|
113
|
-
}
|
|
114
|
-
@media (min-width: base.$bp-s) {
|
|
115
|
-
height: 2.5em;
|
|
116
|
-
}
|
|
117
|
-
&:hover,
|
|
118
|
-
&:focus-visible {
|
|
119
|
-
text-decoration: underline;
|
|
120
|
-
}
|
|
121
|
-
.is-selected & {
|
|
122
|
-
background: rgb(247, 247, 247);
|
|
123
|
-
font-weight: 600;
|
|
124
|
-
box-shadow: inset 5px 0px 0 0 var(--violet-dark-5);
|
|
125
|
-
@media (min-width: base.$bp-s) {
|
|
126
|
-
box-shadow: inset 0 -3px 0 0 var(--violet-dark-5);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
</style>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import AttributionControl from './AttributionControl.svelte';
|
|
4
|
-
import DesignTokens from '../../DesignTokens/DesignTokens.svelte';
|
|
5
|
-
import Map from '../Map/Map.svelte';
|
|
6
|
-
import { SWRDataLabLight } from '../MapStyle';
|
|
7
|
-
|
|
8
|
-
const { Story } = defineMeta({
|
|
9
|
-
title: 'Maplibre/Control/AttributionControl',
|
|
10
|
-
component: AttributionControl
|
|
11
|
-
});
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<Story asChild name="Default">
|
|
15
|
-
<DesignTokens>
|
|
16
|
-
<div class="container">
|
|
17
|
-
<Map style={SWRDataLabLight} initialLocation={{ lat: 51, lng: 10, zoom: 20 }}>
|
|
18
|
-
<AttributionControl customAttribution="SWR Data Lab" position="bottom-left" />
|
|
19
|
-
</Map>
|
|
20
|
-
</div>
|
|
21
|
-
</DesignTokens>
|
|
22
|
-
</Story>
|
|
23
|
-
|
|
24
|
-
<style>
|
|
25
|
-
.container {
|
|
26
|
-
width: 500px;
|
|
27
|
-
height: 300px;
|
|
28
|
-
}
|
|
29
|
-
</style>
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import maplibre, { type ControlPosition } from 'maplibre-gl';
|
|
3
|
-
import MapControl from '../MapControl/MapControl.svelte';
|
|
4
|
-
|
|
5
|
-
interface AttributionControlProps {
|
|
6
|
-
position?: ControlPosition;
|
|
7
|
-
customAttribution?: string;
|
|
8
|
-
}
|
|
9
|
-
const { position = 'bottom-right', customAttribution }: AttributionControlProps = $props();
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
|
-
<MapControl
|
|
13
|
-
{position}
|
|
14
|
-
control={new maplibre.AttributionControl({
|
|
15
|
-
customAttribution,
|
|
16
|
-
compact: false
|
|
17
|
-
})}
|
|
18
|
-
/>
|
|
19
|
-
|
|
20
|
-
<style>
|
|
21
|
-
:global {
|
|
22
|
-
.maplibregl-ctrl.maplibregl-ctrl-attrib {
|
|
23
|
-
font-size: var(--fs-small-3);
|
|
24
|
-
letter-spacing: 0.005em;
|
|
25
|
-
word-spacing: 0.005em;
|
|
26
|
-
font-family: var(--swr-sans);
|
|
27
|
-
}
|
|
28
|
-
.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
|
|
29
|
-
display: block;
|
|
30
|
-
}
|
|
31
|
-
.maplibregl-ctrl-attrib-button {
|
|
32
|
-
display: none;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.maplibregl-ctrl-attrib a {
|
|
36
|
-
color: inherit;
|
|
37
|
-
text-decoration: none;
|
|
38
|
-
text-underline-offset: 0.2em;
|
|
39
|
-
}
|
|
40
|
-
.maplibregl-ctrl-attrib a:hover {
|
|
41
|
-
color: inherit;
|
|
42
|
-
text-decoration: underline;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
</style>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CarmenGeojsonFeature,
|
|
3
|
-
type MaplibreGeocoderApi,
|
|
4
|
-
type MaplibreGeocoderApiConfig,
|
|
5
|
-
type MaplibreGeocoderFeatureResults
|
|
6
|
-
} from '@maplibre/maplibre-gl-geocoder';
|
|
7
|
-
|
|
8
|
-
export class MaptilerGeocoderAPI implements MaplibreGeocoderApi {
|
|
9
|
-
key: string;
|
|
10
|
-
|
|
11
|
-
constructor(key: string) {
|
|
12
|
-
this.key = key;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async forwardGeocode(config: MaplibreGeocoderApiConfig): Promise<MaplibreGeocoderFeatureResults> {
|
|
16
|
-
const result: MaplibreGeocoderFeatureResults = {
|
|
17
|
-
type: 'FeatureCollection',
|
|
18
|
-
features: []
|
|
19
|
-
};
|
|
20
|
-
try {
|
|
21
|
-
const response = await fetch(
|
|
22
|
-
`https://api.maptiler.com/geocoding/${config.query}.json?country=${config.countries}&language=${config.language}&key=${this.key}`
|
|
23
|
-
);
|
|
24
|
-
const geojson = await response.json();
|
|
25
|
-
for (const feature of geojson.features) {
|
|
26
|
-
const res: CarmenGeojsonFeature = {
|
|
27
|
-
type: 'Feature',
|
|
28
|
-
id: feature.id,
|
|
29
|
-
place_type: ['place'],
|
|
30
|
-
place_name: feature.place_name,
|
|
31
|
-
language: feature.properties.display_name,
|
|
32
|
-
text: feature.text,
|
|
33
|
-
bbox: feature.bbox,
|
|
34
|
-
geometry: {
|
|
35
|
-
type: 'Point',
|
|
36
|
-
coordinates: feature.center
|
|
37
|
-
},
|
|
38
|
-
properties: {
|
|
39
|
-
text: feature.text
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
result.features.push(res);
|
|
43
|
-
}
|
|
44
|
-
} catch (e) {
|
|
45
|
-
console.error(`Failed to forwardGeocode with error: ${e}`);
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { within, expect } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import GeocoderControl from './GeocoderControl.svelte';
|
|
6
|
-
import DesignTokens from '../../DesignTokens/DesignTokens.svelte';
|
|
7
|
-
import Map from '../Map/Map.svelte';
|
|
8
|
-
|
|
9
|
-
import { SWRDataLabLight } from '../MapStyle';
|
|
10
|
-
|
|
11
|
-
const { Story } = defineMeta({
|
|
12
|
-
title: 'Maplibre/Control/GeocoderControl',
|
|
13
|
-
component: GeocoderControl
|
|
14
|
-
});
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<Story
|
|
18
|
-
asChild
|
|
19
|
-
name="Default"
|
|
20
|
-
play={async ({ canvasElement, step }) => {
|
|
21
|
-
const canvas = within(canvasElement);
|
|
22
|
-
const containerEl = canvas.getByTestId('map-container');
|
|
23
|
-
|
|
24
|
-
await step('Geocoder control renders', async () => {
|
|
25
|
-
const el = containerEl.querySelector('.maplibregl-ctrl-geocoder');
|
|
26
|
-
expect(el).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
await step('Localised placeholder text renders', async () => {
|
|
29
|
-
const el = containerEl.querySelector('.maplibregl-ctrl-geocoder input');
|
|
30
|
-
expect(el).toHaveAttribute('placeholder', 'Suche');
|
|
31
|
-
});
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
<DesignTokens>
|
|
35
|
-
<div class="container">
|
|
36
|
-
<Map style={SWRDataLabLight} initialLocation={{ lat: 51, lng: 10, zoom: 20 }}>
|
|
37
|
-
<GeocoderControl languages="de" service="maptiler" key="V32kPHZjMa0Mkn6YvSzA" />
|
|
38
|
-
</Map>
|
|
39
|
-
</div>
|
|
40
|
-
</DesignTokens>
|
|
41
|
-
</Story>
|
|
42
|
-
<Story
|
|
43
|
-
asChild
|
|
44
|
-
name="Custom placeholder text"
|
|
45
|
-
play={async ({ canvasElement, step }) => {
|
|
46
|
-
const canvas = within(canvasElement);
|
|
47
|
-
const containerEl = canvas.getByTestId('map-container');
|
|
48
|
-
|
|
49
|
-
await step('Geocoder control renders', async () => {
|
|
50
|
-
const el = containerEl.querySelector('.maplibregl-ctrl-geocoder');
|
|
51
|
-
expect(el).toBeTruthy();
|
|
52
|
-
});
|
|
53
|
-
await step('Custom placeholder text renders', async () => {
|
|
54
|
-
const el = containerEl.querySelector('.maplibregl-ctrl-geocoder input');
|
|
55
|
-
expect(el).toHaveAttribute('placeholder', 'My placeholder text');
|
|
56
|
-
});
|
|
57
|
-
}}
|
|
58
|
-
>
|
|
59
|
-
<DesignTokens>
|
|
60
|
-
<div class="container">
|
|
61
|
-
<Map style={SWRDataLabLight} initialLocation={{ lat: 51, lng: 10, zoom: 20 }}>
|
|
62
|
-
<GeocoderControl
|
|
63
|
-
placeholder="My placeholder text"
|
|
64
|
-
languages="de"
|
|
65
|
-
service="maptiler"
|
|
66
|
-
key="V32kPHZjMa0Mkn6YvSzA"
|
|
67
|
-
/>
|
|
68
|
-
</Map>
|
|
69
|
-
</div>
|
|
70
|
-
</DesignTokens>
|
|
71
|
-
</Story>
|
|
72
|
-
|
|
73
|
-
<style>
|
|
74
|
-
.container {
|
|
75
|
-
width: 500px;
|
|
76
|
-
height: 300px;
|
|
77
|
-
}
|
|
78
|
-
</style>
|