@guardian/interactive-component-library 0.3.1 → 0.3.2-rc1

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 (284) hide show
  1. package/dist/components/index.d.ts +3 -0
  2. package/dist/components/molecules/canvas-map/Map.d.ts +8 -0
  3. package/dist/components/molecules/canvas-map/Map.js +90 -0
  4. package/dist/components/molecules/canvas-map/context/MapContext.d.ts +19 -0
  5. package/dist/components/molecules/canvas-map/context/MapContext.js +20 -0
  6. package/dist/components/molecules/canvas-map/controls/ZoomControl.d.ts +6 -0
  7. package/dist/components/molecules/canvas-map/controls/ZoomControl.js +40 -0
  8. package/dist/components/molecules/canvas-map/controls/icons/index.d.ts +3 -0
  9. package/dist/components/molecules/canvas-map/controls/icons/minus.d.ts +1 -0
  10. package/dist/components/molecules/canvas-map/controls/icons/minus.js +25 -0
  11. package/dist/components/molecules/canvas-map/controls/icons/plus.d.ts +1 -0
  12. package/dist/components/molecules/canvas-map/controls/icons/plus.js +25 -0
  13. package/dist/components/molecules/canvas-map/controls/icons/reset.d.ts +3 -0
  14. package/dist/components/molecules/canvas-map/controls/icons/reset.js +25 -0
  15. package/dist/components/molecules/canvas-map/controls/index.d.ts +1 -0
  16. package/dist/components/molecules/canvas-map/controls/style.module.css.js +11 -0
  17. package/dist/components/molecules/canvas-map/index.d.ts +12 -0
  18. package/dist/components/molecules/canvas-map/lib/Feature.d.ts +44 -0
  19. package/dist/components/molecules/canvas-map/lib/Feature.js +113 -0
  20. package/dist/components/molecules/canvas-map/lib/FeatureCollection.d.ts +21 -0
  21. package/dist/components/molecules/canvas-map/lib/FeatureCollection.js +24 -0
  22. package/dist/components/molecules/canvas-map/lib/Map.d.ts +82 -0
  23. package/dist/components/molecules/canvas-map/lib/Map.js +267 -0
  24. package/dist/components/molecules/canvas-map/lib/View.d.ts +222 -0
  25. package/dist/components/molecules/canvas-map/lib/View.js +208 -0
  26. package/dist/components/molecules/canvas-map/lib/events/Dispatcher.d.ts +8 -0
  27. package/dist/components/molecules/canvas-map/lib/events/Dispatcher.js +35 -0
  28. package/dist/components/molecules/canvas-map/lib/events/MapEvent.d.ts +6 -0
  29. package/dist/components/molecules/canvas-map/lib/events/MapEvent.js +9 -0
  30. package/dist/components/molecules/canvas-map/lib/events/index.d.ts +2 -0
  31. package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.d.ts +63 -0
  32. package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.js +122 -0
  33. package/dist/components/molecules/canvas-map/lib/geometry/Geometry.d.ts +32 -0
  34. package/dist/components/molecules/canvas-map/lib/geometry/Geometry.js +41 -0
  35. package/dist/components/molecules/canvas-map/lib/geometry/LineString.d.ts +12 -0
  36. package/dist/components/molecules/canvas-map/lib/geometry/LineString.js +19 -0
  37. package/dist/components/molecules/canvas-map/lib/geometry/Point.d.ts +11 -0
  38. package/dist/components/molecules/canvas-map/lib/geometry/Point.js +22 -0
  39. package/dist/components/molecules/canvas-map/lib/geometry/Polygon.d.ts +16 -0
  40. package/dist/components/molecules/canvas-map/lib/geometry/Polygon.js +46 -0
  41. package/dist/components/molecules/canvas-map/lib/geometry/index.d.ts +4 -0
  42. package/dist/components/molecules/canvas-map/lib/interpolators/index.d.ts +2 -0
  43. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.d.ts +5 -0
  44. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.js +95 -0
  45. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.d.ts +4 -0
  46. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.js +65 -0
  47. package/dist/components/molecules/canvas-map/lib/layers/TextLayer.d.ts +52 -0
  48. package/dist/components/molecules/canvas-map/lib/layers/TextLayer.js +118 -0
  49. package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.d.ts +57 -0
  50. package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.js +136 -0
  51. package/dist/components/molecules/canvas-map/lib/layers/index.d.ts +3 -0
  52. package/dist/components/molecules/canvas-map/lib/projection/index.d.ts +27 -0
  53. package/dist/components/molecules/canvas-map/lib/projection/index.js +12 -0
  54. package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.d.ts +16 -0
  55. package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.js +90 -0
  56. package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.d.ts +6 -0
  57. package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.js +53 -0
  58. package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.d.ts +21 -0
  59. package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.js +133 -0
  60. package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.d.ts +10 -0
  61. package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.js +79 -0
  62. package/dist/components/molecules/canvas-map/lib/sources/VectorSource.d.ts +15 -0
  63. package/dist/components/molecules/canvas-map/lib/sources/VectorSource.js +53 -0
  64. package/dist/components/molecules/canvas-map/lib/styles/Fill.d.ts +7 -0
  65. package/dist/components/molecules/canvas-map/lib/styles/Fill.js +15 -0
  66. package/dist/components/molecules/canvas-map/lib/styles/Stroke.d.ts +24 -0
  67. package/dist/components/molecules/canvas-map/lib/styles/Stroke.js +22 -0
  68. package/dist/components/molecules/canvas-map/lib/styles/Style.d.ts +24 -0
  69. package/dist/components/molecules/canvas-map/lib/styles/Style.js +17 -0
  70. package/dist/components/molecules/canvas-map/lib/styles/Text.d.ts +146 -0
  71. package/dist/components/molecules/canvas-map/lib/styles/Text.js +116 -0
  72. package/dist/components/molecules/canvas-map/lib/styles/index.d.ts +4 -0
  73. package/dist/components/molecules/canvas-map/lib/util/array.d.ts +6 -0
  74. package/dist/components/molecules/canvas-map/lib/util/array.js +15 -0
  75. package/dist/components/molecules/canvas-map/lib/util/bboxFeature.d.ts +8 -0
  76. package/dist/components/molecules/canvas-map/lib/util/bboxFeature.js +24 -0
  77. package/dist/components/molecules/canvas-map/lib/util/bounds.d.ts +47 -0
  78. package/dist/components/molecules/canvas-map/lib/util/bounds.js +61 -0
  79. package/dist/components/molecules/canvas-map/lib/util/coordinate.d.ts +26 -0
  80. package/dist/components/molecules/canvas-map/lib/util/coordinate.js +35 -0
  81. package/dist/components/molecules/canvas-map/lib/util/debug.d.ts +11 -0
  82. package/dist/components/molecules/canvas-map/lib/util/debug.js +27 -0
  83. package/dist/components/molecules/canvas-map/lib/util/deflate.d.ts +36 -0
  84. package/dist/components/molecules/canvas-map/lib/util/distance.d.ts +1 -0
  85. package/dist/components/molecules/canvas-map/lib/util/distance.js +12 -0
  86. package/dist/components/molecules/canvas-map/lib/util/dom.d.ts +9 -0
  87. package/dist/components/molecules/canvas-map/lib/util/dom.js +28 -0
  88. package/dist/components/molecules/canvas-map/lib/util/extent.d.ts +98 -0
  89. package/dist/components/molecules/canvas-map/lib/util/extent.js +118 -0
  90. package/dist/components/molecules/canvas-map/lib/util/index.d.ts +6 -0
  91. package/dist/components/molecules/canvas-map/lib/util/memoise.d.ts +10 -0
  92. package/dist/components/molecules/canvas-map/lib/util/memoise.js +20 -0
  93. package/dist/components/molecules/canvas-map/lib/util/resolution.d.ts +9 -0
  94. package/dist/components/molecules/canvas-map/lib/util/resolution.js +11 -0
  95. package/dist/components/molecules/canvas-map/lib/util/simplify.d.ts +114 -0
  96. package/dist/components/molecules/canvas-map/lib/util/size.d.ts +32 -0
  97. package/dist/components/molecules/canvas-map/lib/util/size.js +53 -0
  98. package/dist/components/molecules/canvas-map/lib/util/toRgba.d.ts +1 -0
  99. package/dist/components/molecules/canvas-map/lib/util/toRgba.js +25 -0
  100. package/dist/components/molecules/canvas-map/lib/util/uid.d.ts +5 -0
  101. package/dist/components/molecules/canvas-map/lib/util/uid.js +7 -0
  102. package/dist/components/molecules/canvas-map/lib/util/zoomLevel.d.ts +2 -0
  103. package/dist/components/molecules/canvas-map/lib/util/zoomLevel.js +14 -0
  104. package/dist/components/molecules/canvas-map/style.module.scss.js +20 -0
  105. package/dist/components/molecules/column-chart/column-chart-example.d.ts +35 -0
  106. package/dist/components/molecules/column-chart/column-chart-util.d.ts +1 -0
  107. package/dist/components/molecules/column-chart/index.d.ts +11 -0
  108. package/dist/components/molecules/column-chart/index.js +63 -0
  109. package/dist/components/molecules/column-chart/style.module.css.js +14 -0
  110. package/dist/components/molecules/control-change/index.d.ts +6 -0
  111. package/dist/components/molecules/control-change/index.js +29 -0
  112. package/dist/components/molecules/control-change/style.module.css.js +11 -0
  113. package/dist/components/molecules/dropdown/index.d.ts +11 -0
  114. package/dist/components/molecules/dropdown/index.js +191 -0
  115. package/dist/components/molecules/dropdown/style.module.css.js +50 -0
  116. package/dist/components/molecules/first-past-the-post-waffle/index.d.ts +5 -0
  117. package/dist/components/molecules/first-past-the-post-waffle/index.js +14 -0
  118. package/dist/components/molecules/first-past-the-post-waffle/style.module.css.js +14 -0
  119. package/dist/components/molecules/index.d.ts +18 -0
  120. package/dist/components/molecules/modal/index.d.ts +8 -0
  121. package/dist/components/molecules/modal/index.js +59 -0
  122. package/dist/components/molecules/modal/style.module.css.js +26 -0
  123. package/dist/components/molecules/option-picker/index.d.ts +26 -0
  124. package/dist/components/molecules/option-picker/index.js +94 -0
  125. package/dist/components/molecules/option-picker/style.module.css.js +35 -0
  126. package/dist/components/molecules/page-section/index.d.ts +8 -0
  127. package/dist/components/molecules/page-section/index.js +52 -0
  128. package/dist/components/molecules/page-section/style.module.scss.js +20 -0
  129. package/dist/components/molecules/party-profile/index.d.ts +10 -0
  130. package/dist/components/molecules/party-profile/index.js +29 -0
  131. package/dist/components/molecules/party-profile/style.module.css.js +26 -0
  132. package/dist/components/molecules/refresh-indicator/index.d.ts +4 -0
  133. package/dist/components/molecules/refresh-indicator/index.js +18 -0
  134. package/dist/components/molecules/refresh-indicator/style.module.scss.js +17 -0
  135. package/dist/components/molecules/responsive-grid/index.d.ts +10 -0
  136. package/dist/components/molecules/responsive-grid/index.js +19 -0
  137. package/dist/components/molecules/responsive-grid/style.module.scss.js +8 -0
  138. package/dist/components/molecules/result-summary/index.d.ts +8 -0
  139. package/dist/components/molecules/result-summary/index.js +40 -0
  140. package/dist/components/molecules/result-summary/style.module.css.js +11 -0
  141. package/dist/components/molecules/search-input/icons/search.d.ts +1 -0
  142. package/dist/components/molecules/search-input/icons/search.js +24 -0
  143. package/dist/components/molecules/search-input/icons/search.module.css.js +11 -0
  144. package/dist/components/molecules/search-input/index.d.ts +11 -0
  145. package/dist/components/molecules/search-input/index.js +165 -0
  146. package/dist/components/molecules/search-input/style.module.css.js +32 -0
  147. package/dist/components/molecules/slope-chart/index.d.ts +16 -0
  148. package/dist/components/molecules/slope-chart/index.js +139 -0
  149. package/dist/components/molecules/slope-chart/style.module.css.js +35 -0
  150. package/dist/components/molecules/svg-map/context/MapContext.d.ts +1 -0
  151. package/dist/components/molecules/svg-map/context/MapContext.js +5 -0
  152. package/dist/components/molecules/svg-map/context/SVGMapProvider.d.ts +10 -0
  153. package/dist/components/molecules/svg-map/context/SVGMapProvider.js +88 -0
  154. package/dist/components/molecules/svg-map/helpers/bboxFeature.d.ts +8 -0
  155. package/dist/components/molecules/svg-map/helpers/bboxFeature.js +26 -0
  156. package/dist/components/molecules/svg-map/helpers/dynamicPropValue.d.ts +1 -0
  157. package/dist/components/molecules/svg-map/helpers/dynamicPropValue.js +9 -0
  158. package/dist/components/molecules/svg-map/helpers/geoMath.d.ts +4 -0
  159. package/dist/components/molecules/svg-map/helpers/saveSVG.d.ts +1 -0
  160. package/dist/components/molecules/svg-map/hooks/useCamera.d.ts +0 -0
  161. package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.d.ts +4 -0
  162. package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.js +19 -0
  163. package/dist/components/molecules/svg-map/index.d.ts +38 -0
  164. package/dist/components/molecules/svg-map/index.js +121 -0
  165. package/dist/components/molecules/svg-map/layers/CompositionBorders.d.ts +3 -0
  166. package/dist/components/molecules/svg-map/layers/CompositionBorders.js +14 -0
  167. package/dist/components/molecules/svg-map/layers/Line.d.ts +7 -0
  168. package/dist/components/molecules/svg-map/layers/Line.js +48 -0
  169. package/dist/components/molecules/svg-map/layers/Point.d.ts +10 -0
  170. package/dist/components/molecules/svg-map/layers/Point.js +59 -0
  171. package/dist/components/molecules/svg-map/layers/Polygon.d.ts +9 -0
  172. package/dist/components/molecules/svg-map/layers/Polygon.js +75 -0
  173. package/dist/components/molecules/svg-map/layers/Prerendered.d.ts +3 -0
  174. package/dist/components/molecules/svg-map/layers/Prerendered.js +11 -0
  175. package/dist/components/molecules/svg-map/layers/compositionBorders.module.scss.js +8 -0
  176. package/dist/components/molecules/svg-map/layers/index.d.ts +5 -0
  177. package/dist/components/molecules/svg-map/layers/index.js +12 -0
  178. package/dist/components/molecules/svg-map/renderers/SVGRenderer.d.ts +3 -0
  179. package/dist/components/molecules/svg-map/renderers/SVGRenderer.js +32 -0
  180. package/dist/components/molecules/svg-map/style.module.css.js +11 -0
  181. package/dist/components/molecules/table/index.d.ts +7 -0
  182. package/dist/components/molecules/table/index.js +90 -0
  183. package/dist/components/molecules/table/style.module.scss.js +29 -0
  184. package/dist/components/molecules/table/useTable.d.ts +8 -0
  185. package/dist/components/molecules/table/useTable.js +128 -0
  186. package/dist/components/molecules/tooltip/index.d.ts +82 -0
  187. package/dist/components/molecules/tooltip/index.js +117 -0
  188. package/dist/components/molecules/tooltip/style.module.css.js +8 -0
  189. package/dist/components/molecules/topline-result/index.d.ts +3 -0
  190. package/dist/components/molecules/topline-result/index.js +61 -0
  191. package/dist/components/molecules/topline-result/style.module.scss.js +38 -0
  192. package/dist/components/organisms/coalitions-tracker/index.d.ts +16 -0
  193. package/dist/components/organisms/coalitions-tracker/index.js +151 -0
  194. package/dist/components/organisms/coalitions-tracker/style.module.scss.js +32 -0
  195. package/dist/components/organisms/index.d.ts +2 -0
  196. package/dist/components/organisms/ticker/gradient/index.d.ts +1 -0
  197. package/dist/components/organisms/ticker/gradient/index.js +35 -0
  198. package/dist/components/organisms/ticker/gradient/style.module.scss.js +14 -0
  199. package/dist/components/organisms/ticker/index.d.ts +5 -0
  200. package/dist/components/organisms/ticker/index.js +102 -0
  201. package/dist/components/organisms/ticker/style.module.scss.js +32 -0
  202. package/dist/components/particles/ad-slot/index.d.ts +40 -0
  203. package/dist/components/particles/ad-slot/index.js +34 -0
  204. package/dist/components/particles/ad-slot/style.module.css.js +11 -0
  205. package/dist/components/particles/arrow-button/index.d.ts +6 -0
  206. package/dist/components/particles/arrow-button/index.js +32 -0
  207. package/dist/components/particles/arrow-button/style.module.css.js +11 -0
  208. package/dist/components/particles/aspect-ratio-box/index.d.ts +4 -0
  209. package/dist/components/particles/aspect-ratio-box/index.js +15 -0
  210. package/dist/components/particles/aspect-ratio-box/style.module.css.js +6 -0
  211. package/dist/components/particles/button/index.d.ts +6 -0
  212. package/dist/components/particles/button/index.js +10 -0
  213. package/dist/components/particles/button/style.module.css.js +11 -0
  214. package/dist/components/particles/change-bar/index.d.ts +8 -0
  215. package/dist/components/particles/change-bar/index.js +27 -0
  216. package/dist/components/particles/change-bar/style.module.scss.js +14 -0
  217. package/dist/components/particles/chevron/index.d.ts +6 -0
  218. package/dist/components/particles/chevron/index.js +78 -0
  219. package/dist/components/particles/chevron/style.module.css.js +20 -0
  220. package/dist/components/particles/circle-icon/index.d.ts +6 -0
  221. package/dist/components/particles/circle-icon/index.js +32 -0
  222. package/dist/components/particles/circle-icon/style.module.css.js +14 -0
  223. package/dist/components/particles/close-button/index.d.ts +5 -0
  224. package/dist/components/particles/close-button/index.js +35 -0
  225. package/dist/components/particles/close-button/style.module.css.js +17 -0
  226. package/dist/components/particles/container/index.d.ts +5 -0
  227. package/dist/components/particles/container/index.js +13 -0
  228. package/dist/components/particles/container/style.module.scss.js +11 -0
  229. package/dist/components/particles/gradient-icon/index.d.ts +1 -0
  230. package/dist/components/particles/gradient-icon/index.js +46 -0
  231. package/dist/components/particles/gradient-icon/style.module.css.js +14 -0
  232. package/dist/components/particles/index.d.ts +18 -0
  233. package/dist/components/particles/info-button/index.d.ts +3 -0
  234. package/dist/components/particles/info-button/index.js +19 -0
  235. package/dist/components/particles/info-button/style.module.css.js +11 -0
  236. package/dist/components/particles/legend-item/index.d.ts +6 -0
  237. package/dist/components/particles/legend-item/index.js +26 -0
  238. package/dist/components/particles/legend-item/style.module.css.js +17 -0
  239. package/dist/components/particles/relative-time-sentence/index.d.ts +4 -0
  240. package/dist/components/particles/relative-time-sentence/index.js +14 -0
  241. package/dist/components/particles/relative-time-sentence/style.module.css.js +8 -0
  242. package/dist/components/particles/square-cut-corner-icon/index.d.ts +6 -0
  243. package/dist/components/particles/square-cut-corner-icon/index.js +56 -0
  244. package/dist/components/particles/square-cut-corner-icon/style.module.scss.js +17 -0
  245. package/dist/components/particles/square-icon/index.d.ts +5 -0
  246. package/dist/components/particles/square-icon/index.js +28 -0
  247. package/dist/components/particles/square-icon/style.module.scss.js +11 -0
  248. package/dist/components/particles/stacked-bar/index.d.ts +23 -0
  249. package/dist/components/particles/stacked-bar/index.js +140 -0
  250. package/dist/components/particles/stacked-bar/style.module.css.js +17 -0
  251. package/dist/components/particles/stacked-grid/index.d.ts +6 -0
  252. package/dist/components/particles/stacked-grid/index.js +35 -0
  253. package/dist/components/particles/stacked-grid/style.module.css.js +20 -0
  254. package/dist/components/particles/waffle/index.d.ts +14 -0
  255. package/dist/components/particles/waffle/index.js +76 -0
  256. package/dist/components/particles/waffle/style.module.css.js +11 -0
  257. package/dist/index.d.ts +2 -0
  258. package/dist/index.js +147 -0
  259. package/dist/shared/colors/index.d.ts +2 -0
  260. package/dist/shared/helpers/createStore.d.ts +1 -0
  261. package/dist/shared/helpers/geometry.d.ts +3 -0
  262. package/dist/shared/helpers/geometry.js +16 -0
  263. package/dist/shared/helpers/geometry.test.d.ts +1 -0
  264. package/dist/shared/helpers/labelsUtil.d.ts +54 -0
  265. package/dist/shared/helpers/labelsUtil.js +58 -0
  266. package/dist/shared/helpers/labelsUtils.test.d.ts +1 -0
  267. package/dist/shared/helpers/shouldUpdate.d.ts +7 -0
  268. package/dist/shared/hooks/index.d.ts +3 -0
  269. package/dist/shared/hooks/useContainerSize.d.ts +1 -0
  270. package/dist/shared/hooks/useContainerSize.js +24 -0
  271. package/dist/shared/hooks/useTouchOrHover.d.ts +7 -0
  272. package/dist/shared/hooks/useTouchOrHover.js +103 -0
  273. package/dist/shared/hooks/useWindowSize.d.ts +4 -0
  274. package/dist/shared/hooks/useWindowSize.js +27 -0
  275. package/dist/style.css +74 -74
  276. package/dist/styles/helpers/mergeStyles.d.ts +1 -0
  277. package/dist/styles/helpers/mergeStyles.js +22 -0
  278. package/dist/styles/helpers/mergeStyles.test.d.ts +1 -0
  279. package/dist/styles/theme.config.d.ts +124 -0
  280. package/package.json +19 -10
  281. package/dist/interactive-component-library.js +0 -8370
  282. package/dist/interactive-component-library.js.map +0 -1
  283. package/dist/interactive-component-library.umd.cjs +0 -8365
  284. package/dist/interactive-component-library.umd.cjs.map +0 -1
