@luanthnh/cntt-ui 0.1.7 → 0.1.9
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 +5 -1
- package/.storybook/globals.d.ts +0 -1
- package/.storybook/main.ts +0 -29
- package/.storybook/preview.ts +0 -32
- package/assets/fonts/Montserrat-Black.eot +0 -0
- package/assets/fonts/Montserrat-Black.ttf +0 -0
- package/assets/fonts/Montserrat-Black.woff +0 -0
- package/assets/fonts/Montserrat-Black.woff2 +0 -0
- package/assets/fonts/Montserrat-BlackItalic.eot +0 -0
- package/assets/fonts/Montserrat-BlackItalic.ttf +0 -0
- package/assets/fonts/Montserrat-BlackItalic.woff +0 -0
- package/assets/fonts/Montserrat-BlackItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-Bold.eot +0 -0
- package/assets/fonts/Montserrat-Bold.ttf +0 -0
- package/assets/fonts/Montserrat-Bold.woff +0 -0
- package/assets/fonts/Montserrat-Bold.woff2 +0 -0
- package/assets/fonts/Montserrat-BoldItalic.eot +0 -0
- package/assets/fonts/Montserrat-BoldItalic.ttf +0 -0
- package/assets/fonts/Montserrat-BoldItalic.woff +0 -0
- package/assets/fonts/Montserrat-BoldItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-ExtraBold.eot +0 -0
- package/assets/fonts/Montserrat-ExtraBold.ttf +0 -0
- package/assets/fonts/Montserrat-ExtraBold.woff +0 -0
- package/assets/fonts/Montserrat-ExtraBold.woff2 +0 -0
- package/assets/fonts/Montserrat-ExtraBoldItalic.eot +0 -0
- package/assets/fonts/Montserrat-ExtraBoldItalic.ttf +0 -0
- package/assets/fonts/Montserrat-ExtraBoldItalic.woff +0 -0
- package/assets/fonts/Montserrat-ExtraBoldItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-ExtraLight.eot +0 -0
- package/assets/fonts/Montserrat-ExtraLight.ttf +0 -0
- package/assets/fonts/Montserrat-ExtraLight.woff +0 -0
- package/assets/fonts/Montserrat-ExtraLight.woff2 +0 -0
- package/assets/fonts/Montserrat-ExtraLightItalic.eot +0 -0
- package/assets/fonts/Montserrat-ExtraLightItalic.ttf +0 -0
- package/assets/fonts/Montserrat-ExtraLightItalic.woff +0 -0
- package/assets/fonts/Montserrat-ExtraLightItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-Italic.eot +0 -0
- package/assets/fonts/Montserrat-Italic.ttf +0 -0
- package/assets/fonts/Montserrat-Italic.woff +0 -0
- package/assets/fonts/Montserrat-Italic.woff2 +0 -0
- package/assets/fonts/Montserrat-Light.eot +0 -0
- package/assets/fonts/Montserrat-Light.ttf +0 -0
- package/assets/fonts/Montserrat-Light.woff +0 -0
- package/assets/fonts/Montserrat-Light.woff2 +0 -0
- package/assets/fonts/Montserrat-LightItalic.eot +0 -0
- package/assets/fonts/Montserrat-LightItalic.ttf +0 -0
- package/assets/fonts/Montserrat-LightItalic.woff +0 -0
- package/assets/fonts/Montserrat-LightItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-Medium.eot +0 -0
- package/assets/fonts/Montserrat-Medium.ttf +0 -0
- package/assets/fonts/Montserrat-Medium.woff +0 -0
- package/assets/fonts/Montserrat-Medium.woff2 +0 -0
- package/assets/fonts/Montserrat-MediumItalic.eot +0 -0
- package/assets/fonts/Montserrat-MediumItalic.ttf +0 -0
- package/assets/fonts/Montserrat-MediumItalic.woff +0 -0
- package/assets/fonts/Montserrat-MediumItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-Regular.eot +0 -0
- package/assets/fonts/Montserrat-Regular.ttf +0 -0
- package/assets/fonts/Montserrat-Regular.woff +0 -0
- package/assets/fonts/Montserrat-Regular.woff2 +0 -0
- package/assets/fonts/Montserrat-SemiBold.eot +0 -0
- package/assets/fonts/Montserrat-SemiBold.ttf +0 -0
- package/assets/fonts/Montserrat-SemiBold.woff +0 -0
- package/assets/fonts/Montserrat-SemiBold.woff2 +0 -0
- package/assets/fonts/Montserrat-SemiBoldItalic.eot +0 -0
- package/assets/fonts/Montserrat-SemiBoldItalic.ttf +0 -0
- package/assets/fonts/Montserrat-SemiBoldItalic.woff +0 -0
- package/assets/fonts/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-Thin.eot +0 -0
- package/assets/fonts/Montserrat-Thin.ttf +0 -0
- package/assets/fonts/Montserrat-Thin.woff +0 -0
- package/assets/fonts/Montserrat-Thin.woff2 +0 -0
- package/assets/fonts/Montserrat-ThinItalic.eot +0 -0
- package/assets/fonts/Montserrat-ThinItalic.ttf +0 -0
- package/assets/fonts/Montserrat-ThinItalic.woff +0 -0
- package/assets/fonts/Montserrat-ThinItalic.woff2 +0 -0
- package/assets/fonts/Montserrat-Variable.eot +0 -0
- package/assets/fonts/Montserrat-Variable.ttf +0 -0
- package/assets/fonts/Montserrat-Variable.woff +0 -0
- package/assets/fonts/Montserrat-Variable.woff2 +0 -0
- package/assets/fonts/Montserrat-VariableItalic.eot +0 -0
- package/assets/fonts/Montserrat-VariableItalic.ttf +0 -0
- package/assets/fonts/Montserrat-VariableItalic.woff +0 -0
- package/assets/fonts/Montserrat-VariableItalic.woff2 +0 -0
- package/assets/icons/arrow-left.svg +0 -1
- package/assets/icons/file.svg +0 -1
- package/assets/icons/globe.svg +0 -1
- package/assets/icons/logo-line.svg +0 -1
- package/assets/icons/next.svg +0 -1
- package/assets/icons/panel-left-expand.svg +0 -1
- package/assets/icons/placeholder.svg +0 -57
- package/assets/icons/vercel.svg +0 -1
- package/assets/icons/window.svg +0 -1
- package/assets/lotties/error-404.json +0 -19642
- package/assets/lotties/error.json +0 -2414
- package/assets/lotties/loader.json +0 -305
- package/components/Welcome.mdx +0 -74
- package/components/lenis/index.tsx +0 -48
- package/components/motion/auto-height.tsx +0 -56
- package/components/motion/cursor.tsx +0 -108
- package/components/motion/highlight.tsx +0 -605
- package/components/motion/number-ticker.tsx +0 -55
- package/components/motion/slot.tsx +0 -106
- package/components/motion/waves.tsx +0 -417
- package/components/primitives/tabs.tsx +0 -174
- package/components/ui/Accordion/index.stories.tsx +0 -39
- package/components/ui/Accordion/index.tsx +0 -170
- package/components/ui/Alert/index.stories.tsx +0 -39
- package/components/ui/Alert/index.tsx +0 -60
- package/components/ui/AlertDialog/index.stories.tsx +0 -47
- package/components/ui/AlertDialog/index.tsx +0 -172
- package/components/ui/AspectRatio/index.stories.tsx +0 -40
- package/components/ui/AspectRatio/index.tsx +0 -9
- package/components/ui/Avatar/index.stories.tsx +0 -39
- package/components/ui/Avatar/index.tsx +0 -44
- package/components/ui/Badge/index.stories.tsx +0 -64
- package/components/ui/Badge/index.tsx +0 -46
- package/components/ui/Breadcrumb/index.stories.tsx +0 -64
- package/components/ui/Breadcrumb/index.tsx +0 -102
- package/components/ui/Button/index.stories.tsx +0 -232
- package/components/ui/Button/index.tsx +0 -114
- package/components/ui/Calendar/index.stories.tsx +0 -20
- package/components/ui/Calendar/index.tsx +0 -149
- package/components/ui/Card/index.stories.tsx +0 -39
- package/components/ui/Card/index.tsx +0 -65
- package/components/ui/Carousel/index.stories.tsx +0 -37
- package/components/ui/Carousel/index.tsx +0 -242
- package/components/ui/Chart/index.stories.tsx +0 -53
- package/components/ui/Chart/index.tsx +0 -322
- package/components/ui/Checkbox/index.stories.tsx +0 -56
- package/components/ui/Checkbox/index.tsx +0 -167
- package/components/ui/CircleProcess/index.stories.tsx +0 -29
- package/components/ui/CircleProcess/index.tsx +0 -50
- package/components/ui/Collapsible/index.stories.tsx +0 -33
- package/components/ui/Collapsible/index.tsx +0 -124
- package/components/ui/Command/index.stories.tsx +0 -65
- package/components/ui/Command/index.tsx +0 -161
- package/components/ui/Container/index.stories.tsx +0 -22
- package/components/ui/Container/index.tsx +0 -30
- package/components/ui/ContextMenu/index.stories.tsx +0 -51
- package/components/ui/ContextMenu/index.tsx +0 -224
- package/components/ui/Dialog/index.stories.tsx +0 -44
- package/components/ui/Dialog/index.tsx +0 -156
- package/components/ui/Drawer/index.stories.tsx +0 -54
- package/components/ui/Drawer/index.tsx +0 -124
- package/components/ui/DropdownMenu/index.stories.tsx +0 -83
- package/components/ui/DropdownMenu/index.tsx +0 -231
- package/components/ui/Dropzone/index.stories.tsx +0 -18
- package/components/ui/Dropzone/index.tsx +0 -47
- package/components/ui/Form/date-field.tsx +0 -77
- package/components/ui/Form/index.stories.tsx +0 -67
- package/components/ui/Form/index.tsx +0 -188
- package/components/ui/Form/select-field.tsx +0 -55
- package/components/ui/Form/text-area-field.tsx +0 -37
- package/components/ui/Form/text-field.tsx +0 -72
- package/components/ui/HStack/index.stories.tsx +0 -48
- package/components/ui/HStack/index.tsx +0 -73
- package/components/ui/HoverCard/index.stories.tsx +0 -38
- package/components/ui/HoverCard/index.tsx +0 -38
- package/components/ui/Icons/index.stories.tsx +0 -27
- package/components/ui/Icons/index.tsx +0 -33
- package/components/ui/ImageWithFallback/index.stories.tsx +0 -32
- package/components/ui/ImageWithFallback/index.tsx +0 -34
- package/components/ui/Input/index.stories.tsx +0 -47
- package/components/ui/Input/index.tsx +0 -21
- package/components/ui/InputOtp/index.stories.tsx +0 -35
- package/components/ui/InputOtp/index.tsx +0 -70
- package/components/ui/Label/index.stories.tsx +0 -18
- package/components/ui/Label/index.tsx +0 -21
- package/components/ui/Marquee/index.stories.tsx +0 -71
- package/components/ui/Marquee/index.tsx +0 -65
- package/components/ui/Menubar/index.stories.tsx +0 -116
- package/components/ui/Menubar/index.tsx +0 -252
- package/components/ui/NavigationMenu/index.stories.tsx +0 -112
- package/components/ui/NavigationMenu/index.tsx +0 -185
- package/components/ui/NoData/index.stories.tsx +0 -24
- package/components/ui/NoData/index.tsx +0 -19
- package/components/ui/Pagination/index.stories.tsx +0 -53
- package/components/ui/Pagination/index.tsx +0 -114
- package/components/ui/Popover/index.stories.tsx +0 -31
- package/components/ui/Popover/index.tsx +0 -42
- package/components/ui/Progress/index.stories.tsx +0 -35
- package/components/ui/Progress/index.tsx +0 -28
- package/components/ui/RadioGroup/index.stories.tsx +0 -28
- package/components/ui/RadioGroup/index.tsx +0 -45
- package/components/ui/Resizable/index.stories.tsx +0 -44
- package/components/ui/Resizable/index.tsx +0 -54
- package/components/ui/ScrollArea/index.stories.tsx +0 -31
- package/components/ui/ScrollArea/index.tsx +0 -56
- package/components/ui/Select/index.stories.tsx +0 -64
- package/components/ui/Select/index.tsx +0 -170
- package/components/ui/Separator/index.stories.tsx +0 -31
- package/components/ui/Separator/index.tsx +0 -28
- package/components/ui/Sheet/index.stories.tsx +0 -45
- package/components/ui/Sheet/index.tsx +0 -130
- package/components/ui/Sidebar/index.stories.tsx +0 -82
- package/components/ui/Sidebar/index.tsx +0 -676
- package/components/ui/Skeleton/index.stories.tsx +0 -36
- package/components/ui/Skeleton/index.tsx +0 -13
- package/components/ui/Slider/index.stories.tsx +0 -48
- package/components/ui/Slider/index.tsx +0 -82
- package/components/ui/Slot/index.stories.tsx +0 -29
- package/components/ui/Slot/index.tsx +0 -106
- package/components/ui/Sonner/index.stories.tsx +0 -36
- package/components/ui/Sonner/index.tsx +0 -31
- package/components/ui/Switch/index.stories.tsx +0 -33
- package/components/ui/Switch/index.tsx +0 -28
- package/components/ui/Table/index.stories.tsx +0 -74
- package/components/ui/Table/index.tsx +0 -95
- package/components/ui/Tabs/index.stories.tsx +0 -38
- package/components/ui/Tabs/index.tsx +0 -78
- package/components/ui/Text/index.stories.tsx +0 -53
- package/components/ui/Text/index.tsx +0 -138
- package/components/ui/Textarea/index.stories.tsx +0 -25
- package/components/ui/Textarea/index.tsx +0 -18
- package/components/ui/Toggle/index.stories.tsx +0 -52
- package/components/ui/Toggle/index.tsx +0 -46
- package/components/ui/ToggleGroup/index.stories.tsx +0 -52
- package/components/ui/ToggleGroup/index.tsx +0 -69
- package/components/ui/Tooltip/index.stories.tsx +0 -29
- package/components/ui/Tooltip/index.tsx +0 -35
- package/components/ui/VStack/index.stories.tsx +0 -45
- package/components/ui/VStack/index.tsx +0 -69
- package/components/ui/colors.stories.tsx +0 -148
- package/eslint.config.js +0 -10
- package/hooks/index.ts +0 -3
- package/hooks/use-auto-height.tsx +0 -99
- package/hooks/use-controlled-state.tsx +0 -32
- package/hooks/use-mobile.ts +0 -19
- package/index.ts +0 -58
- package/lib/get-strict-context.ts +0 -15
- package/lib/utils.ts +0 -10
- package/scripts/generate-exports.ts +0 -32
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -11
- package/types/svg.d.ts +0 -10
- package/vercel.json +0 -5
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as RechartsPrimitive from 'recharts';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
9
|
-
const THEMES = { light: '', dark: '.dark' } as const;
|
|
10
|
-
|
|
11
|
-
export type ChartConfig = {
|
|
12
|
-
[k in string]: {
|
|
13
|
-
label?: React.ReactNode;
|
|
14
|
-
icon?: React.ComponentType;
|
|
15
|
-
} & (
|
|
16
|
-
| { color?: string; theme?: never }
|
|
17
|
-
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type ChartContextProps = {
|
|
22
|
-
config: ChartConfig;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
26
|
-
|
|
27
|
-
function useChart() {
|
|
28
|
-
const context = React.useContext(ChartContext);
|
|
29
|
-
|
|
30
|
-
if (!context) {
|
|
31
|
-
throw new Error('useChart must be used within a <ChartContainer />');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return context;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function ChartContainer({
|
|
38
|
-
id,
|
|
39
|
-
className,
|
|
40
|
-
children,
|
|
41
|
-
config,
|
|
42
|
-
...props
|
|
43
|
-
}: React.ComponentProps<'div'> & {
|
|
44
|
-
config: ChartConfig;
|
|
45
|
-
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
|
|
46
|
-
}) {
|
|
47
|
-
const uniqueId = React.useId();
|
|
48
|
-
const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<ChartContext.Provider value={{ config }}>
|
|
52
|
-
<div
|
|
53
|
-
data-slot="chart"
|
|
54
|
-
data-chart={chartId}
|
|
55
|
-
className={cn(
|
|
56
|
-
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
57
|
-
className,
|
|
58
|
-
)}
|
|
59
|
-
{...props}
|
|
60
|
-
>
|
|
61
|
-
<ChartStyle id={chartId} config={config} />
|
|
62
|
-
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
|
63
|
-
</div>
|
|
64
|
-
</ChartContext.Provider>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
69
|
-
const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
|
|
70
|
-
|
|
71
|
-
if (!colorConfig.length) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<style
|
|
77
|
-
dangerouslySetInnerHTML={{
|
|
78
|
-
__html: Object.entries(THEMES)
|
|
79
|
-
.map(
|
|
80
|
-
([theme, prefix]) => `
|
|
81
|
-
${prefix} [data-chart=${id}] {
|
|
82
|
-
${colorConfig
|
|
83
|
-
.map(([key, itemConfig]) => {
|
|
84
|
-
const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
|
|
85
|
-
return color ? ` --color-${key}: ${color};` : null;
|
|
86
|
-
})
|
|
87
|
-
.join('\n')}
|
|
88
|
-
}
|
|
89
|
-
`,
|
|
90
|
-
)
|
|
91
|
-
.join('\n'),
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
98
|
-
|
|
99
|
-
function ChartTooltipContent({
|
|
100
|
-
active,
|
|
101
|
-
payload,
|
|
102
|
-
className,
|
|
103
|
-
indicator = 'dot',
|
|
104
|
-
hideLabel = false,
|
|
105
|
-
hideIndicator = false,
|
|
106
|
-
label,
|
|
107
|
-
labelFormatter,
|
|
108
|
-
labelClassName,
|
|
109
|
-
formatter,
|
|
110
|
-
color,
|
|
111
|
-
nameKey,
|
|
112
|
-
labelKey,
|
|
113
|
-
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
114
|
-
React.ComponentProps<'div'> & {
|
|
115
|
-
hideLabel?: boolean;
|
|
116
|
-
hideIndicator?: boolean;
|
|
117
|
-
indicator?: 'line' | 'dot' | 'dashed';
|
|
118
|
-
nameKey?: string;
|
|
119
|
-
labelKey?: string;
|
|
120
|
-
}) {
|
|
121
|
-
const { config } = useChart();
|
|
122
|
-
|
|
123
|
-
const tooltipLabel = React.useMemo(() => {
|
|
124
|
-
if (hideLabel || !payload?.length) {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const [item] = payload;
|
|
129
|
-
const key = `${labelKey || item?.dataKey || item?.name || 'value'}`;
|
|
130
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
131
|
-
const value =
|
|
132
|
-
!labelKey && typeof label === 'string'
|
|
133
|
-
? config[label as keyof typeof config]?.label || label
|
|
134
|
-
: itemConfig?.label;
|
|
135
|
-
|
|
136
|
-
if (labelFormatter) {
|
|
137
|
-
return (
|
|
138
|
-
<div className={cn('font-medium', labelClassName)}>{labelFormatter(value, payload)}</div>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (!value) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return <div className={cn('font-medium', labelClassName)}>{value}</div>;
|
|
147
|
-
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
148
|
-
|
|
149
|
-
if (!active || !payload?.length) {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const nestLabel = payload.length === 1 && indicator !== 'dot';
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<div
|
|
157
|
-
className={cn(
|
|
158
|
-
'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
|
|
159
|
-
className,
|
|
160
|
-
)}
|
|
161
|
-
>
|
|
162
|
-
{!nestLabel ? tooltipLabel : null}
|
|
163
|
-
<div className="grid gap-1.5">
|
|
164
|
-
{payload.map((item, index) => {
|
|
165
|
-
const key = `${nameKey || item.name || item.dataKey || 'value'}`;
|
|
166
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
167
|
-
const indicatorColor = color || item.payload.fill || item.color;
|
|
168
|
-
|
|
169
|
-
return (
|
|
170
|
-
<div
|
|
171
|
-
key={item.dataKey}
|
|
172
|
-
className={cn(
|
|
173
|
-
'[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5',
|
|
174
|
-
indicator === 'dot' && 'items-center',
|
|
175
|
-
)}
|
|
176
|
-
>
|
|
177
|
-
{formatter && item?.value !== undefined && item.name ? (
|
|
178
|
-
formatter(item.value, item.name, item, index, item.payload)
|
|
179
|
-
) : (
|
|
180
|
-
<>
|
|
181
|
-
{itemConfig?.icon ? (
|
|
182
|
-
<itemConfig.icon />
|
|
183
|
-
) : (
|
|
184
|
-
!hideIndicator && (
|
|
185
|
-
<div
|
|
186
|
-
className={cn(
|
|
187
|
-
'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
|
|
188
|
-
{
|
|
189
|
-
'h-2.5 w-2.5': indicator === 'dot',
|
|
190
|
-
'w-1': indicator === 'line',
|
|
191
|
-
'w-0 border-[1.5px] border-dashed bg-transparent':
|
|
192
|
-
indicator === 'dashed',
|
|
193
|
-
'my-0.5': nestLabel && indicator === 'dashed',
|
|
194
|
-
},
|
|
195
|
-
)}
|
|
196
|
-
style={
|
|
197
|
-
{
|
|
198
|
-
'--color-bg': indicatorColor,
|
|
199
|
-
'--color-border': indicatorColor,
|
|
200
|
-
} as React.CSSProperties
|
|
201
|
-
}
|
|
202
|
-
/>
|
|
203
|
-
)
|
|
204
|
-
)}
|
|
205
|
-
<div
|
|
206
|
-
className={cn(
|
|
207
|
-
'flex flex-1 justify-between leading-none',
|
|
208
|
-
nestLabel ? 'items-end' : 'items-center',
|
|
209
|
-
)}
|
|
210
|
-
>
|
|
211
|
-
<div className="grid gap-1.5">
|
|
212
|
-
{nestLabel ? tooltipLabel : null}
|
|
213
|
-
<span className="text-muted-foreground">
|
|
214
|
-
{itemConfig?.label || item.name}
|
|
215
|
-
</span>
|
|
216
|
-
</div>
|
|
217
|
-
{item.value && (
|
|
218
|
-
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
219
|
-
{item.value.toLocaleString()}
|
|
220
|
-
</span>
|
|
221
|
-
)}
|
|
222
|
-
</div>
|
|
223
|
-
</>
|
|
224
|
-
)}
|
|
225
|
-
</div>
|
|
226
|
-
);
|
|
227
|
-
})}
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const ChartLegend = RechartsPrimitive.Legend;
|
|
234
|
-
|
|
235
|
-
function ChartLegendContent({
|
|
236
|
-
className,
|
|
237
|
-
hideIcon = false,
|
|
238
|
-
payload,
|
|
239
|
-
verticalAlign = 'bottom',
|
|
240
|
-
nameKey,
|
|
241
|
-
}: React.ComponentProps<'div'> &
|
|
242
|
-
Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {
|
|
243
|
-
hideIcon?: boolean;
|
|
244
|
-
nameKey?: string;
|
|
245
|
-
}) {
|
|
246
|
-
const { config } = useChart();
|
|
247
|
-
|
|
248
|
-
if (!payload?.length) {
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return (
|
|
253
|
-
<div
|
|
254
|
-
className={cn(
|
|
255
|
-
'flex items-center justify-center gap-4',
|
|
256
|
-
verticalAlign === 'top' ? 'pb-3' : 'pt-3',
|
|
257
|
-
className,
|
|
258
|
-
)}
|
|
259
|
-
>
|
|
260
|
-
{payload.map((item) => {
|
|
261
|
-
const key = `${nameKey || item.dataKey || 'value'}`;
|
|
262
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
263
|
-
|
|
264
|
-
return (
|
|
265
|
-
<div
|
|
266
|
-
key={item.value}
|
|
267
|
-
className={cn(
|
|
268
|
-
'[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3',
|
|
269
|
-
)}
|
|
270
|
-
>
|
|
271
|
-
{itemConfig?.icon && !hideIcon ? (
|
|
272
|
-
<itemConfig.icon />
|
|
273
|
-
) : (
|
|
274
|
-
<div
|
|
275
|
-
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
276
|
-
style={{
|
|
277
|
-
backgroundColor: item.color,
|
|
278
|
-
}}
|
|
279
|
-
/>
|
|
280
|
-
)}
|
|
281
|
-
{itemConfig?.label}
|
|
282
|
-
</div>
|
|
283
|
-
);
|
|
284
|
-
})}
|
|
285
|
-
</div>
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// Helper to extract item config from a payload.
|
|
290
|
-
function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
|
|
291
|
-
if (typeof payload !== 'object' || payload === null) {
|
|
292
|
-
return undefined;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const payloadPayload =
|
|
296
|
-
'payload' in payload && typeof payload.payload === 'object' && payload.payload !== null
|
|
297
|
-
? payload.payload
|
|
298
|
-
: undefined;
|
|
299
|
-
|
|
300
|
-
let configLabelKey: string = key;
|
|
301
|
-
|
|
302
|
-
if (key in payload && typeof payload[key as keyof typeof payload] === 'string') {
|
|
303
|
-
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
304
|
-
} else if (
|
|
305
|
-
payloadPayload &&
|
|
306
|
-
key in payloadPayload &&
|
|
307
|
-
typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
|
|
308
|
-
) {
|
|
309
|
-
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export {
|
|
316
|
-
ChartContainer,
|
|
317
|
-
ChartTooltip,
|
|
318
|
-
ChartTooltipContent,
|
|
319
|
-
ChartLegend,
|
|
320
|
-
ChartLegendContent,
|
|
321
|
-
ChartStyle,
|
|
322
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Checkbox } from './index';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Checkbox> = {
|
|
6
|
-
title: 'UI/Checkbox',
|
|
7
|
-
component: Checkbox,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
argTypes: {
|
|
10
|
-
variant: {
|
|
11
|
-
control: 'select',
|
|
12
|
-
options: ['default', 'accent'],
|
|
13
|
-
},
|
|
14
|
-
size: {
|
|
15
|
-
control: 'select',
|
|
16
|
-
options: ['default', 'sm', 'lg'],
|
|
17
|
-
},
|
|
18
|
-
disabled: {
|
|
19
|
-
control: 'boolean',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default meta;
|
|
25
|
-
type Story = StoryObj<typeof Checkbox>;
|
|
26
|
-
|
|
27
|
-
export const Default: Story = {
|
|
28
|
-
args: {
|
|
29
|
-
variant: 'default',
|
|
30
|
-
size: 'default',
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const Checked: Story = {
|
|
35
|
-
args: {
|
|
36
|
-
defaultChecked: true,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const Large: Story = {
|
|
41
|
-
args: {
|
|
42
|
-
size: 'lg',
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const Accent: Story = {
|
|
47
|
-
args: {
|
|
48
|
-
variant: 'accent',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const Disabled: Story = {
|
|
53
|
-
args: {
|
|
54
|
-
disabled: true,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { cva, VariantProps } from 'class-variance-authority';
|
|
5
|
-
import { motion, SVGMotionProps, type HTMLMotionProps } from 'motion/react';
|
|
6
|
-
import { Checkbox as CheckboxPrimitive } from 'radix-ui';
|
|
7
|
-
|
|
8
|
-
import { getStrictContext } from '@/lib/get-strict-context';
|
|
9
|
-
import { cn } from '@/lib/utils';
|
|
10
|
-
import { useControlledState } from '@/hooks/use-controlled-state';
|
|
11
|
-
|
|
12
|
-
const checkboxVariants = cva(
|
|
13
|
-
'peer focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&[data-state=checked],&[data-state=indeterminate]]:bg-primary [&[data-state=checked],&[data-state=indeterminate]]:text-primary-foreground flex shrink-0 items-center justify-center transition-colors duration-500 outline-none focus-visible:ring-[3px] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
14
|
-
{
|
|
15
|
-
variants: {
|
|
16
|
-
variant: {
|
|
17
|
-
default: 'bg-background border',
|
|
18
|
-
accent: 'bg-input',
|
|
19
|
-
},
|
|
20
|
-
size: {
|
|
21
|
-
default: 'size-5 rounded-sm',
|
|
22
|
-
sm: 'size-4.5 rounded-[5px]',
|
|
23
|
-
lg: 'size-6 rounded-[7px]',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
defaultVariants: {
|
|
27
|
-
variant: 'default',
|
|
28
|
-
size: 'default',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const checkboxIndicatorVariants = cva('', {
|
|
34
|
-
variants: {
|
|
35
|
-
size: {
|
|
36
|
-
default: 'size-3.5',
|
|
37
|
-
sm: 'size-3',
|
|
38
|
-
lg: 'size-4',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
defaultVariants: {
|
|
42
|
-
size: 'default',
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
type CheckboxContextType = {
|
|
47
|
-
isChecked: boolean | 'indeterminate';
|
|
48
|
-
setIsChecked: (checked: boolean | 'indeterminate') => void;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const [CheckboxProvider, useCheckbox] = getStrictContext<CheckboxContextType>('CheckboxContext');
|
|
52
|
-
|
|
53
|
-
type CheckboxProps = HTMLMotionProps<'button'> &
|
|
54
|
-
Omit<React.ComponentProps<typeof CheckboxPrimitive.Root>, 'asChild'> &
|
|
55
|
-
VariantProps<typeof checkboxVariants>;
|
|
56
|
-
|
|
57
|
-
function Checkbox({
|
|
58
|
-
defaultChecked,
|
|
59
|
-
checked,
|
|
60
|
-
onCheckedChange,
|
|
61
|
-
disabled,
|
|
62
|
-
required,
|
|
63
|
-
name,
|
|
64
|
-
value,
|
|
65
|
-
className,
|
|
66
|
-
variant,
|
|
67
|
-
size,
|
|
68
|
-
children,
|
|
69
|
-
...props
|
|
70
|
-
}: CheckboxProps) {
|
|
71
|
-
const [isChecked, setIsChecked] = useControlledState({
|
|
72
|
-
value: checked,
|
|
73
|
-
defaultValue: defaultChecked,
|
|
74
|
-
onChange: onCheckedChange,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<CheckboxProvider value={{ isChecked, setIsChecked }}>
|
|
79
|
-
<CheckboxPrimitive.Root
|
|
80
|
-
defaultChecked={defaultChecked}
|
|
81
|
-
checked={checked}
|
|
82
|
-
onCheckedChange={setIsChecked}
|
|
83
|
-
disabled={disabled}
|
|
84
|
-
required={required}
|
|
85
|
-
name={name}
|
|
86
|
-
value={value}
|
|
87
|
-
asChild
|
|
88
|
-
>
|
|
89
|
-
<motion.button
|
|
90
|
-
data-slot="checkbox"
|
|
91
|
-
whileTap={{ scale: 0.95 }}
|
|
92
|
-
whileHover={{ scale: 1.05 }}
|
|
93
|
-
className={cn(checkboxVariants({ variant, size, className }))}
|
|
94
|
-
{...props}
|
|
95
|
-
>
|
|
96
|
-
{children}
|
|
97
|
-
<CheckboxIndicator size={size} />
|
|
98
|
-
</motion.button>
|
|
99
|
-
</CheckboxPrimitive.Root>
|
|
100
|
-
</CheckboxProvider>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
type CheckboxIndicatorProps = SVGMotionProps<SVGSVGElement> &
|
|
105
|
-
VariantProps<typeof checkboxIndicatorVariants>;
|
|
106
|
-
|
|
107
|
-
function CheckboxIndicator({ className, size, ...props }: CheckboxIndicatorProps) {
|
|
108
|
-
const { isChecked } = useCheckbox();
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<CheckboxPrimitive.Indicator forceMount asChild>
|
|
112
|
-
<motion.svg
|
|
113
|
-
data-slot="checkbox-indicator"
|
|
114
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
115
|
-
fill="none"
|
|
116
|
-
viewBox="0 0 24 24"
|
|
117
|
-
strokeWidth="3.5"
|
|
118
|
-
stroke="currentColor"
|
|
119
|
-
initial="unchecked"
|
|
120
|
-
animate={isChecked ? 'checked' : 'unchecked'}
|
|
121
|
-
className={cn(checkboxIndicatorVariants({ size }), className)}
|
|
122
|
-
{...props}
|
|
123
|
-
>
|
|
124
|
-
{isChecked === 'indeterminate' ? (
|
|
125
|
-
<motion.line
|
|
126
|
-
x1="5"
|
|
127
|
-
y1="12"
|
|
128
|
-
x2="19"
|
|
129
|
-
y2="12"
|
|
130
|
-
strokeLinecap="round"
|
|
131
|
-
initial={{ pathLength: 0, opacity: 0 }}
|
|
132
|
-
animate={{
|
|
133
|
-
pathLength: 1,
|
|
134
|
-
opacity: 1,
|
|
135
|
-
transition: { duration: 0.2 },
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
) : (
|
|
139
|
-
<motion.path
|
|
140
|
-
strokeLinecap="round"
|
|
141
|
-
strokeLinejoin="round"
|
|
142
|
-
d="M4.5 12.75l6 6 9-13.5"
|
|
143
|
-
variants={{
|
|
144
|
-
checked: {
|
|
145
|
-
pathLength: 1,
|
|
146
|
-
opacity: 1,
|
|
147
|
-
transition: {
|
|
148
|
-
duration: 0.2,
|
|
149
|
-
delay: 0.2,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
unchecked: {
|
|
153
|
-
pathLength: 0,
|
|
154
|
-
opacity: 0,
|
|
155
|
-
transition: {
|
|
156
|
-
duration: 0.2,
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
}}
|
|
160
|
-
/>
|
|
161
|
-
)}
|
|
162
|
-
</motion.svg>
|
|
163
|
-
</CheckboxPrimitive.Indicator>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export { Checkbox, type CheckboxProps };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import CircleProcess from './index';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof CircleProcess> = {
|
|
6
|
-
title: 'UI/CircleProcess',
|
|
7
|
-
component: CircleProcess,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
argTypes: {
|
|
10
|
-
progress: {
|
|
11
|
-
control: { type: 'range', min: 0, max: 100 },
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default meta;
|
|
17
|
-
type Story = StoryObj<typeof CircleProcess>;
|
|
18
|
-
|
|
19
|
-
export const Default: Story = {
|
|
20
|
-
args: {
|
|
21
|
-
progress: 75,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const Complete: Story = {
|
|
26
|
-
args: {
|
|
27
|
-
progress: 100,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { useTheme } from 'next-themes';
|
|
2
|
-
|
|
3
|
-
import { cn } from '@/lib/utils';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
progress: number;
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default function CircleProcess({ progress = 0, className }: Props) {
|
|
11
|
-
const numericProgress = Number(progress) / 100;
|
|
12
|
-
const circumference = 2 * Math.PI * 39;
|
|
13
|
-
const offset = circumference * (1 - numericProgress);
|
|
14
|
-
|
|
15
|
-
const { theme, systemTheme } = useTheme();
|
|
16
|
-
|
|
17
|
-
const actualTheme = theme === 'system' ? systemTheme : theme;
|
|
18
|
-
const strokeColor = actualTheme === 'dark' ? '#1e2b47' : '#e5e7eb';
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div className="flex h-full items-center justify-center">
|
|
22
|
-
<div className={cn('relative h-[40px] w-[40px]', className)}>
|
|
23
|
-
<svg className="absolute top-0 left-0 h-full w-full -rotate-90" viewBox="0 0 100 100">
|
|
24
|
-
<circle cx="50" cy="50" r="40" fill="none" stroke={strokeColor} strokeWidth="4" />
|
|
25
|
-
<circle
|
|
26
|
-
cx="50"
|
|
27
|
-
cy="50"
|
|
28
|
-
r="40"
|
|
29
|
-
fill="none"
|
|
30
|
-
stroke="url(#progress-gradient)"
|
|
31
|
-
strokeWidth="4"
|
|
32
|
-
strokeDasharray={circumference}
|
|
33
|
-
strokeDashoffset={offset}
|
|
34
|
-
strokeLinecap="round"
|
|
35
|
-
/>
|
|
36
|
-
<defs>
|
|
37
|
-
<linearGradient id="progress-gradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
38
|
-
<stop offset="0%" stopColor="#4e51f0" />
|
|
39
|
-
<stop offset="100%" stopColor="#1053f3" />
|
|
40
|
-
</linearGradient>
|
|
41
|
-
</defs>
|
|
42
|
-
</svg>
|
|
43
|
-
|
|
44
|
-
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-sm font-medium text-gray-900 dark:text-gray-50">
|
|
45
|
-
{Math.round(numericProgress * 100)}%
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Button } from '../Button';
|
|
4
|
-
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from './index';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Collapsible> = {
|
|
7
|
-
title: 'UI/Collapsible',
|
|
8
|
-
component: Collapsible,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default meta;
|
|
13
|
-
type Story = StoryObj<typeof Collapsible>;
|
|
14
|
-
|
|
15
|
-
export const Default: Story = {
|
|
16
|
-
render: (args) => (
|
|
17
|
-
<Collapsible {...args} className="w-87.5 space-y-2">
|
|
18
|
-
<div className="flex items-center justify-between space-x-4 px-4">
|
|
19
|
-
<h4 className="text-sm font-semibold">@peduarte starred 3 repositories</h4>
|
|
20
|
-
<CollapsibleTrigger>
|
|
21
|
-
<Button variant="ghost" size="sm" className="w-9 p-0">
|
|
22
|
-
<span className="sr-only">Toggle</span>
|
|
23
|
-
</Button>
|
|
24
|
-
</CollapsibleTrigger>
|
|
25
|
-
</div>
|
|
26
|
-
<div className="rounded-md border px-4 py-3 font-mono text-sm">@radix-ui/primitives</div>
|
|
27
|
-
<CollapsiblePanel className="space-y-2">
|
|
28
|
-
<div className="rounded-md border px-4 py-3 font-mono text-sm">@radix-ui/react</div>
|
|
29
|
-
<div className="rounded-md border px-4 py-3 font-mono text-sm">@stitches/react</div>
|
|
30
|
-
</CollapsiblePanel>
|
|
31
|
-
</Collapsible>
|
|
32
|
-
),
|
|
33
|
-
};
|