@karakuri-ui/react 0.1.2 → 0.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.
@@ -0,0 +1,163 @@
1
+ import * as React from 'react';
2
+ import * as RechartsPrimitive from 'recharts';
3
+
4
+ declare const THEMES: {
5
+ readonly light: "";
6
+ readonly dark: ".dark";
7
+ };
8
+ type ChartConfig = {
9
+ [k in string]: {
10
+ label?: React.ReactNode;
11
+ icon?: React.ComponentType;
12
+ } & ({
13
+ color?: string;
14
+ theme?: never;
15
+ } | {
16
+ color?: never;
17
+ theme: Record<keyof typeof THEMES, string>;
18
+ });
19
+ };
20
+ type ChartContextProps = {
21
+ config: ChartConfig;
22
+ hoverFade: boolean;
23
+ activeIndex: number | null;
24
+ setActiveIndex: (index: number | null) => void;
25
+ activeDataKey: string | null;
26
+ setActiveDataKey: (key: string | null) => void;
27
+ };
28
+ declare function useChart(): ChartContextProps;
29
+ declare function ChartContainer({ id, className, children, config, hoverFade, ...props }: React.ComponentProps<'div'> & {
30
+ config: ChartConfig;
31
+ /** Enable hover-to-highlight: hovered bar group stays full opacity, others fade. */
32
+ hoverFade?: boolean;
33
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
34
+ }): React.JSX.Element;
35
+ declare const ChartStyle: ({ id, config }: {
36
+ id: string;
37
+ config: ChartConfig;
38
+ }) => React.JSX.Element;
39
+ type ChartBarRadius = 'none' | 'sm' | 'base' | 'md' | 'lg';
40
+ type ChartBarVariant = 'solid' | 'outline';
41
+ type ChartBarProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Bar>, 'radius'> & {
42
+ /** Named radius token. Auto-adapts corners based on layout and stack position. */
43
+ radius?: ChartBarRadius;
44
+ /** 'horizontal' rounds the right side (away from Y-axis). Default: 'vertical' */
45
+ layout?: 'vertical' | 'horizontal';
46
+ /** 'bottom' rounds the bottom corners (base of a stack). Default: 'top' */
47
+ stackPosition?: 'top' | 'bottom';
48
+ /** 'outline' renders a thick border with a semi-transparent fill. Default: 'solid' */
49
+ variant?: ChartBarVariant;
50
+ };
51
+ declare function ChartBar({ radius, layout, stackPosition, variant, fill, stackId, ...props }: ChartBarProps): React.JSX.Element;
52
+ declare function ChartTooltip(props: React.ComponentProps<typeof RechartsPrimitive.Tooltip>): React.JSX.Element;
53
+ type TooltipPayloadItem = {
54
+ dataKey?: string | number;
55
+ name?: string;
56
+ value?: number | string;
57
+ type?: string;
58
+ color?: string;
59
+ payload?: Record<string, unknown>;
60
+ fill?: string;
61
+ };
62
+ type ChartTooltipContentProps = React.ComponentProps<'div'> & {
63
+ active?: boolean;
64
+ payload?: TooltipPayloadItem[];
65
+ label?: string;
66
+ labelFormatter?: (value: unknown, payload: TooltipPayloadItem[]) => React.ReactNode;
67
+ labelClassName?: string;
68
+ formatter?: (value: unknown, name: string, item: TooltipPayloadItem, index: number, payload: Record<string, unknown>) => React.ReactNode;
69
+ color?: string;
70
+ hideLabel?: boolean;
71
+ hideIndicator?: boolean;
72
+ indicator?: 'line' | 'dot' | 'dashed';
73
+ nameKey?: string;
74
+ labelKey?: string;
75
+ };
76
+ declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: ChartTooltipContentProps): React.JSX.Element | null;
77
+ declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
78
+ type LegendPayloadItem = {
79
+ value?: string;
80
+ type?: string;
81
+ color?: string;
82
+ dataKey?: string;
83
+ };
84
+ type ChartLegendContentProps = React.ComponentProps<'div'> & {
85
+ payload?: LegendPayloadItem[];
86
+ verticalAlign?: 'top' | 'middle' | 'bottom';
87
+ align?: 'left' | 'center' | 'right';
88
+ /** Recharts passes layout when Legend uses layout prop */
89
+ layout?: 'horizontal' | 'vertical';
90
+ hideIcon?: boolean;
91
+ nameKey?: string;
92
+ };
93
+ declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, align, layout, nameKey, }: ChartLegendContentProps): React.JSX.Element | null;
94
+ type ChartXAxisProps = React.ComponentProps<typeof RechartsPrimitive.XAxis>;
95
+ type ChartYAxisProps = React.ComponentProps<typeof RechartsPrimitive.YAxis>;
96
+ declare function ChartXAxis({ tick, padding, ...props }: ChartXAxisProps): React.JSX.Element;
97
+ declare function ChartYAxis({ tick, width, ...props }: ChartYAxisProps): React.JSX.Element;
98
+ type ChartLineType = 'linear' | 'monotone' | 'step' | 'natural';
99
+ type ChartLineVariant = 'solid' | 'dashed';
100
+ type ChartLineProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Line>, 'type' | 'dot' | 'activeDot'> & {
101
+ /** Curve interpolation type. Default: 'monotone' */
102
+ type?: ChartLineType;
103
+ /** Line style. 'dashed' applies stroke-dasharray. Default: 'solid' */
104
+ variant?: ChartLineVariant;
105
+ /** Show data point dots. Default: true */
106
+ dot?: boolean;
107
+ /** Show highlighted dot on hover. Default: true */
108
+ activeDot?: boolean;
109
+ };
110
+ declare function ChartLine({ type, variant, dot: showDot, activeDot: showActiveDot, stroke, dataKey, ...props }: ChartLineProps): React.JSX.Element;
111
+ type ChartAreaType = 'linear' | 'monotone' | 'step' | 'natural';
112
+ type ChartAreaVariant = 'solid' | 'gradient';
113
+ type ChartAreaProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Area>, 'type' | 'dot' | 'activeDot'> & {
114
+ /** Curve interpolation type. Default: 'monotone' */
115
+ type?: ChartAreaType;
116
+ /** Fill style. 'gradient' auto-generates an SVG linearGradient. Default: 'solid' */
117
+ variant?: ChartAreaVariant;
118
+ /** Show data point dots. Default: true */
119
+ dot?: boolean;
120
+ /** Show highlighted dot on hover. Default: true */
121
+ activeDot?: boolean;
122
+ /** Fill opacity for this area (0–1). Default: 0.4 */
123
+ fillOpacity?: number;
124
+ };
125
+ declare function ChartArea({ type, variant, dot: showDot, activeDot: showActiveDot, fillOpacity, stroke, fill, dataKey, ...props }: ChartAreaProps): React.JSX.Element;
126
+ type ChartPieVariant = 'pie' | 'donut';
127
+ type ChartPieLabel = 'none' | 'outside' | 'inside';
128
+ type ChartPieLabelContent = 'value' | 'percent';
129
+ type ChartPieProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Pie>, 'label' | 'labelLine' | 'activeShape'> & {
130
+ /** 'donut' applies innerRadius automatically. Default: 'pie' */
131
+ variant?: ChartPieVariant;
132
+ /** Label position. Default: 'none' */
133
+ label?: ChartPieLabel;
134
+ /** Label display content. Default: 'value' */
135
+ labelContent?: ChartPieLabelContent;
136
+ /** Hover expand effect. Default: true */
137
+ activeShape?: boolean;
138
+ /** Override inner radius (default: 0 for pie, 60 for donut) */
139
+ innerRadius?: number;
140
+ /** Padding angle between slices (degrees). Default: 0 */
141
+ paddingAngle?: number;
142
+ /** Corner radius for slices. Default: 0 */
143
+ cornerRadius?: number;
144
+ };
145
+ declare function ChartPie({ variant, label: labelMode, labelContent, activeShape: showActiveShape, innerRadius, paddingAngle, cornerRadius, startAngle, endAngle, ...props }: ChartPieProps): React.JSX.Element;
146
+ declare const Chart: typeof ChartContainer & {
147
+ Bar: typeof ChartBar;
148
+ Line: typeof ChartLine;
149
+ Area: typeof ChartArea;
150
+ Pie: typeof ChartPie;
151
+ Tooltip: typeof ChartTooltip;
152
+ TooltipContent: typeof ChartTooltipContent;
153
+ Legend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
154
+ LegendContent: typeof ChartLegendContent;
155
+ XAxis: typeof ChartXAxis;
156
+ YAxis: typeof ChartYAxis;
157
+ Style: ({ id, config }: {
158
+ id: string;
159
+ config: ChartConfig;
160
+ }) => React.JSX.Element;
161
+ };
162
+
163
+ export { Chart, ChartArea, type ChartAreaType, type ChartAreaVariant, ChartBar, type ChartBarRadius, type ChartBarVariant, type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartLine, type ChartLineType, type ChartLineVariant, ChartPie, type ChartPieLabel, type ChartPieLabelContent, type ChartPieVariant, ChartStyle, ChartTooltip, ChartTooltipContent, ChartXAxis, ChartYAxis, useChart };
@@ -0,0 +1,163 @@
1
+ import * as React from 'react';
2
+ import * as RechartsPrimitive from 'recharts';
3
+
4
+ declare const THEMES: {
5
+ readonly light: "";
6
+ readonly dark: ".dark";
7
+ };
8
+ type ChartConfig = {
9
+ [k in string]: {
10
+ label?: React.ReactNode;
11
+ icon?: React.ComponentType;
12
+ } & ({
13
+ color?: string;
14
+ theme?: never;
15
+ } | {
16
+ color?: never;
17
+ theme: Record<keyof typeof THEMES, string>;
18
+ });
19
+ };
20
+ type ChartContextProps = {
21
+ config: ChartConfig;
22
+ hoverFade: boolean;
23
+ activeIndex: number | null;
24
+ setActiveIndex: (index: number | null) => void;
25
+ activeDataKey: string | null;
26
+ setActiveDataKey: (key: string | null) => void;
27
+ };
28
+ declare function useChart(): ChartContextProps;
29
+ declare function ChartContainer({ id, className, children, config, hoverFade, ...props }: React.ComponentProps<'div'> & {
30
+ config: ChartConfig;
31
+ /** Enable hover-to-highlight: hovered bar group stays full opacity, others fade. */
32
+ hoverFade?: boolean;
33
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
34
+ }): React.JSX.Element;
35
+ declare const ChartStyle: ({ id, config }: {
36
+ id: string;
37
+ config: ChartConfig;
38
+ }) => React.JSX.Element;
39
+ type ChartBarRadius = 'none' | 'sm' | 'base' | 'md' | 'lg';
40
+ type ChartBarVariant = 'solid' | 'outline';
41
+ type ChartBarProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Bar>, 'radius'> & {
42
+ /** Named radius token. Auto-adapts corners based on layout and stack position. */
43
+ radius?: ChartBarRadius;
44
+ /** 'horizontal' rounds the right side (away from Y-axis). Default: 'vertical' */
45
+ layout?: 'vertical' | 'horizontal';
46
+ /** 'bottom' rounds the bottom corners (base of a stack). Default: 'top' */
47
+ stackPosition?: 'top' | 'bottom';
48
+ /** 'outline' renders a thick border with a semi-transparent fill. Default: 'solid' */
49
+ variant?: ChartBarVariant;
50
+ };
51
+ declare function ChartBar({ radius, layout, stackPosition, variant, fill, stackId, ...props }: ChartBarProps): React.JSX.Element;
52
+ declare function ChartTooltip(props: React.ComponentProps<typeof RechartsPrimitive.Tooltip>): React.JSX.Element;
53
+ type TooltipPayloadItem = {
54
+ dataKey?: string | number;
55
+ name?: string;
56
+ value?: number | string;
57
+ type?: string;
58
+ color?: string;
59
+ payload?: Record<string, unknown>;
60
+ fill?: string;
61
+ };
62
+ type ChartTooltipContentProps = React.ComponentProps<'div'> & {
63
+ active?: boolean;
64
+ payload?: TooltipPayloadItem[];
65
+ label?: string;
66
+ labelFormatter?: (value: unknown, payload: TooltipPayloadItem[]) => React.ReactNode;
67
+ labelClassName?: string;
68
+ formatter?: (value: unknown, name: string, item: TooltipPayloadItem, index: number, payload: Record<string, unknown>) => React.ReactNode;
69
+ color?: string;
70
+ hideLabel?: boolean;
71
+ hideIndicator?: boolean;
72
+ indicator?: 'line' | 'dot' | 'dashed';
73
+ nameKey?: string;
74
+ labelKey?: string;
75
+ };
76
+ declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: ChartTooltipContentProps): React.JSX.Element | null;
77
+ declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
78
+ type LegendPayloadItem = {
79
+ value?: string;
80
+ type?: string;
81
+ color?: string;
82
+ dataKey?: string;
83
+ };
84
+ type ChartLegendContentProps = React.ComponentProps<'div'> & {
85
+ payload?: LegendPayloadItem[];
86
+ verticalAlign?: 'top' | 'middle' | 'bottom';
87
+ align?: 'left' | 'center' | 'right';
88
+ /** Recharts passes layout when Legend uses layout prop */
89
+ layout?: 'horizontal' | 'vertical';
90
+ hideIcon?: boolean;
91
+ nameKey?: string;
92
+ };
93
+ declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, align, layout, nameKey, }: ChartLegendContentProps): React.JSX.Element | null;
94
+ type ChartXAxisProps = React.ComponentProps<typeof RechartsPrimitive.XAxis>;
95
+ type ChartYAxisProps = React.ComponentProps<typeof RechartsPrimitive.YAxis>;
96
+ declare function ChartXAxis({ tick, padding, ...props }: ChartXAxisProps): React.JSX.Element;
97
+ declare function ChartYAxis({ tick, width, ...props }: ChartYAxisProps): React.JSX.Element;
98
+ type ChartLineType = 'linear' | 'monotone' | 'step' | 'natural';
99
+ type ChartLineVariant = 'solid' | 'dashed';
100
+ type ChartLineProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Line>, 'type' | 'dot' | 'activeDot'> & {
101
+ /** Curve interpolation type. Default: 'monotone' */
102
+ type?: ChartLineType;
103
+ /** Line style. 'dashed' applies stroke-dasharray. Default: 'solid' */
104
+ variant?: ChartLineVariant;
105
+ /** Show data point dots. Default: true */
106
+ dot?: boolean;
107
+ /** Show highlighted dot on hover. Default: true */
108
+ activeDot?: boolean;
109
+ };
110
+ declare function ChartLine({ type, variant, dot: showDot, activeDot: showActiveDot, stroke, dataKey, ...props }: ChartLineProps): React.JSX.Element;
111
+ type ChartAreaType = 'linear' | 'monotone' | 'step' | 'natural';
112
+ type ChartAreaVariant = 'solid' | 'gradient';
113
+ type ChartAreaProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Area>, 'type' | 'dot' | 'activeDot'> & {
114
+ /** Curve interpolation type. Default: 'monotone' */
115
+ type?: ChartAreaType;
116
+ /** Fill style. 'gradient' auto-generates an SVG linearGradient. Default: 'solid' */
117
+ variant?: ChartAreaVariant;
118
+ /** Show data point dots. Default: true */
119
+ dot?: boolean;
120
+ /** Show highlighted dot on hover. Default: true */
121
+ activeDot?: boolean;
122
+ /** Fill opacity for this area (0–1). Default: 0.4 */
123
+ fillOpacity?: number;
124
+ };
125
+ declare function ChartArea({ type, variant, dot: showDot, activeDot: showActiveDot, fillOpacity, stroke, fill, dataKey, ...props }: ChartAreaProps): React.JSX.Element;
126
+ type ChartPieVariant = 'pie' | 'donut';
127
+ type ChartPieLabel = 'none' | 'outside' | 'inside';
128
+ type ChartPieLabelContent = 'value' | 'percent';
129
+ type ChartPieProps = Omit<React.ComponentProps<typeof RechartsPrimitive.Pie>, 'label' | 'labelLine' | 'activeShape'> & {
130
+ /** 'donut' applies innerRadius automatically. Default: 'pie' */
131
+ variant?: ChartPieVariant;
132
+ /** Label position. Default: 'none' */
133
+ label?: ChartPieLabel;
134
+ /** Label display content. Default: 'value' */
135
+ labelContent?: ChartPieLabelContent;
136
+ /** Hover expand effect. Default: true */
137
+ activeShape?: boolean;
138
+ /** Override inner radius (default: 0 for pie, 60 for donut) */
139
+ innerRadius?: number;
140
+ /** Padding angle between slices (degrees). Default: 0 */
141
+ paddingAngle?: number;
142
+ /** Corner radius for slices. Default: 0 */
143
+ cornerRadius?: number;
144
+ };
145
+ declare function ChartPie({ variant, label: labelMode, labelContent, activeShape: showActiveShape, innerRadius, paddingAngle, cornerRadius, startAngle, endAngle, ...props }: ChartPieProps): React.JSX.Element;
146
+ declare const Chart: typeof ChartContainer & {
147
+ Bar: typeof ChartBar;
148
+ Line: typeof ChartLine;
149
+ Area: typeof ChartArea;
150
+ Pie: typeof ChartPie;
151
+ Tooltip: typeof ChartTooltip;
152
+ TooltipContent: typeof ChartTooltipContent;
153
+ Legend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
154
+ LegendContent: typeof ChartLegendContent;
155
+ XAxis: typeof ChartXAxis;
156
+ YAxis: typeof ChartYAxis;
157
+ Style: ({ id, config }: {
158
+ id: string;
159
+ config: ChartConfig;
160
+ }) => React.JSX.Element;
161
+ };
162
+
163
+ export { Chart, ChartArea, type ChartAreaType, type ChartAreaVariant, ChartBar, type ChartBarRadius, type ChartBarVariant, type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartLine, type ChartLineType, type ChartLineVariant, ChartPie, type ChartPieLabel, type ChartPieLabelContent, type ChartPieVariant, ChartStyle, ChartTooltip, ChartTooltipContent, ChartXAxis, ChartYAxis, useChart };