@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,35 @@
1
+ import { createUid } from "../util/uid.js";
2
+ class Dispatcher {
3
+ constructor(target) {
4
+ this._listenersByEvent = /* @__PURE__ */ new Map();
5
+ this.target = target;
6
+ target.on = this.on.bind(this);
7
+ target.unsubscribe = this.unsubscribe.bind(this);
8
+ }
9
+ on(eventType, callback) {
10
+ let listenersForEvent = this._listenersByEvent.get(eventType);
11
+ if (!listenersForEvent) {
12
+ listenersForEvent = /* @__PURE__ */ new Map();
13
+ this._listenersByEvent.set(eventType, listenersForEvent);
14
+ }
15
+ const uid = createUid();
16
+ listenersForEvent.set(uid, callback);
17
+ return uid;
18
+ }
19
+ unsubscribe(eventType, listenerKey) {
20
+ const listenersForEvent = this._listenersByEvent.get(eventType);
21
+ if (!listenersForEvent) return;
22
+ if (!listenersForEvent.has(listenerKey)) return;
23
+ listenersForEvent.delete(listenerKey);
24
+ }
25
+ dispatch(eventType, payload) {
26
+ const listenersForEvent = this._listenersByEvent.get(eventType);
27
+ if (!listenersForEvent) return;
28
+ listenersForEvent.forEach((callback) => {
29
+ callback(this.target, payload);
30
+ });
31
+ }
32
+ }
33
+ export {
34
+ Dispatcher
35
+ };
@@ -0,0 +1,6 @@
1
+ export namespace MapEvent {
2
+ let CHANGE: string;
3
+ let ZOOM: string;
4
+ let TRANSITION_START: string;
5
+ let TRANSITION_END: string;
6
+ }
@@ -0,0 +1,9 @@
1
+ const MapEvent = {
2
+ CHANGE: "change",
3
+ ZOOM: "zoom",
4
+ TRANSITION_START: "transition_start",
5
+ TRANSITION_END: "transition_end"
6
+ };
7
+ export {
8
+ MapEvent
9
+ };
@@ -0,0 +1,2 @@
1
+ export * from './Dispatcher';
2
+ export * from './MapEvent';
@@ -0,0 +1,63 @@
1
+ import { Feature } from '../Feature';
2
+ import { LineString, Polygon, Point } from '../geometry';
3
+ /**
4
+ * @typedef {Object} GeoJSONFeature
5
+ * @property {string} type
6
+ * @property {Object} geometry
7
+ * @property {Record<string, any>} properties
8
+ */
9
+ /**
10
+ * @typedef {Object} GeoJSONFeatureCollection
11
+ * @property {string} type
12
+ * @property {GeoJSONFeature[]} features
13
+ */
14
+ /**
15
+ * @typedef GeoJSONParseOptions
16
+ * @property {boolean} [isProjected=false] - Tells the parser whether the geometry is already projected or not
17
+ */
18
+ export class GeoJSON {
19
+ /**
20
+ * @constructor
21
+ * @param {GeoJSONParseOptions} [parseOptions]
22
+ */
23
+ constructor(parseOptions?: GeoJSONParseOptions);
24
+ isProjected: boolean;
25
+ /**
26
+ * Convert GeoJSON object(s) to array of {@link Feature} objects.
27
+ *
28
+ * @function
29
+ * @param {GeoJSONFeature | GeoJSONFeatureCollection | GeoJSONFeature[]} object GeoJSON object
30
+ * @returns {Feature[]}
31
+ */
32
+ readFeaturesFromObject(object: GeoJSONFeature | GeoJSONFeatureCollection | GeoJSONFeature[]): Feature[];
33
+ /**
34
+ * Convert single GeoJSON feature to {@link Feature} object.
35
+ *
36
+ * @function
37
+ * @param {GeoJSONFeature} geoJSONObject GeoJSON object
38
+ * @returns {Feature | null}
39
+ */
40
+ readFeatureFromObject(geoJSONObject: GeoJSONFeature): Feature | null;
41
+ readGeometriesFromObject(geometry: any): (LineString | Polygon | Point)[];
42
+ readPolygonForCoordinates(coordinates: any): Polygon;
43
+ readLineStringForCoordinates(coordinates: any): LineString;
44
+ readPointForCoordinates(coordinates: any): Point;
45
+ }
46
+ export type GeoJSONFeature = {
47
+ type: string;
48
+ geometry: any;
49
+ properties: Record<string, any>;
50
+ };
51
+ export type GeoJSONFeatureCollection = {
52
+ type: string;
53
+ features: GeoJSONFeature[];
54
+ };
55
+ export type GeoJSONParseOptions = {
56
+ /**
57
+ * - Tells the parser whether the geometry is already projected or not
58
+ */
59
+ /**
60
+ * - Tells the parser whether the geometry is already projected or not
61
+ */
62
+ isProjected?: boolean;
63
+ };
@@ -0,0 +1,122 @@
1
+ import { Feature } from "../Feature.js";
2
+ import { LineString } from "../geometry/LineString.js";
3
+ import { Polygon } from "../geometry/Polygon.js";
4
+ import { Point } from "../geometry/Point.js";
5
+ import { extentForCoordinates } from "../util/extent.js";
6
+ class GeoJSON {
7
+ /**
8
+ * @constructor
9
+ * @param {GeoJSONParseOptions} [parseOptions]
10
+ */
11
+ constructor(parseOptions = {}) {
12
+ this.isProjected = parseOptions == null ? void 0 : parseOptions.isProjected;
13
+ }
14
+ /**
15
+ * Convert GeoJSON object(s) to array of {@link Feature} objects.
16
+ *
17
+ * @function
18
+ * @param {GeoJSONFeature | GeoJSONFeatureCollection | GeoJSONFeature[]} object GeoJSON object
19
+ * @returns {Feature[]}
20
+ */
21
+ readFeaturesFromObject(object) {
22
+ const geoJSONObject = object;
23
+ let features = null;
24
+ if (geoJSONObject["type"] === "FeatureCollection") {
25
+ const geoJSONFeatureCollection = object;
26
+ features = [];
27
+ const geoJSONFeatures = geoJSONFeatureCollection["features"];
28
+ for (let i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
29
+ const featureObject = this.readFeatureFromObject(geoJSONFeatures[i]);
30
+ if (!featureObject) {
31
+ continue;
32
+ }
33
+ features.push(featureObject);
34
+ }
35
+ } else if (geoJSONObject["type"] === "Feature") {
36
+ features = [
37
+ this.readFeatureFromObject(
38
+ /** @type {GeoJSONFeature} */
39
+ geoJSONObject
40
+ )
41
+ ];
42
+ } else if (Array.isArray(geoJSONObject)) {
43
+ features = [];
44
+ for (let i = 0, ii = geoJSONObject.length; i < ii; ++i) {
45
+ const featureObject = this.readFeatureFromObject(geoJSONObject[i]);
46
+ if (!featureObject) {
47
+ continue;
48
+ }
49
+ features.push(featureObject);
50
+ }
51
+ } else {
52
+ try {
53
+ const geometries = this.readGeometriesFromObject(geoJSONObject);
54
+ const feature = new Feature({ geometries });
55
+ features = [feature];
56
+ } catch {
57
+ console.warn("Unable to interpret GeoJSON:", geoJSONObject);
58
+ return;
59
+ }
60
+ }
61
+ return features.flat();
62
+ }
63
+ /**
64
+ * Convert single GeoJSON feature to {@link Feature} object.
65
+ *
66
+ * @function
67
+ * @param {GeoJSONFeature} geoJSONObject GeoJSON object
68
+ * @returns {Feature | null}
69
+ */
70
+ readFeatureFromObject(geoJSONObject) {
71
+ const geometries = this.readGeometriesFromObject(geoJSONObject["geometry"]);
72
+ if (geometries.length > 0) {
73
+ return new Feature({
74
+ id: geoJSONObject["id"],
75
+ geometries,
76
+ properties: geoJSONObject["properties"]
77
+ });
78
+ }
79
+ return null;
80
+ }
81
+ readGeometriesFromObject(geometry) {
82
+ const geometries = [];
83
+ if (geometry.type === "Polygon") {
84
+ const polygon = this.readPolygonForCoordinates(geometry.coordinates);
85
+ geometries.push(polygon);
86
+ } else if (geometry.type === "MultiPolygon") {
87
+ for (const polygonCoordinates of geometry.coordinates) {
88
+ const polygon = this.readPolygonForCoordinates(polygonCoordinates);
89
+ geometries.push(polygon);
90
+ }
91
+ } else if (geometry.type === "LineString") {
92
+ const lineString = this.readLineStringForCoordinates(geometry.coordinates);
93
+ geometries.push(lineString);
94
+ } else if (geometry.type === "MultiLineString") {
95
+ for (const lineStringCoordinates of geometry.coordinates) {
96
+ const lineString = this.readLineStringForCoordinates(
97
+ lineStringCoordinates
98
+ );
99
+ geometries.push(lineString);
100
+ }
101
+ } else if (geometry.type === "Point") {
102
+ const point = this.readPointForCoordinates(geometry.coordinates);
103
+ geometries.push(point);
104
+ }
105
+ return geometries;
106
+ }
107
+ readPolygonForCoordinates(coordinates) {
108
+ const outerRing = coordinates[0];
109
+ const extent = extentForCoordinates(outerRing);
110
+ return new Polygon({ extent, coordinates });
111
+ }
112
+ readLineStringForCoordinates(coordinates) {
113
+ const extent = extentForCoordinates(coordinates);
114
+ return new LineString({ extent, coordinates });
115
+ }
116
+ readPointForCoordinates(coordinates) {
117
+ return new Point({ coordinates });
118
+ }
119
+ }
120
+ export {
121
+ GeoJSON
122
+ };
@@ -0,0 +1,32 @@
1
+ export class Geometry {
2
+ /**
3
+ * Represents vector geometry
4
+ * @constructor
5
+ * @param {Object} options
6
+ * @param {string} options.type - The type of geometry (e.g., 'Point', 'LineString', 'Polygon')
7
+ * @param {import("../util").Extent} options.extent - The extent of the geometry (e.g., [xmin, ymin, xmax, ymax])
8
+ * @param {Array} options.coordinates - The coordinates of the geometry (e.g., [[x1, y1], [x2, y2], ...])
9
+ */
10
+ constructor({ type, extent, coordinates }: {
11
+ type: string;
12
+ extent: import('../util').Extent;
13
+ coordinates: any[];
14
+ });
15
+ type: string;
16
+ extent: import('../util').Extent;
17
+ coordinates: any[];
18
+ getProjected: any;
19
+ /**
20
+ * Returns the geometry as a GeoJSON object
21
+ * @function
22
+ * @param {import("../projection").Projection} projection - The projection to use for the geometry
23
+ * @returns {Object} A GeoJSON representation of the projected geometry
24
+ * @private
25
+ */
26
+ private _getProjected;
27
+ /**
28
+ * Returns the geometry as a GeoJSON object
29
+ * @returns {Object} The GeoJSON representation of the geometry
30
+ */
31
+ getGeoJSON(): any;
32
+ }
@@ -0,0 +1,41 @@
1
+ import { memoise } from "../util/memoise.js";
2
+ class Geometry {
3
+ /**
4
+ * Represents vector geometry
5
+ * @constructor
6
+ * @param {Object} options
7
+ * @param {string} options.type - The type of geometry (e.g., 'Point', 'LineString', 'Polygon')
8
+ * @param {import("../util").Extent} options.extent - The extent of the geometry (e.g., [xmin, ymin, xmax, ymax])
9
+ * @param {Array} options.coordinates - The coordinates of the geometry (e.g., [[x1, y1], [x2, y2], ...])
10
+ */
11
+ constructor({ type, extent, coordinates }) {
12
+ this.type = type;
13
+ this.extent = extent;
14
+ this.coordinates = coordinates;
15
+ this.getProjected = memoise(this._getProjected).bind(this);
16
+ }
17
+ /**
18
+ * Returns the geometry as a GeoJSON object
19
+ * @function
20
+ * @param {import("../projection").Projection} projection - The projection to use for the geometry
21
+ * @returns {Object} A GeoJSON representation of the projected geometry
22
+ * @private
23
+ */
24
+ // eslint-disable-next-line no-unused-vars
25
+ _getProjected(projection) {
26
+ throw new Error("Not implemented");
27
+ }
28
+ /**
29
+ * Returns the geometry as a GeoJSON object
30
+ * @returns {Object} The GeoJSON representation of the geometry
31
+ */
32
+ getGeoJSON() {
33
+ return {
34
+ type: this.type,
35
+ coordinates: this.coordinates
36
+ };
37
+ }
38
+ }
39
+ export {
40
+ Geometry
41
+ };
@@ -0,0 +1,12 @@
1
+ import { Geometry } from './Geometry';
2
+ export class LineString extends Geometry {
3
+ constructor({ type, extent, coordinates }: {
4
+ type?: string;
5
+ extent: any;
6
+ coordinates: any;
7
+ });
8
+ _getProjected(projection: any): {
9
+ type: string;
10
+ coordinates: any[];
11
+ };
12
+ }
@@ -0,0 +1,19 @@
1
+ import { Geometry } from "./Geometry.js";
2
+ class LineString extends Geometry {
3
+ constructor({ type = "LineString", extent, coordinates }) {
4
+ super({ type, extent, coordinates });
5
+ }
6
+ _getProjected(projection) {
7
+ const projected = [];
8
+ for (const point of this.coordinates) {
9
+ projected.push(projection(point));
10
+ }
11
+ return {
12
+ type: this.type,
13
+ coordinates: projected
14
+ };
15
+ }
16
+ }
17
+ export {
18
+ LineString
19
+ };
@@ -0,0 +1,11 @@
1
+ import { Geometry } from './Geometry';
2
+ export class Point extends Geometry {
3
+ constructor({ type, coordinates }: {
4
+ type?: string;
5
+ coordinates: any;
6
+ });
7
+ _getProjected(projection: any): {
8
+ type: string;
9
+ coordinates: any;
10
+ };
11
+ }
@@ -0,0 +1,22 @@
1
+ import { Extent } from "../util/extent.js";
2
+ import { Geometry } from "./Geometry.js";
3
+ class Point extends Geometry {
4
+ constructor({ type = "Point", coordinates }) {
5
+ super({ type, extent: null, coordinates });
6
+ this.extent = new Extent(
7
+ coordinates[0],
8
+ coordinates[1],
9
+ coordinates[0],
10
+ coordinates[1]
11
+ );
12
+ }
13
+ _getProjected(projection) {
14
+ return {
15
+ type: this.type,
16
+ coordinates: projection(this.coordinates)
17
+ };
18
+ }
19
+ }
20
+ export {
21
+ Point
22
+ };
@@ -0,0 +1,16 @@
1
+ import { Geometry } from './Geometry';
2
+ export class Polygon extends Geometry {
3
+ constructor({ type, extent, coordinates }: {
4
+ type?: string;
5
+ extent: any;
6
+ coordinates: any;
7
+ });
8
+ _getProjected(projection: any): {
9
+ type: string;
10
+ coordinates: any[][];
11
+ };
12
+ getOuterRing(): any;
13
+ setOuterRing(coordinates: any): void;
14
+ setCoordinates(coordinates: any): void;
15
+ clone(): Polygon;
16
+ }
@@ -0,0 +1,46 @@
1
+ import { Geometry } from "./Geometry.js";
2
+ class Polygon extends Geometry {
3
+ constructor({ type = "Polygon", extent, coordinates }) {
4
+ super({ type, extent, coordinates });
5
+ }
6
+ _getProjected(projection) {
7
+ const projected = [];
8
+ const rings = this.coordinates;
9
+ for (const ring of rings) {
10
+ const projectedRing = [];
11
+ for (const point of ring) {
12
+ const projectedPoint = projection(point);
13
+ if (projectedPoint) {
14
+ projectedRing.push(projectedPoint);
15
+ } else {
16
+ break;
17
+ }
18
+ }
19
+ if (projectedRing.length > 0) {
20
+ projected.push(projectedRing);
21
+ }
22
+ }
23
+ return {
24
+ type: this.type,
25
+ coordinates: projected
26
+ };
27
+ }
28
+ getOuterRing() {
29
+ return this.coordinates[0];
30
+ }
31
+ setOuterRing(coordinates) {
32
+ this.coordinates[0] = coordinates;
33
+ }
34
+ setCoordinates(coordinates) {
35
+ this.coordinates = coordinates;
36
+ }
37
+ clone() {
38
+ return new Polygon({
39
+ extent: this.extent,
40
+ coordinates: JSON.parse(JSON.stringify(this.coordinates))
41
+ });
42
+ }
43
+ }
44
+ export {
45
+ Polygon
46
+ };
@@ -0,0 +1,4 @@
1
+ export * from './Geometry';
2
+ export * from './LineString';
3
+ export * from './Polygon';
4
+ export * from './Point';
@@ -0,0 +1,2 @@
1
+ export * from './interpolateFeatures';
2
+ export * from './interpolateStyles';
@@ -0,0 +1,5 @@
1
+ export function interpolateFeatures(currentFeatures: any, newFeatures: any, { interpolate, separate, combine }: {
2
+ interpolate: any;
3
+ separate: any;
4
+ combine: any;
5
+ }): (t: any) => any;
@@ -0,0 +1,95 @@
1
+ function interpolateFeatures(currentFeatures, newFeatures, { interpolate, separate, combine }) {
2
+ if (currentFeatures.length !== newFeatures.length) {
3
+ throw new Error(
4
+ "interpolateFeatures expects an equal number of features for start and end"
5
+ );
6
+ }
7
+ const featureInterpolators = [];
8
+ for (let i = 0; i < currentFeatures.length; i++) {
9
+ const geometryInterpolators = [];
10
+ const currentGeometries = currentFeatures[i].geometries;
11
+ const newGeometries = newFeatures[i].geometries;
12
+ if (newGeometries.length === currentGeometries.length) {
13
+ for (let e = 0; e < currentGeometries.length; e++) {
14
+ const currentGeometry = currentGeometries[e];
15
+ const newGeometry = newGeometries[e];
16
+ if (currentGeometry.type !== "Polygon" || newGeometry.type !== "Polygon") {
17
+ throw new Error("interpolateFeatures expects only Polygon geometry");
18
+ }
19
+ const shapeInterpolator = interpolate(
20
+ currentGeometries[e].getOuterRing(),
21
+ newGeometries[e].getOuterRing(),
22
+ { string: false }
23
+ );
24
+ geometryInterpolators.push({
25
+ type: "default",
26
+ interpolator: shapeInterpolator
27
+ });
28
+ }
29
+ } else if (currentGeometries.length === 1 && newGeometries.length > 1) {
30
+ const separationInterpolator = separate(
31
+ currentGeometries[0].getOuterRing(),
32
+ newGeometries.map((geometry) => geometry.getOuterRing()),
33
+ { string: false, single: true }
34
+ );
35
+ geometryInterpolators.push({
36
+ type: "separate",
37
+ interpolator: separationInterpolator
38
+ });
39
+ } else if (currentGeometries.length > 1 && newGeometries.length === 1) {
40
+ const combinationInterpolator = combine(
41
+ currentGeometries.map((geometry) => geometry.getOuterRing()),
42
+ newGeometries[0].getOuterRing(),
43
+ { string: false, single: true }
44
+ );
45
+ geometryInterpolators.push({
46
+ type: "combine",
47
+ interpolator: combinationInterpolator
48
+ });
49
+ } else {
50
+ throw new Error(
51
+ `Encountered an unexpected number of geometries: ${currentGeometries.length} and ${newGeometries.length}`
52
+ );
53
+ }
54
+ featureInterpolators.push(geometryInterpolators);
55
+ }
56
+ return (t) => {
57
+ if (t >= 1) {
58
+ return newFeatures;
59
+ }
60
+ const features = [];
61
+ for (let i = 0; i < featureInterpolators.length; i++) {
62
+ const feature = newFeatures[i].clone();
63
+ const geometries = [];
64
+ const geometryInterpolators = featureInterpolators[i];
65
+ for (const [
66
+ index,
67
+ { type, interpolator }
68
+ ] of geometryInterpolators.entries()) {
69
+ let geometry = feature.geometries[index].clone();
70
+ let interpolated;
71
+ switch (type) {
72
+ case "separate":
73
+ case "combine":
74
+ interpolated = interpolator(t);
75
+ interpolated.forEach((d) => {
76
+ const polygon = geometry.clone();
77
+ polygon.setCoordinates([d]);
78
+ geometries.push(polygon);
79
+ });
80
+ break;
81
+ default:
82
+ geometry.setOuterRing(interpolator(t));
83
+ geometries.push(geometry);
84
+ break;
85
+ }
86
+ }
87
+ feature.setGeometry(geometries);
88
+ features.push(feature);
89
+ }
90
+ return features;
91
+ };
92
+ }
93
+ export {
94
+ interpolateFeatures
95
+ };
@@ -0,0 +1,4 @@
1
+ import { Style, Fill, Stroke } from '../styles';
2
+ export function interpolateStyles(firstStyle: any, secondStyle: any, interpolateColors: any, interpolateNumbers: any): (t: any) => Style;
3
+ export function interpolateFill(fillA: any, fillB: any, interpolateColors: any, interpolateNumbers: any): (t: any) => Fill;
4
+ export function interpolateStroke(strokeA: any, strokeB: any, interpolateColors: any, interpolateNumbers: any): (t: any) => Stroke;
@@ -0,0 +1,65 @@
1
+ import { Style } from "../styles/Style.js";
2
+ import { Stroke } from "../styles/Stroke.js";
3
+ import { Fill } from "../styles/Fill.js";
4
+ function interpolateStyles(firstStyle, secondStyle, interpolateColors, interpolateNumbers) {
5
+ const fillInterpolator = interpolateFill(
6
+ firstStyle.fill,
7
+ secondStyle.fill,
8
+ interpolateColors,
9
+ interpolateNumbers
10
+ );
11
+ const strokeInterpolator = interpolateStroke(
12
+ firstStyle.stroke,
13
+ secondStyle.stroke,
14
+ interpolateColors,
15
+ interpolateNumbers
16
+ );
17
+ return (t) => {
18
+ return new Style({
19
+ fill: fillInterpolator(t),
20
+ stroke: strokeInterpolator(t)
21
+ });
22
+ };
23
+ }
24
+ function interpolateFill(fillA, fillB, interpolateColors, interpolateNumbers) {
25
+ const colorInterpolator = interpolateColors(
26
+ (fillA == null ? void 0 : fillA.color) ?? "transparent",
27
+ (fillB == null ? void 0 : fillB.color) ?? "transparent"
28
+ );
29
+ const opacityInterpolator = interpolateNumbers(
30
+ (fillA == null ? void 0 : fillA.opacity) ?? 1,
31
+ (fillB == null ? void 0 : fillB.opacity) ?? 1
32
+ );
33
+ return (t) => {
34
+ return new Fill({
35
+ color: colorInterpolator(t),
36
+ opacity: opacityInterpolator(t)
37
+ });
38
+ };
39
+ }
40
+ function interpolateStroke(strokeA, strokeB, interpolateColors, interpolateNumbers) {
41
+ const colorInterpolator = interpolateColors(
42
+ (strokeA == null ? void 0 : strokeA.color) ?? "transparent",
43
+ (strokeB == null ? void 0 : strokeB.color) ?? "transparent"
44
+ );
45
+ const opacityInterpolator = interpolateNumbers(
46
+ (strokeA == null ? void 0 : strokeA.opacity) ?? 1,
47
+ (strokeB == null ? void 0 : strokeB.opacity) ?? 1
48
+ );
49
+ const widthInterpolator = interpolateNumbers(
50
+ (strokeA == null ? void 0 : strokeA.width) ?? 1,
51
+ (strokeB == null ? void 0 : strokeB.width) ?? 1
52
+ );
53
+ return (t) => {
54
+ return new Stroke({
55
+ color: colorInterpolator(t),
56
+ opacity: opacityInterpolator(t),
57
+ width: widthInterpolator(t)
58
+ });
59
+ };
60
+ }
61
+ export {
62
+ interpolateFill,
63
+ interpolateStroke,
64
+ interpolateStyles
65
+ };