@dinachi/cli 1.0.0 → 1.3.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 (105) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/index.js +244 -72
  3. package/package.json +5 -1
  4. package/templates/accordion/accordion.tsx +5 -1
  5. package/templates/agent/agent.tsx +35 -18
  6. package/templates/alert/alert.tsx +345 -0
  7. package/templates/alert/index.ts +16 -0
  8. package/templates/alert-dialog/alert-dialog.tsx +14 -3
  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 +4 -0
  12. package/templates/ask-bar/ask-bar.tsx +1061 -0
  13. package/templates/ask-bar/index.ts +1 -0
  14. package/templates/autocomplete/autocomplete.tsx +14 -4
  15. package/templates/avatar/avatar.tsx +3 -0
  16. package/templates/badge/badge.tsx +1 -0
  17. package/templates/breadcrumb/breadcrumb.tsx +606 -0
  18. package/templates/breadcrumb/index.ts +9 -0
  19. package/templates/button/button.tsx +1 -0
  20. package/templates/calendar/calendar.tsx +1155 -0
  21. package/templates/calendar/index.ts +15 -0
  22. package/templates/card/card.tsx +6 -1
  23. package/templates/carousel/carousel.tsx +7 -0
  24. package/templates/checkbox/checkbox.tsx +1 -0
  25. package/templates/checkbox-group/checkbox-group.tsx +1 -0
  26. package/templates/collapsible/collapsible.tsx +3 -1
  27. package/templates/combobox/combobox.tsx +15 -4
  28. package/templates/command-items/command-items.tsx +69 -0
  29. package/templates/command-items/index.ts +1 -0
  30. package/templates/command-palette/command-palette.tsx +954 -0
  31. package/templates/command-palette/index.ts +1 -0
  32. package/templates/compare-slider/compare-slider.tsx +1 -0
  33. package/templates/comparison-table/comparison-table.tsx +540 -0
  34. package/templates/comparison-table/index.ts +15 -0
  35. package/templates/context-menu/context-menu.tsx +61 -14
  36. package/templates/data-table/data-table.tsx +2077 -0
  37. package/templates/data-table/index.ts +14 -0
  38. package/templates/date-picker/date-picker.tsx +527 -0
  39. package/templates/date-picker/index.ts +2 -0
  40. package/templates/date-range-picker/date-range-picker.tsx +504 -0
  41. package/templates/date-range-picker/index.ts +2 -0
  42. package/templates/detail-list/detail-list.tsx +419 -0
  43. package/templates/detail-list/index.ts +12 -0
  44. package/templates/dialog/dialog.tsx +13 -3
  45. package/templates/drawer/drawer.tsx +19 -6
  46. package/templates/expandable-card/expandable-card.tsx +5 -1
  47. package/templates/field/field.tsx +5 -1
  48. package/templates/fieldset/fieldset.tsx +2 -0
  49. package/templates/form/form.tsx +1 -0
  50. package/templates/heat-table/heat-table.tsx +613 -0
  51. package/templates/heat-table/index.ts +9 -0
  52. package/templates/hold-to-confirm/hold-to-confirm.tsx +1 -0
  53. package/templates/input/input.tsx +1 -0
  54. package/templates/label/label.tsx +1 -0
  55. package/templates/link/link.tsx +1 -0
  56. package/templates/load-transition/load-transition.tsx +1 -0
  57. package/templates/marquee/marquee.tsx +1 -0
  58. package/templates/menu/menu.tsx +27 -6
  59. package/templates/menubar/menubar.tsx +15 -3
  60. package/templates/meter/meter.tsx +5 -1
  61. package/templates/month-picker/index.ts +1 -0
  62. package/templates/month-picker/month-picker.tsx +351 -0
  63. package/templates/navigation-menu/navigation-menu.tsx +13 -2
  64. package/templates/number-field/number-field.tsx +7 -1
  65. package/templates/number-ticker/number-ticker.tsx +3 -0
  66. package/templates/omnibar/index.ts +1 -0
  67. package/templates/omnibar/omnibar.tsx +1009 -0
  68. package/templates/otp-field/otp-field.tsx +4 -0
  69. package/templates/pagination/index.ts +8 -0
  70. package/templates/pagination/pagination.tsx +389 -0
  71. package/templates/popover/popover.tsx +19 -5
  72. package/templates/preview-card/preview-card.tsx +11 -3
  73. package/templates/progress/progress.tsx +5 -1
  74. package/templates/progress-ring/progress-ring.tsx +1 -0
  75. package/templates/radio/radio.tsx +3 -0
  76. package/templates/scroll-area/scroll-area.tsx +14 -4
  77. package/templates/scroll-progress/scroll-progress.tsx +1 -0
  78. package/templates/scroll-reveal/scroll-reveal.tsx +1 -0
  79. package/templates/select/select.tsx +18 -2
  80. package/templates/separator/separator.tsx +1 -0
  81. package/templates/skeleton/skeleton.tsx +1 -0
  82. package/templates/slider/slider.tsx +7 -0
  83. package/templates/sortable/sortable.tsx +3 -0
  84. package/templates/stagger-list/stagger-list.tsx +2 -0
  85. package/templates/streaming-text/streaming-text.tsx +1 -0
  86. package/templates/swipeable-row/swipeable-row.tsx +1 -0
  87. package/templates/switch/switch.tsx +2 -0
  88. package/templates/table/index.ts +13 -0
  89. package/templates/table/table.tsx +265 -0
  90. package/templates/tabs/tabs.tsx +5 -0
  91. package/templates/text/text.tsx +1 -0
  92. package/templates/text-morph/text-morph.tsx +2 -0
  93. package/templates/text-shimmer/text-shimmer.tsx +1 -0
  94. package/templates/textarea/textarea.tsx +1 -0
  95. package/templates/time-slots/index.ts +1 -0
  96. package/templates/time-slots/time-slots.tsx +589 -0
  97. package/templates/toast/toast.tsx +10 -1
  98. package/templates/toggle/toggle.tsx +1 -0
  99. package/templates/toggle-group/toggle-group.tsx +2 -0
  100. package/templates/toolbar/toolbar.tsx +6 -0
  101. package/templates/tooltip/tooltip.tsx +9 -3
  102. package/templates/week-strip/index.ts +1 -0
  103. package/templates/week-strip/week-strip.tsx +329 -0
  104. package/templates/year-view/index.ts +1 -0
  105. package/templates/year-view/year-view.tsx +362 -0
