react-minimal-pie-chart 8.3.0 → 8.4.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 +14 -8
- package/dist/index.js +104 -128
- package/dist/index.js.map +1 -1
- package/es/index.js +97 -116
- package/es/index.js.map +1 -1
- package/lib/index.js +102 -126
- package/lib/index.js.map +1 -1
- package/package.json +30 -25
- package/types/Chart/Chart.d.ts +14 -30
- package/types/Chart/extendData.d.ts +2 -2
- package/types/Chart/index.d.ts +2 -1
- package/types/Chart/renderLabels.d.ts +2 -2
- package/types/Chart/renderSegments.d.ts +2 -2
- package/types/Label.d.ts +8 -7
- package/types/commonTypes.d.ts +7 -8
- package/types/index.d.ts +2 -1
- package/types/utils.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-minimal-pie-chart",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Lightweight but versatile SVG pie/donut charts for React",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "jest ./src
|
|
18
|
+
"test": "jest ./src",
|
|
19
19
|
"test:bundles": "npm run test:bundles:snapshot && npm run test:bundles:unit && npm run test:bundles:es5 && npm run test:bundles:size",
|
|
20
20
|
"test:bundles:unit": "jest ./src --config ./jest/es.config.js && jest ./src --config ./jest/lib.config.js && jest ./src --config ./jest/dist.config.js",
|
|
21
21
|
"test:bundles:snapshot": "jest ./jest/__tests__/bundles-snapshot.test.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test:update": "npm run compile:source && npm run test:bundles:snapshot -- -u && git add ./jest/__tests__/__snapshots__",
|
|
27
27
|
"clean": "rm -rf lib es dist types",
|
|
28
28
|
"compile": "npm run clean && npm run compile:types && npm run compile:source",
|
|
29
|
-
"compile:source": "rollup -c",
|
|
29
|
+
"compile:source": "rollup -c --bundleConfigAsCjs",
|
|
30
30
|
"compile:types": "tsc -p tsconfig.build.json",
|
|
31
31
|
"contrib:add": "all-contributors add",
|
|
32
32
|
"contrib:generate": "all-contributors generate",
|
|
@@ -57,44 +57,49 @@
|
|
|
57
57
|
"react": "^16.8.0 || ^17.0.0 || ^18",
|
|
58
58
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18"
|
|
59
59
|
},
|
|
60
|
-
"dependencies": {
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@types/svg-path-parser": "^1.1.3"
|
|
62
|
+
},
|
|
61
63
|
"devDependencies": {
|
|
62
64
|
"@babel/core": "^7.12.10",
|
|
63
65
|
"@babel/plugin-transform-react-jsx": "^7.12.12",
|
|
64
66
|
"@babel/preset-env": "^7.12.11",
|
|
65
67
|
"@babel/preset-typescript": "^7.12.7",
|
|
66
|
-
"@rollup/plugin-babel": "^
|
|
67
|
-
"@rollup/plugin-commonjs": "^
|
|
68
|
-
"@rollup/plugin-node-resolve": "^
|
|
68
|
+
"@rollup/plugin-babel": "^6.0.2",
|
|
69
|
+
"@rollup/plugin-commonjs": "^23.0.2",
|
|
70
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
69
71
|
"@schwingbat/relative-angle": "^1.0.0",
|
|
70
|
-
"@size-limit/preset-small-lib": "^5.0.
|
|
71
|
-
"@storybook/addon-actions": "^6.
|
|
72
|
-
"@storybook/react": "^6.
|
|
73
|
-
"@storybook/storybook-deployer": "^2.8.
|
|
74
|
-
"@testing-library/jest-dom": "^5.
|
|
75
|
-
"@testing-library/react": "^
|
|
76
|
-
"@types/react": "^
|
|
72
|
+
"@size-limit/preset-small-lib": "^5.0.5",
|
|
73
|
+
"@storybook/addon-actions": "^6.5.13",
|
|
74
|
+
"@storybook/react": "^6.5.13",
|
|
75
|
+
"@storybook/storybook-deployer": "^2.8.16",
|
|
76
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
77
|
+
"@testing-library/react": "^13.4.0",
|
|
78
|
+
"@types/react": "^18.0.24",
|
|
79
|
+
"@types/react-dom": "^18.0.8",
|
|
77
80
|
"all-contributors-cli": "^6.19.0",
|
|
78
|
-
"babel-jest": "^
|
|
81
|
+
"babel-jest": "^29.2.2",
|
|
79
82
|
"babel-loader": "^8.2.2",
|
|
80
83
|
"es-check": "^6.0.0",
|
|
81
|
-
"jest": "^
|
|
84
|
+
"jest": "^29.2.2",
|
|
85
|
+
"jest-environment-jsdom": "^29.2.2",
|
|
82
86
|
"lint-staged": "^11.1.2",
|
|
83
87
|
"prettier": "^2.2.1",
|
|
84
|
-
"
|
|
85
|
-
"react": "^
|
|
86
|
-
"react-
|
|
87
|
-
"
|
|
88
|
-
"rollup": "^2.40.0",
|
|
88
|
+
"react": "^18.2.0",
|
|
89
|
+
"react-dom": "^18.2.0",
|
|
90
|
+
"react-tooltip": "^4.4.3",
|
|
91
|
+
"rollup": "^3.2.3",
|
|
89
92
|
"simple-git-hooks": "^2.4.1",
|
|
90
|
-
"size-limit": "^5.0.
|
|
93
|
+
"size-limit": "^5.0.5",
|
|
91
94
|
"svg-partial-circle": "1.0.0",
|
|
92
95
|
"svg-path-parser": "^1.1.0",
|
|
93
|
-
"typescript": "^4.
|
|
96
|
+
"typescript": "^4.8.4"
|
|
94
97
|
},
|
|
95
98
|
"jest": {
|
|
96
99
|
"testRegex": "/__tests__/.*\\.test\\.[jt]sx?$",
|
|
97
|
-
"
|
|
100
|
+
"testEnvironmentOptions": {
|
|
101
|
+
"url": "http://localhost/"
|
|
102
|
+
},
|
|
98
103
|
"testEnvironment": "jsdom",
|
|
99
104
|
"coverageReporters": [
|
|
100
105
|
"text",
|
|
@@ -105,7 +110,7 @@
|
|
|
105
110
|
"!**/__tests__/**"
|
|
106
111
|
],
|
|
107
112
|
"setupFilesAfterEnv": [
|
|
108
|
-
"<rootDir>/jest.setup.
|
|
113
|
+
"<rootDir>/jest.setup.ts"
|
|
109
114
|
]
|
|
110
115
|
},
|
|
111
116
|
"size-limit": [
|
package/types/Chart/Chart.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, FocusEvent, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import type { Data,
|
|
3
|
-
declare type Props = {
|
|
2
|
+
import type { Data, BaseDataEntry, LabelRenderFunction } from '../commonTypes';
|
|
3
|
+
export declare type Props<DataEntry extends BaseDataEntry = BaseDataEntry> = {
|
|
4
4
|
animate?: boolean;
|
|
5
5
|
animationDuration?: number;
|
|
6
6
|
animationEasing?: string;
|
|
@@ -8,18 +8,18 @@ declare type Props = {
|
|
|
8
8
|
center?: [number, number];
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
className?: string;
|
|
11
|
-
data: Data
|
|
11
|
+
data: Data<DataEntry>;
|
|
12
12
|
lengthAngle?: number;
|
|
13
13
|
lineWidth?: number;
|
|
14
|
-
label?: LabelRenderFunction
|
|
14
|
+
label?: LabelRenderFunction<DataEntry>;
|
|
15
15
|
labelPosition?: number;
|
|
16
16
|
labelStyle?: CSSProperties | ((dataIndex: number) => CSSProperties | undefined);
|
|
17
|
-
onBlur?:
|
|
18
|
-
onClick?:
|
|
19
|
-
onFocus?:
|
|
20
|
-
onKeyDown?:
|
|
21
|
-
onMouseOut?:
|
|
22
|
-
onMouseOver?:
|
|
17
|
+
onBlur?: (event: FocusEvent, dataIndex: number) => void;
|
|
18
|
+
onClick?: (event: MouseEvent, dataIndex: number) => void;
|
|
19
|
+
onFocus?: (event: FocusEvent, dataIndex: number) => void;
|
|
20
|
+
onKeyDown?: (event: KeyboardEvent, dataIndex: number) => void;
|
|
21
|
+
onMouseOut?: (event: MouseEvent, dataIndex: number) => void;
|
|
22
|
+
onMouseOver?: (event: MouseEvent, dataIndex: number) => void;
|
|
23
23
|
paddingAngle?: number;
|
|
24
24
|
radius?: number;
|
|
25
25
|
reveal?: number;
|
|
@@ -32,11 +32,11 @@ declare type Props = {
|
|
|
32
32
|
totalValue?: number;
|
|
33
33
|
viewBoxSize?: [number, number];
|
|
34
34
|
};
|
|
35
|
-
declare const defaultProps: {
|
|
35
|
+
export declare const defaultProps: {
|
|
36
36
|
animationDuration: number;
|
|
37
37
|
animationEasing: string;
|
|
38
38
|
center: [number, number];
|
|
39
|
-
data: Data
|
|
39
|
+
data: Data<BaseDataEntry>;
|
|
40
40
|
labelPosition: number;
|
|
41
41
|
lengthAngle: number;
|
|
42
42
|
lineWidth: number;
|
|
@@ -45,21 +45,5 @@ declare const defaultProps: {
|
|
|
45
45
|
startAngle: number;
|
|
46
46
|
viewBoxSize: [number, number];
|
|
47
47
|
};
|
|
48
|
-
export declare type PropsWithDefaults = Props & typeof defaultProps;
|
|
49
|
-
export declare function ReactMinimalPieChart(
|
|
50
|
-
export declare namespace ReactMinimalPieChart {
|
|
51
|
-
var defaultProps: {
|
|
52
|
-
animationDuration: number;
|
|
53
|
-
animationEasing: string;
|
|
54
|
-
center: [number, number];
|
|
55
|
-
data: Data;
|
|
56
|
-
labelPosition: number;
|
|
57
|
-
lengthAngle: number;
|
|
58
|
-
lineWidth: number;
|
|
59
|
-
paddingAngle: number;
|
|
60
|
-
radius: number;
|
|
61
|
-
startAngle: number;
|
|
62
|
-
viewBoxSize: [number, number];
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
48
|
+
export declare type PropsWithDefaults<DataEntry extends BaseDataEntry> = Props<DataEntry> & typeof defaultProps;
|
|
49
|
+
export declare function ReactMinimalPieChart<DataEntry extends BaseDataEntry>(originalProps: Props<DataEntry>): JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ExtendedData } from '../commonTypes';
|
|
1
|
+
import type { BaseDataEntry, ExtendedData } from '../commonTypes';
|
|
2
2
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
3
|
-
export default function extendData({ data, lengthAngle: totalAngle, totalValue, paddingAngle, startAngle: chartStartAngle, }: ChartProps): ExtendedData
|
|
3
|
+
export default function extendData<DataEntry extends BaseDataEntry>({ data, lengthAngle: totalAngle, totalValue, paddingAngle, startAngle: chartStartAngle, }: ChartProps<DataEntry>): ExtendedData<DataEntry>;
|
package/types/Chart/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ReactMinimalPieChart as PieChart } from './Chart';
|
|
1
|
+
export { ReactMinimalPieChart as PieChart, defaultProps as pieChartDefaultProps, } from './Chart';
|
|
2
|
+
export type { Props as PieChartProps } from './Chart';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
3
|
-
import type { ExtendedData } from '../commonTypes';
|
|
4
|
-
export default function renderLabels(data: ExtendedData
|
|
3
|
+
import type { ExtendedData, BaseDataEntry } from '../commonTypes';
|
|
4
|
+
export default function renderLabels<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>): JSX.Element[] | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { ExtendedData } from '../commonTypes';
|
|
2
|
+
import type { ExtendedData, BaseDataEntry } from '../commonTypes';
|
|
3
3
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
4
|
-
export default function renderSegments(data: ExtendedData
|
|
4
|
+
export default function renderSegments<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>, revealOverride?: null | number): JSX.Element[];
|
package/types/Label.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { CSSProperties
|
|
2
|
-
import type {
|
|
3
|
-
export declare type LabelRenderProps = {
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { ExtendedData, BaseDataEntry, LabelRenderFunction } from './commonTypes';
|
|
3
|
+
export declare type LabelRenderProps<DataEntry extends BaseDataEntry> = {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
dx: number;
|
|
7
7
|
dy: number;
|
|
8
8
|
textAnchor: string;
|
|
9
|
-
dataEntry:
|
|
9
|
+
dataEntry: ExtendedData<DataEntry>[number];
|
|
10
10
|
dataIndex: number;
|
|
11
11
|
style?: CSSProperties;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export default function ReactMinimalPieChartLabel<DataEntry extends BaseDataEntry>({ renderLabel, labelProps, }: {
|
|
14
|
+
renderLabel: LabelRenderFunction<DataEntry>;
|
|
15
|
+
labelProps: LabelRenderProps<DataEntry>;
|
|
16
|
+
}): JSX.Element | null;
|
package/types/commonTypes.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LabelRenderProps } from './Label';
|
|
3
|
-
export declare type
|
|
4
|
-
export declare type
|
|
5
|
-
export declare type DataEntry = {
|
|
3
|
+
export declare type LabelRenderFunction<DataEntry extends BaseDataEntry> = (labelRenderProps: LabelRenderProps<DataEntry>) => ReactNode;
|
|
4
|
+
export declare type BaseDataEntry = {
|
|
6
5
|
title?: string | number;
|
|
7
6
|
color: string;
|
|
8
7
|
value: number;
|
|
9
8
|
key?: string | number;
|
|
10
|
-
[key: string]: any;
|
|
11
9
|
};
|
|
12
|
-
|
|
10
|
+
declare type BaseExtendedDataEntry<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry & {
|
|
13
11
|
degrees: number;
|
|
14
12
|
startAngle: number;
|
|
15
13
|
percentage: number;
|
|
16
14
|
};
|
|
17
|
-
export declare type Data = DataEntry[];
|
|
18
|
-
export declare type ExtendedData =
|
|
15
|
+
export declare type Data<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry[];
|
|
16
|
+
export declare type ExtendedData<DataEntry extends BaseDataEntry = BaseDataEntry> = BaseExtendedDataEntry<DataEntry>[];
|
|
17
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { PieChart } from './Chart';
|
|
1
|
+
export { PieChart, pieChartDefaultProps } from './Chart';
|
|
2
|
+
export type { PieChartProps } from './Chart';
|
package/types/utils.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export declare function shiftVectorAlongAngle(angle: number, distance: number):
|
|
|
8
8
|
};
|
|
9
9
|
export declare function isNumber(value: unknown): value is number;
|
|
10
10
|
export declare function functionProp<Prop, Payload>(prop: Prop, payload?: Payload): Prop extends (...args: any) => any ? ReturnType<Prop> : Prop;
|
|
11
|
+
export declare function makePropsWithDefaults<Result extends Object>(props: Partial<Result>, defaultProps: Result): Result;
|