@lobehub/charts 1.0.0 → 1.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/README.md +1 -0
- package/es/AreaChart/index.js +9 -5
- package/es/BarChart/index.js +5 -1
- package/es/BarList/index.d.ts +24 -0
- package/es/BarList/index.js +149 -0
- package/es/BarList/styles.d.ts +10 -0
- package/es/BarList/styles.js +17 -0
- package/es/DonutChart/index.d.ts +2 -1
- package/es/DonutChart/index.js +7 -3
- package/es/Heatmaps/Calendar.d.ts +18 -0
- package/es/Heatmaps/Calendar.js +67 -0
- package/es/Heatmaps/ChartLabels.d.ts +15 -0
- package/es/Heatmaps/ChartLabels.js +50 -0
- package/es/Heatmaps/Footer.d.ts +22 -0
- package/es/Heatmaps/Footer.js +60 -0
- package/es/Heatmaps/index.d.ts +28 -0
- package/es/Heatmaps/index.js +181 -0
- package/es/Heatmaps/styles.d.ts +7 -0
- package/es/Heatmaps/styles.js +14 -0
- package/es/LineChart/index.js +10 -6
- package/es/ScatterChart/index.js +10 -6
- package/es/SparkChart/SparkAreaChart.d.ts +11 -0
- package/es/SparkChart/SparkAreaChart.js +140 -0
- package/es/SparkChart/SparkBarChart.d.ts +8 -0
- package/es/SparkChart/SparkBarChart.js +98 -0
- package/es/SparkChart/SparkLineChart.d.ts +9 -0
- package/es/SparkChart/SparkLineChart.js +102 -0
- package/es/SparkChart/index.d.ts +3 -0
- package/es/SparkChart/index.js +3 -0
- package/es/Tracker/TrackerBlock.d.ts +8 -0
- package/es/Tracker/TrackerBlock.js +62 -0
- package/es/Tracker/index.d.ts +18 -0
- package/es/Tracker/index.js +98 -0
- package/es/Tracker/styles.d.ts +5 -0
- package/es/Tracker/styles.js +12 -0
- package/es/common/BaseSparkChartProps.d.ts +13 -0
- package/es/common/BaseSparkChartProps.js +1 -0
- package/es/common/utils.d.ts +2 -2
- package/es/common/utils.js +4 -4
- package/es/hooks/useOnWindowResize.js +2 -1
- package/es/hooks/usePrefersReducedMotion.d.ts +1 -0
- package/es/hooks/usePrefersReducedMotion.js +23 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +5 -1
- package/es/types.d.ts +25 -0
- package/es/utils/calendar.d.ts +29 -0
- package/es/utils/calendar.js +194 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/theme.d.ts +2 -0
- package/es/utils/theme.js +49 -0
- package/package.json +7 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
+
var _templateObject;
|
|
7
|
+
var _excluded = ["data", "categories", "index", "colors", "animationDuration", "showAnimation", "curveType", "connectNulls", "noDataText", "autoMinValue", "minValue", "maxValue", "className", "width", "height", "style"];
|
|
8
|
+
import { css } from 'antd-style';
|
|
9
|
+
import { forwardRef } from 'react';
|
|
10
|
+
import { Flexbox } from 'react-layout-kit';
|
|
11
|
+
import { Line, LineChart as ReChartsLineChart, ResponsiveContainer, XAxis, YAxis } from 'recharts';
|
|
12
|
+
import { useStyles } from "../LineChart/styles";
|
|
13
|
+
import NoData from "../common/NoData";
|
|
14
|
+
import { constructCategoryColors, getYAxisDomain } from "../common/utils";
|
|
15
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
var SparkLineChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
19
|
+
var _useStyles = useStyles(),
|
|
20
|
+
cx = _useStyles.cx,
|
|
21
|
+
theme = _useStyles.theme;
|
|
22
|
+
var themeColorRange = useThemeColorRange();
|
|
23
|
+
var _props$data = props.data,
|
|
24
|
+
data = _props$data === void 0 ? [] : _props$data,
|
|
25
|
+
_props$categories = props.categories,
|
|
26
|
+
categories = _props$categories === void 0 ? [] : _props$categories,
|
|
27
|
+
index = props.index,
|
|
28
|
+
_props$colors = props.colors,
|
|
29
|
+
colors = _props$colors === void 0 ? themeColorRange : _props$colors,
|
|
30
|
+
_props$animationDurat = props.animationDuration,
|
|
31
|
+
animationDuration = _props$animationDurat === void 0 ? 900 : _props$animationDurat,
|
|
32
|
+
_props$showAnimation = props.showAnimation,
|
|
33
|
+
showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
|
|
34
|
+
_props$curveType = props.curveType,
|
|
35
|
+
curveType = _props$curveType === void 0 ? 'linear' : _props$curveType,
|
|
36
|
+
_props$connectNulls = props.connectNulls,
|
|
37
|
+
connectNulls = _props$connectNulls === void 0 ? false : _props$connectNulls,
|
|
38
|
+
_props$noDataText = props.noDataText,
|
|
39
|
+
noDataText = _props$noDataText === void 0 ? /*#__PURE__*/_jsx("div", {}) : _props$noDataText,
|
|
40
|
+
_props$autoMinValue = props.autoMinValue,
|
|
41
|
+
autoMinValue = _props$autoMinValue === void 0 ? false : _props$autoMinValue,
|
|
42
|
+
minValue = props.minValue,
|
|
43
|
+
maxValue = props.maxValue,
|
|
44
|
+
className = props.className,
|
|
45
|
+
_props$width = props.width,
|
|
46
|
+
width = _props$width === void 0 ? 112 : _props$width,
|
|
47
|
+
_props$height = props.height,
|
|
48
|
+
height = _props$height === void 0 ? 48 : _props$height,
|
|
49
|
+
style = props.style,
|
|
50
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
51
|
+
var categoryColors = constructCategoryColors(categories, colors);
|
|
52
|
+
var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
|
|
53
|
+
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
54
|
+
className: className,
|
|
55
|
+
height: height,
|
|
56
|
+
ref: ref,
|
|
57
|
+
style: _objectSpread({
|
|
58
|
+
position: 'relative'
|
|
59
|
+
}, style),
|
|
60
|
+
width: width
|
|
61
|
+
}, rest), {}, {
|
|
62
|
+
children: /*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
63
|
+
children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsLineChart, {
|
|
64
|
+
data: data,
|
|
65
|
+
margin: {
|
|
66
|
+
bottom: 1,
|
|
67
|
+
left: 1,
|
|
68
|
+
right: 1,
|
|
69
|
+
top: 1
|
|
70
|
+
},
|
|
71
|
+
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
72
|
+
domain: yAxisDomain,
|
|
73
|
+
hide: true
|
|
74
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
75
|
+
dataKey: index,
|
|
76
|
+
hide: true
|
|
77
|
+
}), categories.map(function (category) {
|
|
78
|
+
var _categoryColors$get;
|
|
79
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
80
|
+
animationDuration: animationDuration,
|
|
81
|
+
className: cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n stroke: ", ";\n "])), (_categoryColors$get = categoryColors.get(category)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary)),
|
|
82
|
+
connectNulls: connectNulls,
|
|
83
|
+
dataKey: category,
|
|
84
|
+
dot: false,
|
|
85
|
+
isAnimationActive: showAnimation,
|
|
86
|
+
name: category,
|
|
87
|
+
stroke: "",
|
|
88
|
+
strokeLinecap: "round",
|
|
89
|
+
strokeLinejoin: "round",
|
|
90
|
+
strokeOpacity: 1,
|
|
91
|
+
strokeWidth: 2,
|
|
92
|
+
type: curveType
|
|
93
|
+
}, category);
|
|
94
|
+
})]
|
|
95
|
+
}) : /*#__PURE__*/_jsx(NoData, {
|
|
96
|
+
noDataText: noDataText
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
SparkLineChart.displayName = 'SparkLineChart';
|
|
102
|
+
export default SparkLineChart;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface TrackerBlockProps {
|
|
3
|
+
color?: 'success' | 'warning' | 'error' | string;
|
|
4
|
+
key?: string | number;
|
|
5
|
+
tooltip?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const TrackerBlock: import("react").ForwardRefExoticComponent<TrackerBlockProps & import("react-layout-kit/lib/FlexBasic").FlexBasicProps & import("react-layout-kit").CommonProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export default TrackerBlock;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
6
|
+
var _excluded = ["color", "tooltip", "width", "style"];
|
|
7
|
+
var _templateObject;
|
|
8
|
+
import { Tooltip } from '@lobehub/ui';
|
|
9
|
+
import { createStyles } from 'antd-style';
|
|
10
|
+
import { forwardRef, useMemo } from 'react';
|
|
11
|
+
import { Flexbox } from 'react-layout-kit';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
var useStyles = createStyles(function (_ref) {
|
|
14
|
+
var css = _ref.css,
|
|
15
|
+
token = _ref.token;
|
|
16
|
+
return {
|
|
17
|
+
block: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n\n &:hover {\n opacity: 0.5;\n }\n "])), token.colorFill, token.borderRadiusSM, token.borderRadiusSM, token.borderRadiusSM, token.borderRadiusSM)
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
var TrackerBlock = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
21
|
+
var color = _ref2.color,
|
|
22
|
+
tooltip = _ref2.tooltip,
|
|
23
|
+
width = _ref2.width,
|
|
24
|
+
style = _ref2.style,
|
|
25
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
26
|
+
var _useStyles = useStyles(),
|
|
27
|
+
styles = _useStyles.styles,
|
|
28
|
+
theme = _useStyles.theme;
|
|
29
|
+
var blockColor = useMemo(function () {
|
|
30
|
+
switch (color) {
|
|
31
|
+
case 'success':
|
|
32
|
+
{
|
|
33
|
+
return theme.colorSuccess;
|
|
34
|
+
}
|
|
35
|
+
case 'warning':
|
|
36
|
+
{
|
|
37
|
+
return theme.colorWarning;
|
|
38
|
+
}
|
|
39
|
+
case 'error':
|
|
40
|
+
{
|
|
41
|
+
return theme.colorError;
|
|
42
|
+
}
|
|
43
|
+
default:
|
|
44
|
+
{
|
|
45
|
+
return color;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [color]);
|
|
49
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
50
|
+
title: tooltip,
|
|
51
|
+
children: /*#__PURE__*/_jsx(Flexbox, _objectSpread({
|
|
52
|
+
className: styles.block,
|
|
53
|
+
height: '100%',
|
|
54
|
+
ref: ref,
|
|
55
|
+
style: _objectSpread({
|
|
56
|
+
background: blockColor
|
|
57
|
+
}, style),
|
|
58
|
+
width: width || '100%'
|
|
59
|
+
}, rest))
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
export default TrackerBlock;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FlexboxProps } from 'react-layout-kit';
|
|
3
|
+
import { TrackerBlockProps } from './TrackerBlock';
|
|
4
|
+
interface DataItem extends TrackerBlockProps {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export interface TrackerProps extends FlexboxProps {
|
|
8
|
+
blockGap?: number | string;
|
|
9
|
+
blockHeight?: number | string;
|
|
10
|
+
blockWidth?: number | string;
|
|
11
|
+
customTooltip?: (payload: DataItem) => ReactNode;
|
|
12
|
+
data: DataItem[];
|
|
13
|
+
leftLabel?: ReactNode;
|
|
14
|
+
onValueChange?: (payload: DataItem) => void;
|
|
15
|
+
rightLabel?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
declare const Tracker: import("react").ForwardRefExoticComponent<TrackerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export default Tracker;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["data", "className", "height", "width", "blockWidth", "blockHeight", "blockGap", "customTooltip", "onValueChange", "leftLabel", "rightLabel", "style"];
|
|
6
|
+
import { forwardRef } from 'react';
|
|
7
|
+
import { Flexbox } from 'react-layout-kit';
|
|
8
|
+
import TrackerBlock from "./TrackerBlock";
|
|
9
|
+
import { useStyles } from "./styles";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
var Tracker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
13
|
+
var _props$data = props.data,
|
|
14
|
+
data = _props$data === void 0 ? [] : _props$data,
|
|
15
|
+
className = props.className,
|
|
16
|
+
height = props.height,
|
|
17
|
+
_props$width = props.width,
|
|
18
|
+
width = _props$width === void 0 ? 'fit-content' : _props$width,
|
|
19
|
+
_props$blockWidth = props.blockWidth,
|
|
20
|
+
blockWidth = _props$blockWidth === void 0 ? 12 : _props$blockWidth,
|
|
21
|
+
_props$blockHeight = props.blockHeight,
|
|
22
|
+
blockHeight = _props$blockHeight === void 0 ? 40 : _props$blockHeight,
|
|
23
|
+
_props$blockGap = props.blockGap,
|
|
24
|
+
blockGap = _props$blockGap === void 0 ? 4 : _props$blockGap,
|
|
25
|
+
customTooltip = props.customTooltip,
|
|
26
|
+
onValueChange = props.onValueChange,
|
|
27
|
+
leftLabel = props.leftLabel,
|
|
28
|
+
rightLabel = props.rightLabel,
|
|
29
|
+
style = props.style,
|
|
30
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
31
|
+
var _useStyles = useStyles(),
|
|
32
|
+
styles = _useStyles.styles,
|
|
33
|
+
cx = _useStyles.cx;
|
|
34
|
+
var content = data.map(function (item, idx) {
|
|
35
|
+
var _item$key;
|
|
36
|
+
return /*#__PURE__*/_jsx(TrackerBlock, {
|
|
37
|
+
color: item.color,
|
|
38
|
+
height: blockHeight,
|
|
39
|
+
onClick: function onClick() {
|
|
40
|
+
return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(item);
|
|
41
|
+
},
|
|
42
|
+
style: {
|
|
43
|
+
cursor: onValueChange ? 'pointer' : 'default'
|
|
44
|
+
},
|
|
45
|
+
tooltip: customTooltip ? customTooltip(item) : item.tooltip,
|
|
46
|
+
width: blockWidth
|
|
47
|
+
}, (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : idx);
|
|
48
|
+
});
|
|
49
|
+
if (leftLabel || rightLabel) {
|
|
50
|
+
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
51
|
+
className: className,
|
|
52
|
+
gap: 8,
|
|
53
|
+
height: height,
|
|
54
|
+
ref: ref,
|
|
55
|
+
style: _objectSpread({
|
|
56
|
+
position: 'relative'
|
|
57
|
+
}, style),
|
|
58
|
+
width: width
|
|
59
|
+
}, rest), {}, {
|
|
60
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
61
|
+
align: 'center',
|
|
62
|
+
horizontal: true,
|
|
63
|
+
justify: 'space-between',
|
|
64
|
+
width: '100%',
|
|
65
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
66
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
67
|
+
children: leftLabel
|
|
68
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
69
|
+
className: cx(styles.label, styles.emphasis),
|
|
70
|
+
style: {
|
|
71
|
+
textAlign: 'right'
|
|
72
|
+
},
|
|
73
|
+
children: rightLabel
|
|
74
|
+
})]
|
|
75
|
+
}), /*#__PURE__*/_jsx(Flexbox, {
|
|
76
|
+
align: 'center',
|
|
77
|
+
gap: blockGap,
|
|
78
|
+
height: blockHeight,
|
|
79
|
+
horizontal: true,
|
|
80
|
+
width: '100%',
|
|
81
|
+
children: content
|
|
82
|
+
})]
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
86
|
+
align: 'center',
|
|
87
|
+
className: className,
|
|
88
|
+
gap: blockGap,
|
|
89
|
+
height: height || blockHeight,
|
|
90
|
+
horizontal: true,
|
|
91
|
+
ref: ref,
|
|
92
|
+
width: width
|
|
93
|
+
}, rest), {}, {
|
|
94
|
+
children: content
|
|
95
|
+
}));
|
|
96
|
+
});
|
|
97
|
+
Tracker.displayName = 'Tracker';
|
|
98
|
+
export default Tracker;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token;
|
|
7
|
+
return {
|
|
8
|
+
emphasis: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n "]))),
|
|
9
|
+
label: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 16px;\n color: ", ";\n "])), token.colorTextDescription),
|
|
10
|
+
strongLabel: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 14px;\n font-weight: 500;\n line-height: 16px;\n fill: ", ";\n "])), token.colorTextSecondary)
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import BaseAnimationTimingProps from './BaseAnimationTimingProps';
|
|
3
|
+
interface BaseSparkChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
autoMinValue?: boolean;
|
|
5
|
+
categories: string[];
|
|
6
|
+
colors?: string[];
|
|
7
|
+
data: any[];
|
|
8
|
+
index: string;
|
|
9
|
+
maxValue?: number;
|
|
10
|
+
minValue?: number;
|
|
11
|
+
noDataText?: string;
|
|
12
|
+
}
|
|
13
|
+
export default BaseSparkChartProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/common/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const constructCategoryColors: (categories: string[], colors: string[]) => Map<string, string>;
|
|
2
2
|
export declare const getYAxisDomain: (autoMinValue: boolean, minValue: number | undefined, maxValue: number | undefined) => (string | number)[];
|
|
3
3
|
export declare const constructCategories: (data: any[], color?: string) => string[];
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
4
|
+
export declare const deepEqual: (obj1: any, obj2: any) => boolean;
|
|
5
|
+
export declare const hasOnlyOneValueForThisKey: (array: any[], keyToCheck: string) => boolean;
|
package/es/common/utils.js
CHANGED
|
@@ -42,7 +42,7 @@ export var constructCategories = function constructCategories(data, color) {
|
|
|
42
42
|
}
|
|
43
43
|
return _toConsumableArray(categories);
|
|
44
44
|
};
|
|
45
|
-
export function deepEqual(obj1, obj2) {
|
|
45
|
+
export var deepEqual = function deepEqual(obj1, obj2) {
|
|
46
46
|
if (obj1 === obj2) return true;
|
|
47
47
|
if (_typeof(obj1) !== 'object' || _typeof(obj2) !== 'object' || obj1 === null || obj2 === null) return false;
|
|
48
48
|
var keys1 = Object.keys(obj1);
|
|
@@ -53,8 +53,8 @@ export function deepEqual(obj1, obj2) {
|
|
|
53
53
|
if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) return false;
|
|
54
54
|
}
|
|
55
55
|
return true;
|
|
56
|
-
}
|
|
57
|
-
export function hasOnlyOneValueForThisKey(array, keyToCheck) {
|
|
56
|
+
};
|
|
57
|
+
export var hasOnlyOneValueForThisKey = function hasOnlyOneValueForThisKey(array, keyToCheck) {
|
|
58
58
|
var val = [];
|
|
59
59
|
var _iterator3 = _createForOfIteratorHelper(array),
|
|
60
60
|
_step3;
|
|
@@ -74,4 +74,4 @@ export function hasOnlyOneValueForThisKey(array, keyToCheck) {
|
|
|
74
74
|
_iterator3.f();
|
|
75
75
|
}
|
|
76
76
|
return true;
|
|
77
|
-
}
|
|
77
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { isOnSeverSide } from "../utils";
|
|
2
3
|
export var useOnWindowResize = function useOnWindowResize(handler) {
|
|
3
4
|
useEffect(function () {
|
|
4
|
-
if (
|
|
5
|
+
if (isOnSeverSide) return;
|
|
5
6
|
var handleResize = function handleResize() {
|
|
6
7
|
handler();
|
|
7
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usePrefersReducedMotion: () => boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { isOnSeverSide } from "../utils";
|
|
4
|
+
var query = '(prefers-reduced-motion: reduce)';
|
|
5
|
+
export var usePrefersReducedMotion = function usePrefersReducedMotion() {
|
|
6
|
+
var _useState = useState(true),
|
|
7
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
8
|
+
prefersReducedMotion = _useState2[0],
|
|
9
|
+
setPrefersReducedMotion = _useState2[1];
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
if (isOnSeverSide) return;
|
|
12
|
+
var mediaQuery = window.matchMedia(query);
|
|
13
|
+
setPrefersReducedMotion(mediaQuery.matches);
|
|
14
|
+
var onChange = function onChange(event) {
|
|
15
|
+
setPrefersReducedMotion(event.matches);
|
|
16
|
+
};
|
|
17
|
+
mediaQuery.addEventListener('change', onChange);
|
|
18
|
+
return function () {
|
|
19
|
+
mediaQuery.removeEventListener('change', onChange);
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
return prefersReducedMotion;
|
|
23
|
+
};
|
package/es/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { default as AreaChart, type AreaChartProps } from './AreaChart';
|
|
2
2
|
export { default as BarChart, type BarChartProps } from './BarChart';
|
|
3
|
+
export { type Bar, default as BarList, type BarListProps } from './BarList';
|
|
3
4
|
export { default as ChartTooltipFrame } from './common/ChartTooltip/ChartTooltipFrame';
|
|
4
5
|
export { default as Legend, type LegendProps } from './components/Legend';
|
|
5
6
|
export { default as DonutChart, type DonutChartProps } from './DonutChart';
|
|
7
|
+
export { default as Heatmaps, type HeatmapsProps } from './Heatmaps';
|
|
6
8
|
export { default as LineChart, type LineChartProps } from './LineChart';
|
|
7
9
|
export { default as ScatterChart, type ScatterChartProps } from './ScatterChart';
|
|
10
|
+
export * from './SparkChart';
|
|
11
|
+
export { default as Tracker, type TrackerProps } from './Tracker';
|
|
8
12
|
export type * from './types';
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { default as AreaChart } from "./AreaChart";
|
|
2
2
|
export { default as BarChart } from "./BarChart";
|
|
3
|
+
export { default as BarList } from "./BarList";
|
|
3
4
|
export { default as ChartTooltipFrame } from "./common/ChartTooltip/ChartTooltipFrame";
|
|
4
5
|
export { default as Legend } from "./components/Legend";
|
|
5
6
|
export { default as DonutChart } from "./DonutChart";
|
|
7
|
+
export { default as Heatmaps } from "./Heatmaps";
|
|
6
8
|
export { default as LineChart } from "./LineChart";
|
|
7
|
-
export { default as ScatterChart } from "./ScatterChart";
|
|
9
|
+
export { default as ScatterChart } from "./ScatterChart";
|
|
10
|
+
export * from "./SparkChart";
|
|
11
|
+
export { default as Tracker } from "./Tracker";
|
package/es/types.d.ts
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
import type { AnimationEvent, ClipboardEvent, CompositionEvent, DOMAttributes, DragEvent, FocusEvent, FormEvent, HTMLAttributes, JSXElementConstructor, KeyboardEvent, MouseEvent, PointerEvent, ReactElement, SVGAttributes, SyntheticEvent, TouchEvent, TransitionEvent, UIEvent, WheelEvent } from 'react';
|
|
2
|
+
export interface Activity {
|
|
3
|
+
count: number;
|
|
4
|
+
date: string;
|
|
5
|
+
level: number;
|
|
6
|
+
}
|
|
7
|
+
export type Week = Array<Activity | undefined>;
|
|
8
|
+
export type Labels = Partial<{
|
|
9
|
+
legend: Partial<{
|
|
10
|
+
less: string;
|
|
11
|
+
more: string;
|
|
12
|
+
}>;
|
|
13
|
+
months: Array<string>;
|
|
14
|
+
tooltip: string;
|
|
15
|
+
totalCount: string;
|
|
16
|
+
weekdays: Array<string>;
|
|
17
|
+
}>;
|
|
18
|
+
interface BlockAttributes extends SVGAttributes<SVGRectElement>, HTMLAttributes<SVGRectElement> {
|
|
19
|
+
}
|
|
20
|
+
export type BlockElement = ReactElement<BlockAttributes, JSXElementConstructor<SVGRectElement>>;
|
|
21
|
+
export type SVGRectEventHandler = Omit<DOMAttributes<SVGRectElement>, 'css' | 'children' | 'dangerouslySetInnerHTML'>;
|
|
22
|
+
export type EventHandlerMap = {
|
|
23
|
+
[key in keyof SVGRectEventHandler]: (...event: Parameters<NonNullable<SVGRectEventHandler[keyof SVGRectEventHandler]>>) => (activity: Activity) => void;
|
|
24
|
+
};
|
|
25
|
+
export type ReactEvent<E extends Element> = AnimationEvent<E> & ClipboardEvent<E> & CompositionEvent<E> & DragEvent<E> & FocusEvent<E> & FormEvent<E> & KeyboardEvent<E> & MouseEvent<E> & PointerEvent<E> & SyntheticEvent<E> & TouchEvent<E> & TransitionEvent<E> & UIEvent<E> & WheelEvent<E>;
|
|
1
26
|
type FixedProps = {
|
|
2
27
|
categoryClicked: string;
|
|
3
28
|
eventType: 'dot' | 'category' | 'bar' | 'slice' | 'bubble';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Day as WeekDay } from 'date-fns';
|
|
2
|
+
import type { Activity, Week } from "../types";
|
|
3
|
+
export declare const DEFAULT_MONTH_LABELS: string[];
|
|
4
|
+
export declare const DEFAULT_LABELS: {
|
|
5
|
+
legend: {
|
|
6
|
+
less: string;
|
|
7
|
+
more: string;
|
|
8
|
+
};
|
|
9
|
+
months: string[];
|
|
10
|
+
tooltip: string;
|
|
11
|
+
totalCount: string;
|
|
12
|
+
weekdays: string[];
|
|
13
|
+
};
|
|
14
|
+
interface MonthLabel {
|
|
15
|
+
label: string;
|
|
16
|
+
weekIndex: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const groupByWeeks: (activities: Array<Activity>, weekStart?: WeekDay) => Array<Week>;
|
|
19
|
+
export declare const getMonthLabels: (weeks: Array<Week>, monthNames?: Array<string>) => Array<MonthLabel>;
|
|
20
|
+
export declare const generateEmptyData: () => Array<Activity>;
|
|
21
|
+
export declare const generateTestData: (args: {
|
|
22
|
+
interval?: {
|
|
23
|
+
end: Date;
|
|
24
|
+
start: Date;
|
|
25
|
+
} | undefined;
|
|
26
|
+
maxLevel?: number | undefined;
|
|
27
|
+
}) => Array<Activity>;
|
|
28
|
+
export declare const maxWeekdayLabelLength: (firstWeek: Week, weekStart: number, labels: string[], fontSize: number) => number;
|
|
29
|
+
export {};
|