@guardian/interactive-component-library 0.2.0-rc4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/interactive-component-library.js +8338 -0
- package/dist/interactive-component-library.js.map +1 -0
- package/dist/interactive-component-library.umd.cjs +8333 -0
- package/dist/interactive-component-library.umd.cjs.map +1 -0
- package/dist/style.css +157 -73
- package/package.json +11 -19
- package/dist/components/index.d.ts +0 -3
- package/dist/components/molecules/canvas-map/Map.d.ts +0 -17
- package/dist/components/molecules/canvas-map/Map.js +0 -89
- package/dist/components/molecules/canvas-map/context/MapContext.d.ts +0 -19
- package/dist/components/molecules/canvas-map/context/MapContext.js +0 -20
- package/dist/components/molecules/canvas-map/controls/ZoomControl.d.ts +0 -6
- package/dist/components/molecules/canvas-map/controls/ZoomControl.js +0 -40
- package/dist/components/molecules/canvas-map/controls/icons/index.d.ts +0 -3
- package/dist/components/molecules/canvas-map/controls/icons/minus.d.ts +0 -1
- package/dist/components/molecules/canvas-map/controls/icons/minus.js +0 -25
- package/dist/components/molecules/canvas-map/controls/icons/plus.d.ts +0 -1
- package/dist/components/molecules/canvas-map/controls/icons/plus.js +0 -25
- package/dist/components/molecules/canvas-map/controls/icons/reset.d.ts +0 -3
- package/dist/components/molecules/canvas-map/controls/icons/reset.js +0 -25
- package/dist/components/molecules/canvas-map/controls/index.d.ts +0 -1
- package/dist/components/molecules/canvas-map/controls/style.module.css.js +0 -11
- package/dist/components/molecules/canvas-map/index.d.ts +0 -12
- package/dist/components/molecules/canvas-map/lib/Feature.d.ts +0 -38
- package/dist/components/molecules/canvas-map/lib/Feature.js +0 -104
- package/dist/components/molecules/canvas-map/lib/FeatureCollection.d.ts +0 -20
- package/dist/components/molecules/canvas-map/lib/FeatureCollection.js +0 -23
- package/dist/components/molecules/canvas-map/lib/Map.d.ts +0 -69
- package/dist/components/molecules/canvas-map/lib/Map.js +0 -254
- package/dist/components/molecules/canvas-map/lib/View.d.ts +0 -136
- package/dist/components/molecules/canvas-map/lib/View.js +0 -179
- package/dist/components/molecules/canvas-map/lib/events/Dispatcher.d.ts +0 -8
- package/dist/components/molecules/canvas-map/lib/events/Dispatcher.js +0 -35
- package/dist/components/molecules/canvas-map/lib/events/MapEvent.d.ts +0 -6
- package/dist/components/molecules/canvas-map/lib/events/MapEvent.js +0 -9
- package/dist/components/molecules/canvas-map/lib/events/index.d.ts +0 -2
- package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.d.ts +0 -10
- package/dist/components/molecules/canvas-map/lib/formats/GeoJSON.js +0 -96
- package/dist/components/molecules/canvas-map/lib/geometry/Geometry.d.ts +0 -32
- package/dist/components/molecules/canvas-map/lib/geometry/Geometry.js +0 -41
- package/dist/components/molecules/canvas-map/lib/geometry/LineString.d.ts +0 -12
- package/dist/components/molecules/canvas-map/lib/geometry/LineString.js +0 -19
- package/dist/components/molecules/canvas-map/lib/geometry/Point.d.ts +0 -11
- package/dist/components/molecules/canvas-map/lib/geometry/Point.js +0 -16
- package/dist/components/molecules/canvas-map/lib/geometry/Polygon.d.ts +0 -16
- package/dist/components/molecules/canvas-map/lib/geometry/Polygon.js +0 -46
- package/dist/components/molecules/canvas-map/lib/geometry/index.d.ts +0 -4
- package/dist/components/molecules/canvas-map/lib/interpolators/index.d.ts +0 -2
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.d.ts +0 -5
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateFeatures.js +0 -95
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.d.ts +0 -4
- package/dist/components/molecules/canvas-map/lib/interpolators/interpolateStyles.js +0 -65
- package/dist/components/molecules/canvas-map/lib/layers/TextLayer.d.ts +0 -52
- package/dist/components/molecules/canvas-map/lib/layers/TextLayer.js +0 -111
- package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.d.ts +0 -53
- package/dist/components/molecules/canvas-map/lib/layers/VectorLayer.js +0 -132
- package/dist/components/molecules/canvas-map/lib/layers/index.d.ts +0 -3
- package/dist/components/molecules/canvas-map/lib/projection/index.d.ts +0 -22
- package/dist/components/molecules/canvas-map/lib/projection/index.js +0 -12
- package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.d.ts +0 -6
- package/dist/components/molecules/canvas-map/lib/renderers/FeatureRenderer.js +0 -46
- package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.d.ts +0 -6
- package/dist/components/molecules/canvas-map/lib/renderers/MapRenderer.js +0 -53
- package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.d.ts +0 -17
- package/dist/components/molecules/canvas-map/lib/renderers/TextLayerRenderer.js +0 -119
- package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.d.ts +0 -10
- package/dist/components/molecules/canvas-map/lib/renderers/VectorLayerRenderer.js +0 -78
- package/dist/components/molecules/canvas-map/lib/sources/VectorSource.d.ts +0 -15
- package/dist/components/molecules/canvas-map/lib/sources/VectorSource.js +0 -56
- package/dist/components/molecules/canvas-map/lib/styles/Fill.d.ts +0 -7
- package/dist/components/molecules/canvas-map/lib/styles/Fill.js +0 -15
- package/dist/components/molecules/canvas-map/lib/styles/Stroke.d.ts +0 -8
- package/dist/components/molecules/canvas-map/lib/styles/Stroke.js +0 -16
- package/dist/components/molecules/canvas-map/lib/styles/Style.d.ts +0 -24
- package/dist/components/molecules/canvas-map/lib/styles/Style.js +0 -17
- package/dist/components/molecules/canvas-map/lib/styles/Text.d.ts +0 -10
- package/dist/components/molecules/canvas-map/lib/styles/Text.js +0 -14
- package/dist/components/molecules/canvas-map/lib/styles/index.d.ts +0 -4
- package/dist/components/molecules/canvas-map/lib/util/array.d.ts +0 -6
- package/dist/components/molecules/canvas-map/lib/util/array.js +0 -15
- package/dist/components/molecules/canvas-map/lib/util/bboxFeature.d.ts +0 -8
- package/dist/components/molecules/canvas-map/lib/util/bboxFeature.js +0 -26
- package/dist/components/molecules/canvas-map/lib/util/debug.d.ts +0 -11
- package/dist/components/molecules/canvas-map/lib/util/debug.js +0 -27
- package/dist/components/molecules/canvas-map/lib/util/deflate.d.ts +0 -36
- package/dist/components/molecules/canvas-map/lib/util/distance.d.ts +0 -1
- package/dist/components/molecules/canvas-map/lib/util/distance.js +0 -12
- package/dist/components/molecules/canvas-map/lib/util/dom.d.ts +0 -9
- package/dist/components/molecules/canvas-map/lib/util/dom.js +0 -28
- package/dist/components/molecules/canvas-map/lib/util/extent.d.ts +0 -21
- package/dist/components/molecules/canvas-map/lib/util/extent.js +0 -38
- package/dist/components/molecules/canvas-map/lib/util/memoise.d.ts +0 -10
- package/dist/components/molecules/canvas-map/lib/util/memoise.js +0 -20
- package/dist/components/molecules/canvas-map/lib/util/resolution.d.ts +0 -9
- package/dist/components/molecules/canvas-map/lib/util/resolution.js +0 -11
- package/dist/components/molecules/canvas-map/lib/util/simplify.d.ts +0 -114
- package/dist/components/molecules/canvas-map/lib/util/size.d.ts +0 -32
- package/dist/components/molecules/canvas-map/lib/util/size.js +0 -53
- package/dist/components/molecules/canvas-map/lib/util/toRgba.d.ts +0 -1
- package/dist/components/molecules/canvas-map/lib/util/toRgba.js +0 -25
- package/dist/components/molecules/canvas-map/lib/util/uid.d.ts +0 -5
- package/dist/components/molecules/canvas-map/lib/util/uid.js +0 -7
- package/dist/components/molecules/canvas-map/lib/util/zoomLevel.d.ts +0 -2
- package/dist/components/molecules/canvas-map/lib/util/zoomLevel.js +0 -14
- package/dist/components/molecules/canvas-map/style.module.scss.js +0 -20
- package/dist/components/molecules/column-chart/column-chart-example.d.ts +0 -35
- package/dist/components/molecules/column-chart/column-chart-util.d.ts +0 -1
- package/dist/components/molecules/column-chart/index.d.ts +0 -11
- package/dist/components/molecules/column-chart/index.js +0 -63
- package/dist/components/molecules/column-chart/style.module.css.js +0 -14
- package/dist/components/molecules/control-change/index.d.ts +0 -6
- package/dist/components/molecules/control-change/index.js +0 -29
- package/dist/components/molecules/control-change/style.module.css.js +0 -11
- package/dist/components/molecules/dropdown/index.d.ts +0 -11
- package/dist/components/molecules/dropdown/index.js +0 -191
- package/dist/components/molecules/dropdown/style.module.css.js +0 -50
- package/dist/components/molecules/first-past-the-post-waffle/index.d.ts +0 -5
- package/dist/components/molecules/first-past-the-post-waffle/index.js +0 -14
- package/dist/components/molecules/first-past-the-post-waffle/style.module.css.js +0 -14
- package/dist/components/molecules/index.d.ts +0 -17
- package/dist/components/molecules/modal/index.d.ts +0 -8
- package/dist/components/molecules/modal/index.js +0 -59
- package/dist/components/molecules/modal/style.module.css.js +0 -26
- package/dist/components/molecules/page-section/index.d.ts +0 -8
- package/dist/components/molecules/page-section/index.js +0 -52
- package/dist/components/molecules/page-section/style.module.scss.js +0 -20
- package/dist/components/molecules/party-profile/index.d.ts +0 -10
- package/dist/components/molecules/party-profile/index.js +0 -29
- package/dist/components/molecules/party-profile/style.module.css.js +0 -26
- package/dist/components/molecules/refresh-indicator/index.d.ts +0 -4
- package/dist/components/molecules/refresh-indicator/index.js +0 -18
- package/dist/components/molecules/refresh-indicator/style.module.scss.js +0 -17
- package/dist/components/molecules/responsive-grid/index.d.ts +0 -10
- package/dist/components/molecules/responsive-grid/index.js +0 -19
- package/dist/components/molecules/responsive-grid/style.module.scss.js +0 -8
- package/dist/components/molecules/result-summary/index.d.ts +0 -8
- package/dist/components/molecules/result-summary/index.js +0 -38
- package/dist/components/molecules/result-summary/style.module.css.js +0 -11
- package/dist/components/molecules/search-input/icons/search.d.ts +0 -1
- package/dist/components/molecules/search-input/icons/search.js +0 -24
- package/dist/components/molecules/search-input/icons/search.module.css.js +0 -11
- package/dist/components/molecules/search-input/index.d.ts +0 -11
- package/dist/components/molecules/search-input/index.js +0 -164
- package/dist/components/molecules/search-input/style.module.css.js +0 -32
- package/dist/components/molecules/slope-chart/index.d.ts +0 -16
- package/dist/components/molecules/slope-chart/index.js +0 -139
- package/dist/components/molecules/slope-chart/style.module.css.js +0 -35
- package/dist/components/molecules/svg-map/context/MapContext.d.ts +0 -1
- package/dist/components/molecules/svg-map/context/MapContext.js +0 -5
- package/dist/components/molecules/svg-map/context/SVGMapProvider.d.ts +0 -10
- package/dist/components/molecules/svg-map/context/SVGMapProvider.js +0 -88
- package/dist/components/molecules/svg-map/helpers/bboxFeature.d.ts +0 -8
- package/dist/components/molecules/svg-map/helpers/bboxFeature.js +0 -26
- package/dist/components/molecules/svg-map/helpers/dynamicPropValue.d.ts +0 -1
- package/dist/components/molecules/svg-map/helpers/dynamicPropValue.js +0 -9
- package/dist/components/molecules/svg-map/helpers/geoMath.d.ts +0 -4
- package/dist/components/molecules/svg-map/helpers/saveSVG.d.ts +0 -1
- package/dist/components/molecules/svg-map/hooks/useCamera.d.ts +0 -0
- package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.d.ts +0 -4
- package/dist/components/molecules/svg-map/hooks/useThrowIfNonLayerChildren.js +0 -19
- package/dist/components/molecules/svg-map/index.d.ts +0 -38
- package/dist/components/molecules/svg-map/index.js +0 -121
- package/dist/components/molecules/svg-map/layers/CompositionBorders.d.ts +0 -3
- package/dist/components/molecules/svg-map/layers/CompositionBorders.js +0 -14
- package/dist/components/molecules/svg-map/layers/Line.d.ts +0 -7
- package/dist/components/molecules/svg-map/layers/Line.js +0 -48
- package/dist/components/molecules/svg-map/layers/Point.d.ts +0 -10
- package/dist/components/molecules/svg-map/layers/Point.js +0 -59
- package/dist/components/molecules/svg-map/layers/Polygon.d.ts +0 -9
- package/dist/components/molecules/svg-map/layers/Polygon.js +0 -75
- package/dist/components/molecules/svg-map/layers/Prerendered.d.ts +0 -3
- package/dist/components/molecules/svg-map/layers/Prerendered.js +0 -11
- package/dist/components/molecules/svg-map/layers/compositionBorders.module.scss.js +0 -8
- package/dist/components/molecules/svg-map/layers/index.d.ts +0 -5
- package/dist/components/molecules/svg-map/layers/index.js +0 -12
- package/dist/components/molecules/svg-map/renderers/SVGRenderer.d.ts +0 -3
- package/dist/components/molecules/svg-map/renderers/SVGRenderer.js +0 -32
- package/dist/components/molecules/svg-map/style.module.css.js +0 -11
- package/dist/components/molecules/table/index.d.ts +0 -7
- package/dist/components/molecules/table/index.js +0 -90
- package/dist/components/molecules/table/style.module.scss.js +0 -29
- package/dist/components/molecules/table/useTable.d.ts +0 -8
- package/dist/components/molecules/table/useTable.js +0 -128
- package/dist/components/molecules/tooltip/index.d.ts +0 -82
- package/dist/components/molecules/tooltip/index.js +0 -117
- package/dist/components/molecules/tooltip/style.module.css.js +0 -8
- package/dist/components/molecules/topline-result/index.d.ts +0 -3
- package/dist/components/molecules/topline-result/index.js +0 -61
- package/dist/components/molecules/topline-result/style.module.scss.js +0 -38
- package/dist/components/organisms/coalitions-tracker/index.d.ts +0 -16
- package/dist/components/organisms/coalitions-tracker/index.js +0 -151
- package/dist/components/organisms/coalitions-tracker/style.module.scss.js +0 -32
- package/dist/components/organisms/index.d.ts +0 -2
- package/dist/components/organisms/ticker/gradient/index.d.ts +0 -1
- package/dist/components/organisms/ticker/gradient/index.js +0 -35
- package/dist/components/organisms/ticker/gradient/style.module.scss.js +0 -14
- package/dist/components/organisms/ticker/index.d.ts +0 -5
- package/dist/components/organisms/ticker/index.js +0 -102
- package/dist/components/organisms/ticker/style.module.scss.js +0 -32
- package/dist/components/particles/ad-slot/index.d.ts +0 -40
- package/dist/components/particles/ad-slot/index.js +0 -34
- package/dist/components/particles/ad-slot/style.module.css.js +0 -11
- package/dist/components/particles/arrow-button/index.d.ts +0 -6
- package/dist/components/particles/arrow-button/index.js +0 -32
- package/dist/components/particles/arrow-button/style.module.css.js +0 -11
- package/dist/components/particles/aspect-ratio-box/index.d.ts +0 -4
- package/dist/components/particles/aspect-ratio-box/index.js +0 -15
- package/dist/components/particles/aspect-ratio-box/style.module.css.js +0 -6
- package/dist/components/particles/button/index.d.ts +0 -6
- package/dist/components/particles/button/index.js +0 -10
- package/dist/components/particles/button/style.module.css.js +0 -11
- package/dist/components/particles/change-bar/index.d.ts +0 -8
- package/dist/components/particles/change-bar/index.js +0 -27
- package/dist/components/particles/change-bar/style.module.scss.js +0 -14
- package/dist/components/particles/chevron/index.d.ts +0 -6
- package/dist/components/particles/chevron/index.js +0 -78
- package/dist/components/particles/chevron/style.module.css.js +0 -20
- package/dist/components/particles/circle-icon/index.d.ts +0 -6
- package/dist/components/particles/circle-icon/index.js +0 -32
- package/dist/components/particles/circle-icon/style.module.css.js +0 -14
- package/dist/components/particles/close-button/index.d.ts +0 -5
- package/dist/components/particles/close-button/index.js +0 -35
- package/dist/components/particles/close-button/style.module.css.js +0 -17
- package/dist/components/particles/container/index.d.ts +0 -5
- package/dist/components/particles/container/index.js +0 -13
- package/dist/components/particles/container/style.module.scss.js +0 -11
- package/dist/components/particles/gradient-icon/index.d.ts +0 -1
- package/dist/components/particles/gradient-icon/index.js +0 -46
- package/dist/components/particles/gradient-icon/style.module.css.js +0 -14
- package/dist/components/particles/index.d.ts +0 -18
- package/dist/components/particles/info-button/index.d.ts +0 -3
- package/dist/components/particles/info-button/index.js +0 -19
- package/dist/components/particles/info-button/style.module.css.js +0 -11
- package/dist/components/particles/legend-item/index.d.ts +0 -6
- package/dist/components/particles/legend-item/index.js +0 -26
- package/dist/components/particles/legend-item/style.module.css.js +0 -17
- package/dist/components/particles/relative-time-sentence/index.d.ts +0 -4
- package/dist/components/particles/relative-time-sentence/index.js +0 -14
- package/dist/components/particles/relative-time-sentence/style.module.css.js +0 -8
- package/dist/components/particles/square-cut-corner-icon/index.d.ts +0 -6
- package/dist/components/particles/square-cut-corner-icon/index.js +0 -56
- package/dist/components/particles/square-cut-corner-icon/style.module.scss.js +0 -17
- package/dist/components/particles/square-icon/index.d.ts +0 -5
- package/dist/components/particles/square-icon/index.js +0 -28
- package/dist/components/particles/square-icon/style.module.scss.js +0 -11
- package/dist/components/particles/stacked-bar/index.d.ts +0 -23
- package/dist/components/particles/stacked-bar/index.js +0 -140
- package/dist/components/particles/stacked-bar/style.module.css.js +0 -17
- package/dist/components/particles/stacked-grid/index.d.ts +0 -6
- package/dist/components/particles/stacked-grid/index.js +0 -35
- package/dist/components/particles/stacked-grid/style.module.css.js +0 -20
- package/dist/components/particles/waffle/index.d.ts +0 -14
- package/dist/components/particles/waffle/index.js +0 -76
- package/dist/components/particles/waffle/style.module.css.js +0 -11
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -128
- package/dist/shared/colors/index.d.ts +0 -2
- package/dist/shared/helpers/createStore.d.ts +0 -1
- package/dist/shared/helpers/geometry.d.ts +0 -3
- package/dist/shared/helpers/geometry.js +0 -16
- package/dist/shared/helpers/geometry.test.d.ts +0 -1
- package/dist/shared/helpers/labelsUtil.d.ts +0 -54
- package/dist/shared/helpers/labelsUtil.js +0 -58
- package/dist/shared/helpers/labelsUtils.test.d.ts +0 -1
- package/dist/shared/helpers/shouldUpdate.d.ts +0 -7
- package/dist/shared/hooks/index.d.ts +0 -3
- package/dist/shared/hooks/useContainerSize.d.ts +0 -1
- package/dist/shared/hooks/useContainerSize.js +0 -24
- package/dist/shared/hooks/useTouchOrHover.d.ts +0 -6
- package/dist/shared/hooks/useTouchOrHover.js +0 -95
- package/dist/shared/hooks/useWindowSize.d.ts +0 -4
- package/dist/shared/hooks/useWindowSize.js +0 -27
- package/dist/styles/helpers/mergeStyles.d.ts +0 -1
- package/dist/styles/helpers/mergeStyles.js +0 -22
- package/dist/styles/helpers/mergeStyles.test.d.ts +0 -1
- package/dist/styles/theme.config.d.ts +0 -124
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { jsx } from "preact/jsx-runtime";
|
|
2
|
-
import defaultStyles from "./style.module.css.js";
|
|
3
|
-
import { mergeStyles } from "../../../styles/helpers/mergeStyles.js";
|
|
4
|
-
import { useContainerSize } from "../../../shared/hooks/useContainerSize.js";
|
|
5
|
-
import { useRef } from "preact/hooks";
|
|
6
|
-
const WaffleType = {
|
|
7
|
-
circle: "circle",
|
|
8
|
-
square: "square"
|
|
9
|
-
};
|
|
10
|
-
const WaffleUnit = ({ type, attributes }) => type === WaffleType.square ? /* @__PURE__ */ jsx("rect", { ...attributes }) : /* @__PURE__ */ jsx("circle", { ...attributes });
|
|
11
|
-
const Waffle = ({
|
|
12
|
-
units,
|
|
13
|
-
numberOfRows,
|
|
14
|
-
type = WaffleType.circle,
|
|
15
|
-
idAccessor,
|
|
16
|
-
onMouseOver = () => {
|
|
17
|
-
},
|
|
18
|
-
onClick = () => {
|
|
19
|
-
},
|
|
20
|
-
styles,
|
|
21
|
-
svgId
|
|
22
|
-
}) => {
|
|
23
|
-
const containerRef = useRef();
|
|
24
|
-
const containerSize = useContainerSize(containerRef);
|
|
25
|
-
const width = containerSize ? containerSize.width : 0;
|
|
26
|
-
const total = units.length;
|
|
27
|
-
const columns = Math.ceil(total / numberOfRows);
|
|
28
|
-
const unitWidth = width / columns;
|
|
29
|
-
const unitHeight = unitWidth;
|
|
30
|
-
const height = numberOfRows * unitHeight;
|
|
31
|
-
styles = mergeStyles(defaultStyles, styles);
|
|
32
|
-
return /* @__PURE__ */ jsx("div", { ref: containerRef, className: styles.container, children: containerSize && /* @__PURE__ */ jsx(
|
|
33
|
-
"svg",
|
|
34
|
-
{
|
|
35
|
-
viewBox: `0 0 ${width} ${height}`,
|
|
36
|
-
className: styles.svg,
|
|
37
|
-
id: svgId,
|
|
38
|
-
children: /* @__PURE__ */ jsx("g", { children: units.map((unit, j) => {
|
|
39
|
-
let attributes;
|
|
40
|
-
if (type === WaffleType.square) {
|
|
41
|
-
attributes = {
|
|
42
|
-
id: unit[idAccessor] || `w-${j}`,
|
|
43
|
-
onMouseOver: (e) => onMouseOver(unit, e),
|
|
44
|
-
onClick: (e) => onClick(unit, e),
|
|
45
|
-
class: `${styles.unit} ${unit.class}`,
|
|
46
|
-
height: unitHeight,
|
|
47
|
-
width: unitWidth,
|
|
48
|
-
x: unitWidth * Math.floor(j / numberOfRows),
|
|
49
|
-
y: unitHeight * (j % numberOfRows)
|
|
50
|
-
};
|
|
51
|
-
} else {
|
|
52
|
-
attributes = {
|
|
53
|
-
id: unit[idAccessor] || `w-${j}`,
|
|
54
|
-
onMouseOver: (e) => onMouseOver(unit, e),
|
|
55
|
-
onClick: (e) => onClick(unit, e),
|
|
56
|
-
class: `${styles.unit} ${unit.class}`,
|
|
57
|
-
r: unitWidth / 2,
|
|
58
|
-
transform: `translate(${unitWidth * Math.floor(j / numberOfRows) + unitWidth / 2}, ${unitHeight * (j % numberOfRows) + unitHeight / 2})`
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return /* @__PURE__ */ jsx(
|
|
62
|
-
WaffleUnit,
|
|
63
|
-
{
|
|
64
|
-
type,
|
|
65
|
-
attributes
|
|
66
|
-
},
|
|
67
|
-
`wu-${j}`
|
|
68
|
-
);
|
|
69
|
-
}) })
|
|
70
|
-
}
|
|
71
|
-
) });
|
|
72
|
-
};
|
|
73
|
-
export {
|
|
74
|
-
Waffle,
|
|
75
|
-
WaffleType
|
|
76
|
-
};
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/* empty css */
|
|
2
|
-
import { Chevron } from "./components/particles/chevron/index.js";
|
|
3
|
-
import { LegendItem } from "./components/particles/legend-item/index.js";
|
|
4
|
-
import { LabelOverlapConfig, LabelType, StackedBar } from "./components/particles/stacked-bar/index.js";
|
|
5
|
-
import { GradientIcon } from "./components/particles/gradient-icon/index.js";
|
|
6
|
-
import { Waffle, WaffleType } from "./components/particles/waffle/index.js";
|
|
7
|
-
import { InfoButton } from "./components/particles/info-button/index.js";
|
|
8
|
-
import { CircleIcon } from "./components/particles/circle-icon/index.js";
|
|
9
|
-
import { RelativeTimeSentence } from "./components/particles/relative-time-sentence/index.js";
|
|
10
|
-
import { Container } from "./components/particles/container/index.js";
|
|
11
|
-
import { ChangeBar } from "./components/particles/change-bar/index.js";
|
|
12
|
-
import { SquareCutCornerIcon } from "./components/particles/square-cut-corner-icon/index.js";
|
|
13
|
-
import { StackedGrid } from "./components/particles/stacked-grid/index.js";
|
|
14
|
-
import { SquareIcon } from "./components/particles/square-icon/index.js";
|
|
15
|
-
import { ArrowButton } from "./components/particles/arrow-button/index.js";
|
|
16
|
-
import { Button } from "./components/particles/button/index.js";
|
|
17
|
-
import { CloseButton } from "./components/particles/close-button/index.js";
|
|
18
|
-
import { AdSlot } from "./components/particles/ad-slot/index.js";
|
|
19
|
-
import { AspectRatioBox } from "./components/particles/aspect-ratio-box/index.js";
|
|
20
|
-
import { Table } from "./components/molecules/table/index.js";
|
|
21
|
-
import { SlopeChart } from "./components/molecules/slope-chart/index.js";
|
|
22
|
-
import { Tooltip } from "./components/molecules/tooltip/index.js";
|
|
23
|
-
import { ControlChange } from "./components/molecules/control-change/index.js";
|
|
24
|
-
import { FirstPastThePostWaffle } from "./components/molecules/first-past-the-post-waffle/index.js";
|
|
25
|
-
import { ToplineResult } from "./components/molecules/topline-result/index.js";
|
|
26
|
-
import { PageSection, SectionLayout } from "./components/molecules/page-section/index.js";
|
|
27
|
-
import { ColumnChart } from "./components/molecules/column-chart/index.js";
|
|
28
|
-
import { PartyProfile } from "./components/molecules/party-profile/index.js";
|
|
29
|
-
import { ResultSummary } from "./components/molecules/result-summary/index.js";
|
|
30
|
-
import { SearchInput } from "./components/molecules/search-input/index.js";
|
|
31
|
-
import { RefreshIndicator } from "./components/molecules/refresh-indicator/index.js";
|
|
32
|
-
import { GridType, ResponsiveGrid } from "./components/molecules/responsive-grid/index.js";
|
|
33
|
-
import { Modal } from "./components/molecules/modal/index.js";
|
|
34
|
-
import { Dropdown } from "./components/molecules/dropdown/index.js";
|
|
35
|
-
import { MapConfiguration, SVGMap, _Projection } from "./components/molecules/svg-map/index.js";
|
|
36
|
-
import { Map } from "./components/molecules/canvas-map/Map.js";
|
|
37
|
-
import { ZoomControl } from "./components/molecules/canvas-map/controls/ZoomControl.js";
|
|
38
|
-
import { Feature } from "./components/molecules/canvas-map/lib/Feature.js";
|
|
39
|
-
import { FeatureCollection } from "./components/molecules/canvas-map/lib/FeatureCollection.js";
|
|
40
|
-
import { Dispatcher } from "./components/molecules/canvas-map/lib/events/Dispatcher.js";
|
|
41
|
-
import { MapEvent } from "./components/molecules/canvas-map/lib/events/MapEvent.js";
|
|
42
|
-
import { Projection } from "./components/molecules/canvas-map/lib/projection/index.js";
|
|
43
|
-
import { TextLayer } from "./components/molecules/canvas-map/lib/layers/TextLayer.js";
|
|
44
|
-
import { VectorLayer } from "./components/molecules/canvas-map/lib/layers/VectorLayer.js";
|
|
45
|
-
import { Style } from "./components/molecules/canvas-map/lib/styles/Style.js";
|
|
46
|
-
import { Stroke } from "./components/molecules/canvas-map/lib/styles/Stroke.js";
|
|
47
|
-
import { Fill } from "./components/molecules/canvas-map/lib/styles/Fill.js";
|
|
48
|
-
import { Text } from "./components/molecules/canvas-map/lib/styles/Text.js";
|
|
49
|
-
import { interpolateFeatures } from "./components/molecules/canvas-map/lib/interpolators/interpolateFeatures.js";
|
|
50
|
-
import { interpolateFill, interpolateStroke, interpolateStyles } from "./components/molecules/canvas-map/lib/interpolators/interpolateStyles.js";
|
|
51
|
-
import { VectorSource } from "./components/molecules/canvas-map/lib/sources/VectorSource.js";
|
|
52
|
-
import { GeoJSON } from "./components/molecules/canvas-map/lib/formats/GeoJSON.js";
|
|
53
|
-
import { bboxFeature } from "./components/molecules/canvas-map/lib/util/bboxFeature.js";
|
|
54
|
-
import { CoalitionsTracker } from "./components/organisms/coalitions-tracker/index.js";
|
|
55
|
-
import { Ticker } from "./components/organisms/ticker/index.js";
|
|
56
|
-
import { useContainerSize } from "./shared/hooks/useContainerSize.js";
|
|
57
|
-
import { useTouchOrHover } from "./shared/hooks/useTouchOrHover.js";
|
|
58
|
-
import { useWindowSize } from "./shared/hooks/useWindowSize.js";
|
|
59
|
-
import * as index from "./components/molecules/svg-map/layers/index.js";
|
|
60
|
-
export {
|
|
61
|
-
AdSlot,
|
|
62
|
-
ArrowButton,
|
|
63
|
-
AspectRatioBox,
|
|
64
|
-
Button,
|
|
65
|
-
ChangeBar,
|
|
66
|
-
Chevron,
|
|
67
|
-
CircleIcon,
|
|
68
|
-
CloseButton,
|
|
69
|
-
CoalitionsTracker,
|
|
70
|
-
ColumnChart,
|
|
71
|
-
Container,
|
|
72
|
-
ControlChange,
|
|
73
|
-
Dispatcher,
|
|
74
|
-
Dropdown,
|
|
75
|
-
Feature,
|
|
76
|
-
FeatureCollection,
|
|
77
|
-
Fill,
|
|
78
|
-
FirstPastThePostWaffle,
|
|
79
|
-
GeoJSON,
|
|
80
|
-
GradientIcon,
|
|
81
|
-
GridType,
|
|
82
|
-
InfoButton,
|
|
83
|
-
LabelOverlapConfig,
|
|
84
|
-
LabelType,
|
|
85
|
-
LegendItem,
|
|
86
|
-
Map,
|
|
87
|
-
MapConfiguration,
|
|
88
|
-
MapEvent,
|
|
89
|
-
index as MapLayers,
|
|
90
|
-
Modal,
|
|
91
|
-
PageSection,
|
|
92
|
-
PartyProfile,
|
|
93
|
-
Projection,
|
|
94
|
-
RefreshIndicator,
|
|
95
|
-
RelativeTimeSentence,
|
|
96
|
-
ResponsiveGrid,
|
|
97
|
-
ResultSummary,
|
|
98
|
-
SVGMap,
|
|
99
|
-
SearchInput,
|
|
100
|
-
SectionLayout,
|
|
101
|
-
SlopeChart,
|
|
102
|
-
SquareCutCornerIcon,
|
|
103
|
-
SquareIcon,
|
|
104
|
-
StackedBar,
|
|
105
|
-
StackedGrid,
|
|
106
|
-
Stroke,
|
|
107
|
-
Style,
|
|
108
|
-
Table,
|
|
109
|
-
Text,
|
|
110
|
-
TextLayer,
|
|
111
|
-
Ticker,
|
|
112
|
-
Tooltip,
|
|
113
|
-
ToplineResult,
|
|
114
|
-
VectorLayer,
|
|
115
|
-
VectorSource,
|
|
116
|
-
Waffle,
|
|
117
|
-
WaffleType,
|
|
118
|
-
ZoomControl,
|
|
119
|
-
_Projection,
|
|
120
|
-
bboxFeature,
|
|
121
|
-
interpolateFeatures,
|
|
122
|
-
interpolateFill,
|
|
123
|
-
interpolateStroke,
|
|
124
|
-
interpolateStyles,
|
|
125
|
-
useContainerSize,
|
|
126
|
-
useTouchOrHover,
|
|
127
|
-
useWindowSize
|
|
128
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function createStore(initialStore: any): ((selectorFn?: (store: any) => any) => any)[];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
function rectsIntersect(rect1, rect2) {
|
|
2
|
-
if (rect1.width === 0 || rect1.height === 0 || rect2.width === 0 || rect2.height === 0) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
if (rect1.x + rect1.width <= rect2.x || rect2.x + rect2.width <= rect1.x || rect1.y + rect1.height <= rect2.y || rect2.y + rect2.height <= rect1.y) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
function pointInsideRect(point, rect) {
|
|
11
|
-
return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
pointInsideRect,
|
|
15
|
-
rectsIntersect
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template {Record<string, unknown>} T
|
|
3
|
-
* @param {T[]} labelPositions
|
|
4
|
-
* @param {number} iteration
|
|
5
|
-
* @param {number} labelSize
|
|
6
|
-
* @param {string} coordinate
|
|
7
|
-
* @param {boolean} moveBothLabels
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export function preventOverlap<T extends Record<string, unknown>>(labelPositions: T[], iteration?: number, labelSize?: number, coordinate?: string, moveBothLabels?: boolean): T[];
|
|
11
|
-
/**
|
|
12
|
-
* Unique objects for a given key’s value;
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```
|
|
16
|
-
* const labels = [
|
|
17
|
-
* {key: 'alpha', value: 1 },
|
|
18
|
-
* {key: 'alpha', value: 9 },
|
|
19
|
-
* {key: 'delta', value: 4 },
|
|
20
|
-
*];
|
|
21
|
-
* console.log(uniqueBy(labels, 'key'));
|
|
22
|
-
* // [
|
|
23
|
-
* // {key: 'alpha', value: 1 },
|
|
24
|
-
* // {key: 'delta', value: 4 },
|
|
25
|
-
* // ]
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @template T extends Record<string, unknown>
|
|
29
|
-
* @param {T[]} array
|
|
30
|
-
* @param {keyof T} key
|
|
31
|
-
* @returns {T[]}
|
|
32
|
-
*/
|
|
33
|
-
export function uniqueBy<T>(array: T[], key: keyof T): T[];
|
|
34
|
-
/**
|
|
35
|
-
* @template {{ value: string }} T
|
|
36
|
-
* @param {T[]} labels
|
|
37
|
-
* @param {number} labelSize
|
|
38
|
-
* @param {string} coordinate
|
|
39
|
-
* @param {boolean} moveBothLabels
|
|
40
|
-
* @returns {T[]}
|
|
41
|
-
*/
|
|
42
|
-
export function positionLabels<T extends {
|
|
43
|
-
value: string;
|
|
44
|
-
}>(labels: T[], labelSize?: number, coordinate?: string, moveBothLabels?: boolean): T[];
|
|
45
|
-
/**
|
|
46
|
-
* Create a function that maps a value from a source domain to a target range.
|
|
47
|
-
*
|
|
48
|
-
* same as this one https://gist.github.com/vectorsize/7031902
|
|
49
|
-
*
|
|
50
|
-
* @param {[number, number]} domain
|
|
51
|
-
* @param {[number, number]} range
|
|
52
|
-
* @returns {(x: number) => number}
|
|
53
|
-
*/
|
|
54
|
-
export function scaleLinear(domain: [number, number], range: [number, number]): (x: number) => number;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
function preventOverlap(labelPositions, iteration = 0, labelSize = 12, coordinate = "y", moveBothLabels = true) {
|
|
2
|
-
const maxIterations = 10;
|
|
3
|
-
let totalOverlap = 0;
|
|
4
|
-
if (!isArrayWithCoordinates(labelPositions, coordinate)) return labelPositions;
|
|
5
|
-
for (let index = 1; index < labelPositions.length; index++) {
|
|
6
|
-
const previousElement = labelPositions[index - 1];
|
|
7
|
-
const element = labelPositions[index];
|
|
8
|
-
const overlap = previousElement[coordinate] - (element[coordinate] - labelSize);
|
|
9
|
-
if (overlap < 0) {
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
if (moveBothLabels) {
|
|
13
|
-
previousElement[coordinate] -= overlap / 2;
|
|
14
|
-
element[coordinate] += overlap / 2;
|
|
15
|
-
} else {
|
|
16
|
-
previousElement[coordinate] -= overlap;
|
|
17
|
-
}
|
|
18
|
-
totalOverlap += overlap;
|
|
19
|
-
}
|
|
20
|
-
if (totalOverlap > 0 && iteration < maxIterations) {
|
|
21
|
-
return preventOverlap(
|
|
22
|
-
labelPositions,
|
|
23
|
-
iteration + 1,
|
|
24
|
-
labelSize,
|
|
25
|
-
coordinate,
|
|
26
|
-
moveBothLabels
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
return labelPositions;
|
|
30
|
-
}
|
|
31
|
-
function uniqueBy(array, key) {
|
|
32
|
-
return [...array.reduce((map, d) => map.set(d[key], d), /* @__PURE__ */ new Map()).values()];
|
|
33
|
-
}
|
|
34
|
-
function positionLabels(labels, labelSize = 12, coordinate = "y", moveBothLabels = true) {
|
|
35
|
-
labels = uniqueBy(labels, "value");
|
|
36
|
-
labels.sort((a, b) => a[coordinate] - b[coordinate]);
|
|
37
|
-
return preventOverlap(labels, 0, labelSize, coordinate, moveBothLabels);
|
|
38
|
-
}
|
|
39
|
-
function scaleLinear(domain, range) {
|
|
40
|
-
const [domainMin, domainMax] = domain;
|
|
41
|
-
const [rangeMin, rangeMax] = range;
|
|
42
|
-
const slope = (rangeMax - rangeMin) / (domainMax - domainMin);
|
|
43
|
-
const intercept = rangeMin - slope * domainMin;
|
|
44
|
-
return function(x) {
|
|
45
|
-
return slope * x + intercept;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function isArrayWithCoordinates(labelPositions, coordinate) {
|
|
49
|
-
return labelPositions.every(
|
|
50
|
-
(position) => typeof position[coordinate] === "number"
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
positionLabels,
|
|
55
|
-
preventOverlap,
|
|
56
|
-
scaleLinear,
|
|
57
|
-
uniqueBy
|
|
58
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function useContainerSize(containerRef: any): undefined;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useState, useLayoutEffect } from "preact/hooks";
|
|
2
|
-
function useContainerSize(containerRef) {
|
|
3
|
-
const [containerSize, setContainerSize] = useState();
|
|
4
|
-
useLayoutEffect(() => {
|
|
5
|
-
const container = containerRef.current;
|
|
6
|
-
if (!container) return;
|
|
7
|
-
const observer = new ResizeObserver((entries) => {
|
|
8
|
-
for (let entry of entries) {
|
|
9
|
-
setContainerSize({
|
|
10
|
-
width: entry.contentRect.width,
|
|
11
|
-
height: entry.contentRect.height
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
observer.observe(container);
|
|
16
|
-
return () => {
|
|
17
|
-
observer.disconnect();
|
|
18
|
-
};
|
|
19
|
-
}, [containerRef]);
|
|
20
|
-
return containerSize;
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
useContainerSize
|
|
24
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { useRef, useState, useEffect } from "preact/hooks";
|
|
2
|
-
import { pointInsideRect } from "../helpers/geometry.js";
|
|
3
|
-
function useTouchOrHover() {
|
|
4
|
-
const ref = useRef();
|
|
5
|
-
const [position, setPosition] = useState();
|
|
6
|
-
const [isActive, setIsActive] = useState(false);
|
|
7
|
-
const [touchRect, setTouchRect] = useState();
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const element = ref.current;
|
|
10
|
-
let touchCancelled = false;
|
|
11
|
-
const touchStarted = (event) => {
|
|
12
|
-
if (event.touches.length > 1) return;
|
|
13
|
-
touchCancelled = false;
|
|
14
|
-
const touch = event.touches[0];
|
|
15
|
-
const { clientX, clientY } = touch;
|
|
16
|
-
const rect = element.getBoundingClientRect();
|
|
17
|
-
const point = { x: clientX - rect.left, y: clientY - rect.top };
|
|
18
|
-
setPosition(point);
|
|
19
|
-
const touchRect2 = {
|
|
20
|
-
x: clientX - touch.radiusX,
|
|
21
|
-
y: clientY - touch.radiusY,
|
|
22
|
-
width: touch.radiusX * 2,
|
|
23
|
-
height: touch.radiusY * 2
|
|
24
|
-
};
|
|
25
|
-
setTouchRect(touchRect2);
|
|
26
|
-
setIsActive(true);
|
|
27
|
-
event.stopPropagation();
|
|
28
|
-
};
|
|
29
|
-
const touchMoved = (event) => {
|
|
30
|
-
if (touchCancelled || event.targetTouches.length !== 1) return;
|
|
31
|
-
const touch = event.targetTouches[0];
|
|
32
|
-
const { clientX, clientY } = touch;
|
|
33
|
-
const rect = element.getBoundingClientRect();
|
|
34
|
-
const point = { x: clientX - rect.left, y: clientY - rect.top };
|
|
35
|
-
if (!event.cancelable || !pointInsideRect(point, rect)) {
|
|
36
|
-
setIsActive(false);
|
|
37
|
-
touchCancelled = true;
|
|
38
|
-
} else {
|
|
39
|
-
setPosition(point);
|
|
40
|
-
setIsActive(true);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const touchEnded = (event) => {
|
|
44
|
-
if (event.cancelable) {
|
|
45
|
-
event.preventDefault();
|
|
46
|
-
}
|
|
47
|
-
setIsActive(false);
|
|
48
|
-
setPosition(null);
|
|
49
|
-
};
|
|
50
|
-
const mouseOver = (event) => {
|
|
51
|
-
const { clientX, clientY } = event;
|
|
52
|
-
const rect = element.getBoundingClientRect();
|
|
53
|
-
const x = clientX - rect.left;
|
|
54
|
-
const y = clientY - rect.top;
|
|
55
|
-
setPosition({ x, y });
|
|
56
|
-
setIsActive(true);
|
|
57
|
-
};
|
|
58
|
-
const mouseMoved = (event) => {
|
|
59
|
-
const { clientX, clientY } = event;
|
|
60
|
-
const rect = element.getBoundingClientRect();
|
|
61
|
-
const x = clientX - rect.left;
|
|
62
|
-
const y = clientY - rect.top;
|
|
63
|
-
setPosition({ x, y });
|
|
64
|
-
};
|
|
65
|
-
const mouseOut = () => {
|
|
66
|
-
setIsActive(false);
|
|
67
|
-
setPosition(null);
|
|
68
|
-
};
|
|
69
|
-
element.addEventListener("touchstart", touchStarted);
|
|
70
|
-
element.addEventListener("touchmove", touchMoved);
|
|
71
|
-
element.addEventListener("touchend", touchEnded);
|
|
72
|
-
element.addEventListener("touchcancel", touchEnded);
|
|
73
|
-
element.addEventListener("mouseover", mouseOver);
|
|
74
|
-
element.addEventListener("mousemove", mouseMoved);
|
|
75
|
-
element.addEventListener("mouseout", mouseOut);
|
|
76
|
-
return () => {
|
|
77
|
-
element.removeEventListener("touchstart", touchStarted);
|
|
78
|
-
element.removeEventListener("touchmove", touchMoved);
|
|
79
|
-
element.removeEventListener("touchend", mouseOut);
|
|
80
|
-
element.removeEventListener("touchcancel", mouseOut);
|
|
81
|
-
element.removeEventListener("mouseover", touchStarted);
|
|
82
|
-
element.removeEventListener("mousemove", mouseMoved);
|
|
83
|
-
element.removeEventListener("mouseout", mouseOut);
|
|
84
|
-
};
|
|
85
|
-
}, []);
|
|
86
|
-
return {
|
|
87
|
-
touchOrHoverRef: ref,
|
|
88
|
-
touchOrHoverIsActive: isActive,
|
|
89
|
-
touchRect,
|
|
90
|
-
positionInTarget: position
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
export {
|
|
94
|
-
useTouchOrHover
|
|
95
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useState, useLayoutEffect } from "preact/hooks";
|
|
2
|
-
function useWindowSize() {
|
|
3
|
-
const [windowSize, setWindowSize] = useState(() => {
|
|
4
|
-
if (typeof window === "undefined") return { width: 0, height: 0 };
|
|
5
|
-
return {
|
|
6
|
-
width: window.innerWidth,
|
|
7
|
-
height: window.innerHeight
|
|
8
|
-
};
|
|
9
|
-
});
|
|
10
|
-
useLayoutEffect(() => {
|
|
11
|
-
if (typeof window === "undefined") return;
|
|
12
|
-
function handleResize() {
|
|
13
|
-
setWindowSize({
|
|
14
|
-
width: window.innerWidth,
|
|
15
|
-
height: window.innerHeight
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
window.addEventListener("resize", handleResize);
|
|
19
|
-
return () => {
|
|
20
|
-
window.removeEventListener("resize", handleResize);
|
|
21
|
-
};
|
|
22
|
-
}, []);
|
|
23
|
-
return windowSize;
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
useWindowSize
|
|
27
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function mergeStyles(firstStyle: any, secondStyle: any): any;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
function mergeStyles(firstStyle, secondStyle) {
|
|
2
|
-
if (!firstStyle) return secondStyle;
|
|
3
|
-
if (!secondStyle) return firstStyle;
|
|
4
|
-
if (typeof firstStyle === "string") {
|
|
5
|
-
if (typeof secondStyle !== "string") {
|
|
6
|
-
throw new Error("Styles to merge must be of the same type");
|
|
7
|
-
}
|
|
8
|
-
return firstStyle.concat(" ", secondStyle);
|
|
9
|
-
}
|
|
10
|
-
const allKeys = /* @__PURE__ */ new Set([
|
|
11
|
-
...Object.keys(firstStyle),
|
|
12
|
-
...Object.keys(secondStyle)
|
|
13
|
-
]);
|
|
14
|
-
const merged = Array.from(allKeys).reduce((result, key) => {
|
|
15
|
-
result[key] = mergeStyles(firstStyle[key], secondStyle[key]);
|
|
16
|
-
return result;
|
|
17
|
-
}, {});
|
|
18
|
-
return merged;
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
mergeStyles
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|