@chakra-ui/charts 3.15.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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/cjs/bar-list/bar-list.cjs +162 -0
  4. package/dist/cjs/bar-list/index.cjs +16 -0
  5. package/dist/cjs/bar-list/namespace.cjs +14 -0
  6. package/dist/cjs/bar-segment/bar-segment.cjs +215 -0
  7. package/dist/cjs/bar-segment/index.cjs +16 -0
  8. package/dist/cjs/bar-segment/namespace.cjs +14 -0
  9. package/dist/cjs/chart/chart.cjs +275 -0
  10. package/dist/cjs/chart/index.cjs +14 -0
  11. package/dist/cjs/chart/namespace.cjs +12 -0
  12. package/dist/cjs/index.cjs +36 -0
  13. package/dist/cjs/use-chart.cjs +130 -0
  14. package/dist/esm/bar-list/bar-list.js +135 -0
  15. package/dist/esm/bar-list/index.js +4 -0
  16. package/dist/esm/bar-list/namespace.js +2 -0
  17. package/dist/esm/bar-segment/bar-segment.js +187 -0
  18. package/dist/esm/bar-segment/index.js +4 -0
  19. package/dist/esm/bar-segment/namespace.js +2 -0
  20. package/dist/esm/chart/chart.js +251 -0
  21. package/dist/esm/chart/index.js +4 -0
  22. package/dist/esm/chart/namespace.js +2 -0
  23. package/dist/esm/index.js +11 -0
  24. package/dist/esm/use-chart.js +108 -0
  25. package/dist/types/bar-list/bar-list.d.ts +40 -0
  26. package/dist/types/bar-list/index.d.ts +3 -0
  27. package/dist/types/bar-list/namespace.d.ts +2 -0
  28. package/dist/types/bar-segment/bar-segment.d.ts +42 -0
  29. package/dist/types/bar-segment/index.d.ts +3 -0
  30. package/dist/types/bar-segment/namespace.d.ts +2 -0
  31. package/dist/types/chart/chart.d.ts +44 -0
  32. package/dist/types/chart/index.d.ts +3 -0
  33. package/dist/types/chart/namespace.d.ts +2 -0
  34. package/dist/types/index.d.mts +5 -0
  35. package/dist/types/index.d.ts +5 -0
  36. package/dist/types/use-chart.d.ts +54 -0
  37. package/package.json +64 -0
