@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.
Files changed (288) hide show
  1. package/dist/Autocomplete/Autocomplete.svelte +237 -0
  2. package/dist/Autocomplete/Autocomplete.svelte.d.ts +34 -0
  3. package/dist/Autocomplete/index.d.ts +2 -0
  4. package/dist/Button/Button.svelte +38 -0
  5. package/dist/Button/Button.svelte.d.ts +10 -0
  6. package/dist/Button/index.d.ts +2 -0
  7. package/dist/Caption/Caption.svelte +21 -0
  8. package/dist/Caption/Caption.svelte.d.ts +8 -0
  9. package/dist/Caption/index.js +2 -0
  10. package/dist/Card/Card.svelte +25 -0
  11. package/dist/Card/Card.svelte.d.ts +7 -0
  12. package/dist/Card/index.d.ts +2 -0
  13. package/dist/ChartFooter/ChartFooter.svelte +38 -0
  14. package/dist/ChartFooter/ChartFooter.svelte.d.ts +8 -0
  15. package/dist/ChartFooter/index.d.ts +2 -0
  16. package/{src → dist}/ChartHeader/ChartHeader.svelte +4 -12
  17. package/dist/ChartHeader/ChartHeader.svelte.d.ts +9 -0
  18. package/dist/ChartHeader/index.d.ts +2 -0
  19. package/{src → dist}/ChartList/ChartList.svelte +2 -16
  20. package/dist/ChartList/ChartList.svelte.d.ts +14 -0
  21. package/dist/ChartList/index.js +2 -0
  22. package/dist/Copy/Copy.svelte +21 -0
  23. package/dist/Copy/Copy.svelte.d.ts +8 -0
  24. package/dist/Copy/index.js +2 -0
  25. package/dist/DesignTokens/DesignTokens.svelte +58 -0
  26. package/dist/DesignTokens/DesignTokens.svelte.d.ts +7 -0
  27. package/dist/DesignTokens/Tokens.d.ts +26 -0
  28. package/dist/DesignTokens/Tokens.js +171 -0
  29. package/dist/DesignTokens/index.d.ts +8 -0
  30. package/{src → dist}/FormLabel/FormLabel.svelte +2 -9
  31. package/dist/FormLabel/FormLabel.svelte.d.ts +9 -0
  32. package/dist/FormLabel/index.js +2 -0
  33. package/{src → dist}/Headline/Headline.svelte +2 -7
  34. package/dist/Headline/Headline.svelte.d.ts +7 -0
  35. package/dist/Headline/index.js +2 -0
  36. package/dist/HighlightCard/HighlightCard.svelte +54 -0
  37. package/dist/HighlightCard/HighlightCard.svelte.d.ts +9 -0
  38. package/dist/HighlightCard/index.d.ts +2 -0
  39. package/dist/Input/Input.svelte +32 -0
  40. package/dist/Input/Input.svelte.d.ts +23 -0
  41. package/dist/Input/index.d.ts +2 -0
  42. package/dist/Logotype/Logotype.svelte.d.ts +26 -0
  43. package/dist/Middot/Middot.svelte.d.ts +26 -0
  44. package/dist/Middot/index.d.ts +2 -0
  45. package/dist/Note/Note.svelte +28 -0
  46. package/dist/Note/Note.svelte.d.ts +7 -0
  47. package/dist/Note/index.js +2 -0
  48. package/dist/Select/Select.svelte +39 -0
  49. package/dist/Select/Select.svelte.d.ts +4 -0
  50. package/{src/Select/Select.types.ts → dist/Select/Select.types.d.ts} +1 -2
  51. package/dist/Select/Select.types.js +1 -0
  52. package/dist/Select/index.d.ts +2 -0
  53. package/dist/Switcher/Switcher.svelte +111 -0
  54. package/dist/Switcher/Switcher.svelte.d.ts +21 -0
  55. package/dist/Switcher/index.d.ts +2 -0
  56. package/dist/assets/close-circle.svg.svelte.d.ts +26 -0
  57. package/dist/assets/grow.svg.svelte.d.ts +26 -0
  58. package/dist/assets/hand-pointer.svg.svelte.d.ts +26 -0
  59. package/dist/assets/shrink.svg.svelte.d.ts +26 -0
  60. package/dist/assets/tap.svg.svelte.d.ts +26 -0
  61. package/dist/assets/times-circle-solid.svg.svelte.d.ts +26 -0
  62. package/dist/index.d.ts +29 -0
  63. package/dist/maplibre/AttributionControl/AttributionControl.svelte +15 -0
  64. package/dist/maplibre/AttributionControl/AttributionControl.svelte.d.ts +8 -0
  65. package/dist/maplibre/AttributionControl/index.d.ts +2 -0
  66. package/dist/maplibre/GeocoderControl/GeocoderAPIs.d.ts +6 -0
  67. package/dist/maplibre/GeocoderControl/GeocoderAPIs.js +40 -0
  68. package/dist/maplibre/GeocoderControl/GeocoderControl.svelte +25 -0
  69. package/dist/maplibre/GeocoderControl/GeocoderControl.svelte.d.ts +27 -0
  70. package/dist/maplibre/GeocoderControl/index.d.ts +2 -0
  71. package/dist/maplibre/Map/FallbackStyle.d.ts +3 -0
  72. package/dist/maplibre/Map/FallbackStyle.js +15 -0
  73. package/dist/maplibre/Map/Map.svelte +91 -0
  74. package/dist/maplibre/Map/Map.svelte.d.ts +23 -0
  75. package/dist/maplibre/Map/index.d.ts +2 -0
  76. package/dist/maplibre/MapControl/MapControl.svelte +29 -0
  77. package/dist/maplibre/MapControl/MapControl.svelte.d.ts +11 -0
  78. package/dist/maplibre/MapControl/index.d.ts +2 -0
  79. package/dist/maplibre/MapStyle/SWRDataLabLight.d.ts +3 -0
  80. package/dist/maplibre/MapStyle/SWRDataLabLight.js +60 -0
  81. package/dist/maplibre/MapStyle/components/Admin.d.ts +1 -0
  82. package/dist/maplibre/MapStyle/components/Admin.js +170 -0
  83. package/dist/maplibre/MapStyle/components/Buildings.d.ts +1 -0
  84. package/dist/maplibre/MapStyle/components/Buildings.js +21 -0
  85. package/dist/maplibre/MapStyle/components/Landuse.d.ts +1 -0
  86. package/dist/maplibre/MapStyle/components/Landuse.js +497 -0
  87. package/dist/maplibre/MapStyle/components/Natural.d.ts +1 -0
  88. package/dist/maplibre/MapStyle/components/Natural.js +1 -0
  89. package/dist/maplibre/MapStyle/components/PlaceLabels.d.ts +4 -0
  90. package/dist/maplibre/MapStyle/components/PlaceLabels.js +194 -0
  91. package/dist/maplibre/MapStyle/components/Roads.d.ts +8 -0
  92. package/dist/maplibre/MapStyle/components/Roads.js +2327 -0
  93. package/dist/maplibre/MapStyle/components/Transit.d.ts +7 -0
  94. package/dist/maplibre/MapStyle/components/Transit.js +499 -0
  95. package/dist/maplibre/MapStyle/components/Walking.d.ts +1 -0
  96. package/dist/maplibre/MapStyle/components/Walking.js +1530 -0
  97. package/dist/maplibre/MapStyle/index.d.ts +2 -0
  98. package/dist/maplibre/MapStyle/tokens.d.ts +20 -0
  99. package/dist/maplibre/MapStyle/tokens.js +20 -0
  100. package/dist/maplibre/NavigationControl/NavigationControl.svelte +9 -0
  101. package/dist/maplibre/NavigationControl/NavigationControl.svelte.d.ts +12 -0
  102. package/dist/maplibre/NavigationControl/index.d.ts +2 -0
  103. package/dist/maplibre/ScaleControl/ScaleControl.svelte +9 -0
  104. package/dist/maplibre/ScaleControl/ScaleControl.svelte.d.ts +9 -0
  105. package/dist/maplibre/ScaleControl/index.d.ts +2 -0
  106. package/dist/maplibre/Source/MapSource.svelte +43 -0
  107. package/dist/maplibre/Source/MapSource.svelte.d.ts +13 -0
  108. package/dist/maplibre/Source/index.d.ts +2 -0
  109. package/dist/maplibre/Source/source.d.ts +28 -0
  110. package/dist/maplibre/Source/source.js +76 -0
  111. package/dist/maplibre/Tooltip/Tooltip.svelte +46 -0
  112. package/dist/maplibre/Tooltip/Tooltip.svelte.d.ts +25 -0
  113. package/dist/maplibre/Tooltip/index.d.ts +2 -0
  114. package/dist/maplibre/VectorLayer/VectorLayer.svelte +73 -0
  115. package/dist/maplibre/VectorLayer/VectorLayer.svelte.d.ts +21 -0
  116. package/dist/maplibre/VectorLayer/index.d.ts +2 -0
  117. package/dist/maplibre/VectorTileSource/VectorTileSource.svelte +13 -0
  118. package/dist/maplibre/VectorTileSource/VectorTileSource.svelte.d.ts +11 -0
  119. package/dist/maplibre/VectorTileSource/index.d.ts +2 -0
  120. package/dist/maplibre/WithLinkLocation/WithLinkLocation.svelte +44 -0
  121. package/dist/maplibre/WithLinkLocation/WithLinkLocation.svelte.d.ts +19 -0
  122. package/dist/maplibre/WithLinkLocation/index.d.ts +2 -0
  123. package/dist/maplibre/context.svelte.d.ts +33 -0
  124. package/dist/maplibre/context.svelte.js +73 -0
  125. package/{src/maplibre/types.ts → dist/maplibre/types.d.ts} +3 -5
  126. package/dist/maplibre/types.js +1 -0
  127. package/dist/maplibre/utils.d.ts +4 -0
  128. package/dist/maplibre/utils.js +34 -0
  129. package/dist/utils/formatDate.d.ts +5 -0
  130. package/dist/utils/formatNumber.d.ts +18 -0
  131. package/dist/utils/getColorsBetween.d.ts +9 -0
  132. package/dist/utils/getComparisonDiffs.d.ts +6 -0
  133. package/dist/utils/getEmbedContext.d.ts +7 -0
  134. package/dist/utils/getEmbedContext.js +27 -0
  135. package/dist/utils/getLaenderFromTopo.d.ts +10 -0
  136. package/dist/utils/getLaenderNicenameFromAgs.d.ts +7 -0
  137. package/dist/utils/isSvelteComponent.d.ts +7 -0
  138. package/dist/utils/prepareSophoraModel.d.ts +2 -0
  139. package/dist/utils/scrollIntoViewWithOffset.d.ts +7 -0
  140. package/dist/utils/slugify.d.ts +1 -0
  141. package/dist/utils/slugify.js +11 -0
  142. package/dist/utils/topoToGeo.d.ts +7 -0
  143. package/package.json +28 -7
  144. package/.storybook/blocks/Mermaid.jsx +0 -9
  145. package/.storybook/main.ts +0 -34
  146. package/.storybook/preview-head.html +0 -13
  147. package/.storybook/preview.ts +0 -47
  148. package/.storybook/vitest.setup.ts +0 -9
  149. package/src/Autocomplete/Autocomplete.stories.svelte +0 -61
  150. package/src/Autocomplete/Autocomplete.svelte +0 -237
  151. package/src/Button/Button.stories.svelte +0 -21
  152. package/src/Button/Button.svelte +0 -52
  153. package/src/Caption/Caption.stories.svelte +0 -24
  154. package/src/Caption/Caption.svelte +0 -29
  155. package/src/Card/Card.stories.svelte +0 -19
  156. package/src/Card/Card.svelte +0 -34
  157. package/src/ChartFooter/ChartFooter.stories.svelte +0 -32
  158. package/src/ChartFooter/ChartFooter.svelte +0 -46
  159. package/src/ChartHeader/ChartHeader.stories.svelte +0 -31
  160. package/src/ChartList/ChartList.stories.svelte +0 -48
  161. package/src/Copy/Copy.stories.svelte +0 -32
  162. package/src/Copy/Copy.svelte +0 -29
  163. package/src/DesignTokens/DesignTokens.svelte +0 -71
  164. package/src/DesignTokens/Tokens.ts +0 -186
  165. package/src/FormLabel/FormLabel.stories.svelte +0 -52
  166. package/src/Headline/Headline.stories.svelte +0 -17
  167. package/src/HighlightCard/HighlightCard.stories.svelte +0 -57
  168. package/src/HighlightCard/HighlightCard.svelte +0 -65
  169. package/src/Input/Input.svelte +0 -21
  170. package/src/Logotype/Logotype.stories.svelte +0 -16
  171. package/src/Middot/Middot.stories.svelte +0 -16
  172. package/src/Note/Note.stories.svelte +0 -23
  173. package/src/Note/Note.svelte +0 -38
  174. package/src/Select/Select.stories.svelte +0 -205
  175. package/src/Select/Select.svelte +0 -76
  176. package/src/Select/SelectStoriesTemplate.svelte +0 -31
  177. package/src/Switcher/Switcher.stories.svelte +0 -44
  178. package/src/Switcher/Switcher.svelte +0 -130
  179. package/src/maplibre/AttributionControl/AttributionControl.stories.svelte +0 -29
  180. package/src/maplibre/AttributionControl/AttributionControl.svelte +0 -45
  181. package/src/maplibre/GeocoderControl/GeocoderAPIs.ts +0 -49
  182. package/src/maplibre/GeocoderControl/GeocoderControl.stories.svelte +0 -78
  183. package/src/maplibre/GeocoderControl/GeocoderControl.svelte +0 -211
  184. package/src/maplibre/Map/FallbackStyle.ts +0 -18
  185. package/src/maplibre/Map/Map.stories.svelte +0 -118
  186. package/src/maplibre/Map/Map.svelte +0 -287
  187. package/src/maplibre/MapControl/MapControl.stories.svelte +0 -56
  188. package/src/maplibre/MapControl/MapControl.svelte +0 -41
  189. package/src/maplibre/MapStyle/SWRDataLabLight.stories.svelte +0 -41
  190. package/src/maplibre/MapStyle/SWRDataLabLight.ts +0 -72
  191. package/src/maplibre/MapStyle/components/Admin.ts +0 -173
  192. package/src/maplibre/MapStyle/components/Buildings.ts +0 -23
  193. package/src/maplibre/MapStyle/components/Landuse.ts +0 -499
  194. package/src/maplibre/MapStyle/components/Natural.ts +0 -1
  195. package/src/maplibre/MapStyle/components/PlaceLabels.ts +0 -199
  196. package/src/maplibre/MapStyle/components/Roads.ts +0 -2345
  197. package/src/maplibre/MapStyle/components/Transit.ts +0 -507
  198. package/src/maplibre/MapStyle/components/Walking.ts +0 -1538
  199. package/src/maplibre/MapStyle/tokens.ts +0 -21
  200. package/src/maplibre/NavigationControl/NavigationControl.stories.svelte +0 -39
  201. package/src/maplibre/NavigationControl/NavigationControl.svelte +0 -36
  202. package/src/maplibre/ScaleControl/ScaleControl.stories.svelte +0 -71
  203. package/src/maplibre/ScaleControl/ScaleControl.svelte +0 -25
  204. package/src/maplibre/Source/MapSource.stories.svelte +0 -9
  205. package/src/maplibre/Source/MapSource.svelte +0 -61
  206. package/src/maplibre/Source/source.ts +0 -89
  207. package/src/maplibre/Tooltip/Tooltip.stories.svelte +0 -192
  208. package/src/maplibre/Tooltip/Tooltip.svelte +0 -183
  209. package/src/maplibre/VectorLayer/VectorLayer.stories.svelte +0 -65
  210. package/src/maplibre/VectorLayer/VectorLayer.svelte +0 -146
  211. package/src/maplibre/VectorTileSource/VectorTileSource.stories.svelte +0 -46
  212. package/src/maplibre/VectorTileSource/VectorTileSource.svelte +0 -24
  213. package/src/maplibre/WithLinkLocation/WithLinkLocation.stories.svelte +0 -29
  214. package/src/maplibre/WithLinkLocation/WithLinkLocation.svelte +0 -83
  215. package/src/maplibre/context.svelte.ts +0 -89
  216. package/src/maplibre/utils.ts +0 -52
  217. package/src/utils/getEmbedContext.js +0 -28
  218. package/src/utils/slugify.ts +0 -12
  219. package/static/favicon.png +0 -0
  220. package/svelte.config.js +0 -18
  221. package/tsconfig.json +0 -19
  222. package/vite.config.ts +0 -6
  223. package/vitest.workspace.ts +0 -32
  224. /package/{src → dist}/Autocomplete/index.js +0 -0
  225. /package/{src → dist}/Button/index.js +0 -0
  226. /package/{src/Caption/index.ts → dist/Caption/index.d.ts} +0 -0
  227. /package/{src → dist}/Card/index.js +0 -0
  228. /package/{src → dist}/ChartFooter/ChartFooter.mdx +0 -0
  229. /package/{src → dist}/ChartFooter/index.js +0 -0
  230. /package/{src → dist}/ChartHeader/ChartHeader.mdx +0 -0
  231. /package/{src → dist}/ChartHeader/index.js +0 -0
  232. /package/{src → dist}/ChartList/ChartList.mdx +0 -0
  233. /package/{src/ChartList/index.ts → dist/ChartList/index.d.ts} +0 -0
  234. /package/{src/Copy/index.ts → dist/Copy/index.d.ts} +0 -0
  235. /package/{src → dist}/DesignTokens/DesignTokens.mdx +0 -0
  236. /package/{src → dist}/DesignTokens/index.js +0 -0
  237. /package/{src → dist}/FormLabel/FormLabel.mdx +0 -0
  238. /package/{src/FormLabel/index.ts → dist/FormLabel/index.d.ts} +0 -0
  239. /package/{src/Headline/index.ts → dist/Headline/index.d.ts} +0 -0
  240. /package/{src → dist}/HighlightCard/index.js +0 -0
  241. /package/{src → dist}/Input/index.js +0 -0
  242. /package/{src → dist}/Intro.mdx +0 -0
  243. /package/{src → dist}/Logotype/Logotype.svelte +0 -0
  244. /package/{src → dist}/Middot/Middot.svelte +0 -0
  245. /package/{src → dist}/Middot/index.js +0 -0
  246. /package/{src/Note/index.ts → dist/Note/index.d.ts} +0 -0
  247. /package/{src → dist}/Select/Select.mdx +0 -0
  248. /package/{src → dist}/Select/index.js +0 -0
  249. /package/{src → dist}/Select/mock_data/jobs.json +0 -0
  250. /package/{src → dist}/Switcher/Switcher.mdx +0 -0
  251. /package/{src → dist}/Switcher/index.js +0 -0
  252. /package/{src → dist}/app.d.ts +0 -0
  253. /package/{src → dist}/app.html +0 -0
  254. /package/{src → dist}/assets/close-circle.svg.svelte +0 -0
  255. /package/{src → dist}/assets/grow.svg.svelte +0 -0
  256. /package/{src → dist}/assets/hand-pointer.svg.svelte +0 -0
  257. /package/{src → dist}/assets/shrink.svg.svelte +0 -0
  258. /package/{src → dist}/assets/tap.svg.svelte +0 -0
  259. /package/{src → dist}/assets/times-circle-solid.svg.svelte +0 -0
  260. /package/{src → dist}/index.js +0 -0
  261. /package/{src → dist}/maplibre/AttributionControl/index.js +0 -0
  262. /package/{src → dist}/maplibre/GeocoderControl/index.js +0 -0
  263. /package/{src → dist}/maplibre/Map/index.js +0 -0
  264. /package/{src → dist}/maplibre/MapControl/MapControl.mdx +0 -0
  265. /package/{src → dist}/maplibre/MapControl/index.js +0 -0
  266. /package/{src → dist}/maplibre/MapStyle/SWRDataLabLight.mdx +0 -0
  267. /package/{src → dist}/maplibre/MapStyle/index.js +0 -0
  268. /package/{src → dist}/maplibre/Maplibre.mdx +0 -0
  269. /package/{src → dist}/maplibre/NavigationControl/index.js +0 -0
  270. /package/{src → dist}/maplibre/ScaleControl/index.js +0 -0
  271. /package/{src → dist}/maplibre/Source/index.js +0 -0
  272. /package/{src → dist}/maplibre/Tooltip/index.js +0 -0
  273. /package/{src → dist}/maplibre/VectorLayer/index.js +0 -0
  274. /package/{src → dist}/maplibre/VectorTileSource/VectorTileSource.mdx +0 -0
  275. /package/{src → dist}/maplibre/VectorTileSource/index.js +0 -0
  276. /package/{src → dist}/maplibre/WithLinkLocation/WithLinkLocation.mdx +0 -0
  277. /package/{src → dist}/maplibre/WithLinkLocation/index.js +0 -0
  278. /package/{src → dist}/styles/base.scss +0 -0
  279. /package/{src → dist}/utils/formatDate.js +0 -0
  280. /package/{src → dist}/utils/formatNumber.js +0 -0
  281. /package/{src → dist}/utils/getColorsBetween.js +0 -0
  282. /package/{src → dist}/utils/getComparisonDiffs.js +0 -0
  283. /package/{src → dist}/utils/getLaenderFromTopo.js +0 -0
  284. /package/{src → dist}/utils/getLaenderNicenameFromAgs.js +0 -0
  285. /package/{src → dist}/utils/isSvelteComponent.js +0 -0
  286. /package/{src → dist}/utils/prepareSophoraModel.js +0 -0
  287. /package/{src → dist}/utils/scrollIntoViewWithOffset.js +0 -0
  288. /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>
@@ -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>