@dinachi/cli 0.12.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -0
- package/dist/index.js +73 -7
- package/package.json +1 -1
- package/templates/accordion/accordion.tsx +70 -12
- package/templates/agent/agent.tsx +1865 -0
- package/templates/agent/index.ts +52 -0
- package/templates/alert-dialog/alert-dialog.tsx +59 -19
- package/templates/alert-dialog/index.ts +2 -0
- package/templates/animated-icon/animated-icon.tsx +1 -0
- package/templates/animated-list/animated-list.tsx +2 -1
- package/templates/animated-tabs/animated-tabs.tsx +69 -5
- package/templates/autocomplete/autocomplete.tsx +188 -21
- package/templates/avatar/avatar.tsx +3 -0
- package/templates/badge/badge.tsx +1 -0
- package/templates/button/button.tsx +1 -0
- package/templates/card/card.tsx +6 -1
- package/templates/carousel/carousel.tsx +109 -24
- package/templates/checkbox/checkbox.tsx +61 -4
- package/templates/checkbox-group/checkbox-group.tsx +83 -8
- package/templates/collapsible/collapsible.tsx +15 -4
- package/templates/combobox/combobox.tsx +312 -26
- package/templates/compare-slider/compare-slider.tsx +104 -28
- package/templates/compare-slider/index.ts +1 -1
- package/templates/context-menu/context-menu.tsx +93 -24
- package/templates/dialog/dialog.tsx +53 -14
- package/templates/drawer/drawer.tsx +36 -8
- package/templates/expandable-card/expandable-card.tsx +70 -43
- package/templates/field/field.tsx +7 -1
- package/templates/fieldset/fieldset.tsx +2 -0
- package/templates/form/form.tsx +1 -0
- package/templates/hold-to-confirm/hold-to-confirm.tsx +100 -16
- package/templates/hold-to-confirm/index.ts +1 -1
- package/templates/input/input.tsx +60 -1
- package/templates/label/label.tsx +1 -0
- package/templates/link/link.tsx +1 -0
- package/templates/load-transition/load-transition.tsx +1 -0
- package/templates/marquee/marquee.tsx +1 -0
- package/templates/menu/menu.tsx +45 -12
- package/templates/menubar/menubar.tsx +41 -11
- package/templates/meter/meter.tsx +5 -1
- package/templates/navigation-menu/navigation-menu.tsx +79 -24
- package/templates/number-field/index.ts +1 -0
- package/templates/number-field/number-field.tsx +77 -2
- package/templates/number-ticker/number-ticker.tsx +3 -0
- package/templates/otp-field/otp-field.tsx +61 -11
- package/templates/popover/popover.tsx +36 -7
- package/templates/preview-card/preview-card.tsx +27 -5
- package/templates/progress/progress.tsx +5 -1
- package/templates/progress-ring/progress-ring.tsx +1 -0
- package/templates/radio/radio.tsx +74 -6
- package/templates/scroll-area/scroll-area.tsx +14 -4
- package/templates/scroll-progress/scroll-progress.tsx +1 -0
- package/templates/scroll-reveal/scroll-reveal.tsx +1 -0
- package/templates/select/select.tsx +241 -12
- package/templates/separator/separator.tsx +1 -0
- package/templates/skeleton/skeleton.tsx +1 -0
- package/templates/slider/slider.tsx +84 -8
- package/templates/sortable/sortable.tsx +79 -9
- package/templates/stagger-list/stagger-list.tsx +2 -0
- package/templates/streaming-text/streaming-text.tsx +1 -0
- package/templates/swipeable-row/index.ts +1 -1
- package/templates/swipeable-row/swipeable-row.tsx +126 -41
- package/templates/switch/switch.tsx +43 -4
- package/templates/tabs/tabs.tsx +79 -10
- package/templates/text/text.tsx +1 -0
- package/templates/text-morph/text-morph.tsx +2 -0
- package/templates/text-shimmer/text-shimmer.tsx +1 -0
- package/templates/textarea/index.ts +1 -1
- package/templates/textarea/textarea.tsx +71 -4
- package/templates/toast/toast.tsx +13 -2
- package/templates/toggle/toggle.tsx +40 -7
- package/templates/toggle-group/toggle-group.tsx +98 -18
- package/templates/toolbar/toolbar.tsx +6 -0
- package/templates/tooltip/tooltip.tsx +9 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export {
|
|
2
|
+
AgentProvider,
|
|
3
|
+
createAgent,
|
|
4
|
+
createAgentChangeDetails,
|
|
5
|
+
isAgentChange,
|
|
6
|
+
useAgent,
|
|
7
|
+
useAgentControl,
|
|
8
|
+
useAgentState,
|
|
9
|
+
useAgentOpen,
|
|
10
|
+
useHasAgent,
|
|
11
|
+
useMergedRef,
|
|
12
|
+
waitForAgent,
|
|
13
|
+
registerTools,
|
|
14
|
+
agentToolsFor,
|
|
15
|
+
useAgentAction,
|
|
16
|
+
runAgentTool,
|
|
17
|
+
agentTools,
|
|
18
|
+
changeAsAgent,
|
|
19
|
+
matchAgentChoice,
|
|
20
|
+
sameAgentValue,
|
|
21
|
+
agentChecked,
|
|
22
|
+
agentNodeText,
|
|
23
|
+
agentChoicesOf,
|
|
24
|
+
agentRound,
|
|
25
|
+
useAgentItem,
|
|
26
|
+
useAgentLatest,
|
|
27
|
+
AgentGroupContext,
|
|
28
|
+
} from "./agent"
|
|
29
|
+
export type {
|
|
30
|
+
Agent,
|
|
31
|
+
AgentAction,
|
|
32
|
+
AgentActionDefinition,
|
|
33
|
+
AgentActionInfo,
|
|
34
|
+
AgentApproval,
|
|
35
|
+
AgentChoice,
|
|
36
|
+
AgentGroup,
|
|
37
|
+
AgentItems,
|
|
38
|
+
AgentOpenParts,
|
|
39
|
+
AgentActResult,
|
|
40
|
+
AgentAllow,
|
|
41
|
+
AgentComponent,
|
|
42
|
+
AgentComponentKind,
|
|
43
|
+
AgentControl,
|
|
44
|
+
AgentOptions,
|
|
45
|
+
AgentQuery,
|
|
46
|
+
AgentStep,
|
|
47
|
+
AgentStepResult,
|
|
48
|
+
AgentToolName,
|
|
49
|
+
AgentToolDefinition,
|
|
50
|
+
AgentToolOptions,
|
|
51
|
+
RegisteredAction,
|
|
52
|
+
} from "./agent"
|
|
@@ -3,10 +3,30 @@
|
|
|
3
3
|
import * as React from "react"
|
|
4
4
|
import { AlertDialog as BaseAlertDialog } from "@base-ui/react/alert-dialog"
|
|
5
5
|
import { cn } from "@/lib/utils"
|
|
6
|
+
import { type AgentOpenParts, useAgentOpen, useHasAgent, useMergedRef } from "@/components/ui/agent"
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const AlertDialogAgentContext = React.createContext<AgentOpenParts | null>(null)
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base UI's root, holding its own open state so an agent can open and close it. A press
|
|
12
|
+
* inside needs a person's approval by default; closing it does not.
|
|
13
|
+
*/
|
|
14
|
+
function AlertDialog<Payload>({ open, defaultOpen, onOpenChange, ...props }: BaseAlertDialog.Root.Props<Payload>) {
|
|
15
|
+
const [state, change, parts] = useAgentOpen("dialog", open, defaultOpen, onOpenChange)
|
|
16
|
+
return (
|
|
17
|
+
<AlertDialogAgentContext.Provider value={useHasAgent() ? parts : null}>
|
|
18
|
+
<BaseAlertDialog.Root<Payload> {...props} open={state} onOpenChange={change} />
|
|
19
|
+
</AlertDialogAgentContext.Provider>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function AlertDialogTrigger<Payload>({ ref, ...props }: BaseAlertDialog.Trigger.Props<Payload> & React.RefAttributes<HTMLElement>) {
|
|
24
|
+
const parts = React.useContext(AlertDialogAgentContext)
|
|
25
|
+
return <BaseAlertDialog.Trigger<Payload> ref={useMergedRef(ref, parts?.trigger)} data-slot="alert-dialog-trigger" {...props} />
|
|
26
|
+
}
|
|
27
|
+
function AlertDialogPortal(props: React.ComponentProps<typeof BaseAlertDialog.Portal>) {
|
|
28
|
+
return <BaseAlertDialog.Portal data-slot="alert-dialog-portal" {...props} />
|
|
29
|
+
}
|
|
10
30
|
|
|
11
31
|
const AlertDialogBackdrop = React.forwardRef<
|
|
12
32
|
HTMLDivElement,
|
|
@@ -21,6 +41,7 @@ const AlertDialogBackdrop = React.forwardRef<
|
|
|
21
41
|
"data-[ending-style]:duration-[var(--motion-duration-fast,150ms)]",
|
|
22
42
|
className
|
|
23
43
|
)}
|
|
44
|
+
data-slot="alert-dialog-backdrop"
|
|
24
45
|
{...props}
|
|
25
46
|
/>
|
|
26
47
|
))
|
|
@@ -36,6 +57,7 @@ const AlertDialogViewport = React.forwardRef<
|
|
|
36
57
|
"fixed inset-0 z-50 flex items-center justify-center overflow-auto",
|
|
37
58
|
className
|
|
38
59
|
)}
|
|
60
|
+
data-slot="alert-dialog-viewport"
|
|
39
61
|
{...props}
|
|
40
62
|
/>
|
|
41
63
|
))
|
|
@@ -46,7 +68,7 @@ const AlertDialogPopup = React.forwardRef<
|
|
|
46
68
|
React.ComponentProps<typeof BaseAlertDialog.Popup>
|
|
47
69
|
>(({ className, ...props }, ref) => (
|
|
48
70
|
<BaseAlertDialog.Popup
|
|
49
|
-
ref={ref}
|
|
71
|
+
ref={useMergedRef(ref, React.useContext(AlertDialogAgentContext)?.popup)}
|
|
50
72
|
className={cn(
|
|
51
73
|
"w-[95%] max-w-lg gap-4 rounded-lg border bg-background p-6 shadow-lg",
|
|
52
74
|
// An alert dialog is not anchored to its trigger, so scaling from the centre is
|
|
@@ -60,6 +82,7 @@ const AlertDialogPopup = React.forwardRef<
|
|
|
60
82
|
"data-[ending-style]:duration-[var(--motion-duration-fast,150ms)]",
|
|
61
83
|
className
|
|
62
84
|
)}
|
|
85
|
+
data-slot="alert-dialog-popup"
|
|
63
86
|
{...props}
|
|
64
87
|
/>
|
|
65
88
|
))
|
|
@@ -72,6 +95,7 @@ const AlertDialogTitle = React.forwardRef<
|
|
|
72
95
|
<BaseAlertDialog.Title
|
|
73
96
|
ref={ref}
|
|
74
97
|
className={cn("text-lg font-medium leading-none tracking-tight", className)}
|
|
98
|
+
data-slot="alert-dialog-title"
|
|
75
99
|
{...props}
|
|
76
100
|
/>
|
|
77
101
|
))
|
|
@@ -84,6 +108,7 @@ const AlertDialogDescription = React.forwardRef<
|
|
|
84
108
|
<BaseAlertDialog.Description
|
|
85
109
|
ref={ref}
|
|
86
110
|
className={cn("text-sm text-muted-foreground", className)}
|
|
111
|
+
data-slot="alert-dialog-description"
|
|
87
112
|
{...props}
|
|
88
113
|
/>
|
|
89
114
|
))
|
|
@@ -92,15 +117,21 @@ AlertDialogDescription.displayName = "AlertDialogDescription"
|
|
|
92
117
|
const AlertDialogAction = React.forwardRef<
|
|
93
118
|
HTMLButtonElement,
|
|
94
119
|
React.ComponentProps<typeof BaseAlertDialog.Close>
|
|
95
|
-
>(({ className, ...props }, ref) => (
|
|
120
|
+
>(({ className, render, ...props }, ref) => (
|
|
96
121
|
<BaseAlertDialog.Close
|
|
97
122
|
ref={ref}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
123
|
+
render={render}
|
|
124
|
+
className={
|
|
125
|
+
render
|
|
126
|
+
? className
|
|
127
|
+
: cn(
|
|
128
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors",
|
|
129
|
+
"hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
130
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
131
|
+
className,
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
data-slot="alert-dialog-action"
|
|
104
135
|
{...props}
|
|
105
136
|
/>
|
|
106
137
|
))
|
|
@@ -109,15 +140,22 @@ AlertDialogAction.displayName = "AlertDialogAction"
|
|
|
109
140
|
const AlertDialogCancel = React.forwardRef<
|
|
110
141
|
HTMLButtonElement,
|
|
111
142
|
React.ComponentProps<typeof BaseAlertDialog.Close>
|
|
112
|
-
>(({ className, ...props }, ref) => (
|
|
143
|
+
>(({ className, render, ...props }, ref) => (
|
|
113
144
|
<BaseAlertDialog.Close
|
|
114
145
|
ref={ref}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
146
|
+
data-agent-confirm="none"
|
|
147
|
+
render={render}
|
|
148
|
+
className={
|
|
149
|
+
render
|
|
150
|
+
? className
|
|
151
|
+
: cn(
|
|
152
|
+
"inline-flex h-10 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors",
|
|
153
|
+
"hover:bg-accent hover:text-accent-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
154
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
155
|
+
className,
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
data-slot="alert-dialog-cancel"
|
|
121
159
|
{...props}
|
|
122
160
|
/>
|
|
123
161
|
))
|
|
@@ -132,6 +170,7 @@ const AlertDialogHeader = ({
|
|
|
132
170
|
"flex flex-col space-y-2 text-center sm:text-left",
|
|
133
171
|
className
|
|
134
172
|
)}
|
|
173
|
+
data-slot="alert-dialog-header"
|
|
135
174
|
{...props}
|
|
136
175
|
/>
|
|
137
176
|
)
|
|
@@ -146,6 +185,7 @@ const AlertDialogFooter = ({
|
|
|
146
185
|
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-1.5",
|
|
147
186
|
className
|
|
148
187
|
)}
|
|
188
|
+
data-slot="alert-dialog-footer"
|
|
149
189
|
{...props}
|
|
150
190
|
/>
|
|
151
191
|
)
|
|
@@ -158,7 +198,7 @@ const AlertDialogContent = React.forwardRef<
|
|
|
158
198
|
<AlertDialogPortal>
|
|
159
199
|
<AlertDialogBackdrop />
|
|
160
200
|
<AlertDialogViewport>
|
|
161
|
-
<AlertDialogPopup ref={ref} className={className} {...props}>
|
|
201
|
+
<AlertDialogPopup ref={ref} className={className} data-slot="alert-dialog-content" {...props}>
|
|
162
202
|
{children}
|
|
163
203
|
</AlertDialogPopup>
|
|
164
204
|
</AlertDialogViewport>
|
|
@@ -3,6 +3,7 @@ export {
|
|
|
3
3
|
AlertDialogTrigger,
|
|
4
4
|
AlertDialogPortal,
|
|
5
5
|
AlertDialogBackdrop,
|
|
6
|
+
AlertDialogViewport,
|
|
6
7
|
AlertDialogPopup,
|
|
7
8
|
AlertDialogTitle,
|
|
8
9
|
AlertDialogDescription,
|
|
@@ -10,4 +11,5 @@ export {
|
|
|
10
11
|
AlertDialogCancel,
|
|
11
12
|
AlertDialogHeader,
|
|
12
13
|
AlertDialogFooter,
|
|
14
|
+
AlertDialogContent,
|
|
13
15
|
} from "./alert-dialog";
|
|
@@ -118,6 +118,7 @@ const AnimatedIcon = React.forwardRef<HTMLSpanElement, AnimatedIconProps>(
|
|
|
118
118
|
// `flip` turns around an axis in the plane of the screen, which is a rotation you
|
|
119
119
|
// cannot see without a vanishing point. The others do not need one.
|
|
120
120
|
style={mode === "flip" ? { perspective: 400, ...style } : style}
|
|
121
|
+
data-slot="animated-icon"
|
|
121
122
|
{...props}
|
|
122
123
|
>
|
|
123
124
|
{/* `initial={false}` so the icon is simply present on first paint. An entrance on
|
|
@@ -85,7 +85,7 @@ const AnimatedList = React.forwardRef<HTMLUListElement, AnimatedListProps>(
|
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
87
|
<AnimatedListContext.Provider value={context}>
|
|
88
|
-
<ul ref={ref} className={cn("list-none", className)} {...props}>
|
|
88
|
+
<ul ref={ref} className={cn("list-none", className)} data-slot="animated-list" {...props}>
|
|
89
89
|
<AnimatePresence mode="popLayout" initial={false} custom={dismissed}>
|
|
90
90
|
{children}
|
|
91
91
|
</AnimatePresence>
|
|
@@ -149,6 +149,7 @@ const AnimatedListItem = React.forwardRef<HTMLLIElement, AnimatedListItemProps>(
|
|
|
149
149
|
// for a spring to settle.
|
|
150
150
|
default: { duration: reducedMotion ? 0.2 : duration, ease: EASE_OUT },
|
|
151
151
|
}}
|
|
152
|
+
data-slot="animated-list-item"
|
|
152
153
|
{...props}
|
|
153
154
|
>
|
|
154
155
|
{children}
|
|
@@ -9,6 +9,16 @@ import {
|
|
|
9
9
|
type Transition,
|
|
10
10
|
} from "motion/react"
|
|
11
11
|
import { cn } from "@/lib/utils"
|
|
12
|
+
import {
|
|
13
|
+
agentChoicesOf,
|
|
14
|
+
changeAsAgent,
|
|
15
|
+
matchAgentChoice,
|
|
16
|
+
useAgentControl,
|
|
17
|
+
useAgentItem,
|
|
18
|
+
useHasAgent,
|
|
19
|
+
useMergedRef,
|
|
20
|
+
type AgentItems,
|
|
21
|
+
} from "@/components/ui/agent"
|
|
12
22
|
|
|
13
23
|
/** `useReducedMotion` reads the OS setting only, and only at mount. Also honour an
|
|
14
24
|
* app-level `<MotionConfig reducedMotion>`, so a user preference in the host app
|
|
@@ -51,6 +61,46 @@ interface AnimatedTabsContextValue {
|
|
|
51
61
|
value: unknown
|
|
52
62
|
layoutId: string
|
|
53
63
|
transition: Transition
|
|
64
|
+
/** Set inside an `AgentProvider`: the triggers, which the agent selects by name. */
|
|
65
|
+
items: AgentItems | null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type Details = BaseTabs.Root.ChangeEventDetails
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The agent clicks the tab, so Base UI decides as it does for a person. Returns a reader
|
|
72
|
+
* for the agent's details, which the change handler takes in place of Base UI's.
|
|
73
|
+
*/
|
|
74
|
+
function useTabsAgent(items: AgentItems, element: React.RefObject<HTMLElement | null>) {
|
|
75
|
+
const pending = React.useRef<Details | null>(null)
|
|
76
|
+
useAgentControl(() => {
|
|
77
|
+
const choices = agentChoicesOf(items)
|
|
78
|
+
const tabs = [...items]
|
|
79
|
+
const active = tabs.find(([el]) => el.getAttribute("aria-selected") === "true")?.[1]
|
|
80
|
+
return {
|
|
81
|
+
kind: "tabs",
|
|
82
|
+
element: choices.length ? element.current : null,
|
|
83
|
+
value: choices.find((c) => c.value === active)?.label ?? "",
|
|
84
|
+
items: choices.map((c) => c.label),
|
|
85
|
+
disabled: choices.length > 0 && choices.every((c) => c.disabled),
|
|
86
|
+
actions: {
|
|
87
|
+
select(wanted: unknown) {
|
|
88
|
+
const match = matchAgentChoice(choices, wanted)
|
|
89
|
+
if (typeof match === "string") return match
|
|
90
|
+
return changeAsAgent<unknown, Details>((_, details) => {
|
|
91
|
+
pending.current = details
|
|
92
|
+
tabs.find(([, v]) => v === match.value)?.[0].click()
|
|
93
|
+
pending.current = null
|
|
94
|
+
}, match.value)
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
return React.useCallback(() => {
|
|
100
|
+
const details = pending.current
|
|
101
|
+
pending.current = null
|
|
102
|
+
return details
|
|
103
|
+
}, [])
|
|
54
104
|
}
|
|
55
105
|
|
|
56
106
|
const AnimatedTabsContext = React.createContext<AnimatedTabsContextValue | null>(
|
|
@@ -103,18 +153,24 @@ const AnimatedTabs = React.forwardRef<
|
|
|
103
153
|
const isControlled = valueProp !== undefined
|
|
104
154
|
const value = isControlled ? valueProp : internalValue
|
|
105
155
|
const reducedMotion = useReducedMotionConfig()
|
|
156
|
+
const element = React.useRef<HTMLDivElement | null>(null)
|
|
157
|
+
const [agentItems] = React.useState<AgentItems>(() => new Map())
|
|
158
|
+
const items = useHasAgent() ? agentItems : null
|
|
159
|
+
const takeAgentDetails = useTabsAgent(agentItems, element)
|
|
106
160
|
|
|
107
161
|
const handleValueChange = React.useCallback<
|
|
108
162
|
NonNullable<BaseRootProps["onValueChange"]>
|
|
109
163
|
>(
|
|
110
164
|
(next, eventDetails) => {
|
|
165
|
+
const details = takeAgentDetails() ?? eventDetails
|
|
166
|
+
onValueChange?.(next, details)
|
|
167
|
+
if (details.isCanceled) return eventDetails.cancel()
|
|
111
168
|
// Batched with the value change, so the render that moves the pill is
|
|
112
169
|
// already the one that knows whether it should move at all.
|
|
113
170
|
setInstant(isKeyboardActivation(eventDetails?.event))
|
|
114
171
|
if (!isControlled) setInternalValue(next)
|
|
115
|
-
onValueChange?.(next, eventDetails)
|
|
116
172
|
},
|
|
117
|
-
[isControlled, onValueChange]
|
|
173
|
+
[isControlled, onValueChange, takeAgentDetails]
|
|
118
174
|
)
|
|
119
175
|
|
|
120
176
|
const contextValue = React.useMemo<AnimatedTabsContextValue>(
|
|
@@ -122,18 +178,20 @@ const AnimatedTabs = React.forwardRef<
|
|
|
122
178
|
value,
|
|
123
179
|
layoutId,
|
|
124
180
|
transition: reducedMotion || instant ? INSTANT_TRANSITION : transition,
|
|
181
|
+
items,
|
|
125
182
|
}),
|
|
126
|
-
[value, layoutId, transition, reducedMotion, instant]
|
|
183
|
+
[value, layoutId, transition, reducedMotion, instant, items]
|
|
127
184
|
)
|
|
128
185
|
|
|
129
186
|
return (
|
|
130
187
|
<AnimatedTabsContext.Provider value={contextValue}>
|
|
131
188
|
<BaseTabs.Root
|
|
132
|
-
ref={ref}
|
|
189
|
+
ref={useMergedRef(ref, element)}
|
|
133
190
|
value={value}
|
|
134
191
|
defaultValue={defaultValue}
|
|
135
192
|
onValueChange={handleValueChange}
|
|
136
193
|
className={cn("w-full", className)}
|
|
194
|
+
data-slot="animated-tabs"
|
|
137
195
|
{...props}
|
|
138
196
|
>
|
|
139
197
|
{children}
|
|
@@ -156,6 +214,7 @@ const AnimatedTabsList = React.forwardRef<
|
|
|
156
214
|
"relative inline-flex items-center gap-0.5 rounded-full bg-muted p-1",
|
|
157
215
|
className
|
|
158
216
|
)}
|
|
217
|
+
data-slot="animated-tabs-list"
|
|
159
218
|
{...props}
|
|
160
219
|
/>
|
|
161
220
|
))
|
|
@@ -173,10 +232,13 @@ const AnimatedTabsTrigger = React.forwardRef<
|
|
|
173
232
|
>(({ className, indicatorClassName, children, value, ...props }, ref) => {
|
|
174
233
|
const context = useAnimatedTabsContext("AnimatedTabsTrigger")
|
|
175
234
|
const isActive = context.value === value
|
|
235
|
+
const element = React.useRef<HTMLButtonElement | null>(null)
|
|
236
|
+
useAgentItem(context.items, element, value)
|
|
176
237
|
|
|
177
238
|
return (
|
|
178
239
|
<BaseTabs.Tab
|
|
179
|
-
ref={ref}
|
|
240
|
+
ref={useMergedRef(ref, element)}
|
|
241
|
+
data-agent-part={context.items ? "" : undefined}
|
|
180
242
|
value={value}
|
|
181
243
|
className={cn(
|
|
182
244
|
"relative isolate inline-flex select-none items-center justify-center whitespace-nowrap",
|
|
@@ -192,6 +254,7 @@ const AnimatedTabsTrigger = React.forwardRef<
|
|
|
192
254
|
"[&:not([data-active])]:hover:text-foreground",
|
|
193
255
|
className
|
|
194
256
|
)}
|
|
257
|
+
data-slot="animated-tabs-trigger"
|
|
195
258
|
{...props}
|
|
196
259
|
>
|
|
197
260
|
{isActive && (
|
|
@@ -229,6 +292,7 @@ const AnimatedTabsContent = React.forwardRef<
|
|
|
229
292
|
"mt-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
230
293
|
className
|
|
231
294
|
)}
|
|
295
|
+
data-slot="animated-tabs-content"
|
|
232
296
|
{...props}
|
|
233
297
|
>
|
|
234
298
|
{children}
|