@@ -0,0 +1,44 @@
1
+ import type { BoxProps } from "@chakra-ui/react";
2
+ import * as React from "react";
3
+ import type { LegendProps, TooltipProps } from "recharts";
4
+ import type { Payload } from "recharts/types/component/DefaultTooltipContent";
5
+ import type { ViewBox } from "recharts/types/util/types";
6
+ import { type ChartColor, type UseChartReturn } from "../use-chart";
7
+ export interface ChartRootProps extends BoxProps {
8
+ children: React.ReactElement;
9
+ chart: UseChartReturn<unknown>;
10
+ }
11
+ export declare const ChartRoot: React.ForwardRefExoticComponent<ChartRootProps & React.RefAttributes<HTMLDivElement>>;
12
+ export interface ChartGradientProps {
13
+ id: string;
14
+ fillOpacity?: number;
15
+ stops: {
16
+ color: ChartColor;
17
+ offset: string | number;
18
+ opacity?: number;
19
+ }[];
20
+ }
21
+ export declare const ChartGradient: React.ForwardRefExoticComponent<ChartGradientProps & React.RefAttributes<SVGLinearGradientElement>>;
22
+ export interface ChartLegendProps extends LegendProps {
23
+ title?: React.ReactNode;
24
+ nameKey?: string;
25
+ }
26
+ export declare function ChartLegend(props: ChartLegendProps): import("react/jsx-runtime").JSX.Element | null;
27
+ export interface ChartTooltipProps extends TooltipProps<string, string> {
28
+ hideLabel?: boolean;
29
+ hideIndicator?: boolean;
30
+ hideSeriesLabel?: boolean;
31
+ showTotal?: boolean;
32
+ fitContent?: boolean;
33
+ nameKey?: string;
34
+ indicator?: "line" | "dot" | "dashed";
35
+ render?: (item: Payload<string, string>) => React.ReactNode;
36
+ }
37
+ export declare function ChartTooltip(props: ChartTooltipProps): import("react/jsx-runtime").JSX.Element | null;
38
+ export interface ChartRadialTextProps {
39
+ viewBox: ViewBox | undefined;
40
+ title: React.ReactNode;
41
+ description: React.ReactNode;
42
+ gap?: number;
43
+ }
44
+ export declare function ChartRadialText(props: ChartRadialTextProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ export { ChartGradient, ChartLegend, ChartRadialText, ChartRoot, ChartTooltip, } from "./chart";
2
+ export type { ChartRootProps, ChartGradientProps, ChartLegendProps, ChartTooltipProps, ChartRadialTextProps, } from "./chart";
3
+ export * as Chart from "./namespace";
@@ -0,0 +1,2 @@
1
+ export { ChartGradient as Gradient, ChartLegend as Legend, ChartRadialText as RadialText, ChartRoot as Root, ChartTooltip as Tooltip, } from "./chart";
2
+ export type { ChartRootProps as RootProps, ChartGradientProps as GradientProps, ChartLegendProps as LegendProps, ChartTooltipProps as TooltipProps, ChartRadialTextProps as RadialTextProps, } from "./chart";
@@ -0,0 +1,5 @@
1
+ export { useChart } from "./use-chart";
2
+ export type { UseChartProps, UseChartReturn } from "./use-chart";
3
+ export * from "./chart";
4
+ export * from "./bar-list";
5
+ export * from "./bar-segment";
@@ -0,0 +1,5 @@
1
+ export { useChart } from "./use-chart";
2
+ export type { UseChartProps, UseChartReturn } from "./use-chart";
3
+ export * from "./chart";
4
+ export * from "./bar-list";
5
+ export * from "./bar-segment";
@@ -0,0 +1,54 @@
1
+ import type { Tokens } from "@chakra-ui/react";
2
+ import * as React from "react";
3
+ export type ChartColor = Tokens["colors"] | React.CSSProperties["color"];
4
+ export type ChartSize = Tokens["sizes"] | (string & {});
5
+ export type ChartSpacing = Tokens["spacing"] | (string & {});
6
+ type ItemDataKey<T> = T extends Array<infer U> ? keyof U : keyof T;
7
+ interface SeriesItem<T> {
8
+ name?: ItemDataKey<T>;
9
+ color?: ChartColor;
10
+ icon?: React.ReactNode;
11
+ label?: React.ReactNode;
12
+ stackId?: string;
13
+ yAxisId?: string;
14
+ strokeDasharray?: string;
15
+ id?: string;
16
+ }
17
+ export interface UseChartProps<T> {
18
+ data: T[];
19
+ series?: SeriesItem<T>[];
20
+ sort?: {
21
+ by: keyof T;
22
+ direction: "asc" | "desc";
23
+ };
24
+ }
25
+ type ValueDomain = [number, number] | ((props: {
26
+ min: number;
27
+ max: number;
28
+ }) => [number, number]);
29
+ export declare function useChart<T>(props: UseChartProps<T>): {
30
+ id: string;
31
+ key: <K extends ItemDataKey<T>>(prop: K | undefined) => K;
32
+ data: T[];
33
+ series: SeriesItem<T>[];
34
+ getSeries: (item: unknown) => SeriesItem<T> | undefined;
35
+ color: (key: ChartColor | undefined) => any;
36
+ size: (key: ChartSize | undefined) => any;
37
+ spacing: (key: ChartSpacing | undefined) => any;
38
+ formatNumber: (options?: Intl.NumberFormatOptions) => (value: number) => string;
39
+ formatDate: (options?: Intl.DateTimeFormatOptions) => (value: string) => string;
40
+ selectedSeries: string | null;
41
+ setSelectedSeries: React.Dispatch<React.SetStateAction<string | null>>;
42
+ highlightedSeries: string | null;
43
+ setHighlightedSeries: React.Dispatch<React.SetStateAction<string | null>>;
44
+ getTotal: (key: keyof T) => number;
45
+ getMin: (key: keyof T) => number;
46
+ getMax: (key: keyof T) => number;
47
+ getPayloadTotal: <T_1 extends {
48
+ value?: string;
49
+ }>(payload: Array<T_1> | undefined) => number | undefined;
50
+ getValuePercent: (key: keyof T, value: number, domain?: ValueDomain) => number;
51
+ };
52
+ export type UseChartReturn<T> = ReturnType<typeof useChart<T>>;
53
+ export declare function getProp<T = unknown>(item: unknown, key: string | undefined): T | undefined;
54
+ export {};
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@chakra-ui/charts",
3
+ "version": "3.15.0",
4
+ "description": "Data visualization components for Chakra UI",
5
+ "type": "module",
6
+ "main": "dist/cjs/index.cjs",
7
+ "module": "dist/esm/index.js",
8
+ "types": "dist/types/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "sideEffects": false,
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "author": "Segun Adebayo <sage@adebayosegun.com>",
17
+ "license": "MIT",
18
+ "homepage": "https://chakra-ui.com/",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/chakra-ui/chakra-ui",
22
+ "directory": "packages/charts"
23
+ },
24
+ "keywords": [
25
+ "ui",
26
+ "charts",
27
+ "chart",
28
+ "react",
29
+ "recharts",
30
+ "chartjs"
31
+ ],
32
+ "exports": {
33
+ ".": {
34
+ "import": {
35
+ "types": "./dist/types/index.d.ts",
36
+ "default": "./dist/esm/index.js"
37
+ },
38
+ "require": {
39
+ "types": "./dist/types/index.d.ts",
40
+ "default": "./dist/cjs/index.cjs"
41
+ }
42
+ },
43
+ "./package.json": "./package.json"
44
+ },
45
+ "devDependencies": {
46
+ "recharts": "2.13.3",
47
+ "react": "19.0.0",
48
+ "react-dom": "19.0.0",
49
+ "@chakra-ui/react": "3.15.0"
50
+ },
51
+ "peerDependencies": {
52
+ "@chakra-ui/react": ">=3",
53
+ "recharts": ">=2",
54
+ "react": ">=18",
55
+ "react-dom": ">=18"
56
+ },
57
+ "scripts": {
58
+ "build:fast": "tsx ../../scripts/build/main.ts",
59
+ "build": "tsx ../../scripts/build/main.ts --dts",
60
+ "dev": "pnpm build:fast --watch",
61
+ "clean": "rimraf dist .turbo",
62
+ "typecheck": "tsc --noEmit"
63
+ }
64
+ }