@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.
Files changed (136) hide show
  1. package/README.md +12 -0
  2. package/components.json +20 -0
  3. package/package.json +85 -0
  4. package/src/components/action-error-toaster/action-error-toaster.tsx +70 -0
  5. package/src/components/admin/admin-audits.tsx +247 -0
  6. package/src/components/admin/admin-files.tsx +346 -0
  7. package/src/components/admin/admin-jobs-executions-panel.tsx +235 -0
  8. package/src/components/admin/admin-jobs-status-badge.tsx +33 -0
  9. package/src/components/admin/admin-jobs.tsx +294 -0
  10. package/src/components/admin/admin-keys.tsx +162 -0
  11. package/src/components/admin/admin-notifications.tsx +130 -0
  12. package/src/components/admin/admin-page.tsx +24 -0
  13. package/src/components/admin/admin-parameters.tsx +864 -0
  14. package/src/components/admin/admin-payments.tsx +93 -0
  15. package/src/components/admin/admin-sessions.tsx +174 -0
  16. package/src/components/admin/admin-user-detail-audits-tab.tsx +82 -0
  17. package/src/components/admin/admin-user-detail-identity-aside.tsx +218 -0
  18. package/src/components/admin/admin-user-detail-overview-tab.tsx +87 -0
  19. package/src/components/admin/admin-user-detail-password-dialog.tsx +85 -0
  20. package/src/components/admin/admin-user-detail-password-schema.ts +11 -0
  21. package/src/components/admin/admin-user-detail-profile-schema.ts +19 -0
  22. package/src/components/admin/admin-user-detail-provider-labels.ts +15 -0
  23. package/src/components/admin/admin-user-detail-security-tab.tsx +146 -0
  24. package/src/components/admin/admin-user-detail-sessions-tab.tsx +93 -0
  25. package/src/components/admin/admin-user-detail.tsx +606 -0
  26. package/src/components/admin/admin-users-roles-picker.tsx +126 -0
  27. package/src/components/admin/admin-users-status-filter.tsx +51 -0
  28. package/src/components/admin/admin-users.tsx +518 -0
  29. package/src/components/admin/diff-lines.spec.ts +58 -0
  30. package/src/components/admin/diff-lines.ts +58 -0
  31. package/src/components/admin/parameter-diff-dialog.tsx +119 -0
  32. package/src/components/admin/parameter-history-item.tsx +252 -0
  33. package/src/components/admin/parameter-json-dialog.tsx +93 -0
  34. package/src/components/admin/parameter-save-dialog.tsx +126 -0
  35. package/src/components/admin/use-confirmed-action.tsx +93 -0
  36. package/src/components/alepha-table/__tests__/use-table-selection.browser.spec.tsx +92 -0
  37. package/src/components/alepha-table/alepha-table.tsx +1158 -0
  38. package/src/components/alepha-table/use-table-selection.ts +95 -0
  39. package/src/components/app-shell/app-shell.tsx +568 -0
  40. package/src/components/auth/__tests__/auth-router.spec.ts +52 -0
  41. package/src/components/auth/auth-login.tsx +382 -0
  42. package/src/components/auth/auth-register.tsx +786 -0
  43. package/src/components/auth/auth-reset-password.tsx +349 -0
  44. package/src/components/auth/auth-router.tsx +126 -0
  45. package/src/components/auth/auth-verify-email.tsx +179 -0
  46. package/src/components/auto-form/auto-form.tsx +867 -0
  47. package/src/components/brand-icon/brand-icon.tsx +104 -0
  48. package/src/components/button-dark/button-dark.tsx +78 -0
  49. package/src/components/button-language/button-language.tsx +98 -0
  50. package/src/components/button-theme/button-theme.tsx +148 -0
  51. package/src/components/button-user/button-user.tsx +214 -0
  52. package/src/components/captcha/turnstile-widget.tsx +157 -0
  53. package/src/components/control/control.tsx +735 -0
  54. package/src/components/control-array/control-array.tsx +700 -0
  55. package/src/components/control-base/__tests__/form-field-a11y.browser.spec.tsx +93 -0
  56. package/src/components/control-base/field-i18n.ts +60 -0
  57. package/src/components/control-base/form-field.tsx +275 -0
  58. package/src/components/control-base/grid.tsx +59 -0
  59. package/src/components/control-base/icon-hint.tsx +64 -0
  60. package/src/components/control-date/control-date.tsx +190 -0
  61. package/src/components/control-number/control-number.tsx +136 -0
  62. package/src/components/control-object/control-object.tsx +200 -0
  63. package/src/components/control-select/control-select.tsx +774 -0
  64. package/src/components/control-upload/control-upload.tsx +475 -0
  65. package/src/components/file-image/file-image.tsx +52 -0
  66. package/src/components/language-toggle/language-toggle.tsx +66 -0
  67. package/src/components/markdown-view/markdown-view.css +114 -0
  68. package/src/components/markdown-view/markdown-view.tsx +92 -0
  69. package/src/components/nav-shell/nav-page.tsx +56 -0
  70. package/src/components/nav-shell/nav-shell.tsx +72 -0
  71. package/src/components/nav-shell/nav-tree-util.ts +62 -0
  72. package/src/components/nav-shell/spotlight.tsx +163 -0
  73. package/src/components/nav-shell/use-nav-breadcrumbs.ts +52 -0
  74. package/src/components/nav-shell/use-nav-entries.ts +101 -0
  75. package/src/components/nav-shell/use-nav-tree.ts +61 -0
  76. package/src/components/ui/accordion.tsx +77 -0
  77. package/src/components/ui/alert-dialog.tsx +186 -0
  78. package/src/components/ui/alert.tsx +75 -0
  79. package/src/components/ui/aspect-ratio.tsx +22 -0
  80. package/src/components/ui/avatar.tsx +106 -0
  81. package/src/components/ui/badge.tsx +51 -0
  82. package/src/components/ui/breadcrumb.tsx +121 -0
  83. package/src/components/ui/button-group.tsx +86 -0
  84. package/src/components/ui/button.tsx +83 -0
  85. package/src/components/ui/calendar.tsx +235 -0
  86. package/src/components/ui/card.tsx +102 -0
  87. package/src/components/ui/carousel.tsx +241 -0
  88. package/src/components/ui/chart.tsx +370 -0
  89. package/src/components/ui/checkbox.tsx +27 -0
  90. package/src/components/ui/collapsible.tsx +19 -0
  91. package/src/components/ui/combobox.tsx +298 -0
  92. package/src/components/ui/command.tsx +196 -0
  93. package/src/components/ui/context-menu.tsx +271 -0
  94. package/src/components/ui/dialog.tsx +153 -0
  95. package/src/components/ui/direction.tsx +4 -0
  96. package/src/components/ui/drawer.tsx +130 -0
  97. package/src/components/ui/dropdown-menu.tsx +269 -0
  98. package/src/components/ui/empty.tsx +100 -0
  99. package/src/components/ui/hover-card.tsx +50 -0
  100. package/src/components/ui/input-group.tsx +157 -0
  101. package/src/components/ui/input-otp.tsx +83 -0
  102. package/src/components/ui/input.tsx +19 -0
  103. package/src/components/ui/item.tsx +200 -0
  104. package/src/components/ui/kbd.tsx +26 -0
  105. package/src/components/ui/label.tsx +19 -0
  106. package/src/components/ui/menubar.tsx +283 -0
  107. package/src/components/ui/navigation-menu.tsx +170 -0
  108. package/src/components/ui/pagination.tsx +133 -0
  109. package/src/components/ui/popover.tsx +87 -0
  110. package/src/components/ui/progress.tsx +82 -0
  111. package/src/components/ui/radio-group.tsx +35 -0
  112. package/src/components/ui/resizable.tsx +49 -0
  113. package/src/components/ui/scroll-area.tsx +51 -0
  114. package/src/components/ui/segmented.tsx +232 -0
  115. package/src/components/ui/select.tsx +201 -0
  116. package/src/components/ui/separator.tsx +22 -0
  117. package/src/components/ui/sheet.tsx +133 -0
  118. package/src/components/ui/sidebar.tsx +723 -0
  119. package/src/components/ui/skeleton.tsx +13 -0
  120. package/src/components/ui/slider.tsx +51 -0
  121. package/src/components/ui/sonner.tsx +46 -0
  122. package/src/components/ui/spinner.tsx +15 -0
  123. package/src/components/ui/switch.tsx +29 -0
  124. package/src/components/ui/table.tsx +115 -0
  125. package/src/components/ui/tabs.tsx +79 -0
  126. package/src/components/ui/textarea.tsx +17 -0
  127. package/src/components/ui/toggle-group.tsx +86 -0
  128. package/src/components/ui/toggle.tsx +44 -0
  129. package/src/components/ui/tooltip.tsx +63 -0
  130. package/src/components/use-dialog/use-dialog.tsx +244 -0
  131. package/src/components/use-toast/use-toast.tsx +89 -0
  132. package/src/hooks/use-mobile.ts +21 -0
  133. package/src/lib/__tests__/i18n-fr.spec.ts +72 -0
  134. package/src/lib/i18n-fr.ts +500 -0
  135. package/src/lib/utils.ts +6 -0
  136. package/src/styles.css +129 -0
