@saena-io/create 0.1.0 → 0.2.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 (100) hide show
  1. package/dist/index.js +9 -9
  2. package/package.json +1 -1
  3. package/template/base/package.json +44 -2
  4. package/template/base/scripts/ui-update.ts +83 -0
  5. package/template/base/src/components/ui/accordion.tsx +75 -0
  6. package/template/base/src/components/ui/alert-dialog.tsx +162 -0
  7. package/template/base/src/components/ui/alert.tsx +73 -0
  8. package/template/base/src/components/ui/app-sidebar.tsx +183 -0
  9. package/template/base/src/components/ui/aspect-ratio.tsx +22 -0
  10. package/template/base/src/components/ui/asset-input.tsx +211 -0
  11. package/template/base/src/components/ui/avatar.tsx +91 -0
  12. package/template/base/src/components/ui/badge.tsx +50 -0
  13. package/template/base/src/components/ui/breadcrumb.tsx +104 -0
  14. package/template/base/src/components/ui/button-group.tsx +78 -0
  15. package/template/base/src/components/ui/button.tsx +56 -0
  16. package/template/base/src/components/ui/calendar.tsx +205 -0
  17. package/template/base/src/components/ui/card.tsx +85 -0
  18. package/template/base/src/components/ui/carousel.tsx +232 -0
  19. package/template/base/src/components/ui/chart.tsx +337 -0
  20. package/template/base/src/components/ui/checkbox.tsx +29 -0
  21. package/template/base/src/components/ui/collapsible.tsx +15 -0
  22. package/template/base/src/components/ui/combobox.tsx +276 -0
  23. package/template/base/src/components/ui/command.tsx +190 -0
  24. package/template/base/src/components/ui/context-menu.tsx +243 -0
  25. package/template/base/src/components/ui/dialog.tsx +134 -0
  26. package/template/base/src/components/ui/direction.tsx +4 -0
  27. package/template/base/src/components/ui/drawer.tsx +120 -0
  28. package/template/base/src/components/ui/dropdown-menu.tsx +254 -0
  29. package/template/base/src/components/ui/empty.tsx +94 -0
  30. package/template/base/src/components/ui/field.tsx +222 -0
  31. package/template/base/src/components/ui/focal-point-picker.tsx +175 -0
  32. package/template/base/src/components/ui/hover-card.tsx +46 -0
  33. package/template/base/src/components/ui/input-group.tsx +149 -0
  34. package/template/base/src/components/ui/input-otp.tsx +85 -0
  35. package/template/base/src/components/ui/input.tsx +20 -0
  36. package/template/base/src/components/ui/item.tsx +188 -0
  37. package/template/base/src/components/ui/kbd.tsx +26 -0
  38. package/template/base/src/components/ui/label.tsx +20 -0
  39. package/template/base/src/components/ui/menubar.tsx +268 -0
  40. package/template/base/src/components/ui/native-select.tsx +58 -0
  41. package/template/base/src/components/ui/nav-main.tsx +70 -0
  42. package/template/base/src/components/ui/nav-projects.tsx +97 -0
  43. package/template/base/src/components/ui/nav-secondary.tsx +37 -0
  44. package/template/base/src/components/ui/nav-user.tsx +108 -0
  45. package/template/base/src/components/ui/navigation-menu.tsx +164 -0
  46. package/template/base/src/components/ui/pagination.tsx +123 -0
  47. package/template/base/src/components/ui/popover.tsx +80 -0
  48. package/template/base/src/components/ui/progress.tsx +66 -0
  49. package/template/base/src/components/ui/radio-group.tsx +36 -0
  50. package/template/base/src/components/ui/resizable.tsx +42 -0
  51. package/template/base/src/components/ui/rich-text/ai-chat-editor.tsx +20 -0
  52. package/template/base/src/components/ui/rich-text/ai-command.tsx +90 -0
  53. package/template/base/src/components/ui/rich-text/ai-copilot.tsx +67 -0
  54. package/template/base/src/components/ui/rich-text/ai-menu.tsx +456 -0
  55. package/template/base/src/components/ui/rich-text/ai-node.tsx +42 -0
  56. package/template/base/src/components/ui/rich-text/ai-toolbar-button.tsx +29 -0
  57. package/template/base/src/components/ui/rich-text/block-draggable.tsx +187 -0
  58. package/template/base/src/components/ui/rich-text/block-selection.tsx +17 -0
  59. package/template/base/src/components/ui/rich-text/code-block-node.tsx +204 -0
  60. package/template/base/src/components/ui/rich-text/codec.ts +63 -0
  61. package/template/base/src/components/ui/rich-text/extension.ts +53 -0
  62. package/template/base/src/components/ui/rich-text/ghost-text.tsx +23 -0
  63. package/template/base/src/components/ui/rich-text/import-export-toolbar.tsx +103 -0
  64. package/template/base/src/components/ui/rich-text/link.tsx +18 -0
  65. package/template/base/src/components/ui/rich-text/list-node.tsx +65 -0
  66. package/template/base/src/components/ui/rich-text/nodes.tsx +44 -0
  67. package/template/base/src/components/ui/rich-text/plugins.ts +233 -0
  68. package/template/base/src/components/ui/rich-text/rich-text-editor.tsx +82 -0
  69. package/template/base/src/components/ui/rich-text/static.tsx +117 -0
  70. package/template/base/src/components/ui/rich-text/table-node.tsx +934 -0
  71. package/template/base/src/components/ui/rich-text/table-toolbar.tsx +232 -0
  72. package/template/base/src/components/ui/rich-text/toggle-node.tsx +36 -0
  73. package/template/base/src/components/ui/rich-text/toolbar-slots.ts +41 -0
  74. package/template/base/src/components/ui/rich-text/toolbar.tsx +668 -0
  75. package/template/base/src/components/ui/rich-text/use-ai-chat.ts +35 -0
  76. package/template/base/src/components/ui/rich-text/variable-type.ts +4 -0
  77. package/template/base/src/components/ui/rich-text/variable.tsx +97 -0
  78. package/template/base/src/components/ui/scroll-area.tsx +49 -0
  79. package/template/base/src/components/ui/select.tsx +202 -0
  80. package/template/base/src/components/ui/separator.tsx +19 -0
  81. package/template/base/src/components/ui/sheet.tsx +126 -0
  82. package/template/base/src/components/ui/sidebar.tsx +695 -0
  83. package/template/base/src/components/ui/skeleton.tsx +13 -0
  84. package/template/base/src/components/ui/slider.tsx +52 -0
  85. package/template/base/src/components/ui/sonner.tsx +50 -0
  86. package/template/base/src/components/ui/spinner.tsx +18 -0
  87. package/template/base/src/components/ui/switch.tsx +30 -0
  88. package/template/base/src/components/ui/table.tsx +89 -0
  89. package/template/base/src/components/ui/tabs.tsx +73 -0
  90. package/template/base/src/components/ui/textarea.tsx +18 -0
  91. package/template/base/src/components/ui/toggle-group.tsx +85 -0
  92. package/template/base/src/components/ui/toggle.tsx +45 -0
  93. package/template/base/src/components/ui/toolbar.tsx +451 -0
  94. package/template/base/src/components/ui/tooltip.tsx +52 -0
  95. package/template/base/src/hooks/use-mobile.ts +19 -0
  96. package/template/base/src/lib/utils.ts +6 -0
  97. package/template/base/src/routes/__root.tsx +1 -1
  98. package/template/base/src/server/auth.ts +2 -2
  99. package/template/base/src/styles/globals.css +230 -0
  100. package/template/base/vite.config.ts +15 -1