@@ -0,0 +1,419 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Check, Copy, Pencil } from "lucide-react"
5
+ import { cn } from "@/lib/utils"
6
+ import { changeAsAgent, useAgentControl, useAgentState, useHasAgent } from "@/components/ui/agent"
7
+ import { Button } from "@/components/ui/button"
8
+
9
+ export type DetailListLayout = "side" | "stacked"
10
+
11
+ export interface DetailListChangeDetails {
12
+ reason: string
13
+ event: Event | undefined
14
+ isCanceled: boolean
15
+ cancel(): void
16
+ }
17
+
18
+ /** What `renderEditor` gets: the draft, ways to change and save it, and props for the field. */
19
+ export interface DetailListEditorProps {
20
+ /** The draft, which starts as the saved value. */
21
+ value: string
22
+ setValue: (value: string) => void
23
+ /** Validates and saves the draft, or `value` when given, as the Save button does. */
24
+ save: (value?: string) => void
25
+ /** Closes the editor and drops the draft. */
26
+ cancel: () => void
27
+ /** Enter saves and Escape cancels, for a field that wants the list's keys. */
28
+ onKeyDown: (event: React.KeyboardEvent) => void
29
+ /** Spread on the field: focus, the row's name and the error. */
30
+ fieldProps: {
31
+ autoFocus: true
32
+ "aria-labelledby": string
33
+ "aria-invalid": true | undefined
34
+ "aria-describedby": string | undefined
35
+ "data-agent-part": "" | undefined
36
+ }
37
+ }
38
+
39
+ const LayoutContext = React.createContext<DetailListLayout>("side")
40
+
41
+ interface ItemContextValue {
42
+ termId: string
43
+ value: string
44
+ editing: boolean
45
+ setEditing: (editing: boolean) => void
46
+ save: (value: string, event?: Event) => string | undefined
47
+ copyable: boolean
48
+ editable: boolean
49
+ multiline: boolean
50
+ renderEditor?: (editor: DetailListEditorProps) => React.ReactNode
51
+ disabled: boolean
52
+ hasAgent: boolean
53
+ }
54
+
55
+ const ItemContext = React.createContext<ItemContextValue | null>(null)
56
+
57
+ export interface DetailListProps extends React.HTMLAttributes<HTMLDListElement> {
58
+ /** Labels beside values, or above them. Below 768px labels always sit above. */
59
+ layout?: DetailListLayout
60
+ }
61
+
62
+ /** A list of labelled values, as a native `dl`. */
63
+ const DetailList = React.forwardRef<HTMLDListElement, DetailListProps>(
64
+ ({ layout = "side", className, ...props }, ref) => (
65
+ <LayoutContext.Provider value={layout}>
66
+ <dl ref={ref} data-slot="detail-list" data-layout={layout} className={cn("m-0", className)} {...props} />
67
+ </LayoutContext.Provider>
68
+ )
69
+ )
70
+ DetailList.displayName = "DetailList"
71
+
72
+ export interface DetailListItemProps
73
+ extends Omit<React.HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
74
+ /** The row's text, which copy copies and edit changes. Controlled. */
75
+ value?: string
76
+ defaultValue?: string
77
+ /** Runs on every saved edit, a person's or an agent's. `details.cancel()` refuses it. */
78
+ onValueChange?: (value: string, details: DetailListChangeDetails) => void
79
+ /** Returns a message to refuse a value, shown under the field or sent back to the agent. */
80
+ validate?: (value: string) => string | undefined
81
+ /** Adds a button that copies the value. */
82
+ copyable?: boolean
83
+ /** Adds a button that edits the value in place. */
84
+ editable?: boolean
85
+ /** Edits in a textarea, saved with Cmd or Ctrl and Enter. */
86
+ multiline?: boolean
87
+ /** Edits in your own field, such as a Select, in place of the text field. Save, Cancel and `validate` still apply. */
88
+ renderEditor?: (editor: DetailListEditorProps) => React.ReactNode
89
+ /** Trims spaces from both ends of a value before it is validated and saved, a person's or an agent's. */
90
+ trim?: boolean
91
+ /** Blocks editing, by people and agents. Copy still works. */
92
+ disabled?: boolean
93
+ }
94
+
95
+ /** One row: a term and its details. Holds the value, and the copy and edit state. */
96
+ const DetailListItem = React.forwardRef<HTMLDivElement, DetailListItemProps>(
97
+ (
98
+ {
99
+ value: valueProp,
100
+ defaultValue = "",
101
+ onValueChange,
102
+ validate,
103
+ copyable = false,
104
+ editable = false,
105
+ multiline = false,
106
+ renderEditor,
107
+ trim = false,
108
+ disabled = false,
109
+ className,
110
+ ...props
111
+ },
112
+ ref
113
+ ) => {
114
+ const layout = React.useContext(LayoutContext)
115
+ const termId = React.useId()
116
+ const [value, change] = useAgentState<string, DetailListChangeDetails>(valueProp, defaultValue, onValueChange)
117
+ const [editing, setEditing] = React.useState(false)
118
+ const row = React.useRef<HTMLDivElement | null>(null)
119
+ const hasAgent = useHasAgent()
120
+
121
+ const setRef = (el: HTMLDivElement | null) => {
122
+ row.current = el
123
+ if (typeof ref === "function") ref(el)
124
+ else if (ref) ref.current = el
125
+ }
126
+
127
+ // Two frames tinted, then the tint fades over 250ms, so the whole flash stays under 300ms.
128
+ const flash = () => {
129
+ const el = row.current
130
+ if (!el) return
131
+ el.setAttribute("data-saved", "")
132
+ requestAnimationFrame(() => requestAnimationFrame(() => el.removeAttribute("data-saved")))
133
+ }
134
+
135
+ // Returns a message when the value is refused, so the caller decides how to show it.
136
+ const commit = (raw: string, apply: (next: string) => string | undefined) => {
137
+ const next = trim ? raw.trim() : raw
138
+ const invalid = validate?.(next)
139
+ if (invalid) return invalid
140
+ if (next === value) return
141
+ const refused = apply(next)
142
+ if (refused) return refused
143
+ flash()
144
+ }
145
+
146
+ const save = (next: string, event?: Event) =>
147
+ commit(next, (v) => {
148
+ const details: DetailListChangeDetails = {
149
+ reason: "none",
150
+ event,
151
+ isCanceled: false,
152
+ cancel: () => void (details.isCanceled = true),
153
+ }
154
+ change(v, details)
155
+ return details.isCanceled ? "The app refused the change." : undefined
156
+ })
157
+
158
+ const agentSet = (next: string) =>
159
+ editing ? "A person is editing this row." : commit(next, (v) => changeAsAgent(change, v))
160
+
161
+ useAgentControl(() =>
162
+ editable
163
+ ? {
164
+ kind: multiline ? "textarea" : "input",
165
+ element: row.current,
166
+ label: row.current?.ownerDocument.getElementById(termId)?.textContent?.trim(),
167
+ value,
168
+ disabled,
169
+ actions: {
170
+ setValue: (next: string) => agentSet(String(next ?? "")),
171
+ clear: () => agentSet(""),
172
+ },
173
+ }
174
+ : null
175
+ )
176
+
177
+ return (
178
+ <ItemContext.Provider
179
+ value={{ termId, value, editing, setEditing, save, copyable, editable, multiline, renderEditor, disabled, hasAgent }}
180
+ >
181
+ <div
182
+ ref={setRef}
183
+ data-slot="detail-list-item"
184
+ className={cn(
185
+ "group/item grid min-h-12 items-start gap-x-3 gap-y-0.5 border-t py-3.5 md:py-3",
186
+ layout === "side" && "md:grid-cols-[150px_minmax(0,1fr)]",
187
+ "transition-[background-color] [transition-duration:250ms] ease-out motion-reduce:transition-none",
188
+ "data-[saved]:bg-[color:color-mix(in_oklab,var(--success)_18%,transparent)] data-[saved]:duration-0",
189
+ "motion-reduce:data-[saved]:bg-transparent",
190
+ className
191
+ )}
192
+ {...props}
193
+ />
194
+ </ItemContext.Provider>
195
+ )
196
+ }
197
+ )
198
+ DetailListItem.displayName = "DetailListItem"
199
+
200
+ /** The label, as a `dt`. */
201
+ const DetailListTerm = React.forwardRef<HTMLElement, React.HTMLAttributes<HTMLElement>>(
202
+ ({ className, ...props }, ref) => {
203
+ const item = React.useContext(ItemContext)
204
+ return (
205
+ <dt
206
+ ref={ref}
207
+ id={item?.termId}
208
+ data-slot="detail-list-term"
209
+ className={cn("pt-0.5 text-sm text-muted-foreground md:text-[13px]", className)}
210
+ {...props}
211
+ />
212
+ )
213
+ }
214
+ )
215
+ DetailListTerm.displayName = "DetailListTerm"
216
+
217
+ export interface DetailListDetailsProps extends Omit<React.HTMLAttributes<HTMLElement>, "children"> {
218
+ /** What the row shows. Defaults to the item's value; a function gets the value to show it your way. */
219
+ children?: React.ReactNode | ((value: string) => React.ReactNode)
220
+ }
221
+
222
+ const iconButton =
223
+ "inline-grid size-11 shrink-0 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40 md:size-[30px]"
224
+
225
+ /** The value, as a `dd`, with the row's copy and edit buttons and its editor. */
226
+ const DetailListDetails = React.forwardRef<HTMLElement, DetailListDetailsProps>(
227
+ ({ className, children, ...props }, ref) => {
228
+ const item = React.useContext(ItemContext)
229
+ const [copied, setCopied] = React.useState<"done" | "failed" | null>(null)
230
+ const editButton = React.useRef<HTMLButtonElement | null>(null)
231
+ const refocus = React.useRef(false)
232
+ const editing = !!item?.editing
233
+
234
+ React.useEffect(() => {
235
+ if (editing || !refocus.current) return
236
+ refocus.current = false
237
+ editButton.current?.focus()
238
+ }, [editing])
239
+
240
+ React.useEffect(() => {
241
+ if (!copied) return
242
+ const t = setTimeout(() => setCopied(null), 1400)
243
+ return () => clearTimeout(t)
244
+ }, [copied])
245
+
246
+ const shown = typeof children === "function" ? children(item?.value ?? "") : (children ?? item?.value)
247
+ const labelledBy = (id: string) => (item ? `${id} ${item.termId}` : undefined)
248
+ const copyId = React.useId()
249
+ const editId = React.useId()
250
+
251
+ const close = () => {
252
+ refocus.current = true
253
+ item?.setEditing(false)
254
+ }
255
+
256
+ return (
257
+ <dd
258
+ ref={ref}
259
+ data-slot="detail-list-details"
260
+ className={cn("m-0 flex min-w-0 items-start gap-2 text-base leading-[1.45] md:text-sm", className)}
261
+ {...props}
262
+ >
263
+ {item && editing ? (
264
+ <Editor item={item} onClose={close} />
265
+ ) : (
266
+ <div className="min-w-0 flex-1 whitespace-pre-line break-words pt-px">{shown}</div>
267
+ )}
268
+ {item && (item.copyable || item.editable) && (
269
+ <div
270
+ className={cn(
271
+ "-my-2.5 -me-2.5 flex shrink-0 gap-0.5 md:-my-[5px] md:-me-1.5",
272
+ "transition-opacity duration-100 motion-reduce:transition-none",
273
+ "md:opacity-0 md:group-hover/item:opacity-100 md:group-focus-within/item:opacity-100",
274
+ editing && "max-md:hidden md:invisible"
275
+ )}
276
+ >
277
+ {item.copyable && (
278
+ <button
279
+ type="button"
280
+ className={iconButton}
281
+ aria-labelledby={labelledBy(copyId)}
282
+ onClick={() => {
283
+ // No clipboard outside a secure context, and a denied write rejects.
284
+ const write = navigator.clipboard?.writeText(item.value)
285
+ if (!write) return setCopied("failed")
286
+ write.then(
287
+ () => setCopied("done"),
288
+ () => setCopied("failed")
289
+ )
290
+ }}
291
+ >
292
+ <span id={copyId} className="sr-only">
293
+ Copy
294
+ </span>
295
+ {copied === "done" ? <Check className="size-[15px] text-foreground" aria-hidden /> : <Copy className="size-[15px]" aria-hidden />}
296
+ </button>
297
+ )}
298
+ {item.editable && (
299
+ <button
300
+ ref={editButton}
301
+ type="button"
302
+ className={iconButton}
303
+ aria-labelledby={labelledBy(editId)}
304
+ disabled={item.disabled}
305
+ data-agent-part={item.hasAgent ? "" : undefined}
306
+ onClick={() => item.setEditing(true)}
307
+ >
308
+ <span id={editId} className="sr-only">
309
+ Edit
310
+ </span>
311
+ <Pencil className="size-[15px]" aria-hidden />
312
+ </button>
313
+ )}
314
+ <span className="sr-only" aria-live="polite">
315
+ {copied === "done" ? "Copied" : copied === "failed" ? "Could not copy" : ""}
316
+ </span>
317
+ </div>
318
+ )}
319
+ </dd>
320
+ )
321
+ }
322
+ )
323
+ DetailListDetails.displayName = "DetailListDetails"
324
+
325
+ const fieldClass =
326
+ "w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 text-base outline-none transition-[box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-[color:color-mix(in_oklab,var(--ring)_50%,transparent)] aria-[invalid=true]:border-destructive md:text-sm"
327
+
328
+ function Editor({ item, onClose }: { item: ItemContextValue; onClose: () => void }) {
329
+ const [draft, setDraft] = React.useState(item.value)
330
+ const [error, setError] = React.useState<string>()
331
+ const errorId = React.useId()
332
+
333
+ const save = (event?: Event, next = draft) => {
334
+ const refused = item.save(next, event)
335
+ if (refused) setError(refused)
336
+ else onClose()
337
+ }
338
+
339
+ const onKeyDown = (event: React.KeyboardEvent) => {
340
+ if (event.key === "Escape") {
341
+ event.preventDefault()
342
+ event.stopPropagation()
343
+ onClose()
344
+ } else if (
345
+ event.key === "Enter" &&
346
+ // Enter also confirms a word in an input method, which is not a save.
347
+ !event.nativeEvent.isComposing &&
348
+ (!item.multiline || event.metaKey || event.ctrlKey)
349
+ ) {
350
+ event.preventDefault()
351
+ save(event.nativeEvent)
352
+ }
353
+ }
354
+
355
+ // The editor only mounts on a click, so reading the platform here cannot mismatch the server.
356
+ const mod = /Mac|iPhone|iPad/.test(navigator.userAgent) ? "⌘" : "Ctrl"
357
+
358
+ const change = (next: string) => {
359
+ setDraft(next)
360
+ setError(undefined)
361
+ }
362
+
363
+ const fieldProps: DetailListEditorProps["fieldProps"] = {
364
+ autoFocus: true,
365
+ "aria-labelledby": item.termId,
366
+ "aria-invalid": error ? true : undefined,
367
+ "aria-describedby": error ? errorId : undefined,
368
+ "data-agent-part": item.hasAgent ? "" : undefined,
369
+ }
370
+
371
+ const field = {
372
+ ...fieldProps,
373
+ value: draft,
374
+ onKeyDown,
375
+ onChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => change(e.target.value),
376
+ }
377
+
378
+ return (
379
+ <div className="grid min-w-0 flex-1 gap-2">
380
+ {item.renderEditor ? (
381
+ item.renderEditor({
382
+ value: draft,
383
+ setValue: change,
384
+ save: (next) => {
385
+ if (next !== undefined) setDraft(next)
386
+ save(undefined, next ?? draft)
387
+ },
388
+ cancel: onClose,
389
+ onKeyDown,
390
+ fieldProps,
391
+ })
392
+ ) : item.multiline ? (
393
+ <textarea {...field} rows={Math.max(2, draft.split("\n").length)} className={cn(fieldClass, "resize-none py-[7px] leading-[1.45]")} />
394
+ ) : (
395
+ <input {...field} className={cn(fieldClass, "h-11 md:h-[34px]")} />
396
+ )}
397
+ {error && (
398
+ <p id={errorId} role="alert" className="text-[13px] text-destructive">
399
+ {error}
400
+ </p>
401
+ )}
402
+ <div className="flex items-center gap-1.5">
403
+ <Button size="sm" className="h-11 md:h-8" onClick={(e) => save(e.nativeEvent)}>
404
+ Save
405
+ </Button>
406
+ <Button size="sm" variant="ghost" className="h-11 md:h-8" onClick={onClose}>
407
+ Cancel
408
+ </Button>
409
+ {!item.renderEditor && (
410
+ <span className="ms-auto text-[11.5px] text-muted-foreground max-md:hidden">
411
+ {item.multiline ? `${mod} Enter` : "Enter"} to save · Esc to cancel
412
+ </span>
413
+ )}
414
+ </div>
415
+ </div>
416
+ )
417
+ }
418
+
419
+ export { DetailList, DetailListItem, DetailListTerm, DetailListDetails }
@@ -0,0 +1,12 @@
1
+ export {
2
+ DetailList,
3
+ DetailListItem,
4
+ DetailListTerm,
5
+ DetailListDetails,
6
+ type DetailListProps,
7
+ type DetailListItemProps,
8
+ type DetailListDetailsProps,
9
+ type DetailListLayout,
10
+ type DetailListChangeDetails,
11
+ type DetailListEditorProps,
12
+ } from "./detail-list"
@@ -23,10 +23,12 @@ function Dialog<Payload>({ open, defaultOpen, onOpenChange, ...props }: BaseDial
23
23
 
24
24
  function DialogTrigger<Payload>({ ref, ...props }: BaseDialog.Trigger.Props<Payload> & React.RefAttributes<HTMLElement>) {
25
25
  const dialog = React.useContext(DialogAgentContext)
26
- return <BaseDialog.Trigger<Payload> ref={useMergedRef(ref, dialog?.trigger)} {...props} />
26
+ return <BaseDialog.Trigger<Payload> ref={useMergedRef(ref, dialog?.trigger)} data-slot="dialog-trigger" {...props} />
27
27
  }
28
28
 
29
- const DialogPortal = BaseDialog.Portal
29
+ function DialogPortal(props: React.ComponentProps<typeof BaseDialog.Portal>) {
30
+ return <BaseDialog.Portal data-slot="dialog-portal" {...props} />
31
+ }
30
32
 
31
33
  const DialogBackdrop = React.forwardRef<
32
34
  HTMLDivElement,
@@ -41,6 +43,7 @@ const DialogBackdrop = React.forwardRef<
41
43
  "data-[ending-style]:duration-[var(--motion-duration-fast,150ms)]",
42
44
  className
43
45
  )}
