@guardian/interactive-component-library 0.3.1 → 0.3.2
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.
- package/dist/components/index.d.ts +3 -0
- package/dist/components/molecules/canvas-map/Map.d.ts +8 -0
- package/dist/components/molecules/canvas-map/Map.js +90 -0
- package/dist/components/molecules/canvas-map/context/MapContext.d.ts +19 -0
- package/dist/components/molecules/canvas-map/context/MapContext.js +20 -0
- package/dist/components/molecules/canvas-map/controls/ZoomControl.d.ts +6 -0
- package/dist/components/molecules/canvas-map/controls/ZoomControl.js +40 -0
- package/dist/components/molecules/canvas-map/controls/icons/index.d.ts +3 -0
- package/dist/components/molecules/canvas-map/controls/icons/minus.d.ts +1 -0
- package/dist/components/molecules/canvas-map/controls/icons/minus.js +25 -0
- package/dist/components/molecules/canvas-map/controls/icons/plus.d.ts +1 -0
- package/dist/components/molecules/canvas-map/controls/icons/plus.js +25 -0
- package/dist/components/molecules/canvas-map/controls/icons/reset.d.ts +3 -0
- package/dist/components/molecules/canvas-map/controls/icons/reset.js +25 -0
- package/dist/components/molecules/canvas-map/controls/index.d.ts +1 -0
- package/dist/components/molecules/canvas-map/controls/style.module.css.js +11 -0
- package/dist/components/molecules/canvas-map/index.d.ts +12 -0
- package/dist/components/molecules/canvas-map/lib/Feature.d.ts +44 -0
- package/dist/components/molecules/canvas-map/lib/Feature.js +113 -0
- package/dist/components/molecules/canvas-map/lib/FeatureCollection.d.ts +21 -0
- package/dist/components/molecules/canvas-map/lib/FeatureCollection.js +24 -0
- package/dist/components/molecules/canvas-map/lib/Map.d.ts +82 -0
- package/dist/components/molecules/canvas-map/lib/Map.js +267 -0
- package/dist/components/molecules/canvas-map/lib/View.d.ts +222 -0
- package/dist/components/molecules/canvas-map/lib/View.js +208 -0
- package/dist/components/molecules/canvas-map/lib/events/Dispatcher.d.ts +8 -0
- package/dist/components/molecules/canvas-map/lib/events/Dispatcher.js +35 -0
- package/dist/components/molecules/canvas-map/lib/events/MapEvent.d.ts +6 -0
- package/dist/components/molecules/canvas-map/lib/events/MapEvent.js +9 -0
- package/dist/components/molecules/canvas-map/lib/events/index.d.ts +2 -0
- package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.d.ts +63 -0
- package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.js +122 -0
- package/dist/components/molecules/canvas-map/lib/geometry/Geometry.d.ts +32 -0
- package/dist/components/molecules/canvas-map/lib/geometry/Geometry.js +41 -0
- package/dist/components/molecules/canvas-map/lib/geometry/LineString.d.ts +12 -0
- package/dist/components/molecules/canvas-map/lib/geometry/LineString.js +19 -0
- package/dist/components/molecules/canvas-map/lib/geometry/Point.d.ts +11 -0
- package/dist/components/molecules/canvas-map/lib/geometry/Point.js +22 -0
- package/dist/components/molecules/canvas-map/lib/geometry/Polygon.d.ts +16 -0
- package/dist/components/molecules/canvas-map/lib/geometry/Polygon.js +46 -0
- package/dist/components/molecules/canvas-map/lib/geometry/index.d.ts +4 -0
- package/dist/components/molecules/canvas-map/lib/interpolators/index.d.ts +2 -0
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.d.ts +5 -0
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.js +95 -0
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.d.ts +4 -0
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.js +65 -0
- package/dist/components/molecules/canvas-map/lib/layers/TextLayer.d.ts +52 -0
- package/dist/components/molecules/canvas-map/lib/layers/TextLayer.js +118 -0
- package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.d.ts +57 -0
- package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.js +136 -0
- package/dist/components/molecules/canvas-map/lib/layers/index.d.ts +3 -0
- package/dist/components/molecules/canvas-map/lib/projection/index.d.ts +27 -0
- package/dist/components/molecules/canvas-map/lib/projection/index.js +12 -0
- package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.d.ts +16 -0
- package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.js +90 -0
- package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.d.ts +6 -0
- package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.js +53 -0
- package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.d.ts +21 -0
- package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.js +133 -0
- package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.d.ts +10 -0
- package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.js +79 -0
- package/dist/components/molecules/canvas-map/lib/sources/VectorSource.d.ts +15 -0
- package/dist/components/molecules/canvas-map/lib/sources/VectorSource.js +53 -0
- package/dist/components/molecules/canvas-map/lib/styles/Fill.d.ts +7 -0
- package/dist/components/molecules/canvas-map/lib/styles/Fill.js +15 -0
- package/dist/components/molecules/canvas-map/lib/styles/Stroke.d.ts +24 -0
- package/dist/components/molecules/canvas-map/lib/styles/Stroke.js +22 -0
- package/dist/components/molecules/canvas-map/lib/styles/Style.d.ts +24 -0
- package/dist/components/molecules/canvas-map/lib/styles/Style.js +17 -0
- package/dist/components/molecules/canvas-map/lib/styles/Text.d.ts +146 -0
- package/dist/components/molecules/canvas-map/lib/styles/Text.js +116 -0
- package/dist/components/molecules/canvas-map/lib/styles/index.d.ts +4 -0
- package/dist/components/molecules/canvas-map/lib/util/array.d.ts +6 -0
- package/dist/components/molecules/canvas-map/lib/util/array.js +15 -0
- package/dist/components/molecules/canvas-map/lib/util/bboxFeature.d.ts +8 -0
- package/dist/components/molecules/canvas-map/lib/util/bboxFeature.js +24 -0
- package/dist/components/molecules/canvas-map/lib/util/bounds.d.ts +47 -0
- package/dist/components/molecules/canvas-map/lib/util/bounds.js +61 -0
- package/dist/components/molecules/canvas-map/lib/util/coordinate.d.ts +26 -0
- package/dist/components/molecules/canvas-map/lib/util/coordinate.js +35 -0
- package/dist/components/molecules/canvas-map/lib/util/debug.d.ts +11 -0
- package/dist/components/molecules/canvas-map/lib/util/debug.js +27 -0
- package/dist/components/molecules/canvas-map/lib/util/deflate.d.ts +36 -0
- package/dist/components/molecules/canvas-map/lib/util/distance.d.ts +1 -0
- package/dist/components/molecules/canvas-map/lib/util/distance.js +12 -0
- package/dist/components/molecules/canvas-map/lib/util/dom.d.ts +9 -0
- package/dist/components/molecules/canvas-map/lib/util/dom.js +28 -0
- package/dist/components/molecules/canvas-map/lib/util/extent.d.ts +98 -0
- package/dist/components/molecules/canvas-map/lib/util/extent.js +118 -0
- package/dist/components/molecules/canvas-map/lib/util/index.d.ts +6 -0
- package/dist/components/molecules/canvas-map/lib/util/memoise.d.ts +10 -0
- package/dist/components/molecules/canvas-map/lib/util/memoise.js +20 -0
- package/dist/components/molecules/canvas-map/lib/util/resolution.d.ts +9 -0
- package/dist/components/molecules/canvas-map/lib/util/resolution.js +11 -0
- package/dist/components/molecules/canvas-map/lib/util/simplify.d.ts +114 -0
- package/dist/components/molecules/canvas-map/lib/util/size.d.ts +32 -0
- package/dist/components/molecules/canvas-map/lib/util/size.js +53 -0
- package/dist/components/molecules/canvas-map/lib/util/toRgba.d.ts +1 -0
- package/dist/components/molecules/canvas-map/lib/util/toRgba.js +25 -0
- package/dist/components/molecules/canvas-map/lib/util/uid.d.ts +5 -0
- package/dist/components/molecules/canvas-map/lib/util/uid.js +7 -0
- package/dist/components/molecules/canvas-map/lib/util/zoomLevel.d.ts +2 -0
- package/dist/components/molecules/canvas-map/lib/util/zoomLevel.js +14 -0
- package/dist/components/molecules/canvas-map/style.module.scss.js +20 -0
- package/dist/components/molecules/column-chart/column-chart-example.d.ts +35 -0
- package/dist/components/molecules/column-chart/column-chart-util.d.ts +1 -0
- package/dist/components/molecules/column-chart/index.d.ts +11 -0
- package/dist/components/molecules/column-chart/index.js +63 -0
- package/dist/components/molecules/column-chart/style.module.css.js +14 -0
- package/dist/components/molecules/control-change/index.d.ts +6 -0
- package/dist/components/molecules/control-change/index.js +29 -0
- package/dist/components/molecules/control-change/style.module.css.js +11 -0
- package/dist/components/molecules/dropdown/index.d.ts +11 -0
- package/dist/components/molecules/dropdown/index.js +191 -0
- package/dist/components/molecules/dropdown/style.module.css.js +50 -0
- package/dist/components/molecules/first-past-the-post-waffle/index.d.ts +5 -0
- package/dist/components/molecules/first-past-the-post-waffle/index.js +14 -0
- package/dist/components/molecules/first-past-the-post-waffle/style.module.css.js +14 -0
- package/dist/components/molecules/index.d.ts +18 -0
- package/dist/components/molecules/modal/index.d.ts +8 -0
- package/dist/components/molecules/modal/index.js +59 -0
- package/dist/components/molecules/modal/style.module.css.js +26 -0
- package/dist/components/molecules/option-picker/index.d.ts +26 -0
- package/dist/components/molecules/option-picker/index.js +94 -0
- package/dist/components/molecules/option-picker/style.module.css.js +35 -0
- package/dist/components/molecules/page-section/index.d.ts +8 -0
- package/dist/components/molecules/page-section/index.js +52 -0
- package/dist/components/molecules/page-section/style.module.scss.js +20 -0
- package/dist/components/molecules/party-profile/index.d.ts +10 -0
- package/dist/components/molecules/party-profile/index.js +29 -0
- package/dist/components/molecules/party-profile/style.module.css.js +26 -0
- package/dist/components/molecules/refresh-indicator/index.d.ts +4 -0
- package/dist/components/molecules/refresh-indicator/index.js +18 -0
- package/dist/components/molecules/refresh-indicator/style.module.scss.js +17 -0
- package/dist/components/molecules/responsive-grid/index.d.ts +10 -0
- package/dist/components/molecules/responsive-grid/index.js +19 -0
- package/dist/components/molecules/responsive-grid/style.module.scss.js +8 -0
- package/dist/components/molecules/result-summary/index.d.ts +8 -0
- package/dist/components/molecules/result-summary/index.js +40 -0
- package/dist/components/molecules/result-summary/style.module.css.js +11 -0
- package/dist/components/molecules/search-input/icons/search.d.ts +1 -0
- package/dist/components/molecules/search-input/icons/search.js +24 -0
- package/dist/components/molecules/search-input/icons/search.module.css.js +11 -0
- package/dist/components/molecules/search-input/index.d.ts +11 -0
- package/dist/components/molecules/search-input/index.js +165 -0
- package/dist/components/molecules/search-input/style.module.css.js +32 -0
- package/dist/components/molecules/slope-chart/index.d.ts +16 -0
- package/dist/components/molecules/slope-chart/index.js +139 -0
- package/dist/components/molecules/slope-chart/style.module.css.js +35 -0
- package/dist/components/molecules/svg-map/context/MapContext.d.ts +1 -0
- package/dist/components/molecules/svg-map/context/MapContext.js +5 -0
- package/dist/components/molecules/svg-map/context/SVGMapProvider.d.ts +10 -0
- package/dist/components/molecules/svg-map/context/SVGMapProvider.js +88 -0
- package/dist/components/molecules/svg-map/helpers/bboxFeature.d.ts +8 -0
- package/dist/components/molecules/svg-map/helpers/bboxFeature.js +26 -0
- package/dist/components/molecules/svg-map/helpers/dynamicPropValue.d.ts +1 -0
- package/dist/components/molecules/svg-map/helpers/dynamicPropValue.js +9 -0
- package/dist/components/molecules/svg-map/helpers/geoMath.d.ts +4 -0
- package/dist/components/molecules/svg-map/helpers/saveSVG.d.ts +1 -0
- package/dist/components/molecules/svg-map/hooks/useCamera.d.ts +0 -0
- package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.d.ts +4 -0
- package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.js +19 -0
- package/dist/components/molecules/svg-map/index.d.ts +38 -0
- package/dist/components/molecules/svg-map/index.js +121 -0
- package/dist/components/molecules/svg-map/layers/CompositionBorders.d.ts +3 -0
- package/dist/components/molecules/svg-map/layers/CompositionBorders.js +14 -0
- package/dist/components/molecules/svg-map/layers/Line.d.ts +7 -0
- package/dist/components/molecules/svg-map/layers/Line.js +48 -0
- package/dist/components/molecules/svg-map/layers/Point.d.ts +10 -0
- package/dist/components/molecules/svg-map/layers/Point.js +59 -0
- package/dist/components/molecules/svg-map/layers/Polygon.d.ts +9 -0
- package/dist/components/molecules/svg-map/layers/Polygon.js +75 -0
- package/dist/components/molecules/svg-map/layers/Prerendered.d.ts +3 -0
- package/dist/components/molecules/svg-map/layers/Prerendered.js +11 -0
- package/dist/components/molecules/svg-map/layers/compositionBorders.module.scss.js +8 -0
- package/dist/components/molecules/svg-map/layers/index.d.ts +5 -0
- package/dist/components/molecules/svg-map/layers/index.js +12 -0
- package/dist/components/molecules/svg-map/renderers/SVGRenderer.d.ts +3 -0
- package/dist/components/molecules/svg-map/renderers/SVGRenderer.js +32 -0
- package/dist/components/molecules/svg-map/style.module.css.js +11 -0
- package/dist/components/molecules/table/index.d.ts +7 -0
- package/dist/components/molecules/table/index.js +90 -0
- package/dist/components/molecules/table/style.module.scss.js +29 -0
- package/dist/components/molecules/table/useTable.d.ts +8 -0
- package/dist/components/molecules/table/useTable.js +128 -0
- package/dist/components/molecules/tooltip/index.d.ts +82 -0
- package/dist/components/molecules/tooltip/index.js +117 -0
- package/dist/components/molecules/tooltip/style.module.css.js +8 -0
- package/dist/components/molecules/topline-result/index.d.ts +3 -0
- package/dist/components/molecules/topline-result/index.js +61 -0
- package/dist/components/molecules/topline-result/style.module.scss.js +38 -0
- package/dist/components/organisms/coalitions-tracker/index.d.ts +16 -0
- package/dist/components/organisms/coalitions-tracker/index.js +151 -0
- package/dist/components/organisms/coalitions-tracker/style.module.scss.js +32 -0
- package/dist/components/organisms/index.d.ts +2 -0
- package/dist/components/organisms/ticker/gradient/index.d.ts +1 -0
- package/dist/components/organisms/ticker/gradient/index.js +35 -0
- package/dist/components/organisms/ticker/gradient/style.module.scss.js +14 -0
- package/dist/components/organisms/ticker/index.d.ts +5 -0
- package/dist/components/organisms/ticker/index.js +102 -0
- package/dist/components/organisms/ticker/style.module.scss.js +32 -0
- package/dist/components/particles/ad-slot/index.d.ts +40 -0
- package/dist/components/particles/ad-slot/index.js +34 -0
- package/dist/components/particles/ad-slot/style.module.css.js +11 -0
- package/dist/components/particles/arrow-button/index.d.ts +6 -0
- package/dist/components/particles/arrow-button/index.js +32 -0
- package/dist/components/particles/arrow-button/style.module.css.js +11 -0
- package/dist/components/particles/aspect-ratio-box/index.d.ts +4 -0
- package/dist/components/particles/aspect-ratio-box/index.js +15 -0
- package/dist/components/particles/aspect-ratio-box/style.module.css.js +6 -0
- package/dist/components/particles/button/index.d.ts +6 -0
- package/dist/components/particles/button/index.js +10 -0
- package/dist/components/particles/button/style.module.css.js +11 -0
- package/dist/components/particles/change-bar/index.d.ts +8 -0
- package/dist/components/particles/change-bar/index.js +27 -0
- package/dist/components/particles/change-bar/style.module.scss.js +14 -0
- package/dist/components/particles/chevron/index.d.ts +6 -0
- package/dist/components/particles/chevron/index.js +78 -0
- package/dist/components/particles/chevron/style.module.css.js +20 -0
- package/dist/components/particles/circle-icon/index.d.ts +6 -0
- package/dist/components/particles/circle-icon/index.js +32 -0
- package/dist/components/particles/circle-icon/style.module.css.js +14 -0
- package/dist/components/particles/close-button/index.d.ts +5 -0
- package/dist/components/particles/close-button/index.js +35 -0
- package/dist/components/particles/close-button/style.module.css.js +17 -0
- package/dist/components/particles/container/index.d.ts +5 -0
- package/dist/components/particles/container/index.js +13 -0
- package/dist/components/particles/container/style.module.scss.js +11 -0
- package/dist/components/particles/gradient-icon/index.d.ts +1 -0
- package/dist/components/particles/gradient-icon/index.js +46 -0
- package/dist/components/particles/gradient-icon/style.module.css.js +14 -0
- package/dist/components/particles/index.d.ts +18 -0
- package/dist/components/particles/info-button/index.d.ts +3 -0
- package/dist/components/particles/info-button/index.js +19 -0
- package/dist/components/particles/info-button/style.module.css.js +11 -0
- package/dist/components/particles/legend-item/index.d.ts +6 -0
- package/dist/components/particles/legend-item/index.js +26 -0
- package/dist/components/particles/legend-item/style.module.css.js +17 -0
- package/dist/components/particles/relative-time-sentence/index.d.ts +4 -0
- package/dist/components/particles/relative-time-sentence/index.js +14 -0
- package/dist/components/particles/relative-time-sentence/style.module.css.js +8 -0
- package/dist/components/particles/square-cut-corner-icon/index.d.ts +6 -0
- package/dist/components/particles/square-cut-corner-icon/index.js +56 -0
- package/dist/components/particles/square-cut-corner-icon/style.module.scss.js +17 -0
- package/dist/components/particles/square-icon/index.d.ts +5 -0
- package/dist/components/particles/square-icon/index.js +28 -0
- package/dist/components/particles/square-icon/style.module.scss.js +11 -0
- package/dist/components/particles/stacked-bar/index.d.ts +23 -0
- package/dist/components/particles/stacked-bar/index.js +140 -0
- package/dist/components/particles/stacked-bar/style.module.css.js +17 -0
- package/dist/components/particles/stacked-grid/index.d.ts +6 -0
- package/dist/components/particles/stacked-grid/index.js +35 -0
- package/dist/components/particles/stacked-grid/style.module.css.js +20 -0
- package/dist/components/particles/waffle/index.d.ts +14 -0
- package/dist/components/particles/waffle/index.js +76 -0
- package/dist/components/particles/waffle/style.module.css.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +147 -0
- package/dist/shared/colors/index.d.ts +2 -0
- package/dist/shared/helpers/createStore.d.ts +1 -0
- package/dist/shared/helpers/geometry.d.ts +3 -0
- package/dist/shared/helpers/geometry.js +16 -0
- package/dist/shared/helpers/geometry.test.d.ts +1 -0
- package/dist/shared/helpers/labelsUtil.d.ts +54 -0
- package/dist/shared/helpers/labelsUtil.js +58 -0
- package/dist/shared/helpers/labelsUtils.test.d.ts +1 -0
- package/dist/shared/helpers/shouldUpdate.d.ts +7 -0
- package/dist/shared/hooks/index.d.ts +3 -0
- package/dist/shared/hooks/useContainerSize.d.ts +1 -0
- package/dist/shared/hooks/useContainerSize.js +24 -0
- package/dist/shared/hooks/useTouchOrHover.d.ts +7 -0
- package/dist/shared/hooks/useTouchOrHover.js +103 -0
- package/dist/shared/hooks/useWindowSize.d.ts +4 -0
- package/dist/shared/hooks/useWindowSize.js +27 -0
- package/dist/style.css +170 -82
- package/dist/styles/helpers/mergeStyles.d.ts +1 -0
- package/dist/styles/helpers/mergeStyles.js +22 -0
- package/dist/styles/helpers/mergeStyles.test.d.ts +1 -0
- package/dist/styles/theme.config.d.ts +124 -0
- package/package.json +19 -10
- package/dist/interactive-component-library.js +0 -8370
- package/dist/interactive-component-library.js.map +0 -1
- package/dist/interactive-component-library.umd.cjs +0 -8365
- package/dist/interactive-component-library.umd.cjs.map +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { geoAlbers, geoMercator } from "d3-geo";
|
|
3
|
+
import { geoAlbersUk } from "d3-composite-projections";
|
|
4
|
+
import { SVGMapProvider } from "./context/SVGMapProvider.js";
|
|
5
|
+
import { SVGRenderer } from "./renderers/SVGRenderer.js";
|
|
6
|
+
import { cloneElement } from "preact";
|
|
7
|
+
import { useRef, useState, useLayoutEffect, useImperativeHandle, useMemo } from "preact/hooks";
|
|
8
|
+
import { forwardRef } from "preact/compat";
|
|
9
|
+
import { useThrowIfNonLayerChildren } from "./hooks/useThrowIfNonLayerChildren.js";
|
|
10
|
+
import { useContainerSize } from "../../../shared/hooks/useContainerSize.js";
|
|
11
|
+
import styles from "./style.module.css.js";
|
|
12
|
+
import "./context/MapContext.js";
|
|
13
|
+
import "flatbush";
|
|
14
|
+
const _Projection = {
|
|
15
|
+
geoAlbersUKComposite: geoAlbersUk(),
|
|
16
|
+
geoAlbersEngland: geoAlbers().center([0, 52.7]).rotate([1.1743, 0]).parallels([50, 54]),
|
|
17
|
+
geoMercator: geoMercator()
|
|
18
|
+
};
|
|
19
|
+
const MapConfiguration = {
|
|
20
|
+
UKComposite: {
|
|
21
|
+
projection: _Projection.geoAlbersUKComposite,
|
|
22
|
+
bounds: [
|
|
23
|
+
[-8.642194417322951, 49.88234469492934],
|
|
24
|
+
[1.7683086664999994, 60.8456995072]
|
|
25
|
+
],
|
|
26
|
+
drawCompositionBorders: true,
|
|
27
|
+
drawToCanvas: false
|
|
28
|
+
},
|
|
29
|
+
England: {
|
|
30
|
+
projection: _Projection.geoAlbersEngland,
|
|
31
|
+
bounds: [
|
|
32
|
+
[-6.41866730264044, 49.8647926027119],
|
|
33
|
+
[1.76370537625026, 55.8111151140706]
|
|
34
|
+
],
|
|
35
|
+
drawCompositionBorders: false,
|
|
36
|
+
drawToCanvas: false
|
|
37
|
+
},
|
|
38
|
+
London: {
|
|
39
|
+
projection: geoMercator(),
|
|
40
|
+
bounds: [
|
|
41
|
+
[-0.510356073504132, 51.2867586289553],
|
|
42
|
+
[0.334043866981608, 51.6918768002741]
|
|
43
|
+
],
|
|
44
|
+
drawCompositionBorders: false,
|
|
45
|
+
drawToCanvas: false
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const ZERO_PADDING = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
49
|
+
const SVGMap = forwardRef(
|
|
50
|
+
({
|
|
51
|
+
id,
|
|
52
|
+
width,
|
|
53
|
+
height,
|
|
54
|
+
config,
|
|
55
|
+
children,
|
|
56
|
+
padding = { top: 20, right: 20, bottom: 20, left: 20 },
|
|
57
|
+
selectedFeature
|
|
58
|
+
}, ref) => {
|
|
59
|
+
useThrowIfNonLayerChildren(children);
|
|
60
|
+
padding = padding || ZERO_PADDING;
|
|
61
|
+
const containerRef = useRef();
|
|
62
|
+
const [isReady, setIsReady] = useState(false);
|
|
63
|
+
useLayoutEffect(() => {
|
|
64
|
+
if (!isReady) {
|
|
65
|
+
setIsReady(true);
|
|
66
|
+
}
|
|
67
|
+
return () => {
|
|
68
|
+
if (isReady) {
|
|
69
|
+
setIsReady(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}, [isReady]);
|
|
73
|
+
const mapRef = useRef();
|
|
74
|
+
useImperativeHandle(
|
|
75
|
+
ref,
|
|
76
|
+
() => ({
|
|
77
|
+
isReady,
|
|
78
|
+
getContainer: () => containerRef.current,
|
|
79
|
+
getContext: () => mapRef.current
|
|
80
|
+
}),
|
|
81
|
+
[isReady]
|
|
82
|
+
);
|
|
83
|
+
const containerSize = useContainerSize(containerRef);
|
|
84
|
+
const containerStyle = useMemo(() => {
|
|
85
|
+
const style = {};
|
|
86
|
+
if (width > 0) style["width"] = width;
|
|
87
|
+
if (height > 0) style["height"] = height;
|
|
88
|
+
return style;
|
|
89
|
+
}, [width, height]);
|
|
90
|
+
const renderSVG = containerSize && !config.drawToCanvas;
|
|
91
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
92
|
+
return /* @__PURE__ */ jsx(
|
|
93
|
+
"figure",
|
|
94
|
+
{
|
|
95
|
+
ref: containerRef,
|
|
96
|
+
className: styles.container,
|
|
97
|
+
style: containerStyle,
|
|
98
|
+
children: renderSVG && /* @__PURE__ */ jsx(
|
|
99
|
+
SVGMapProvider,
|
|
100
|
+
{
|
|
101
|
+
id,
|
|
102
|
+
width: containerSize.width,
|
|
103
|
+
height: containerSize.height,
|
|
104
|
+
padding,
|
|
105
|
+
config,
|
|
106
|
+
mapRef,
|
|
107
|
+
selectedFeature,
|
|
108
|
+
children: /* @__PURE__ */ jsx(SVGRenderer, { children: childrenArray.map(
|
|
109
|
+
(child, index) => cloneElement(child, { zIndex: index })
|
|
110
|
+
) })
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
export {
|
|
118
|
+
MapConfiguration,
|
|
119
|
+
SVGMap,
|
|
120
|
+
_Projection
|
|
121
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { useContext } from "preact/hooks";
|
|
3
|
+
import { MapContext } from "../context/MapContext.js";
|
|
4
|
+
import defaultStyles from "./compositionBorders.module.scss.js";
|
|
5
|
+
import { mergeStyles } from "../../../../styles/helpers/mergeStyles.js";
|
|
6
|
+
function CompositionBorders({ styles }) {
|
|
7
|
+
const context = useContext(MapContext);
|
|
8
|
+
const { projection } = context;
|
|
9
|
+
styles = mergeStyles(defaultStyles, styles);
|
|
10
|
+
return /* @__PURE__ */ jsx("path", { className: styles.path, d: projection.getCompositionBorders() });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
CompositionBorders
|
|
14
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx, Fragment } from "preact/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect } from "preact/hooks";
|
|
3
|
+
import { MapContext } from "../context/MapContext.js";
|
|
4
|
+
import { dynamicPropValue } from "../helpers/dynamicPropValue.js";
|
|
5
|
+
function Line({ id, features, stroke = null, strokeWidth = 1, styles }) {
|
|
6
|
+
const context = useContext(MapContext);
|
|
7
|
+
const draw = (ctx, path) => {
|
|
8
|
+
for (const feature of features) {
|
|
9
|
+
ctx.beginPath();
|
|
10
|
+
ctx.lineWidth = strokeWidth / context.pixelRatio;
|
|
11
|
+
ctx.strokeStyle = stroke;
|
|
12
|
+
path(feature);
|
|
13
|
+
ctx.stroke();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (context.config.drawToCanvas) {
|
|
18
|
+
context.register(draw);
|
|
19
|
+
}
|
|
20
|
+
return () => {
|
|
21
|
+
if (context.config.drawToCanvas) {
|
|
22
|
+
context.unregister(draw);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
if (context.config.drawToCanvas) {
|
|
27
|
+
return "<!--Line layer-->";
|
|
28
|
+
}
|
|
29
|
+
return /* @__PURE__ */ jsx(Fragment, { children: features.map((d, index) => {
|
|
30
|
+
const resolvedStrokeWidth = dynamicPropValue(strokeWidth, d, index);
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"path",
|
|
33
|
+
{
|
|
34
|
+
id: dynamicPropValue(id, d, index),
|
|
35
|
+
stroke: dynamicPropValue(stroke, d, index),
|
|
36
|
+
strokeLinejoin: "round",
|
|
37
|
+
strokeWidth: resolvedStrokeWidth,
|
|
38
|
+
fill: "none",
|
|
39
|
+
className: dynamicPropValue(styles, d, index),
|
|
40
|
+
d: context.path(d)
|
|
41
|
+
},
|
|
42
|
+
index
|
|
43
|
+
);
|
|
44
|
+
}) });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
Line
|
|
48
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function Point({ id, features, radius, fill, stroke, strokeWidth, zIndex, styles, }: {
|
|
2
|
+
id: any;
|
|
3
|
+
features: any;
|
|
4
|
+
radius?: number;
|
|
5
|
+
fill?: any;
|
|
6
|
+
stroke?: any;
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
zIndex?: number;
|
|
9
|
+
styles: any;
|
|
10
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx, Fragment } from "preact/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect } from "preact/hooks";
|
|
3
|
+
import { MapContext } from "../context/MapContext.js";
|
|
4
|
+
import { dynamicPropValue } from "../helpers/dynamicPropValue.js";
|
|
5
|
+
function Point({
|
|
6
|
+
id,
|
|
7
|
+
features,
|
|
8
|
+
radius = 4,
|
|
9
|
+
fill = null,
|
|
10
|
+
stroke = null,
|
|
11
|
+
strokeWidth = 1,
|
|
12
|
+
zIndex = 0,
|
|
13
|
+
styles
|
|
14
|
+
}) {
|
|
15
|
+
const context = useContext(MapContext);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
function findFeatureAtPoint(point) {
|
|
18
|
+
for (const [index, feature] of features.entries()) {
|
|
19
|
+
const resolvedRadius = dynamicPropValue(radius, feature, index);
|
|
20
|
+
if (isNaN(resolvedRadius)) return;
|
|
21
|
+
const [cx, cy] = context.projection(feature.geometry.coordinates);
|
|
22
|
+
const distanceSquared = (point[0] - cx) ** 2 + (point[1] - cy) ** 2;
|
|
23
|
+
const radiusSquared = resolvedRadius ** 2;
|
|
24
|
+
if (distanceSquared <= radiusSquared) {
|
|
25
|
+
return feature;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const layer = {
|
|
31
|
+
zIndex,
|
|
32
|
+
findFeatureAtPoint
|
|
33
|
+
};
|
|
34
|
+
context.registerLayer(layer);
|
|
35
|
+
return () => {
|
|
36
|
+
context.unregisterLayer(layer);
|
|
37
|
+
};
|
|
38
|
+
}, [context, features, radius, zIndex]);
|
|
39
|
+
return /* @__PURE__ */ jsx(Fragment, { children: features.map((d, index) => {
|
|
40
|
+
const [cx, cy] = context.projection(d.geometry.coordinates);
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
"circle",
|
|
43
|
+
{
|
|
44
|
+
id: dynamicPropValue(id, d, index),
|
|
45
|
+
cx,
|
|
46
|
+
cy,
|
|
47
|
+
r: dynamicPropValue(radius, d, index),
|
|
48
|
+
className: dynamicPropValue(styles, d, index),
|
|
49
|
+
fill: dynamicPropValue(fill, d, index),
|
|
50
|
+
stroke: dynamicPropValue(stroke, d, index),
|
|
51
|
+
strokeWidth: dynamicPropValue(strokeWidth, d, index)
|
|
52
|
+
},
|
|
53
|
+
index
|
|
54
|
+
);
|
|
55
|
+
}) });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
Point
|
|
59
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx, Fragment } from "preact/jsx-runtime";
|
|
2
|
+
import { useContext, useState, useEffect, useCallback } from "preact/hooks";
|
|
3
|
+
import { MapContext } from "../context/MapContext.js";
|
|
4
|
+
import { dynamicPropValue } from "../helpers/dynamicPropValue.js";
|
|
5
|
+
import { geoContains } from "d3-geo";
|
|
6
|
+
import Flatbush from "flatbush";
|
|
7
|
+
function Polygon({
|
|
8
|
+
id,
|
|
9
|
+
features,
|
|
10
|
+
fill = null,
|
|
11
|
+
stroke = null,
|
|
12
|
+
strokeWidth = 1,
|
|
13
|
+
zIndex = 0,
|
|
14
|
+
styles
|
|
15
|
+
}) {
|
|
16
|
+
const context = useContext(MapContext);
|
|
17
|
+
const [searchIndex, setSearchIndex] = useState();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!context.path) return;
|
|
20
|
+
let index = new Flatbush(features.length);
|
|
21
|
+
for (const feature of features) {
|
|
22
|
+
const bounds = context.path.bounds(feature);
|
|
23
|
+
index.add(
|
|
24
|
+
Math.floor(bounds[0][0]),
|
|
25
|
+
Math.floor(bounds[0][1]),
|
|
26
|
+
Math.ceil(bounds[1][0]),
|
|
27
|
+
Math.ceil(bounds[1][1])
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
index.finish();
|
|
31
|
+
setSearchIndex(index);
|
|
32
|
+
}, [context.path, features]);
|
|
33
|
+
const findFeatureAtPoint = useCallback(
|
|
34
|
+
([x, y]) => {
|
|
35
|
+
const projectedPoint = context.projection.invert([x, y]);
|
|
36
|
+
const results = searchIndex.search(x, y, x, y);
|
|
37
|
+
let found = results[0];
|
|
38
|
+
results.forEach((idx) => {
|
|
39
|
+
const feature = features[idx];
|
|
40
|
+
if (geoContains(feature, projectedPoint)) {
|
|
41
|
+
found = idx;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return features[found];
|
|
45
|
+
},
|
|
46
|
+
[context, searchIndex, features]
|
|
47
|
+
);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const layer = {
|
|
50
|
+
zIndex,
|
|
51
|
+
findFeatureAtPoint
|
|
52
|
+
};
|
|
53
|
+
context.registerLayer(layer);
|
|
54
|
+
return () => {
|
|
55
|
+
context.unregisterLayer(layer);
|
|
56
|
+
};
|
|
57
|
+
}, [context, zIndex, findFeatureAtPoint]);
|
|
58
|
+
return /* @__PURE__ */ jsx(Fragment, { children: features.map((d, index) => {
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
"path",
|
|
61
|
+
{
|
|
62
|
+
id: dynamicPropValue(id, d, index),
|
|
63
|
+
className: dynamicPropValue(styles, d, index),
|
|
64
|
+
fill: dynamicPropValue(fill, d, index),
|
|
65
|
+
stroke: dynamicPropValue(stroke, d, index),
|
|
66
|
+
strokeWidth: dynamicPropValue(strokeWidth, d, index),
|
|
67
|
+
d: context.path(d)
|
|
68
|
+
},
|
|
69
|
+
index
|
|
70
|
+
);
|
|
71
|
+
}) });
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
Polygon
|
|
75
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { useContext } from "preact/hooks";
|
|
3
|
+
import { MapContext } from "../context/MapContext.js";
|
|
4
|
+
function Prerendered({ url }) {
|
|
5
|
+
const context = useContext(MapContext);
|
|
6
|
+
const { width, height } = context.contentSize;
|
|
7
|
+
return /* @__PURE__ */ jsx("image", { width, height, href: url });
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
Prerendered
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Polygon } from "./Polygon.js";
|
|
2
|
+
import { Line } from "./Line.js";
|
|
3
|
+
import { CompositionBorders } from "./CompositionBorders.js";
|
|
4
|
+
import { Prerendered } from "./Prerendered.js";
|
|
5
|
+
import { Point } from "./Point.js";
|
|
6
|
+
export {
|
|
7
|
+
CompositionBorders,
|
|
8
|
+
Line,
|
|
9
|
+
Point,
|
|
10
|
+
Polygon,
|
|
11
|
+
Prerendered
|
|
12
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useContext } from "preact/hooks";
|
|
3
|
+
import { MapContext } from "../context/MapContext.js";
|
|
4
|
+
import { CompositionBorders } from "../layers/CompositionBorders.js";
|
|
5
|
+
function SVGRenderer({ children }) {
|
|
6
|
+
const { id, config, size, selectedFeature, padding } = useContext(MapContext);
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"svg",
|
|
9
|
+
{
|
|
10
|
+
id,
|
|
11
|
+
width: size.width,
|
|
12
|
+
height: size.height,
|
|
13
|
+
viewBox: `0 0 ${size.width} ${size.height}`,
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
onClick: () => {
|
|
16
|
+
if (selectedFeature) {
|
|
17
|
+
selectedFeature.value = null;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
children: /* @__PURE__ */ jsxs("g", { transform: `translate(${padding.left} ${padding.top})`, children: [
|
|
21
|
+
/* @__PURE__ */ jsx("g", { children }),
|
|
22
|
+
config.drawCompositionBorders && Object.prototype.hasOwnProperty.call(
|
|
23
|
+
config.projection,
|
|
24
|
+
"getCompositionBorders"
|
|
25
|
+
) && /* @__PURE__ */ jsx(CompositionBorders, {})
|
|
26
|
+
] })
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
SVGRenderer
|
|
32
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsxs, jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { useState } from "preact/hooks";
|
|
3
|
+
import { useTable } from "./useTable.js";
|
|
4
|
+
import { Chevron } from "../../particles/chevron/index.js";
|
|
5
|
+
import defaultStyles from "./style.module.scss.js";
|
|
6
|
+
import { mergeStyles } from "../../../styles/helpers/mergeStyles.js";
|
|
7
|
+
function Table({
|
|
8
|
+
columns,
|
|
9
|
+
data,
|
|
10
|
+
hideHeader = false,
|
|
11
|
+
stickyHeader = false,
|
|
12
|
+
styles
|
|
13
|
+
}) {
|
|
14
|
+
const [sortState, setSortState] = useState(() => {
|
|
15
|
+
const columnIndex = columns.findIndex((column) => {
|
|
16
|
+
if ("sort" in column) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
});
|
|
21
|
+
const ascending = columnIndex >= 0 ? columns[columnIndex].sort.ascending : false;
|
|
22
|
+
return {
|
|
23
|
+
columnIndex,
|
|
24
|
+
ascending
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
const table = useTable({ columns, data, sortState });
|
|
28
|
+
const sortByColumn = (index) => {
|
|
29
|
+
setSortState((currentState) => {
|
|
30
|
+
return {
|
|
31
|
+
columnIndex: index,
|
|
32
|
+
ascending: index === currentState.columnIndex ? !currentState.ascending : false
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
styles = mergeStyles(defaultStyles, styles);
|
|
37
|
+
return /* @__PURE__ */ jsxs("table", { className: styles.table, cellSpacing: 0, cellPadding: 0, children: [
|
|
38
|
+
/* @__PURE__ */ jsx("thead", { className: hideHeader && styles.hideHeader, children: /* @__PURE__ */ jsx("tr", { children: table.columns.map((column, index) => {
|
|
39
|
+
var _a;
|
|
40
|
+
let columnStyle = mergeStyles(
|
|
41
|
+
styles.headerCell,
|
|
42
|
+
(_a = column.styles) == null ? void 0 : _a.headerCell
|
|
43
|
+
);
|
|
44
|
+
if (stickyHeader) {
|
|
45
|
+
columnStyle = mergeStyles(columnStyle, styles.stickyHeader);
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ jsx("th", { scope: "col", className: columnStyle, children: /* @__PURE__ */ jsx(
|
|
48
|
+
HeaderCell,
|
|
49
|
+
{
|
|
50
|
+
styles: mergeStyles(styles, column.styles),
|
|
51
|
+
onClick: () => sortByColumn(index),
|
|
52
|
+
...column.headerProps
|
|
53
|
+
},
|
|
54
|
+
index
|
|
55
|
+
) }, column.id);
|
|
56
|
+
}) }) }),
|
|
57
|
+
/* @__PURE__ */ jsx("tbody", { className: hideHeader && styles.hideHeaderNoBorder, children: table.rows.map((row) => {
|
|
58
|
+
return /* @__PURE__ */ jsx("tr", { className: styles.bodyRow, children: row.cells.map((cell) => {
|
|
59
|
+
var _a;
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
"td",
|
|
62
|
+
{
|
|
63
|
+
className: mergeStyles(
|
|
64
|
+
styles.bodyCell,
|
|
65
|
+
(_a = cell.column.styles) == null ? void 0 : _a.bodyCell
|
|
66
|
+
),
|
|
67
|
+
children: cell.displayValue
|
|
68
|
+
},
|
|
69
|
+
cell.id
|
|
70
|
+
);
|
|
71
|
+
}) }, row.id);
|
|
72
|
+
}) })
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
75
|
+
function HeaderCell({ text, sortable, isSorted, styles, onClick }) {
|
|
76
|
+
if (!sortable) {
|
|
77
|
+
return text;
|
|
78
|
+
}
|
|
79
|
+
let direction = "down";
|
|
80
|
+
if ((isSorted == null ? void 0 : isSorted.ascending) === false) {
|
|
81
|
+
direction = "up";
|
|
82
|
+
}
|
|
83
|
+
return /* @__PURE__ */ jsxs("button", { onClick, className: styles.headerCellButton, children: [
|
|
84
|
+
/* @__PURE__ */ jsx("span", { children: text }),
|
|
85
|
+
/* @__PURE__ */ jsx(Chevron, { active: !!isSorted, direction })
|
|
86
|
+
] });
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
Table
|
|
90
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const table = "_table_fhbur_9";
|
|
2
|
+
const hideHeader = "_hideHeader_fhbur_20";
|
|
3
|
+
const hideHeaderNoBorder = "_hideHeaderNoBorder_fhbur_29";
|
|
4
|
+
const headerCell = "_headerCell_fhbur_33";
|
|
5
|
+
const stickyHeader = "_stickyHeader_fhbur_42";
|
|
6
|
+
const headerCellButton = "_headerCellButton_fhbur_49";
|
|
7
|
+
const bodyRow = "_bodyRow_fhbur_58";
|
|
8
|
+
const bodyCell = "_bodyCell_fhbur_62";
|
|
9
|
+
const defaultStyles = {
|
|
10
|
+
table,
|
|
11
|
+
hideHeader,
|
|
12
|
+
hideHeaderNoBorder,
|
|
13
|
+
headerCell,
|
|
14
|
+
stickyHeader,
|
|
15
|
+
headerCellButton,
|
|
16
|
+
bodyRow,
|
|
17
|
+
bodyCell
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
bodyCell,
|
|
21
|
+
bodyRow,
|
|
22
|
+
defaultStyles as default,
|
|
23
|
+
headerCell,
|
|
24
|
+
headerCellButton,
|
|
25
|
+
hideHeader,
|
|
26
|
+
hideHeaderNoBorder,
|
|
27
|
+
stickyHeader,
|
|
28
|
+
table
|
|
29
|
+
};
|