@mbao01/common 0.9.2 → 0.9.4
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/dist/types/components/Chart/stories/args/index.d.ts +13 -1
- package/dist/types/components/Chart/stories/args/scatterArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/args/scatterChartArgs.d.ts +2 -0
- package/dist/types/components/Chart/stories/examples/ScatterChart.d.ts +17 -0
- package/dist/types/components/Drawer/Drawer.d.ts +3 -3
- package/dist/types/components/Drawer/constants.d.ts +1 -0
- package/dist/types/components/Drawer/types.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Chart/stories/args/index.ts +29 -0
- package/src/components/Chart/stories/args/scatterArgs.ts +79 -0
- package/src/components/Chart/stories/args/scatterChartArgs.ts +6 -0
- package/src/components/Chart/stories/examples/ScatterChart.tsx +263 -0
- package/src/components/Dialog/constants.ts +1 -1
- package/src/components/Drawer/Drawer.tsx +15 -4
- package/src/components/Drawer/constants.ts +4 -0
- package/src/components/Drawer/types.ts +5 -0
- package/src/components/WidgetShell/WidgetShell.tsx +2 -0
- package/src/index.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AreaProps, BarProps, LineProps, PieProps, RadarProps, RadialBarProps, XAxisProps, YAxisProps } from 'recharts';
|
|
1
|
+
import { AreaProps, BarProps, LineProps, PieProps, RadarProps, RadialBarProps, ScatterProps, XAxisProps, YAxisProps } from 'recharts';
|
|
2
2
|
import { ArgTypes } from '@storybook/react-vite';
|
|
3
3
|
import { CartesianChartProps, PolarChartProps } from 'recharts/types/util/types';
|
|
4
4
|
import { Flatten, OmitSVGElement } from './types';
|
|
@@ -60,4 +60,16 @@ export declare const radarArgKey: {
|
|
|
60
60
|
radarChart: "radarChart";
|
|
61
61
|
};
|
|
62
62
|
export declare const radarChartArgs: ArgTypes;
|
|
63
|
+
export type ScatterChartProps = {
|
|
64
|
+
scatter: OmitSVGElement<ScatterProps>;
|
|
65
|
+
scatterChart: CartesianChartProps;
|
|
66
|
+
} & AxisProps;
|
|
67
|
+
export type ScatterChartArgs = Partial<Flatten<ScatterChartProps>> & {};
|
|
68
|
+
export declare const scatterArgKey: {
|
|
69
|
+
scatter: "scatter";
|
|
70
|
+
scatterChart: "scatterChart";
|
|
71
|
+
xAxis: "xAxis";
|
|
72
|
+
yAxis: "yAxis";
|
|
73
|
+
};
|
|
74
|
+
export declare const scatterChartArgs: ArgTypes;
|
|
63
75
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ScatterChartProps } from '../args';
|
|
2
|
+
/**
|
|
3
|
+
* ## Parent
|
|
4
|
+
*
|
|
5
|
+
* The ScatterChart can be used within: `<Chart />`
|
|
6
|
+
*
|
|
7
|
+
* ## Children
|
|
8
|
+
*
|
|
9
|
+
* The ScatterChart can be used with the following child components: `<XAxis />`, `<YAxis />`, `<ZAxis />`,
|
|
10
|
+
* `<ReferenceArea />`, `<ReferenceDot />`, `<ReferenceLine />`, `<CartesianGrid />`,
|
|
11
|
+
* `<ChartLegend />`, `<ChartTooltip />`, `<Scatter />`, `<Customized />` or valid svg elements.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ScatterChartExample: (props: ScatterChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const MultiSeriesScatterChartExample: (props: ScatterChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const BubbleScatterChartExample: (props: ScatterChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const WithLineScatterChartExample: (props: ScatterChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const ShapesScatterChartExample: (props: ScatterChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DrawerProps } from './types';
|
|
1
|
+
import { DrawerContentProps, DrawerProps } from './types';
|
|
2
2
|
declare const Drawer: {
|
|
3
3
|
({ shouldScaleBackground, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
@@ -6,7 +6,7 @@ declare const Drawer: {
|
|
|
6
6
|
Overlay: import('react').ForwardRefExoticComponent<Omit<Omit<import('@radix-ui/react-dialog').DialogOverlayProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
7
7
|
Trigger: import('react').ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogTriggerProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
8
8
|
Close: import('react').ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogCloseProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
9
|
-
Content: import('react').ForwardRefExoticComponent<Omit<
|
|
9
|
+
Content: import('react').ForwardRefExoticComponent<Omit<DrawerContentProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
10
10
|
Header: {
|
|
11
11
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
displayName: string;
|
|
@@ -22,7 +22,7 @@ declare const DrawerTrigger: import('react').ForwardRefExoticComponent<import('@
|
|
|
22
22
|
declare const DrawerPortal: typeof import('vaul').Portal;
|
|
23
23
|
declare const DrawerClose: import('react').ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogCloseProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
24
24
|
declare const DrawerOverlay: import('react').ForwardRefExoticComponent<Omit<Omit<import('@radix-ui/react-dialog').DialogOverlayProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
25
|
-
declare const DrawerContent: import('react').ForwardRefExoticComponent<Omit<
|
|
25
|
+
declare const DrawerContent: import('react').ForwardRefExoticComponent<Omit<DrawerContentProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
26
26
|
declare const DrawerHeader: {
|
|
27
27
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
28
28
|
displayName: string;
|
|
@@ -4,3 +4,4 @@ export declare const getDrawerHeaderClasses: (props?: import('class-variance-aut
|
|
|
4
4
|
export declare const getDrawerFooterClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
5
5
|
export declare const getDrawerOverlayClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
6
6
|
export declare const getDrawerTitleClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
7
|
+
export declare const getDrawerCloseClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { Drawer as DrawerPrimitive } from 'vaul';
|
|
2
2
|
export type DrawerProps = React.ComponentProps<typeof DrawerPrimitive.Root>;
|
|
3
|
+
export type DrawerContentProps = React.ComponentProps<typeof DrawerPrimitive.Content> & {
|
|
4
|
+
showClose?: boolean;
|
|
5
|
+
closeProps?: React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
6
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ export * from './components/Widget';
|
|
|
84
84
|
export * from './components/WidgetShell';
|
|
85
85
|
/** molecules */
|
|
86
86
|
export * from './components/Banner';
|
|
87
|
+
export * from './components/Drawer';
|
|
87
88
|
export * from './components/Empty';
|
|
88
89
|
export * from './components/Sidebar';
|
|
89
90
|
export * from './components/Stepper';
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
PieProps,
|
|
6
6
|
RadarProps,
|
|
7
7
|
RadialBarProps,
|
|
8
|
+
ScatterProps,
|
|
8
9
|
XAxisProps,
|
|
9
10
|
YAxisProps,
|
|
10
11
|
} from "recharts";
|
|
@@ -24,6 +25,8 @@ import { radarArgs } from "./radarArgs";
|
|
|
24
25
|
import { radarChartArgs as radarChartComponentArgs } from "./radarChartArgs";
|
|
25
26
|
import { radialBarArgs } from "./radialBarArgs";
|
|
26
27
|
import { radialBarChartArgs as radialBarChartComponentArgs } from "./radialBarChartArgs";
|
|
28
|
+
import { scatterArgs } from "./scatterArgs";
|
|
29
|
+
import { scatterChartArgs as scatterChartComponentArgs } from "./scatterChartArgs";
|
|
27
30
|
import { OmitSVGElement } from "./types";
|
|
28
31
|
import { xAxisArgs } from "./xAxisArgs";
|
|
29
32
|
import { yAxisArgs } from "./yAxisArgs";
|
|
@@ -177,3 +180,29 @@ export const radarChartArgs: ArgTypes = {
|
|
|
177
180
|
...categorizeArgs(radarChartComponentArgs, radarArgKey.radarChart),
|
|
178
181
|
...categorizeArgs(radarArgs, radarArgKey.radar),
|
|
179
182
|
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Scatter chart
|
|
186
|
+
*/
|
|
187
|
+
type ScatterArgKey = "scatter" | "scatterChart" | "xAxis" | "yAxis";
|
|
188
|
+
|
|
189
|
+
export type ScatterChartProps = {
|
|
190
|
+
scatter: OmitSVGElement<ScatterProps>;
|
|
191
|
+
scatterChart: CartesianChartProps;
|
|
192
|
+
} & AxisProps;
|
|
193
|
+
|
|
194
|
+
export type ScatterChartArgs = Partial<Flatten<ScatterChartProps>> & {};
|
|
195
|
+
|
|
196
|
+
export const scatterArgKey = {
|
|
197
|
+
scatter: "scatter",
|
|
198
|
+
scatterChart: "scatterChart",
|
|
199
|
+
xAxis: "xAxis",
|
|
200
|
+
yAxis: "yAxis",
|
|
201
|
+
} satisfies Record<string, ScatterArgKey>;
|
|
202
|
+
|
|
203
|
+
export const scatterChartArgs: ArgTypes = {
|
|
204
|
+
...categorizeArgs(scatterChartComponentArgs, scatterArgKey.scatterChart),
|
|
205
|
+
...categorizeArgs(xAxisArgs, scatterArgKey.xAxis),
|
|
206
|
+
...categorizeArgs(yAxisArgs, scatterArgKey.yAxis),
|
|
207
|
+
...categorizeArgs(scatterArgs, scatterArgKey.scatter),
|
|
208
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type ArgTypes } from "@storybook/react-vite";
|
|
2
|
+
import { generalStyleArgs, hide, labelDescription, labelSummary } from "./stylesArgs";
|
|
3
|
+
import { animationArgs } from "./animationArgs";
|
|
4
|
+
import { dataKey, zAxisId } from "./cartesianSharedArgs";
|
|
5
|
+
|
|
6
|
+
export const scatterArgs: ArgTypes = {
|
|
7
|
+
...generalStyleArgs,
|
|
8
|
+
...animationArgs,
|
|
9
|
+
dataKey,
|
|
10
|
+
zAxisId,
|
|
11
|
+
hide,
|
|
12
|
+
name: {
|
|
13
|
+
description: `The name of data. This option will be used in tooltip and legend to represent a scatter.
|
|
14
|
+
If no value was set to this option, the value of dataKey will be used alternatively.`,
|
|
15
|
+
table: {
|
|
16
|
+
type: {
|
|
17
|
+
summary: "string | number",
|
|
18
|
+
},
|
|
19
|
+
category: "General",
|
|
20
|
+
},
|
|
21
|
+
control: "text",
|
|
22
|
+
},
|
|
23
|
+
shape: {
|
|
24
|
+
description:
|
|
25
|
+
"If a string set, specified symbol will be used to show scatter item. If ReactElement, the element will be cloned to render scatter item. If a function, it will be called to render scatter item.",
|
|
26
|
+
table: {
|
|
27
|
+
type: {
|
|
28
|
+
summary: "'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | ReactElement | Function",
|
|
29
|
+
},
|
|
30
|
+
defaultValue: {
|
|
31
|
+
summary: "'circle'",
|
|
32
|
+
},
|
|
33
|
+
category: "Style",
|
|
34
|
+
},
|
|
35
|
+
control: "select",
|
|
36
|
+
options: ["circle", "cross", "diamond", "square", "star", "triangle", "wye"],
|
|
37
|
+
},
|
|
38
|
+
line: {
|
|
39
|
+
description:
|
|
40
|
+
"If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. If object set, line will be drawn which have the props merged by the internal calculated props and the option.",
|
|
41
|
+
table: {
|
|
42
|
+
type: {
|
|
43
|
+
summary: "boolean | Object | ReactElement | Function",
|
|
44
|
+
},
|
|
45
|
+
defaultValue: {
|
|
46
|
+
summary: "false",
|
|
47
|
+
},
|
|
48
|
+
category: "Style",
|
|
49
|
+
},
|
|
50
|
+
control: "boolean",
|
|
51
|
+
},
|
|
52
|
+
lineType: {
|
|
53
|
+
description: "The type of line in the scatter chart, 'joint' connects adjacent points, 'fitting' uses a fitting line.",
|
|
54
|
+
table: {
|
|
55
|
+
type: {
|
|
56
|
+
summary: "'joint' | 'fitting'",
|
|
57
|
+
},
|
|
58
|
+
defaultValue: {
|
|
59
|
+
summary: "'joint'",
|
|
60
|
+
},
|
|
61
|
+
category: "Style",
|
|
62
|
+
},
|
|
63
|
+
control: "radio",
|
|
64
|
+
options: ["joint", "fitting"],
|
|
65
|
+
},
|
|
66
|
+
label: {
|
|
67
|
+
description: labelDescription,
|
|
68
|
+
table: {
|
|
69
|
+
type: {
|
|
70
|
+
summary: labelSummary,
|
|
71
|
+
},
|
|
72
|
+
defaultValue: {
|
|
73
|
+
summary: "false",
|
|
74
|
+
},
|
|
75
|
+
category: "Style",
|
|
76
|
+
},
|
|
77
|
+
control: "boolean",
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { CartesianGrid, Scatter, ScatterChart, XAxis, YAxis, ZAxis } from "recharts";
|
|
2
|
+
import { Chart } from "../../Chart";
|
|
3
|
+
import {
|
|
4
|
+
ChartLegend,
|
|
5
|
+
ChartLegendContent,
|
|
6
|
+
ChartTooltip,
|
|
7
|
+
ChartTooltipContent,
|
|
8
|
+
} from "../../components";
|
|
9
|
+
import { type ChartConfig } from "../../types";
|
|
10
|
+
import { ScatterChartProps } from "../args";
|
|
11
|
+
|
|
12
|
+
const chartConfig = {
|
|
13
|
+
desktop: {
|
|
14
|
+
label: "Desktop",
|
|
15
|
+
color: "hsl(var(--chart-1))",
|
|
16
|
+
},
|
|
17
|
+
mobile: {
|
|
18
|
+
label: "Mobile",
|
|
19
|
+
color: "hsl(var(--chart-2))",
|
|
20
|
+
},
|
|
21
|
+
} satisfies ChartConfig;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* ## Parent
|
|
25
|
+
*
|
|
26
|
+
* The ScatterChart can be used within: `<Chart />`
|
|
27
|
+
*
|
|
28
|
+
* ## Children
|
|
29
|
+
*
|
|
30
|
+
* The ScatterChart can be used with the following child components: `<XAxis />`, `<YAxis />`, `<ZAxis />`,
|
|
31
|
+
* `<ReferenceArea />`, `<ReferenceDot />`, `<ReferenceLine />`, `<CartesianGrid />`,
|
|
32
|
+
* `<ChartLegend />`, `<ChartTooltip />`, `<Scatter />`, `<Customized />` or valid svg elements.
|
|
33
|
+
*/
|
|
34
|
+
export const ScatterChartExample = (props: ScatterChartProps) => {
|
|
35
|
+
return (
|
|
36
|
+
<Chart config={chartConfig} className="h-[300px] w-full">
|
|
37
|
+
<ScatterChart {...props.scatterChart}>
|
|
38
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
39
|
+
<XAxis {...props.xAxis} />
|
|
40
|
+
<YAxis {...props.yAxis} />
|
|
41
|
+
<ChartTooltip cursor={{ strokeDasharray: "3 3" }} content={<ChartTooltipContent />} />
|
|
42
|
+
<Scatter {...props.scatter} />
|
|
43
|
+
</ScatterChart>
|
|
44
|
+
</Chart>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const MultiSeriesScatterChartExample = (props: ScatterChartProps) => {
|
|
49
|
+
const desktopData = [
|
|
50
|
+
{ x: 100, y: 200 },
|
|
51
|
+
{ x: 120, y: 100 },
|
|
52
|
+
{ x: 170, y: 300 },
|
|
53
|
+
{ x: 140, y: 250 },
|
|
54
|
+
{ x: 150, y: 400 },
|
|
55
|
+
{ x: 110, y: 280 },
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const mobileData = [
|
|
59
|
+
{ x: 200, y: 260 },
|
|
60
|
+
{ x: 240, y: 290 },
|
|
61
|
+
{ x: 190, y: 340 },
|
|
62
|
+
{ x: 198, y: 250 },
|
|
63
|
+
{ x: 180, y: 280 },
|
|
64
|
+
{ x: 210, y: 220 },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Chart config={chartConfig} className="h-[300px] w-full">
|
|
69
|
+
<ScatterChart {...props.scatterChart}>
|
|
70
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
71
|
+
<XAxis {...props.xAxis} />
|
|
72
|
+
<YAxis {...props.yAxis} />
|
|
73
|
+
<ChartTooltip cursor={{ strokeDasharray: "3 3" }} content={<ChartTooltipContent />} />
|
|
74
|
+
<Scatter
|
|
75
|
+
{...props.scatter}
|
|
76
|
+
name="Desktop"
|
|
77
|
+
data={desktopData}
|
|
78
|
+
fill="var(--color-desktop)"
|
|
79
|
+
/>
|
|
80
|
+
<Scatter
|
|
81
|
+
{...props.scatter}
|
|
82
|
+
name="Mobile"
|
|
83
|
+
data={mobileData}
|
|
84
|
+
fill="var(--color-mobile)"
|
|
85
|
+
/>
|
|
86
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
87
|
+
</ScatterChart>
|
|
88
|
+
</Chart>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const BubbleScatterChartExample = (props: ScatterChartProps) => {
|
|
93
|
+
const chartConfig = {
|
|
94
|
+
visitors: {
|
|
95
|
+
label: "Visitors",
|
|
96
|
+
color: "hsl(var(--chart-1))",
|
|
97
|
+
},
|
|
98
|
+
} satisfies ChartConfig;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Chart config={chartConfig} className="h-[300px] w-full">
|
|
102
|
+
<ScatterChart {...props.scatterChart}>
|
|
103
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
104
|
+
<XAxis
|
|
105
|
+
dataKey="hours"
|
|
106
|
+
name="Hours Spent"
|
|
107
|
+
type="number"
|
|
108
|
+
tickLine={false}
|
|
109
|
+
axisLine={false}
|
|
110
|
+
tickMargin={8}
|
|
111
|
+
{...props.xAxis}
|
|
112
|
+
/>
|
|
113
|
+
<YAxis
|
|
114
|
+
dataKey="score"
|
|
115
|
+
name="Test Score"
|
|
116
|
+
type="number"
|
|
117
|
+
tickLine={false}
|
|
118
|
+
axisLine={false}
|
|
119
|
+
tickMargin={8}
|
|
120
|
+
{...props.yAxis}
|
|
121
|
+
/>
|
|
122
|
+
<ZAxis dataKey="students" range={[60, 400]} name="Students" />
|
|
123
|
+
<ChartTooltip cursor={{ strokeDasharray: "3 3" }} content={<ChartTooltipContent />} />
|
|
124
|
+
<Scatter
|
|
125
|
+
name="Visitors"
|
|
126
|
+
fill="var(--color-visitors)"
|
|
127
|
+
{...props.scatter}
|
|
128
|
+
/>
|
|
129
|
+
</ScatterChart>
|
|
130
|
+
</Chart>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const WithLineScatterChartExample = (props: ScatterChartProps) => {
|
|
135
|
+
const chartConfig = {
|
|
136
|
+
performance: {
|
|
137
|
+
label: "Performance",
|
|
138
|
+
color: "hsl(var(--chart-1))",
|
|
139
|
+
},
|
|
140
|
+
} satisfies ChartConfig;
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<Chart config={chartConfig} className="h-[300px] w-full">
|
|
144
|
+
<ScatterChart {...props.scatterChart}>
|
|
145
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
146
|
+
<XAxis
|
|
147
|
+
dataKey="x"
|
|
148
|
+
name="Experience (years)"
|
|
149
|
+
type="number"
|
|
150
|
+
tickLine={false}
|
|
151
|
+
axisLine={false}
|
|
152
|
+
tickMargin={8}
|
|
153
|
+
{...props.xAxis}
|
|
154
|
+
/>
|
|
155
|
+
<YAxis
|
|
156
|
+
dataKey="y"
|
|
157
|
+
name="Salary ($k)"
|
|
158
|
+
type="number"
|
|
159
|
+
tickLine={false}
|
|
160
|
+
axisLine={false}
|
|
161
|
+
tickMargin={8}
|
|
162
|
+
{...props.yAxis}
|
|
163
|
+
/>
|
|
164
|
+
<ChartTooltip cursor={{ strokeDasharray: "3 3" }} content={<ChartTooltipContent />} />
|
|
165
|
+
<Scatter
|
|
166
|
+
name="Performance"
|
|
167
|
+
fill="var(--color-performance)"
|
|
168
|
+
line={{ stroke: "var(--color-performance)", strokeWidth: 2 }}
|
|
169
|
+
lineType="fitting"
|
|
170
|
+
{...props.scatter}
|
|
171
|
+
/>
|
|
172
|
+
</ScatterChart>
|
|
173
|
+
</Chart>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const ShapesScatterChartExample = (props: ScatterChartProps) => {
|
|
178
|
+
const chartConfig = {
|
|
179
|
+
series1: {
|
|
180
|
+
label: "Series A",
|
|
181
|
+
color: "hsl(var(--chart-1))",
|
|
182
|
+
},
|
|
183
|
+
series2: {
|
|
184
|
+
label: "Series B",
|
|
185
|
+
color: "hsl(var(--chart-2))",
|
|
186
|
+
},
|
|
187
|
+
series3: {
|
|
188
|
+
label: "Series C",
|
|
189
|
+
color: "hsl(var(--chart-3))",
|
|
190
|
+
},
|
|
191
|
+
} satisfies ChartConfig;
|
|
192
|
+
|
|
193
|
+
const series1Data = [
|
|
194
|
+
{ x: 10, y: 30 },
|
|
195
|
+
{ x: 30, y: 50 },
|
|
196
|
+
{ x: 50, y: 70 },
|
|
197
|
+
{ x: 70, y: 40 },
|
|
198
|
+
{ x: 90, y: 60 },
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
const series2Data = [
|
|
202
|
+
{ x: 20, y: 80 },
|
|
203
|
+
{ x: 40, y: 20 },
|
|
204
|
+
{ x: 60, y: 50 },
|
|
205
|
+
{ x: 80, y: 90 },
|
|
206
|
+
{ x: 100, y: 30 },
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
const series3Data = [
|
|
210
|
+
{ x: 15, y: 45 },
|
|
211
|
+
{ x: 35, y: 65 },
|
|
212
|
+
{ x: 55, y: 25 },
|
|
213
|
+
{ x: 75, y: 85 },
|
|
214
|
+
{ x: 95, y: 55 },
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<Chart config={chartConfig} className="h-[300px] w-full">
|
|
219
|
+
<ScatterChart {...props.scatterChart}>
|
|
220
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
221
|
+
<XAxis
|
|
222
|
+
dataKey="x"
|
|
223
|
+
type="number"
|
|
224
|
+
tickLine={false}
|
|
225
|
+
axisLine={false}
|
|
226
|
+
tickMargin={8}
|
|
227
|
+
{...props.xAxis}
|
|
228
|
+
/>
|
|
229
|
+
<YAxis
|
|
230
|
+
dataKey="y"
|
|
231
|
+
type="number"
|
|
232
|
+
tickLine={false}
|
|
233
|
+
axisLine={false}
|
|
234
|
+
tickMargin={8}
|
|
235
|
+
{...props.yAxis}
|
|
236
|
+
/>
|
|
237
|
+
<ChartTooltip cursor={{ strokeDasharray: "3 3" }} content={<ChartTooltipContent />} />
|
|
238
|
+
<Scatter
|
|
239
|
+
name="Series A"
|
|
240
|
+
data={series1Data}
|
|
241
|
+
fill="var(--color-series1)"
|
|
242
|
+
shape="circle"
|
|
243
|
+
{...props.scatter}
|
|
244
|
+
/>
|
|
245
|
+
<Scatter
|
|
246
|
+
name="Series B"
|
|
247
|
+
data={series2Data}
|
|
248
|
+
fill="var(--color-series2)"
|
|
249
|
+
shape="diamond"
|
|
250
|
+
{...props.scatter}
|
|
251
|
+
/>
|
|
252
|
+
<Scatter
|
|
253
|
+
name="Series C"
|
|
254
|
+
data={series3Data}
|
|
255
|
+
fill="var(--color-series3)"
|
|
256
|
+
shape="triangle"
|
|
257
|
+
{...props.scatter}
|
|
258
|
+
/>
|
|
259
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
260
|
+
</ScatterChart>
|
|
261
|
+
</Chart>
|
|
262
|
+
);
|
|
263
|
+
};
|
|
@@ -41,5 +41,5 @@ export const getDialogTitleClasses = cva("text-lg font-semibold leading-none tra
|
|
|
41
41
|
export const getDialogDescriptionClasses = cva("text-sm text-muted-foreground");
|
|
42
42
|
|
|
43
43
|
export const getDialogCloseClasses = cva(
|
|
44
|
-
"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-all duration-200 hover:opacity-100 hover:rotate-90 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
44
|
+
"absolute right-4 top-4 cursor-pointer rounded-xs opacity-70 ring-offset-background transition-all duration-200 hover:opacity-100 hover:rotate-90 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
45
45
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
+
import { XIcon } from "lucide-react";
|
|
4
5
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
5
6
|
import { cn } from "../../utilities";
|
|
6
7
|
import {
|
|
8
|
+
getDrawerCloseClasses,
|
|
7
9
|
getDrawerContentClasses,
|
|
8
10
|
getDrawerDescriptionClasses,
|
|
9
11
|
getDrawerFooterClasses,
|
|
@@ -11,7 +13,7 @@ import {
|
|
|
11
13
|
getDrawerOverlayClasses,
|
|
12
14
|
getDrawerTitleClasses,
|
|
13
15
|
} from "./constants";
|
|
14
|
-
import { DrawerProps } from "./types";
|
|
16
|
+
import { DrawerContentProps, DrawerProps } from "./types";
|
|
15
17
|
|
|
16
18
|
const Drawer = ({ shouldScaleBackground = true, ...props }: DrawerProps) => (
|
|
17
19
|
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
|
@@ -38,8 +40,8 @@ DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
|
38
40
|
|
|
39
41
|
const DrawerContent = forwardRef<
|
|
40
42
|
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
41
|
-
|
|
42
|
-
>(({ className, children, ...props }, ref) => (
|
|
43
|
+
DrawerContentProps
|
|
44
|
+
>(({ className, children, showClose, closeProps, ...props }, ref) => (
|
|
43
45
|
<DrawerPortal>
|
|
44
46
|
<DrawerOverlay />
|
|
45
47
|
<DrawerPrimitive.Content
|
|
@@ -47,8 +49,17 @@ const DrawerContent = forwardRef<
|
|
|
47
49
|
className={cn(getDrawerContentClasses(), className)}
|
|
48
50
|
{...props}
|
|
49
51
|
>
|
|
50
|
-
<div className="mx-auto mt-4 h-2 w-[80px] rounded-full bg-base-300" />
|
|
52
|
+
<div className="mx-auto mt-4 h-2 min-h-2 w-[80px] rounded-full bg-base-300" />
|
|
51
53
|
{children}
|
|
54
|
+
{showClose ? (
|
|
55
|
+
<DrawerPrimitive.Close
|
|
56
|
+
{...closeProps}
|
|
57
|
+
className={cn(getDrawerCloseClasses(), closeProps?.className)}
|
|
58
|
+
>
|
|
59
|
+
<XIcon className="h-4 w-4" />
|
|
60
|
+
<span className="sr-only">Close</span>
|
|
61
|
+
</DrawerPrimitive.Close>
|
|
62
|
+
) : null}
|
|
52
63
|
</DrawerPrimitive.Content>
|
|
53
64
|
</DrawerPortal>
|
|
54
65
|
));
|
|
@@ -13,3 +13,7 @@ export const getDrawerFooterClasses = cva("mt-auto flex flex-col gap-2 p-4");
|
|
|
13
13
|
export const getDrawerOverlayClasses = cva("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm");
|
|
14
14
|
|
|
15
15
|
export const getDrawerTitleClasses = cva("text-lg font-semibold leading-none tracking-tight");
|
|
16
|
+
|
|
17
|
+
export const getDrawerCloseClasses = cva(
|
|
18
|
+
"absolute right-4 top-4 cursor-pointer rounded-xs opacity-70 ring-offset-background transition-all duration-200 hover:opacity-100 hover:rotate-90 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
19
|
+
);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
2
2
|
|
|
3
3
|
export type DrawerProps = React.ComponentProps<typeof DrawerPrimitive.Root>;
|
|
4
|
+
|
|
5
|
+
export type DrawerContentProps = React.ComponentProps<typeof DrawerPrimitive.Content> & {
|
|
6
|
+
showClose?: boolean;
|
|
7
|
+
closeProps?: React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
8
|
+
};
|
|
@@ -69,6 +69,8 @@ const WidgetShellError = ({
|
|
|
69
69
|
</div>
|
|
70
70
|
{onRetry && (
|
|
71
71
|
<Button
|
|
72
|
+
outline
|
|
73
|
+
size="sm"
|
|
72
74
|
type="button"
|
|
73
75
|
onClick={onRetry}
|
|
74
76
|
className="inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors duration-200 hover:bg-base-200"
|
package/src/index.ts
CHANGED
|
@@ -92,6 +92,7 @@ export * from "./components/WidgetShell";
|
|
|
92
92
|
|
|
93
93
|
/** molecules */
|
|
94
94
|
export * from "./components/Banner";
|
|
95
|
+
export * from "./components/Drawer";
|
|
95
96
|
export * from "./components/Empty";
|
|
96
97
|
export * from "./components/Sidebar";
|
|
97
98
|
export * from "./components/Stepper";
|