46
+ data-slot="dialog-backdrop"
44
47
  {...props}
45
48
  />
46
49
  ))
@@ -56,6 +59,7 @@ const DialogViewport = React.forwardRef<
56
59
  "fixed inset-0 z-50 flex items-center justify-center overflow-auto",
57
60
  className
58
61
  )}
62
+ data-slot="dialog-viewport"
59
63
  {...props}
60
64
  />
61
65
  ))
@@ -83,6 +87,7 @@ const DialogPopup = React.forwardRef<
83
87
  "data-[ending-style]:duration-[var(--motion-duration-fast,150ms)]",
84
88
  className
85
89
  )}
90
+ data-slot="dialog-popup"
86
91
  {...props}
87
92
  />
88
93
  )
@@ -96,6 +101,7 @@ const DialogTitle = React.forwardRef<
96
101
  <BaseDialog.Title
97
102
  ref={ref}
98
103
  className={cn("text-lg font-medium leading-none tracking-tight", className)}
104
+ data-slot="dialog-title"
99
105
  {...props}
100
106
  />
101
107
  ))
@@ -108,6 +114,7 @@ const DialogDescription = React.forwardRef<
108
114
  <BaseDialog.Description
109
115
  ref={ref}
110
116
  className={cn("text-sm text-muted-foreground", className)}
