@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,96 @@
|
|
|
1
|
+
import { Feature } from "../Feature.js";
|
|
2
|
+
import { LineString } from "../geometry/LineString.js";
|
|
3
|
+
import { Polygon } from "../geometry/Polygon.js";
|
|
4
|
+
import { Point } from "../geometry/Point.js";
|
|
5
|
+
import { extentForCoordinates } from "../util/extent.js";
|
|
6
|
+
class GeoJSON {
|
|
7
|
+
readFeaturesFromObject(object) {
|
|
8
|
+
const geoJSONObject = object;
|
|
9
|
+
let features = null;
|
|
10
|
+
if (geoJSONObject["type"] === "FeatureCollection") {
|
|
11
|
+
const geoJSONFeatureCollection = object;
|
|
12
|
+
features = [];
|
|
13
|
+
const geoJSONFeatures = geoJSONFeatureCollection["features"];
|
|
14
|
+
for (let i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
|
15
|
+
const featureObject = this.readFeatureFromObject(geoJSONFeatures[i]);
|
|
16
|
+
if (!featureObject) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
features.push(featureObject);
|
|
20
|
+
}
|
|
21
|
+
} else if (geoJSONObject["type"] === "Feature") {
|
|
22
|
+
features = [this.readFeatureFromObject(geoJSONObject)];
|
|
23
|
+
} else if (Array.isArray(geoJSONObject)) {
|
|
24
|
+
features = [];
|
|
25
|
+
for (let i = 0, ii = geoJSONObject.length; i < ii; ++i) {
|
|
26
|
+
const featureObject = this.readFeatureFromObject(geoJSONObject[i]);
|
|
27
|
+
if (!featureObject) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
features.push(featureObject);
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
try {
|
|
34
|
+
const geometries = this.readGeometriesFromObject(geoJSONObject);
|
|
35
|
+
const feature = new Feature({ geometries });
|
|
36
|
+
features = [feature];
|
|
37
|
+
} catch {
|
|
38
|
+
console.warn("Unable to interpret GeoJSON:", geoJSONObject);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return features.flat();
|
|
43
|
+
}
|
|
44
|
+
readFeatureFromObject(geoJSONObject) {
|
|
45
|
+
const geometries = this.readGeometriesFromObject(geoJSONObject["geometry"]);
|
|
46
|
+
if (geometries.length > 0) {
|
|
47
|
+
return new Feature({
|
|
48
|
+
id: geoJSONObject["id"],
|
|
49
|
+
geometries,
|
|
50
|
+
properties: geoJSONObject["properties"]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
readGeometriesFromObject(geometry) {
|
|
56
|
+
const geometries = [];
|
|
57
|
+
if (geometry.type === "Polygon") {
|
|
58
|
+
const polygon = this.readPolygonForCoordinates(geometry.coordinates);
|
|
59
|
+
geometries.push(polygon);
|
|
60
|
+
} else if (geometry.type === "MultiPolygon") {
|
|
61
|
+
for (const polygonCoordinates of geometry.coordinates) {
|
|
62
|
+
const polygon = this.readPolygonForCoordinates(polygonCoordinates);
|
|
63
|
+
geometries.push(polygon);
|
|
64
|
+
}
|
|
65
|
+
} else if (geometry.type === "LineString") {
|
|
66
|
+
const lineString = this.readLineStringForCoordinates(geometry.coordinates);
|
|
67
|
+
geometries.push(lineString);
|
|
68
|
+
} else if (geometry.type === "MultiLineString") {
|
|
69
|
+
for (const lineStringCoordinates of geometry.coordinates) {
|
|
70
|
+
const lineString = this.readLineStringForCoordinates(
|
|
71
|
+
lineStringCoordinates
|
|
72
|
+
);
|
|
73
|
+
geometries.push(lineString);
|
|
74
|
+
}
|
|
75
|
+
} else if (geometry.type === "Point") {
|
|
76
|
+
const point = this.readPointForCoordinates(geometry.coordinates);
|
|
77
|
+
geometries.push(point);
|
|
78
|
+
}
|
|
79
|
+
return geometries;
|
|
80
|
+
}
|
|
81
|
+
readPolygonForCoordinates(coordinates) {
|
|
82
|
+
const outerRing = coordinates[0];
|
|
83
|
+
const extent = extentForCoordinates(outerRing);
|
|
84
|
+
return new Polygon({ extent, coordinates });
|
|
85
|
+
}
|
|
86
|
+
readLineStringForCoordinates(coordinates) {
|
|
87
|
+
const extent = extentForCoordinates(coordinates);
|
|
88
|
+
return new LineString({ extent, coordinates });
|
|
89
|
+
}
|
|
90
|
+
readPointForCoordinates(coordinates) {
|
|
91
|
+
return new Point({ coordinates });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
GeoJSON
|
|
96
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class Geometry {
|
|
2
|
+
/**
|
|
3
|
+
* Represents vector geometry
|
|
4
|
+
* @constructor
|
|
5
|
+
* @param {Object} options
|
|
6
|
+
* @param {string} options.type - The type of geometry (e.g., 'Point', 'LineString', 'Polygon')
|
|
7
|
+
* @param {Array} options.extent - The extent of the geometry (e.g., [xmin, ymin, xmax, ymax])
|
|
8
|
+
* @param {Array} options.coordinates - The coordinates of the geometry (e.g., [[x1, y1], [x2, y2], ...])
|
|
9
|
+
*/
|
|
10
|
+
constructor({ type, extent, coordinates }: {
|
|
11
|
+
type: string;
|
|
12
|
+
extent: any[];
|
|
13
|
+
coordinates: any[];
|
|
14
|
+
});
|
|
15
|
+
type: string;
|
|
16
|
+
extent: any[];
|
|
17
|
+
coordinates: any[];
|
|
18
|
+
getProjected: any;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the geometry as a GeoJSON object
|
|
21
|
+
* @function
|
|
22
|
+
* @param {import("../projection").Projection} projection - The projection to use for the geometry
|
|
23
|
+
* @returns {Object} A GeoJSON representation of the projected geometry
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
private _getProjected;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the geometry as a GeoJSON object
|
|
29
|
+
* @returns {Object} The GeoJSON representation of the geometry
|
|
30
|
+
*/
|
|
31
|
+
getGeoJSON(): any;
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { memoise } from "../util/memoise.js";
|
|
2
|
+
class Geometry {
|
|
3
|
+
/**
|
|
4
|
+
* Represents vector geometry
|
|
5
|
+
* @constructor
|
|
6
|
+
* @param {Object} options
|
|
7
|
+
* @param {string} options.type - The type of geometry (e.g., 'Point', 'LineString', 'Polygon')
|
|
8
|
+
* @param {Array} options.extent - The extent of the geometry (e.g., [xmin, ymin, xmax, ymax])
|
|
9
|
+
* @param {Array} options.coordinates - The coordinates of the geometry (e.g., [[x1, y1], [x2, y2], ...])
|
|
10
|
+
*/
|
|
11
|
+
constructor({ type, extent, coordinates }) {
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.extent = extent;
|
|
14
|
+
this.coordinates = coordinates;
|
|
15
|
+
this.getProjected = memoise(this._getProjected).bind(this);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the geometry as a GeoJSON object
|
|
19
|
+
* @function
|
|
20
|
+
* @param {import("../projection").Projection} projection - The projection to use for the geometry
|
|
21
|
+
* @returns {Object} A GeoJSON representation of the projected geometry
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line no-unused-vars
|
|
25
|
+
_getProjected(projection) {
|
|
26
|
+
throw new Error("Not implemented");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns the geometry as a GeoJSON object
|
|
30
|
+
* @returns {Object} The GeoJSON representation of the geometry
|
|
31
|
+
*/
|
|
32
|
+
getGeoJSON() {
|
|
33
|
+
return {
|
|
34
|
+
type: this.type,
|
|
35
|
+
coordinates: this.coordinates
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
Geometry
|
|
41
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Geometry } from './Geometry';
|
|
2
|
+
export class LineString extends Geometry {
|
|
3
|
+
constructor({ type, extent, coordinates }: {
|
|
4
|
+
type?: string;
|
|
5
|
+
extent: any;
|
|
6
|
+
coordinates: any;
|
|
7
|
+
});
|
|
8
|
+
_getProjected(projection: any): {
|
|
9
|
+
type: string;
|
|
10
|
+
coordinates: any[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Geometry } from "./Geometry.js";
|
|
2
|
+
class LineString extends Geometry {
|
|
3
|
+
constructor({ type = "LineString", extent, coordinates }) {
|
|
4
|
+
super({ type, extent, coordinates });
|
|
5
|
+
}
|
|
6
|
+
_getProjected(projection) {
|
|
7
|
+
const projected = [];
|
|
8
|
+
for (const point of this.coordinates) {
|
|
9
|
+
projected.push(projection(point));
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
type: this.type,
|
|
13
|
+
coordinates: projected
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
LineString
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Geometry } from "./Geometry.js";
|
|
2
|
+
class Point extends Geometry {
|
|
3
|
+
constructor({ type = "Point", coordinates }) {
|
|
4
|
+
super({ type, extent: null, coordinates });
|
|
5
|
+
this.extent = [...coordinates, ...coordinates];
|
|
6
|
+
}
|
|
7
|
+
_getProjected(projection) {
|
|
8
|
+
return {
|
|
9
|
+
type: this.type,
|
|
10
|
+
coordinates: projection(this.coordinates)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
Point
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Geometry } from './Geometry';
|
|
2
|
+
export class Polygon extends Geometry {
|
|
3
|
+
constructor({ type, extent, coordinates }: {
|
|
4
|
+
type?: string;
|
|
5
|
+
extent: any;
|
|
6
|
+
coordinates: any;
|
|
7
|
+
});
|
|
8
|
+
_getProjected(projection: any): {
|
|
9
|
+
type: string;
|
|
10
|
+
coordinates: any[][];
|
|
11
|
+
};
|
|
12
|
+
getOuterRing(): any;
|
|
13
|
+
setOuterRing(coordinates: any): void;
|
|
14
|
+
setCoordinates(coordinates: any): void;
|
|
15
|
+
clone(): Polygon;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Geometry } from "./Geometry.js";
|
|
2
|
+
class Polygon extends Geometry {
|
|
3
|
+
constructor({ type = "Polygon", extent, coordinates }) {
|
|
4
|
+
super({ type, extent, coordinates });
|
|
5
|
+
}
|
|
6
|
+
_getProjected(projection) {
|
|
7
|
+
const projected = [];
|
|
8
|
+
const rings = this.coordinates;
|
|
9
|
+
for (const ring of rings) {
|
|
10
|
+
const projectedRing = [];
|
|
11
|
+
for (const point of ring) {
|
|
12
|
+
const projectedPoint = projection(point);
|
|
13
|
+
if (projectedPoint) {
|
|
14
|
+
projectedRing.push(projectedPoint);
|
|
15
|
+
} else {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (projectedRing.length > 0) {
|
|
20
|
+
projected.push(projectedRing);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
type: this.type,
|
|
25
|
+
coordinates: projected
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
getOuterRing() {
|
|
29
|
+
return this.coordinates[0];
|
|
30
|
+
}
|
|
31
|
+
setOuterRing(coordinates) {
|
|
32
|
+
this.coordinates[0] = coordinates;
|
|
33
|
+
}
|
|
34
|
+
setCoordinates(coordinates) {
|
|
35
|
+
this.coordinates = coordinates;
|
|
36
|
+
}
|
|
37
|
+
clone() {
|
|
38
|
+
return new Polygon({
|
|
39
|
+
extent: this.extent,
|
|
40
|
+
coordinates: JSON.parse(JSON.stringify(this.coordinates))
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
Polygon
|
|
46
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function interpolateFeatures(currentFeatures, newFeatures, { interpolate, separate, combine }) {
|
|
2
|
+
if (currentFeatures.length !== newFeatures.length) {
|
|
3
|
+
throw new Error(
|
|
4
|
+
"interpolateFeatures expects an equal number of features for start and end"
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
const featureInterpolators = [];
|
|
8
|
+
for (let i = 0; i < currentFeatures.length; i++) {
|
|
9
|
+
const geometryInterpolators = [];
|
|
10
|
+
const currentGeometries = currentFeatures[i].geometries;
|
|
11
|
+
const newGeometries = newFeatures[i].geometries;
|
|
12
|
+
if (newGeometries.length === currentGeometries.length) {
|
|
13
|
+
for (let e = 0; e < currentGeometries.length; e++) {
|
|
14
|
+
const currentGeometry = currentGeometries[e];
|
|
15
|
+
const newGeometry = newGeometries[e];
|
|
16
|
+
if (currentGeometry.type !== "Polygon" || newGeometry.type !== "Polygon") {
|
|
17
|
+
throw new Error("interpolateFeatures expects only Polygon geometry");
|
|
18
|
+
}
|
|
19
|
+
const shapeInterpolator = interpolate(
|
|
20
|
+
currentGeometries[e].getOuterRing(),
|
|
21
|
+
newGeometries[e].getOuterRing(),
|
|
22
|
+
{ string: false }
|
|
23
|
+
);
|
|
24
|
+
geometryInterpolators.push({
|
|
25
|
+
type: "default",
|
|
26
|
+
interpolator: shapeInterpolator
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
} else if (currentGeometries.length === 1 && newGeometries.length > 1) {
|
|
30
|
+
const separationInterpolator = separate(
|
|
31
|
+
currentGeometries[0].getOuterRing(),
|
|
32
|
+
newGeometries.map((geometry) => geometry.getOuterRing()),
|
|
33
|
+
{ string: false, single: true }
|
|
34
|
+
);
|
|
35
|
+
geometryInterpolators.push({
|
|
36
|
+
type: "separate",
|
|
37
|
+
interpolator: separationInterpolator
|
|
38
|
+
});
|
|
39
|
+
} else if (currentGeometries.length > 1 && newGeometries.length === 1) {
|
|
40
|
+
const combinationInterpolator = combine(
|
|
41
|
+
currentGeometries.map((geometry) => geometry.getOuterRing()),
|
|
42
|
+
newGeometries[0].getOuterRing(),
|
|
43
|
+
{ string: false, single: true }
|
|
44
|
+
);
|
|
45
|
+
geometryInterpolators.push({
|
|
46
|
+
type: "combine",
|
|
47
|
+
interpolator: combinationInterpolator
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Encountered an unexpected number of geometries: ${currentGeometries.length} and ${newGeometries.length}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
featureInterpolators.push(geometryInterpolators);
|
|
55
|
+
}
|
|
56
|
+
return (t) => {
|
|
57
|
+
if (t >= 1) {
|
|
58
|
+
return newFeatures;
|
|
59
|
+
}
|
|
60
|
+
const features = [];
|
|
61
|
+
for (let i = 0; i < featureInterpolators.length; i++) {
|
|
62
|
+
const feature = newFeatures[i].clone();
|
|
63
|
+
const geometries = [];
|
|
64
|
+
const geometryInterpolators = featureInterpolators[i];
|
|
65
|
+
for (const [
|
|
66
|
+
index,
|
|
67
|
+
{ type, interpolator }
|
|
68
|
+
] of geometryInterpolators.entries()) {
|
|
69
|
+
let geometry = feature.geometries[index].clone();
|
|
70
|
+
let interpolated;
|
|
71
|
+
switch (type) {
|
|
72
|
+
case "separate":
|
|
73
|
+
case "combine":
|
|
74
|
+
interpolated = interpolator(t);
|
|
75
|
+
interpolated.forEach((d) => {
|
|
76
|
+
const polygon = geometry.clone();
|
|
77
|
+
polygon.setCoordinates([d]);
|
|
78
|
+
geometries.push(polygon);
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
geometry.setOuterRing(interpolator(t));
|
|
83
|
+
geometries.push(geometry);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
feature.setGeometry(geometries);
|
|
88
|
+
features.push(feature);
|
|
89
|
+
}
|
|
90
|
+
return features;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
interpolateFeatures
|
|
95
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Style, Fill, Stroke } from '../styles';
|
|
2
|
+
export function interpolateStyles(firstStyle: any, secondStyle: any, interpolateColors: any, interpolateNumbers: any): (t: any) => Style;
|
|
3
|
+
export function interpolateFill(fillA: any, fillB: any, interpolateColors: any, interpolateNumbers: any): (t: any) => Fill;
|
|
4
|
+
export function interpolateStroke(strokeA: any, strokeB: any, interpolateColors: any, interpolateNumbers: any): (t: any) => Stroke;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
};
|