react-minimal-pie-chart 8.4.0 → 8.4.1
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 +5 -11
- package/dist/index.js +70 -47
- package/dist/index.js.map +1 -1
- package/es/index.js +70 -47
- package/es/index.js.map +1 -1
- package/lib/index.js +70 -47
- package/lib/index.js.map +1 -1
- package/package.json +47 -57
- package/types/Chart/Chart.d.ts +5 -4
- package/types/Chart/renderLabels.d.ts +2 -2
- package/types/Chart/renderSegments.d.ts +2 -2
- package/types/Label.d.ts +3 -2
- package/types/Path.d.ts +3 -2
- package/types/commonTypes.d.ts +5 -5
- package/types/utils.d.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-minimal-pie-chart",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.1",
|
|
4
4
|
"description": "Lightweight but versatile SVG pie/donut charts for React",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -22,22 +22,20 @@
|
|
|
22
22
|
"test:bundles:es5": "es-check es5 './@(lib|dist)/*.js'",
|
|
23
23
|
"test:bundles:size": "size-limit",
|
|
24
24
|
"test:source": "npm run test:ts && npm t -- --coverage",
|
|
25
|
-
"test:ts": "tsc
|
|
26
|
-
"test:update": "npm run
|
|
25
|
+
"test:ts": "tsc --noEmit",
|
|
26
|
+
"test:update": "npm run build:source && npm run test:bundles:snapshot -- -u && git add ./jest/__tests__/__snapshots__",
|
|
27
27
|
"clean": "rm -rf lib es dist types",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"format": "prettier --write \"**/*.{js,ts,tsx,json,md}\"",
|
|
28
|
+
"build": "npm run clean && npm run build:types && npm run build:source",
|
|
29
|
+
"build:source": "rollup -c --bundleConfigAsCjs",
|
|
30
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
31
|
+
"format:check": "prettier . --check",
|
|
32
|
+
"format:fix": "npm run format:check -- --write",
|
|
34
33
|
"preversion": "npm run prepare",
|
|
35
34
|
"version": "git add package.json",
|
|
36
35
|
"postversion": "git push && git push --tags",
|
|
37
|
-
"prepare": "npx simple-git-hooks && npm run test:source && npm run
|
|
38
|
-
"start": "
|
|
39
|
-
"storybook:
|
|
40
|
-
"storybook:build": "build-storybook"
|
|
36
|
+
"prepare": "npx simple-git-hooks && npm run test:source && npm run build && npm run test:bundles",
|
|
37
|
+
"start": "storybook dev",
|
|
38
|
+
"storybook:build": "storybook build"
|
|
41
39
|
},
|
|
42
40
|
"keywords": [
|
|
43
41
|
"react",
|
|
@@ -57,43 +55,44 @@
|
|
|
57
55
|
"react": "^16.8.0 || ^17.0.0 || ^18",
|
|
58
56
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18"
|
|
59
57
|
},
|
|
60
|
-
"dependencies": {
|
|
61
|
-
"@types/svg-path-parser": "^1.1.3"
|
|
62
|
-
},
|
|
63
58
|
"devDependencies": {
|
|
64
|
-
"@babel/core": "^7.
|
|
65
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
66
|
-
"@babel/preset-env": "^7.
|
|
67
|
-
"@babel/preset-typescript": "^7.
|
|
68
|
-
"@
|
|
69
|
-
"@rollup/plugin-
|
|
70
|
-
"@rollup/plugin-
|
|
59
|
+
"@babel/core": "^7.24.7",
|
|
60
|
+
"@babel/plugin-transform-react-jsx": "^7.24.7",
|
|
61
|
+
"@babel/preset-env": "^7.24.7",
|
|
62
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
63
|
+
"@changesets/cli": "^2.27.9",
|
|
64
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
65
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
66
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
71
67
|
"@schwingbat/relative-angle": "^1.0.0",
|
|
72
|
-
"@size-limit/preset-small-lib": "^
|
|
73
|
-
"@storybook/addon-
|
|
74
|
-
"@storybook/react": "^
|
|
75
|
-
"@storybook/
|
|
76
|
-
"@
|
|
77
|
-
"@testing-library/
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"jest
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"react
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
68
|
+
"@size-limit/preset-small-lib": "^11.1.4",
|
|
69
|
+
"@storybook/addon-essentials": "^8.1.6",
|
|
70
|
+
"@storybook/react": "^8.1.6",
|
|
71
|
+
"@storybook/react-vite": "^8.1.6",
|
|
72
|
+
"@storybook/test": "^8.1.6",
|
|
73
|
+
"@testing-library/jest-dom": "^6.4.5",
|
|
74
|
+
"@testing-library/react": "^16.0.0",
|
|
75
|
+
"@tsconfig/node18": "^18.2.4",
|
|
76
|
+
"@types/jest": "^29.5.12",
|
|
77
|
+
"@types/node": "^22.8.6",
|
|
78
|
+
"@types/react": "^18.3.3",
|
|
79
|
+
"@types/react-dom": "^18.3.0",
|
|
80
|
+
"@types/svg-path-parser": "^1.1.6",
|
|
81
|
+
"babel-jest": "^29.7.0",
|
|
82
|
+
"es-check": "^7.2.1",
|
|
83
|
+
"jest": "^29.7.0",
|
|
84
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
85
|
+
"prettier": "^3.2.5",
|
|
86
|
+
"react": "^18.3.1",
|
|
87
|
+
"react-dom": "^18.3.1",
|
|
88
|
+
"react-tooltip": "^4.5.1",
|
|
89
|
+
"rollup": "^4.18.0",
|
|
90
|
+
"simple-git-hooks": "^2.11.1",
|
|
91
|
+
"size-limit": "^11.1.4",
|
|
92
|
+
"storybook": "^8.1.6",
|
|
94
93
|
"svg-partial-circle": "1.0.0",
|
|
95
94
|
"svg-path-parser": "^1.1.0",
|
|
96
|
-
"typescript": "^4.
|
|
95
|
+
"typescript": "^5.4.5"
|
|
97
96
|
},
|
|
98
97
|
"jest": {
|
|
99
98
|
"testRegex": "/__tests__/.*\\.test\\.[jt]sx?$",
|
|
@@ -115,7 +114,7 @@
|
|
|
115
114
|
},
|
|
116
115
|
"size-limit": [
|
|
117
116
|
{
|
|
118
|
-
"limit": "2 KB",
|
|
117
|
+
"limit": "2.5 KB",
|
|
119
118
|
"path": "./es/index.js",
|
|
120
119
|
"ignore": [
|
|
121
120
|
"react"
|
|
@@ -123,15 +122,6 @@
|
|
|
123
122
|
}
|
|
124
123
|
],
|
|
125
124
|
"simple-git-hooks": {
|
|
126
|
-
"pre-commit": "npm run
|
|
127
|
-
},
|
|
128
|
-
"lint-staged": {
|
|
129
|
-
"*.{js,ts,tsx}": [
|
|
130
|
-
"npm run test:update",
|
|
131
|
-
"prettier --write"
|
|
132
|
-
],
|
|
133
|
-
"*.{json,md}": [
|
|
134
|
-
"prettier --write"
|
|
135
|
-
]
|
|
125
|
+
"pre-commit": "npm run format:check && npm run test:source"
|
|
136
126
|
}
|
|
137
127
|
}
|
package/types/Chart/Chart.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { CSSProperties, FocusEvent, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
3
|
import type { Data, BaseDataEntry, LabelRenderFunction } from '../commonTypes';
|
|
3
|
-
export
|
|
4
|
+
export type Props<DataEntry extends BaseDataEntry = BaseDataEntry> = {
|
|
4
5
|
animate?: boolean;
|
|
5
6
|
animationDuration?: number;
|
|
6
7
|
animationEasing?: string;
|
|
@@ -36,7 +37,7 @@ export declare const defaultProps: {
|
|
|
36
37
|
animationDuration: number;
|
|
37
38
|
animationEasing: string;
|
|
38
39
|
center: [number, number];
|
|
39
|
-
data: Data
|
|
40
|
+
data: Data;
|
|
40
41
|
labelPosition: number;
|
|
41
42
|
lengthAngle: number;
|
|
42
43
|
lineWidth: number;
|
|
@@ -45,5 +46,5 @@ export declare const defaultProps: {
|
|
|
45
46
|
startAngle: number;
|
|
46
47
|
viewBoxSize: [number, number];
|
|
47
48
|
};
|
|
48
|
-
export
|
|
49
|
-
export declare function ReactMinimalPieChart<DataEntry extends BaseDataEntry>(originalProps: Props<DataEntry>): JSX.Element;
|
|
49
|
+
export type PropsWithDefaults<DataEntry extends BaseDataEntry = BaseDataEntry> = Props<DataEntry> & typeof defaultProps;
|
|
50
|
+
export declare function ReactMinimalPieChart<DataEntry extends BaseDataEntry>(originalProps: Props<DataEntry>): React.JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
3
3
|
import type { ExtendedData, BaseDataEntry } from '../commonTypes';
|
|
4
|
-
export default function renderLabels<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>): JSX.Element[] | undefined;
|
|
4
|
+
export default function renderLabels<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>): React.JSX.Element[] | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { ExtendedData, BaseDataEntry } from '../commonTypes';
|
|
3
3
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
4
|
-
export default function renderSegments<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>, revealOverride?: null | number): JSX.Element[];
|
|
4
|
+
export default function renderSegments<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>, revealOverride?: null | number): React.JSX.Element[];
|
package/types/Label.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { CSSProperties } from 'react';
|
|
2
3
|
import type { ExtendedData, BaseDataEntry, LabelRenderFunction } from './commonTypes';
|
|
3
|
-
export
|
|
4
|
+
export type LabelRenderProps<DataEntry extends BaseDataEntry> = {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
6
7
|
dx: number;
|
|
@@ -13,4 +14,4 @@ export declare type LabelRenderProps<DataEntry extends BaseDataEntry> = {
|
|
|
13
14
|
export default function ReactMinimalPieChartLabel<DataEntry extends BaseDataEntry>({ renderLabel, labelProps, }: {
|
|
14
15
|
renderLabel: LabelRenderFunction<DataEntry>;
|
|
15
16
|
labelProps: LabelRenderProps<DataEntry>;
|
|
16
|
-
}): JSX.Element | null;
|
|
17
|
+
}): React.JSX.Element | null;
|
package/types/Path.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { SVGProps } from 'react';
|
|
2
3
|
export declare function makePathCommands(cx: number, cy: number, startAngle: number, lengthAngle: number, radius: number): string;
|
|
3
|
-
|
|
4
|
+
type Props = SVGProps<SVGPathElement> & {
|
|
4
5
|
cx: number;
|
|
5
6
|
cy: number;
|
|
6
7
|
lengthAngle: number;
|
|
@@ -12,5 +13,5 @@ declare type Props = SVGProps<SVGPathElement> & {
|
|
|
12
13
|
startAngle: number;
|
|
13
14
|
title?: string | number;
|
|
14
15
|
};
|
|
15
|
-
export default function ReactMinimalPieChartPath({ cx, cy, lengthAngle, lineWidth, radius, shift, reveal, rounded, startAngle, title, ...props }: Props): JSX.Element;
|
|
16
|
+
export default function ReactMinimalPieChartPath({ cx, cy, lengthAngle, lineWidth, radius, shift, reveal, rounded, startAngle, title, ...props }: Props): React.JSX.Element;
|
|
16
17
|
export {};
|
package/types/commonTypes.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LabelRenderProps } from './Label';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type LabelRenderFunction<DataEntry extends BaseDataEntry> = (labelRenderProps: LabelRenderProps<DataEntry>) => ReactNode;
|
|
4
|
+
export type BaseDataEntry = {
|
|
5
5
|
title?: string | number;
|
|
6
6
|
color: string;
|
|
7
7
|
value: number;
|
|
8
8
|
key?: string | number;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type BaseExtendedDataEntry<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry & {
|
|
11
11
|
degrees: number;
|
|
12
12
|
startAngle: number;
|
|
13
13
|
percentage: number;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type Data<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry[];
|
|
16
|
+
export type ExtendedData<DataEntry extends BaseDataEntry = BaseDataEntry> = BaseExtendedDataEntry<DataEntry>[];
|
|
17
17
|
export {};
|
package/types/utils.d.ts
CHANGED
|
@@ -7,5 +7,7 @@ export declare function shiftVectorAlongAngle(angle: number, distance: number):
|
|
|
7
7
|
dy: number;
|
|
8
8
|
};
|
|
9
9
|
export declare function isNumber(value: unknown): value is number;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Conditionally return a prop or a function prop result
|
|
12
|
+
*/
|
|
13
|
+
export declare function functionProp<ReturnedProp, Payload>(prop: ((args: Payload) => ReturnedProp) | ReturnedProp, payload: Payload): ReturnedProp;
|