117
+ data-slot="dialog-description"
111
118
  {...props}
112
119
  />
113
120
  ))
@@ -130,6 +137,7 @@ const DialogClose = React.forwardRef<
130
137
  className,
131
138
  )
132
139
  }
140
+ data-slot="dialog-close"
133
141
  {...props}
134
142
  />
135
143
  ))
@@ -144,6 +152,7 @@ const DialogHeader = ({
144
152
  "flex flex-col space-y-1.5 text-center sm:text-left",
145
153
  className
146
154
  )}
155
+ data-slot="dialog-header"
147
156
  {...props}
148
157
  />
149
158
  )
@@ -158,6 +167,7 @@ const DialogFooter = ({
158
167
  "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-1.5",
159
168
  className
160
169
  )}
170
+ data-slot="dialog-footer"
161
171
  {...props}
162
172
  />
163
173
  )
@@ -170,7 +180,7 @@ const DialogContent = React.forwardRef<
170
180
  <DialogPortal>
171
181
  <DialogBackdrop />
172
182
  <DialogViewport>
173
- <DialogPopup ref={ref} className={className} {...props}>
183
+ <DialogPopup ref={ref} className={className} data-slot="dialog-content" {...props}>
174
184
  {children}
175
185
  </DialogPopup>
176
186
  </DialogViewport>
