@octanejs/shadcn 0.0.9 → 0.0.11

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.
@@ -0,0 +1,90 @@
1
+ // Base UI base tabs — TRANSCRIBED from upstream's `bases/base-ui/ui/tabs.tsx` (maintainer-supplied),
2
+ // class strings verbatim. Runs on @octanejs/base-ui's `Tabs`, which was ported for this family:
3
+ // Root / List / Tab / Panel.
4
+ //
5
+ // ONE DEPARTURE FROM THE SOURCE, FORCED BY A VERSION SKEW. Upstream writes its orientation variants
6
+ // as `data-horizontal:` / `data-vertical:` — bare attributes. The pinned @octanejs/base-ui (v1.6.0)
7
+ // converts the orientation state to `data-orientation="horizontal" | "vertical"` instead, so those
8
+ // utilities would match nothing: the root would never switch to a column, and every
9
+ // `group-data-horizontal/tabs:` and `group-data-vertical/tabs:` selector on the trigger would be
10
+ // dead. They are written as `data-[orientation=…]:` here.
11
+ //
12
+ // This is the SAME skew the slider hit, and it is not a porting mistake in either layer — shadcn's
13
+ // Base UI sources target a newer Base UI than the pin this package binds. The primitive stays
14
+ // faithful to its pin; the adaptation belongs here. When the binding moves to a release that emits
15
+ // the bare attributes, these revert to upstream's spelling.
16
+ //
17
+ // `data-active` on the trigger needs no such treatment: the pin emits it exactly as upstream's
18
+ // classes expect (verified by rendering).
19
+ //
20
+ // Octane adaptations: no `"use client"`.
21
+ import { cva, type VariantProps } from 'class-variance-authority';
22
+ import { Tabs as TabsPrimitive } from '@octanejs/base-ui/tabs';
23
+
24
+ import { cn } from '../../../lib/utils';
25
+
26
+ type Props = { className?: string } & Record<string, unknown>;
27
+
28
+ export interface TabsProps extends Props {
29
+ orientation?: 'horizontal' | 'vertical';
30
+ }
31
+
32
+ export function Tabs({ className, orientation = 'horizontal', ...props }: TabsProps) @{
33
+ <TabsPrimitive.Root
34
+ data-slot="tabs"
35
+ data-orientation={orientation}
36
+ orientation={orientation}
37
+ className={cn('group/tabs flex gap-2 data-[orientation=horizontal]:flex-col', className)}
38
+ {...props}
39
+ />
40
+ }
41
+
42
+ export const tabsListVariants = cva(
43
+ 'group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none',
44
+ {
45
+ variants: {
46
+ variant: {
47
+ default: 'bg-muted',
48
+ line: 'gap-1 bg-transparent',
49
+ },
50
+ },
51
+ defaultVariants: {
52
+ variant: 'default',
53
+ },
54
+ },
55
+ );
56
+
57
+ export interface TabsListProps extends Props {
58
+ variant?: VariantProps<typeof tabsListVariants>['variant'];
59
+ }
60
+
61
+ export function TabsList({ className, variant = 'default', ...props }: TabsListProps) @{
62
+ <TabsPrimitive.List
63
+ data-slot="tabs-list"
64
+ data-variant={variant}
65
+ className={cn(tabsListVariants({ variant }), className)}
66
+ {...props}
67
+ />
68
+ }
69
+
70
+ export function TabsTrigger({ className, ...props }: Props) @{
71
+ <TabsPrimitive.Tab
72
+ data-slot="tabs-trigger"
73
+ className={cn(
74
+ 'relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
75
+ 'group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent',
76
+ 'data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground',
77
+ 'after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100',
78
+ className,
79
+ )}
80
+ {...props}
81
+ />
82
+ }
83
+
84
+ export function TabsContent({ className, ...props }: Props) @{
85
+ <TabsPrimitive.Panel
86
+ data-slot="tabs-content"
87
+ className={cn('flex-1 text-sm outline-none', className)}
88
+ {...props}
89
+ />
90
+ }