@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/dist/index.js +73 -7
  3. package/package.json +1 -1
  4. package/templates/accordion/accordion.tsx +70 -12
  5. package/templates/agent/agent.tsx +1865 -0
  6. package/templates/agent/index.ts +52 -0
  7. package/templates/alert-dialog/alert-dialog.tsx +59 -19
  8. package/templates/alert-dialog/index.ts +2 -0
  9. package/templates/animated-icon/animated-icon.tsx +1 -0
  10. package/templates/animated-list/animated-list.tsx +2 -1
  11. package/templates/animated-tabs/animated-tabs.tsx +69 -5
  12. package/templates/autocomplete/autocomplete.tsx +188 -21
  13. package/templates/avatar/avatar.tsx +3 -0
  14. package/templates/badge/badge.tsx +1 -0
  15. package/templates/button/button.tsx +1 -0
  16. package/templates/card/card.tsx +6 -1
  17. package/templates/carousel/carousel.tsx +109 -24
  18. package/templates/checkbox/checkbox.tsx +61 -4
  19. package/templates/checkbox-group/checkbox-group.tsx +83 -8
  20. package/templates/collapsible/collapsible.tsx +15 -4
  21. package/templates/combobox/combobox.tsx +312 -26
  22. package/templates/compare-slider/compare-slider.tsx +104 -28
  23. package/templates/compare-slider/index.ts +1 -1
  24. package/templates/context-menu/context-menu.tsx +93 -24
  25. package/templates/dialog/dialog.tsx +53 -14
  26. package/templates/drawer/drawer.tsx +36 -8
  27. package/templates/expandable-card/expandable-card.tsx +70 -43
  28. package/templates/field/field.tsx +7 -1
  29. package/templates/fieldset/fieldset.tsx +2 -0
  30. package/templates/form/form.tsx +1 -0
  31. package/templates/hold-to-confirm/hold-to-confirm.tsx +100 -16
  32. package/templates/hold-to-confirm/index.ts +1 -1
  33. package/templates/input/input.tsx +60 -1
  34. package/templates/label/label.tsx +1 -0
  35. package/templates/link/link.tsx +1 -0
  36. package/templates/load-transition/load-transition.tsx +1 -0
  37. package/templates/marquee/marquee.tsx +1 -0
  38. package/templates/menu/menu.tsx +45 -12
  39. package/templates/menubar/menubar.tsx +41 -11
  40. package/templates/meter/meter.tsx +5 -1
  41. package/templates/navigation-menu/navigation-menu.tsx +79 -24
  42. package/templates/number-field/index.ts +1 -0
  43. package/templates/number-field/number-field.tsx +77 -2
  44. package/templates/number-ticker/number-ticker.tsx +3 -0
  45. package/templates/otp-field/otp-field.tsx +61 -11
  46. package/templates/popover/popover.tsx +36 -7
  47. package/templates/preview-card/preview-card.tsx +27 -5
  48. package/templates/progress/progress.tsx +5 -1
  49. package/templates/progress-ring/progress-ring.tsx +1 -0
  50. package/templates/radio/radio.tsx +74 -6
  51. package/templates/scroll-area/scroll-area.tsx +14 -4
  52. package/templates/scroll-progress/scroll-progress.tsx +1 -0
  53. package/templates/scroll-reveal/scroll-reveal.tsx +1 -0
  54. package/templates/select/select.tsx +241 -12
  55. package/templates/separator/separator.tsx +1 -0
  56. package/templates/skeleton/skeleton.tsx +1 -0
  57. package/templates/slider/slider.tsx +84 -8
  58. package/templates/sortable/sortable.tsx +79 -9
  59. package/templates/stagger-list/stagger-list.tsx +2 -0
  60. package/templates/streaming-text/streaming-text.tsx +1 -0
  61. package/templates/swipeable-row/index.ts +1 -1
  62. package/templates/swipeable-row/swipeable-row.tsx +126 -41
  63. package/templates/switch/switch.tsx +43 -4
  64. package/templates/tabs/tabs.tsx +79 -10
  65. package/templates/text/text.tsx +1 -0
  66. package/templates/text-morph/text-morph.tsx +2 -0
  67. package/templates/text-shimmer/text-shimmer.tsx +1 -0
  68. package/templates/textarea/index.ts +1 -1
  69. package/templates/textarea/textarea.tsx +71 -4
  70. package/templates/toast/toast.tsx +13 -2
  71. package/templates/toggle/toggle.tsx +40 -7
  72. package/templates/toggle-group/toggle-group.tsx +98 -18
  73. package/templates/toolbar/toolbar.tsx +6 -0
  74. package/templates/tooltip/tooltip.tsx +9 -3
