@guardian/interactive-component-library 0.2.0-rc3 → 0.2.0

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 (276) hide show
  1. package/dist/interactive-component-library.js +8338 -0
  2. package/dist/interactive-component-library.js.map +1 -0
  3. package/dist/interactive-component-library.umd.cjs +8333 -0
  4. package/dist/interactive-component-library.umd.cjs.map +1 -0
  5. package/dist/style.css +157 -73
  6. package/package.json +10 -6
  7. package/dist/components/index.d.ts +0 -3
  8. package/dist/components/molecules/canvas-map/Map.d.ts +0 -17
  9. package/dist/components/molecules/canvas-map/Map.js +0 -89
  10. package/dist/components/molecules/canvas-map/context/MapContext.d.ts +0 -19
  11. package/dist/components/molecules/canvas-map/context/MapContext.js +0 -20
  12. package/dist/components/molecules/canvas-map/controls/ZoomControl.d.ts +0 -6
  13. package/dist/components/molecules/canvas-map/controls/ZoomControl.js +0 -40
  14. package/dist/components/molecules/canvas-map/controls/icons/index.d.ts +0 -3
  15. package/dist/components/molecules/canvas-map/controls/icons/minus.d.ts +0 -1
  16. package/dist/components/molecules/canvas-map/controls/icons/minus.js +0 -25
  17. package/dist/components/molecules/canvas-map/controls/icons/plus.d.ts +0 -1
  18. package/dist/components/molecules/canvas-map/controls/icons/plus.js +0 -25
  19. package/dist/components/molecules/canvas-map/controls/icons/reset.d.ts +0 -3
  20. package/dist/components/molecules/canvas-map/controls/icons/reset.js +0 -25
  21. package/dist/components/molecules/canvas-map/controls/index.d.ts +0 -1
  22. package/dist/components/molecules/canvas-map/controls/style.module.css.js +0 -11
  23. package/dist/components/molecules/canvas-map/index.d.ts +0 -12
  24. package/dist/components/molecules/canvas-map/lib/Feature.d.ts +0 -38
  25. package/dist/components/molecules/canvas-map/lib/Feature.js +0 -104
  26. package/dist/components/molecules/canvas-map/lib/FeatureCollection.d.ts +0 -20
  27. package/dist/components/molecules/canvas-map/lib/FeatureCollection.js +0 -23
  28. package/dist/components/molecules/canvas-map/lib/Map.d.ts +0 -69
  29. package/dist/components/molecules/canvas-map/lib/Map.js +0 -254
  30. package/dist/components/molecules/canvas-map/lib/View.d.ts +0 -136
  31. package/dist/components/molecules/canvas-map/lib/View.js +0 -179
  32. package/dist/components/molecules/canvas-map/lib/events/Dispatcher.d.ts +0 -8
  33. package/dist/components/molecules/canvas-map/lib/events/Dispatcher.js +0 -35
  34. package/dist/components/molecules/canvas-map/lib/events/MapEvent.d.ts +0 -6
  35. package/dist/components/molecules/canvas-map/lib/events/MapEvent.js +0 -9
  36. package/dist/components/molecules/canvas-map/lib/events/index.d.ts +0 -2
  37. package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.d.ts +0 -10
  38. package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.js +0 -96
  39. package/dist/components/molecules/canvas-map/lib/geometry/Geometry.d.ts +0 -32
  40. package/dist/components/molecules/canvas-map/lib/geometry/Geometry.js +0 -41
  41. package/dist/components/molecules/canvas-map/lib/geometry/LineString.d.ts +0 -12
  42. package/dist/components/molecules/canvas-map/lib/geometry/LineString.js +0 -19
  43. package/dist/components/molecules/canvas-map/lib/geometry/Point.d.ts +0 -11
  44. package/dist/components/molecules/canvas-map/lib/geometry/Point.js +0 -16
  45. package/dist/components/molecules/canvas-map/lib/geometry/Polygon.d.ts +0 -16
  46. package/dist/components/molecules/canvas-map/lib/geometry/Polygon.js +0 -46
  47. package/dist/components/molecules/canvas-map/lib/geometry/index.d.ts +0 -4
  48. package/dist/components/molecules/canvas-map/lib/interpolators/index.d.ts +0 -2
  49. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.d.ts +0 -5
  50. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.js +0 -95
  51. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.d.ts +0 -4
  52. package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.js +0 -65
  53. package/dist/components/molecules/canvas-map/lib/layers/TextLayer.d.ts +0 -52
  54. package/dist/components/molecules/canvas-map/lib/layers/TextLayer.js +0 -111
  55. package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.d.ts +0 -53
  56. package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.js +0 -132
  57. package/dist/components/molecules/canvas-map/lib/layers/index.d.ts +0 -3
  58. package/dist/components/molecules/canvas-map/lib/projection/index.d.ts +0 -22
  59. package/dist/components/molecules/canvas-map/lib/projection/index.js +0 -12
  60. package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.d.ts +0 -6
  61. package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.js +0 -46
  62. package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.d.ts +0 -6
  63. package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.js +0 -53
  64. package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.d.ts +0 -17
  65. package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.js +0 -119
  66. package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.d.ts +0 -10
  67. package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.js +0 -78
  68. package/dist/components/molecules/canvas-map/lib/sources/VectorSource.d.ts +0 -15
  69. package/dist/components/molecules/canvas-map/lib/sources/VectorSource.js +0 -56
  70. package/dist/components/molecules/canvas-map/lib/styles/Fill.d.ts +0 -7
  71. package/dist/components/molecules/canvas-map/lib/styles/Fill.js +0 -15
  72. package/dist/components/molecules/canvas-map/lib/styles/Stroke.d.ts +0 -8
  73. package/dist/components/molecules/canvas-map/lib/styles/Stroke.js +0 -16
  74. package/dist/components/molecules/canvas-map/lib/styles/Style.d.ts +0 -24
  75. package/dist/components/molecules/canvas-map/lib/styles/Style.js +0 -17
  76. package/dist/components/molecules/canvas-map/lib/styles/Text.d.ts +0 -10
  77. package/dist/components/molecules/canvas-map/lib/styles/Text.js +0 -14
  78. package/dist/components/molecules/canvas-map/lib/styles/index.d.ts +0 -4
  79. package/dist/components/molecules/canvas-map/lib/util/array.d.ts +0 -6
  80. package/dist/components/molecules/canvas-map/lib/util/array.js +0 -15
  81. package/dist/components/molecules/canvas-map/lib/util/bboxFeature.d.ts +0 -8
  82. package/dist/components/molecules/canvas-map/lib/util/bboxFeature.js +0 -26
  83. package/dist/components/molecules/canvas-map/lib/util/debug.d.ts +0 -11
  84. package/dist/components/molecules/canvas-map/lib/util/debug.js +0 -27
  85. package/dist/components/molecules/canvas-map/lib/util/deflate.d.ts +0 -36
  86. package/dist/components/molecules/canvas-map/lib/util/distance.d.ts +0 -1
  87. package/dist/components/molecules/canvas-map/lib/util/distance.js +0 -12
  88. package/dist/components/molecules/canvas-map/lib/util/dom.d.ts +0 -9
  89. package/dist/components/molecules/canvas-map/lib/util/dom.js +0 -28
  90. package/dist/components/molecules/canvas-map/lib/util/extent.d.ts +0 -21
  91. package/dist/components/molecules/canvas-map/lib/util/extent.js +0 -38
  92. package/dist/components/molecules/canvas-map/lib/util/memoise.d.ts +0 -10
  93. package/dist/components/molecules/canvas-map/lib/util/memoise.js +0 -20
  94. package/dist/components/molecules/canvas-map/lib/util/resolution.d.ts +0 -9
  95. package/dist/components/molecules/canvas-map/lib/util/resolution.js +0 -11
  96. package/dist/components/molecules/canvas-map/lib/util/simplify.d.ts +0 -114
  97. package/dist/components/molecules/canvas-map/lib/util/size.d.ts +0 -32
  98. package/dist/components/molecules/canvas-map/lib/util/size.js +0 -53
  99. package/dist/components/molecules/canvas-map/lib/util/toRgba.d.ts +0 -1
  100. package/dist/components/molecules/canvas-map/lib/util/toRgba.js +0 -25
  101. package/dist/components/molecules/canvas-map/lib/util/uid.d.ts +0 -5
  102. package/dist/components/molecules/canvas-map/lib/util/uid.js +0 -7
  103. package/dist/components/molecules/canvas-map/lib/util/zoomLevel.d.ts +0 -2
  104. package/dist/components/molecules/canvas-map/lib/util/zoomLevel.js +0 -14
  105. package/dist/components/molecules/canvas-map/style.module.scss.js +0 -20
  106. package/dist/components/molecules/column-chart/column-chart-example.d.ts +0 -35
  107. package/dist/components/molecules/column-chart/column-chart-util.d.ts +0 -1
  108. package/dist/components/molecules/column-chart/index.d.ts +0 -11
  109. package/dist/components/molecules/column-chart/index.js +0 -63
  110. package/dist/components/molecules/column-chart/style.module.css.js +0 -14
  111. package/dist/components/molecules/control-change/index.d.ts +0 -6
  112. package/dist/components/molecules/control-change/index.js +0 -29
  113. package/dist/components/molecules/control-change/style.module.css.js +0 -11
  114. package/dist/components/molecules/dropdown/index.d.ts +0 -11
  115. package/dist/components/molecules/dropdown/index.js +0 -191
  116. package/dist/components/molecules/dropdown/style.module.css.js +0 -50
  117. package/dist/components/molecules/first-past-the-post-waffle/index.d.ts +0 -5
  118. package/dist/components/molecules/first-past-the-post-waffle/index.js +0 -14
  119. package/dist/components/molecules/first-past-the-post-waffle/style.module.css.js +0 -14
  120. package/dist/components/molecules/index.d.ts +0 -17
  121. package/dist/components/molecules/modal/index.d.ts +0 -8
  122. package/dist/components/molecules/modal/index.js +0 -59
  123. package/dist/components/molecules/modal/style.module.css.js +0 -26
  124. package/dist/components/molecules/page-section/index.d.ts +0 -8
  125. package/dist/components/molecules/page-section/index.js +0 -52
  126. package/dist/components/molecules/page-section/style.module.scss.js +0 -20
  127. package/dist/components/molecules/party-profile/index.d.ts +0 -10
  128. package/dist/components/molecules/party-profile/index.js +0 -29
  129. package/dist/components/molecules/party-profile/style.module.css.js +0 -26
  130. package/dist/components/molecules/refresh-indicator/index.d.ts +0 -4
  131. package/dist/components/molecules/refresh-indicator/index.js +0 -18
  132. package/dist/components/molecules/refresh-indicator/style.module.scss.js +0 -17
  133. package/dist/components/molecules/responsive-grid/index.d.ts +0 -10
  134. package/dist/components/molecules/responsive-grid/index.js +0 -19
  135. package/dist/components/molecules/responsive-grid/style.module.scss.js +0 -8
  136. package/dist/components/molecules/result-summary/index.d.ts +0 -8
  137. package/dist/components/molecules/result-summary/index.js +0 -38
  138. package/dist/components/molecules/result-summary/style.module.css.js +0 -11
  139. package/dist/components/molecules/search-input/icons/search.d.ts +0 -1
  140. package/dist/components/molecules/search-input/icons/search.js +0 -24
  141. package/dist/components/molecules/search-input/icons/search.module.css.js +0 -11
  142. package/dist/components/molecules/search-input/index.d.ts +0 -11
  143. package/dist/components/molecules/search-input/index.js +0 -164
  144. package/dist/components/molecules/search-input/style.module.css.js +0 -32
  145. package/dist/components/molecules/slope-chart/index.d.ts +0 -16
  146. package/dist/components/molecules/slope-chart/index.js +0 -139
  147. package/dist/components/molecules/slope-chart/style.module.css.js +0 -35
  148. package/dist/components/molecules/svg-map/context/MapContext.d.ts +0 -1
  149. package/dist/components/molecules/svg-map/context/MapContext.js +0 -5
  150. package/dist/components/molecules/svg-map/context/SVGMapProvider.d.ts +0 -10
  151. package/dist/components/molecules/svg-map/context/SVGMapProvider.js +0 -88
  152. package/dist/components/molecules/svg-map/helpers/bboxFeature.d.ts +0 -8
  153. package/dist/components/molecules/svg-map/helpers/bboxFeature.js +0 -26
  154. package/dist/components/molecules/svg-map/helpers/dynamicPropValue.d.ts +0 -1
  155. package/dist/components/molecules/svg-map/helpers/dynamicPropValue.js +0 -9
  156. package/dist/components/molecules/svg-map/helpers/geoMath.d.ts +0 -4
  157. package/dist/components/molecules/svg-map/helpers/saveSVG.d.ts +0 -1
  158. package/dist/components/molecules/svg-map/hooks/useCamera.d.ts +0 -0
  159. package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.d.ts +0 -4
  160. package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.js +0 -19
  161. package/dist/components/molecules/svg-map/index.d.ts +0 -38
  162. package/dist/components/molecules/svg-map/index.js +0 -121
  163. package/dist/components/molecules/svg-map/layers/CompositionBorders.d.ts +0 -3
  164. package/dist/components/molecules/svg-map/layers/CompositionBorders.js +0 -14
  165. package/dist/components/molecules/svg-map/layers/Line.d.ts +0 -7
  166. package/dist/components/molecules/svg-map/layers/Line.js +0 -48
  167. package/dist/components/molecules/svg-map/layers/Point.d.ts +0 -10
  168. package/dist/components/molecules/svg-map/layers/Point.js +0 -59
  169. package/dist/components/molecules/svg-map/layers/Polygon.d.ts +0 -9
  170. package/dist/components/molecules/svg-map/layers/Polygon.js +0 -75
  171. package/dist/components/molecules/svg-map/layers/Prerendered.d.ts +0 -3
  172. package/dist/components/molecules/svg-map/layers/Prerendered.js +0 -11
  173. package/dist/components/molecules/svg-map/layers/compositionBorders.module.scss.js +0 -8
  174. package/dist/components/molecules/svg-map/layers/index.d.ts +0 -5
  175. package/dist/components/molecules/svg-map/layers/index.js +0 -12
  176. package/dist/components/molecules/svg-map/renderers/SVGRenderer.d.ts +0 -3
  177. package/dist/components/molecules/svg-map/renderers/SVGRenderer.js +0 -32
  178. package/dist/components/molecules/svg-map/style.module.css.js +0 -11
  179. package/dist/components/molecules/table/index.d.ts +0 -7
  180. package/dist/components/molecules/table/index.js +0 -90
  181. package/dist/components/molecules/table/style.module.scss.js +0 -29
  182. package/dist/components/molecules/table/useTable.d.ts +0 -8
  183. package/dist/components/molecules/table/useTable.js +0 -128
  184. package/dist/components/molecules/tooltip/index.d.ts +0 -82
  185. package/dist/components/molecules/tooltip/index.js +0 -117
  186. package/dist/components/molecules/tooltip/style.module.css.js +0 -8
  187. package/dist/components/molecules/topline-result/index.d.ts +0 -3
  188. package/dist/components/molecules/topline-result/index.js +0 -61
  189. package/dist/components/molecules/topline-result/style.module.scss.js +0 -38
  190. package/dist/components/organisms/coalitions-tracker/index.d.ts +0 -16
  191. package/dist/components/organisms/coalitions-tracker/index.js +0 -151
  192. package/dist/components/organisms/coalitions-tracker/style.module.scss.js +0 -32
  193. package/dist/components/organisms/index.d.ts +0 -2
  194. package/dist/components/organisms/ticker/gradient/index.d.ts +0 -1
  195. package/dist/components/organisms/ticker/gradient/index.js +0 -35
  196. package/dist/components/organisms/ticker/gradient/style.module.scss.js +0 -14
  197. package/dist/components/organisms/ticker/index.d.ts +0 -5
  198. package/dist/components/organisms/ticker/index.js +0 -102
  199. package/dist/components/organisms/ticker/style.module.scss.js +0 -32
  200. package/dist/components/particles/ad-slot/index.d.ts +0 -40
  201. package/dist/components/particles/ad-slot/index.js +0 -34
  202. package/dist/components/particles/ad-slot/style.module.css.js +0 -11
  203. package/dist/components/particles/arrow-button/index.d.ts +0 -6
  204. package/dist/components/particles/arrow-button/index.js +0 -32
  205. package/dist/components/particles/arrow-button/style.module.css.js +0 -11
  206. package/dist/components/particles/aspect-ratio-box/index.d.ts +0 -4
  207. package/dist/components/particles/aspect-ratio-box/index.js +0 -15
  208. package/dist/components/particles/aspect-ratio-box/style.module.css.js +0 -6
  209. package/dist/components/particles/button/index.d.ts +0 -6
  210. package/dist/components/particles/button/index.js +0 -10
  211. package/dist/components/particles/button/style.module.css.js +0 -11
  212. package/dist/components/particles/change-bar/index.d.ts +0 -8
  213. package/dist/components/particles/change-bar/index.js +0 -27
  214. package/dist/components/particles/change-bar/style.module.scss.js +0 -14
  215. package/dist/components/particles/chevron/index.d.ts +0 -6
  216. package/dist/components/particles/chevron/index.js +0 -78
  217. package/dist/components/particles/chevron/style.module.css.js +0 -20
  218. package/dist/components/particles/circle-icon/index.d.ts +0 -6
  219. package/dist/components/particles/circle-icon/index.js +0 -32
  220. package/dist/components/particles/circle-icon/style.module.css.js +0 -14
  221. package/dist/components/particles/close-button/index.d.ts +0 -5
  222. package/dist/components/particles/close-button/index.js +0 -35
  223. package/dist/components/particles/close-button/style.module.css.js +0 -17
  224. package/dist/components/particles/container/index.d.ts +0 -5
  225. package/dist/components/particles/container/index.js +0 -13
  226. package/dist/components/particles/container/style.module.scss.js +0 -11
  227. package/dist/components/particles/gradient-icon/index.d.ts +0 -1
  228. package/dist/components/particles/gradient-icon/index.js +0 -46
  229. package/dist/components/particles/gradient-icon/style.module.css.js +0 -14
  230. package/dist/components/particles/index.d.ts +0 -18
  231. package/dist/components/particles/info-button/index.d.ts +0 -3
  232. package/dist/components/particles/info-button/index.js +0 -19
  233. package/dist/components/particles/info-button/style.module.css.js +0 -11
  234. package/dist/components/particles/legend-item/index.d.ts +0 -6
  235. package/dist/components/particles/legend-item/index.js +0 -26
  236. package/dist/components/particles/legend-item/style.module.css.js +0 -17
  237. package/dist/components/particles/relative-time-sentence/index.d.ts +0 -4
  238. package/dist/components/particles/relative-time-sentence/index.js +0 -14
  239. package/dist/components/particles/relative-time-sentence/style.module.css.js +0 -8
  240. package/dist/components/particles/square-cut-corner-icon/index.d.ts +0 -6
  241. package/dist/components/particles/square-cut-corner-icon/index.js +0 -56
  242. package/dist/components/particles/square-cut-corner-icon/style.module.scss.js +0 -17
  243. package/dist/components/particles/square-icon/index.d.ts +0 -5
  244. package/dist/components/particles/square-icon/index.js +0 -28
  245. package/dist/components/particles/square-icon/style.module.scss.js +0 -11
  246. package/dist/components/particles/stacked-bar/index.d.ts +0 -23
  247. package/dist/components/particles/stacked-bar/index.js +0 -140
  248. package/dist/components/particles/stacked-bar/style.module.css.js +0 -17
  249. package/dist/components/particles/stacked-grid/index.d.ts +0 -6
  250. package/dist/components/particles/stacked-grid/index.js +0 -35
  251. package/dist/components/particles/stacked-grid/style.module.css.js +0 -20
  252. package/dist/components/particles/waffle/index.d.ts +0 -14
  253. package/dist/components/particles/waffle/index.js +0 -76
  254. package/dist/components/particles/waffle/style.module.css.js +0 -11
  255. package/dist/index.d.ts +0 -2
  256. package/dist/index.js +0 -128
  257. package/dist/shared/colors/index.d.ts +0 -2
  258. package/dist/shared/helpers/createStore.d.ts +0 -1
  259. package/dist/shared/helpers/geometry.d.ts +0 -3
  260. package/dist/shared/helpers/geometry.js +0 -16
  261. package/dist/shared/helpers/geometry.test.d.ts +0 -1
  262. package/dist/shared/helpers/labelsUtil.d.ts +0 -54
  263. package/dist/shared/helpers/labelsUtil.js +0 -58
  264. package/dist/shared/helpers/labelsUtils.test.d.ts +0 -1
  265. package/dist/shared/helpers/shouldUpdate.d.ts +0 -7
  266. package/dist/shared/hooks/index.d.ts +0 -3
  267. package/dist/shared/hooks/useContainerSize.d.ts +0 -1
  268. package/dist/shared/hooks/useContainerSize.js +0 -24
  269. package/dist/shared/hooks/useTouchOrHover.d.ts +0 -6
  270. package/dist/shared/hooks/useTouchOrHover.js +0 -95
  271. package/dist/shared/hooks/useWindowSize.d.ts +0 -4
  272. package/dist/shared/hooks/useWindowSize.js +0 -27
  273. package/dist/styles/helpers/mergeStyles.d.ts +0 -1
  274. package/dist/styles/helpers/mergeStyles.js +0 -22
  275. package/dist/styles/helpers/mergeStyles.test.d.ts +0 -1
  276. package/dist/styles/theme.config.d.ts +0 -124
