@alepha/ui 0.25.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/README.md +12 -0
- package/components.json +20 -0
- package/package.json +85 -0
- package/src/components/action-error-toaster/action-error-toaster.tsx +70 -0
- package/src/components/admin/admin-audits.tsx +247 -0
- package/src/components/admin/admin-files.tsx +346 -0
- package/src/components/admin/admin-jobs-executions-panel.tsx +235 -0
- package/src/components/admin/admin-jobs-status-badge.tsx +33 -0
- package/src/components/admin/admin-jobs.tsx +294 -0
- package/src/components/admin/admin-keys.tsx +162 -0
- package/src/components/admin/admin-notifications.tsx +130 -0
- package/src/components/admin/admin-page.tsx +24 -0
- package/src/components/admin/admin-parameters.tsx +864 -0
- package/src/components/admin/admin-payments.tsx +93 -0
- package/src/components/admin/admin-sessions.tsx +174 -0
- package/src/components/admin/admin-user-detail-audits-tab.tsx +82 -0
- package/src/components/admin/admin-user-detail-identity-aside.tsx +218 -0
- package/src/components/admin/admin-user-detail-overview-tab.tsx +87 -0
- package/src/components/admin/admin-user-detail-password-dialog.tsx +85 -0
- package/src/components/admin/admin-user-detail-password-schema.ts +11 -0
- package/src/components/admin/admin-user-detail-profile-schema.ts +19 -0
- package/src/components/admin/admin-user-detail-provider-labels.ts +15 -0
- package/src/components/admin/admin-user-detail-security-tab.tsx +146 -0
- package/src/components/admin/admin-user-detail-sessions-tab.tsx +93 -0
- package/src/components/admin/admin-user-detail.tsx +606 -0
- package/src/components/admin/admin-users-roles-picker.tsx +126 -0
- package/src/components/admin/admin-users-status-filter.tsx +51 -0
- package/src/components/admin/admin-users.tsx +518 -0
- package/src/components/admin/diff-lines.spec.ts +58 -0
- package/src/components/admin/diff-lines.ts +58 -0
- package/src/components/admin/parameter-diff-dialog.tsx +119 -0
- package/src/components/admin/parameter-history-item.tsx +252 -0
- package/src/components/admin/parameter-json-dialog.tsx +93 -0
- package/src/components/admin/parameter-save-dialog.tsx +126 -0
- package/src/components/admin/use-confirmed-action.tsx +93 -0
- package/src/components/alepha-table/__tests__/use-table-selection.browser.spec.tsx +92 -0
- package/src/components/alepha-table/alepha-table.tsx +1158 -0
- package/src/components/alepha-table/use-table-selection.ts +95 -0
- package/src/components/app-shell/app-shell.tsx +568 -0
- package/src/components/auth/__tests__/auth-router.spec.ts +52 -0
- package/src/components/auth/auth-login.tsx +382 -0
- package/src/components/auth/auth-register.tsx +786 -0
- package/src/components/auth/auth-reset-password.tsx +349 -0
- package/src/components/auth/auth-router.tsx +126 -0
- package/src/components/auth/auth-verify-email.tsx +179 -0
- package/src/components/auto-form/auto-form.tsx +867 -0
- package/src/components/brand-icon/brand-icon.tsx +104 -0
- package/src/components/button-dark/button-dark.tsx +78 -0
- package/src/components/button-language/button-language.tsx +98 -0
- package/src/components/button-theme/button-theme.tsx +148 -0
- package/src/components/button-user/button-user.tsx +214 -0
- package/src/components/captcha/turnstile-widget.tsx +157 -0
- package/src/components/control/control.tsx +735 -0
- package/src/components/control-array/control-array.tsx +700 -0
- package/src/components/control-base/__tests__/form-field-a11y.browser.spec.tsx +93 -0
- package/src/components/control-base/field-i18n.ts +60 -0
- package/src/components/control-base/form-field.tsx +275 -0
- package/src/components/control-base/grid.tsx +59 -0
- package/src/components/control-base/icon-hint.tsx +64 -0
- package/src/components/control-date/control-date.tsx +190 -0
- package/src/components/control-number/control-number.tsx +136 -0
- package/src/components/control-object/control-object.tsx +200 -0
- package/src/components/control-select/control-select.tsx +774 -0
- package/src/components/control-upload/control-upload.tsx +475 -0
- package/src/components/file-image/file-image.tsx +52 -0
- package/src/components/language-toggle/language-toggle.tsx +66 -0
- package/src/components/markdown-view/markdown-view.css +114 -0
- package/src/components/markdown-view/markdown-view.tsx +92 -0
- package/src/components/nav-shell/nav-page.tsx +56 -0
- package/src/components/nav-shell/nav-shell.tsx +72 -0
- package/src/components/nav-shell/nav-tree-util.ts +62 -0
- package/src/components/nav-shell/spotlight.tsx +163 -0
- package/src/components/nav-shell/use-nav-breadcrumbs.ts +52 -0
- package/src/components/nav-shell/use-nav-entries.ts +101 -0
- package/src/components/nav-shell/use-nav-tree.ts +61 -0
- package/src/components/ui/accordion.tsx +77 -0
- package/src/components/ui/alert-dialog.tsx +186 -0
- package/src/components/ui/alert.tsx +75 -0
- package/src/components/ui/aspect-ratio.tsx +22 -0
- package/src/components/ui/avatar.tsx +106 -0
- package/src/components/ui/badge.tsx +51 -0
- package/src/components/ui/breadcrumb.tsx +121 -0
- package/src/components/ui/button-group.tsx +86 -0
- package/src/components/ui/button.tsx +83 -0
- package/src/components/ui/calendar.tsx +235 -0
- package/src/components/ui/card.tsx +102 -0
- package/src/components/ui/carousel.tsx +241 -0
- package/src/components/ui/chart.tsx +370 -0
- package/src/components/ui/checkbox.tsx +27 -0
- package/src/components/ui/collapsible.tsx +19 -0
- package/src/components/ui/combobox.tsx +298 -0
- package/src/components/ui/command.tsx +196 -0
- package/src/components/ui/context-menu.tsx +271 -0
- package/src/components/ui/dialog.tsx +153 -0
- package/src/components/ui/direction.tsx +4 -0
- package/src/components/ui/drawer.tsx +130 -0
- package/src/components/ui/dropdown-menu.tsx +269 -0
- package/src/components/ui/empty.tsx +100 -0
- package/src/components/ui/hover-card.tsx +50 -0
- package/src/components/ui/input-group.tsx +157 -0
- package/src/components/ui/input-otp.tsx +83 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/item.tsx +200 -0
- package/src/components/ui/kbd.tsx +26 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/menubar.tsx +283 -0
- package/src/components/ui/navigation-menu.tsx +170 -0
- package/src/components/ui/pagination.tsx +133 -0
- package/src/components/ui/popover.tsx +87 -0
- package/src/components/ui/progress.tsx +82 -0
- package/src/components/ui/radio-group.tsx +35 -0
- package/src/components/ui/resizable.tsx +49 -0
- package/src/components/ui/scroll-area.tsx +51 -0
- package/src/components/ui/segmented.tsx +232 -0
- package/src/components/ui/select.tsx +201 -0
- package/src/components/ui/separator.tsx +22 -0
- package/src/components/ui/sheet.tsx +133 -0
- package/src/components/ui/sidebar.tsx +723 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/slider.tsx +51 -0
- package/src/components/ui/sonner.tsx +46 -0
- package/src/components/ui/spinner.tsx +15 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/table.tsx +115 -0
- package/src/components/ui/tabs.tsx +79 -0
- package/src/components/ui/textarea.tsx +17 -0
- package/src/components/ui/toggle-group.tsx +86 -0
- package/src/components/ui/toggle.tsx +44 -0
- package/src/components/ui/tooltip.tsx +63 -0
- package/src/components/use-dialog/use-dialog.tsx +244 -0
- package/src/components/use-toast/use-toast.tsx +89 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/lib/__tests__/i18n-fr.spec.ts +72 -0
- package/src/lib/i18n-fr.ts +500 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles.css +129 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Button } from "@alepha/ui/components/ui/button";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
4
|
+
import {
|
|
5
|
+
ChevronLeftIcon,
|
|
6
|
+
ChevronRightIcon,
|
|
7
|
+
MoreHorizontalIcon,
|
|
8
|
+
} from "lucide-react";
|
|
9
|
+
import type * as React from "react";
|
|
10
|
+
|
|
11
|
+
function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
|
|
12
|
+
return (
|
|
13
|
+
<nav
|
|
14
|
+
role="navigation"
|
|
15
|
+
aria-label="pagination"
|
|
16
|
+
data-slot="pagination"
|
|
17
|
+
className={cn("mx-auto flex w-full justify-center", className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function PaginationContent({
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<"ul">) {
|
|
27
|
+
return (
|
|
28
|
+
<ul
|
|
29
|
+
data-slot="pagination-content"
|
|
30
|
+
className={cn("flex items-center gap-0.5", className)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function PaginationItem({ ...props }: React.ComponentProps<"li">) {
|
|
37
|
+
return <li data-slot="pagination-item" {...props} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type PaginationLinkProps = {
|
|
41
|
+
isActive?: boolean;
|
|
42
|
+
} & Pick<React.ComponentProps<typeof Button>, "size"> &
|
|
43
|
+
React.ComponentProps<"a">;
|
|
44
|
+
|
|
45
|
+
function PaginationLink({
|
|
46
|
+
className,
|
|
47
|
+
isActive,
|
|
48
|
+
size = "icon",
|
|
49
|
+
...props
|
|
50
|
+
}: PaginationLinkProps) {
|
|
51
|
+
return (
|
|
52
|
+
<Button
|
|
53
|
+
variant={isActive ? "outline" : "ghost"}
|
|
54
|
+
size={size}
|
|
55
|
+
className={cn(className)}
|
|
56
|
+
nativeButton={false}
|
|
57
|
+
render={
|
|
58
|
+
<a
|
|
59
|
+
aria-current={isActive ? "page" : undefined}
|
|
60
|
+
data-slot="pagination-link"
|
|
61
|
+
data-active={isActive}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function PaginationPrevious({
|
|
70
|
+
className,
|
|
71
|
+
text = "Previous",
|
|
72
|
+
...props
|
|
73
|
+
}: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
|
|
74
|
+
return (
|
|
75
|
+
<PaginationLink
|
|
76
|
+
aria-label="Go to previous page"
|
|
77
|
+
size="default"
|
|
78
|
+
className={cn("pl-1.5!", className)}
|
|
79
|
+
{...props}
|
|
80
|
+
>
|
|
81
|
+
<ChevronLeftIcon data-icon="inline-start" />
|
|
82
|
+
<span className="hidden sm:block">{text}</span>
|
|
83
|
+
</PaginationLink>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function PaginationNext({
|
|
88
|
+
className,
|
|
89
|
+
text = "Next",
|
|
90
|
+
...props
|
|
91
|
+
}: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
|
|
92
|
+
return (
|
|
93
|
+
<PaginationLink
|
|
94
|
+
aria-label="Go to next page"
|
|
95
|
+
size="default"
|
|
96
|
+
className={cn("pr-1.5!", className)}
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
<span className="hidden sm:block">{text}</span>
|
|
100
|
+
<ChevronRightIcon data-icon="inline-end" />
|
|
101
|
+
</PaginationLink>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function PaginationEllipsis({
|
|
106
|
+
className,
|
|
107
|
+
...props
|
|
108
|
+
}: React.ComponentProps<"span">) {
|
|
109
|
+
return (
|
|
110
|
+
<span
|
|
111
|
+
aria-hidden
|
|
112
|
+
data-slot="pagination-ellipsis"
|
|
113
|
+
className={cn(
|
|
114
|
+
"flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",
|
|
115
|
+
className,
|
|
116
|
+
)}
|
|
117
|
+
{...props}
|
|
118
|
+
>
|
|
119
|
+
<MoreHorizontalIcon />
|
|
120
|
+
<span className="sr-only">More pages</span>
|
|
121
|
+
</span>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
Pagination,
|
|
127
|
+
PaginationContent,
|
|
128
|
+
PaginationEllipsis,
|
|
129
|
+
PaginationItem,
|
|
130
|
+
PaginationLink,
|
|
131
|
+
PaginationNext,
|
|
132
|
+
PaginationPrevious,
|
|
133
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
2
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
|
|
5
|
+
function Popover({ ...props }: PopoverPrimitive.Root.Props) {
|
|
6
|
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
|
|
10
|
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function PopoverContent({
|
|
14
|
+
className,
|
|
15
|
+
align = "center",
|
|
16
|
+
alignOffset = 0,
|
|
17
|
+
side = "bottom",
|
|
18
|
+
sideOffset = 4,
|
|
19
|
+
...props
|
|
20
|
+
}: PopoverPrimitive.Popup.Props &
|
|
21
|
+
Pick<
|
|
22
|
+
PopoverPrimitive.Positioner.Props,
|
|
23
|
+
"align" | "alignOffset" | "side" | "sideOffset"
|
|
24
|
+
>) {
|
|
25
|
+
return (
|
|
26
|
+
<PopoverPrimitive.Portal>
|
|
27
|
+
<PopoverPrimitive.Positioner
|
|
28
|
+
align={align}
|
|
29
|
+
alignOffset={alignOffset}
|
|
30
|
+
side={side}
|
|
31
|
+
sideOffset={sideOffset}
|
|
32
|
+
className="isolate z-50"
|
|
33
|
+
>
|
|
34
|
+
<PopoverPrimitive.Popup
|
|
35
|
+
data-slot="popover-content"
|
|
36
|
+
className={cn(
|
|
37
|
+
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
</PopoverPrimitive.Positioner>
|
|
43
|
+
</PopoverPrimitive.Portal>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
data-slot="popover-header"
|
|
51
|
+
className={cn("flex flex-col gap-0.5 text-sm", className)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {
|
|
58
|
+
return (
|
|
59
|
+
<PopoverPrimitive.Title
|
|
60
|
+
data-slot="popover-title"
|
|
61
|
+
className={cn("font-medium", className)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function PopoverDescription({
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
}: PopoverPrimitive.Description.Props) {
|
|
71
|
+
return (
|
|
72
|
+
<PopoverPrimitive.Description
|
|
73
|
+
data-slot="popover-description"
|
|
74
|
+
className={cn("text-muted-foreground", className)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
Popover,
|
|
82
|
+
PopoverContent,
|
|
83
|
+
PopoverDescription,
|
|
84
|
+
PopoverHeader,
|
|
85
|
+
PopoverTitle,
|
|
86
|
+
PopoverTrigger,
|
|
87
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
4
|
+
import { Progress as ProgressPrimitive } from "@base-ui/react/progress";
|
|
5
|
+
|
|
6
|
+
function Progress({
|
|
7
|
+
className,
|
|
8
|
+
children,
|
|
9
|
+
value,
|
|
10
|
+
...props
|
|
11
|
+
}: ProgressPrimitive.Root.Props) {
|
|
12
|
+
return (
|
|
13
|
+
<ProgressPrimitive.Root
|
|
14
|
+
value={value}
|
|
15
|
+
data-slot="progress"
|
|
16
|
+
className={cn("flex flex-wrap gap-3", className)}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
<ProgressTrack>
|
|
21
|
+
<ProgressIndicator />
|
|
22
|
+
</ProgressTrack>
|
|
23
|
+
</ProgressPrimitive.Root>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props) {
|
|
28
|
+
return (
|
|
29
|
+
<ProgressPrimitive.Track
|
|
30
|
+
className={cn(
|
|
31
|
+
"relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
data-slot="progress-track"
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function ProgressIndicator({
|
|
41
|
+
className,
|
|
42
|
+
...props
|
|
43
|
+
}: ProgressPrimitive.Indicator.Props) {
|
|
44
|
+
return (
|
|
45
|
+
<ProgressPrimitive.Indicator
|
|
46
|
+
data-slot="progress-indicator"
|
|
47
|
+
className={cn("h-full bg-primary transition-all", className)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function ProgressLabel({ className, ...props }: ProgressPrimitive.Label.Props) {
|
|
54
|
+
return (
|
|
55
|
+
<ProgressPrimitive.Label
|
|
56
|
+
className={cn("text-sm font-medium", className)}
|
|
57
|
+
data-slot="progress-label"
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props) {
|
|
64
|
+
return (
|
|
65
|
+
<ProgressPrimitive.Value
|
|
66
|
+
className={cn(
|
|
67
|
+
"ml-auto text-sm text-muted-foreground tabular-nums",
|
|
68
|
+
className,
|
|
69
|
+
)}
|
|
70
|
+
data-slot="progress-value"
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
Progress,
|
|
78
|
+
ProgressIndicator,
|
|
79
|
+
ProgressLabel,
|
|
80
|
+
ProgressTrack,
|
|
81
|
+
ProgressValue,
|
|
82
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
2
|
+
import { Radio as RadioPrimitive } from "@base-ui/react/radio";
|
|
3
|
+
import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group";
|
|
4
|
+
|
|
5
|
+
function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
|
|
6
|
+
return (
|
|
7
|
+
<RadioGroupPrimitive
|
|
8
|
+
data-slot="radio-group"
|
|
9
|
+
className={cn("grid w-full gap-2", className)}
|
|
10
|
+
{...props}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
|
|
16
|
+
return (
|
|
17
|
+
<RadioPrimitive.Root
|
|
18
|
+
data-slot="radio-group-item"
|
|
19
|
+
className={cn(
|
|
20
|
+
"group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
<RadioPrimitive.Indicator
|
|
26
|
+
data-slot="radio-group-indicator"
|
|
27
|
+
className="flex size-4 items-center justify-center"
|
|
28
|
+
>
|
|
29
|
+
<span className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground" />
|
|
30
|
+
</RadioPrimitive.Indicator>
|
|
31
|
+
</RadioPrimitive.Root>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
4
|
+
import * as ResizablePrimitive from "react-resizable-panels";
|
|
5
|
+
|
|
6
|
+
function ResizablePanelGroup({
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}: ResizablePrimitive.GroupProps) {
|
|
10
|
+
return (
|
|
11
|
+
<ResizablePrimitive.Group
|
|
12
|
+
data-slot="resizable-panel-group"
|
|
13
|
+
className={cn(
|
|
14
|
+
"flex h-full w-full aria-[orientation=vertical]:flex-col",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
|
|
23
|
+
return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function ResizableHandle({
|
|
27
|
+
withHandle,
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}: ResizablePrimitive.SeparatorProps & {
|
|
31
|
+
withHandle?: boolean;
|
|
32
|
+
}) {
|
|
33
|
+
return (
|
|
34
|
+
<ResizablePrimitive.Separator
|
|
35
|
+
data-slot="resizable-handle"
|
|
36
|
+
className={cn(
|
|
37
|
+
"relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
{withHandle && (
|
|
43
|
+
<div className="z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border" />
|
|
44
|
+
)}
|
|
45
|
+
</ResizablePrimitive.Separator>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { ResizableHandle, ResizablePanel, ResizablePanelGroup };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
2
|
+
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
3
|
+
|
|
4
|
+
function ScrollArea({
|
|
5
|
+
className,
|
|
6
|
+
children,
|
|
7
|
+
...props
|
|
8
|
+
}: ScrollAreaPrimitive.Root.Props) {
|
|
9
|
+
return (
|
|
10
|
+
<ScrollAreaPrimitive.Root
|
|
11
|
+
data-slot="scroll-area"
|
|
12
|
+
className={cn("relative", className)}
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<ScrollAreaPrimitive.Viewport
|
|
16
|
+
data-slot="scroll-area-viewport"
|
|
17
|
+
className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1"
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</ScrollAreaPrimitive.Viewport>
|
|
21
|
+
<ScrollBar />
|
|
22
|
+
<ScrollAreaPrimitive.Corner />
|
|
23
|
+
</ScrollAreaPrimitive.Root>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function ScrollBar({
|
|
28
|
+
className,
|
|
29
|
+
orientation = "vertical",
|
|
30
|
+
...props
|
|
31
|
+
}: ScrollAreaPrimitive.Scrollbar.Props) {
|
|
32
|
+
return (
|
|
33
|
+
<ScrollAreaPrimitive.Scrollbar
|
|
34
|
+
data-slot="scroll-area-scrollbar"
|
|
35
|
+
data-orientation={orientation}
|
|
36
|
+
orientation={orientation}
|
|
37
|
+
className={cn(
|
|
38
|
+
"flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
<ScrollAreaPrimitive.Thumb
|
|
44
|
+
data-slot="scroll-area-thumb"
|
|
45
|
+
className="relative flex-1 rounded-full bg-border"
|
|
46
|
+
/>
|
|
47
|
+
</ScrollAreaPrimitive.Scrollbar>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { ScrollArea, ScrollBar };
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
export interface SegmentedOption {
|
|
7
|
+
value: string;
|
|
8
|
+
label: React.ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SegmentedProps
|
|
13
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
14
|
+
/**
|
|
15
|
+
* Selectable options. Each one renders as a segment.
|
|
16
|
+
*/
|
|
17
|
+
options: SegmentedOption[];
|
|
18
|
+
/**
|
|
19
|
+
* Controlled value. Pair with `onChange` for full control.
|
|
20
|
+
*/
|
|
21
|
+
value?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Initial value when uncontrolled.
|
|
24
|
+
*/
|
|
25
|
+
defaultValue?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Called when the active segment changes.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: (value: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Visual size — `xs`, `sm`, `md` (default), `lg`, or `xl`.
|
|
32
|
+
*/
|
|
33
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
34
|
+
/**
|
|
35
|
+
* Stretch segments to fill the available width.
|
|
36
|
+
*/
|
|
37
|
+
fullWidth?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Disable all segments.
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Render 1px separators between inactive segments. Defaults to `true`.
|
|
44
|
+
*/
|
|
45
|
+
dividers?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Optional form name (used when rendered inside a form).
|
|
48
|
+
*/
|
|
49
|
+
name?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Outer-box height + text per size — picked so the control lines up
|
|
53
|
+
// pixel-for-pixel with a `<Button>` of the same size token (xs h-6, sm h-7,
|
|
54
|
+
// md=Button-default h-8, lg h-9). The box owns the height (border-box, so the
|
|
55
|
+
// `p-0.5` + 1px border are included) and the segments stretch to fill it.
|
|
56
|
+
const sizeClass: Record<NonNullable<SegmentedProps["size"]>, string> = {
|
|
57
|
+
xs: "h-6 text-xs",
|
|
58
|
+
sm: "h-7 text-[0.8rem]",
|
|
59
|
+
md: "h-8 text-sm",
|
|
60
|
+
lg: "h-9 text-sm",
|
|
61
|
+
xl: "h-11 text-base",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Horizontal padding per size, applied to each segment (height comes from the
|
|
65
|
+
// stretched box, not the segment).
|
|
66
|
+
const itemPadClass: Record<NonNullable<SegmentedProps["size"]>, string> = {
|
|
67
|
+
xs: "px-2",
|
|
68
|
+
sm: "px-2.5",
|
|
69
|
+
md: "px-3",
|
|
70
|
+
lg: "px-4",
|
|
71
|
+
xl: "px-5",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
interface ThumbRect {
|
|
75
|
+
left: number;
|
|
76
|
+
top: number;
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function Segmented(props: SegmentedProps) {
|
|
82
|
+
const {
|
|
83
|
+
options,
|
|
84
|
+
value: controlled,
|
|
85
|
+
defaultValue,
|
|
86
|
+
onChange,
|
|
87
|
+
size = "md",
|
|
88
|
+
fullWidth,
|
|
89
|
+
disabled,
|
|
90
|
+
dividers = true,
|
|
91
|
+
name,
|
|
92
|
+
className,
|
|
93
|
+
...rest
|
|
94
|
+
} = props;
|
|
95
|
+
|
|
96
|
+
const [uncontrolled, setUncontrolled] = React.useState<string | undefined>(
|
|
97
|
+
defaultValue,
|
|
98
|
+
);
|
|
99
|
+
const value = controlled !== undefined ? controlled : uncontrolled;
|
|
100
|
+
|
|
101
|
+
const containerRef = React.useRef<HTMLDivElement | null>(null);
|
|
102
|
+
const itemRefs = React.useRef<Array<HTMLButtonElement | null>>([]);
|
|
103
|
+
const [thumb, setThumb] = React.useState<ThumbRect | null>(null);
|
|
104
|
+
const [animate, setAnimate] = React.useState(false);
|
|
105
|
+
|
|
106
|
+
const activeIndex = options.findIndex((opt) => opt.value === value);
|
|
107
|
+
|
|
108
|
+
const measureThumb = React.useCallback(() => {
|
|
109
|
+
if (activeIndex < 0) {
|
|
110
|
+
setThumb(null);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const el = itemRefs.current[activeIndex];
|
|
114
|
+
const container = containerRef.current;
|
|
115
|
+
if (!el || !container) return;
|
|
116
|
+
const elRect = el.getBoundingClientRect();
|
|
117
|
+
const parentRect = container.getBoundingClientRect();
|
|
118
|
+
setThumb({
|
|
119
|
+
left: elRect.left - parentRect.left,
|
|
120
|
+
top: elRect.top - parentRect.top,
|
|
121
|
+
width: elRect.width,
|
|
122
|
+
height: elRect.height,
|
|
123
|
+
});
|
|
124
|
+
}, [activeIndex]);
|
|
125
|
+
|
|
126
|
+
React.useLayoutEffect(() => {
|
|
127
|
+
measureThumb();
|
|
128
|
+
}, [measureThumb, options.length, size, fullWidth]);
|
|
129
|
+
|
|
130
|
+
React.useEffect(() => {
|
|
131
|
+
if (!containerRef.current) return;
|
|
132
|
+
const observer = new ResizeObserver(() => measureThumb());
|
|
133
|
+
observer.observe(containerRef.current);
|
|
134
|
+
return () => observer.disconnect();
|
|
135
|
+
}, [measureThumb]);
|
|
136
|
+
|
|
137
|
+
// Enable animation only after the first measurement so the thumb doesn't
|
|
138
|
+
// slide from (0,0) on initial paint.
|
|
139
|
+
React.useEffect(() => {
|
|
140
|
+
if (thumb && !animate) {
|
|
141
|
+
const id = requestAnimationFrame(() => setAnimate(true));
|
|
142
|
+
return () => cancelAnimationFrame(id);
|
|
143
|
+
}
|
|
144
|
+
}, [thumb, animate]);
|
|
145
|
+
|
|
146
|
+
const handleSelect = (next: string) => {
|
|
147
|
+
if (controlled === undefined) setUncontrolled(next);
|
|
148
|
+
onChange?.(next);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
ref={containerRef}
|
|
154
|
+
role="radiogroup"
|
|
155
|
+
aria-disabled={disabled || undefined}
|
|
156
|
+
data-slot="segmented"
|
|
157
|
+
className={cn(
|
|
158
|
+
"border-input bg-muted/40 relative box-border inline-flex items-stretch rounded-md border p-0.5",
|
|
159
|
+
sizeClass[size],
|
|
160
|
+
fullWidth && "flex w-full",
|
|
161
|
+
disabled && "opacity-50",
|
|
162
|
+
className,
|
|
163
|
+
)}
|
|
164
|
+
{...rest}
|
|
165
|
+
>
|
|
166
|
+
{thumb && (
|
|
167
|
+
<span
|
|
168
|
+
aria-hidden
|
|
169
|
+
data-slot="segmented-thumb"
|
|
170
|
+
className={cn(
|
|
171
|
+
"bg-primary pointer-events-none absolute rounded-[calc(var(--radius)-2px)] shadow-sm",
|
|
172
|
+
// Animate only `transform` — it's GPU-composited in both browsers.
|
|
173
|
+
// Transitioning width/height forces a per-frame reflow + box-shadow
|
|
174
|
+
// repaint on the main thread, which Firefox handles poorly (visible
|
|
175
|
+
// jank); Chrome's fast-paths hide it. Width/height still update, but
|
|
176
|
+
// instantly — for equal-width segments they never change anyway, so
|
|
177
|
+
// only the slide animates.
|
|
178
|
+
animate && "transition-transform duration-200 ease-out",
|
|
179
|
+
)}
|
|
180
|
+
style={{
|
|
181
|
+
transform: `translate(${thumb.left}px, ${thumb.top}px)`,
|
|
182
|
+
width: thumb.width,
|
|
183
|
+
height: thumb.height,
|
|
184
|
+
top: 0,
|
|
185
|
+
left: 0,
|
|
186
|
+
willChange: "transform",
|
|
187
|
+
}}
|
|
188
|
+
/>
|
|
189
|
+
)}
|
|
190
|
+
{options.map((opt, index) => {
|
|
191
|
+
const active = opt.value === value;
|
|
192
|
+
const itemDisabled = disabled || opt.disabled;
|
|
193
|
+
const showDivider =
|
|
194
|
+
dividers && index > 0 && !active && index - 1 !== activeIndex;
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<button
|
|
198
|
+
key={opt.value}
|
|
199
|
+
ref={(el) => {
|
|
200
|
+
itemRefs.current[index] = el;
|
|
201
|
+
}}
|
|
202
|
+
type="button"
|
|
203
|
+
role="radio"
|
|
204
|
+
aria-checked={active}
|
|
205
|
+
aria-disabled={itemDisabled || undefined}
|
|
206
|
+
disabled={itemDisabled}
|
|
207
|
+
data-state={active ? "active" : "inactive"}
|
|
208
|
+
data-slot="segmented-item"
|
|
209
|
+
name={name}
|
|
210
|
+
value={opt.value}
|
|
211
|
+
onClick={() => !itemDisabled && handleSelect(opt.value)}
|
|
212
|
+
className={cn(
|
|
213
|
+
"relative z-10 inline-flex min-w-0 items-center justify-center rounded-[calc(var(--radius)-2px)] font-medium whitespace-nowrap",
|
|
214
|
+
"transition-colors duration-150 ease-in-out",
|
|
215
|
+
"focus-visible:ring-ring/50 focus-visible:outline-none focus-visible:ring-[3px]",
|
|
216
|
+
itemPadClass[size],
|
|
217
|
+
active
|
|
218
|
+
? "text-primary-foreground"
|
|
219
|
+
: "text-muted-foreground hover:text-foreground",
|
|
220
|
+
itemDisabled && "cursor-not-allowed opacity-50",
|
|
221
|
+
fullWidth && "flex-1",
|
|
222
|
+
showDivider &&
|
|
223
|
+
"before:bg-border before:absolute before:inset-y-1.5 before:left-0 before:w-px before:content-['']",
|
|
224
|
+
)}
|
|
225
|
+
>
|
|
226
|
+
{opt.label}
|
|
227
|
+
</button>
|
|
228
|
+
);
|
|
229
|
+
})}
|
|
230
|
+
</div>
|
|
231
|
+
);
|
|
232
|
+
}
|