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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-minimal-pie-chart",
3
- "version": "8.4.0",
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 -p tsconfig.test.json",
26
- "test:update": "npm run compile:source && npm run test:bundles:snapshot -- -u && git add ./jest/__tests__/__snapshots__",
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
- "compile": "npm run clean && npm run compile:types && npm run compile:source",
29
- "compile:source": "rollup -c --bundleConfigAsCjs",
30
- "compile:types": "tsc -p tsconfig.build.json",
31
- "contrib:add": "all-contributors add",
32
- "contrib:generate": "all-contributors generate",
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 compile && npm run test:bundles",
38
- "start": "start-storybook -p 9001 -c .storybook",
39
- "storybook:deploy": "storybook-to-ghpages",
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.12.10",
65
- "@babel/plugin-transform-react-jsx": "^7.12.12",
66
- "@babel/preset-env": "^7.12.11",
67
- "@babel/preset-typescript": "^7.12.7",
68
- "@rollup/plugin-babel": "^6.0.2",
69
- "@rollup/plugin-commonjs": "^23.0.2",
70
- "@rollup/plugin-node-resolve": "^15.0.1",
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": "^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",
80
- "all-contributors-cli": "^6.19.0",
81
- "babel-jest": "^29.2.2",
82
- "babel-loader": "^8.2.2",
83
- "es-check": "^6.0.0",
84
- "jest": "^29.2.2",
85
- "jest-environment-jsdom": "^29.2.2",
86
- "lint-staged": "^11.1.2",
87
- "prettier": "^2.2.1",
88
- "react": "^18.2.0",
89
- "react-dom": "^18.2.0",
90
- "react-tooltip": "^4.4.3",
91
- "rollup": "^3.2.3",
92
- "simple-git-hooks": "^2.4.1",
93
- "size-limit": "^5.0.5",
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.8.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 test:source && npx lint-staged"
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
  }
@@ -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 declare type Props<DataEntry extends BaseDataEntry = BaseDataEntry> = {
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<BaseDataEntry>;
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 declare type PropsWithDefaults<DataEntry extends BaseDataEntry> = Props<DataEntry> & typeof defaultProps;
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
- /// <reference types="react" />
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
- /// <reference types="react" />
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 declare type LabelRenderProps<DataEntry extends BaseDataEntry> = {
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
- declare type Props = SVGProps<SVGPathElement> & {
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 {};
@@ -1,17 +1,17 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { LabelRenderProps } from './Label';
3
- export declare type LabelRenderFunction<DataEntry extends BaseDataEntry> = (labelRenderProps: LabelRenderProps<DataEntry>) => ReactNode;
4
- export declare type BaseDataEntry = {
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
- declare type BaseExtendedDataEntry<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry & {
10
+ type BaseExtendedDataEntry<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry & {
11
11
  degrees: number;
12
12
  startAngle: number;
13
13
  percentage: number;
14
14
  };
15
- export declare type Data<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry[];
16
- export declare type ExtendedData<DataEntry extends BaseDataEntry = BaseDataEntry> = BaseExtendedDataEntry<DataEntry>[];
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
- 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;
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;