@@ -186,6 +186,7 @@ const TextMorph = React.forwardRef<HTMLSpanElement, TextMorphProps>(
186
186
  return (
187
187
  <motion.span
188
188
  ref={ref}
189
+ data-slot="text-morph"
189
190
  className={cn("relative inline-block", className)}
190
191
  {...props}
191
192
  >
@@ -210,6 +211,7 @@ const TextMorph = React.forwardRef<HTMLSpanElement, TextMorphProps>(
210
211
  return (
211
212
  <motion.span
212
213
  ref={ref}
214
+ data-slot="text-morph"
213
215
  layout
214
216
  transition={move}
215
217
  className={cn(
@@ -137,6 +137,7 @@ const TextShimmer = React.forwardRef<HTMLSpanElement, TextShimmerProps>(
137
137
  // as one. It also makes the decorative use of a shimmer feel as wrong in the
138
138
  // markup as it is on screen.
139
139
  role="status"
140
+ data-slot="text-shimmer"
140
141
  className={cn("inline-block", className)}
141
142
  style={{ ...shimmerStyle, ...style }}
142
143
  {...props}
@@ -1,2 +1,2 @@
1
1
  export { Textarea } from './textarea'
2
- export type { TextareaProps } from './textarea'
2
+ export type { TextareaChangeDetails, TextareaProps } from './textarea'
@@ -1,17 +1,84 @@
1
1
  import * as React from "react"
2
+ import { Input as BaseInput } from "@base-ui/react/input"
2
3
  import { cn } from "@/lib/utils"
4
+ import { createAgentChangeDetails, useAgentControl, useMergedRef } from "@/components/ui/agent"
3
5
 
4
- export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>
6
+ export interface TextareaChangeDetails {
7
+ reason: string
8
+ event: Event | undefined
9
+ isCanceled: boolean
10
+ cancel(): void
11
+ }
12
+
13
+ export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
14
+ /** Called with the new text on each edit, a person's or an agent's. An agent's can be canceled. */
15
+ onValueChange?: (value: string, details: TextareaChangeDetails) => void
16
+ }
17
+
18
+ function writeValue(textarea: HTMLTextAreaElement, value: string) {
19
+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")?.set?.call(textarea, value)
20
+ }
21
+
22
+ function personDetails(event: Event): TextareaChangeDetails {
23
+ const details = { reason: "none", event, isCanceled: false, cancel: () => void (details.isCanceled = true) }
24
+ return details
25
+ }
5
26
 
6
27
  const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
7
- ({ className, ...props }, ref) => {
28
+ ({ className, onValueChange, onChange, ...props }, ref) => {
29
+ const element = React.useRef<HTMLTextAreaElement>(null)
30
+ const mergedRef = useMergedRef(ref, element)
31
+
32
+ // Set while the agent's input event runs, as onValueChange has already heard of it.
33
+ const agentWrite = React.useRef(false)
34
+
35
+ const setValue = (value: string) => {
36
+ const textarea = element.current
37
+ if (!textarea) return "The textarea is not mounted."
38
+ if (textarea.readOnly) return "The textarea is read-only."
39
+ // The app may refuse first. Then a real input event, so onChange hears of it too.
40
+ if (onValueChange) {
41
+ const details = createAgentChangeDetails<TextareaChangeDetails>("none")
42
+ onValueChange(value, details)
43
+ if (details.isCanceled) return "The app refused the change."
44
+ }
45
+ agentWrite.current = true
46
+ try {
47
+ writeValue(textarea, value)
48
+ textarea.dispatchEvent(new Event("input", { bubbles: true }))
49
+ } finally {
50
+ agentWrite.current = false
51
+ }
52
+ }
53
+
54
+ useAgentControl(() => ({
55
+ kind: "textarea",
56
+ element: element.current,
57
+ value: element.current?.value,
58
+ actions: {
59
+ setValue: (value: string) => setValue(String(value ?? "")),
60
+ clear: () => setValue(""),
61
+ },
62
+ }))
63
+
64
+ const Control = BaseInput as unknown as React.ComponentType<React.ComponentProps<"textarea"> & { render: React.ReactElement }>
8
65
  return (
9
- <textarea
66
+ <Control
67
+ render={<textarea />}
10
68
  className={cn(
11
69
  "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
12
70
  className
13
71
  )}
14
- ref={ref}
72
+ ref={mergedRef}
73
+ onChange={
74
+ onValueChange
75
+ ? (event) => {
76
+ onChange?.(event)
77
+ if (!agentWrite.current) onValueChange(event.target.value, personDetails(event.nativeEvent))
78
+ }
79
+ : onChange
80
+ }
81
+ data-slot="textarea"
15
82
  {...props}
16
83
  />
17
84
  )
@@ -17,6 +17,7 @@ export type ToastViewportProps = React.ComponentProps<
17
17
  const ToastViewport = React.forwardRef<HTMLDivElement, ToastViewportProps>(
18
18
  ({ className, ...props }, ref) => (
19
19
  <BaseToast.Viewport
20
+ data-slot="toast-viewport"
20
21
  ref={ref}
21
22
  className={cn(
22
23
  "fixed z-10 top-auto right-4 bottom-4 mx-auto flex w-[250px] sm:right-8 sm:bottom-8 sm:w-[300px]",
@@ -100,6 +101,7 @@ export interface ToastProps
100
101
  const ToastRoot = React.forwardRef<HTMLDivElement, ToastProps>(
101
102
  ({ className, variant, ...props }, ref) => (
102
103
  <BaseToast.Root
104
+ data-slot="toast-root"
103
105
  ref={ref}
104
106
  className={cn(toastVariants({ variant }), className)}
105
107
  {...props}
@@ -114,6 +116,7 @@ const ToastTitle = React.forwardRef<
114
116
  React.ComponentProps<typeof BaseToast.Title>
115
117
  >(({ className, ...props }, ref) => (
116
118
  <BaseToast.Title
119
+ data-slot="toast-title"
117
120
  ref={ref}
118
121
  className={cn("text-[0.975rem] leading-5 font-medium", className)}
119
122
  {...props}
@@ -127,6 +130,7 @@ const ToastDescription = React.forwardRef<
127
130
  React.ComponentProps<typeof BaseToast.Description>
128
131
  >(({ className, ...props }, ref) => (
129
132
  <BaseToast.Description
133
+ data-slot="toast-description"
130
134
  ref={ref}
131
135
  className={cn("text-[0.925rem] leading-5 opacity-90", className)}
132
136
  {...props}
@@ -142,6 +146,7 @@ const ToastContent = React.forwardRef<
142
146
  React.ComponentProps<typeof BaseToast.Content>
143
147
  >(({ className, ...props }, ref) => (
144
148
  <BaseToast.Content
149
+ data-slot="toast-content"
145
150
  ref={ref}
146
151
  className={cn(
147
152
  "flex items-start gap-3 overflow-hidden pr-6 transition-opacity [transition-duration:250ms]",
@@ -160,6 +165,7 @@ const ToastAction = React.forwardRef<
160
165
  React.ComponentProps<typeof BaseToast.Action>
161
166
  >(({ className, ...props }, ref) => (
162
167
  <BaseToast.Action
168
+ data-slot="toast-action"
163
169
  ref={ref}
164
170
  className={cn(
165
171
  "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors",
@@ -178,8 +184,11 @@ const ToastClose = React.forwardRef<
178
184
  React.ComponentProps<typeof BaseToast.Close>
179
185
  >(({ className, children, ...props }, ref) => (
180
186
  <BaseToast.Close
187
+ data-slot="toast-close"
181
188
  ref={ref}
182
189
  aria-label="Close"
190
+ data-agent-dismiss=""
191
+ data-agent-part=""
183
192
  className={cn(
184
193
  "absolute top-2 right-2 flex h-5 w-5 items-center justify-center rounded border-none bg-transparent opacity-60 transition-opacity",
185
194
  "hover:opacity-100 focus:outline-none focus:ring-1 focus:ring-ring",
@@ -199,6 +208,7 @@ const ToastPositioner = React.forwardRef<
199
208
  React.ComponentProps<typeof BaseToast.Positioner>
200
209
  >(({ className, ...props }, ref) => (
201
210
  <BaseToast.Positioner
211
+ data-slot="toast-positioner"
202
212
  ref={ref}
203
213
  className={cn("z-50", className)}
204
214
  {...props}
@@ -212,6 +222,7 @@ const ToastArrow = React.forwardRef<
212
222
  React.ComponentProps<typeof BaseToast.Arrow>
213
223
  >(({ className, ...props }, ref) => (
214
224
  <BaseToast.Arrow
225
+ data-slot="toast-arrow"
215
226
  ref={ref}
216
227
  className={cn(
217
228
  "fill-background [stroke-width:1px] stroke-border",
@@ -279,7 +290,7 @@ function ToastList({ renderToast }: { renderToast?: RenderToastFn }) {
279
290
  <ToastDescription>{toast.description}</ToastDescription>
280
291
  )}
281
292
  </div>
282
- {toast.actionProps && <ToastAction {...toast.actionProps} />}
293
+ {toast.actionProps && <ToastAction />}
283
294
  <ToastClose />
284
295
  </ToastContent>
285
296
  )}
@@ -313,7 +324,7 @@ const Toast = React.forwardRef<HTMLDivElement, ToastComponentProps>(
313
324
  <ToastProvider limit={limit} timeout={timeout} toastManager={toastManager}>
314
325
  {children}
315
326
  <ToastPortal>
316
- <ToastViewport ref={ref} className={className} {...props}>
327
+ <ToastViewport data-slot="toast" ref={ref} className={className} {...props}>
317
328
  <ToastList renderToast={renderToast} />
318
329
  </ToastViewport>
319
330
  </ToastPortal>
@@ -4,6 +4,7 @@ import * as React from "react"
4
4
  import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
5
5
  import { type VariantProps, cva } from "class-variance-authority"
6
6
  import { cn } from "@/lib/utils"
7
+ import { agentChecked, changeAsAgent, useAgentControl, useAgentState, useMergedRef } from "@/components/ui/agent"
7
8
 
8
9
  const toggleVariants = cva(
9
10
  [
@@ -49,16 +50,48 @@ export interface ToggleProps
49
50
  extends React.ComponentPropsWithoutRef<typeof TogglePrimitive>,
50
51
  VariantProps<typeof toggleVariants> {}
51
52
 
53
+ /**
54
+ * Base UI's toggle, holding its own pressed state so an agent can press it the way a
55
+ * parent would. Controlled use is unchanged, and `onPressedChange` sees the agent's
56
+ * changes first and can cancel them. The agent reads pressed as `checked`.
57
+ */
52
58
  const Toggle = React.forwardRef<
53
59
  React.ComponentRef<typeof TogglePrimitive>,
54
60
  ToggleProps
55
- >(({ className, variant, size, ...props }, ref) => (
56
- <TogglePrimitive
57
- ref={ref}
58
- className={cn(toggleVariants({ variant, size }), className)}
59
- {...props}
60
- />
61
- ))
61
+ >(({ className, variant, size, pressed: pressedProp, defaultPressed = false, onPressedChange, ...props }, ref) => {
62
+ const [pressed, change] = useAgentState<boolean, TogglePrimitive.ChangeEventDetails>(
63
+ pressedProp,
64
+ defaultPressed,
65
+ onPressedChange
66
+ )
67
+ const element = React.useRef<HTMLButtonElement | null>(null)
68
+ const mergedRef = useMergedRef(ref, element)
69
+
70
+ useAgentControl(() => {
71
+ const set = (next: boolean) => (next === pressed ? undefined : changeAsAgent(change, next))
72
+ return {
73
+ kind: "toggle",
74
+ element: element.current,
75
+ checked: pressed,
76
+ disabled: props.disabled,
77
+ actions: {
78
+ toggle: () => set(!pressed),
79
+ setChecked: (value: unknown) => set(agentChecked(value)),
80
+ },
81
+ }
82
+ })
83
+
84
+ return (
85
+ <TogglePrimitive
86
+ ref={mergedRef}
87
+ data-slot="toggle"
88
+ className={cn(toggleVariants({ variant, size }), className)}
89
+ {...props}
90
+ pressed={pressed}
91
+ onPressedChange={change}
92
+ />
93
+ )
94
+ })
62
95
 
63
96
  Toggle.displayName = "Toggle"
64
97
 
@@ -5,6 +5,33 @@ import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group
5
5
  import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
6
6
  import { cva } from "class-variance-authority"
7
7
  import { cn } from "@/lib/utils"
8
+ import {
9
+ agentChoicesOf,
10
+ changeAsAgent,
11
+ matchAgentChoice,
12
+ sameAgentValue,
13
+ useAgentControl,
14
+ useAgentItem,
15
+ useAgentState,
16
+ useHasAgent,
17
+ useMergedRef,
18
+ type AgentChoice,
19
+ type AgentItems,
20
+ } from "@/components/ui/agent"
21
+
22
+ type ToggleItems = AgentItems<string>
23
+
24
+ const ToggleAgentContext = React.createContext<ToggleItems | null>(null)
25
+
26
+ function matchAll(choices: AgentChoice[], wanted: unknown): string[] | string {
27
+ const values: string[] = []
28
+ for (const one of Array.isArray(wanted) ? wanted : [wanted]) {
29
+ const match = matchAgentChoice(choices, one)
30
+ if (typeof match === "string") return match
31
+ values.push(match.value as string)
32
+ }
33
+ return values
34
+ }
8
35
 
9
36
  type ToggleGroupItemProps = React.ComponentPropsWithoutRef<typeof TogglePrimitive> & {
10
37
  variant?: "default" | "outline"
@@ -43,29 +70,82 @@ const toggleGroupItemVariants = cva(
43
70
  const ToggleGroup = React.forwardRef<
44
71
  React.ComponentRef<typeof ToggleGroupPrimitive>,
45
72
  React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive>
46
- >(({ className, ...props }, ref) => (
47
- <ToggleGroupPrimitive
48
- ref={ref}
49
- className={cn(
50
- "inline-flex items-center justify-center gap-1",
51
- "data-[orientation=vertical]:flex-col",
52
- className
53
- )}
54
- {...props}
55
- />
56
- ))
73
+ >(({ className, value: valueProp, defaultValue, onValueChange, ...props }, ref) => {
74
+ const [value, change] = useAgentState<readonly string[], ToggleGroupPrimitive.ChangeEventDetails>(
75
+ valueProp,
76
+ defaultValue ?? [],
77
+ onValueChange as ((value: readonly string[], details: ToggleGroupPrimitive.ChangeEventDetails) => void) | undefined
78
+ )
79
+ const element = React.useRef<HTMLDivElement | null>(null)
80
+ const mergedRef = useMergedRef(ref, element)
81
+ const [items] = React.useState<ToggleItems>(() => new Map())
82
+
83
+ const pick = (wanted: unknown, add: boolean) => {
84
+ const values = matchAll(agentChoicesOf(items), wanted)
85
+ if (typeof values === "string") return values
86
+ const fresh = values.filter((v) => !value.some((w) => sameAgentValue(v, w)))
87
+ if (!fresh.length && (add || values.length === value.length)) return undefined
88
+ return changeAsAgent(change, add ? [...value, ...fresh] : values)
89
+ }
90
+
91
+ const add = (wanted: unknown) => pick(wanted, true)
92
+ const replace = (wanted: unknown) => pick(wanted, false)
93
+ const actions: Record<string, typeof add> = props.multiple ? { select: add, setValue: replace } : { select: replace }
94
+
95
+ useAgentControl(() => {
96
+ const choices = agentChoicesOf(items)
97
+ const labels = value.map((v) => choices.find((c) => sameAgentValue(c.value, v))?.label ?? String(v))
98
+ return {
99
+ kind: "toggle-group",
100
+ element: choices.length ? element.current : null,
101
+ value: props.multiple ? labels : (labels[0] ?? ""),
102
+ items: choices.map((c) => c.label),
103
+ multiple: props.multiple || undefined,
104
+ disabled: props.disabled,
105
+ actions,
106
+ }
107
+ })
108
+
109
+ return (
110
+ <ToggleAgentContext.Provider value={useHasAgent() ? items : null}>
111
+ <ToggleGroupPrimitive
112
+ ref={mergedRef}
113
+ data-slot="toggle-group"
114
+ className={cn(
115
+ "inline-flex items-center justify-center gap-1",
116
+ "data-[orientation=vertical]:flex-col",
117
+ className
118
+ )}
119
+ {...props}
120
+ value={value}
121
+ onValueChange={change}
122
+ />
123
+ </ToggleAgentContext.Provider>
124
+ )
125
+ })
57
126
  ToggleGroup.displayName = "ToggleGroup"
58
127
 
59
128
  const ToggleGroupItem = React.forwardRef<
60
129
  React.ComponentRef<typeof TogglePrimitive>,
61
130
  ToggleGroupItemProps
62
- >(({ className, variant = "outline", size = "sm", ...props }, ref) => (
63
- <TogglePrimitive
64
- ref={ref}
65
- className={cn(toggleGroupItemVariants({ variant, size }), className)}
66
- {...props}
67
- />
68
- ))
131
+ >(({ className, variant = "outline", size = "sm", ...props }, ref) => {
132
+ const items = React.useContext(ToggleAgentContext)
133
+ const element = React.useRef<HTMLButtonElement | null>(null)
134
+ const mergedRef = useMergedRef(ref, element)
135
+ useAgentItem(items, element, props.value as string | undefined)
136
+
137
+ // Inside AgentProvider the group reports its items, so the buttons stay out of the
138
+ // snapshot rather than appearing twice.
139
+ return (
140
+ <TogglePrimitive
141
+ ref={mergedRef}
142
+ data-slot="toggle-group-item"
143
+ data-agent-part={items ? "" : undefined}
144
+ className={cn(toggleGroupItemVariants({ variant, size }), className)}
145
+ {...props}
146
+ />
147
+ )
148
+ })
69
149
  ToggleGroupItem.displayName = "ToggleGroupItem"
70
150
 
71
151
  export { ToggleGroup, ToggleGroupItem }
@@ -7,6 +7,7 @@ const ToolbarRoot = React.forwardRef<
7
7
  React.ComponentProps<typeof BaseToolbar.Root>
8
8
  >(({ className, ...props }, ref) => (
9
9
  <BaseToolbar.Root
10
+ data-slot="toolbar"
10
11
  ref={ref}
11
12
  className={cn(
12
13
  "flex flex-wrap items-center gap-1 rounded-md border bg-background p-1",
@@ -23,6 +24,7 @@ const ToolbarButton = React.forwardRef<
23
24
  React.ComponentProps<typeof BaseToolbar.Button>
24
25
  >(({ className, ...props }, ref) => (
25
26
  <BaseToolbar.Button
27
+ data-slot="toolbar-button"
26
28
  ref={ref}
27
29
  className={cn(
28
30
  "inline-flex shrink-0 items-center justify-center rounded-sm px-3 py-2 text-sm font-medium transition-colors",
@@ -42,6 +44,7 @@ const ToolbarLink = React.forwardRef<
42
44
  React.ComponentProps<typeof BaseToolbar.Link>
43
45
  >(({ className, ...props }, ref) => (
44
46
  <BaseToolbar.Link
47
+ data-slot="toolbar-link"
45
48
  ref={ref}
46
49
  className={cn(
47
50
  "inline-flex shrink-0 items-center justify-center rounded-sm px-3 py-2 text-sm font-medium transition-colors",
@@ -60,6 +63,7 @@ const ToolbarSeparator = React.forwardRef<
60
63
  React.ComponentProps<typeof BaseToolbar.Separator>
61
64
  >(({ className, orientation = "vertical", ...props }, ref) => (
62
65
  <BaseToolbar.Separator
66
+ data-slot="toolbar-separator"
63
67
  ref={ref}
64
68
  orientation={orientation}
65
69
  className={cn(
@@ -77,6 +81,7 @@ const ToolbarGroup = React.forwardRef<
77
81
  React.ComponentProps<typeof BaseToolbar.Group>
78
82
  >(({ className, ...props }, ref) => (
79
83
  <BaseToolbar.Group
84
+ data-slot="toolbar-group"
80
85
  ref={ref}
81
86
  className={cn("flex shrink-0 items-center gap-1", className)}
82
87
  {...props}
@@ -89,6 +94,7 @@ const ToolbarInput = React.forwardRef<
89
94
  React.ComponentProps<typeof BaseToolbar.Input>
90
95
  >(({ className, ...props }, ref) => (
91
96
  <BaseToolbar.Input
97
+ data-slot="toolbar-input"
92
98
  ref={ref}
93
99
  className={cn(
94
100
  "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors",
@@ -15,12 +15,14 @@ const TooltipTrigger = React.forwardRef<
15
15
  HTMLButtonElement,
16
16
  React.ComponentProps<typeof BaseTooltip.Trigger>
17
17
  >(({ className, ...props }, ref) => (
18
- <BaseTooltip.Trigger ref={ref} className={className} {...props} />
18
+ <BaseTooltip.Trigger ref={ref} className={className} data-slot="tooltip-trigger" {...props} />
19
19
  ));
20
20
  TooltipTrigger.displayName = "TooltipTrigger";
21
21
 
22
22
  // Portal Component
23
- const TooltipPortal: typeof BaseTooltip.Portal = BaseTooltip.Portal;
23
+ function TooltipPortal(props: React.ComponentProps<typeof BaseTooltip.Portal>): React.JSX.Element {
24
+ return <BaseTooltip.Portal data-slot="tooltip-portal" {...props} />;
25
+ }
24
26
 
25
27
  // Positioner Component
26
28
  const TooltipPositioner: React.ForwardRefExoticComponent<
@@ -34,6 +36,7 @@ const TooltipPositioner: React.ForwardRefExoticComponent<
34
36
  ref={ref}
35
37
  sideOffset={sideOffset}
36
38
  className={cn("z-50", className)}
39
+ data-slot="tooltip-positioner"
37
40
  {...props}
38
41
  />
39
42
  ));
@@ -73,6 +76,7 @@ const TooltipPopup: React.ForwardRefExoticComponent<
73
76
  variantStyles[variant],
74
77
  className
75
78
  )}
79
+ data-slot="tooltip-popup"
76
80
  {...props}
77
81
  />
78
82
  );
@@ -99,6 +103,7 @@ const TooltipArrow: React.ForwardRefExoticComponent<
99
103
  "data-[side=top]:bottom-[-8px] data-[side=top]:rotate-180",
100
104
  className
101
105
  )}
106
+ data-slot="tooltip-arrow"
102
107
  {...props}
103
108
  >
104
109
  {children || <TooltipArrowSvg variant={variant} />}
@@ -139,6 +144,7 @@ const TooltipContent: React.ForwardRefExoticComponent<
139
144
  ref={ref}
140
145
  className={className}
141
146
  variant={variant}
147
+ data-slot="tooltip-content"
142
148
  {...props}
143
149
  >
144
150
  {showArrow && <TooltipArrow variant={variant} />}
@@ -164,7 +170,7 @@ const TooltipArrowSvg: React.MemoExoticComponent<
164
170
  variant === "inverse" ? "fill-primary" : "fill-border";
165
171
 
166
172
  return (
167
- <svg width="20" height="10" viewBox="0 0 20 10" fill="none" {...props}>
173
+ <svg width="20" height="10" viewBox="0 0 20 10" fill="none" data-slot="tooltip-arrow-svg" {...props}>
168
174
  <path
169
175
  d="M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z"
170
176
  className={fillClasses}