@@ -19,11 +19,20 @@ function Drawer<Payload>({ open, defaultOpen, onOpenChange, ...props }: DrawerPr
19
19
 
20
20
  function DrawerTrigger<Payload>({ ref, ...props }: DrawerPrimitive.Trigger.Props<Payload> & React.RefAttributes<HTMLElement>) {
21
21
  const parts = React.useContext(DrawerAgentContext)
22
- return <DrawerPrimitive.Trigger<Payload> ref={useMergedRef(ref, parts?.trigger)} {...props} />
22
+ return <DrawerPrimitive.Trigger<Payload> ref={useMergedRef(ref, parts?.trigger)} data-slot="drawer-trigger" {...props} />
23
+ }
24
+
25
+ function DrawerPortal(props: React.ComponentProps<typeof DrawerPrimitive.Portal>) {
26
+ return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />
27
+ }
28
+
29
+ function DrawerClose(props: React.ComponentProps<typeof DrawerPrimitive.Close>) {
30
+ return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
31
+ }
32
+
33
+ function DrawerSwipeArea(props: React.ComponentProps<typeof DrawerPrimitive.SwipeArea>) {
34
+ return <DrawerPrimitive.SwipeArea data-slot="drawer-swipe-area" {...props} />
23
35
  }
24
- const DrawerPortal = DrawerPrimitive.Portal
25
- const DrawerClose = DrawerPrimitive.Close
26
- const DrawerSwipeArea = DrawerPrimitive.SwipeArea
27
36
 
28
37
  const DrawerBackdrop = React.forwardRef<
29
38
  React.ComponentRef<typeof DrawerPrimitive.Backdrop>,
@@ -44,6 +53,7 @@ const DrawerBackdrop = React.forwardRef<
44
53
  "data-[swiping]:transition-none",
45
54
  className
46
55
  )}
