@guardian/interactive-component-library 0.2.0-rc4 → 0.3.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 +8365 -0
  2. package/dist/interactive-component-library.js.map +1 -0
  3. package/dist/interactive-component-library.umd.cjs +8360 -0
  4. package/dist/interactive-component-library.umd.cjs.map +1 -0
  5. package/dist/style.css +157 -73
  6. package/package.json +11 -19
  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,119 +0,0 @@
1
- import { FeatureRenderer } from "./FeatureRenderer.js";
2
- import { replaceChildren } from "../util/dom.js";
3
- const textPadding = {
4
- top: 20,
5
- right: 20,
6
- bottom: 20,
7
- left: 20
8
- };
9
- class TextLayerRenderer {
10
- constructor(layer) {
11
- this.layer = layer;
12
- this.featureRenderer = new FeatureRenderer();
13
- this._element = document.createElement("div");
14
- this._element.className = "gv-text-layer";
15
- const style = this._element.style;
16
- style.position = "absolute";
17
- style.width = "100%";
18
- style.height = "100%";
19
- style.pointerEvents = "none";
20
- style.overflow = "hidden";
21
- }
22
- renderFrame(frameState, targetElement) {
23
- if (this.layer.opacity === 0) return targetElement;
24
- const { declutterTree } = frameState;
25
- const { projection, viewPortSize, sizeInPixels, visibleExtent, transform } = frameState.viewState;
26
- this._element.style.opacity = this.layer.opacity;
27
- const source = this.layer.source;
28
- const features = source.getFeaturesInExtent(visibleExtent);
29
- const textElements = [];
30
- for (const feature of features) {
31
- const geometries = feature.getProjectedGeometries(projection);
32
- const point = geometries.find((d) => d.type === "Point");
33
- if (!point) {
34
- throw new Error(
35
- `Expected Point geometry for feature in TextLayer: ${feature}`
36
- );
37
- }
38
- const styleFunction = feature.getStyleFunction() || this.layer.getStyleFunction();
39
- const featureStyle = styleFunction(feature);
40
- const textElement = this.getTextElementWithID(feature.uid);
41
- textElement.innerText = featureStyle.text.content;
42
- const [relativeX, relativeY] = transform.apply(point.coordinates).map((d, i) => d / sizeInPixels[i]);
43
- const position = {
44
- left: `${relativeX * 100}%`,
45
- top: `${relativeY * 100}%`
46
- };
47
- this.styleTextElement(textElement, featureStyle.text, position);
48
- const bbox = this.getElementBBox(textElement, {
49
- x: relativeX * viewPortSize[0],
50
- y: relativeY * viewPortSize[1]
51
- });
52
- if (declutterTree.collides(bbox)) {
53
- continue;
54
- }
55
- declutterTree.insert(bbox);
56
- if (this.layer.drawCollisionBoxes) {
57
- const collisionBoxDebugElement = this.getCollisionBoxElement(bbox);
58
- textElements.push(collisionBoxDebugElement);
59
- }
60
- textElements.push(textElement);
61
- }
62
- replaceChildren(this._element, textElements);
63
- return this._element;
64
- }
65
- getTextElementWithID(id) {
66
- const elementId = `text-feature-${id}`;
67
- let textElement = this._element.querySelector(`#${elementId}`);
68
- if (!textElement) {
69
- textElement = document.createElement("div");
70
- textElement.id = elementId;
71
- }
72
- return textElement;
73
- }
74
- styleTextElement(element, textStyle, position) {
75
- const style = element.style;
76
- style.position = "absolute";
77
- style.transform = `translate(-50%, -50%)`;
78
- style.left = position.left;
79
- style.top = position.top;
80
- style.textAlign = "center";
81
- style.whiteSpace = "nowrap";
82
- style.fontFamily = textStyle.fontFamily;
83
- style.fontSize = textStyle.fontSize;
84
- style.fontWeight = textStyle.fontWeight;
85
- style.lineHeight = textStyle.lineHeight;
86
- style.color = textStyle.color;
87
- style.textShadow = textStyle.textShadow;
88
- style.padding = `${textPadding.top}px ${textPadding.right}px ${textPadding.bottom}px ${textPadding.left}px`;
89
- }
90
- getElementBBox(element, position) {
91
- if (!element.parentElement) {
92
- document.body.appendChild(element);
93
- }
94
- const { width, height } = element.getBoundingClientRect();
95
- if (element.parentElement !== this._element) {
96
- element.remove();
97
- }
98
- return {
99
- minX: Math.floor(position.x) - width / 2,
100
- minY: Math.floor(position.y) - height / 2,
101
- maxX: Math.ceil(position.x + width / 2),
102
- maxY: Math.ceil(position.y + height / 2)
103
- };
104
- }
105
- getCollisionBoxElement(bbox) {
106
- const element = document.createElement("div");
107
- const style = element.style;
108
- style.position = "absolute";
109
- style.left = `${bbox.minX}px`;
110
- style.top = `${bbox.minY}px`;
111
- style.width = `${bbox.maxX - bbox.minX}px`;
112
- style.height = `${bbox.maxY - bbox.minY}px`;
113
- style.border = "2px solid black";
114
- return element;
115
- }
116
- }
117
- export {
118
- TextLayerRenderer
119
- };
@@ -1,10 +0,0 @@
1
- import { FeatureRenderer } from './FeatureRenderer';
2
- export class VectorLayerRenderer {
3
- constructor(layer: any);
4
- layer: any;
5
- featureRenderer: FeatureRenderer;
6
- renderFrame(frameState: any, targetElement: any): any;
7
- getOrCreateContainer(targetElement: any, sizeInPixels: any): any;
8
- _container: any;
9
- createContainer(): HTMLDivElement;
10
- }
@@ -1,78 +0,0 @@
1
- import { FeatureRenderer } from "./FeatureRenderer.js";
2
- class VectorLayerRenderer {
3
- constructor(layer) {
4
- this.layer = layer;
5
- this.featureRenderer = new FeatureRenderer();
6
- }
7
- renderFrame(frameState, targetElement) {
8
- if (this.layer.opacity === 0) return targetElement;
9
- const { projection, sizeInPixels, visibleExtent, transform } = frameState.viewState;
10
- const container = this.getOrCreateContainer(targetElement, sizeInPixels);
11
- const context = container.firstElementChild.getContext("2d");
12
- context.save();
13
- context.translate(transform.x, transform.y);
14
- context.scale(transform.k, transform.k);
15
- context.lineJoin = "round";
16
- context.lineCap = "round";
17
- context.globalAlpha = this.layer.opacity;
18
- const source = this.layer.source;
19
- const features = source.getFeaturesInExtent(visibleExtent);
20
- for (const feature of features) {
21
- const styleFunction = feature.getStyleFunction() || this.layer.getStyleFunction();
22
- const featureStyle = styleFunction(feature);
23
- if ((featureStyle == null ? void 0 : featureStyle.stroke) || (featureStyle == null ? void 0 : featureStyle.fill)) {
24
- context.save();
25
- this.featureRenderer.setStyle(featureStyle);
26
- this.featureRenderer.render(frameState, feature, context);
27
- context.restore();
28
- }
29
- }
30
- if (Object.prototype.hasOwnProperty.call(projection, "getCompositionBorders")) {
31
- context.beginPath();
32
- context.lineWidth = 1 / transform.k;
33
- context.strokeStyle = "#999";
34
- projection.drawCompositionBorders(context);
35
- context.stroke();
36
- }
37
- context.restore();
38
- return container;
39
- }
40
- getOrCreateContainer(targetElement, sizeInPixels) {
41
- let container = null;
42
- let containerReused = false;
43
- let canvas = targetElement && targetElement.firstElementChild;
44
- if (canvas instanceof HTMLCanvasElement) {
45
- container = targetElement;
46
- containerReused = true;
47
- } else if (this._container) {
48
- container = this._container;
49
- } else {
50
- container = this.createContainer();
51
- }
52
- if (!containerReused) {
53
- const canvas2 = container.firstElementChild;
54
- canvas2.width = sizeInPixels[0];
55
- canvas2.height = sizeInPixels[1];
56
- }
57
- this._container = container;
58
- return container;
59
- }
60
- createContainer() {
61
- const container = document.createElement("div");
62
- container.className = "gv-map-layer";
63
- let style = container.style;
64
- style.position = "absolute";
65
- style.width = "100%";
66
- style.height = "100%";
67
- const canvas = document.createElement("canvas");
68
- style = canvas.style;
69
- style.position = "absolute";
70
- style.width = "100%";
71
- style.height = "100%";
72
- container.appendChild(canvas);
73
- return container;
74
- }
75
- }
76
- export {
77
- VectorLayerRenderer
78
- };
@@ -1,15 +0,0 @@
1
- import { Dispatcher } from '../events';
2
- import { default as RBush } from 'rbush';
3
- export class VectorSource {
4
- constructor({ features }: {
5
- features: any;
6
- });
7
- dispatcher: Dispatcher;
8
- _featuresRtree: RBush;
9
- tearDown(): void;
10
- getFeatures(): any;
11
- getFeaturesAtCoordinate(coordinate: any): any[];
12
- getFeaturesInExtent(extent: any): any[];
13
- setFeatures(features: any): void;
14
- _features: any;
15
- }
@@ -1,56 +0,0 @@
1
- import RBush from "rbush";
2
- import knn from "rbush-knn";
3
- import { Dispatcher } from "../events/Dispatcher.js";
4
- import { MapEvent } from "../events/MapEvent.js";
5
- class VectorSource {
6
- constructor({ features }) {
7
- this.dispatcher = new Dispatcher(this);
8
- this._featuresRtree = new RBush();
9
- this.setFeatures(features);
10
- }
11
- tearDown() {
12
- this.dispatcher = null;
13
- }
14
- getFeatures() {
15
- return this._features;
16
- }
17
- getFeaturesAtCoordinate(coordinate) {
18
- const [lon, lat] = coordinate;
19
- const features = knn(
20
- this._featuresRtree,
21
- lon,
22
- lat,
23
- 10,
24
- (d) => d.feature.containsCoordinate(coordinate)
25
- ).map((d) => {
26
- const midX = d.minX + (d.minX + d.maxX) / 2;
27
- const midY = d.minY + (d.minY + d.maxY) / 2;
28
- d.distance = Math.hypot(midX - lon, midY - lat);
29
- return d;
30
- });
31
- features.sort((a, b) => a.distance - b.distance);
32
- return features.map((d) => d.feature);
33
- }
34
- getFeaturesInExtent(extent) {
35
- const [minX, minY, maxX, maxY] = extent;
36
- return this._featuresRtree.search({ minX, minY, maxX, maxY }).map((d) => d.feature);
37
- }
38
- setFeatures(features) {
39
- this._featuresRtree.clear();
40
- for (const feature of features) {
41
- const [minX, minY, maxX, maxY] = feature.getExtent();
42
- this._featuresRtree.insert({
43
- minX: Math.floor(minX),
44
- minY: Math.floor(minY),
45
- maxX: Math.ceil(maxX),
46
- maxY: Math.ceil(maxY),
47
- feature
48
- });
49
- }
50
- this._features = features;
51
- this.dispatcher.dispatch(MapEvent.CHANGE);
52
- }
53
- }
54
- export {
55
- VectorSource
56
- };
@@ -1,7 +0,0 @@
1
- export class Fill {
2
- constructor(options: any);
3
- color: any;
4
- opacity: any;
5
- _getRgba: (...arg0: any[]) => string;
6
- getRgba(): string;
7
- }
@@ -1,15 +0,0 @@
1
- import { memoise } from "../util/memoise.js";
2
- import { toRgba } from "../util/toRgba.js";
3
- class Fill {
4
- constructor(options) {
5
- this.color = (options == null ? void 0 : options.color) || "#CCC";
6
- this.opacity = (options == null ? void 0 : options.opacity) || 1;
7
- this._getRgba = memoise(toRgba);
8
- }
9
- getRgba() {
10
- return this._getRgba(this.color, this.opacity);
11
- }
12
- }
13
- export {
14
- Fill
15
- };
@@ -1,8 +0,0 @@
1
- export class Stroke {
2
- constructor(options: any);
3
- color: any;
4
- width: any;
5
- opacity: any;
6
- _getRgba: (...arg0: any[]) => string;
7
- getRgba(): string;
8
- }
@@ -1,16 +0,0 @@
1
- import { memoise } from "../util/memoise.js";
2
- import { toRgba } from "../util/toRgba.js";
3
- class Stroke {
4
- constructor(options) {
5
- this.color = (options == null ? void 0 : options.color) || "#121212";
6
- this.width = (options == null ? void 0 : options.width) || 0.5;
7
- this.opacity = (options == null ? void 0 : options.opacity) || 1;
8
- this._getRgba = memoise(toRgba);
9
- }
10
- getRgba() {
11
- return this._getRgba(this.color, this.opacity);
12
- }
13
- }
14
- export {
15
- Stroke
16
- };
@@ -1,24 +0,0 @@
1
- /**
2
- * A function that takes a {@link import("../Feature").Feature} and returns a {@link Style}
3
- *
4
- * @typedef {function(import("../Feature").Feature):(Style)} StyleFunction
5
- */
6
- /**
7
- * Class representing a style.
8
- * @class
9
- * @property {Object} properties - The properties of the style
10
- * @property {Object} properties.stroke - The stroke color of the style
11
- * @property {Object} properties.fill - The fill color of the style
12
- * @property {Object} properties.text - The text color of the style
13
- */
14
- export class Style {
15
- constructor(properties: any);
16
- stroke: any;
17
- fill: any;
18
- text: any;
19
- clone(): Style;
20
- }
21
- /**
22
- * A function that takes a {@link import ("../Feature").Feature} and returns a {@link Style}
23
- */
24
- export type StyleFunction = (arg0: import('../Feature').Feature) => (Style);
@@ -1,17 +0,0 @@
1
- class Style {
2
- constructor(properties) {
3
- this.stroke = properties == null ? void 0 : properties.stroke;
4
- this.fill = properties == null ? void 0 : properties.fill;
5
- this.text = properties == null ? void 0 : properties.text;
6
- }
7
- clone() {
8
- return new Style({
9
- stroke: this.stroke,
10
- fill: this.fill,
11
- text: this.text
12
- });
13
- }
14
- }
15
- export {
16
- Style
17
- };
@@ -1,10 +0,0 @@
1
- export class Text {
2
- constructor(options: any);
3
- content: any;
4
- fontFamily: any;
5
- fontSize: any;
6
- fontWeight: any;
7
- lineHeight: any;
8
- color: any;
9
- textShadow: any;
10
- }
@@ -1,14 +0,0 @@
1
- class Text {
2
- constructor(options) {
3
- this.content = options == null ? void 0 : options.content;
4
- this.fontFamily = (options == null ? void 0 : options.fontFamily) || "var(--text-sans)";
5
- this.fontSize = (options == null ? void 0 : options.fontSize) || "17px";
6
- this.fontWeight = (options == null ? void 0 : options.fontWeight) || "400";
7
- this.lineHeight = (options == null ? void 0 : options.lineHeight) || 1.3;
8
- this.color = (options == null ? void 0 : options.color) || "#121212";
9
- this.textShadow = (options == null ? void 0 : options.textShadow) || "1px 1px 0px #f6f6f6, -1px -1px 0px #f6f6f6, -1px 1px 0px #f6f6f6, 1px -1px #f6f6f6";
10
- }
11
- }
12
- export {
13
- Text
14
- };
@@ -1,4 +0,0 @@
1
- export * from './Style';
2
- export * from './Stroke';
3
- export * from './Fill';
4
- export * from './Text';
@@ -1,6 +0,0 @@
1
- /**
2
- * @param {Array<any>|Uint8ClampedArray} arr1 The first array to compare.
3
- * @param {Array<any>|Uint8ClampedArray} arr2 The second array to compare.
4
- * @return {boolean} Whether the two arrays are equal.
5
- */
6
- export function arrayEquals(arr1: Array<any> | Uint8ClampedArray, arr2: Array<any> | Uint8ClampedArray): boolean;
@@ -1,15 +0,0 @@
1
- function arrayEquals(arr1, arr2) {
2
- const len1 = arr1.length;
3
- if (len1 !== arr2.length) {
4
- return false;
5
- }
6
- for (let i = 0; i < len1; i++) {
7
- if (arr1[i] !== arr2[i]) {
8
- return false;
9
- }
10
- }
11
- return true;
12
- }
13
- export {
14
- arrayEquals
15
- };
@@ -1,8 +0,0 @@
1
- export function bboxFeature(bounds: any): {
2
- type: string;
3
- properties: {};
4
- geometry: {
5
- coordinates: any[][][];
6
- type: string;
7
- };
8
- };
@@ -1,26 +0,0 @@
1
- function bboxFeature(bounds) {
2
- const minLon = bounds[0][0];
3
- const minLat = bounds[0][1];
4
- const maxLon = bounds[1][0];
5
- const maxLat = bounds[1][1];
6
- const feature = {
7
- type: "Feature",
8
- properties: {},
9
- geometry: {
10
- coordinates: [
11
- [
12
- [minLon, maxLat],
13
- [maxLon, maxLat],
14
- [maxLon, minLat],
15
- [minLon, minLat],
16
- [minLon, maxLat]
17
- ]
18
- ],
19
- type: "Polygon"
20
- }
21
- };
22
- return feature;
23
- }
24
- export {
25
- bboxFeature
26
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * @function
3
- * @param {Array<import('../geometry').Geometry>} geometries
4
- */
5
- export function validateGeometries(geometries: Array<import('../geometry').Geometry>): void;
6
- /**
7
- *
8
- * @param {import('../Feature').Feature | Object} feature - The feature you want to inspect
9
- * @returns {string} URL to geojson.io, with feature embedded
10
- */
11
- export function generateDebugUrl(feature: import('../Feature').Feature | any, convertToGeoJSON?: boolean): string;
@@ -1,27 +0,0 @@
1
- function validateGeometries(geometries) {
2
- if (!Array.isArray(geometries)) {
3
- throw new Error("geometries must be an array");
4
- }
5
- geometries.forEach((geometry) => {
6
- var _a;
7
- if (!geometry.type) {
8
- throw new Error("geometry must have a type");
9
- }
10
- if (!((_a = geometry.coordinates) == null ? void 0 : _a.length)) {
11
- throw new Error("geometry must have coordinates");
12
- }
13
- });
14
- }
15
- function generateDebugUrl(feature, convertToGeoJSON = true) {
16
- const featureGeoJSON = convertToGeoJSON ? feature.getGeoJSON() : feature;
17
- const featureCollection = {
18
- type: "FeatureCollection",
19
- features: [featureGeoJSON]
20
- };
21
- const jsonString = encodeURIComponent(JSON.stringify(featureCollection));
22
- return `https://geojson.io/#data=data:application/json,${jsonString}`;
23
- }
24
- export {
25
- generateDebugUrl,
26
- validateGeometries
27
- };
@@ -1,36 +0,0 @@
1
- /**
2
- * @module ol/geom/flat/deflate
3
- */
4
- /**
5
- * @param {Array<number>} flatCoordinates Flat coordinates.
6
- * @param {number} offset Offset.
7
- * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
8
- * @return {number} offset Offset.
9
- */
10
- export function deflateCoordinate(flatCoordinates: Array<number>, offset: number, coordinate: any): number;
11
- /**
12
- * @param {Array<number>} flatCoordinates Flat coordinates.
13
- * @param {number} offset Offset.
14
- * @param {Array<import("../../coordinate.js").Coordinate>} coordinates Coordinates.
15
- * @param {number} stride Stride.
16
- * @return {number} offset Offset.
17
- */
18
- export function deflateCoordinates(flatCoordinates: Array<number>, offset: number, coordinates: Array<any>, stride: number): number;
19
- /**
20
- * @param {Array<number>} flatCoordinates Flat coordinates.
21
- * @param {number} offset Offset.
22
- * @param {Array<Array<import("../../coordinate.js").Coordinate>>} coordinatess Coordinatess.
23
- * @param {number} stride Stride.
24
- * @param {Array<number>} [ends] Ends.
25
- * @return {Array<number>} Ends.
26
- */
27
- export function deflateCoordinatesArray(flatCoordinates: Array<number>, offset: number, coordinatess: Array<Array<any>>, stride: number, ends?: Array<number>): Array<number>;
28
- /**
29
- * @param {Array<number>} flatCoordinates Flat coordinates.
30
- * @param {number} offset Offset.
31
- * @param {Array<Array<Array<import("../../coordinate.js").Coordinate>>>} coordinatesss Coordinatesss.
32
- * @param {number} stride Stride.
33
- * @param {Array<Array<number>>} [endss] Endss.
34
- * @return {Array<Array<number>>} Endss.
35
- */
36
- export function deflateMultiCoordinatesArray(flatCoordinates: Array<number>, offset: number, coordinatesss: Array<Array<Array<any>>>, stride: number, endss?: Array<Array<number>>): Array<Array<number>>;
@@ -1 +0,0 @@
1
- export function haversineDistance(lat1: any, lon1: any, lat2: any, lon2: any): number;
@@ -1,12 +0,0 @@
1
- function haversineDistance(lat1, lon1, lat2, lon2) {
2
- const R = 6371e3;
3
- const toRadians = (degrees) => degrees * Math.PI / 180;
4
- const dLat = toRadians(lat2 - lat1);
5
- const dLon = toRadians(lon2 - lon1);
6
- const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
7
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
8
- return R * c;
9
- }
10
- export {
11
- haversineDistance
12
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * Transform the children of a parent node so they match the
3
- * provided list of children. This function aims to efficiently
4
- * remove, add, and reorder child nodes while maintaining a simple
5
- * implementation (it is not guaranteed to minimize DOM operations).
6
- * @param {Node} node The parent node whose children need reworking.
7
- * @param {Array<Node>} children The desired children.
8
- */
9
- export function replaceChildren(node: Node, children: Array<Node>): void;
@@ -1,28 +0,0 @@
1
- function replaceChildren(node, children) {
2
- const oldChildren = node.childNodes;
3
- let done = false;
4
- for (let i = 0; !done; ++i) {
5
- const oldChild = oldChildren[i];
6
- const newChild = children[i];
7
- if (!oldChild && !newChild) {
8
- done = true;
9
- break;
10
- }
11
- if (oldChild === newChild) {
12
- continue;
13
- }
14
- if (!oldChild) {
15
- node.appendChild(newChild);
16
- continue;
17
- }
18
- if (!newChild) {
19
- node.removeChild(oldChild);
20
- --i;
21
- continue;
22
- }
23
- node.insertBefore(newChild, oldChild);
24
- }
25
- }
26
- export {
27
- replaceChildren
28
- };
@@ -1,21 +0,0 @@
1
- export function extentForCoordinates(coordinates: any): number[];
2
- export function combineExtents(extent1: any, extent2: any): number[];
3
- /**
4
- * Check if the passed coordinate is contained or on the edge of the extent.
5
- *
6
- * @param {Extent} extent Extent.
7
- * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
8
- * @return {boolean} The coordinate is contained in the extent.
9
- * @api
10
- */
11
- export function containsCoordinate(extent: Extent, coordinate: any): boolean;
12
- /**
13
- * Check if the passed coordinate is contained or on the edge of the extent.
14
- *
15
- * @param {Extent} extent Extent.
16
- * @param {number} x X coordinate.
17
- * @param {number} y Y coordinate.
18
- * @return {boolean} The x, y values are contained in the extent.
19
- * @api
20
- */
21
- export function containsXY(extent: Extent, x: number, y: number): boolean;
@@ -1,38 +0,0 @@
1
- function extentForCoordinates(coordinates) {
2
- let minX = Infinity, minY = Infinity;
3
- let maxX = -Infinity, maxY = -Infinity;
4
- for (const coordinate of coordinates) {
5
- if (coordinate[0] < minX) {
6
- minX = coordinate[0];
7
- }
8
- if (coordinate[0] > maxX) {
9
- maxX = coordinate[0];
10
- }
11
- if (coordinate[1] < minY) {
12
- minY = coordinate[1];
13
- }
14
- if (coordinate[1] > maxY) {
15
- maxY = coordinate[1];
16
- }
17
- }
18
- return [minX, minY, maxX, maxY];
19
- }
20
- function combineExtents(extent1, extent2) {
21
- const minX = Math.min(extent1[0], extent2[0]);
22
- const minY = Math.min(extent1[1], extent2[1]);
23
- const maxX = Math.max(extent1[2], extent2[2]);
24
- const maxY = Math.max(extent1[3], extent2[3]);
25
- return [minX, minY, maxX, maxY];
26
- }
27
- function containsCoordinate(extent, coordinate) {
28
- return containsXY(extent, coordinate[0], coordinate[1]);
29
- }
30
- function containsXY(extent, x, y) {
31
- return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3];
32
- }
33
- export {
34
- combineExtents,
35
- containsCoordinate,
36
- containsXY,
37
- extentForCoordinates
38
- };