@cntyclub/ui-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-HDGMSYQS.js +26461 -0
- package/dist/chunk-HDGMSYQS.js.map +1 -0
- package/dist/chunk-PR4QN5HX.js +39 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/form.d.ts +175 -0
- package/dist/form.js +5207 -0
- package/dist/form.js.map +1 -0
- package/dist/index.d.ts +1462 -0
- package/dist/index.js +81862 -0
- package/dist/index.js.map +1 -0
- package/dist/input-CZvh825j.d.ts +24 -0
- package/dist/qr-code-styling-3Y6LZH6V.js +1123 -0
- package/dist/qr-code-styling-3Y6LZH6V.js.map +1 -0
- package/package.json +79 -0
- package/src/components/form/checkbox-group-field.tsx +101 -0
- package/src/components/form/date-field.tsx +79 -0
- package/src/components/form/date-range-field.tsx +106 -0
- package/src/components/form/form-context.ts +10 -0
- package/src/components/form/form.tsx +54 -0
- package/src/components/form/number-field.tsx +69 -0
- package/src/components/form/select-field.tsx +76 -0
- package/src/components/form/submit-button.tsx +28 -0
- package/src/components/form/text-field.tsx +107 -0
- package/src/components/layout/dashboard-header.tsx +54 -0
- package/src/components/layout/dashboard-panel.tsx +34 -0
- package/src/components/theme-provider.tsx +403 -0
- package/src/components/ui/accordion.tsx +69 -0
- package/src/components/ui/alert-dialog.tsx +169 -0
- package/src/components/ui/alert.tsx +80 -0
- package/src/components/ui/animated-theme-toggler.tsx +265 -0
- package/src/components/ui/app-store-buttons.tsx +182 -0
- package/src/components/ui/aspect-ratio.tsx +23 -0
- package/src/components/ui/autocomplete.tsx +296 -0
- package/src/components/ui/avatar-group.tsx +95 -0
- package/src/components/ui/avatar.tsx +285 -0
- package/src/components/ui/badge-group.tsx +160 -0
- package/src/components/ui/badge.tsx +172 -0
- package/src/components/ui/breadcrumb.tsx +112 -0
- package/src/components/ui/button.tsx +77 -0
- package/src/components/ui/calendar.tsx +137 -0
- package/src/components/ui/card.tsx +244 -0
- package/src/components/ui/carousel.tsx +258 -0
- package/src/components/ui/chart.tsx +379 -0
- package/src/components/ui/checkbox-group.tsx +16 -0
- package/src/components/ui/checkbox.tsx +82 -0
- package/src/components/ui/collapsible.tsx +45 -0
- package/src/components/ui/combobox.tsx +411 -0
- package/src/components/ui/command.tsx +264 -0
- package/src/components/ui/context-menu.tsx +271 -0
- package/src/components/ui/credit-card.tsx +214 -0
- package/src/components/ui/dialog.tsx +196 -0
- package/src/components/ui/drawer.tsx +135 -0
- package/src/components/ui/empty.tsx +127 -0
- package/src/components/ui/featured-icon.tsx +149 -0
- package/src/components/ui/field.tsx +88 -0
- package/src/components/ui/fieldset.tsx +29 -0
- package/src/components/ui/form.tsx +17 -0
- package/src/components/ui/frame.tsx +82 -0
- package/src/components/ui/generic-empty.tsx +142 -0
- package/src/components/ui/group.tsx +97 -0
- package/src/components/ui/horizontal-scroll-fader.tsx +228 -0
- package/src/components/ui/input-group.tsx +102 -0
- package/src/components/ui/input-otp.tsx +96 -0
- package/src/components/ui/input.tsx +66 -0
- package/src/components/ui/item.tsx +198 -0
- package/src/components/ui/kbd.tsx +30 -0
- package/src/components/ui/label.tsx +28 -0
- package/src/components/ui/menu.tsx +312 -0
- package/src/components/ui/menubar.tsx +93 -0
- package/src/components/ui/meter.tsx +67 -0
- package/src/components/ui/multi-select.tsx +308 -0
- package/src/components/ui/navigation-menu.tsx +143 -0
- package/src/components/ui/number-field.tsx +160 -0
- package/src/components/ui/pagination-controls.tsx +74 -0
- package/src/components/ui/pagination.tsx +149 -0
- package/src/components/ui/popover.tsx +119 -0
- package/src/components/ui/preview-card.tsx +55 -0
- package/src/components/ui/progress.tsx +289 -0
- package/src/components/ui/qr-code.tsx +150 -0
- package/src/components/ui/radio-group.tsx +103 -0
- package/src/components/ui/resizable.tsx +56 -0
- package/src/components/ui/scroll-area.tsx +90 -0
- package/src/components/ui/scroller.tsx +38 -0
- package/src/components/ui/section-header.tsx +118 -0
- package/src/components/ui/select.tsx +181 -0
- package/src/components/ui/separator.tsx +23 -0
- package/src/components/ui/sheet.tsx +224 -0
- package/src/components/ui/sidebar.tsx +744 -0
- package/src/components/ui/skeleton.tsx +16 -0
- package/src/components/ui/slider.tsx +108 -0
- package/src/components/ui/smooth-scroll.tsx +143 -0
- package/src/components/ui/social-button.tsx +247 -0
- package/src/components/ui/spinner-on-demand.tsx +32 -0
- package/src/components/ui/spinner.tsx +18 -0
- package/src/components/ui/stat.tsx +187 -0
- package/src/components/ui/stepper.tsx +167 -0
- package/src/components/ui/switch.tsx +56 -0
- package/src/components/ui/table.tsx +126 -0
- package/src/components/ui/tabs.tsx +90 -0
- package/src/components/ui/tag.tsx +229 -0
- package/src/components/ui/target-countdown.tsx +46 -0
- package/src/components/ui/text-editor.tsx +313 -0
- package/src/components/ui/textarea.tsx +51 -0
- package/src/components/ui/timeline.tsx +116 -0
- package/src/components/ui/toast.tsx +268 -0
- package/src/components/ui/toggle-group.tsx +101 -0
- package/src/components/ui/toggle.tsx +45 -0
- package/src/components/ui/toolbar.tsx +89 -0
- package/src/components/ui/tooltip.tsx +102 -0
- package/src/components/ui/vertical-scroll-fader.tsx +250 -0
- package/src/components/ui/video-player.tsx +275 -0
- package/src/components/upload/avatar-upload-base.tsx +131 -0
- package/src/components/upload/image-upload-base.tsx +112 -0
- package/src/form.ts +17 -0
- package/src/index.ts +125 -0
- package/src/lib/hooks/use-callback-ref.ts +15 -0
- package/src/lib/hooks/use-first-render.ts +11 -0
- package/src/lib/hooks/use-hover.ts +53 -0
- package/src/lib/hooks/use-is-tab-active.ts +17 -0
- package/src/lib/hooks/use-media-query.ts +164 -0
- package/src/lib/utils/css.ts +6 -0
- package/src/styles.css +300 -0
- package/src/types/helpers.ts +24 -0
- package/src/types/react.d.ts +7 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Progress as ProgressPrimitive } from "@base-ui/react";
|
|
4
|
+
import { Transition } from "@headlessui/react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { CloudUploadIcon, TrashIcon, UserIcon } from "lucide-react";
|
|
7
|
+
import { useDropzone } from "react-dropzone";
|
|
8
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar";
|
|
9
|
+
import { Button } from "../ui/button";
|
|
10
|
+
import { SpinnerOnDemand } from "../ui/spinner-on-demand";
|
|
11
|
+
|
|
12
|
+
export interface AvatarUploadBaseProps
|
|
13
|
+
extends Omit<React.ComponentProps<typeof Avatar>, "onDrop" | "children"> {
|
|
14
|
+
onDrop: (file: File) => void;
|
|
15
|
+
onDelete?: () => void;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
progress: number;
|
|
19
|
+
imageUrl: string | undefined;
|
|
20
|
+
initials: React.ReactNode;
|
|
21
|
+
alt: string;
|
|
22
|
+
avatarClassName?: string;
|
|
23
|
+
mode?: "image" | "image&video";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function AvatarUploadBase({
|
|
27
|
+
onDrop,
|
|
28
|
+
onDelete,
|
|
29
|
+
disabled,
|
|
30
|
+
loading = false,
|
|
31
|
+
progress,
|
|
32
|
+
imageUrl,
|
|
33
|
+
initials,
|
|
34
|
+
alt,
|
|
35
|
+
className,
|
|
36
|
+
avatarClassName,
|
|
37
|
+
mode = "image",
|
|
38
|
+
...props
|
|
39
|
+
}: AvatarUploadBaseProps) {
|
|
40
|
+
const {
|
|
41
|
+
getRootProps,
|
|
42
|
+
getInputProps,
|
|
43
|
+
open: onDropOpen,
|
|
44
|
+
isDragActive,
|
|
45
|
+
} = useDropzone({
|
|
46
|
+
onDrop: ([file]) => file && onDrop(file),
|
|
47
|
+
noClick: true,
|
|
48
|
+
accept: {
|
|
49
|
+
"image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp"],
|
|
50
|
+
...(mode === "image&video"
|
|
51
|
+
? { "video/*": [".webm", ".mp4"] }
|
|
52
|
+
: undefined),
|
|
53
|
+
},
|
|
54
|
+
multiple: false,
|
|
55
|
+
disabled: disabled || loading,
|
|
56
|
+
});
|
|
57
|
+
const progressValue = Math.trunc(100 * Math.min(1, progress));
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
{...getRootProps()}
|
|
62
|
+
tabIndex={undefined}
|
|
63
|
+
className={clsx(
|
|
64
|
+
"relative flex items-center gap-3 rounded-full",
|
|
65
|
+
className,
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
<input {...getInputProps()} />
|
|
69
|
+
<Avatar className={avatarClassName} key={imageUrl} {...props}>
|
|
70
|
+
<AvatarImage src={imageUrl} alt={alt} />
|
|
71
|
+
<AvatarFallback className="text-xl">
|
|
72
|
+
{initials || <UserIcon />}
|
|
73
|
+
</AvatarFallback>
|
|
74
|
+
</Avatar>
|
|
75
|
+
<div className="relative flex items-center gap-3 transition">
|
|
76
|
+
<Button
|
|
77
|
+
size="sm"
|
|
78
|
+
variant="outline"
|
|
79
|
+
disabled={loading || disabled}
|
|
80
|
+
onClick={onDropOpen}
|
|
81
|
+
className="grow relative max-w-55 mx-auto"
|
|
82
|
+
>
|
|
83
|
+
<SpinnerOnDemand icon={<CloudUploadIcon />} isLoading={loading} />
|
|
84
|
+
Upload
|
|
85
|
+
<Transition
|
|
86
|
+
show={loading}
|
|
87
|
+
as={ProgressPrimitive.Root}
|
|
88
|
+
className="absolute inset-0 grow overflow-hidden rounded-[inherit] pointer-events-none"
|
|
89
|
+
style={{
|
|
90
|
+
// Fix overflow clipping in Safari
|
|
91
|
+
// https://gist.github.com/domske/b66047671c780a238b51c51ffde8d3a0
|
|
92
|
+
transform: "translateZ(0)",
|
|
93
|
+
}}
|
|
94
|
+
value={progressValue}
|
|
95
|
+
>
|
|
96
|
+
<ProgressPrimitive.Track className="size-full">
|
|
97
|
+
<ProgressPrimitive.Indicator
|
|
98
|
+
className="duration-660 ease-[cubic-bezier(0.65,0,0.35,1)] size-full bg-accent/8 transition-transform"
|
|
99
|
+
style={{ transform: `translateX(-${100 - progressValue}%)` }}
|
|
100
|
+
/>
|
|
101
|
+
</ProgressPrimitive.Track>
|
|
102
|
+
</Transition>
|
|
103
|
+
</Button>
|
|
104
|
+
{imageUrl && onDelete && (
|
|
105
|
+
<Button
|
|
106
|
+
disabled={disabled || loading}
|
|
107
|
+
size="icon-sm"
|
|
108
|
+
variant="outline"
|
|
109
|
+
onClick={onDelete}
|
|
110
|
+
>
|
|
111
|
+
<TrashIcon />
|
|
112
|
+
<span className="sr-only">Remove</span>
|
|
113
|
+
</Button>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
<Transition
|
|
117
|
+
as="div"
|
|
118
|
+
show={isDragActive}
|
|
119
|
+
className={clsx(
|
|
120
|
+
"pointer-events-none absolute inset-0 flex flex-col items-center justify-center rounded-2xl transition duration-200 [--opacity:1] data-closed:[--opacity:0]",
|
|
121
|
+
"bg-accent/[calc(var(--opacity)*8%)] ring-1 ring-border/[calc(var(--opacity)*100%)] backdrop-blur-[calc(var(--opacity)*var(--blur-sm))]",
|
|
122
|
+
)}
|
|
123
|
+
>
|
|
124
|
+
<CloudUploadIcon className="size-8 text-foreground/[calc(var(--opacity)*100%)] transition-colors" />
|
|
125
|
+
<p className="text-sm font-medium text-foreground/[calc(var(--opacity)*100%)] transition-colors">
|
|
126
|
+
Drop files here
|
|
127
|
+
</p>
|
|
128
|
+
</Transition>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Progress as ProgressPrimitive } from "@base-ui/react";
|
|
4
|
+
import { Transition } from "@headlessui/react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { CloudUploadIcon, TrashIcon } from "lucide-react";
|
|
7
|
+
import { useDropzone } from "react-dropzone";
|
|
8
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar";
|
|
9
|
+
import { Button } from "../ui/button";
|
|
10
|
+
import { SpinnerOnDemand } from "../ui/spinner-on-demand";
|
|
11
|
+
|
|
12
|
+
export interface ImageUploadBaseProps
|
|
13
|
+
extends Omit<React.ComponentProps<"div">, "onDrop"> {
|
|
14
|
+
onDrop: (file: File) => void;
|
|
15
|
+
onDelete?: () => void;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
progress: number;
|
|
19
|
+
imageUrl: string | null;
|
|
20
|
+
alt: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function ImageUploadBase({
|
|
24
|
+
onDrop,
|
|
25
|
+
onDelete,
|
|
26
|
+
disabled,
|
|
27
|
+
loading = false,
|
|
28
|
+
progress,
|
|
29
|
+
imageUrl,
|
|
30
|
+
alt,
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
}: ImageUploadBaseProps) {
|
|
34
|
+
const {
|
|
35
|
+
getRootProps,
|
|
36
|
+
getInputProps,
|
|
37
|
+
open: onDropOpen,
|
|
38
|
+
isDragActive,
|
|
39
|
+
} = useDropzone({
|
|
40
|
+
onDrop: ([file]) => file && onDrop(file),
|
|
41
|
+
noClick: true,
|
|
42
|
+
accept: {
|
|
43
|
+
"image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp"],
|
|
44
|
+
},
|
|
45
|
+
multiple: false,
|
|
46
|
+
disabled: disabled || loading,
|
|
47
|
+
});
|
|
48
|
+
const progressValue = Math.trunc(100 * Math.min(1, progress));
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
{...getRootProps()}
|
|
53
|
+
tabIndex={undefined}
|
|
54
|
+
data-slot="image-upload-root"
|
|
55
|
+
className={clsx(
|
|
56
|
+
"group/image-upload-root flex flex-col rounded-lg border-2 p-0.5 border-dashed border-input bg-muted/30 text-center transition-colors hover:border-muted-foreground/40 hover:bg-muted/50 has-data-[active=true]:border-primary/60 has-data-[active=true]:bg-primary/5",
|
|
57
|
+
className,
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
<div className="flex flex-col relative rounded-md">
|
|
62
|
+
<input {...getInputProps()} />
|
|
63
|
+
<Avatar
|
|
64
|
+
key={imageUrl ?? "none"}
|
|
65
|
+
className="peer/avatar absolute size-full inset-0 rounded-[inherit]"
|
|
66
|
+
>
|
|
67
|
+
{imageUrl && (
|
|
68
|
+
<AvatarImage key={imageUrl ?? "none"} src={imageUrl} alt={alt} />
|
|
69
|
+
)}
|
|
70
|
+
<AvatarFallback className="bg-linear-to-br from-muted to-background" />
|
|
71
|
+
</Avatar>
|
|
72
|
+
<div
|
|
73
|
+
data-active={loading || isDragActive}
|
|
74
|
+
className="flex justify-center items-center [--opacity:0] p-8 data-[active=true]:[--opacity:1] peer-has-data-[slot=avatar-fallback]/avatar:[--opacity:1] group-hover/image-upload-root:[--opacity:1] relative z-10 rounded-[inherit] bg-background/[calc(55%*var(--opacity))] backdrop-blur-[calc(var(--blur-xs)*var(--opacity))] gap-3 transition"
|
|
75
|
+
>
|
|
76
|
+
<Button
|
|
77
|
+
size="sm"
|
|
78
|
+
variant="outline"
|
|
79
|
+
disabled={loading || disabled}
|
|
80
|
+
onClick={onDropOpen}
|
|
81
|
+
className="grow relative max-w-32 opacity-(--opacity)"
|
|
82
|
+
>
|
|
83
|
+
<SpinnerOnDemand icon={<CloudUploadIcon />} isLoading={loading} />
|
|
84
|
+
{isDragActive ? "Drop files here" : "Upload"}
|
|
85
|
+
<Transition
|
|
86
|
+
show={loading}
|
|
87
|
+
as={ProgressPrimitive.Root}
|
|
88
|
+
className="absolute inset-0 opacity-(--opacity) grow overflow-hidden rounded-[inherit] pointer-events-none"
|
|
89
|
+
value={progressValue}
|
|
90
|
+
>
|
|
91
|
+
<ProgressPrimitive.Track className="size-full">
|
|
92
|
+
<ProgressPrimitive.Indicator className="duration-660 ease-[cubic-bezier(0.65,0,0.35,1)] size-full bg-accent/8 transition-all" />
|
|
93
|
+
</ProgressPrimitive.Track>
|
|
94
|
+
</Transition>
|
|
95
|
+
</Button>
|
|
96
|
+
{imageUrl && onDelete && !isDragActive && (
|
|
97
|
+
<Button
|
|
98
|
+
disabled={disabled || loading}
|
|
99
|
+
size="icon-sm"
|
|
100
|
+
variant="outline"
|
|
101
|
+
onClick={onDelete}
|
|
102
|
+
className="opacity-(--opacity)"
|
|
103
|
+
aria-label="Remove"
|
|
104
|
+
>
|
|
105
|
+
<TrashIcon />
|
|
106
|
+
</Button>
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
package/src/form.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Country Club UI Kit — TanStack Form bindings.
|
|
2
|
+
// Import from "@countryclub/ui-react/form".
|
|
3
|
+
|
|
4
|
+
export * from "./components/form/checkbox-group-field";
|
|
5
|
+
export * from "./components/form/date-field";
|
|
6
|
+
export * from "./components/form/date-range-field";
|
|
7
|
+
export * from "./components/form/form";
|
|
8
|
+
export {
|
|
9
|
+
appFieldContext,
|
|
10
|
+
appFormContext,
|
|
11
|
+
useAppFieldContext,
|
|
12
|
+
useAppFormContext,
|
|
13
|
+
} from "./components/form/form-context";
|
|
14
|
+
export * from "./components/form/number-field";
|
|
15
|
+
export * from "./components/form/select-field";
|
|
16
|
+
export * from "./components/form/submit-button";
|
|
17
|
+
export * from "./components/form/text-field";
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Country Club UI Kit — React component library.
|
|
2
|
+
// Design tokens live in ./styles.css (Tailwind CSS v4).
|
|
3
|
+
|
|
4
|
+
// Core UI components
|
|
5
|
+
export * from "./components/ui/accordion";
|
|
6
|
+
export * from "./components/ui/alert";
|
|
7
|
+
export * from "./components/ui/alert-dialog";
|
|
8
|
+
export * from "./components/ui/animated-theme-toggler";
|
|
9
|
+
export * from "./components/ui/app-store-buttons";
|
|
10
|
+
export * from "./components/ui/aspect-ratio";
|
|
11
|
+
export * from "./components/ui/autocomplete";
|
|
12
|
+
export * from "./components/ui/avatar";
|
|
13
|
+
export * from "./components/ui/avatar-group";
|
|
14
|
+
export * from "./components/ui/badge";
|
|
15
|
+
export * from "./components/ui/badge-group";
|
|
16
|
+
export * from "./components/ui/breadcrumb";
|
|
17
|
+
export * from "./components/ui/button";
|
|
18
|
+
export * from "./components/ui/calendar";
|
|
19
|
+
export * from "./components/ui/card";
|
|
20
|
+
export * from "./components/ui/carousel";
|
|
21
|
+
export * from "./components/ui/chart";
|
|
22
|
+
export * from "./components/ui/checkbox";
|
|
23
|
+
export * from "./components/ui/checkbox-group";
|
|
24
|
+
export * from "./components/ui/collapsible";
|
|
25
|
+
export * from "./components/ui/combobox";
|
|
26
|
+
export * from "./components/ui/command";
|
|
27
|
+
export * from "./components/ui/credit-card";
|
|
28
|
+
export * from "./components/ui/drawer";
|
|
29
|
+
export * from "./components/ui/context-menu";
|
|
30
|
+
export * from "./components/ui/dialog";
|
|
31
|
+
export * from "./components/ui/empty";
|
|
32
|
+
export * from "./components/ui/featured-icon";
|
|
33
|
+
export * from "./components/ui/field";
|
|
34
|
+
export * from "./components/ui/fieldset";
|
|
35
|
+
export * from "./components/ui/form";
|
|
36
|
+
export * from "./components/ui/frame";
|
|
37
|
+
export * from "./components/ui/generic-empty";
|
|
38
|
+
export * from "./components/ui/group";
|
|
39
|
+
export * from "./components/ui/horizontal-scroll-fader";
|
|
40
|
+
export * from "./components/ui/input";
|
|
41
|
+
export * from "./components/ui/input-group";
|
|
42
|
+
export * from "./components/ui/input-otp";
|
|
43
|
+
export * from "./components/ui/item";
|
|
44
|
+
export * from "./components/ui/kbd";
|
|
45
|
+
export * from "./components/ui/label";
|
|
46
|
+
export * from "./components/ui/menu";
|
|
47
|
+
export * from "./components/ui/menubar";
|
|
48
|
+
export * from "./components/ui/meter";
|
|
49
|
+
export * from "./components/ui/multi-select";
|
|
50
|
+
export * from "./components/ui/navigation-menu";
|
|
51
|
+
export * from "./components/ui/number-field";
|
|
52
|
+
export * from "./components/ui/pagination";
|
|
53
|
+
export * from "./components/ui/pagination-controls";
|
|
54
|
+
export * from "./components/ui/popover";
|
|
55
|
+
export * from "./components/ui/preview-card";
|
|
56
|
+
export * from "./components/ui/progress";
|
|
57
|
+
export * from "./components/ui/qr-code";
|
|
58
|
+
export * from "./components/ui/radio-group";
|
|
59
|
+
export * from "./components/ui/resizable";
|
|
60
|
+
export * from "./components/ui/scroll-area";
|
|
61
|
+
export * from "./components/ui/scroller";
|
|
62
|
+
export * from "./components/ui/section-header";
|
|
63
|
+
export * from "./components/ui/smooth-scroll";
|
|
64
|
+
export * from "./components/ui/social-button";
|
|
65
|
+
export * from "./components/ui/stepper";
|
|
66
|
+
export * from "./components/ui/select";
|
|
67
|
+
export * from "./components/ui/separator";
|
|
68
|
+
export * from "./components/ui/sheet";
|
|
69
|
+
export * from "./components/ui/sidebar";
|
|
70
|
+
export * from "./components/ui/skeleton";
|
|
71
|
+
export * from "./components/ui/slider";
|
|
72
|
+
export * from "./components/ui/spinner";
|
|
73
|
+
export * from "./components/ui/spinner-on-demand";
|
|
74
|
+
export * from "./components/ui/stat";
|
|
75
|
+
export * from "./components/ui/switch";
|
|
76
|
+
export * from "./components/ui/table";
|
|
77
|
+
export * from "./components/ui/tabs";
|
|
78
|
+
export * from "./components/ui/tag";
|
|
79
|
+
export { default as TargetCountdown } from "./components/ui/target-countdown";
|
|
80
|
+
export * from "./components/ui/timeline";
|
|
81
|
+
export * from "./components/ui/text-editor";
|
|
82
|
+
export * from "./components/ui/textarea";
|
|
83
|
+
export * from "./components/ui/toast";
|
|
84
|
+
export * from "./components/ui/toggle";
|
|
85
|
+
export {
|
|
86
|
+
ToggleGroup,
|
|
87
|
+
ToggleGroupItem,
|
|
88
|
+
ToggleGroupSeparator,
|
|
89
|
+
} from "./components/ui/toggle-group";
|
|
90
|
+
export * from "./components/ui/toolbar";
|
|
91
|
+
export * from "./components/ui/tooltip";
|
|
92
|
+
export * from "./components/ui/vertical-scroll-fader";
|
|
93
|
+
export * from "./components/ui/video-player";
|
|
94
|
+
|
|
95
|
+
// Layout components
|
|
96
|
+
export * from "./components/layout/dashboard-header";
|
|
97
|
+
export * from "./components/layout/dashboard-panel";
|
|
98
|
+
|
|
99
|
+
// Theme
|
|
100
|
+
export * from "./components/theme-provider";
|
|
101
|
+
|
|
102
|
+
// Upload
|
|
103
|
+
export * from "./components/upload/avatar-upload-base";
|
|
104
|
+
export * from "./components/upload/image-upload-base";
|
|
105
|
+
|
|
106
|
+
// Utilities
|
|
107
|
+
export { cn } from "./lib/utils/css";
|
|
108
|
+
|
|
109
|
+
// Hooks
|
|
110
|
+
export { default as useCallbackRef } from "./lib/hooks/use-callback-ref";
|
|
111
|
+
export { useFirstRender } from "./lib/hooks/use-first-render";
|
|
112
|
+
export { useHover } from "./lib/hooks/use-hover";
|
|
113
|
+
export { default as useIsTabActive } from "./lib/hooks/use-is-tab-active";
|
|
114
|
+
export {
|
|
115
|
+
useIs2xl,
|
|
116
|
+
useIsLg,
|
|
117
|
+
useIsMd,
|
|
118
|
+
useIsSm,
|
|
119
|
+
useIsXl,
|
|
120
|
+
useMediaQuery,
|
|
121
|
+
useSubscribeBreakpoints,
|
|
122
|
+
} from "./lib/hooks/use-media-query";
|
|
123
|
+
|
|
124
|
+
// Type helpers
|
|
125
|
+
export type * from "./types/helpers";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
|
|
5
|
+
// biome-ignore lint/suspicious/noExplicitAny: Generic shinanigans
|
|
6
|
+
function useCallbackRef<T extends (...args: Array<any>) => any>(fn: T): T {
|
|
7
|
+
const fnRef = useRef(fn);
|
|
8
|
+
fnRef.current = fn;
|
|
9
|
+
|
|
10
|
+
// biome-ignore lint/suspicious/noExplicitAny: Generic shinanigans
|
|
11
|
+
const ref = useRef((...args: Array<any>) => fnRef.current(...args));
|
|
12
|
+
return ref.current as T;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default useCallbackRef;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useRef, useState } from "react";
|
|
4
|
+
|
|
5
|
+
export function useHover<T extends Element>({
|
|
6
|
+
mounted = true,
|
|
7
|
+
}: {
|
|
8
|
+
mounted?: boolean;
|
|
9
|
+
} = {}): readonly [(node: T | null) => void, boolean] {
|
|
10
|
+
const [hovering, setHovering] = useState(false);
|
|
11
|
+
const previousNode = useRef<T | null>(null);
|
|
12
|
+
|
|
13
|
+
const [prevMounted, setPrevMounted] = useState(mounted);
|
|
14
|
+
if (mounted !== prevMounted) {
|
|
15
|
+
setPrevMounted(mounted);
|
|
16
|
+
if (!mounted) {
|
|
17
|
+
setHovering(false);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const handleMouseEnter = useCallback(() => {
|
|
22
|
+
setHovering(true);
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
const handleMouseLeave = useCallback(() => {
|
|
26
|
+
setHovering(false);
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
const customRef = useCallback<React.RefCallback<T>>(
|
|
30
|
+
(node) => {
|
|
31
|
+
if (previousNode.current?.nodeType === Node.ELEMENT_NODE) {
|
|
32
|
+
previousNode.current.removeEventListener(
|
|
33
|
+
"mouseenter",
|
|
34
|
+
handleMouseEnter,
|
|
35
|
+
);
|
|
36
|
+
previousNode.current.removeEventListener(
|
|
37
|
+
"mouseleave",
|
|
38
|
+
handleMouseLeave,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (node?.nodeType === Node.ELEMENT_NODE) {
|
|
43
|
+
node.addEventListener("mouseenter", handleMouseEnter);
|
|
44
|
+
node.addEventListener("mouseleave", handleMouseLeave);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
previousNode.current = node;
|
|
48
|
+
},
|
|
49
|
+
[handleMouseEnter, handleMouseLeave],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return [customRef, hovering] as const;
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
|
|
5
|
+
const subscribe = (onVisibilityChange: () => void) => {
|
|
6
|
+
window.addEventListener("visibilitychange", onVisibilityChange);
|
|
7
|
+
return () =>
|
|
8
|
+
window.removeEventListener("visibilitychange", onVisibilityChange);
|
|
9
|
+
};
|
|
10
|
+
const getSnapshot = () => !document.hidden;
|
|
11
|
+
const getServerSnapshot = () => true;
|
|
12
|
+
|
|
13
|
+
function useIsTabActive() {
|
|
14
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default useIsTabActive;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useLayoutEffect, useSyncExternalStore } from "react";
|
|
4
|
+
import { create } from "zustand";
|
|
5
|
+
import { useFirstRender } from "./use-first-render";
|
|
6
|
+
|
|
7
|
+
const breakpoints = ["sm", "md", "lg", "xl", "2xl"] as const;
|
|
8
|
+
type Breakpoints = (typeof breakpoints)[number];
|
|
9
|
+
|
|
10
|
+
const useBreakpointsStore = create<
|
|
11
|
+
{
|
|
12
|
+
[breakpoint in Breakpoints as `is${Capitalize<breakpoint>}`]: boolean;
|
|
13
|
+
} & {
|
|
14
|
+
[breakpoint in Breakpoints as `setIs${Capitalize<breakpoint>}`]: (
|
|
15
|
+
value: boolean,
|
|
16
|
+
) => void;
|
|
17
|
+
}
|
|
18
|
+
>((set) => ({
|
|
19
|
+
isSm: false,
|
|
20
|
+
isMd: false,
|
|
21
|
+
isLg: false,
|
|
22
|
+
isXl: false,
|
|
23
|
+
is2xl: false,
|
|
24
|
+
setIsSm: (value: boolean) => set({ isSm: value }),
|
|
25
|
+
setIsMd: (value: boolean) => set({ isMd: value }),
|
|
26
|
+
setIsLg: (value: boolean) => set({ isLg: value }),
|
|
27
|
+
setIsXl: (value: boolean) => set({ isXl: value }),
|
|
28
|
+
setIs2xl: (value: boolean) => set({ is2xl: value }),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const getBreakpointValue = (breakpoint: Breakpoints) =>
|
|
32
|
+
getComputedStyle(document.documentElement).getPropertyValue(
|
|
33
|
+
`--breakpoint-${breakpoint}`,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const setters = {
|
|
37
|
+
sm: "setIsSm" as const,
|
|
38
|
+
md: "setIsMd" as const,
|
|
39
|
+
lg: "setIsLg" as const,
|
|
40
|
+
xl: "setIsXl" as const,
|
|
41
|
+
"2xl": "setIs2xl" as const,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function useSyncWithStore(breakpoint: Breakpoints) {
|
|
45
|
+
const setBreakpoint = useBreakpointsStore(
|
|
46
|
+
(state) => state[setters[breakpoint]],
|
|
47
|
+
);
|
|
48
|
+
useLayoutEffect(() => {
|
|
49
|
+
const matchMedia = window.matchMedia(
|
|
50
|
+
`(min-width: ${getBreakpointValue(breakpoint)})`,
|
|
51
|
+
);
|
|
52
|
+
matchMedia.addEventListener("change", () => {
|
|
53
|
+
setBreakpoint(matchMedia.matches);
|
|
54
|
+
});
|
|
55
|
+
setBreakpoint(matchMedia.matches);
|
|
56
|
+
return () => {
|
|
57
|
+
matchMedia.removeEventListener("change", () => {
|
|
58
|
+
setBreakpoint(matchMedia.matches);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
}, [breakpoint, setBreakpoint]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// It could be lazy
|
|
65
|
+
export function useSubscribeBreakpoints() {
|
|
66
|
+
useSyncWithStore("sm");
|
|
67
|
+
useSyncWithStore("md");
|
|
68
|
+
useSyncWithStore("lg");
|
|
69
|
+
useSyncWithStore("xl");
|
|
70
|
+
useSyncWithStore("2xl");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface UseMediaQueryOptions {
|
|
74
|
+
ssr?: boolean;
|
|
75
|
+
defaultSSRValue?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function useMediaQuery(
|
|
79
|
+
query: string,
|
|
80
|
+
{ ssr = false, defaultSSRValue = false }: UseMediaQueryOptions = {},
|
|
81
|
+
) {
|
|
82
|
+
const subscribe = useCallback(
|
|
83
|
+
(callback: (m: MediaQueryListEvent) => void) => {
|
|
84
|
+
const matchMedia = window.matchMedia(query);
|
|
85
|
+
|
|
86
|
+
matchMedia.addEventListener("change", callback);
|
|
87
|
+
return () => {
|
|
88
|
+
matchMedia.removeEventListener("change", callback);
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
[query],
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const getSnapshot = () => window.matchMedia(query).matches;
|
|
95
|
+
|
|
96
|
+
const getServerSnapshot = () => defaultSSRValue;
|
|
97
|
+
|
|
98
|
+
const value = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
99
|
+
const isFirstRender = useFirstRender();
|
|
100
|
+
if (ssr && isFirstRender) {
|
|
101
|
+
return defaultSSRValue;
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function useIsSm({
|
|
107
|
+
ssr = false,
|
|
108
|
+
defaultSSRValue = false,
|
|
109
|
+
}: UseMediaQueryOptions = {}) {
|
|
110
|
+
const isFirstRender = useFirstRender();
|
|
111
|
+
const isSm = useBreakpointsStore((state) => state.isSm);
|
|
112
|
+
if (ssr && isFirstRender) {
|
|
113
|
+
return defaultSSRValue;
|
|
114
|
+
}
|
|
115
|
+
return isSm;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function useIsMd({
|
|
119
|
+
ssr = false,
|
|
120
|
+
defaultSSRValue = false,
|
|
121
|
+
}: UseMediaQueryOptions = {}) {
|
|
122
|
+
const isFirstRender = useFirstRender();
|
|
123
|
+
const isMd = useBreakpointsStore((state) => state.isMd);
|
|
124
|
+
if (ssr && isFirstRender) {
|
|
125
|
+
return defaultSSRValue;
|
|
126
|
+
}
|
|
127
|
+
return isMd;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function useIsLg({
|
|
131
|
+
ssr = false,
|
|
132
|
+
defaultSSRValue = false,
|
|
133
|
+
}: UseMediaQueryOptions = {}) {
|
|
134
|
+
const isFirstRender = useFirstRender();
|
|
135
|
+
const isLg = useBreakpointsStore((state) => state.isLg);
|
|
136
|
+
if (ssr && isFirstRender) {
|
|
137
|
+
return defaultSSRValue;
|
|
138
|
+
}
|
|
139
|
+
return isLg;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function useIsXl({
|
|
143
|
+
ssr = false,
|
|
144
|
+
defaultSSRValue = false,
|
|
145
|
+
}: UseMediaQueryOptions = {}) {
|
|
146
|
+
const isFirstRender = useFirstRender();
|
|
147
|
+
const isXl = useBreakpointsStore((state) => state.isXl);
|
|
148
|
+
if (ssr && isFirstRender) {
|
|
149
|
+
return defaultSSRValue;
|
|
150
|
+
}
|
|
151
|
+
return isXl;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function useIs2xl({
|
|
155
|
+
ssr = false,
|
|
156
|
+
defaultSSRValue = false,
|
|
157
|
+
}: UseMediaQueryOptions = {}) {
|
|
158
|
+
const isFirstRender = useFirstRender();
|
|
159
|
+
const is2xl = useBreakpointsStore((state) => state.is2xl);
|
|
160
|
+
if (ssr && isFirstRender) {
|
|
161
|
+
return defaultSSRValue;
|
|
162
|
+
}
|
|
163
|
+
return is2xl;
|
|
164
|
+
}
|