56
+ data-slot="drawer-backdrop"
47
57
  {...props}
48
58
  />
49
59
  ))
@@ -89,6 +99,7 @@ const DrawerContent = React.forwardRef<
89
99
  "motion-reduce:data-[ending-style]:translate-x-0 motion-reduce:data-[ending-style]:translate-y-0 motion-reduce:data-[ending-style]:opacity-0",
90
100
  className
91
101
  )}
102
+ data-slot="drawer-content"
92
103
  {...props}
93
104
  >
94
105
  <DrawerPrimitive.Content className="size-full overflow-y-auto">
@@ -107,6 +118,7 @@ function DrawerTitle({
107
118
  return (
108
119
  <DrawerPrimitive.Title
109
120
  className={cn("text-lg font-medium leading-none tracking-tight", className)}
121
+ data-slot="drawer-title"
110
122
  {...props}
111
123
  />
112
124
  )
@@ -119,18 +131,19 @@ function DrawerDescription({
119
131
  return (
120
132
  <DrawerPrimitive.Description
121
133
  className={cn("text-sm text-muted-foreground", className)}
134
+ data-slot="drawer-description"
122
135
  {...props}
123
136
  />
124
137
  )
125
138
  }
126
139
 
127
140
  const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
128
- <div className={cn("flex flex-col gap-1.5 text-center sm:text-left", className)} {...props} />
141
+ <div className={cn("flex flex-col gap-1.5 text-center sm:text-left", className)} data-slot="drawer-header" {...props} />
129
142
  )
130
143
  DrawerHeader.displayName = "DrawerHeader"
131
144
 
132
145
  const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
133
- <div className={cn("mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end", className)} {...props} />
146
+ <div className={cn("mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end", className)} data-slot="drawer-footer" {...props} />
134
147
  )
135
148
  DrawerFooter.displayName = "DrawerFooter"
136
149
 
@@ -134,7 +134,7 @@ const ExpandableCard = React.forwardRef<HTMLDivElement, ExpandableCardProps>(
134
134
 
135
135
  return (
136
136
  <ExpandableCardContext.Provider value={context}>
137
- <div ref={ref} className={cn("relative", className)} {...props} />
137
+ <div ref={ref} className={cn("relative", className)} data-slot="expandable-card" {...props} />
138
138
  </ExpandableCardContext.Provider>
139
139
  )
140
140
  }
@@ -171,6 +171,7 @@ const ExpandableCardTrigger = React.forwardRef<
171
171
  "block w-full overflow-hidden rounded-2xl border border-border bg-background text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
172
172
  className
173
173
  )}
