@luanthnh/cntt-ui 0.1.5
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/.storybook/globals.d.ts +1 -0
- package/.storybook/main.ts +29 -0
- package/.storybook/preview.ts +32 -0
- package/README.md +86 -0
- 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 +1 -0
- package/assets/icons/file.svg +1 -0
- package/assets/icons/globe.svg +1 -0
- package/assets/icons/logo-line.svg +1 -0
- package/assets/icons/next.svg +1 -0
- package/assets/icons/panel-left-expand.svg +1 -0
- package/assets/icons/placeholder.svg +57 -0
- package/assets/icons/vercel.svg +1 -0
- package/assets/icons/window.svg +1 -0
- package/assets/lotties/error-404.json +19642 -0
- package/assets/lotties/error.json +2414 -0
- package/assets/lotties/loader.json +305 -0
- package/components/Welcome.mdx +74 -0
- package/components/lenis/index.tsx +48 -0
- package/components/motion/auto-height.tsx +56 -0
- package/components/motion/cursor.tsx +108 -0
- package/components/motion/highlight.tsx +605 -0
- package/components/motion/number-ticker.tsx +55 -0
- package/components/motion/slot.tsx +106 -0
- package/components/motion/waves.tsx +417 -0
- package/components/primitives/tabs.tsx +174 -0
- package/components/ui/Accordion/index.stories.tsx +39 -0
- package/components/ui/Accordion/index.tsx +170 -0
- package/components/ui/Alert/index.stories.tsx +39 -0
- package/components/ui/Alert/index.tsx +60 -0
- package/components/ui/AlertDialog/index.stories.tsx +47 -0
- package/components/ui/AlertDialog/index.tsx +172 -0
- package/components/ui/AspectRatio/index.stories.tsx +40 -0
- package/components/ui/AspectRatio/index.tsx +9 -0
- package/components/ui/Avatar/index.stories.tsx +39 -0
- package/components/ui/Avatar/index.tsx +44 -0
- package/components/ui/Badge/index.stories.tsx +64 -0
- package/components/ui/Badge/index.tsx +46 -0
- package/components/ui/Breadcrumb/index.stories.tsx +64 -0
- package/components/ui/Breadcrumb/index.tsx +102 -0
- package/components/ui/Button/index.stories.tsx +232 -0
- package/components/ui/Button/index.tsx +114 -0
- package/components/ui/Calendar/index.stories.tsx +20 -0
- package/components/ui/Calendar/index.tsx +149 -0
- package/components/ui/Card/index.stories.tsx +39 -0
- package/components/ui/Card/index.tsx +65 -0
- package/components/ui/Carousel/index.stories.tsx +37 -0
- package/components/ui/Carousel/index.tsx +242 -0
- package/components/ui/Chart/index.stories.tsx +53 -0
- package/components/ui/Chart/index.tsx +322 -0
- package/components/ui/Checkbox/index.stories.tsx +56 -0
- package/components/ui/Checkbox/index.tsx +167 -0
- package/components/ui/CircleProcess/index.stories.tsx +29 -0
- package/components/ui/CircleProcess/index.tsx +50 -0
- package/components/ui/Collapsible/index.stories.tsx +33 -0
- package/components/ui/Collapsible/index.tsx +124 -0
- package/components/ui/Command/index.stories.tsx +65 -0
- package/components/ui/Command/index.tsx +161 -0
- package/components/ui/Container/index.stories.tsx +22 -0
- package/components/ui/Container/index.tsx +30 -0
- package/components/ui/ContextMenu/index.stories.tsx +51 -0
- package/components/ui/ContextMenu/index.tsx +224 -0
- package/components/ui/Dialog/index.stories.tsx +44 -0
- package/components/ui/Dialog/index.tsx +156 -0
- package/components/ui/Drawer/index.stories.tsx +54 -0
- package/components/ui/Drawer/index.tsx +124 -0
- package/components/ui/DropdownMenu/index.stories.tsx +83 -0
- package/components/ui/DropdownMenu/index.tsx +231 -0
- package/components/ui/Dropzone/index.stories.tsx +18 -0
- package/components/ui/Dropzone/index.tsx +47 -0
- package/components/ui/Form/date-field.tsx +77 -0
- package/components/ui/Form/index.stories.tsx +67 -0
- package/components/ui/Form/index.tsx +188 -0
- package/components/ui/Form/select-field.tsx +55 -0
- package/components/ui/Form/text-area-field.tsx +37 -0
- package/components/ui/Form/text-field.tsx +72 -0
- package/components/ui/HStack/index.stories.tsx +48 -0
- package/components/ui/HStack/index.tsx +73 -0
- package/components/ui/HoverCard/index.stories.tsx +38 -0
- package/components/ui/HoverCard/index.tsx +38 -0
- package/components/ui/Icons/index.stories.tsx +27 -0
- package/components/ui/Icons/index.tsx +33 -0
- package/components/ui/ImageWithFallback/index.stories.tsx +32 -0
- package/components/ui/ImageWithFallback/index.tsx +34 -0
- package/components/ui/Input/index.stories.tsx +47 -0
- package/components/ui/Input/index.tsx +21 -0
- package/components/ui/InputOtp/index.stories.tsx +35 -0
- package/components/ui/InputOtp/index.tsx +70 -0
- package/components/ui/Label/index.stories.tsx +18 -0
- package/components/ui/Label/index.tsx +21 -0
- package/components/ui/Marquee/index.stories.tsx +71 -0
- package/components/ui/Marquee/index.tsx +65 -0
- package/components/ui/Menubar/index.stories.tsx +116 -0
- package/components/ui/Menubar/index.tsx +252 -0
- package/components/ui/NavigationMenu/index.stories.tsx +112 -0
- package/components/ui/NavigationMenu/index.tsx +185 -0
- package/components/ui/NoData/index.stories.tsx +24 -0
- package/components/ui/NoData/index.tsx +19 -0
- package/components/ui/Pagination/index.stories.tsx +53 -0
- package/components/ui/Pagination/index.tsx +114 -0
- package/components/ui/Popover/index.stories.tsx +31 -0
- package/components/ui/Popover/index.tsx +42 -0
- package/components/ui/Progress/index.stories.tsx +35 -0
- package/components/ui/Progress/index.tsx +28 -0
- package/components/ui/RadioGroup/index.stories.tsx +28 -0
- package/components/ui/RadioGroup/index.tsx +45 -0
- package/components/ui/Resizable/index.stories.tsx +44 -0
- package/components/ui/Resizable/index.tsx +54 -0
- package/components/ui/ScrollArea/index.stories.tsx +31 -0
- package/components/ui/ScrollArea/index.tsx +56 -0
- package/components/ui/Select/index.stories.tsx +64 -0
- package/components/ui/Select/index.tsx +170 -0
- package/components/ui/Separator/index.stories.tsx +31 -0
- package/components/ui/Separator/index.tsx +28 -0
- package/components/ui/Sheet/index.stories.tsx +45 -0
- package/components/ui/Sheet/index.tsx +130 -0
- package/components/ui/Sidebar/index.stories.tsx +82 -0
- package/components/ui/Sidebar/index.tsx +676 -0
- package/components/ui/Skeleton/index.stories.tsx +36 -0
- package/components/ui/Skeleton/index.tsx +13 -0
- package/components/ui/Slider/index.stories.tsx +48 -0
- package/components/ui/Slider/index.tsx +82 -0
- package/components/ui/Slot/index.stories.tsx +29 -0
- package/components/ui/Slot/index.tsx +106 -0
- package/components/ui/Sonner/index.stories.tsx +36 -0
- package/components/ui/Sonner/index.tsx +31 -0
- package/components/ui/Switch/index.stories.tsx +33 -0
- package/components/ui/Switch/index.tsx +28 -0
- package/components/ui/Table/index.stories.tsx +74 -0
- package/components/ui/Table/index.tsx +95 -0
- package/components/ui/Tabs/index.stories.tsx +38 -0
- package/components/ui/Tabs/index.tsx +78 -0
- package/components/ui/Text/index.stories.tsx +53 -0
- package/components/ui/Text/index.tsx +138 -0
- package/components/ui/Textarea/index.stories.tsx +25 -0
- package/components/ui/Textarea/index.tsx +18 -0
- package/components/ui/Toggle/index.stories.tsx +52 -0
- package/components/ui/Toggle/index.tsx +46 -0
- package/components/ui/ToggleGroup/index.stories.tsx +52 -0
- package/components/ui/ToggleGroup/index.tsx +69 -0
- package/components/ui/Tooltip/index.stories.tsx +29 -0
- package/components/ui/Tooltip/index.tsx +35 -0
- package/components/ui/VStack/index.stories.tsx +45 -0
- package/components/ui/VStack/index.tsx +69 -0
- package/components/ui/colors.stories.tsx +148 -0
- package/dist/arrow-left-46B4CAEY.svg +1 -0
- package/dist/file-4IXBJF4J.svg +1 -0
- package/dist/globe-KVAXBN2U.svg +1 -0
- package/dist/index.cjs +6001 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +693 -0
- package/dist/index.d.ts +693 -0
- package/dist/index.js +5714 -0
- package/dist/index.js.map +1 -0
- package/dist/logo-line-QLUD5DAV.svg +1 -0
- package/dist/next-HOXZBJQP.svg +1 -0
- package/dist/panel-left-expand-SIPFBG4J.svg +1 -0
- package/dist/placeholder-H3V4XYVI.svg +57 -0
- package/dist/vercel-KFYFHF3A.svg +1 -0
- package/dist/window-JNUL4Q2E.svg +1 -0
- package/eslint.config.js +10 -0
- package/globals.css +994 -0
- package/hooks/index.ts +3 -0
- package/hooks/use-auto-height.tsx +99 -0
- package/hooks/use-controlled-state.tsx +32 -0
- package/hooks/use-mobile.ts +19 -0
- package/index.ts +58 -0
- package/lib/get-strict-context.ts +15 -0
- package/lib/utils.ts +10 -0
- package/package.json +107 -0
- package/scripts/generate-exports.ts +32 -0
- package/tsconfig.json +12 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +11 -0
- package/types/svg.d.ts +10 -0
- package/vercel.json +5 -0
package/hooks/index.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
type AutoHeightOptions = {
|
|
6
|
+
includeParentBox?: boolean;
|
|
7
|
+
includeSelfBox?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function useAutoHeight<T extends HTMLElement = HTMLDivElement>(
|
|
11
|
+
deps: React.DependencyList = [],
|
|
12
|
+
options: AutoHeightOptions = {
|
|
13
|
+
includeParentBox: true,
|
|
14
|
+
includeSelfBox: false,
|
|
15
|
+
},
|
|
16
|
+
) {
|
|
17
|
+
const ref = React.useRef<T | null>(null);
|
|
18
|
+
const roRef = React.useRef<ResizeObserver | null>(null);
|
|
19
|
+
const [height, setHeight] = React.useState(0);
|
|
20
|
+
|
|
21
|
+
const measure = React.useCallback(() => {
|
|
22
|
+
const el = ref.current;
|
|
23
|
+
if (!el) return 0;
|
|
24
|
+
|
|
25
|
+
const base = el.getBoundingClientRect().height || 0;
|
|
26
|
+
|
|
27
|
+
let extra = 0;
|
|
28
|
+
|
|
29
|
+
if (options.includeParentBox && el.parentElement) {
|
|
30
|
+
const cs = getComputedStyle(el.parentElement);
|
|
31
|
+
const paddingY =
|
|
32
|
+
(parseFloat(cs.paddingTop || '0') || 0) + (parseFloat(cs.paddingBottom || '0') || 0);
|
|
33
|
+
const borderY =
|
|
34
|
+
(parseFloat(cs.borderTopWidth || '0') || 0) +
|
|
35
|
+
(parseFloat(cs.borderBottomWidth || '0') || 0);
|
|
36
|
+
const isBorderBox = cs.boxSizing === 'border-box';
|
|
37
|
+
if (isBorderBox) {
|
|
38
|
+
extra += paddingY + borderY;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options.includeSelfBox) {
|
|
43
|
+
const cs = getComputedStyle(el);
|
|
44
|
+
const paddingY =
|
|
45
|
+
(parseFloat(cs.paddingTop || '0') || 0) + (parseFloat(cs.paddingBottom || '0') || 0);
|
|
46
|
+
const borderY =
|
|
47
|
+
(parseFloat(cs.borderTopWidth || '0') || 0) +
|
|
48
|
+
(parseFloat(cs.borderBottomWidth || '0') || 0);
|
|
49
|
+
const isBorderBox = cs.boxSizing === 'border-box';
|
|
50
|
+
if (isBorderBox) {
|
|
51
|
+
extra += paddingY + borderY;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
|
|
56
|
+
const total = Math.ceil((base + extra) * dpr) / dpr;
|
|
57
|
+
|
|
58
|
+
return total;
|
|
59
|
+
}, [options.includeParentBox, options.includeSelfBox]);
|
|
60
|
+
|
|
61
|
+
React.useLayoutEffect(() => {
|
|
62
|
+
const el = ref.current;
|
|
63
|
+
if (!el) return;
|
|
64
|
+
|
|
65
|
+
setHeight(measure());
|
|
66
|
+
|
|
67
|
+
if (roRef.current) {
|
|
68
|
+
roRef.current.disconnect();
|
|
69
|
+
roRef.current = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const ro = new ResizeObserver(() => {
|
|
73
|
+
const next = measure();
|
|
74
|
+
requestAnimationFrame(() => setHeight(next));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
ro.observe(el);
|
|
78
|
+
if (options.includeParentBox && el.parentElement) {
|
|
79
|
+
ro.observe(el.parentElement);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
roRef.current = ro;
|
|
83
|
+
|
|
84
|
+
return () => {
|
|
85
|
+
ro.disconnect();
|
|
86
|
+
roRef.current = null;
|
|
87
|
+
};
|
|
88
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
|
+
}, deps);
|
|
90
|
+
|
|
91
|
+
React.useLayoutEffect(() => {
|
|
92
|
+
if (height === 0) {
|
|
93
|
+
const next = measure();
|
|
94
|
+
if (next !== 0) setHeight(next);
|
|
95
|
+
}
|
|
96
|
+
}, [height, measure]);
|
|
97
|
+
|
|
98
|
+
return { ref, height } as const;
|
|
99
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface CommonControlledStateProps<T> {
|
|
4
|
+
value?: T;
|
|
5
|
+
defaultValue?: T;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useControlledState<T, Rest extends unknown[] = []>(
|
|
9
|
+
props: CommonControlledStateProps<T> & {
|
|
10
|
+
onChange?: (value: T, ...args: Rest) => void;
|
|
11
|
+
},
|
|
12
|
+
): readonly [T, (next: T, ...args: Rest) => void] {
|
|
13
|
+
const { value, defaultValue, onChange } = props;
|
|
14
|
+
|
|
15
|
+
const [state, setInternalState] = React.useState<T>(
|
|
16
|
+
value !== undefined ? value : (defaultValue as T),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (value !== undefined) setInternalState(value);
|
|
21
|
+
}, [value]);
|
|
22
|
+
|
|
23
|
+
const setState = React.useCallback(
|
|
24
|
+
(next: T, ...args: Rest) => {
|
|
25
|
+
setInternalState(next);
|
|
26
|
+
onChange?.(next, ...args);
|
|
27
|
+
},
|
|
28
|
+
[onChange],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return [state, setState] as const;
|
|
32
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768;
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
+
};
|
|
13
|
+
mql.addEventListener('change', onChange);
|
|
14
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
15
|
+
return () => mql.removeEventListener('change', onChange);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
return !!isMobile;
|
|
19
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Auto-generated file. Do not edit manually.
|
|
2
|
+
export * from './components/ui/Accordion';
|
|
3
|
+
export * from './components/ui/Alert';
|
|
4
|
+
export * from './components/ui/AlertDialog';
|
|
5
|
+
export * from './components/ui/AspectRatio';
|
|
6
|
+
export * from './components/ui/Avatar';
|
|
7
|
+
export * from './components/ui/Badge';
|
|
8
|
+
export * from './components/ui/Breadcrumb';
|
|
9
|
+
export * from './components/ui/Button';
|
|
10
|
+
export * from './components/ui/Calendar';
|
|
11
|
+
export * from './components/ui/Card';
|
|
12
|
+
export * from './components/ui/Carousel';
|
|
13
|
+
export * from './components/ui/Chart';
|
|
14
|
+
export * from './components/ui/Checkbox';
|
|
15
|
+
export * from './components/ui/CircleProcess';
|
|
16
|
+
export * from './components/ui/Collapsible';
|
|
17
|
+
export * from './components/ui/Command';
|
|
18
|
+
export * from './components/ui/Container';
|
|
19
|
+
export * from './components/ui/ContextMenu';
|
|
20
|
+
export * from './components/ui/Dialog';
|
|
21
|
+
export * from './components/ui/Drawer';
|
|
22
|
+
export * from './components/ui/DropdownMenu';
|
|
23
|
+
export * from './components/ui/Dropzone';
|
|
24
|
+
export * from './components/ui/Form';
|
|
25
|
+
export * from './components/ui/HStack';
|
|
26
|
+
export * from './components/ui/HoverCard';
|
|
27
|
+
export * from './components/ui/Icons';
|
|
28
|
+
export * from './components/ui/ImageWithFallback';
|
|
29
|
+
export * from './components/ui/Input';
|
|
30
|
+
export * from './components/ui/InputOtp';
|
|
31
|
+
export * from './components/ui/Label';
|
|
32
|
+
export * from './components/ui/Marquee';
|
|
33
|
+
export * from './components/ui/Menubar';
|
|
34
|
+
export * from './components/ui/NavigationMenu';
|
|
35
|
+
export * from './components/ui/NoData';
|
|
36
|
+
export * from './components/ui/Pagination';
|
|
37
|
+
export * from './components/ui/Popover';
|
|
38
|
+
export * from './components/ui/Progress';
|
|
39
|
+
export * from './components/ui/RadioGroup';
|
|
40
|
+
export * from './components/ui/Resizable';
|
|
41
|
+
export * from './components/ui/ScrollArea';
|
|
42
|
+
export * from './components/ui/Select';
|
|
43
|
+
export * from './components/ui/Separator';
|
|
44
|
+
export * from './components/ui/Sheet';
|
|
45
|
+
export * from './components/ui/Sidebar';
|
|
46
|
+
export * from './components/ui/Skeleton';
|
|
47
|
+
export * from './components/ui/Slider';
|
|
48
|
+
export * from './components/ui/Slot';
|
|
49
|
+
export * from './components/ui/Sonner';
|
|
50
|
+
export * from './components/ui/Switch';
|
|
51
|
+
export * from './components/ui/Table';
|
|
52
|
+
export * from './components/ui/Tabs';
|
|
53
|
+
export * from './components/ui/Text';
|
|
54
|
+
export * from './components/ui/Textarea';
|
|
55
|
+
export * from './components/ui/Toggle';
|
|
56
|
+
export * from './components/ui/ToggleGroup';
|
|
57
|
+
export * from './components/ui/Tooltip';
|
|
58
|
+
export * from './components/ui/VStack';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export function getStrictContext<T>(name: string) {
|
|
4
|
+
const Context = React.createContext<T | undefined>(undefined);
|
|
5
|
+
|
|
6
|
+
function useContext() {
|
|
7
|
+
const context = React.useContext(Context);
|
|
8
|
+
if (context === undefined) {
|
|
9
|
+
throw new Error(`use${name} must be used within a ${name}Provider`);
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return [Context.Provider, useContext] as const;
|
|
15
|
+
}
|
package/lib/utils.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { clsx, type ClassValue } from 'clsx';
|
|
2
|
+
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs: ClassValue[]) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function onMutateError(error: unknown) {
|
|
9
|
+
console.error('Mutation error:', error);
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luanthnh/cntt-ui",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": [
|
|
6
|
+
"**/*.css"
|
|
7
|
+
],
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./globals.css": "./globals.css"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"generate:exports": "tsx scripts/generate-exports.ts",
|
|
23
|
+
"prebuild": "pnpm generate:exports",
|
|
24
|
+
"dev": "storybook dev -p 6006",
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"build:storybook": "storybook build"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@base-ui-components/react": "1.0.0-rc.0",
|
|
30
|
+
"@hookform/resolvers": "^5.2.2",
|
|
31
|
+
"@radix-ui/react-accordion": "^1.2.1",
|
|
32
|
+
"@radix-ui/react-alert-dialog": "^1.1.2",
|
|
33
|
+
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
|
34
|
+
"@radix-ui/react-avatar": "^1.1.1",
|
|
35
|
+
"@radix-ui/react-checkbox": "^1.1.2",
|
|
36
|
+
"@radix-ui/react-collapsible": "^1.1.1",
|
|
37
|
+
"@radix-ui/react-context-menu": "^2.2.2",
|
|
38
|
+
"@radix-ui/react-dialog": "^1.1.2",
|
|
39
|
+
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
40
|
+
"@radix-ui/react-hover-card": "^1.1.2",
|
|
41
|
+
"@radix-ui/react-label": "^2.1.0",
|
|
42
|
+
"@radix-ui/react-menubar": "^1.1.2",
|
|
43
|
+
"@radix-ui/react-navigation-menu": "^1.2.1",
|
|
44
|
+
"@radix-ui/react-popover": "^1.1.2",
|
|
45
|
+
"@radix-ui/react-progress": "^1.1.0",
|
|
46
|
+
"@radix-ui/react-radio-group": "^1.2.1",
|
|
47
|
+
"@radix-ui/react-scroll-area": "^1.2.1",
|
|
48
|
+
"@radix-ui/react-select": "^2.1.2",
|
|
49
|
+
"@radix-ui/react-separator": "^1.1.0",
|
|
50
|
+
"@radix-ui/react-slider": "^1.2.1",
|
|
51
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
52
|
+
"@radix-ui/react-switch": "^1.1.1",
|
|
53
|
+
"@radix-ui/react-tabs": "^1.1.1",
|
|
54
|
+
"@radix-ui/react-toggle": "^1.1.0",
|
|
55
|
+
"@radix-ui/react-toggle-group": "^1.1.0",
|
|
56
|
+
"@radix-ui/react-tooltip": "^1.1.4",
|
|
57
|
+
"class-variance-authority": "^0.7.1",
|
|
58
|
+
"clsx": "^2.1.1",
|
|
59
|
+
"cmdk": "1.0.0",
|
|
60
|
+
"date-fns": "^4.1.0",
|
|
61
|
+
"embla-carousel-react": "^8.5.1",
|
|
62
|
+
"framer-motion": "^11.13.1",
|
|
63
|
+
"input-otp": "^1.4.1",
|
|
64
|
+
"lenis": "^1.1.18",
|
|
65
|
+
"lucide-react": "^0.462.0",
|
|
66
|
+
"motion": "^11.11.17",
|
|
67
|
+
"next-themes": "^0.4.3",
|
|
68
|
+
"radix-ui": "^1.4.3",
|
|
69
|
+
"react-day-picker": "^9.13.0",
|
|
70
|
+
"react-dropzone": "^14.3.8",
|
|
71
|
+
"react-hook-form": "^7.69.0",
|
|
72
|
+
"react-resizable-panels": "^4.0.15",
|
|
73
|
+
"recharts": "^2.13.3",
|
|
74
|
+
"sonner": "^1.7.0",
|
|
75
|
+
"tailwind-merge": "^2.5.5",
|
|
76
|
+
"tailwindcss-animate": "^1.0.7",
|
|
77
|
+
"tempus": "1.0.0-dev.17",
|
|
78
|
+
"vaul": "^1.1.1",
|
|
79
|
+
"zod": "^4.2.1"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"react": ">=18",
|
|
83
|
+
"react-dom": ">=18"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@storybook/addon-essentials": "^8.6.15",
|
|
87
|
+
"@storybook/addon-interactions": "^8.6.15",
|
|
88
|
+
"@storybook/addon-onboarding": "^1.0.11",
|
|
89
|
+
"@storybook/blocks": "^8.6.15",
|
|
90
|
+
"@storybook/react": "^8.6.15",
|
|
91
|
+
"@storybook/react-vite": "^8.6.15",
|
|
92
|
+
"@storybook/test": "^8.6.15",
|
|
93
|
+
"@tailwindcss/typography": "^0.5.15",
|
|
94
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
95
|
+
"@types/react": "^19.2.7",
|
|
96
|
+
"@types/react-dom": "^19.2.3",
|
|
97
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
98
|
+
"react": "19.2.3",
|
|
99
|
+
"react-dom": "19.2.3",
|
|
100
|
+
"storybook": "^8.6.15",
|
|
101
|
+
"tailwindcss": "^4.0.0",
|
|
102
|
+
"tsup": "^8.5.1",
|
|
103
|
+
"tsx": "^4.21.0",
|
|
104
|
+
"typescript": "^5.9.3",
|
|
105
|
+
"vite": "^7.3.0"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
async function generateExports() {
|
|
5
|
+
const componentsDir = path.join(process.cwd(), 'components/ui');
|
|
6
|
+
const componentDirs = await fs.readdir(componentsDir, { withFileTypes: true });
|
|
7
|
+
|
|
8
|
+
const exports = [];
|
|
9
|
+
|
|
10
|
+
for (const dir of componentDirs) {
|
|
11
|
+
if (dir.isDirectory()) {
|
|
12
|
+
const componentName = dir.name;
|
|
13
|
+
const indexPath = path.join(dir.path, dir.name, 'index.tsx');
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await fs.access(indexPath);
|
|
17
|
+
exports.push(`export * from "./components/ui/${componentName}"`);
|
|
18
|
+
} catch {
|
|
19
|
+
console.warn(`No index.tsx found for component: ${componentName}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const content = `// Auto-generated file. Do not edit manually.
|
|
25
|
+
${exports.join('\n')}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
await fs.writeFile(path.join(process.cwd(), 'index.ts'), content);
|
|
29
|
+
console.log('Exports generated successfully!');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
generateExports().catch(console.error);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"ignoreDeprecations": "5.0",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@/*": ["./*"]
|
|
8
|
+
},
|
|
9
|
+
"incremental": false
|
|
10
|
+
},
|
|
11
|
+
"include": ["**/*.ts", "**/*.tsx", "types/*.d.ts", "lib", "scripts", "hooks", "components"]
|
|
12
|
+
}
|