rockin 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/styles.css CHANGED
@@ -302,8 +302,8 @@
302
302
  --chart-scale-04: oklch(0.58 0.06 270);
303
303
  --chart-scale-05: oklch(0.68 0.07 270);
304
304
  --chart-scale-pattern-color: oklch(0.145 0 0);
305
- --selection: oklch(0.145 0 0);
306
- --selection-foreground: oklch(1 0 0);
305
+ --selection: oklch(0.985 0 0);
306
+ --selection-foreground: oklch(0.145 0 0);
307
307
  }
308
308
 
309
309
  @media (display-mode: standalone) {
@@ -1,6 +1,6 @@
1
1
  import { Accordion as Accordion$1 } from '@base-ui/react/accordion';
2
2
  import * as React$1 from 'react';
3
- import React__default, { ComponentProps, ReactNode, HTMLAttributes } from 'react';
3
+ import React__default, { ComponentProps, ReactNode, HTMLAttributes, ButtonHTMLAttributes } from 'react';
4
4
  import { AlertDialog as AlertDialog$1 } from '@base-ui/react/alert-dialog';
5
5
  import * as class_variance_authority_types from 'class-variance-authority/types';
6
6
  import { Button as Button$1 } from '@base-ui/react/button';
@@ -1032,6 +1032,37 @@ declare function Switch({ className, size, ...props }: Switch$1.Root.Props & {
1032
1032
  size?: "sm" | "default";
1033
1033
  }): React$1.JSX.Element;
1034
1034
 
1035
+ type Variant = "pill" | "underline" | "segment";
1036
+ /** Whether trigger icons show on every tab or only on the selected one. */
1037
+ type IconDisplay = "always" | "selected";
1038
+ declare function Tabs({ defaultValue, value, onValueChange, variant, icons, children, className, }: {
1039
+ defaultValue?: string;
1040
+ value?: string;
1041
+ onValueChange?: (v: string) => void;
1042
+ variant?: Variant;
1043
+ /**
1044
+ * With "selected", a trigger's icon springs open only on the selected tab
1045
+ * and folds away when another is chosen. Defaults to "always".
1046
+ */
1047
+ icons?: IconDisplay;
1048
+ children: ReactNode;
1049
+ className?: string;
1050
+ }): React$1.JSX.Element;
1051
+ declare function TabsList({ children, className, wrapperClassName, onKeyDown, ...props }: {
1052
+ wrapperClassName?: string;
1053
+ } & HTMLAttributes<HTMLDivElement>): React$1.JSX.Element;
1054
+ declare function TabsTrigger({ value, icon, children, className, indicatorClassName, onClick, ...props }: {
1055
+ value: string;
1056
+ /** An icon before the label, such as a Lucide icon element. */
1057
+ icon?: ReactNode;
1058
+ indicatorClassName?: string;
1059
+ } & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value">): React$1.JSX.Element;
1060
+ declare function TabsContent({ value, children, className, }: {
1061
+ value: string;
1062
+ children: ReactNode;
1063
+ className?: string;
1064
+ }): React$1.JSX.Element;
1065
+
1035
1066
  declare function Textarea({ className, ...props }: React$1.ComponentProps<"textarea">): React$1.JSX.Element;
1036
1067
 
1037
1068
  declare function ThemeToggle({ size, variant, className, }: {
@@ -1045,4 +1076,4 @@ declare function Tooltip({ ...props }: Tooltip$1.Root.Props): React$1.JSX.Elemen
1045
1076
  declare function TooltipTrigger({ ...props }: Tooltip$1.Trigger.Props): React$1.JSX.Element;
1046
1077
  declare function TooltipContent({ className, side, sideOffset, align, alignOffset, children, ...props }: Tooltip$1.Popup.Props & Pick<Tooltip$1.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">): React$1.JSX.Element;
1047
1078
 
1048
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AnimatedDiv, type AnimatedTAGProps, Apple, AppleHelloEffectEnglish, AppleHelloEffectHindi, AppleHelloEffectSpanish, Autocomplete, AutocompleteClear, AutocompleteCollection, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteInput, AutocompleteItem, AutocompleteList, AutocompletePopup, AutocompleteRow, AutocompleteSeparator, AutocompleteStatus, AutocompleteTrigger, AutocompleteValue, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BlogCardAnimation, Bottom, Bubble, BubbleContent, BubbleGroup, BubbleReactions, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, CodeBlock, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type CustomRendererProps, DEFAULT_I18N, DEFAULT_OPERATORS, DashedSeparator, DataTable, DataTableBody, DataTableCell, DataTableEmptyBody, DataTableHeader, DataTablePagination, DataTableRow, DataTableSearchFilter, DataTableSkeleton, DataTableToolbarSection, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Dock, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerSwipeHandle, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EASE_DRAWER, EASE_IN_OUT, EASE_OUT, EASE_OUT_CSS, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FadeContainer, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, type Filter, type FilterFieldConfig, type FilterFieldGroup, type FilterFieldsConfig, type FilterGroup, type FilterI18nConfig, type FilterOperator, type FilterOption, type FilterOptionListRenderProps, Filters, FiltersContent, Image, type ImageProps, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, JellyAction, JellyBlob, JellyEmpty, type JellyEmptyProps, JellyGroup, JellyLink, JellyMascot, type JellyMascotConfig, JellyMini, type JellySize, Kbd, KbdGroup, Label, ListItemVariant, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, NativeAppBridge, NumberStepper, OTPInput, type OTPInputProps, type OTPStatus, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, QuantityInput, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, RollingNumber, SPRING_LAYOUT, SPRING_MOUSE, SPRING_PANEL, SPRING_PRESS, SPRING_SWAP, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, ShimmerSkeleton, type SkeletonProps as ShimmerSkeletonProps, Skeleton, SkeletonAvatar, SkeletonButton, type SkeletonProps, type SkeletonRounded, SkeletonText, type SkeletonVariant, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay, type SortableProps, SwipeAction, SwipeActions, SwipeContent, SwipeItem, SwipeRoot, type SwipeSide, type SwipeState, Switch, Textarea, ThemeToggle, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Top, activityItemAnimation, badgeVariants, buttonGroupVariants, buttonVariants, createFilter, createFilterGroup, fromLeftChildren, fromLeftVariant, fromRightVariant, fromTopVariant, getSkeletonVariantDuration, hamFastFadeContainer, headingFromLeft, kanbanOrderCardAnimation, kanbanOrderCardLayoutTransition, kanbanOrderCardReducedMotionAnimation, mobileNavItemSideways, opacityVariant, popUp, popUpFromBottomForText, resolveSkeletonA11yProps, searchBarSlideAnimation, skeletonRoundedClasses, skeletonVariantDefaultDuration, svgVariant, useAutocompleteFilter, useCarousel, useComboboxAnchor, useJellyMood };
1079
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AnimatedDiv, type AnimatedTAGProps, Apple, AppleHelloEffectEnglish, AppleHelloEffectHindi, AppleHelloEffectSpanish, Autocomplete, AutocompleteClear, AutocompleteCollection, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteInput, AutocompleteItem, AutocompleteList, AutocompletePopup, AutocompleteRow, AutocompleteSeparator, AutocompleteStatus, AutocompleteTrigger, AutocompleteValue, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BlogCardAnimation, Bottom, Bubble, BubbleContent, BubbleGroup, BubbleReactions, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, CodeBlock, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type CustomRendererProps, DEFAULT_I18N, DEFAULT_OPERATORS, DashedSeparator, DataTable, DataTableBody, DataTableCell, DataTableEmptyBody, DataTableHeader, DataTablePagination, DataTableRow, DataTableSearchFilter, DataTableSkeleton, DataTableToolbarSection, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Dock, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerSwipeHandle, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EASE_DRAWER, EASE_IN_OUT, EASE_OUT, EASE_OUT_CSS, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FadeContainer, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, type Filter, type FilterFieldConfig, type FilterFieldGroup, type FilterFieldsConfig, type FilterGroup, type FilterI18nConfig, type FilterOperator, type FilterOption, type FilterOptionListRenderProps, Filters, FiltersContent, Image, type ImageProps, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, JellyAction, JellyBlob, JellyEmpty, type JellyEmptyProps, JellyGroup, JellyLink, JellyMascot, type JellyMascotConfig, JellyMini, type JellySize, Kbd, KbdGroup, Label, ListItemVariant, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, NativeAppBridge, NumberStepper, OTPInput, type OTPInputProps, type OTPStatus, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, QuantityInput, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, RollingNumber, SPRING_LAYOUT, SPRING_MOUSE, SPRING_PANEL, SPRING_PRESS, SPRING_SWAP, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, ShimmerSkeleton, type SkeletonProps as ShimmerSkeletonProps, Skeleton, SkeletonAvatar, SkeletonButton, type SkeletonProps, type SkeletonRounded, SkeletonText, type SkeletonVariant, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay, type SortableProps, SwipeAction, SwipeActions, SwipeContent, SwipeItem, SwipeRoot, type SwipeSide, type SwipeState, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeToggle, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Top, activityItemAnimation, badgeVariants, buttonGroupVariants, buttonVariants, createFilter, createFilterGroup, fromLeftChildren, fromLeftVariant, fromRightVariant, fromTopVariant, getSkeletonVariantDuration, hamFastFadeContainer, headingFromLeft, kanbanOrderCardAnimation, kanbanOrderCardLayoutTransition, kanbanOrderCardReducedMotionAnimation, mobileNavItemSideways, opacityVariant, popUp, popUpFromBottomForText, resolveSkeletonA11yProps, searchBarSlideAnimation, skeletonRoundedClasses, skeletonVariantDefaultDuration, svgVariant, useAutocompleteFilter, useCarousel, useComboboxAnchor, useJellyMood };
package/dist/ui/index.js CHANGED
@@ -17,8 +17,8 @@ export { CodeBlock } from "./code-block.js"
17
17
  export { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, useComboboxAnchor } from "./combobox.js"
18
18
  export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, useCommandState } from "./command.js"
19
19
  export { DashedSeparator } from "./dashed.js"
20
- export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from "./dialog.js"
21
20
  export { DataGrid, DataGridCell, DataGridClipboard, DataGridColumn, DataGridFillHandle, DataGridMove, DataGridRow, DataTable, DataTableBody, DataTableCell, DataTableColumnResize, DataTableEmptyBody, DataTableHeader, DataTablePagination, DataTableRoot, DataTableRow, DataTableSearchFilter, DataTableSkeleton, DataTableToolbarSection, GridAsyncComboboxCell, GridComboboxCell, GridNumberCell, GridTextCell } from "./data-table/index.js"
21
+ export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from "./dialog.js"
22
22
  export { Dock } from "./dock.js"
23
23
  export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerSwipeHandle, DrawerTitle, DrawerTrigger } from "./drawer.js"
24
24
  export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./dropdown-menu.js"
@@ -52,6 +52,7 @@ export { Toaster } from "./sonner.js"
52
52
  export { Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay } from "./sortable.js"
53
53
  export { SwipeAction, SwipeActions, SwipeContent, SwipeItem, SwipeRoot } from "./swipe-actions.js"
54
54
  export { Switch } from "./switch.js"
55
+ export { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs.js"
55
56
  export { Textarea } from "./textarea.js"
56
57
  export { ThemeToggle } from "./theme-toggle.js"
57
58
  export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js"
@@ -0,0 +1,696 @@
1
+ "use client";
2
+
3
+ // src/lib/ease.ts
4
+ var EASE_OUT = [0.16, 1, 0.3, 1];
5
+ var SPRING_SWAP = {
6
+ type: "spring",
7
+ stiffness: 460,
8
+ damping: 30,
9
+ mass: 0.55
10
+ };
11
+
12
+ // src/ui/tabs.tsx
13
+ import { cn } from "cn";
14
+ import { ChevronLeft, ChevronRight } from "lucide-react";
15
+ import {
16
+ cancelFrame,
17
+ frame,
18
+ motion,
19
+ MotionConfig,
20
+ useReducedMotion,
21
+ useSpring
22
+ } from "motion/react";
23
+ import {
24
+ createContext,
25
+ useCallback,
26
+ useContext,
27
+ useId,
28
+ useLayoutEffect,
29
+ useMemo,
30
+ useRef,
31
+ useState
32
+ } from "react";
33
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
34
+ import { createElement } from "react";
35
+ var TabsCtx = createContext(null);
36
+ function useTabs() {
37
+ const ctx = useContext(TabsCtx);
38
+ if (!ctx) throw new Error("Tabs.* must be used inside <Tabs>");
39
+ return ctx;
40
+ }
41
+ var transition = {
42
+ type: "spring",
43
+ stiffness: 245,
44
+ damping: 36,
45
+ mass: 1.2
46
+ };
47
+ function Tabs({
48
+ defaultValue,
49
+ value,
50
+ onValueChange,
51
+ variant = "pill",
52
+ icons = "always",
53
+ children,
54
+ className
55
+ }) {
56
+ const [internal, setInternal] = useState(defaultValue ?? "");
57
+ const layoutId = useId();
58
+ const reduce = useReducedMotion();
59
+ const controlled = value !== void 0;
60
+ const current = controlled ? value : internal;
61
+ const setValue = useCallback(
62
+ (v) => {
63
+ if (!controlled) setInternal(v);
64
+ onValueChange?.(v);
65
+ },
66
+ [controlled, onValueChange]
67
+ );
68
+ const x = useSpring(0, transition);
69
+ const y = useSpring(0, transition);
70
+ const width = useSpring(0, transition);
71
+ const height = useSpring(0, transition);
72
+ const track = useMemo(() => ({ x, y, width, height }), [x, y, width, height]);
73
+ const [placed, setPlaced] = useState(false);
74
+ const [tabs, setTabs] = useState(/* @__PURE__ */ new Map());
75
+ const registerTab = useCallback((tab, disabled) => {
76
+ setTabs(
77
+ (map) => map.get(tab) === disabled ? map : new Map(map).set(tab, disabled)
78
+ );
79
+ }, []);
80
+ const unregisterTab = useCallback((tab) => {
81
+ setTabs((map) => {
82
+ if (!map.has(tab)) return map;
83
+ const next = new Map(map);
84
+ next.delete(tab);
85
+ return next;
86
+ });
87
+ }, []);
88
+ const [panels, setPanels] = useState(/* @__PURE__ */ new Set());
89
+ const registerPanel = useCallback((panel) => {
90
+ setPanels((set) => set.has(panel) ? set : new Set(set).add(panel));
91
+ }, []);
92
+ const unregisterPanel = useCallback((panel) => {
93
+ setPanels((set) => {
94
+ if (!set.has(panel)) return set;
95
+ const next = new Set(set);
96
+ next.delete(panel);
97
+ return next;
98
+ });
99
+ }, []);
100
+ let tabStop = null;
101
+ if (tabs.size > 0) {
102
+ const enabled = Array.from(tabs).filter(([, disabled]) => !disabled);
103
+ tabStop = enabled.some(([tab]) => tab === current) ? current : enabled[0]?.[0] ?? "";
104
+ }
105
+ const baseId = useId();
106
+ const tabId = useCallback(
107
+ (tab) => `${baseId}-tab-${tab.replace(/[^\w-]/g, "_")}`,
108
+ [baseId]
109
+ );
110
+ const panelId = useCallback(
111
+ (tab) => `${baseId}-panel-${tab.replace(/[^\w-]/g, "_")}`,
112
+ [baseId]
113
+ );
114
+ const contextValue = useMemo(
115
+ () => ({
116
+ value: current,
117
+ setValue,
118
+ layoutId,
119
+ variant,
120
+ icons,
121
+ track,
122
+ placed,
123
+ setPlaced,
124
+ tabStop,
125
+ registerTab,
126
+ unregisterTab,
127
+ panels,
128
+ registerPanel,
129
+ unregisterPanel,
130
+ tabId,
131
+ panelId
132
+ }),
133
+ [
134
+ current,
135
+ icons,
136
+ layoutId,
137
+ setValue,
138
+ variant,
139
+ track,
140
+ placed,
141
+ tabStop,
142
+ registerTab,
143
+ unregisterTab,
144
+ panels,
145
+ registerPanel,
146
+ unregisterPanel,
147
+ tabId,
148
+ panelId
149
+ ]
150
+ );
151
+ return /* @__PURE__ */ jsx(MotionConfig, { transition: reduce ? { duration: 0 } : transition, children: /* @__PURE__ */ jsx(TabsCtx.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(motion.div, { layoutRoot: true, className, children }) }) });
152
+ }
153
+ var listClasses = {
154
+ pill: "inline-flex items-center gap-1 rounded-full bg-card p-1",
155
+ underline: "inline-flex items-center gap-1 border-b border-border",
156
+ segment: "inline-flex items-center gap-0 rounded-lg bg-card p-0.5"
157
+ };
158
+ function TabsList({
159
+ children,
160
+ className,
161
+ wrapperClassName,
162
+ onKeyDown,
163
+ ...props
164
+ }) {
165
+ const { variant, value, icons, track, placed, setPlaced } = useTabs();
166
+ const reduce = useReducedMotion();
167
+ const tracked = icons === "selected" && variant !== "underline";
168
+ const rootRef = useRef(null);
169
+ const viewportRef = useRef(null);
170
+ const listRef = useRef(null);
171
+ const viewportId = useId();
172
+ const [edges, setEdges] = useState({
173
+ overflow: false,
174
+ left: false,
175
+ right: false
176
+ });
177
+ const measure = useCallback(() => {
178
+ const root = rootRef.current;
179
+ const viewport = viewportRef.current;
180
+ if (!root || !viewport) return;
181
+ const overflow = viewport.scrollWidth > root.clientWidth + 1;
182
+ const max = Math.max(0, viewport.scrollWidth - viewport.clientWidth);
183
+ const rtl = getComputedStyle(viewport).direction === "rtl";
184
+ const fromLeft = Math.max(
185
+ 0,
186
+ Math.min(max, rtl ? max + viewport.scrollLeft : viewport.scrollLeft)
187
+ );
188
+ const next = { overflow, left: fromLeft > 1, right: fromLeft < max - 1 };
189
+ setEdges(
190
+ (previous) => previous.overflow === next.overflow && previous.left === next.left && previous.right === next.right ? previous : next
191
+ );
192
+ }, []);
193
+ const reveal = useCallback(
194
+ (tab) => {
195
+ const viewport = viewportRef.current;
196
+ if (!viewport || !tab) return;
197
+ const frame2 = viewport.getBoundingClientRect();
198
+ const item = tab.getBoundingClientRect();
199
+ const max = Math.max(0, viewport.scrollWidth - viewport.clientWidth);
200
+ const rtl = getComputedStyle(viewport).direction === "rtl";
201
+ const fromLeft = Math.max(
202
+ 0,
203
+ Math.min(max, rtl ? max + viewport.scrollLeft : viewport.scrollLeft)
204
+ );
205
+ const left = frame2.left + (fromLeft > 1 ? 36 : 0);
206
+ const right = frame2.right - (fromLeft < max - 1 ? 36 : 0);
207
+ const delta = item.left < left ? item.left - left : item.right > right ? item.right - right : 0;
208
+ if (delta)
209
+ viewport.scrollBy({
210
+ left: delta,
211
+ behavior: reduce ? "instant" : "smooth"
212
+ });
213
+ },
214
+ [reduce]
215
+ );
216
+ useLayoutEffect(() => {
217
+ const root = rootRef.current;
218
+ const viewport = viewportRef.current;
219
+ const list = listRef.current;
220
+ if (!root || !viewport || !list) return;
221
+ const update = () => {
222
+ measure();
223
+ reveal(
224
+ list.querySelector('[role="tab"][aria-selected="true"]')
225
+ );
226
+ };
227
+ const observer = new ResizeObserver(update);
228
+ observer.observe(root);
229
+ observer.observe(viewport);
230
+ observer.observe(list);
231
+ viewport.addEventListener("scroll", measure, { passive: true });
232
+ update();
233
+ return () => {
234
+ observer.disconnect();
235
+ viewport.removeEventListener("scroll", measure);
236
+ };
237
+ }, [measure, reveal]);
238
+ useLayoutEffect(() => {
239
+ void children;
240
+ void value;
241
+ void edges.overflow;
242
+ measure();
243
+ reveal(
244
+ listRef.current?.querySelector(
245
+ '[role="tab"][aria-selected="true"]'
246
+ ) ?? null
247
+ );
248
+ }, [children, value, edges.overflow, measure, reveal]);
249
+ useLayoutEffect(() => {
250
+ if (!tracked) return;
251
+ const list = listRef.current;
252
+ if (!list) return;
253
+ void children;
254
+ const place = () => {
255
+ const tabs = Array.from(
256
+ list.querySelectorAll('[role="tab"]')
257
+ );
258
+ const target = tabs.find(
259
+ (tab) => tab.dataset.tabsValue === value
260
+ )?.parentElement;
261
+ if (!target) return;
262
+ const icons2 = Array.from(
263
+ list.querySelectorAll('[role="tab"] > [data-tabs-icon]')
264
+ );
265
+ const saved = icons2.map((icon) => [
266
+ icon.style.width,
267
+ icon.style.marginRight
268
+ ]);
269
+ for (const icon of icons2) {
270
+ const open = icon.parentElement?.parentElement === target;
271
+ icon.style.width = open ? "auto" : "0px";
272
+ icon.style.marginRight = open ? `${ICON_GAP}px` : "0px";
273
+ }
274
+ const box = {
275
+ x: target.offsetLeft,
276
+ y: target.offsetTop,
277
+ // Fractional: a rounded width leaves the pill a hair off its tab.
278
+ width: target.getBoundingClientRect().width,
279
+ height: target.offsetHeight
280
+ };
281
+ icons2.forEach((icon, index) => {
282
+ ;
283
+ [icon.style.width, icon.style.marginRight] = saved[index];
284
+ });
285
+ const instant = reduce || track.width.get() === 0;
286
+ for (const key of ["x", "y", "width", "height"]) {
287
+ if (instant) track[key].jump(box[key]);
288
+ else track[key].set(box[key]);
289
+ }
290
+ if (box.width > 0) setPlaced(true);
291
+ };
292
+ place();
293
+ const observer = new ResizeObserver(place);
294
+ for (const tab of list.querySelectorAll('[role="tab"]'))
295
+ if (tab.parentElement) observer.observe(tab.parentElement);
296
+ return () => observer.disconnect();
297
+ }, [tracked, value, children, reduce, track, setPlaced]);
298
+ useLayoutEffect(() => {
299
+ if (variant === "underline") return;
300
+ const list = listRef.current;
301
+ if (!list) return;
302
+ void children;
303
+ void placed;
304
+ const labels = Array.from(
305
+ list.querySelectorAll("[data-tabs-label]")
306
+ );
307
+ const indicator = list.querySelector("[data-tabs-indicator]");
308
+ const target = list.querySelector(
309
+ '[role="tab"][aria-selected="true"]'
310
+ );
311
+ if (!indicator || !target || target.dataset.tabsValue !== value) {
312
+ for (const label of labels) label.style.clipPath = "inset(0 100% 0 0)";
313
+ return;
314
+ }
315
+ let frames = 0;
316
+ let stillFrames = 0;
317
+ let previous;
318
+ const syncClips = () => {
319
+ const pill = (reduce ? target : indicator).getBoundingClientRect();
320
+ const clips = labels.map((label) => {
321
+ const bounds = label.getBoundingClientRect();
322
+ const left = Math.max(
323
+ 0,
324
+ Math.min(bounds.width, pill.left - bounds.left)
325
+ );
326
+ const right = Math.max(
327
+ 0,
328
+ Math.min(bounds.width, bounds.right - pill.right)
329
+ );
330
+ return left + right >= bounds.width ? "inset(0 100% 0 0)" : `inset(0 ${right}px 0 ${left}px)`;
331
+ });
332
+ labels.forEach((label, index) => {
333
+ if (label.style.clipPath !== clips[index])
334
+ label.style.clipPath = clips[index];
335
+ });
336
+ frames += 1;
337
+ stillFrames = previous && Math.abs(pill.left - previous.left) < 0.01 && Math.abs(pill.right - previous.right) < 0.01 ? stillFrames + 1 : 0;
338
+ previous = { left: pill.left, right: pill.right };
339
+ if (reduce || frames > 2 && stillFrames >= 2) cancelFrame(syncClips);
340
+ };
341
+ frame.postRender(syncClips, true);
342
+ const resync = () => {
343
+ frames = 0;
344
+ stillFrames = 0;
345
+ previous = void 0;
346
+ cancelFrame(syncClips);
347
+ frame.postRender(syncClips, true);
348
+ };
349
+ const observer = new ResizeObserver(resync);
350
+ observer.observe(list);
351
+ return () => {
352
+ observer.disconnect();
353
+ cancelFrame(syncClips);
354
+ };
355
+ }, [value, children, variant, reduce, placed]);
356
+ const onListKeyDown = (event) => {
357
+ onKeyDown?.(event);
358
+ if (event.defaultPrevented) return;
359
+ const list = listRef.current;
360
+ if (!list || !(event.target instanceof HTMLElement)) return;
361
+ const tabs = Array.from(
362
+ list.querySelectorAll('[role="tab"]')
363
+ ).filter((tab) => !tab.disabled && tab.closest('[role="tablist"]') === list);
364
+ const at = tabs.indexOf(event.target);
365
+ if (at < 0) return;
366
+ const rtl = getComputedStyle(list).direction === "rtl";
367
+ const forward = rtl ? "ArrowLeft" : "ArrowRight";
368
+ const back = rtl ? "ArrowRight" : "ArrowLeft";
369
+ const next = event.key === forward ? tabs[(at + 1) % tabs.length] : event.key === back ? tabs[(at - 1 + tabs.length) % tabs.length] : event.key === "Home" ? tabs[0] : event.key === "End" ? tabs[tabs.length - 1] : null;
370
+ if (!next) return;
371
+ event.preventDefault();
372
+ next.focus();
373
+ next.click();
374
+ };
375
+ const scroll = (direction) => {
376
+ const viewport = viewportRef.current;
377
+ if (viewport)
378
+ viewport.scrollBy({
379
+ left: direction * viewport.clientWidth * 0.8,
380
+ behavior: reduce ? "instant" : "smooth"
381
+ });
382
+ };
383
+ const controlClass = "absolute inset-y-0 z-20 inline-flex w-9 items-center justify-center text-foreground transition-opacity hover:opacity-70 focus-visible:outline-2 focus-visible:-outline-offset-4 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-0";
384
+ const surfaceClass = variant === "pill" ? "rounded-full bg-card" : variant === "segment" ? "rounded-lg bg-card" : "";
385
+ return /* @__PURE__ */ jsxs(
386
+ "div",
387
+ {
388
+ ref: rootRef,
389
+ className: cn(
390
+ "relative isolate flex w-full max-w-full min-w-0 items-center",
391
+ edges.overflow && surfaceClass,
392
+ wrapperClassName
393
+ ),
394
+ children: [
395
+ edges.overflow && /* @__PURE__ */ jsx(
396
+ "button",
397
+ {
398
+ type: "button",
399
+ "aria-label": "Scroll tabs left",
400
+ "aria-controls": viewportId,
401
+ disabled: !edges.left,
402
+ onClick: () => scroll(-1),
403
+ className: cn(controlClass, "left-0 rounded-l-full"),
404
+ children: /* @__PURE__ */ jsx(ChevronLeft, { size: 20, "aria-hidden": "true" })
405
+ }
406
+ ),
407
+ /* @__PURE__ */ jsx(
408
+ motion.div,
409
+ {
410
+ ref: viewportRef,
411
+ id: viewportId,
412
+ layoutScroll: true,
413
+ className: cn(
414
+ "w-full min-w-0 scrollbar-none overflow-x-auto [&::-webkit-scrollbar]:hidden",
415
+ edges.overflow && "rounded-[inherit]"
416
+ ),
417
+ style: edges.overflow ? {
418
+ maskImage: `linear-gradient(to right, ${edges.left ? "transparent, black 40px" : "black, black 0px"}, ${edges.right ? "black calc(100% - 40px), transparent" : "black 100%"})`
419
+ } : void 0,
420
+ onFocusCapture: (event) => {
421
+ if (event.target instanceof HTMLElement && event.target.getAttribute("role") === "tab")
422
+ reveal(event.target);
423
+ },
424
+ children: /* @__PURE__ */ jsx(
425
+ "div",
426
+ {
427
+ ...props,
428
+ ref: listRef,
429
+ role: "tablist",
430
+ onKeyDown: onListKeyDown,
431
+ className: cn(
432
+ listClasses[variant],
433
+ "w-max",
434
+ tracked && "relative",
435
+ className
436
+ ),
437
+ children
438
+ }
439
+ )
440
+ }
441
+ ),
442
+ edges.overflow && edges.left && /* @__PURE__ */ jsx(
443
+ "span",
444
+ {
445
+ "aria-hidden": "true",
446
+ className: "pointer-events-none absolute inset-y-0 left-0 z-10 w-10 rounded-l-[inherit] mask-[linear-gradient(to_right,black,transparent)] backdrop-blur-[2px]"
447
+ }
448
+ ),
449
+ edges.overflow && edges.right && /* @__PURE__ */ jsx(
450
+ "span",
451
+ {
452
+ "aria-hidden": "true",
453
+ className: "pointer-events-none absolute inset-y-0 right-0 z-10 w-10 rounded-r-[inherit] mask-[linear-gradient(to_left,black,transparent)] backdrop-blur-[2px]"
454
+ }
455
+ ),
456
+ edges.overflow && /* @__PURE__ */ jsx(
457
+ "button",
458
+ {
459
+ type: "button",
460
+ "aria-label": "Scroll tabs right",
461
+ "aria-controls": viewportId,
462
+ disabled: !edges.right,
463
+ onClick: () => scroll(1),
464
+ className: cn(controlClass, "right-0 rounded-r-full"),
465
+ children: /* @__PURE__ */ jsx(ChevronRight, { size: 20, "aria-hidden": "true" })
466
+ }
467
+ )
468
+ ]
469
+ }
470
+ );
471
+ }
472
+ var ICON_GAP = 6;
473
+ function TriggerIcon({ icon, active }) {
474
+ const { icons } = useTabs();
475
+ const reduce = useReducedMotion();
476
+ if (icons === "always") {
477
+ return /* @__PURE__ */ jsx(
478
+ "span",
479
+ {
480
+ "aria-hidden": "true",
481
+ className: "mr-1.5 inline-flex shrink-0 items-center",
482
+ children: icon
483
+ }
484
+ );
485
+ }
486
+ return /* @__PURE__ */ jsx(
487
+ motion.span,
488
+ {
489
+ "aria-hidden": "true",
490
+ "data-tabs-icon": "",
491
+ initial: false,
492
+ animate: {
493
+ width: active ? "auto" : 0,
494
+ marginRight: active ? ICON_GAP : 0,
495
+ opacity: active ? 1 : 0,
496
+ scale: active ? 1 : 0.6
497
+ },
498
+ transition: reduce ? { duration: 0 } : SPRING_SWAP,
499
+ className: "inline-flex shrink-0 items-center justify-center overflow-hidden",
500
+ children: icon
501
+ }
502
+ );
503
+ }
504
+ function TabsTrigger({
505
+ value,
506
+ icon,
507
+ children,
508
+ className,
509
+ indicatorClassName,
510
+ onClick,
511
+ ...props
512
+ }) {
513
+ const {
514
+ value: current,
515
+ setValue,
516
+ layoutId,
517
+ variant,
518
+ icons,
519
+ track,
520
+ placed,
521
+ tabStop,
522
+ registerTab,
523
+ unregisterTab,
524
+ panels,
525
+ tabId,
526
+ panelId
527
+ } = useTabs();
528
+ const active = current === value;
529
+ const disabled = Boolean(props.disabled);
530
+ useLayoutEffect(() => {
531
+ registerTab(value, disabled);
532
+ }, [registerTab, value, disabled]);
533
+ useLayoutEffect(() => () => unregisterTab(value), [unregisterTab, value]);
534
+ const a11y = {
535
+ id: tabId(value),
536
+ "aria-controls": panels.has(value) ? panelId(value) : void 0,
537
+ tabIndex: !disabled && (tabStop === null || tabStop === value) ? 0 : -1
538
+ };
539
+ const content = icon ? /* @__PURE__ */ jsxs(Fragment, { children: [
540
+ /* @__PURE__ */ jsx(TriggerIcon, { icon, active }),
541
+ children
542
+ ] }) : children;
543
+ const [initialClip] = useState(
544
+ () => active ? "inset(0)" : "inset(0 100% 0 0)"
545
+ );
546
+ if (variant === "underline") {
547
+ return /* @__PURE__ */ jsxs(
548
+ "button",
549
+ {
550
+ ...a11y,
551
+ ...props,
552
+ type: "button",
553
+ role: "tab",
554
+ "aria-selected": active,
555
+ onClick: (event) => {
556
+ onClick?.(event);
557
+ if (!event.defaultPrevented) setValue(value);
558
+ },
559
+ className: cn(
560
+ "relative isolate -mb-px inline-flex min-h-11 shrink-0 items-center px-3 pt-1 pb-2.5 text-sm font-medium whitespace-nowrap transition-colors",
561
+ active ? "text-foreground" : "text-muted-foreground hover:text-foreground",
562
+ className
563
+ ),
564
+ children: [
565
+ content,
566
+ active ? /* @__PURE__ */ jsx(
567
+ motion.span,
568
+ {
569
+ layoutId,
570
+ layout: true,
571
+ className: cn(
572
+ "absolute right-0 bottom-0 left-0 h-px bg-primary",
573
+ indicatorClassName
574
+ )
575
+ }
576
+ ) : null
577
+ ]
578
+ }
579
+ );
580
+ }
581
+ const radius = variant === "pill" ? "rounded-full" : "rounded-md";
582
+ const tracked = icons === "selected" && placed;
583
+ return /* @__PURE__ */ jsxs("div", { className: cn("shrink-0", !tracked && "relative"), children: [
584
+ active && tracked ? /* @__PURE__ */ jsx(
585
+ motion.span,
586
+ {
587
+ "data-tabs-indicator": "",
588
+ style: { ...track, borderRadius: variant === "pill" ? 9999 : 8 },
589
+ className: cn(
590
+ "absolute top-0 left-0 bg-primary",
591
+ radius,
592
+ indicatorClassName
593
+ )
594
+ },
595
+ "tracked"
596
+ ) : active ? /* @__PURE__ */ jsx(
597
+ motion.span,
598
+ {
599
+ "data-tabs-indicator": "",
600
+ layoutId,
601
+ layout: true,
602
+ style: { borderRadius: variant === "pill" ? 9999 : 8 },
603
+ className: cn(
604
+ "absolute inset-0 bg-primary",
605
+ radius,
606
+ indicatorClassName
607
+ )
608
+ },
609
+ "layout"
610
+ ) : null,
611
+ /* @__PURE__ */ jsxs(
612
+ "button",
613
+ {
614
+ ...a11y,
615
+ ...props,
616
+ type: "button",
617
+ role: "tab",
618
+ "aria-selected": active,
619
+ "data-tabs-value": value,
620
+ onClick: (event) => {
621
+ onClick?.(event);
622
+ if (!event.defaultPrevented) setValue(value);
623
+ },
624
+ className: cn(
625
+ "relative z-10 inline-flex items-center justify-center bg-transparent px-3.5 py-1.5 text-sm font-medium whitespace-nowrap outline-none",
626
+ "text-muted-foreground hover:text-foreground",
627
+ radius,
628
+ className
629
+ ),
630
+ children: [
631
+ content,
632
+ /* @__PURE__ */ jsx(
633
+ "span",
634
+ {
635
+ "data-tabs-label": "",
636
+ "aria-hidden": "true",
637
+ inert: true,
638
+ className: "pointer-events-none absolute inset-0 inline-flex items-center justify-center gap-[inherit] p-[inherit] text-primary-foreground",
639
+ style: { clipPath: initialClip },
640
+ children: content
641
+ }
642
+ )
643
+ ]
644
+ }
645
+ )
646
+ ] });
647
+ }
648
+ function TabsContent({
649
+ value,
650
+ children,
651
+ className
652
+ }) {
653
+ const {
654
+ value: current,
655
+ registerPanel,
656
+ unregisterPanel,
657
+ tabId,
658
+ panelId
659
+ } = useTabs();
660
+ const reduce = useReducedMotion();
661
+ const active = current === value;
662
+ useLayoutEffect(() => {
663
+ registerPanel(value);
664
+ return () => unregisterPanel(value);
665
+ }, [registerPanel, unregisterPanel, value]);
666
+ const a11y = {
667
+ id: panelId(value),
668
+ role: "tabpanel",
669
+ "aria-labelledby": tabId(value)
670
+ };
671
+ if (!active) {
672
+ return /* @__PURE__ */ jsx("div", { ...a11y, hidden: true, className, children });
673
+ }
674
+ return /* @__PURE__ */ createElement(
675
+ motion.div,
676
+ {
677
+ ...a11y,
678
+ tabIndex: 0,
679
+ key: value,
680
+ initial: { opacity: 0, y: reduce ? 0 : 4 },
681
+ animate: { opacity: 1, y: 0 },
682
+ transition: { duration: 0.18, ease: EASE_OUT },
683
+ className: cn(
684
+ "mt-4 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
685
+ className
686
+ )
687
+ },
688
+ children
689
+ );
690
+ }
691
+ export {
692
+ Tabs,
693
+ TabsContent,
694
+ TabsList,
695
+ TabsTrigger
696
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rockin",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "Reusable React UI components, hooks, icons, utilities, and styles for Rock Star projects.",
5
5
  "keywords": [
6
6
  "react",