174
+ data-slot="expandable-card-trigger"
174
175
  {...props}
175
176
  />
176
177
  )
@@ -326,6 +327,7 @@ const ExpandableCardPanel = React.forwardRef<HTMLDivElement, ExpandableCardPanel
326
327
  panelSurface(fullscreen),
327
328
  className
328
329
  )}
330
+ data-slot="expandable-card-panel"
329
331
  {...props}
330
332
  >
331
333
  <ExitMark panel={panel} />
@@ -391,6 +393,7 @@ const ExpandableCardShared = React.forwardRef<HTMLDivElement, ExpandableCardShar
391
393
  ref={ref}
392
394
  layoutId={layoutId(part)}
393
395
  transition={transition}
396
+ data-slot="expandable-card-shared"
394
397
  {...props}
395
398
  />
396
399
  )
@@ -418,6 +421,7 @@ const ExpandableCardBody = React.forwardRef<HTMLDivElement, ExpandableCardBodyPr
418
421
  animate={{ opacity: 1, y: 0 }}
419
422
  transition={{ delay: reducedMotion ? 0 : 0.16, duration: 0.24 }}
420
423
  className={cn("text-sm leading-relaxed text-muted-foreground", className)}
424
+ data-slot="expandable-card-body"
421
425
  {...props}