@@ -1,179 +0,0 @@
1
- import { scaleSize, scalePadding, sizeMinusPadding } from "./util/size.js";
2
- import { bboxFeature } from "./util/bboxFeature.js";
3
- import { zoomIdentity, ZoomTransform } from "d3-zoom";
4
- import { zoomLevelToZoomScale, zoomLevelForResolution } from "./util/zoomLevel.js";
5
- import { resolutionForExtent } from "./util/resolution.js";
6
- import { Projection } from "./projection/index.js";
7
- import { generateDebugUrl } from "./util/debug.js";
8
- class View {
9
- constructor({
10
- projection = Projection.geoIdentity,
11
- extent,
12
- minZoom = 1,
13
- maxZoom = 10,
14
- padding = { top: 0, right: 0, bottom: 0, left: 0 }
15
- }, debug = false) {
16
- this.debug = debug;
17
- projection.revision = 0;
18
- this.projection = projection;
19
- this.extent = extent;
20
- this.minZoom = minZoom;
21
- this.maxZoom = maxZoom;
22
- this._transform = zoomIdentity;
23
- this._padding = padding;
24
- this._viewPortSize = [0, 0];
25
- this.pixelRatio = window.devicePixelRatio;
26
- }
27
- set viewPortSize(size) {
28
- const previousSize = this._viewPortSize;
29
- this._viewPortSize = size;
30
- if (previousSize !== size) {
31
- if (this.extent) {
32
- this.fitExtent(this.extent);
33
- }
34
- }
35
- }
36
- get viewPortSize() {
37
- return this._viewPortSize;
38
- }
39
- set transform(transform) {
40
- this._transform = transform;
41
- }
42
- get transform() {
43
- return new ZoomTransform(
44
- this._transform.k,
45
- this._transform.x * this.pixelRatio,
46
- this._transform.y * this.pixelRatio
47
- );
48
- }
49
- // map size in pixels (i.e. scaled by device pixel ratio)
50
- get mapSize() {
51
- return scaleSize(this.viewPortSize, this.pixelRatio);
52
- }
53
- get padding() {
54
- return this._padding;
55
- }
56
- // padding in pixels (i.e. scaled by device pixel ratio)
57
- get scaledPadding() {
58
- const scaledPadding = { ...this._padding };
59
- return scalePadding(scaledPadding, this.pixelRatio);
60
- }
61
- get baseResolution() {
62
- const baseExtent = this.getVisibleExtent(zoomIdentity, this.projection);
63
- const baseResolution = resolutionForExtent(baseExtent, this.viewPortSize);
64
- return baseResolution;
65
- }
66
- // calculates the upper and lower zoom scales
67
- get scaleExtent() {
68
- const maxScale = zoomLevelToZoomScale(this.maxZoom, this.baseResolution);
69
- return [1, maxScale];
70
- }
71
- setProjection(projection) {
72
- this.projection = projection;
73
- this.fitObject(bboxFeature(this.extent));
74
- }
75
- // only set the raw projection when it has already been configured with projection.fitExtent()
76
- setRawProjection(projection) {
77
- this.projection = projection;
78
- }
79
- fitExtent(extent) {
80
- const extentFeature = bboxFeature(extent);
81
- this.fitObject(extentFeature);
82
- if (this.debug) {
83
- console.log("Fit extent", extent, generateDebugUrl(extentFeature, false));
84
- }
85
- }
86
- fitObject(geoJSON) {
87
- this.projection.fitExtent(this.getMapExtent(), geoJSON);
88
- ++this.projection.revision;
89
- }
90
- // returns bounds relative to the viewport
91
- boundsForExtent(extent) {
92
- const SW = this.projection([extent[0], extent[1]]);
93
- const NE = this.projection([extent[2], extent[3]]);
94
- const minX = SW[0] / this.pixelRatio;
95
- const minY = NE[1] / this.pixelRatio;
96
- const maxX = NE[0] / this.pixelRatio;
97
- const maxY = SW[1] / this.pixelRatio;
98
- const width = maxX - minX;
99
- const height = maxY - minY;
100
- return [
101
- [minX, minY],
102
- [width, height]
103
- ];
104
- }
105
- invert(point) {
106
- const { projection, pixelRatio, transform } = this.getState();
107
- const scaledPoint = [point[0] * pixelRatio, point[1] * pixelRatio];
108
- const untransformedPoint = transform.invert(scaledPoint);
109
- const mapCoordinate = projection.invert(untransformedPoint);
110
- return mapCoordinate;
111
- }
112
- // bounds is defined as [[minX, minY], [maxX, maxY]]
113
- invertBounds(bounds) {
114
- const topLeft = bounds[0];
115
- const topRight = [bounds[1][0], bounds[0][1]];
116
- const bottomRight = [bounds[1][0], bounds[1][1]];
117
- const bottomLeft = [bounds[0][0], bounds[1][1]];
118
- const points = [topLeft, topRight, bottomRight, bottomLeft, topLeft];
119
- return points.map((d) => this.invert(d));
120
- }
121
- // map resolution (meters per pixel)
122
- getResolution() {
123
- return resolutionForExtent(
124
- this.getVisibleExtent(this.transform, this.projection),
125
- this.viewPortSize
126
- );
127
- }
128
- // map zoom level (0 = the entire world)
129
- getZoomLevel() {
130
- return zoomLevelForResolution(this.getResolution());
131
- }
132
- //
133
- /**
134
- * Function that returns the extent of the view in screen coordinates
135
- * The extent is defined as [[minX, minY], [maxX, maxY]]
136
- * @function getMapExtent
137
- * @returns {[[number, number], [number, number]]}
138
- */
139
- getMapExtent() {
140
- const mapSizeInPixels = this.mapSize;
141
- const paddingInPixels = this.scaledPadding;
142
- return [
143
- [paddingInPixels.left, paddingInPixels.top],
144
- sizeMinusPadding(mapSizeInPixels, {
145
- ...paddingInPixels,
146
- left: 0,
147
- top: 0
148
- })
149
- ];
150
- }
151
- // visible extent in map coordinates
152
- getVisibleExtent(transform, projection) {
153
- if (this.projection === Projection.geoIdentity) {
154
- const [width2, height2] = this.mapSize;
155
- return [0, 0, width2, height2];
156
- }
157
- const [width, height] = this.mapSize;
158
- const southWest = projection.invert(transform.invert([0, height]));
159
- const northEast = projection.invert(transform.invert([width, 0]));
160
- return [southWest[0], southWest[1], northEast[0], northEast[1]];
161
- }
162
- getState() {
163
- const transform = this.transform;
164
- const projection = this.projection;
165
- return {
166
- transform,
167
- projection,
168
- zoomLevel: transform.k,
169
- pixelRatio: this.pixelRatio,
170
- padding: this.padding,
171
- viewPortSize: this.viewPortSize,
172
- sizeInPixels: scaleSize(this.viewPortSize, this.pixelRatio),
173
- visibleExtent: this.getVisibleExtent(transform, projection)
174
- };
175
- }
176
- }
177
- export {
178
- View
179
- };
@@ -1,8 +0,0 @@
1
- export class Dispatcher {
2
- constructor(target: any);
3
- _listenersByEvent: Map<any, any>;
4
- target: any;
5
- on(eventType: any, callback: any): string;
6
- unsubscribe(eventType: any, listenerKey: any): void;
7
- dispatch(eventType: any, payload: any): void;
8
- }
@@ -1,35 +0,0 @@
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
- };
@@ -1,6 +0,0 @@
1
- export namespace MapEvent {
2
- let CHANGE: string;
3
- let ZOOM: string;
4
- let TRANSITION_START: string;
5
- let TRANSITION_END: string;
6
- }
@@ -1,9 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- export * from './Dispatcher';
2
- export * from './MapEvent';
@@ -1,10 +0,0 @@
1
- import { Feature } from '../Feature';
2
- import { LineString, Polygon, Point } from '../geometry';
3
- export class GeoJSON {
4
- readFeaturesFromObject(object: any): Feature[];
5
- readFeatureFromObject(geoJSONObject: any): Feature;
6
- readGeometriesFromObject(geometry: any): (LineString | Polygon | Point)[];
7
- readPolygonForCoordinates(coordinates: any): Polygon;
8
- readLineStringForCoordinates(coordinates: any): LineString;
9
- readPointForCoordinates(coordinates: any): Point;
10
- }
@@ -1,96 +0,0 @@
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
- readFeaturesFromObject(object) {
8
- const geoJSONObject = object;
9
- let features = null;
10
- if (geoJSONObject["type"] === "FeatureCollection") {
11
- const geoJSONFeatureCollection = object;
12
- features = [];
13
- const geoJSONFeatures = geoJSONFeatureCollection["features"];
14
- for (let i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
15
- const featureObject = this.readFeatureFromObject(geoJSONFeatures[i]);
16
- if (!featureObject) {
17
- continue;
18
- }
19
- features.push(featureObject);
20
- }
21
- } else if (geoJSONObject["type"] === "Feature") {
22
- features = [this.readFeatureFromObject(geoJSONObject)];
23
- } else if (Array.isArray(geoJSONObject)) {
24
- features = [];
25
- for (let i = 0, ii = geoJSONObject.length; i < ii; ++i) {
26
- const featureObject = this.readFeatureFromObject(geoJSONObject[i]);
27
- if (!featureObject) {
28
- continue;
29
- }
30
- features.push(featureObject);
31
- }
32
- } else {
33
- try {
34
- const geometries = this.readGeometriesFromObject(geoJSONObject);
35
- const feature = new Feature({ geometries });
36
- features = [feature];
37
- } catch {
38
- console.warn("Unable to interpret GeoJSON:", geoJSONObject);
39
- return;
40
- }
41
- }
42
- return features.flat();
43
- }
44
- readFeatureFromObject(geoJSONObject) {
45
- const geometries = this.readGeometriesFromObject(geoJSONObject["geometry"]);
46
- if (geometries.length > 0) {
47
- return new Feature({
48
- id: geoJSONObject["id"],
49
- geometries,
50
- properties: geoJSONObject["properties"]
51
- });
52
- }
53
- return null;
54
- }
55
- readGeometriesFromObject(geometry) {
56
- const geometries = [];
57
- if (geometry.type === "Polygon") {
58
- const polygon = this.readPolygonForCoordinates(geometry.coordinates);
59
- geometries.push(polygon);
60
- } else if (geometry.type === "MultiPolygon") {
61
- for (const polygonCoordinates of geometry.coordinates) {
62
- const polygon = this.readPolygonForCoordinates(polygonCoordinates);
63
- geometries.push(polygon);
64
- }
65
- } else if (geometry.type === "LineString") {
66
- const lineString = this.readLineStringForCoordinates(geometry.coordinates);
67
- geometries.push(lineString);
68
- } else if (geometry.type === "MultiLineString") {
69
- for (const lineStringCoordinates of geometry.coordinates) {
70
- const lineString = this.readLineStringForCoordinates(
71
- lineStringCoordinates
72
- );
73
- geometries.push(lineString);
74
- }
75
- } else if (geometry.type === "Point") {
76
- const point = this.readPointForCoordinates(geometry.coordinates);
77
- geometries.push(point);
78
- }
79
- return geometries;
80
- }
81
- readPolygonForCoordinates(coordinates) {
82
- const outerRing = coordinates[0];
83
- const extent = extentForCoordinates(outerRing);
84
- return new Polygon({ extent, coordinates });
85
- }
86
- readLineStringForCoordinates(coordinates) {
87
- const extent = extentForCoordinates(coordinates);
88
- return new LineString({ extent, coordinates });
89
- }
90
- readPointForCoordinates(coordinates) {
91
- return new Point({ coordinates });
92
- }
93
- }
94
- export {
95
- GeoJSON
96
- };
@@ -1,32 +0,0 @@
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 {Array} 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: any[];
13
- coordinates: any[];
14
- });
15
- type: string;
16
- extent: any[];
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
- }
@@ -1,41 +0,0 @@
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 {Array} 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
- };
@@ -1,12 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
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
- }
@@ -1,16 +0,0 @@
1
- import { Geometry } from "./Geometry.js";
2
- class Point extends Geometry {
3
- constructor({ type = "Point", coordinates }) {
4
- super({ type, extent: null, coordinates });
5
- this.extent = [...coordinates, ...coordinates];
6
- }
7
- _getProjected(projection) {
8
- return {
9
- type: this.type,
10
- coordinates: projection(this.coordinates)
11
- };
12
- }
13
- }
14
- export {
15
- Point
16
- };
@@ -1,16 +0,0 @@
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
- }
@@ -1,46 +0,0 @@
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
- };
@@ -1,4 +0,0 @@
1
- export * from './Geometry';
2
- export * from './LineString';
3
- export * from './Polygon';
4
- export * from './Point';
@@ -1,2 +0,0 @@
1
- export * from './interpolateFeatures';
2
- export * from './interpolateStyles';
@@ -1,5 +0,0 @@
1
- export function interpolateFeatures(currentFeatures: any, newFeatures: any, { interpolate, separate, combine }: {
2
- interpolate: any;
3
- separate: any;
4
- combine: any;
5
- }): (t: any) => any;
@@ -1,95 +0,0 @@
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
- };
@@ -1,4 +0,0 @@
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;