@guardian/interactive-component-library 0.2.0-rc1 → 0.2.0-rc2
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/_virtual/_commonjsHelpers.js +8 -0
- package/dist/_virtual/dayjs.min.js +4 -0
- package/dist/_virtual/relativeTime.js +4 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/molecules/canvas-map/Map.d.ts +17 -0
- package/dist/components/molecules/canvas-map/Map.js +89 -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 +38 -0
- package/dist/components/molecules/canvas-map/lib/Feature.js +104 -0
- package/dist/components/molecules/canvas-map/lib/FeatureCollection.d.ts +20 -0
- package/dist/components/molecules/canvas-map/lib/FeatureCollection.js +23 -0
- package/dist/components/molecules/canvas-map/lib/Map.d.ts +69 -0
- package/dist/components/molecules/canvas-map/lib/Map.js +254 -0
- package/dist/components/molecules/canvas-map/lib/View.d.ts +136 -0
- package/dist/components/molecules/canvas-map/lib/View.js +179 -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 +10 -0
- package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.js +96 -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 +16 -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 +111 -0
- package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.d.ts +53 -0
- package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.js +132 -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 +22 -0
- package/dist/components/molecules/canvas-map/lib/projection/index.js +12 -0
- package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.d.ts +6 -0
- package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.js +46 -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 +17 -0
- package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.js +119 -0
- package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.d.ts +10 -0
- package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.js +78 -0
- package/dist/components/molecules/canvas-map/lib/sources/VectorSource.d.ts +15 -0
- package/dist/components/molecules/canvas-map/lib/sources/VectorSource.js +56 -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 +8 -0
- package/dist/components/molecules/canvas-map/lib/styles/Stroke.js +16 -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 +10 -0
- package/dist/components/molecules/canvas-map/lib/styles/Text.js +14 -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 +26 -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 +21 -0
- package/dist/components/molecules/canvas-map/lib/util/extent.js +38 -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 +17 -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/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 +36 -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 +164 -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 +120 -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 +128 -0
- package/dist/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +338 -0
- package/dist/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +13 -0
- package/dist/node_modules/.pnpm/d3-composite-projections@1.4.0/node_modules/d3-composite-projections/src/albersUk.js +108 -0
- package/dist/node_modules/.pnpm/d3-composite-projections@1.4.0/node_modules/d3-composite-projections/src/bounds.js +24 -0
- package/dist/node_modules/.pnpm/d3-composite-projections@1.4.0/node_modules/d3-composite-projections/src/fit.js +18 -0
- package/dist/node_modules/.pnpm/d3-composite-projections@1.4.0/node_modules/d3-composite-projections/src/math.js +4 -0
- package/dist/node_modules/.pnpm/d3-dispatch@3.0.1/node_modules/d3-dispatch/src/dispatch.js +70 -0
- package/dist/node_modules/.pnpm/d3-ease@3.0.1/node_modules/d3-ease/src/cubic.js +6 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/color.js +24 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/constant.js +4 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/number.js +8 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/rgb.js +20 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/string.js +43 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/transform/decompose.js +28 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/transform/index.js +59 -0
- package/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/transform/parse.js +18 -0
- package/dist/node_modules/.pnpm/d3-path@2.0.0/node_modules/d3-path/src/path.js +73 -0
- package/dist/node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timeout.js +13 -0
- package/dist/node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js +96 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/interrupt.js +21 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/index.js +5 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/interrupt.js +9 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/transition.js +39 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/attr.js +55 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/attrTween.js +42 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/delay.js +18 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/duration.js +18 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/ease.js +14 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/easeVarying.js +15 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/end.js +23 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/filter.js +16 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/index.js +68 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/interpolate.js +11 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/merge.js +18 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/on.js +23 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/remove.js +13 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/schedule.js +125 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/select.js +20 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/selectAll.js +24 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/selection.js +8 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/style.js +47 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/styleTween.js +25 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/text.js +18 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/textTween.js +25 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/transition.js +22 -0
- package/dist/node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/tween.js +64 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.12/node_modules/dayjs/dayjs.min.js +282 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.12/node_modules/dayjs/plugin/relativeTime.js +48 -0
- package/dist/node_modules/.pnpm/flatbush@4.4.0/node_modules/flatbush/index.js +339 -0
- package/dist/node_modules/.pnpm/flatqueue@2.0.3/node_modules/flatqueue/index.js +67 -0
- package/dist/node_modules/.pnpm/preact-merge-refs@1.0.2_preact@10.21.0/node_modules/preact-merge-refs/lib/preact-merge-refs.modern.js +10 -0
- package/dist/node_modules/.pnpm/preact-transitioning@1.4.1_preact@10.21.0/node_modules/preact-transitioning/lib/preact-transitioning.modern.js +63 -0
- package/dist/node_modules/.pnpm/quickselect@2.0.0/node_modules/quickselect/index.js +47 -0
- package/dist/node_modules/.pnpm/rbush-knn@4.0.0/node_modules/rbush-knn/index.js +42 -0
- package/dist/node_modules/.pnpm/rbush@4.0.0/node_modules/rbush/index.js +378 -0
- package/dist/node_modules/.pnpm/tinyqueue@2.0.3/node_modules/tinyqueue/index.js +65 -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 +6 -0
- package/dist/shared/hooks/useTouchOrHover.js +95 -0
- package/dist/shared/hooks/useWindowSize.d.ts +4 -0
- package/dist/shared/hooks/useWindowSize.js +27 -0
- package/dist/style.css +74 -74
- 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 +6 -9
- package/dist/interactive-component-library.js +0 -7993
- package/dist/interactive-component-library.js.map +0 -1
- package/dist/interactive-component-library.umd.cjs +0 -7989
- package/dist/interactive-component-library.umd.cjs.map +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useRef, useMemo } from "preact/hooks";
|
|
3
|
+
import { positionLabels, scaleLinear } from "../../../shared/helpers/labelsUtil.js";
|
|
4
|
+
import { useContainerSize } from "../../../shared/hooks/useContainerSize.js";
|
|
5
|
+
import defaultStyles from "./style.module.css.js";
|
|
6
|
+
import { mergeStyles } from "../../../styles/helpers/mergeStyles.js";
|
|
7
|
+
const SlopeChart = ({
|
|
8
|
+
domain,
|
|
9
|
+
lines,
|
|
10
|
+
y1Label = (d) => d.y1,
|
|
11
|
+
y2Label = (d) => d.y2,
|
|
12
|
+
axis,
|
|
13
|
+
styles,
|
|
14
|
+
padding = { left: 24, right: 24, top: 20, bottom: 20 },
|
|
15
|
+
svgId
|
|
16
|
+
}) => {
|
|
17
|
+
const wrapperRef = useRef(null);
|
|
18
|
+
const containerSize = useContainerSize(wrapperRef);
|
|
19
|
+
const width = containerSize ? containerSize.width : 0;
|
|
20
|
+
const contentWidth = Math.floor(width - padding.left - padding.right);
|
|
21
|
+
const contentHeight = contentWidth;
|
|
22
|
+
const height = contentHeight + padding.top + padding.bottom;
|
|
23
|
+
const yScale = scaleLinear(domain, [contentHeight, 0]);
|
|
24
|
+
const show = width > 0;
|
|
25
|
+
const y1Labels = useMemo(() => {
|
|
26
|
+
let labels = lines.map((d) => ({ y: yScale(d.y1), value: y1Label(d) }));
|
|
27
|
+
return positionLabels(labels);
|
|
28
|
+
}, [lines, y1Label, yScale]);
|
|
29
|
+
const y2Labels = useMemo(() => {
|
|
30
|
+
let labels = lines.map((d) => ({ y: yScale(d.y2), value: y2Label(d) }));
|
|
31
|
+
return positionLabels(labels);
|
|
32
|
+
}, [lines, y2Label, yScale]);
|
|
33
|
+
styles = mergeStyles({ ...defaultStyles }, styles);
|
|
34
|
+
const chart = /* @__PURE__ */ jsx("svg", { className: styles.svg, width, height, id: svgId, children: /* @__PURE__ */ jsxs("g", { transform: `translate(${padding.left} ${padding.top})`, children: [
|
|
35
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(0 ${contentHeight})`, children: [
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
"line",
|
|
38
|
+
{
|
|
39
|
+
x1: 0,
|
|
40
|
+
x2: contentWidth,
|
|
41
|
+
className: styles.axis,
|
|
42
|
+
shapeRendering: "crispEdges"
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
"text",
|
|
47
|
+
{
|
|
48
|
+
dominantBaseline: "hanging",
|
|
49
|
+
className: [styles.label, styles.axisLabel].join(" "),
|
|
50
|
+
children: axis.startLabel
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
"text",
|
|
55
|
+
{
|
|
56
|
+
x: contentWidth,
|
|
57
|
+
dominantBaseline: "hanging",
|
|
58
|
+
textAnchor: "end",
|
|
59
|
+
className: [styles.label, styles.axisLabel].join(" "),
|
|
60
|
+
children: axis.endLabel
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] }),
|
|
64
|
+
lines.map((line, index) => {
|
|
65
|
+
const itemStyles = mergeStyles({ ...styles }, line.styles);
|
|
66
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
"line",
|
|
69
|
+
{
|
|
70
|
+
x1: 0,
|
|
71
|
+
y1: yScale(line.y1),
|
|
72
|
+
x2: contentWidth,
|
|
73
|
+
y2: yScale(line.y2),
|
|
74
|
+
className: `${itemStyles.lineWhite}`
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
"line",
|
|
79
|
+
{
|
|
80
|
+
x1: 0,
|
|
81
|
+
y1: yScale(line.y1),
|
|
82
|
+
x2: contentWidth,
|
|
83
|
+
y2: yScale(line.y2),
|
|
84
|
+
className: `${itemStyles.line} stroke-color--${line.abbreviation}`
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
"circle",
|
|
89
|
+
{
|
|
90
|
+
cx: 0,
|
|
91
|
+
cy: yScale(line.y1),
|
|
92
|
+
r: 4,
|
|
93
|
+
className: `${itemStyles.circle} fill-color--${line.abbreviation}`
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
"circle",
|
|
98
|
+
{
|
|
99
|
+
cx: contentWidth,
|
|
100
|
+
cy: yScale(line.y2),
|
|
101
|
+
r: 4,
|
|
102
|
+
className: `${itemStyles.circle} fill-color--${line.abbreviation}`
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }, index);
|
|
106
|
+
}),
|
|
107
|
+
y1Labels.map((label, index) => {
|
|
108
|
+
return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
109
|
+
"text",
|
|
110
|
+
{
|
|
111
|
+
x: 0,
|
|
112
|
+
y: label.y,
|
|
113
|
+
className: [styles.label, styles.y1Label].join(" "),
|
|
114
|
+
textAnchor: "end",
|
|
115
|
+
dominantBaseline: "middle",
|
|
116
|
+
children: label.value
|
|
117
|
+
}
|
|
118
|
+
) }, index);
|
|
119
|
+
}),
|
|
120
|
+
y2Labels.map((label, index) => {
|
|
121
|
+
return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
122
|
+
"text",
|
|
123
|
+
{
|
|
124
|
+
x: contentWidth,
|
|
125
|
+
y: label.y,
|
|
126
|
+
className: [styles.label, styles.y2Label].join(" "),
|
|
127
|
+
textAnchor: "start",
|
|
128
|
+
dominantBaseline: "middle",
|
|
129
|
+
children: label.value
|
|
130
|
+
}
|
|
131
|
+
) }, index);
|
|
132
|
+
})
|
|
133
|
+
] }) });
|
|
134
|
+
return /* @__PURE__ */ jsx("div", { className: styles.slopeChartContainer, ref: wrapperRef, children: show && chart });
|
|
135
|
+
};
|
|
136
|
+
export {
|
|
137
|
+
SlopeChart,
|
|
138
|
+
SlopeChart as default
|
|
139
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const slopeChartContainer = "_slopeChartContainer_nmjjj_1";
|
|
2
|
+
const svg = "_svg_nmjjj_5";
|
|
3
|
+
const line = "_line_nmjjj_9";
|
|
4
|
+
const lineWhite = "_lineWhite_nmjjj_14";
|
|
5
|
+
const circle = "_circle_nmjjj_19";
|
|
6
|
+
const label = "_label_nmjjj_23";
|
|
7
|
+
const y1Label = "_y1Label_nmjjj_29";
|
|
8
|
+
const y2Label = "_y2Label_nmjjj_33";
|
|
9
|
+
const axis = "_axis_nmjjj_37";
|
|
10
|
+
const axisLabel = "_axisLabel_nmjjj_42";
|
|
11
|
+
const defaultStyles = {
|
|
12
|
+
slopeChartContainer,
|
|
13
|
+
svg,
|
|
14
|
+
line,
|
|
15
|
+
lineWhite,
|
|
16
|
+
circle,
|
|
17
|
+
label,
|
|
18
|
+
y1Label,
|
|
19
|
+
y2Label,
|
|
20
|
+
axis,
|
|
21
|
+
axisLabel
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
axis,
|
|
25
|
+
axisLabel,
|
|
26
|
+
circle,
|
|
27
|
+
defaultStyles as default,
|
|
28
|
+
label,
|
|
29
|
+
line,
|
|
30
|
+
lineWhite,
|
|
31
|
+
slopeChartContainer,
|
|
32
|
+
svg,
|
|
33
|
+
y1Label,
|
|
34
|
+
y2Label
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MapContext: import('preact').Context<any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function SVGMapProvider({ id, mapRef, width, height, padding, config, selectedFeature, children, }: {
|
|
2
|
+
id: any;
|
|
3
|
+
mapRef: any;
|
|
4
|
+
width: any;
|
|
5
|
+
height: any;
|
|
6
|
+
padding: any;
|
|
7
|
+
config: any;
|
|
8
|
+
selectedFeature: any;
|
|
9
|
+
children: any;
|
|
10
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef, useCallback } from "preact/hooks";
|
|
3
|
+
import { geoPath } from "d3-geo";
|
|
4
|
+
import { bboxFeature } from "../helpers/bboxFeature.js";
|
|
5
|
+
import { MapContext } from "./MapContext.js";
|
|
6
|
+
function SVGMapProvider({
|
|
7
|
+
id,
|
|
8
|
+
mapRef,
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
padding,
|
|
12
|
+
config,
|
|
13
|
+
selectedFeature,
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
16
|
+
const contentSize = useMemo(
|
|
17
|
+
() => ({
|
|
18
|
+
width: width - padding.left - padding.right,
|
|
19
|
+
height: height - padding.top - padding.bottom
|
|
20
|
+
}),
|
|
21
|
+
[width, height, padding]
|
|
22
|
+
);
|
|
23
|
+
const projection = useMemo(() => {
|
|
24
|
+
return config.projection.fitSize(
|
|
25
|
+
[contentSize.width, contentSize.height],
|
|
26
|
+
bboxFeature(config.bounds)
|
|
27
|
+
);
|
|
28
|
+
}, [contentSize, config]);
|
|
29
|
+
const path = geoPath().projection(projection);
|
|
30
|
+
const layerSet = useRef(/* @__PURE__ */ new Set());
|
|
31
|
+
const layers = useRef([]);
|
|
32
|
+
const updateLayers = useCallback((layerSet2) => {
|
|
33
|
+
const _layers = Array.from(layerSet2.current);
|
|
34
|
+
_layers.sort((a, b) => {
|
|
35
|
+
return b.zIndex - a.zIndex;
|
|
36
|
+
});
|
|
37
|
+
layers.current = _layers;
|
|
38
|
+
}, []);
|
|
39
|
+
const registerLayer = useCallback(
|
|
40
|
+
(layer) => {
|
|
41
|
+
layerSet.current.add(layer);
|
|
42
|
+
updateLayers(layerSet);
|
|
43
|
+
},
|
|
44
|
+
[updateLayers]
|
|
45
|
+
);
|
|
46
|
+
const unregisterLayer = useCallback(
|
|
47
|
+
(layer) => {
|
|
48
|
+
layerSet.current.delete(layer);
|
|
49
|
+
updateLayers(layerSet);
|
|
50
|
+
},
|
|
51
|
+
[updateLayers]
|
|
52
|
+
);
|
|
53
|
+
const findFeatureAtPoint = useCallback(
|
|
54
|
+
({ x, y }) => {
|
|
55
|
+
const adjustedPoint = [x - padding.left, y - padding.top];
|
|
56
|
+
for (const layer of layers.current) {
|
|
57
|
+
if (typeof layer.findFeatureAtPoint === "function") {
|
|
58
|
+
const feature = layer.findFeatureAtPoint(adjustedPoint);
|
|
59
|
+
if (feature) return feature;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
},
|
|
64
|
+
[padding]
|
|
65
|
+
);
|
|
66
|
+
const context = {
|
|
67
|
+
id,
|
|
68
|
+
projection,
|
|
69
|
+
config,
|
|
70
|
+
path,
|
|
71
|
+
size: { width, height },
|
|
72
|
+
contentSize,
|
|
73
|
+
padding,
|
|
74
|
+
extent: [
|
|
75
|
+
[0, 0],
|
|
76
|
+
[width, height]
|
|
77
|
+
],
|
|
78
|
+
selectedFeature,
|
|
79
|
+
registerLayer,
|
|
80
|
+
unregisterLayer,
|
|
81
|
+
findFeatureAtPoint
|
|
82
|
+
};
|
|
83
|
+
mapRef.current = context;
|
|
84
|
+
return /* @__PURE__ */ jsx(MapContext.Provider, { value: context, children });
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
SVGMapProvider
|
|
88
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function dynamicPropValue(prop: any, d: any, index: any): any;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function calculateScale(mapBounds: any, mapWidthPixels: any, mapHeightPixels: any): number;
|
|
2
|
+
export function circleContainsCoordinates(circleCoordinates: any, radius: any, coordinates: any): boolean;
|
|
3
|
+
export function distanceInKmBetweenEarthCoordinates(point1: any, point2: any): number;
|
|
4
|
+
export function degreesToRadians(degrees: any): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function saveSVG(elementId: any): void;
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect } from "preact/hooks";
|
|
2
|
+
import { toChildArray } from "preact";
|
|
3
|
+
import * as index from "../layers/index.js";
|
|
4
|
+
const layerTypes = Object.values(index);
|
|
5
|
+
function useThrowIfNonLayerChildren(children) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const firstNonLayerChild = toChildArray(children).find(
|
|
8
|
+
(child) => !layerTypes.includes(child.type)
|
|
9
|
+
);
|
|
10
|
+
if (firstNonLayerChild) {
|
|
11
|
+
throw Error(
|
|
12
|
+
`unknown component type passed as child to SVGMap component: ${firstNonLayerChild.type}`
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}, [children]);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useThrowIfNonLayerChildren
|
|
19
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * as MapLayers from './layers';
|
|
2
|
+
export namespace _Projection {
|
|
3
|
+
let geoAlbersUKComposite: any;
|
|
4
|
+
let geoAlbersEngland: any;
|
|
5
|
+
let geoMercator: any;
|
|
6
|
+
}
|
|
7
|
+
export namespace MapConfiguration {
|
|
8
|
+
namespace UKComposite {
|
|
9
|
+
import projection = _Projection.geoAlbersUKComposite;
|
|
10
|
+
export { projection };
|
|
11
|
+
export let bounds: number[][];
|
|
12
|
+
export let drawCompositionBorders: boolean;
|
|
13
|
+
export let drawToCanvas: boolean;
|
|
14
|
+
}
|
|
15
|
+
namespace England {
|
|
16
|
+
import projection_1 = _Projection.geoAlbersEngland;
|
|
17
|
+
export { projection_1 as projection };
|
|
18
|
+
let bounds_1: number[][];
|
|
19
|
+
export { bounds_1 as bounds };
|
|
20
|
+
let drawCompositionBorders_1: boolean;
|
|
21
|
+
export { drawCompositionBorders_1 as drawCompositionBorders };
|
|
22
|
+
let drawToCanvas_1: boolean;
|
|
23
|
+
export { drawToCanvas_1 as drawToCanvas };
|
|
24
|
+
}
|
|
25
|
+
namespace London {
|
|
26
|
+
let projection_2: any;
|
|
27
|
+
export { projection_2 as projection };
|
|
28
|
+
let bounds_2: number[][];
|
|
29
|
+
export { bounds_2 as bounds };
|
|
30
|
+
let drawCompositionBorders_2: boolean;
|
|
31
|
+
export { drawCompositionBorders_2 as drawCompositionBorders };
|
|
32
|
+
let drawToCanvas_2: boolean;
|
|
33
|
+
export { drawToCanvas_2 as drawToCanvas };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const SVGMap: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<{}> & {
|
|
37
|
+
ref?: import('preact').Ref<any>;
|
|
38
|
+
}>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { geoAlbers, geoMercator } from "d3-geo";
|
|
3
|
+
import geoAlbersUk from "../../../node_modules/.pnpm/d3-composite-projections@1.4.0/node_modules/d3-composite-projections/src/albersUk.js";
|
|
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
|
+
const _Projection = {
|
|
14
|
+
geoAlbersUKComposite: geoAlbersUk(),
|
|
15
|
+
geoAlbersEngland: geoAlbers().center([0, 52.7]).rotate([1.1743, 0]).parallels([50, 54]),
|
|
16
|
+
geoMercator: geoMercator()
|
|
17
|
+
};
|
|
18
|
+
const MapConfiguration = {
|
|
19
|
+
UKComposite: {
|
|
20
|
+
projection: _Projection.geoAlbersUKComposite,
|
|
21
|
+
bounds: [
|
|
22
|
+
[-8.642194417322951, 49.88234469492934],
|
|
23
|
+
[1.7683086664999994, 60.8456995072]
|
|
24
|
+
],
|
|
25
|
+
drawCompositionBorders: true,
|
|
26
|
+
drawToCanvas: false
|
|
27
|
+
},
|
|
28
|
+
England: {
|
|
29
|
+
projection: _Projection.geoAlbersEngland,
|
|
30
|
+
bounds: [
|
|
31
|
+
[-6.41866730264044, 49.8647926027119],
|
|
32
|
+
[1.76370537625026, 55.8111151140706]
|
|
33
|
+
],
|
|
34
|
+
drawCompositionBorders: false,
|
|
35
|
+
drawToCanvas: false
|
|
36
|
+
},
|
|
37
|
+
London: {
|
|
38
|
+
projection: geoMercator(),
|
|
39
|
+
bounds: [
|
|
40
|
+
[-0.510356073504132, 51.2867586289553],
|
|
41
|
+
[0.334043866981608, 51.6918768002741]
|
|
42
|
+
],
|
|
43
|
+
drawCompositionBorders: false,
|
|
44
|
+
drawToCanvas: false
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const ZERO_PADDING = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
48
|
+
const SVGMap = forwardRef(
|
|
49
|
+
({
|
|
50
|
+
id,
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
config,
|
|
54
|
+
children,
|
|
55
|
+
padding = { top: 20, right: 20, bottom: 20, left: 20 },
|
|
56
|
+
selectedFeature
|
|
57
|
+
}, ref) => {
|
|
58
|
+
useThrowIfNonLayerChildren(children);
|
|
59
|
+
padding = padding || ZERO_PADDING;
|
|
60
|
+
const containerRef = useRef();
|
|
61
|
+
const [isReady, setIsReady] = useState(false);
|
|
62
|
+
useLayoutEffect(() => {
|
|
63
|
+
if (!isReady) {
|
|
64
|
+
setIsReady(true);
|
|
65
|
+
}
|
|
66
|
+
return () => {
|
|
67
|
+
if (isReady) {
|
|
68
|
+
setIsReady(false);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [isReady]);
|
|
72
|
+
const mapRef = useRef();
|
|
73
|
+
useImperativeHandle(
|
|
74
|
+
ref,
|
|
75
|
+
() => ({
|
|
76
|
+
isReady,
|
|
77
|
+
getContainer: () => containerRef.current,
|
|
78
|
+
getContext: () => mapRef.current
|
|
79
|
+
}),
|
|
80
|
+
[isReady]
|
|
81
|
+
);
|
|
82
|
+
const containerSize = useContainerSize(containerRef);
|
|
83
|
+
const containerStyle = useMemo(() => {
|
|
84
|
+
const style = {};
|
|
85
|
+
if (width > 0) style["width"] = width;
|
|
86
|
+
if (height > 0) style["height"] = height;
|
|
87
|
+
return style;
|
|
88
|
+
}, [width, height]);
|
|
89
|
+
const renderSVG = containerSize && !config.drawToCanvas;
|
|
90
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
91
|
+
return /* @__PURE__ */ jsx(
|
|
92
|
+
"figure",
|
|
93
|
+
{
|
|
94
|
+
ref: containerRef,
|
|
95
|
+
className: styles.container,
|
|
96
|
+
style: containerStyle,
|
|
97
|
+
children: renderSVG && /* @__PURE__ */ jsx(
|
|
98
|
+
SVGMapProvider,
|
|
99
|
+
{
|
|
100
|
+
id,
|
|
101
|
+
width: containerSize.width,
|
|
102
|
+
height: containerSize.height,
|
|
103
|
+
padding,
|
|
104
|
+
config,
|
|
105
|
+
mapRef,
|
|
106
|
+
selectedFeature,
|
|
107
|
+
children: /* @__PURE__ */ jsx(SVGRenderer, { children: childrenArray.map(
|
|
108
|
+
(child, index) => cloneElement(child, { zIndex: index })
|
|
109
|
+
) })
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
export {
|
|
117
|
+
MapConfiguration,
|
|
118
|
+
SVGMap,
|
|
119
|
+
_Projection
|
|
120
|
+
};
|
|
@@ -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
|
+
};
|