@@ -0,0 +1,78 @@
1
+ import { mergeProps } from '@base-ui/react/merge-props';
2
+ import { useRender } from '@base-ui/react/use-render';
3
+ import { type VariantProps, cva } from 'class-variance-authority';
4
+
5
+ import { Separator } from '@saena-io/ui/components/separator';
6
+ import { cn } from '@saena-io/ui/lib/utils';
7
+
8
+ const buttonGroupVariants = cva(
9
+ "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-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
10
+ {
11
+ variants: {
12
+ orientation: {
13
+ horizontal:
14
+ '*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-md! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0',
15
+ vertical:
16
+ 'flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-md! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0',
17
+ },
18
+ },
19
+ defaultVariants: {
20
+ orientation: 'horizontal',
21
+ },
22
+ },
23
+ );
24
+
25
+ function ButtonGroup({
26
+ className,
27
+ orientation,
28
+ ...props
29
+ }: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>) {
30
+ return (
31
+ <div
32
+ role="group"
33
+ data-slot="button-group"
34
+ data-orientation={orientation}
35
+ className={cn(buttonGroupVariants({ orientation }), className)}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ function ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>) {
42
+ return useRender({
43
+ defaultTagName: 'div',
44
+ props: mergeProps<'div'>(
45
+ {
46
+ className: cn(
47
+ "flex items-center gap-2 rounded-md border bg-muted px-2.5 text-xs/relaxed font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
48
+ className,
49
+ ),
50
+ },
51
+ props,
52
+ ),
53
+ render,
54
+ state: {
55
+ slot: 'button-group-text',
56
+ },
57
+ });
58
+ }
59
+
60
+ function ButtonGroupSeparator({
61
+ className,
62
+ orientation = 'vertical',
63
+ ...props
64
+ }: React.ComponentProps<typeof Separator>) {
65
+ return (
66
+ <Separator
67
+ data-slot="button-group-separator"
68
+ orientation={orientation}
69
+ className={cn(
70
+ 'relative self-stretch bg-input data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto',
71
+ className,
72
+ )}
73
+ {...props}
74
+ />
75
+ );
76
+ }
77
+
78
+ export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants };
@@ -0,0 +1,56 @@
1
+ import { Button as ButtonPrimitive } from '@base-ui/react/button';
2
+ import { type VariantProps, cva } from 'class-variance-authority';
3
+
4
+ import { cn } from '@saena-io/ui/lib/utils';
5
+
6
+ const buttonVariants = cva(
7
+ "group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs/relaxed font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 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 hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30',
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-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
25
+ xs: "h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-2.5",
26
+ sm: "h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
27
+ lg: "h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-4",
28
+ icon: "size-7 [&_svg:not([class*='size-'])]:size-3.5",
29
+ 'icon-xs': "size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5",
30
+ 'icon-sm': "size-6 [&_svg:not([class*='size-'])]:size-3",
31
+ 'icon-lg': "size-8 [&_svg:not([class*='size-'])]:size-4",
32
+ },
33
+ },
34
+ defaultVariants: {
35
+ variant: 'default',
36
+ size: 'default',
37
+ },
38
+ },
39
+ );
40
+
41
+ function Button({
42
+ className,
43
+ variant = 'default',
44
+ size = 'default',
45
+ ...props
46
+ }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
47
+ return (
48
+ <ButtonPrimitive
49
+ data-slot="button"
50
+ className={cn(buttonVariants({ variant, size, className }))}
51
+ {...props}
52
+ />
53
+ );
54
+ }
55
+
56
+ export { Button, buttonVariants };
@@ -0,0 +1,205 @@
1
+ import * as React from 'react';
2
+ import { type DayButton, DayPicker, type Locale, getDefaultClassNames } from 'react-day-picker';
3
+
4
+ import { ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon } from '@hugeicons/core-free-icons';
5
+ import { HugeiconsIcon } from '@hugeicons/react';
6
+ import { Button, buttonVariants } from '@saena-io/ui/components/button';
7
+ import { cn } from '@saena-io/ui/lib/utils';
8
+
9
+ function Calendar({
10
+ className,
11
+ classNames,
12
+ showOutsideDays = true,
13
+ captionLayout = 'label',
14
+ buttonVariant = 'ghost',
15
+ locale,
16
+ formatters,
17
+ components,
18
+ ...props
19
+ }: React.ComponentProps<typeof DayPicker> & {
20
+ buttonVariant?: React.ComponentProps<typeof Button>['variant'];
21
+ }) {
22
+ const defaultClassNames = getDefaultClassNames();
23
+
24
+ return (
25
+ <DayPicker
26
+ showOutsideDays={showOutsideDays}
27
+ className={cn(
28
+ 'group/calendar bg-background p-3 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(6)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent',
29
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
30
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
31
+ className,
32
+ )}
33
+ captionLayout={captionLayout}
34
+ locale={locale}
35
+ formatters={{
36
+ formatMonthDropdown: (date) => date.toLocaleString(locale?.code, { month: 'short' }),
37
+ ...formatters,
38
+ }}
39
+ classNames={{
40
+ root: cn('w-fit', defaultClassNames.root),
41
+ months: cn('relative flex flex-col gap-4 md:flex-row', defaultClassNames.months),
42
+ month: cn('flex w-full flex-col gap-4', defaultClassNames.month),
43
+ nav: cn(
44
+ 'absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1',
45
+ defaultClassNames.nav,
46
+ ),
47
+ button_previous: cn(
48
+ buttonVariants({ variant: buttonVariant }),
49
+ 'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
50
+ defaultClassNames.button_previous,
51
+ ),
52
+ button_next: cn(
53
+ buttonVariants({ variant: buttonVariant }),
54
+ 'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
55
+ defaultClassNames.button_next,
56
+ ),
57
+ month_caption: cn(
58
+ 'flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)',
59
+ defaultClassNames.month_caption,
60
+ ),
61
+ dropdowns: cn(
62
+ 'flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium',
63
+ defaultClassNames.dropdowns,
64
+ ),
65
+ dropdown_root: cn('relative rounded-(--cell-radius)', defaultClassNames.dropdown_root),
66
+ dropdown: cn('absolute inset-0 bg-popover opacity-0', defaultClassNames.dropdown),
67
+ caption_label: cn(
68
+ 'font-medium select-none',
69
+ captionLayout === 'label'
70
+ ? 'text-sm'
71
+ : 'flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground',
72
+ defaultClassNames.caption_label,
73
+ ),
74
+ month_grid: cn('w-full border-collapse', defaultClassNames.month_grid),
75
+ weekdays: cn('flex', defaultClassNames.weekdays),
76
+ weekday: cn(
77
+ 'flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none',
78
+ defaultClassNames.weekday,
79
+ ),
80
+ week: cn('mt-2 flex w-full', defaultClassNames.week),
81
+ week_number_header: cn('w-(--cell-size) select-none', defaultClassNames.week_number_header),
82
+ week_number: cn(
83
+ 'text-[0.8rem] text-muted-foreground select-none',
84
+ defaultClassNames.week_number,
85
+ ),
86
+ day: cn(
87
+ '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)',
88
+ props.showWeekNumber
89
+ ? '[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)'
90
+ : '[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)',
91
+ defaultClassNames.day,
92
+ ),
93
+ range_start: cn(
94
+ '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',
95
+ defaultClassNames.range_start,
96
+ ),
97
+ range_middle: cn('rounded-none', defaultClassNames.range_middle),
98
+ range_end: cn(
99
+ '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',
100
+ defaultClassNames.range_end,
101
+ ),
102
+ today: cn(
103
+ 'rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none',
104
+ defaultClassNames.today,
105
+ ),
106
+ outside: cn(
107
+ 'text-muted-foreground aria-selected:text-muted-foreground',
108
+ defaultClassNames.outside,
109
+ ),
110
+ disabled: cn('text-muted-foreground opacity-50', defaultClassNames.disabled),
111
+ hidden: cn('invisible', defaultClassNames.hidden),
112
+ ...classNames,
113
+ }}
114
+ components={{
115
+ Root: ({ className, rootRef, ...props }) => {
116
+ return <div data-slot="calendar" ref={rootRef} className={cn(className)} {...props} />;
117
+ },
118
+ Chevron: ({ className, orientation, ...props }) => {
119
+ if (orientation === 'left') {
120
+ return (
121
+ <HugeiconsIcon
122
+ icon={ArrowLeftIcon}
123
+ strokeWidth={2}
124
+ className={cn('size-4', className)}
125
+ {...props}
126
+ />
127
+ );
128
+ }
129
+
130
+ if (orientation === 'right') {
131
+ return (
132
+ <HugeiconsIcon
133
+ icon={ArrowRightIcon}
134
+ strokeWidth={2}
135
+ className={cn('size-4', className)}
136
+ {...props}
137
+ />
138
+ );
139
+ }
140
+
141
+ return (
142
+ <HugeiconsIcon
143
+ icon={ArrowDownIcon}
144
+ strokeWidth={2}
145
+ className={cn('size-4', className)}
146
+ {...props}
147
+ />
148
+ );
149
+ },
150
+ DayButton: ({ ...props }) => <CalendarDayButton locale={locale} {...props} />,
151
+ WeekNumber: ({ children, ...props }) => {
152
+ return (
153
+ <td {...props}>
154
+ <div className="flex size-(--cell-size) items-center justify-center text-center">
155
+ {children}
156
+ </div>
157
+ </td>
158
+ );
159
+ },
160
+ ...components,
161
+ }}
162
+ {...props}
163
+ />
164
+ );
165
+ }
166
+
167
+ function CalendarDayButton({
168
+ className,
169
+ day,
170
+ modifiers,
171
+ locale,
172
+ ...props
173
+ }: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
174
+ const defaultClassNames = getDefaultClassNames();
175
+
176
+ const ref = React.useRef<HTMLButtonElement>(null);
177
+ React.useEffect(() => {
178
+ if (modifiers.focused) ref.current?.focus();
179
+ }, [modifiers.focused]);
180
+
181
+ return (
182
+ <Button
183
+ variant="ghost"
184
+ size="icon"
185
+ data-day={day.date.toLocaleDateString(locale?.code)}
186
+ data-selected-single={
187
+ modifiers.selected &&
188
+ !modifiers.range_start &&
189
+ !modifiers.range_end &&
190
+ !modifiers.range_middle
191
+ }
192
+ data-range-start={modifiers.range_start}
193
+ data-range-end={modifiers.range_end}
194
+ data-range-middle={modifiers.range_middle}
195
+ className={cn(
196
+ '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',
197
+ defaultClassNames.day,
198
+ className,
199
+ )}
200
+ {...props}
201
+ />
202
+ );
203
+ }
204
+
205
+ export { Calendar, CalendarDayButton };
@@ -0,0 +1,85 @@
1
+ import type * as React from 'react';
2
+
3
+ import { cn } from '@saena-io/ui/lib/utils';
4
+
5
+ function Card({
6
+ className,
7
+ size = 'default',
8
+ ...props
9
+ }: React.ComponentProps<'div'> & { size?: 'default' | 'sm' }) {
10
+ return (
11
+ <div
12
+ data-slot="card"
13
+ data-size={size}
14
+ className={cn(
15
+ 'group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-lg bg-card py-(--card-spacing) text-xs/relaxed text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg',
16
+ className,
17
+ )}
18
+ {...props}
19
+ />
20
+ );
21
+ }
22
+
23
+ function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
24
+ return (
25
+ <div
26
+ data-slot="card-header"
27
+ className={cn(
28
+ 'group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)',
29
+ className,
30
+ )}
31
+ {...props}
32
+ />
33
+ );
34
+ }
35
+
36
+ function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
37
+ return (
38
+ <div
39
+ data-slot="card-title"
40
+ className={cn('font-heading text-sm font-medium', className)}
41
+ {...props}
42
+ />
43
+ );
44
+ }
45
+
46
+ function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
47
+ return (
48
+ <div
49
+ data-slot="card-description"
50
+ className={cn('text-xs/relaxed text-muted-foreground', className)}
51
+ {...props}
52
+ />
53
+ );
54
+ }
55
+
56
+ function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
57
+ return (
58
+ <div
59
+ data-slot="card-action"
60
+ className={cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', className)}
61
+ {...props}
62
+ />
63
+ );
64
+ }
65
+
66
+ function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
67
+ return (
68
+ <div data-slot="card-content" className={cn('px-(--card-spacing)', className)} {...props} />
69
+ );
70
+ }
71
+
72
+ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
73
+ return (
74
+ <div
75
+ data-slot="card-footer"
76
+ className={cn(
77
+ 'flex items-center rounded-b-lg px-(--card-spacing) [.border-t]:pt-(--card-spacing)',
78
+ className,
79
+ )}
80
+ {...props}
81
+ />
82
+ );
83
+ }
84
+
85
+ export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
@@ -0,0 +1,232 @@
1
+ 'use client';
2
+
3
+ import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react';
4
+ import * as React from 'react';
5
+
6
+ import { ArrowLeft01Icon, ArrowRight01Icon } from '@hugeicons/core-free-icons';
7
+ import { HugeiconsIcon } from '@hugeicons/react';
8
+ import { Button } from '@saena-io/ui/components/button';
9
+ import { cn } from '@saena-io/ui/lib/utils';
10
+
11
+ type CarouselApi = UseEmblaCarouselType[1];
12
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
13
+ type CarouselOptions = UseCarouselParameters[0];
14
+ type CarouselPlugin = UseCarouselParameters[1];
15
+
16
+ type CarouselProps = {
17
+ opts?: CarouselOptions;
18
+ plugins?: CarouselPlugin;
19
+ orientation?: 'horizontal' | 'vertical';
20
+ setApi?: (api: CarouselApi) => void;
21
+ };
22
+
23
+ type CarouselContextProps = {
24
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0];
25
+ api: ReturnType<typeof useEmblaCarousel>[1];
26
+ scrollPrev: () => void;
27
+ scrollNext: () => void;
28
+ canScrollPrev: boolean;
29
+ canScrollNext: boolean;
30
+ } & CarouselProps;
31
+
32
+ const CarouselContext = React.createContext<CarouselContextProps | null>(null);
33
+
34
+ function useCarousel() {
35
+ const context = React.useContext(CarouselContext);
36
+
37
+ if (!context) {
38
+ throw new Error('useCarousel must be used within a <Carousel />');
39
+ }
40
+
41
+ return context;
42
+ }
43
+
44
+ function Carousel({
45
+ orientation = 'horizontal',
46
+ opts,
47
+ setApi,
48
+ plugins,
49
+ className,
50
+ children,
51
+ ...props
52
+ }: React.ComponentProps<'div'> & CarouselProps) {
53
+ const [carouselRef, api] = useEmblaCarousel(
54
+ {
55
+ ...opts,
56
+ axis: orientation === 'horizontal' ? 'x' : 'y',
57
+ },
58
+ plugins,
59
+ );
60
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false);
61
+ const [canScrollNext, setCanScrollNext] = React.useState(false);
62
+
63
+ const onSelect = React.useCallback((api: CarouselApi) => {
64
+ if (!api) return;
65
+ setCanScrollPrev(api.canScrollPrev());
66
+ setCanScrollNext(api.canScrollNext());
67
+ }, []);
68
+
69
+ const scrollPrev = React.useCallback(() => {
70
+ api?.scrollPrev();
71
+ }, [api]);
72
+
73
+ const scrollNext = React.useCallback(() => {
74
+ api?.scrollNext();
75
+ }, [api]);
76
+
77
+ const handleKeyDown = React.useCallback(
78
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
79
+ if (event.key === 'ArrowLeft') {
80
+ event.preventDefault();
81
+ scrollPrev();
82
+ } else if (event.key === 'ArrowRight') {
83
+ event.preventDefault();
84
+ scrollNext();
85
+ }
86
+ },
87
+ [scrollPrev, scrollNext],
88
+ );
89
+
90
+ React.useEffect(() => {
91
+ if (!api || !setApi) return;
92
+ setApi(api);
93
+ }, [api, setApi]);
94
+
95
+ React.useEffect(() => {
96
+ if (!api) return;
97
+ onSelect(api);
98
+ api.on('reInit', onSelect);
99
+ api.on('select', onSelect);
100
+
101
+ return () => {
102
+ api?.off('select', onSelect);
103
+ };
104
+ }, [api, onSelect]);
105
+
106
+ return (
107
+ <CarouselContext.Provider
108
+ value={{
109
+ carouselRef,
110
+ api: api,
111
+ opts,
112
+ orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
113
+ scrollPrev,
114
+ scrollNext,
115
+ canScrollPrev,
116
+ canScrollNext,
117
+ }}
118
+ >
119
+ <div
120
+ onKeyDownCapture={handleKeyDown}
121
+ className={cn('relative', className)}
122
+ role="region"
123
+ aria-roledescription="carousel"
124
+ data-slot="carousel"
125
+ {...props}
126
+ >
127
+ {children}
128
+ </div>
129
+ </CarouselContext.Provider>
130
+ );
131
+ }
132
+
133
+ function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
134
+ const { carouselRef, orientation } = useCarousel();
135
+
136
+ return (
137
+ <div ref={carouselRef} className="overflow-hidden" data-slot="carousel-content">
138
+ <div
139
+ className={cn('flex', orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col', className)}
140
+ {...props}
141
+ />
142
+ </div>
143
+ );
144
+ }
145
+
146
+ function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
147
+ const { orientation } = useCarousel();
148
+
149
+ return (
150
+ <div
151
+ role="group"
152
+ aria-roledescription="slide"
153
+ data-slot="carousel-item"
154
+ className={cn(
155
+ 'min-w-0 shrink-0 grow-0 basis-full',
156
+ orientation === 'horizontal' ? 'pl-4' : 'pt-4',
157
+ className,
158
+ )}
159
+ {...props}
160
+ />
161
+ );
162
+ }
163
+
164
+ function CarouselPrevious({
165
+ className,
166
+ variant = 'outline',
167
+ size = 'icon-sm',
168
+ ...props
169
+ }: React.ComponentProps<typeof Button>) {
170
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel();
171
+
172
+ return (
173
+ <Button
174
+ data-slot="carousel-previous"
175
+ variant={variant}
176
+ size={size}
177
+ className={cn(
178
+ 'absolute touch-manipulation rounded-full',
179
+ orientation === 'horizontal'
180
+ ? 'top-1/2 -left-12 -translate-y-1/2'
181
+ : '-top-12 left-1/2 -translate-x-1/2 rotate-90',
182
+ className,
183
+ )}
184
+ disabled={!canScrollPrev}
185
+ onClick={scrollPrev}
186
+ {...props}
187
+ >
188
+ <HugeiconsIcon icon={ArrowLeft01Icon} strokeWidth={2} />
189
+ <span className="sr-only">Previous slide</span>
190
+ </Button>
191
+ );
192
+ }
193
+
194
+ function CarouselNext({
195
+ className,
196
+ variant = 'outline',
197
+ size = 'icon-sm',
198
+ ...props
199
+ }: React.ComponentProps<typeof Button>) {
200
+ const { orientation, scrollNext, canScrollNext } = useCarousel();
201
+
202
+ return (
203
+ <Button
204
+ data-slot="carousel-next"
205
+ variant={variant}
206
+ size={size}
207
+ className={cn(
208
+ 'absolute touch-manipulation rounded-full',
209
+ orientation === 'horizontal'
210
+ ? 'top-1/2 -right-12 -translate-y-1/2'
211
+ : '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
212
+ className,
213
+ )}
214
+ disabled={!canScrollNext}
215
+ onClick={scrollNext}
216
+ {...props}
217
+ >
218
+ <HugeiconsIcon icon={ArrowRight01Icon} strokeWidth={2} />
219
+ <span className="sr-only">Next slide</span>
220
+ </Button>
221
+ );
222
+ }
223
+
224
+ export {
225
+ type CarouselApi,
226
+ Carousel,
227
+ CarouselContent,
228
+ CarouselItem,
229
+ CarouselPrevious,
230
+ CarouselNext,
231
+ useCarousel,
232
+ };