@@ -0,0 +1,3 @@
1
+ export * from './particles';
2
+ export * from './molecules';
3
+ export * from './organisms';
@@ -0,0 +1,8 @@
1
+ import { Map } from './lib/Map';
2
+ export type MapComponentProps = {
3
+ config: any;
4
+ inModalState?: boolean;
5
+ onLoad?: (map: Map) => void;
6
+ children: import('preact').ComponentChildren;
7
+ mapRef?: import('preact').Ref<Map>;
8
+ };
@@ -0,0 +1,90 @@
1
+ import { jsxs, jsx } from "preact/jsx-runtime";
2
+ import { useRef, useState, useEffect } from "preact/hooks";
3
+ import { Map } from "./lib/Map.js";
4
+ import { MapProvider } from "./context/MapContext.js";
5
+ import styles from "./style.module.scss.js";
6
+ const mobileHelpText = "Use two fingers to zoom";
7
+ const Component = ({
8
+ config,
9
+ inModalState = false,
10
+ onLoad,
11
+ children,
12
+ mapRef
13
+ }) => {
14
+ const targetRef = useRef();
15
+ const [map, setMap] = useState(
16
+ /** @type {Map | null} */
17
+ null
18
+ );
19
+ const [zoomHelpText, setZoomHelpText] = useState("");
20
+ const [showHelpText, setShowHelpText] = useState(false);
21
+ useEffect(() => {
22
+ var _a;
23
+ if (!targetRef.current) return;
24
+ const map2 = new Map({
25
+ ...config,
26
+ target: targetRef.current
27
+ });
28
+ map2.collaborativeGesturesEnabled(true);
29
+ setMap(map2);
30
+ if (mapRef) {
31
+ mapRef.current = map2;
32
+ }
33
+ if (onLoad) {
34
+ onLoad(map2);
35
+ }
36
+ let zoomHelpText2 = "";
37
+ if (
38
+ // @ts-ignore
39
+ ((_a = navigator.userAgentData) == null ? void 0 : _a.mobile) || navigator.userAgent.indexOf("Mobile") !== -1
40
+ ) {
41
+ zoomHelpText2 = mobileHelpText;
42
+ } else {
43
+ zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
44
+ }
45
+ setZoomHelpText(zoomHelpText2);
46
+ return () => {
47
+ map2.destroy();
48
+ setMap(null);
49
+ if (mapRef) {
50
+ mapRef.current = null;
51
+ }
52
+ };
53
+ }, [config, onLoad, mapRef]);
54
+ useEffect(() => {
55
+ if (!map) return;
56
+ let timeoutID;
57
+ map.onFilterEvent((showHelpText2) => {
58
+ if (timeoutID) clearTimeout(timeoutID);
59
+ setShowHelpText(showHelpText2);
60
+ if (showHelpText2) {
61
+ timeoutID = setTimeout(() => {
62
+ setShowHelpText(false);
63
+ }, 1e3);
64
+ }
65
+ });
66
+ return () => {
67
+ if (timeoutID) clearTimeout(timeoutID);
68
+ };
69
+ }, [map]);
70
+ useEffect(() => {
71
+ if (!map) return;
72
+ map.collaborativeGesturesEnabled(!inModalState);
73
+ }, [map, inModalState]);
74
+ return /* @__PURE__ */ jsxs("figure", { ref: targetRef, className: styles.mapContainer, children: [
75
+ /* @__PURE__ */ jsxs(
76
+ "div",
77
+ {
78
+ className: styles.helpTextContainer,
79
+ style: { opacity: showHelpText ? 1 : 0 },
80
+ "aria-hidden": true,
81
+ children: [
82
+ /* @__PURE__ */ jsx("p", { className: [styles.helpText, styles.desktopHelpText].join(" "), children: zoomHelpText }),
83
+ /* @__PURE__ */ jsx("p", { className: [styles.helpText, styles.mobileHelpText].join(" "), children: mobileHelpText })
84
+ ]
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsx(MapProvider, { map, children })
88
+ ] });
89
+ };
90
+ Map.Component = Component;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @param {Object} params
3
+ * @param {import('../lib/Map').Map} params.map
4
+ * @param {import('preact').ComponentChildren} params.children
5
+ */
6
+ export function MapProvider({ map, children }: {
7
+ map: import('../lib/Map').Map;
8
+ children: import('preact').ComponentChildren;
9
+ }): import("preact").JSX.Element;
10
+ export type MapContext = {
11
+ registerLayer: ((layer: import('../lib/layers').Layer) => void) | null;
12
+ };
13
+ /**
14
+ * @typedef {{ registerLayer: ((layer: import("../lib/layers").Layer) => void) | null }} MapContext
15
+ */
16
+ /**
17
+ * @type {import('preact').Context<MapContext | null>}
18
+ */
19
+ export const MapContext: import('preact').Context<MapContext | null>;
@@ -0,0 +1,20 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+ import { createContext } from "preact";
3
+ import { useEffect } from "preact/hooks";
4
+ const MapContext = createContext(null);
5
+ function MapProvider({ map, children }) {
6
+ const registeredLayers = [];
7
+ const registerLayer = (layer) => {
8
+ registeredLayers.push(layer);
9
+ };
10
+ useEffect(() => {
11
+ if (map && !map.hasLayers(registeredLayers)) {
12
+ map.setLayers(registeredLayers);
13
+ }
14
+ }, [map, children]);
15
+ return /* @__PURE__ */ jsx(MapContext.Provider, { value: { registerLayer }, children });
16
+ }
17
+ export {
18
+ MapContext,
19
+ MapProvider
20
+ };
@@ -0,0 +1,6 @@
1
+ export function ZoomControl({ resetEnabled, onZoomIn, onZoomOut, onReset }: {
2
+ resetEnabled: any;
3
+ onZoomIn: any;
4
+ onZoomOut: any;
5
+ onReset: any;
6
+ }): import("preact").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsxs, jsx } from "preact/jsx-runtime";
2
+ import { IconMinus } from "./icons/minus.js";
3
+ import { IconPlus } from "./icons/plus.js";
4
+ import { IconReset } from "./icons/reset.js";
5
+ import styles from "./style.module.css.js";
6
+ function ZoomControl({ resetEnabled, onZoomIn, onZoomOut, onReset }) {
7
+ const _onZoomIn = (event) => {
8
+ event.stopPropagation();
9
+ onZoomIn(event);
10
+ };
11
+ const _onZoomOut = (event) => {
12
+ event.stopPropagation();
13
+ onZoomOut(event);
14
+ };
15
+ const _onReset = (event) => {
16
+ event.stopPropagation();
17
+ onReset(event);
18
+ };
19
+ return /* @__PURE__ */ jsxs("div", { className: styles.zoomControl, children: [
20
+ /* @__PURE__ */ jsx("button", { className: styles.button, onClick: _onZoomIn, children: /* @__PURE__ */ jsx(IconPlus, {}) }),
21
+ /* @__PURE__ */ jsx("button", { className: styles.button, onClick: _onZoomOut, children: /* @__PURE__ */ jsx(IconMinus, {}) }),
22
+ /* @__PURE__ */ jsx(
23
+ "button",
24
+ {
25
+ className: styles.button,
26
+ onClick: _onReset,
27
+ disabled: !resetEnabled,
28
+ children: /* @__PURE__ */ jsx(
29
+ IconReset,
30
+ {
31
+ fill: resetEnabled ? "var(--primary-text-color)" : "var(--news-grey-03)"
32
+ }
33
+ )
34
+ }
35
+ )
36
+ ] });
37
+ }
38
+ export {
39
+ ZoomControl
40
+ };
@@ -0,0 +1,3 @@
1
+ export * from './minus';
2
+ export * from './plus';
3
+ export * from './reset';
@@ -0,0 +1 @@
1
+ export function IconMinus(): import("preact").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+ function IconMinus() {
3
+ return /* @__PURE__ */ jsx(
4
+ "svg",
5
+ {
6
+ width: "22",
7
+ height: "4",
8
+ viewBox: "0 0 22 4",
9
+ fill: "none",
10
+ xmlns: "http://www.w3.org/2000/svg",
11
+ children: /* @__PURE__ */ jsx(
12
+ "path",
13
+ {
14
+ fillRule: "evenodd",
15
+ clipRule: "evenodd",
16
+ d: "M0 0.75V3.24999H21.9999V0.75H0Z",
17
+ fill: "var(--news-grey-01)"
18
+ }
19
+ )
20
+ }
21
+ );
22
+ }
23
+ export {
24
+ IconMinus
25
+ };
@@ -0,0 +1 @@
1
+ export function IconPlus(): import("preact").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+ function IconPlus() {
3
+ return /* @__PURE__ */ jsx(
4
+ "svg",
5
+ {
6
+ width: "22",
7
+ height: "22",
8
+ viewBox: "0 0 22 22",
9
+ fill: "none",
10
+ xmlns: "http://www.w3.org/2000/svg",
11
+ children: /* @__PURE__ */ jsx(
12
+ "path",
13
+ {
14
+ fillRule: "evenodd",
15
+ clipRule: "evenodd",
16
+ d: "M9.79997 12.2L10.225 21.9999H11.75L12.2 12.2L21.9999 11.75V10.225L12.2 9.79997L11.75 0H10.225L9.79997 9.79997L0 10.225V11.75L9.79997 12.2Z",
17
+ fill: "var(--news-grey-01)"
18
+ }
19
+ )
20
+ }
21
+ );
22
+ }
23
+ export {
24
+ IconPlus
25
+ };
@@ -0,0 +1,3 @@
1
+ export function IconReset({ fill }: {
2
+ fill?: string;
3
+ }): import("preact").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+ function IconReset({ fill = "#121212" }) {
3
+ return /* @__PURE__ */ jsx(
4
+ "svg",
5
+ {
6
+ width: "40",
7
+ height: "40",
8
+ viewBox: "0 0 40 40",
9
+ fill: "none",
10
+ xmlns: "http://www.w3.org/2000/svg",
11
+ children: /* @__PURE__ */ jsx(
12
+ "path",
13
+ {
14
+ fillRule: "evenodd",
15
+ clipRule: "evenodd",
16
+ d: "M32.107 33.107L26.5535 27.5535C24.7984 29.0775 22.5069 30 20 30L19.9916 30L19.9811 30C17.4476 30 15.1269 29.0482 13.3721 27.4882C11.3038 25.6561 10 22.9803 10 20H11.8C11.8 24.5287 15.4713 28.2 20 28.2C20.0567 28.2 20.1134 28.1994 20.1698 28.1983C24.5716 28.0965 28.1587 24.4465 28.1587 19.9772C28.1587 15.467 24.4685 11.7995 19.9811 11.7995C17.407 11.7995 15.1975 12.9385 13.6713 14.7608L16.9742 15.3075V16.4465L11.1428 16.4465L10.71 16.0137V10H11.8262L12.3956 13.4396C14.218 11.3212 16.9059 10 19.9811 10C25.5164 10 30.0039 14.4647 30.0039 19.9772C30.0039 21.8429 29.4982 23.5854 28.6171 25.0771C28.4764 25.3155 28.326 25.5474 28.1666 25.7725L33.8221 31.428C33.2844 32.0212 32.7116 32.5819 32.107 33.107Z",
17
+ fill
18
+ }
19
+ )
20
+ }
21
+ );
22
+ }
23
+ export {
24
+ IconReset
25
+ };
@@ -0,0 +1 @@
1
+ export * from './ZoomControl';
@@ -0,0 +1,11 @@
1
+ const zoomControl = "_zoomControl_13wd1_1";
2
+ const button = "_button_13wd1_7";
3
+ const styles = {
4
+ zoomControl,
5
+ button
6
+ };
7
+ export {
8
+ button,
9
+ styles as default,
10
+ zoomControl
11
+ };
@@ -0,0 +1,12 @@
1
+ export * from './lib/Map';
2
+ export * from './controls';
3
+ export * from './lib/Feature';
4
+ export * from './lib/FeatureCollection';
5
+ export * from './lib/events';
6
+ export * from './lib/projection';
7
+ export * from './lib/layers';
8
+ export * from './lib/styles';
9
+ export * from './lib/util';
10
+ export * from './lib/interpolators';
11
+ export * from './lib/sources/VectorSource';
12
+ export * from './lib/formats/GeoJSON';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Class representing a map Feature.
3
+ * @class
4
+ * @property {string} id - The unique identifier of the feature
5
+ * @property {Array} geometries - The geometries of the feature
6
+ * @property {Object} properties - The properties of the feature
7
+ * @property {Style} style - The style of the feature
8
+ */
9
+ export class Feature {
10
+ /**
11
+ * Represents a feature on the map
12
+ * @constructor
13
+ * @param {Object} props - The properties for the feature.
14
+ * @property {string} id - The unique identifier of the feature
15
+ * @property {Array} geometries - The geometries of the feature
16
+ * @property {Object} properties - The properties of the feature
17
+ * @property {import("./styles").Style | import("./styles").StyleFunction} style - The style of the feature
18
+ */
19
+ constructor({ id, geometries, properties, style }: any);
20
+ id: any;
21
+ geometries: any;
22
+ properties: any;
23
+ style: any;
24
+ uid: string;
25
+ _getProjectedGeometries: any;
26
+ setGeometries(geometries: any): void;
27
+ _extent: any;
28
+ /**
29
+ * Get the extent of the geometries in the feature.
30
+
31
+ * @returns {import("./util").Extent}
32
+ */
33
+ getExtent(): import('./util').Extent;
34
+ getProjectedGeometries(projection: any): any;
35
+ getStyleFunction(): any;
36
+ containsCoordinate(coordinate: any): boolean;
37
+ clone(): Feature;
38
+ /**
39
+ * Returns the geometries as a GeoJSON object
40
+ * @returns {Object} The GeoJSON representation of the geometries
41
+ */
42
+ getGeoJSON(): any;
43
+ _getGeometryGeoJSON(): any;
44
+ }
@@ -0,0 +1,113 @@
1
+ import { createUid } from "./util/uid.js";
2
+ import { combineExtents, containsCoordinate } from "./util/extent.js";
3
+ import { polygonContains } from "d3-polygon";
4
+ import { memoise } from "./util/memoise.js";
5
+ class Feature {
6
+ /**
7
+ * Represents a feature on the map
8
+ * @constructor
9
+ * @param {Object} props - The properties for the feature.
10
+ * @property {string} id - The unique identifier of the feature
11
+ * @property {Array} geometries - The geometries of the feature
12
+ * @property {Object} properties - The properties of the feature
13
+ * @property {import("./styles").Style | import("./styles").StyleFunction} style - The style of the feature
14
+ */
15
+ constructor({ id, geometries, properties, style }) {
16
+ this.id = id;
17
+ this.geometries = geometries;
18
+ this.properties = properties;
19
+ this.style = style;
20
+ this.uid = createUid();
21
+ this._getProjectedGeometries = memoise((projection) => {
22
+ return this.geometries.map(
23
+ (d) => d.getProjected(projection, projection.revision)
24
+ );
25
+ }).bind(this);
26
+ }
27
+ setGeometries(geometries) {
28
+ this.geometries = geometries;
29
+ this._extent = void 0;
30
+ }
31
+ /**
32
+ * Get the extent of the geometries in the feature.
33
+
34
+ * @returns {import("./util").Extent}
35
+ */
36
+ getExtent() {
37
+ if (this._extent) return this._extent;
38
+ const extent = this.geometries.reduce((combinedExtent, geometry) => {
39
+ if (!combinedExtent) return geometry.extent;
40
+ return combineExtents(geometry.extent, combinedExtent);
41
+ }, null);
42
+ this._extent = extent;
43
+ return extent;
44
+ }
45
+ getProjectedGeometries(projection) {
46
+ return this._getProjectedGeometries(projection, projection.revision);
47
+ }
48
+ getStyleFunction() {
49
+ const style = this.style;
50
+ if (!style) return null;
51
+ if (typeof style === "function") return style;
52
+ return () => {
53
+ return style;
54
+ };
55
+ }
56
+ containsCoordinate(coordinate) {
57
+ if (!containsCoordinate(this.getExtent(), coordinate)) {
58
+ return false;
59
+ }
60
+ for (const geometry of this.geometries) {
61
+ if (polygonContains(geometry.getOuterRing(), coordinate)) {
62
+ return true;
63
+ }
64
+ }
65
+ return false;
66
+ }
67
+ clone() {
68
+ return new Feature({
69
+ id: this.id,
70
+ geometries: this.geometries.map((d) => d.clone()),
71
+ properties: this.properties,
72
+ style: this.style
73
+ });
74
+ }
75
+ /**
76
+ * Returns the geometries as a GeoJSON object
77
+ * @returns {Object} The GeoJSON representation of the geometries
78
+ */
79
+ getGeoJSON() {
80
+ const geometries = this.geometries.map((d) => d.getGeoJSON());
81
+ if (geometries.length === 1) return geometries[0];
82
+ return {
83
+ type: "Feature",
84
+ geometry: this._getGeometryGeoJSON(),
85
+ properties: this.properties
86
+ };
87
+ }
88
+ _getGeometryGeoJSON() {
89
+ const geometries = this.geometries.map((d) => d.getGeoJSON());
90
+ if (geometries.length === 0) throw new Error("Feature has no geometries");
91
+ if (geometries.length === 1) return geometries[0];
92
+ if (geometries[0].type === "Polygon") {
93
+ return {
94
+ type: "MultiPolygon",
95
+ coordinates: geometries.map((d) => d.coordinates)
96
+ };
97
+ } else if (geometries[0].type === "LineString") {
98
+ return {
99
+ type: "MultiLineString",
100
+ coordinates: geometries.map((d) => d.coordinates)
101
+ };
102
+ } else if (geometries[0].type === "Point") {
103
+ return {
104
+ type: "MultiPoint",
105
+ coordinates: geometries.map((d) => d.coordinates)
106
+ };
107
+ }
108
+ throw new Error("Could not determine geometry type");
109
+ }
110
+ }
111
+ export {
112
+ Feature
113
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Class representing a collection of map features.
3
+ * @class
4
+ * @property {import("./Feature").Feature[]} features - The features in the feature collection
5
+ */
6
+ export class FeatureCollection {
7
+ /**
8
+ * Create a feature collection from GeoJSON features.
9
+ * @param {Object | Object[]} geoJSON - The GeoJSON object
10
+ * @param {import("./formats/GeoJSON").GeoJSONParseOptions} [parseOptions] - Options for parsing the GeoJSON object
11
+ * @returns {FeatureCollection} The feature collection
12
+ */
13
+ static fromGeoJSON(geoJSON: any | any[], parseOptions?: import('./formats/GeoJSON').GeoJSONParseOptions): FeatureCollection;
14
+ /**
15
+ * Create a feature collection.
16
+ * @constructor
17
+ * @param {import("./Feature").Feature[]} features - The features to put in the collection
18
+ */
19
+ constructor(features: import('./Feature').Feature[]);
20
+ features: import('./Feature').Feature[];
21
+ }
@@ -0,0 +1,24 @@
1
+ import { GeoJSON } from "./formats/GeoJSON.js";
2
+ class FeatureCollection {
3
+ /**
4
+ * Create a feature collection from GeoJSON features.
5
+ * @param {Object | Object[]} geoJSON - The GeoJSON object
6
+ * @param {import("./formats/GeoJSON").GeoJSONParseOptions} [parseOptions] - Options for parsing the GeoJSON object
7
+ * @returns {FeatureCollection} The feature collection
8
+ */
9
+ static fromGeoJSON(geoJSON, parseOptions) {
10
+ const features = new GeoJSON(parseOptions).readFeaturesFromObject(geoJSON);
11
+ return new FeatureCollection(features);
12
+ }
13
+ /**
14
+ * Create a feature collection.
15
+ * @constructor
16
+ * @param {import("./Feature").Feature[]} features - The features to put in the collection
17
+ */
18
+ constructor(features) {
19
+ this.features = features;
20
+ }
21
+ }
22
+ export {
23
+ FeatureCollection
24
+ };
@@ -0,0 +1,82 @@
1
+ import { View } from './View';
2
+ import { Dispatcher } from './events';
3
+ import { MapRenderer } from './renderers/MapRenderer';
4
+ /**
5
+ * Map component that renders into a canvas
6
+ * It has built-in support for zooming and panning, as well as support for vector layers
7
+ */
8
+ export class Map {
9
+ /**
10
+ * @constructor
11
+ * @param {Object} config - The configuration for the map.
12
+ * @param {Object} config.view - The view configuration for the map.
13
+ * @param {boolean} config.debug - Whether to enable debug mode or not.
14
+ * @param {HTMLElement} config.target - The target element to render the map into.
15
+ */
16
+ constructor(config: {
17
+ view: any;
18
+ debug: boolean;
19
+ target: HTMLElement;
20
+ });
21
+ options: {
22
+ view: any;
23
+ debug: boolean;
24
+ target: HTMLElement;
25
+ };
26
+ view: View;
27
+ target: HTMLElement;
28
+ layers: any[];
29
+ dispatcher: Dispatcher;
30
+ _viewport: HTMLDivElement;
31
+ _renderer: MapRenderer;
32
+ _resizeObserver: ResizeObserver;
33
+ destroy(): void;
34
+ /** PUBLIC GETTERS */
35
+ get size(): number[];
36
+ get viewPort(): HTMLDivElement;
37
+ get zoomScale(): any;
38
+ get isTransitioning(): boolean;
39
+ /** PUBLIC METHODS */
40
+ collaborativeGesturesEnabled(enabled: any): any;
41
+ _collaborativeGesturesEnabled: any;
42
+ onFilterEvent(callback: any): void;
43
+ _filterEventCallback: any;
44
+ fitObject(geoJSON: any): void;
45
+ addLayer(layer: any): void;
46
+ addLayers(layers: any): void;
47
+ setLayers(layers: any): void;
48
+ removeLayer(layer: any): void;
49
+ zoomIn(options: any): Promise<any>;
50
+ zoomOut(options: any): Promise<any>;
51
+ zoomTo(zoomScale: any, options?: {
52
+ duration: number;
53
+ }): Promise<any>;
54
+ zoomToFeature(feature: any, focalPoint: any, padding?: {
55
+ top: number;
56
+ right: number;
57
+ bottom: number;
58
+ left: number;
59
+ }): void;
60
+ /** @param {import("./layers").Layer[]} layers */
61
+ hasLayers(layers: import('./layers').Layer[]): boolean;
62
+ resetZoom(options: any): Promise<any>;
63
+ findFeatures(point: any): any[];
64
+ changed(): void;
65
+ transition(options: {
66
+ duration: number;
67
+ }, callback: any): Promise<any>;
68
+ _isTransitioning: boolean;
69
+ /** PRIVATE METHODS */
70
+ _updateSize(): void;
71
+ _size: number[];
72
+ _updateViewportSize(size: any): void;
73
+ _createZoomBehaviour(viewPortSize: any): void;
74
+ _zoomBypassKey: string;
75
+ _zoomBehaviour: any;
76
+ _requestRender(): void;
77
+ _animationFrameRequestID: number;
78
+ _renderFrame(): void;
79
+ }
80
+ export namespace Map {
81
+ let Component: any;
82
+ }