@@ -0,0 +1,86 @@
1
+ import { Separator } from "@alepha/ui/components/ui/separator";
2
+ import { cn } from "@alepha/ui/lib/utils";
3
+ import { mergeProps } from "@base-ui/react/merge-props";
4
+ import { useRender } from "@base-ui/react/use-render";
5
+ import { cva, type VariantProps } from "class-variance-authority";
6
+
7
+ const buttonGroupVariants = cva(
8
+ "flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
9
+ {
10
+ variants: {
11
+ orientation: {
12
+ horizontal:
13
+ "*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0",
14
+ vertical:
15
+ "flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0",
16
+ },
17
+ },
18
+ defaultVariants: {
19
+ orientation: "horizontal",
20
+ },
21
+ },
22
+ );
23
+
24
+ function ButtonGroup({
25
+ className,
26
+ orientation,
27
+ ...props
28
+ }: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {
29
+ return (
30
+ <div
31
+ role="group"
32
+ data-slot="button-group"
33
+ data-orientation={orientation}
34
+ className={cn(buttonGroupVariants({ orientation }), className)}
35
+ {...props}
36
+ />
37
+ );
38
+ }
39
+
40
+ function ButtonGroupText({
41
+ className,
42
+ render,
43
+ ...props
44
+ }: useRender.ComponentProps<"div">) {
45
+ return useRender({
46
+ defaultTagName: "div",
47
+ props: mergeProps<"div">(
48
+ {
49
+ className: cn(
50
+ "flex items-center gap-2 rounded-lg border bg-muted px-2.5 text-sm font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
51
+ className,
52
+ ),
53
+ },
54
+ props,
55
+ ),
56
+ render,
57
+ state: {
58
+ slot: "button-group-text",
59
+ },
60
+ });
61
+ }
62
+
63
+ function ButtonGroupSeparator({
64
+ className,
65
+ orientation = "vertical",
66
+ ...props
67
+ }: React.ComponentProps<typeof Separator>) {
68
+ return (
69
+ <Separator
70
+ data-slot="button-group-separator"
71
+ orientation={orientation}
72
+ className={cn(
73
+ "relative self-stretch bg-input data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto",
74
+ className,
75
+ )}
76
+ {...props}
77
+ />
78
+ );
79
+ }
80
+
81
+ export {
82
+ ButtonGroup,
83
+ ButtonGroupSeparator,
84
+ ButtonGroupText,
85
+ buttonGroupVariants,
86
+ };
@@ -0,0 +1,83 @@
1
+ import { cn } from "@alepha/ui/lib/utils";
2
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
3
+ import { cva, type VariantProps } from "class-variance-authority";
4
+ import { Loader2Icon } from "lucide-react";
5
+
6
+ const buttonVariants = cva(
7
+ "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
12
+ outline:
13
+ "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
14
+ secondary:
15
+ "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
16
+ ghost:
17
+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
18
+ destructive:
19
+ "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ size: {
23
+ default:
24
+ "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
25
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
26
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
27
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
28
+ icon: "size-8",
29
+ "icon-xs":
30
+ "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
31
+ "icon-sm":
32
+ "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
33
+ "icon-lg": "size-9",
34
+ },
35
+ },
36
+ defaultVariants: {
37
+ variant: "default",
38
+ size: "default",
39
+ },
40
+ },
41
+ );
42
+
43
+ function Button({
44
+ className,
45
+ variant = "default",
46
+ size = "default",
47
+ loading = false,
48
+ disabled,
49
+ children,
50
+ ...props
51
+ }: ButtonPrimitive.Props &
52
+ VariantProps<typeof buttonVariants> & {
53
+ /**
54
+ * When true, hides the button's content (icon + label) and shows a single
55
+ * centered spinner in its place, disables the button, and marks it
56
+ * `aria-busy`. The hidden content stays in the layout, so the button keeps
57
+ * its natural width and doesn't resize while busy. Use for form submits and
58
+ * async actions so the click can't be double-fired.
59
+ */
60
+ loading?: boolean;
61
+ }) {
62
+ return (
63
+ <ButtonPrimitive
64
+ data-slot="button"
65
+ data-loading={loading || undefined}
66
+ aria-busy={loading || undefined}
67
+ disabled={disabled || loading}
68
+ className={cn(buttonVariants({ variant, size, className }), {
69
+ relative: loading,
70
+ })}
71
+ {...props}
72
+ >
73
+ {loading && (
74
+ <span className="absolute inset-0 flex items-center justify-center">
75
+ <Loader2Icon aria-hidden className="animate-spin" />
76
+ </span>
77
+ )}
78
+ <span className={cn("contents", { invisible: loading })}>{children}</span>
79
+ </ButtonPrimitive>
80
+ );
81
+ }
82
+
83
+ export { Button, buttonVariants };
@@ -0,0 +1,235 @@
1
+ import { Button, buttonVariants } from "@alepha/ui/components/ui/button";
2
+ import { cn } from "@alepha/ui/lib/utils";
3
+ import { useI18n } from "alepha/react/i18n";
4
+ import { enUS, es, fr } from "date-fns/locale";
5
+ import {
6
+ ChevronDownIcon,
7
+ ChevronLeftIcon,
8
+ ChevronRightIcon,
9
+ } from "lucide-react";
10
+ import * as React from "react";
11
+ import {
12
+ type DayButton,
13
+ DayPicker,
14
+ getDefaultClassNames,
15
+ type Locale,
16
+ } from "react-day-picker";
17
+
18
+ // Map Alepha's active language to a date-fns locale so month names and
19
+ // weekday headers render translated by default (consumers can still override
20
+ // via the `locale` prop). Unmapped languages fall back to react-day-picker's
21
+ // own default (en-US).
22
+ const LOCALE_BY_LANG: Record<string, Locale> = { fr, es, en: enUS };
23
+
24
+ function Calendar({
25
+ className,
26
+ classNames,
27
+ showOutsideDays = true,
28
+ captionLayout = "label",
29
+ buttonVariant = "ghost",
30
+ locale,
31
+ formatters,
32
+ components,
33
+ ...props
34
+ }: React.ComponentProps<typeof DayPicker> & {
35
+ buttonVariant?: React.ComponentProps<typeof Button>["variant"];
36
+ }) {
37
+ const defaultClassNames = getDefaultClassNames();
38
+ const { lang } = useI18n();
39
+ const resolvedLocale = locale ?? LOCALE_BY_LANG[lang];
40
+
41
+ return (
42
+ <DayPicker
43
+ showOutsideDays={showOutsideDays}
44
+ className={cn(
45
+ "group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
46
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
47
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
48
+ className,
49
+ )}
50
+ captionLayout={captionLayout}
51
+ locale={resolvedLocale}
52
+ formatters={{
53
+ formatMonthDropdown: (date) =>
54
+ date.toLocaleString(resolvedLocale?.code, { month: "short" }),
55
+ ...formatters,
56
+ }}
57
+ classNames={{
58
+ root: cn("w-fit", defaultClassNames.root),
59
+ months: cn(
60
+ "relative flex flex-col gap-4 md:flex-row",
61
+ defaultClassNames.months,
62
+ ),
63
+ month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
64
+ nav: cn(
65
+ "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
66
+ defaultClassNames.nav,
67
+ ),
68
+ button_previous: cn(
69
+ buttonVariants({ variant: buttonVariant }),
70
+ "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
71
+ defaultClassNames.button_previous,
72
+ ),
73
+ button_next: cn(
74
+ buttonVariants({ variant: buttonVariant }),
75
+ "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
76
+ defaultClassNames.button_next,
77
+ ),
78
+ month_caption: cn(
79
+ "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
80
+ defaultClassNames.month_caption,
81
+ ),
82
+ dropdowns: cn(
83
+ "flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
84
+ defaultClassNames.dropdowns,
85
+ ),
86
+ dropdown_root: cn(
87
+ "relative rounded-(--cell-radius)",
88
+ defaultClassNames.dropdown_root,
89
+ ),
90
+ dropdown: cn(
91
+ "absolute inset-0 bg-popover opacity-0",
92
+ defaultClassNames.dropdown,
93
+ ),
94
+ caption_label: cn(
95
+ "font-medium select-none",
96
+ captionLayout === "label"
97
+ ? "text-sm"
98
+ : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
99
+ defaultClassNames.caption_label,
100
+ ),
101
+ month_grid: "w-full border-collapse",
102
+ weekdays: cn("flex", defaultClassNames.weekdays),
103
+ weekday: cn(
104
+ "flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
105
+ defaultClassNames.weekday,
106
+ ),
107
+ week: cn("mt-2 flex w-full", defaultClassNames.week),
108
+ week_number_header: cn(
109
+ "w-(--cell-size) select-none",
110
+ defaultClassNames.week_number_header,
111
+ ),
112
+ week_number: cn(
113
+ "text-[0.8rem] text-muted-foreground select-none",
114
+ defaultClassNames.week_number,
115
+ ),
116
+ day: cn(
117
+ "group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)",
118
+ props.showWeekNumber
119
+ ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
120
+ : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
121
+ defaultClassNames.day,
122
+ ),
123
+ range_start: cn(
124
+ "relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
125
+ defaultClassNames.range_start,
126
+ ),
127
+ range_middle: cn("rounded-none", defaultClassNames.range_middle),
128
+ range_end: cn(
129
+ "relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
130
+ defaultClassNames.range_end,
131
+ ),
132
+ today: cn(
133
+ "rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
134
+ defaultClassNames.today,
135
+ ),
136
+ outside: cn(
137
+ "text-muted-foreground aria-selected:text-muted-foreground",
138
+ defaultClassNames.outside,
139
+ ),
140
+ disabled: cn(
141
+ "text-muted-foreground opacity-50",
142
+ defaultClassNames.disabled,
143
+ ),
144
+ hidden: cn("invisible", defaultClassNames.hidden),
145
+ ...classNames,
146
+ }}
147
+ components={{
148
+ Root: ({ className, rootRef, ...props }) => {
149
+ return (
150
+ <div
151
+ data-slot="calendar"
152
+ ref={rootRef}
153
+ className={cn(className)}
154
+ {...props}
155
+ />
156
+ );
157
+ },
158
+ Chevron: ({ className, orientation, ...props }) => {
159
+ if (orientation === "left") {
160
+ return (
161
+ <ChevronLeftIcon className={cn("size-4", className)} {...props} />
162
+ );
163
+ }
164
+
165
+ if (orientation === "right") {
166
+ return (
167
+ <ChevronRightIcon
168
+ className={cn("size-4", className)}
169
+ {...props}
170
+ />
171
+ );
172
+ }
173
+
174
+ return (
175
+ <ChevronDownIcon className={cn("size-4", className)} {...props} />
176
+ );
177
+ },
178
+ DayButton: ({ ...props }) => (
179
+ <CalendarDayButton locale={resolvedLocale} {...props} />
180
+ ),
181
+ WeekNumber: ({ children, ...props }) => {
182
+ return (
183
+ <td {...props}>
184
+ <div className="flex size-(--cell-size) items-center justify-center text-center">
185
+ {children}
186
+ </div>
187
+ </td>
188
+ );
189
+ },
190
+ ...components,
191
+ }}
192
+ {...props}
193
+ />
194
+ );
195
+ }
196
+
197
+ function CalendarDayButton({
198
+ className,
199
+ day,
200
+ modifiers,
201
+ locale,
202
+ ...props
203
+ }: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
204
+ const defaultClassNames = getDefaultClassNames();
205
+
206
+ const ref = React.useRef<HTMLButtonElement>(null);
207
+ React.useEffect(() => {
208
+ if (modifiers.focused) ref.current?.focus();
209
+ }, [modifiers.focused]);
210
+
211
+ return (
212
+ <Button
213
+ variant="ghost"
214
+ size="icon"
215
+ data-day={day.date.toLocaleDateString(locale?.code)}
216
+ data-selected-single={
217
+ modifiers.selected &&
218
+ !modifiers.range_start &&
219
+ !modifiers.range_end &&
220
+ !modifiers.range_middle
221
+ }
222
+ data-range-start={modifiers.range_start}
223
+ data-range-end={modifiers.range_end}
224
+ data-range-middle={modifiers.range_middle}
225
+ className={cn(
226
+ "relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
227
+ defaultClassNames.day,
228
+ className,
229
+ )}
230
+ {...props}
231
+ />
232
+ );
233
+ }
234
+
235
+ export { Calendar, CalendarDayButton };
@@ -0,0 +1,102 @@
1
+ import { cn } from "@alepha/ui/lib/utils";
2
+ import type * as React from "react";
3
+
4
+ function Card({
5
+ className,
6
+ size = "default",
7
+ ...props
8
+ }: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
9
+ return (
10
+ <div
11
+ data-slot="card"
12
+ data-size={size}
13
+ className={cn(
14
+ "group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
15
+ className,
16
+ )}
17
+ {...props}
18
+ />
19
+ );
20
+ }
21
+
22
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
23
+ return (
24
+ <div
25
+ data-slot="card-header"
26
+ className={cn(
27
+ "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
28
+ className,
29
+ )}
30
+ {...props}
31
+ />
32
+ );
33
+ }
34
+
35
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
36
+ return (
37
+ <div
38
+ data-slot="card-title"
39
+ className={cn(
40
+ "text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
41
+ className,
42
+ )}
43
+ {...props}
44
+ />
45
+ );
46
+ }
47
+
48
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
49
+ return (
50
+ <div
51
+ data-slot="card-description"
52
+ className={cn("text-sm text-muted-foreground", className)}
53
+ {...props}
54
+ />
55
+ );
56
+ }
57
+
58
+ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
59
+ return (
60
+ <div
61
+ data-slot="card-action"
62
+ className={cn(
63
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
64
+ className,
65
+ )}
66
+ {...props}
67
+ />
68
+ );
69
+ }
70
+
71
+ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
72
+ return (
73
+ <div
74
+ data-slot="card-content"
75
+ className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
76
+ {...props}
77
+ />
78
+ );
79
+ }
80
+
81
+ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
82
+ return (
83
+ <div
84
+ data-slot="card-footer"
85
+ className={cn(
86
+ "flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
87
+ className,
88
+ )}
89
+ {...props}
90
+ />
91
+ );
92
+ }
93
+
94
+ export {
95
+ Card,
96
+ CardAction,
97
+ CardContent,
98
+ CardDescription,
99
+ CardFooter,
100
+ CardHeader,
101
+ CardTitle,
102
+ };