422
426
  />
423
427
  )
@@ -6,7 +6,7 @@ const Field = React.forwardRef<
6
6
  HTMLDivElement,
7
7
  React.ComponentProps<typeof BaseField.Root>
8
8
  >(({ className, ...props }, ref) => (
9
- <BaseField.Root ref={ref} className={cn("space-y-2", className)} {...props} />
9
+ <BaseField.Root ref={ref} data-slot="field" className={cn("space-y-2", className)} {...props} />
10
10
  ));
11
11
  Field.displayName = "Field";
12
12
 
@@ -16,6 +16,7 @@ const FieldLabel = React.forwardRef<
16
16
  >(({ className, ...props }, ref) => (
17
17
  <BaseField.Label
18
18
  ref={ref}
19
+ data-slot="field-label"
19
20
  className={cn(
20
21
  "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70",
21
22
  "data-[invalid]:text-destructive",
@@ -32,6 +33,7 @@ const FieldControl = React.forwardRef<
32
33
  >(({ className, ...props }, ref) => (
33
34
  <BaseField.Control
34
35
  ref={ref}
36
+ data-slot="field-control"
35
37
  className={cn(
36
38
  "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background",
37
39
  "file:border-0 file:bg-transparent file:text-sm file:font-medium",
@@ -52,6 +54,7 @@ const FieldDescription = React.forwardRef<
52
54
  >(({ className, ...props }, ref) => (
53
55
  <BaseField.Description
54
56
  ref={ref}
57
+ data-slot="field-description"
55
58
  className={cn(
56
59
  "text-sm text-muted-foreground",
57
60
  "data-[disabled]:opacity-50",
@@ -69,6 +72,7 @@ const FieldError = React.forwardRef<
69
72
  // Tells the agent bridge this describes what is wrong, not what the field is for.
70
73
  <BaseField.Error
71
74
  ref={ref}
75
+ data-slot="field-error"
72
76
  data-agent-error=""
73
77
  className={cn(
74
78
  "text-sm font-medium text-destructive",
@@ -10,6 +10,7 @@ const Fieldset = React.forwardRef<
10
10
  >(({ className, ...props }, ref) => (
11
11
  <FieldsetPrimitive.Root
12
12
  ref={ref}
13
+ data-slot="fieldset"
13
14
  className={cn("space-y-3 rounded-lg border p-4", className)}
14
15
  {...props}
15
16
  />
@@ -22,6 +23,7 @@ const FieldsetLegend = React.forwardRef<
22
23
  >(({ className, ...props }, ref) => (
23
24
  <FieldsetPrimitive.Legend
24
25
  ref={ref}
26
+ data-slot="fieldset-legend"
25
27
  className={cn("px-1 text-sm font-medium", className)}
26
28
  {...props}
27
29
  />
@@ -12,6 +12,7 @@ const Form = React.forwardRef<
12
12
  >(({ className, ...props }, ref) => (
13
13
  <BaseForm
14
14
  ref={ref}
15
+ data-slot="form"
15
16
  className={cn("space-y-4", className)}
16
17
  {...props}
17
18
  />