@guardian/interactive-component-library 0.2.0-rc4 → 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 +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,65 +0,0 @@
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
- };
@@ -1,52 +0,0 @@
1
- import { VectorSource } from '../sources/VectorSource';
2
- import { Style } from '../styles';
3
- import { TextLayerRenderer } from '../renderers/TextLayerRenderer';
4
- import { Dispatcher } from '../events/Dispatcher';
5
- /** @typedef {Omit<ConstructorParameters<typeof TextLayer>[0], "source">} TextLayerOptions */
6
- /** @typedef {TextLayerOptions & { features: import("../Feature").Feature[]}} TextLayerComponentProps */
7
- export class TextLayer {
8
- /** @param {TextLayerComponentProps} props */
9
- static Component({ features, style, minZoom, opacity, declutter, drawCollisionBoxes, }: TextLayerComponentProps): any;
10
- /**
11
- * @param {import("../Feature").Feature[]} features
12
- * @param {TextLayerOptions} options
13
- */
14
- static with(features: import('../Feature').Feature[], options: TextLayerOptions): TextLayer;
15
- /**
16
- * @constructor
17
- * @param {Object} params
18
- * @param {VectorSource} params.source
19
- * @param {Style | (() => Style)} [params.style=undefined]
20
- * @param {number} [params.minZoom=0]
21
- * @param {number} [params.opacity=1]
22
- * @param {boolean} [params.declutter=true]
23
- * @param {boolean} [params.drawCollisionBoxes=false]
24
- */
25
- constructor({ source, style, minZoom, opacity, declutter, drawCollisionBoxes, }: {
26
- source: VectorSource;
27
- style?: Style | (() => Style);
28
- minZoom?: number;
29
- opacity?: number;
30
- declutter?: boolean;
31
- drawCollisionBoxes?: boolean;
32
- });
33
- source: VectorSource;
34
- _style: Style | (() => Style);
35
- minZoom: number;
36
- opacity: number;
37
- declutter: boolean;
38
- drawCollisionBoxes: boolean;
39
- renderer: TextLayerRenderer;
40
- dispatcher: Dispatcher;
41
- tearDown(): void;
42
- set style(style: Style | (() => Style));
43
- get style(): Style | (() => Style);
44
- getExtent(): any;
45
- _extent: any;
46
- getStyleFunction(): () => Style;
47
- renderFrame(frameState: any, targetElement: any): any;
48
- }
49
- export type TextLayerOptions = Omit<ConstructorParameters<typeof TextLayer>[0], "source">;
50
- export type TextLayerComponentProps = TextLayerOptions & {
51
- features: import('../Feature').Feature[];
52
- };
@@ -1,111 +0,0 @@
1
- import { TextLayerRenderer } from "../renderers/TextLayerRenderer.js";
2
- import { Style } from "../styles/Style.js";
3
- import { Text } from "../styles/Text.js";
4
- import { Dispatcher } from "../events/Dispatcher.js";
5
- import { combineExtents } from "../util/extent.js";
6
- import { MapEvent } from "../events/MapEvent.js";
7
- import { VectorSource } from "../sources/VectorSource.js";
8
- import { MapContext } from "../../context/MapContext.js";
9
- import { useContext, useMemo, useEffect } from "preact/hooks";
10
- class TextLayer {
11
- /** @param {TextLayerComponentProps} props */
12
- static Component({
13
- features,
14
- style,
15
- minZoom,
16
- opacity,
17
- declutter,
18
- drawCollisionBoxes
19
- }) {
20
- const { registerLayer } = useContext(MapContext);
21
- const layer = useMemo(
22
- () => TextLayer.with(features, {
23
- style,
24
- minZoom,
25
- opacity,
26
- declutter,
27
- drawCollisionBoxes
28
- }),
29
- // eslint-disable-next-line react-hooks/exhaustive-deps
30
- [features, minZoom, opacity, declutter, drawCollisionBoxes]
31
- );
32
- registerLayer(layer);
33
- useEffect(() => {
34
- layer.style = style;
35
- }, [style]);
36
- return null;
37
- }
38
- /**
39
- * @param {import("../Feature").Feature[]} features
40
- * @param {TextLayerOptions} options
41
- */
42
- static with(features, options) {
43
- const source = new VectorSource({ features });
44
- return new TextLayer({ source, ...options });
45
- }
46
- /**
47
- * @constructor
48
- * @param {Object} params
49
- * @param {VectorSource} params.source
50
- * @param {Style | (() => Style)} [params.style=undefined]
51
- * @param {number} [params.minZoom=0]
52
- * @param {number} [params.opacity=1]
53
- * @param {boolean} [params.declutter=true]
54
- * @param {boolean} [params.drawCollisionBoxes=false]
55
- */
56
- constructor({
57
- source,
58
- style,
59
- minZoom = 0,
60
- opacity = 1,
61
- declutter = true,
62
- drawCollisionBoxes = false
63
- }) {
64
- this.source = source;
65
- this._style = style;
66
- this.minZoom = minZoom;
67
- this.opacity = opacity;
68
- this.declutter = declutter;
69
- this.drawCollisionBoxes = drawCollisionBoxes;
70
- this.renderer = new TextLayerRenderer(this);
71
- this.dispatcher = new Dispatcher(this);
72
- }
73
- tearDown() {
74
- this.dispatcher = null;
75
- }
76
- get style() {
77
- if (this._style) return this._style;
78
- const defaultStyle = new Style({
79
- text: new Text()
80
- });
81
- return defaultStyle;
82
- }
83
- set style(style) {
84
- this._style = style;
85
- this.dispatcher.dispatch(MapEvent.CHANGE);
86
- }
87
- getExtent() {
88
- if (this._extent) return this._extent;
89
- const features = this.source.getFeatures();
90
- const extent = features.reduce((combinedExtent, feature) => {
91
- const featureExtent = feature.getExtent();
92
- if (!combinedExtent) return featureExtent;
93
- return combineExtents(featureExtent, combinedExtent);
94
- }, null);
95
- this._extent = extent;
96
- return extent;
97
- }
98
- getStyleFunction() {
99
- const style = this.style;
100
- if (typeof style === "function") return style;
101
- return () => {
102
- return style;
103
- };
104
- }
105
- renderFrame(frameState, targetElement) {
106
- return this.renderer.renderFrame(frameState, targetElement);
107
- }
108
- }
109
- export {
110
- TextLayer
111
- };
@@ -1,53 +0,0 @@
1
- import { Dispatcher } from '../events';
2
- import { VectorLayerRenderer } from '../renderers/VectorLayerRenderer';
3
- import { Style } from '../styles';
4
- import { VectorSource } from '../sources/VectorSource';
5
- /** @typedef {Omit<ConstructorParameters<typeof VectorLayer>[0], "source">} VectorLayerOptions */
6
- /** @typedef {VectorLayerOptions & { features: import("../Feature").Feature[] | import("../FeatureCollection").FeatureCollection }} VectorLayerComponentProps */
7
- export class VectorLayer {
8
- /** @param {VectorLayerComponentProps} props */
9
- static Component({ features: featureCollection, style, minZoom, opacity, hitDetectionEnabled, }: VectorLayerComponentProps): any;
10
- /**
11
- * @param {import("../Feature").Feature[]} features
12
- * @param {VectorLayerOptions} options
13
- */
14
- static with(features: import('../Feature').Feature[], options: VectorLayerOptions): VectorLayer;
15
- /**
16
- * @param {Object} params
17
- * @param {VectorSource} params.source
18
- * @param {Style | (() => Style)} [params.style=undefined]
19
- * @param {number} [params.minZoom=0]
20
- * @param {number} [params.opacity=1]
21
- * @param {boolean} [params.hitDetectionEnabled=true]
22
- */
23
- constructor({ source, style, minZoom, opacity, hitDetectionEnabled, }: {
24
- source: VectorSource;
25
- style?: Style | (() => Style);
26
- minZoom?: number;
27
- opacity?: number;
28
- hitDetectionEnabled?: boolean;
29
- });
30
- dispatcher: Dispatcher;
31
- renderer: VectorLayerRenderer;
32
- set source(source: any);
33
- get source(): any;
34
- _style: Style | (() => Style);
35
- minZoom: number;
36
- opacity: number;
37
- hitDetectionEnabled: boolean;
38
- _source: any;
39
- _extent: any;
40
- setRawProjection(projection: any): void;
41
- projection: any;
42
- tearDown(): void;
43
- set style(style: Style | (() => Style));
44
- get style(): Style | (() => Style);
45
- getStyleFunction(): () => Style;
46
- getExtent(): any;
47
- findFeatures(coordinate: any): any;
48
- renderFrame(frameState: any, targetElement: any): any;
49
- }
50
- export type VectorLayerOptions = Omit<ConstructorParameters<typeof VectorLayer>[0], "source">;
51
- export type VectorLayerComponentProps = VectorLayerOptions & {
52
- features: import('../Feature').Feature[] | import('../FeatureCollection').FeatureCollection;
53
- };
@@ -1,132 +0,0 @@
1
- import { VectorLayerRenderer } from "../renderers/VectorLayerRenderer.js";
2
- import { Style } from "../styles/Style.js";
3
- import { Stroke } from "../styles/Stroke.js";
4
- import { combineExtents } from "../util/extent.js";
5
- import { Dispatcher } from "../events/Dispatcher.js";
6
- import { MapEvent } from "../events/MapEvent.js";
7
- import { VectorSource } from "../sources/VectorSource.js";
8
- import { useContext, useMemo, useEffect } from "preact/hooks";
9
- import { MapContext } from "../../context/MapContext.js";
10
- import { FeatureCollection } from "../FeatureCollection.js";
11
- class VectorLayer {
12
- /** @param {VectorLayerComponentProps} props */
13
- static Component({
14
- features: featureCollection,
15
- style,
16
- minZoom,
17
- opacity,
18
- hitDetectionEnabled = true
19
- }) {
20
- const { registerLayer } = useContext(MapContext);
21
- const layer = useMemo(
22
- () => {
23
- const features = featureCollection instanceof FeatureCollection ? featureCollection.features : (
24
- /** @type {import("../Feature").Feature[]} */
25
- featureCollection
26
- );
27
- return VectorLayer.with(features, {
28
- style,
29
- minZoom,
30
- opacity,
31
- hitDetectionEnabled
32
- });
33
- },
34
- // eslint-disable-next-line react-hooks/exhaustive-deps
35
- [featureCollection, minZoom, opacity, hitDetectionEnabled]
36
- );
37
- registerLayer(layer);
38
- useEffect(() => {
39
- layer.style = style;
40
- }, [style]);
41
- return null;
42
- }
43
- /**
44
- * @param {import("../Feature").Feature[]} features
45
- * @param {VectorLayerOptions} options
46
- */
47
- static with(features, options) {
48
- const source = new VectorSource({ features });
49
- return new VectorLayer({ source, ...options });
50
- }
51
- /**
52
- * @param {Object} params
53
- * @param {VectorSource} params.source
54
- * @param {Style | (() => Style)} [params.style=undefined]
55
- * @param {number} [params.minZoom=0]
56
- * @param {number} [params.opacity=1]
57
- * @param {boolean} [params.hitDetectionEnabled=true]
58
- */
59
- constructor({
60
- source,
61
- style,
62
- minZoom = 0,
63
- opacity = 1,
64
- hitDetectionEnabled = true
65
- }) {
66
- this.dispatcher = new Dispatcher(this);
67
- this.renderer = new VectorLayerRenderer(this);
68
- this.source = source;
69
- this._style = style;
70
- this.minZoom = minZoom;
71
- this.opacity = opacity;
72
- this.hitDetectionEnabled = hitDetectionEnabled;
73
- }
74
- get source() {
75
- return this._source;
76
- }
77
- set source(source) {
78
- if (this._source && source !== this._source) {
79
- this._source.tearDown();
80
- }
81
- this._source = source;
82
- source.on(MapEvent.CHANGE, () => {
83
- this._extent = null;
84
- this.dispatcher.dispatch(MapEvent.CHANGE);
85
- });
86
- }
87
- setRawProjection(projection) {
88
- this.projection = projection;
89
- }
90
- tearDown() {
91
- this.dispatcher = null;
92
- }
93
- get style() {
94
- if (this._style) return this._style;
95
- const defaultStyle = new Style({
96
- stroke: new Stroke()
97
- });
98
- return defaultStyle;
99
- }
100
- set style(style) {
101
- this._style = style;
102
- this.dispatcher.dispatch(MapEvent.CHANGE);
103
- }
104
- getStyleFunction() {
105
- const style = this.style;
106
- if (typeof style === "function") return style;
107
- return () => {
108
- return style;
109
- };
110
- }
111
- getExtent() {
112
- if (this._extent) return this._extent;
113
- const features = this.source.getFeatures();
114
- const extent = features.reduce((combinedExtent, feature) => {
115
- const featureExtent = feature.getExtent();
116
- if (!combinedExtent) return featureExtent;
117
- return combineExtents(featureExtent, combinedExtent);
118
- }, null);
119
- this._extent = extent;
120
- return extent;
121
- }
122
- findFeatures(coordinate) {
123
- if (!this.hitDetectionEnabled) return;
124
- return this.source.getFeaturesAtCoordinate(coordinate);
125
- }
126
- renderFrame(frameState, targetElement) {
127
- return this.renderer.renderFrame(frameState, targetElement);
128
- }
129
- }
130
- export {
131
- VectorLayer
132
- };
@@ -1,3 +0,0 @@
1
- export * from './TextLayer';
2
- export * from './VectorLayer';
3
- export type Layer = import('./TextLayer').TextLayer | import('./VectorLayer').VectorLayer;
@@ -1,22 +0,0 @@
1
- export namespace Projection {
2
- let geoIdentity: {
3
- (p: any): number[];
4
- invert(p: any): number[];
5
- stream(stream: any): any;
6
- postclip(_: any, ...args: any[]): any;
7
- clipExtent(_: any, ...args: any[]): any[][] | any;
8
- scale(_: any, ...args: any[]): number | any;
9
- translate(_: any, ...args: any[]): number[] | any;
10
- angle(_: any, ...args: any[]): number | any;
11
- reflectX(_: any, ...args: any[]): boolean | any;
12
- reflectY(_: any, ...args: any[]): boolean | any;
13
- fitExtent(extent: any, object: any): any;
14
- fitSize(size: any, object: any): any;
15
- fitWidth(width: any, object: any): any;
16
- fitHeight(height: any, object: any): any;
17
- };
18
- let geoMercator: any;
19
- let geoAlbersUS: any;
20
- let geoAlbersUKComposite: any;
21
- let geoAlbersEngland: any;
22
- }
@@ -1,12 +0,0 @@
1
- import { geoIdentity, geoMercator, geoAlbersUsa, geoAlbers } from "d3-geo";
2
- import { geoAlbersUk } from "d3-composite-projections";
3
- const Projection = {
4
- geoIdentity: geoIdentity(),
5
- geoMercator: geoMercator(),
6
- geoAlbersUS: geoAlbersUsa().scale(1070).translate([487.5, 305]),
7
- geoAlbersUKComposite: geoAlbersUk(),
8
- geoAlbersEngland: geoAlbers().center([0, 52.7]).rotate([1.1743, 0]).parallels([50, 54])
9
- };
10
- export {
11
- Projection
12
- };
@@ -1,6 +0,0 @@
1
- export class FeatureRenderer {
2
- drawingFunction: any;
3
- setStyle(style: any): void;
4
- style: any;
5
- render(frameState: any, feature: any, context: any): void;
6
- }
@@ -1,46 +0,0 @@
1
- import { geoPath } from "d3-geo";
2
- import { validateGeometries, generateDebugUrl } from "../util/debug.js";
3
- class FeatureRenderer {
4
- constructor() {
5
- this.drawingFunction = geoPath();
6
- }
7
- setStyle(style) {
8
- this.style = style;
9
- }
10
- render(frameState, feature, context) {
11
- if (!this.style) {
12
- return;
13
- }
14
- const { projection, transform, pixelRatio } = frameState.viewState;
15
- const { stroke, fill } = this.style;
16
- this.drawingFunction.context(context);
17
- context.beginPath();
18
- const geometries = feature.getProjectedGeometries(projection);
19
- if (frameState.debug) {
20
- try {
21
- validateGeometries(geometries);
22
- } catch {
23
- console.error(
24
- `Invalid geometry. Feature skipped during rendering. Click here to inspect geometry: ${generateDebugUrl(feature)}
25
- `,
26
- feature
27
- );
28
- }
29
- }
30
- for (const geometry of geometries) {
31
- this.drawingFunction(geometry);
32
- }
33
- if (fill) {
34
- context.fillStyle = fill.getRgba();
35
- context.fill();
36
- }
37
- if (stroke) {
38
- context.lineWidth = stroke.width * pixelRatio / transform.k;
39
- context.strokeStyle = stroke.getRgba();
40
- context.stroke();
41
- }
42
- }
43
- }
44
- export {
45
- FeatureRenderer
46
- };
@@ -1,6 +0,0 @@
1
- export class MapRenderer {
2
- constructor(map: any);
3
- map: any;
4
- _element: HTMLDivElement;
5
- renderFrame(frameState: any): void;
6
- }
@@ -1,53 +0,0 @@
1
- import { replaceChildren } from "../util/dom.js";
2
- import RBush from "rbush";
3
- class MapRenderer {
4
- constructor(map) {
5
- this.map = map;
6
- this._element = document.createElement("div");
7
- this._element.className = "gv-layer-container";
8
- const style = this._element.style;
9
- style.position = "absolute";
10
- style.width = "100%";
11
- style.height = "100%";
12
- style.zIndex = "0";
13
- const container = map.viewPort;
14
- container.insertBefore(this._element, container.firstChild || null);
15
- }
16
- renderFrame(frameState) {
17
- const { zoomLevel, projection } = frameState.viewState;
18
- const layers = this.map.layers;
19
- const mapElements = [];
20
- let previousElement = null;
21
- const visibleLayers = layers.filter((layer) => {
22
- return zoomLevel > (layer.minZoom || 0);
23
- });
24
- const renderLayer = (layer, declutterTree2) => {
25
- const viewState = frameState.viewState;
26
- if (layer.projection) {
27
- viewState.projection = layer.projection;
28
- }
29
- const element = layer.renderFrame(
30
- { ...frameState, viewState, declutterTree: declutterTree2 },
31
- previousElement
32
- );
33
- if (element !== previousElement) {
34
- mapElements.push(element);
35
- previousElement = element;
36
- }
37
- viewState.projection = projection;
38
- };
39
- const baseLayers = visibleLayers.filter((layer) => !layer.declutter);
40
- for (const layer of baseLayers) {
41
- renderLayer(layer);
42
- }
43
- const declutterTree = new RBush();
44
- const layersToDeclutter = [...visibleLayers].filter((layer) => !!layer.declutter).reverse();
45
- for (const layer of layersToDeclutter) {
46
- renderLayer(layer, declutterTree);
47
- }
48
- replaceChildren(this._element, mapElements);
49
- }
50
- }
51
- export {
52
- MapRenderer
53
- };
@@ -1,17 +0,0 @@
1
- import { FeatureRenderer } from './FeatureRenderer';
2
- export class TextLayerRenderer {
3
- constructor(layer: any);
4
- layer: any;
5
- featureRenderer: FeatureRenderer;
6
- _element: HTMLDivElement;
7
- renderFrame(frameState: any, targetElement: any): any;
8
- getTextElementWithID(id: any): Element;
9
- styleTextElement(element: any, textStyle: any, position: any): void;
10
- getElementBBox(element: any, position: any): {
11
- minX: number;
12
- minY: number;
13
- maxX: number;
14
- maxY: number;
15
- };
16
- getCollisionBoxElement(bbox: any): HTMLDivElement;
17
- }