@luanthnh/cntt-ui 0.1.8 → 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 -193
- 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,13 +0,0 @@
|
|
|
1
|
-
import { cn } from '@/lib/utils';
|
|
2
|
-
|
|
3
|
-
function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
|
|
4
|
-
return (
|
|
5
|
-
<div
|
|
6
|
-
data-slot="skeleton"
|
|
7
|
-
className={cn('animate-pulse rounded-md bg-gray-200 dark:bg-gray-700', className)}
|
|
8
|
-
{...props}
|
|
9
|
-
/>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { Skeleton };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Slider } from './index';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Slider> = {
|
|
6
|
-
title: 'UI/Slider',
|
|
7
|
-
component: Slider,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
argTypes: {
|
|
10
|
-
color: {
|
|
11
|
-
control: 'select',
|
|
12
|
-
options: ['default', 'white'],
|
|
13
|
-
},
|
|
14
|
-
size: {
|
|
15
|
-
control: 'select',
|
|
16
|
-
options: ['default', 'sm'],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default meta;
|
|
22
|
-
type Story = StoryObj<typeof Slider>;
|
|
23
|
-
|
|
24
|
-
export const Default: Story = {
|
|
25
|
-
args: {
|
|
26
|
-
defaultValue: [50],
|
|
27
|
-
max: 100,
|
|
28
|
-
step: 1,
|
|
29
|
-
className: 'w-[60%]',
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const Range: Story = {
|
|
34
|
-
args: {
|
|
35
|
-
defaultValue: [25, 75],
|
|
36
|
-
max: 100,
|
|
37
|
-
step: 1,
|
|
38
|
-
className: 'w-[60%]',
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const Small: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
defaultValue: [40],
|
|
45
|
-
size: 'sm',
|
|
46
|
-
className: 'w-[60%]',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
interface Props extends Omit<React.ComponentProps<typeof SliderPrimitive.Root>, 'color'> {
|
|
9
|
-
color?: 'default' | 'white';
|
|
10
|
-
size?: 'sm' | 'default';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function Slider({
|
|
14
|
-
className,
|
|
15
|
-
defaultValue,
|
|
16
|
-
value,
|
|
17
|
-
min = 0,
|
|
18
|
-
max = 100,
|
|
19
|
-
color = 'default',
|
|
20
|
-
size = 'default',
|
|
21
|
-
...props
|
|
22
|
-
}: Props) {
|
|
23
|
-
const _values = React.useMemo(
|
|
24
|
-
() => (Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max]),
|
|
25
|
-
[value, defaultValue, min, max],
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<SliderPrimitive.Root
|
|
30
|
-
data-slot="slider"
|
|
31
|
-
defaultValue={defaultValue}
|
|
32
|
-
value={value}
|
|
33
|
-
min={min}
|
|
34
|
-
max={max}
|
|
35
|
-
className={cn(
|
|
36
|
-
'group relative flex w-full cursor-pointer touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col',
|
|
37
|
-
className,
|
|
38
|
-
)}
|
|
39
|
-
{...props}
|
|
40
|
-
>
|
|
41
|
-
<SliderPrimitive.Track
|
|
42
|
-
data-slot="slider-track"
|
|
43
|
-
className={cn(
|
|
44
|
-
'bg-muted/60 relative grow overflow-hidden rounded-full transition-all data-[orientation=horizontal]:h-[3px] data-[orientation=horizontal]:w-full group-hover:data-[orientation=horizontal]:h-[6px] data-[orientation=vertical]:h-full data-[orientation=vertical]:w-[3px] group-hover:data-[orientation=vertical]:w-[6px]',
|
|
45
|
-
{
|
|
46
|
-
'data-[orientation=horizontal]:h-[2px] group-hover:data-[orientation=horizontal]:h-[4px]':
|
|
47
|
-
size === 'sm',
|
|
48
|
-
'data-[orientation=vertical]:w-[2px] group-hover:data-[orientation=vertical]:w-[4px]':
|
|
49
|
-
size === 'sm',
|
|
50
|
-
},
|
|
51
|
-
)}
|
|
52
|
-
>
|
|
53
|
-
<SliderPrimitive.Range
|
|
54
|
-
data-slot="slider-range"
|
|
55
|
-
className={cn(
|
|
56
|
-
'absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full',
|
|
57
|
-
{
|
|
58
|
-
'bg-white': color === 'white',
|
|
59
|
-
'bg-primary': color === 'default',
|
|
60
|
-
},
|
|
61
|
-
)}
|
|
62
|
-
/>
|
|
63
|
-
</SliderPrimitive.Track>
|
|
64
|
-
{Array.from({ length: _values.length }, (_, index) => (
|
|
65
|
-
<SliderPrimitive.Thumb
|
|
66
|
-
data-slot="slider-thumb"
|
|
67
|
-
key={index}
|
|
68
|
-
className={cn(
|
|
69
|
-
'ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',
|
|
70
|
-
{
|
|
71
|
-
'border-white bg-white': color === 'white',
|
|
72
|
-
'bg-primary border-primary': color === 'default',
|
|
73
|
-
'size-3': size === 'sm',
|
|
74
|
-
},
|
|
75
|
-
)}
|
|
76
|
-
/>
|
|
77
|
-
))}
|
|
78
|
-
</SliderPrimitive.Root>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { Slider };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Button } from '../Button';
|
|
4
|
-
import { Slot } from './index';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Slot> = {
|
|
7
|
-
title: 'UI/Slot',
|
|
8
|
-
component: Slot,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default meta;
|
|
13
|
-
type Story = StoryObj<typeof Slot>;
|
|
14
|
-
|
|
15
|
-
export const Default: Story = {
|
|
16
|
-
render: (args) => (
|
|
17
|
-
<Slot {...args}>
|
|
18
|
-
<Button>I am a button rendered via Slot</Button>
|
|
19
|
-
</Slot>
|
|
20
|
-
),
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const WithCustomElement: Story = {
|
|
24
|
-
render: (args) => (
|
|
25
|
-
<Slot {...args} className="bg-red-500 p-4 text-white">
|
|
26
|
-
<div>I am a div rendered via Slot with custom styles</div>
|
|
27
|
-
</Slot>
|
|
28
|
-
),
|
|
29
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { isMotionComponent, motion, type HTMLMotionProps } from 'motion/react';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
type AnyProps = Record<string, unknown>;
|
|
9
|
-
|
|
10
|
-
type DOMMotionProps<T extends HTMLElement = HTMLElement> = Omit<
|
|
11
|
-
HTMLMotionProps<keyof HTMLElementTagNameMap>,
|
|
12
|
-
'ref'
|
|
13
|
-
> & {
|
|
14
|
-
ref?: React.Ref<T>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type WithAsChild<Base extends object> =
|
|
18
|
-
| (Base & { asChild: true; children: React.ReactElement })
|
|
19
|
-
| (Base & { asChild?: false | undefined });
|
|
20
|
-
|
|
21
|
-
type SlotProps<T extends HTMLElement = HTMLElement> = {
|
|
22
|
-
children?: React.ReactElement;
|
|
23
|
-
} & DOMMotionProps<T>;
|
|
24
|
-
|
|
25
|
-
function mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]): React.RefCallback<T> {
|
|
26
|
-
return (node) => {
|
|
27
|
-
refs.forEach((ref) => {
|
|
28
|
-
if (!ref) return;
|
|
29
|
-
if (typeof ref === 'function') {
|
|
30
|
-
ref(node);
|
|
31
|
-
} else {
|
|
32
|
-
(ref as React.RefObject<T | null>).current = node;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const motionComponentCache = new Map<React.ElementType, React.ElementType>();
|
|
39
|
-
|
|
40
|
-
function getMotionComponent(Component: React.ElementType): React.ElementType {
|
|
41
|
-
if (!motionComponentCache.has(Component)) {
|
|
42
|
-
motionComponentCache.set(Component, motion.create(Component));
|
|
43
|
-
}
|
|
44
|
-
return motionComponentCache.get(Component)!;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function mergeProps<T extends HTMLElement>(
|
|
48
|
-
childProps: AnyProps,
|
|
49
|
-
slotProps: DOMMotionProps<T>,
|
|
50
|
-
): AnyProps {
|
|
51
|
-
const merged: AnyProps = { ...childProps, ...slotProps };
|
|
52
|
-
|
|
53
|
-
if (childProps.className || slotProps.className) {
|
|
54
|
-
merged.className = cn(childProps.className as string, slotProps.className as string);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (childProps.style || slotProps.style) {
|
|
58
|
-
merged.style = {
|
|
59
|
-
...(childProps.style as React.CSSProperties),
|
|
60
|
-
...(slotProps.style as React.CSSProperties),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return merged;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function Slot<T extends HTMLElement = HTMLElement>({ children, ...props }: SlotProps<T>) {
|
|
68
|
-
const isValidElement = React.isValidElement(children);
|
|
69
|
-
const childType = isValidElement ? children.type : null;
|
|
70
|
-
const isAlreadyMotion =
|
|
71
|
-
isValidElement &&
|
|
72
|
-
childType !== null &&
|
|
73
|
-
typeof childType === 'object' &&
|
|
74
|
-
isMotionComponent(childType);
|
|
75
|
-
|
|
76
|
-
const Base = React.useMemo(() => {
|
|
77
|
-
if (!isValidElement || !childType) return null;
|
|
78
|
-
return isAlreadyMotion
|
|
79
|
-
? (childType as React.ElementType)
|
|
80
|
-
: getMotionComponent(childType as React.ElementType);
|
|
81
|
-
}, [isValidElement, isAlreadyMotion, childType]);
|
|
82
|
-
|
|
83
|
-
const childRef = isValidElement && children ? (children.props as AnyProps).ref : undefined;
|
|
84
|
-
const childProps =
|
|
85
|
-
isValidElement && children
|
|
86
|
-
? (({ ref: _ref, ...rest }) => rest)(children.props as AnyProps)
|
|
87
|
-
: {};
|
|
88
|
-
|
|
89
|
-
const mergedRef = React.useCallback(
|
|
90
|
-
(node: T | null) => {
|
|
91
|
-
mergeRefs(childRef as React.Ref<T>, props.ref)(node);
|
|
92
|
-
},
|
|
93
|
-
[childRef, props.ref],
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
if (!isValidElement || !Base || !children) return null;
|
|
97
|
-
|
|
98
|
-
const mergedProps = mergeProps(childProps, props);
|
|
99
|
-
|
|
100
|
-
return React.createElement(Base, {
|
|
101
|
-
...mergedProps,
|
|
102
|
-
ref: mergedRef,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export { Slot, type SlotProps, type WithAsChild, type DOMMotionProps, type AnyProps };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { toast } from 'sonner';
|
|
3
|
-
|
|
4
|
-
import { Button } from '../Button';
|
|
5
|
-
import { Toaster } from './index';
|
|
6
|
-
|
|
7
|
-
const meta: Meta<typeof Toaster> = {
|
|
8
|
-
title: 'UI/Sonner',
|
|
9
|
-
component: Toaster,
|
|
10
|
-
tags: ['autodocs'],
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
type Story = StoryObj<typeof Toaster>;
|
|
15
|
-
|
|
16
|
-
export const Default: Story = {
|
|
17
|
-
render: () => (
|
|
18
|
-
<div className="flex flex-col gap-2">
|
|
19
|
-
<Toaster />
|
|
20
|
-
<Button
|
|
21
|
-
variant="outline"
|
|
22
|
-
onClick={() =>
|
|
23
|
-
toast('Event has been created', {
|
|
24
|
-
description: 'Sunday, December 03, 2023 at 9:00 AM',
|
|
25
|
-
action: {
|
|
26
|
-
label: 'Undo',
|
|
27
|
-
onClick: () => console.log('Undo'),
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
>
|
|
32
|
-
Show Toast
|
|
33
|
-
</Button>
|
|
34
|
-
</div>
|
|
35
|
-
),
|
|
36
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useTheme } from 'next-themes';
|
|
4
|
-
import { Toaster as Sonner, type ToasterProps } from 'sonner';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
const Toaster = ({ toastOptions, ...props }: ToasterProps) => {
|
|
9
|
-
const { theme = 'system' } = useTheme();
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<Sonner
|
|
13
|
-
theme={theme as ToasterProps['theme']}
|
|
14
|
-
className="toaster group"
|
|
15
|
-
toastOptions={{
|
|
16
|
-
...toastOptions,
|
|
17
|
-
classNames: {
|
|
18
|
-
toast: cn('sonner-toast', toastOptions?.classNames?.toast),
|
|
19
|
-
icon: cn('sonner-icon', toastOptions?.classNames?.icon),
|
|
20
|
-
title: cn('sonner-title', toastOptions?.classNames?.title),
|
|
21
|
-
description: cn('sonner-description', toastOptions?.classNames?.description),
|
|
22
|
-
actionButton: cn('sonner-action', toastOptions?.classNames?.actionButton),
|
|
23
|
-
closeButton: cn('sonner-close', toastOptions?.classNames?.closeButton),
|
|
24
|
-
},
|
|
25
|
-
}}
|
|
26
|
-
{...props}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { Toaster };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Switch } from './index';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Switch> = {
|
|
6
|
-
title: 'UI/Switch',
|
|
7
|
-
component: Switch,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
argTypes: {
|
|
10
|
-
disabled: {
|
|
11
|
-
control: 'boolean',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default meta;
|
|
17
|
-
type Story = StoryObj<typeof Switch>;
|
|
18
|
-
|
|
19
|
-
export const Default: Story = {
|
|
20
|
-
args: {},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const Checked: Story = {
|
|
24
|
-
args: {
|
|
25
|
-
defaultChecked: true,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const Disabled: Story = {
|
|
30
|
-
args: {
|
|
31
|
-
disabled: true,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
7
|
-
|
|
8
|
-
function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
|
9
|
-
return (
|
|
10
|
-
<SwitchPrimitive.Root
|
|
11
|
-
data-slot="switch"
|
|
12
|
-
className={cn(
|
|
13
|
-
'peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
|
14
|
-
className,
|
|
15
|
-
)}
|
|
16
|
-
{...props}
|
|
17
|
-
>
|
|
18
|
-
<SwitchPrimitive.Thumb
|
|
19
|
-
data-slot="switch-thumb"
|
|
20
|
-
className={cn(
|
|
21
|
-
'bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0',
|
|
22
|
-
)}
|
|
23
|
-
/>
|
|
24
|
-
</SwitchPrimitive.Root>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { Switch };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Table,
|
|
5
|
-
TableBody,
|
|
6
|
-
TableCaption,
|
|
7
|
-
TableCell,
|
|
8
|
-
TableFooter,
|
|
9
|
-
TableHead,
|
|
10
|
-
TableHeader,
|
|
11
|
-
TableRow,
|
|
12
|
-
} from './index';
|
|
13
|
-
|
|
14
|
-
const meta: Meta<typeof Table> = {
|
|
15
|
-
title: 'UI/Table',
|
|
16
|
-
component: Table,
|
|
17
|
-
tags: ['autodocs'],
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default meta;
|
|
21
|
-
type Story = StoryObj<typeof Table>;
|
|
22
|
-
|
|
23
|
-
const invoices = [
|
|
24
|
-
{
|
|
25
|
-
invoice: 'INV001',
|
|
26
|
-
paymentStatus: 'Paid',
|
|
27
|
-
totalAmount: '$250.00',
|
|
28
|
-
paymentMethod: 'Credit Card',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
invoice: 'INV002',
|
|
32
|
-
paymentStatus: 'Pending',
|
|
33
|
-
totalAmount: '$150.00',
|
|
34
|
-
paymentMethod: 'PayPal',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
invoice: 'INV003',
|
|
38
|
-
paymentStatus: 'Unpaid',
|
|
39
|
-
totalAmount: '$350.00',
|
|
40
|
-
paymentMethod: 'Bank Transfer',
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
export const Default: Story = {
|
|
45
|
-
render: (args) => (
|
|
46
|
-
<Table {...args}>
|
|
47
|
-
<TableCaption>A list of your recent invoices.</TableCaption>
|
|
48
|
-
<TableHeader>
|
|
49
|
-
<TableRow>
|
|
50
|
-
<TableHead className="w-25">Invoice</TableHead>
|
|
51
|
-
<TableHead>Status</TableHead>
|
|
52
|
-
<TableHead>Method</TableHead>
|
|
53
|
-
<TableHead className="text-right">Amount</TableHead>
|
|
54
|
-
</TableRow>
|
|
55
|
-
</TableHeader>
|
|
56
|
-
<TableBody>
|
|
57
|
-
{invoices.map((invoice) => (
|
|
58
|
-
<TableRow key={invoice.invoice}>
|
|
59
|
-
<TableCell className="font-medium">{invoice.invoice}</TableCell>
|
|
60
|
-
<TableCell>{invoice.paymentStatus}</TableCell>
|
|
61
|
-
<TableCell>{invoice.paymentMethod}</TableCell>
|
|
62
|
-
<TableCell className="text-right">{invoice.totalAmount}</TableCell>
|
|
63
|
-
</TableRow>
|
|
64
|
-
))}
|
|
65
|
-
</TableBody>
|
|
66
|
-
<TableFooter>
|
|
67
|
-
<TableRow>
|
|
68
|
-
<TableCell colSpan={3}>Total</TableCell>
|
|
69
|
-
<TableCell className="text-right">$750.00</TableCell>
|
|
70
|
-
</TableRow>
|
|
71
|
-
</TableFooter>
|
|
72
|
-
</Table>
|
|
73
|
-
),
|
|
74
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
import { cn } from '@/lib/utils';
|
|
6
|
-
|
|
7
|
-
function Table({ className, ...props }: React.ComponentProps<'table'>) {
|
|
8
|
-
return (
|
|
9
|
-
<div data-slot="table-container" className="relative w-full overflow-x-auto">
|
|
10
|
-
<table
|
|
11
|
-
data-slot="table"
|
|
12
|
-
className={cn('w-full caption-bottom text-sm', className)}
|
|
13
|
-
{...props}
|
|
14
|
-
/>
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
|
|
20
|
-
return <thead data-slot="table-header" className={cn('[&_tr]:border-b', className)} {...props} />;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
|
|
24
|
-
return (
|
|
25
|
-
<tbody
|
|
26
|
-
data-slot="table-body"
|
|
27
|
-
className={cn('[&_tr:last-child]:border-0', className)}
|
|
28
|
-
{...props}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {
|
|
34
|
-
return (
|
|
35
|
-
<tfoot
|
|
36
|
-
data-slot="table-footer"
|
|
37
|
-
className={cn(
|
|
38
|
-
'dark:bg-card border-t bg-gray-50 font-medium [&>tr]:last:border-b-0',
|
|
39
|
-
className,
|
|
40
|
-
)}
|
|
41
|
-
{...props}
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
|
|
47
|
-
return (
|
|
48
|
-
<tr
|
|
49
|
-
data-slot="table-row"
|
|
50
|
-
className={cn(
|
|
51
|
-
'group data-[state=selected]:bg-muted dark:hover:bg-card border-b transition-colors hover:bg-gray-50',
|
|
52
|
-
className,
|
|
53
|
-
)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
|
|
60
|
-
return (
|
|
61
|
-
<th
|
|
62
|
-
data-slot="table-head"
|
|
63
|
-
className={cn(
|
|
64
|
-
'text-foreground group-hover:bg-primary-50 dark:group-hover:bg-primary-900/20 h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
|
|
65
|
-
className,
|
|
66
|
-
)}
|
|
67
|
-
{...props}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function TableCell({ className, ...props }: React.ComponentProps<'td'>) {
|
|
73
|
-
return (
|
|
74
|
-
<td
|
|
75
|
-
data-slot="table-cell"
|
|
76
|
-
className={cn(
|
|
77
|
-
'dark:group-hover:bg-card p-2 align-middle whitespace-nowrap group-hover:bg-gray-50 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
|
|
78
|
-
className,
|
|
79
|
-
)}
|
|
80
|
-
{...props}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function TableCaption({ className, ...props }: React.ComponentProps<'caption'>) {
|
|
86
|
-
return (
|
|
87
|
-
<caption
|
|
88
|
-
data-slot="table-caption"
|
|
89
|
-
className={cn('text-muted-foreground mt-4 text-sm', className)}
|
|
90
|
-
{...props}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { Tabs, TabsContent, TabsContents, TabsList, TabsTrigger } from './index';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Tabs> = {
|
|
7
|
-
title: 'UI/Tabs',
|
|
8
|
-
component: Tabs,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default meta;
|
|
13
|
-
type Story = StoryObj<typeof Tabs>;
|
|
14
|
-
|
|
15
|
-
export const Default: Story = {
|
|
16
|
-
render: (args: React.ComponentProps<typeof Tabs>) => (
|
|
17
|
-
<Tabs {...args} defaultValue="account" className="w-100">
|
|
18
|
-
<TabsList className="grid w-full grid-cols-2">
|
|
19
|
-
<TabsTrigger value="account">Account</TabsTrigger>
|
|
20
|
-
<TabsTrigger value="password">Password</TabsTrigger>
|
|
21
|
-
</TabsList>
|
|
22
|
-
<TabsContents>
|
|
23
|
-
<TabsContent value="account">
|
|
24
|
-
<div className="rounded-md border p-4">
|
|
25
|
-
<h3 className="text-lg font-medium">Account</h3>
|
|
26
|
-
<p className="text-muted-foreground text-sm">Make changes to your account here.</p>
|
|
27
|
-
</div>
|
|
28
|
-
</TabsContent>
|
|
29
|
-
<TabsContent value="password">
|
|
30
|
-
<div className="rounded-md border p-4">
|
|
31
|
-
<h3 className="text-lg font-medium">Password</h3>
|
|
32
|
-
<p className="text-muted-foreground text-sm">Change your password here.</p>
|
|
33
|
-
</div>
|
|
34
|
-
</TabsContent>
|
|
35
|
-
</TabsContents>
|
|
36
|
-
</Tabs>
|
|
37
|
-
),
|
|
38
|
-
};
|