@behavioral-agentic-design-system/core 0.27.0 → 0.29.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/package.json +5 -5
- package/scripts/a11y-lint.cjs +78 -9
- package/scripts/build-tokens.cjs +273 -15
- package/scripts/wcag-audit.cjs +37 -7
- package/src/api/layers/file.ts +1 -0
- package/src/app/font-ready.tsx +6 -5
- package/src/app/layout.tsx +54 -3
- package/src/app/preview/components/page.tsx +5735 -2500
- package/src/app/preview/layout.tsx +4 -1
- package/src/app/preview/showcase-filter.tsx +66 -0
- package/src/app/preview/tab-replay.tsx +63 -0
- package/src/app/shell.tsx +91 -18
- package/src/components/customize/save-bar.tsx +19 -6
- package/src/components/docs-tab.tsx +36 -24
- package/src/components/layers-tab.tsx +37 -5
- package/src/components/ui/ai-badge.tsx +74 -0
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/chat-bubble.tsx +298 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/clipboard.tsx +291 -0
- package/src/components/ui/close-button.tsx +71 -0
- package/src/components/ui/combobox.tsx +62 -3
- package/src/components/ui/container.tsx +65 -0
- package/src/components/ui/copy-button.tsx +5 -1
- package/src/components/ui/data-table.tsx +388 -0
- package/src/components/ui/date-field.tsx +368 -0
- package/src/components/ui/drawer.tsx +334 -0
- package/src/components/ui/file-button.tsx +145 -0
- package/src/components/ui/floating-indicator.tsx +217 -0
- package/src/components/ui/focus-trap.tsx +184 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +28 -0
- package/src/components/ui/input.tsx +38 -3
- package/src/components/ui/keyboard-shortcut.tsx +146 -0
- package/src/components/ui/loading-dots.tsx +99 -0
- package/src/components/ui/mark.tsx +69 -0
- package/src/components/ui/month-picker.tsx +296 -0
- package/src/components/ui/multi-select.tsx +15 -13
- package/src/components/ui/nav-link.tsx +200 -0
- package/src/components/ui/navigation-rail.tsx +256 -0
- package/src/components/ui/notification.tsx +20 -0
- package/src/components/ui/password-input.tsx +34 -1
- package/src/components/ui/progress.tsx +15 -1
- package/src/components/ui/prose.tsx +62 -0
- package/src/components/ui/result.tsx +151 -0
- package/src/components/ui/rolling-number.tsx +201 -0
- package/src/components/ui/simple-grid.tsx +110 -0
- package/src/components/ui/skeleton.tsx +52 -3
- package/src/components/ui/squircle.tsx +274 -0
- package/src/components/ui/stack.tsx +105 -0
- package/src/components/ui/status-badge.tsx +93 -0
- package/src/components/ui/tabs.tsx +34 -7
- package/src/components/ui/tag.tsx +46 -5
- package/src/components/ui/theme-icon.tsx +138 -0
- package/src/components/ui/timeline.tsx +27 -10
- package/src/components/ui/tooltip.tsx +12 -1
- package/src/components/ui/tree-select.tsx +386 -0
- package/src/components/ui/typing-indicator.tsx +2 -2
- package/src/components/ui/word-rotate.tsx +6 -1
- package/src/components/ui/year-picker.tsx +307 -0
- package/src/data/docs-index.ts +10 -0
- package/src/hooks/use-global-primary-color.ts +57 -6
- package/src/stories/AiBadge.stories.tsx +67 -0
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/ChatBubble.stories.tsx +222 -0
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/Clipboard.stories.tsx +136 -0
- package/src/stories/CloseButton.stories.tsx +65 -0
- package/src/stories/Combobox.stories.tsx +74 -3
- package/src/stories/Container.stories.tsx +134 -0
- package/src/stories/CopyButton.stories.tsx +2 -0
- package/src/stories/DataTable.stories.tsx +271 -0
- package/src/stories/DateField.stories.tsx +114 -0
- package/src/stories/Drawer.stories.tsx +211 -0
- package/src/stories/FileButton.stories.tsx +117 -0
- package/src/stories/FloatingIndicator.stories.tsx +343 -0
- package/src/stories/FocusTrap.stories.tsx +218 -0
- package/src/stories/FormatByte.stories.tsx +142 -0
- package/src/stories/Input.stories.tsx +91 -0
- package/src/stories/KeyboardShortcut.stories.tsx +87 -0
- package/src/stories/LoadingDots.stories.tsx +73 -0
- package/src/stories/Mark.stories.tsx +84 -0
- package/src/stories/MonthPicker.stories.tsx +99 -0
- package/src/stories/MultiSelect.stories.tsx +3 -1
- package/src/stories/NavLink.stories.tsx +213 -0
- package/src/stories/NavigationRail.stories.tsx +413 -0
- package/src/stories/Notification.stories.tsx +53 -0
- package/src/stories/PasswordInput.stories.tsx +21 -0
- package/src/stories/Progress.stories.tsx +38 -0
- package/src/stories/Prose.stories.tsx +232 -0
- package/src/stories/Result.stories.tsx +145 -0
- package/src/stories/RollingNumber.stories.tsx +226 -0
- package/src/stories/SimpleGrid.stories.tsx +130 -0
- package/src/stories/Skeleton.stories.tsx +62 -1
- package/src/stories/Squircle.stories.tsx +127 -0
- package/src/stories/Stack.stories.tsx +139 -0
- package/src/stories/StatusBadge.stories.tsx +125 -0
- package/src/stories/Tabs.stories.tsx +56 -1
- package/src/stories/Tag.stories.tsx +31 -0
- package/src/stories/ThemeIcon.stories.tsx +97 -0
- package/src/stories/Timeline.stories.tsx +69 -0
- package/src/stories/Tooltip.stories.tsx +18 -0
- package/src/stories/TreeSelect.stories.tsx +222 -0
- package/src/stories/TypingIndicator.stories.tsx +1 -0
- package/src/stories/WordRotate.stories.tsx +1 -0
- package/src/stories/YearPicker.stories.tsx +100 -0
- package/src/styles.css +289 -15
- package/src/tokens.json +96 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { CheckIcon, ChevronDownIcon, ChevronRightIcon } from "lucide-react"
|
|
5
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils"
|
|
8
|
+
import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* TreeSelect — a select-shaped trigger that opens a popover containing an
|
|
12
|
+
* expandable tree. The user picks one leaf (single mode: commit + close) or
|
|
13
|
+
* several leaves (multiple mode: toggle + stay open) from an arbitrary-depth
|
|
14
|
+
* hierarchy. Branch rows organize (click / Enter toggles expansion); leaf rows
|
|
15
|
+
* carry the selection — the same leaf-commit semantics as Cascader, applied to
|
|
16
|
+
* a tree instead of columns.
|
|
17
|
+
*
|
|
18
|
+
* Fills the gap between Cascader (known-depth ≤4 column browser), TreeView
|
|
19
|
+
* (persistent inline tree with no committed value), and Select / Combobox /
|
|
20
|
+
* MultiSelect (flat lists). Sources: Ant Design TreeSelect, Mantine Combobox
|
|
21
|
+
* TreeSelect example.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export interface TreeSelectNode {
|
|
25
|
+
value: string
|
|
26
|
+
label: string
|
|
27
|
+
disabled?: boolean
|
|
28
|
+
children?: TreeSelectNode[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface TreeSelectProps {
|
|
32
|
+
/** The tree of options. Nodes with `children` are branches (expand/collapse); nodes without are selectable leaves. */
|
|
33
|
+
data: TreeSelectNode[]
|
|
34
|
+
/** Controlled value — a leaf value in single mode, an array of leaf values in multiple mode. */
|
|
35
|
+
value?: string | string[]
|
|
36
|
+
/** Fires with the committed value: a string in single mode, a string[] in multiple mode. */
|
|
37
|
+
onChange?: (value: string | string[]) => void
|
|
38
|
+
placeholder?: string
|
|
39
|
+
disabled?: boolean
|
|
40
|
+
/** Multi-select mode: leaves toggle independently and the popover stays open between toggles. */
|
|
41
|
+
multiple?: boolean
|
|
42
|
+
/** Branch values expanded on first render. Ancestors of the current selection auto-expand on open. */
|
|
43
|
+
defaultExpanded?: string[]
|
|
44
|
+
className?: string
|
|
45
|
+
/** aria-label for the trigger when no visible label is associated. */
|
|
46
|
+
"aria-label"?: string
|
|
47
|
+
/** aria-labelledby pointing at an external label element. */
|
|
48
|
+
"aria-labelledby"?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Map every node value to its label + ancestor branch values (for display + auto-expand). */
|
|
52
|
+
function indexTree(
|
|
53
|
+
nodes: TreeSelectNode[],
|
|
54
|
+
ancestors: string[] = [],
|
|
55
|
+
into: Map<string, { label: string; ancestors: string[] }> = new Map()
|
|
56
|
+
): Map<string, { label: string; ancestors: string[] }> {
|
|
57
|
+
for (const node of nodes) {
|
|
58
|
+
into.set(node.value, { label: node.label, ancestors })
|
|
59
|
+
if (node.children?.length) {
|
|
60
|
+
indexTree(node.children, [...ancestors, node.value], into)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return into
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getVisibleItems(contentEl: HTMLElement): HTMLButtonElement[] {
|
|
67
|
+
return Array.from(
|
|
68
|
+
contentEl.querySelectorAll<HTMLButtonElement>('[data-slot="tree-select-item"]')
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function TreeSelect({
|
|
73
|
+
data,
|
|
74
|
+
value,
|
|
75
|
+
onChange,
|
|
76
|
+
placeholder = "Select…",
|
|
77
|
+
disabled,
|
|
78
|
+
multiple = false,
|
|
79
|
+
defaultExpanded = [],
|
|
80
|
+
className,
|
|
81
|
+
"aria-label": ariaLabel,
|
|
82
|
+
"aria-labelledby": ariaLabelledBy,
|
|
83
|
+
}: TreeSelectProps) {
|
|
84
|
+
const [open, setOpen] = React.useState(false)
|
|
85
|
+
const [internalValue, setInternalValue] = React.useState<string | string[]>(
|
|
86
|
+
multiple ? [] : ""
|
|
87
|
+
)
|
|
88
|
+
const [expanded, setExpanded] = React.useState<Set<string>>(
|
|
89
|
+
() => new Set(defaultExpanded)
|
|
90
|
+
)
|
|
91
|
+
const contentRef = React.useRef<HTMLDivElement>(null)
|
|
92
|
+
const portalThemeClass = usePortalThemeClass()
|
|
93
|
+
|
|
94
|
+
const nodeIndex = React.useMemo(() => indexTree(data), [data])
|
|
95
|
+
|
|
96
|
+
const currentValue = value !== undefined ? value : internalValue
|
|
97
|
+
const selectedValues = React.useMemo<string[]>(() => {
|
|
98
|
+
if (Array.isArray(currentValue)) return currentValue
|
|
99
|
+
return currentValue ? [currentValue] : []
|
|
100
|
+
}, [currentValue])
|
|
101
|
+
|
|
102
|
+
const selectedLabels = selectedValues
|
|
103
|
+
.map((v) => nodeIndex.get(v)?.label)
|
|
104
|
+
.filter((l): l is string => !!l)
|
|
105
|
+
const displayValue = selectedLabels.length > 0 ? selectedLabels.join(", ") : null
|
|
106
|
+
|
|
107
|
+
function commit(next: string | string[]) {
|
|
108
|
+
if (value === undefined) setInternalValue(next)
|
|
109
|
+
onChange?.(next)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function handleOpenChange(nextOpen: boolean) {
|
|
113
|
+
setOpen(nextOpen)
|
|
114
|
+
if (nextOpen && selectedValues.length > 0) {
|
|
115
|
+
// Auto-expand every ancestor of the current selection so the picked
|
|
116
|
+
// leaf is visible when the popup opens.
|
|
117
|
+
setExpanded((prev) => {
|
|
118
|
+
const next = new Set(prev)
|
|
119
|
+
for (const v of selectedValues) {
|
|
120
|
+
for (const ancestor of nodeIndex.get(v)?.ancestors ?? []) {
|
|
121
|
+
next.add(ancestor)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return next
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function toggleExpanded(nodeValue: string) {
|
|
130
|
+
setExpanded((prev) => {
|
|
131
|
+
const next = new Set(prev)
|
|
132
|
+
if (next.has(nodeValue)) next.delete(nodeValue)
|
|
133
|
+
else next.add(nodeValue)
|
|
134
|
+
return next
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function handleActivate(node: TreeSelectNode) {
|
|
139
|
+
if (node.disabled) return
|
|
140
|
+
if (node.children?.length) {
|
|
141
|
+
toggleExpanded(node.value)
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
if (multiple) {
|
|
145
|
+
const next = selectedValues.includes(node.value)
|
|
146
|
+
? selectedValues.filter((v) => v !== node.value)
|
|
147
|
+
: [...selectedValues, node.value]
|
|
148
|
+
commit(next)
|
|
149
|
+
} else {
|
|
150
|
+
commit(node.value)
|
|
151
|
+
setOpen(false)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function handleItemKeyDown(
|
|
156
|
+
e: React.KeyboardEvent<HTMLButtonElement>,
|
|
157
|
+
node: TreeSelectNode,
|
|
158
|
+
level: number
|
|
159
|
+
) {
|
|
160
|
+
const content = contentRef.current
|
|
161
|
+
if (!content) return
|
|
162
|
+
const items = getVisibleItems(content)
|
|
163
|
+
const idx = items.indexOf(e.currentTarget)
|
|
164
|
+
const isBranch = !!node.children?.length
|
|
165
|
+
const isExpanded = expanded.has(node.value)
|
|
166
|
+
|
|
167
|
+
switch (e.key) {
|
|
168
|
+
case "ArrowDown":
|
|
169
|
+
e.preventDefault()
|
|
170
|
+
items[idx + 1]?.focus()
|
|
171
|
+
break
|
|
172
|
+
case "ArrowUp":
|
|
173
|
+
e.preventDefault()
|
|
174
|
+
items[idx - 1]?.focus()
|
|
175
|
+
break
|
|
176
|
+
case "ArrowRight":
|
|
177
|
+
e.preventDefault()
|
|
178
|
+
if (isBranch && !isExpanded) toggleExpanded(node.value)
|
|
179
|
+
else if (isBranch && isExpanded) items[idx + 1]?.focus()
|
|
180
|
+
break
|
|
181
|
+
case "ArrowLeft":
|
|
182
|
+
e.preventDefault()
|
|
183
|
+
if (isBranch && isExpanded) {
|
|
184
|
+
toggleExpanded(node.value)
|
|
185
|
+
} else {
|
|
186
|
+
// Focus the closest ancestor (a visible item with a lower aria-level)
|
|
187
|
+
for (let i = idx - 1; i >= 0; i--) {
|
|
188
|
+
const itemLevel = parseInt(items[i].getAttribute("data-level") ?? "1", 10)
|
|
189
|
+
if (itemLevel < level) {
|
|
190
|
+
items[i].focus()
|
|
191
|
+
break
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
break
|
|
196
|
+
case "Home":
|
|
197
|
+
e.preventDefault()
|
|
198
|
+
items[0]?.focus()
|
|
199
|
+
break
|
|
200
|
+
case "End":
|
|
201
|
+
e.preventDefault()
|
|
202
|
+
items[items.length - 1]?.focus()
|
|
203
|
+
break
|
|
204
|
+
case "Enter":
|
|
205
|
+
case " ":
|
|
206
|
+
e.preventDefault()
|
|
207
|
+
handleActivate(node)
|
|
208
|
+
break
|
|
209
|
+
default: {
|
|
210
|
+
// Typeahead: printable character jumps to the next visible node whose
|
|
211
|
+
// label starts with it (WAI-ARIA tree pattern), wrapping around.
|
|
212
|
+
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && e.key !== " ") {
|
|
213
|
+
const char = e.key.toLowerCase()
|
|
214
|
+
for (let step = 1; step <= items.length; step++) {
|
|
215
|
+
const candidate = items[(idx + step) % items.length]
|
|
216
|
+
const label = candidate.getAttribute("data-label") ?? ""
|
|
217
|
+
if (label.toLowerCase().startsWith(char)) {
|
|
218
|
+
e.preventDefault()
|
|
219
|
+
candidate.focus()
|
|
220
|
+
break
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function focusInitialItem() {
|
|
229
|
+
const content = contentRef.current
|
|
230
|
+
if (!content) return
|
|
231
|
+
const items = getVisibleItems(content)
|
|
232
|
+
const selected = items.find((el) => el.hasAttribute("data-selected"))
|
|
233
|
+
;(selected ?? items[0])?.focus()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function renderNodes(nodes: TreeSelectNode[], level: number): React.ReactNode {
|
|
237
|
+
return (
|
|
238
|
+
<ul
|
|
239
|
+
role={level === 1 ? "tree" : "group"}
|
|
240
|
+
aria-label={level === 1 ? (ariaLabel ?? "Options") : undefined}
|
|
241
|
+
aria-multiselectable={level === 1 && multiple ? true : undefined}
|
|
242
|
+
className="space-y-0.5"
|
|
243
|
+
>
|
|
244
|
+
{nodes.map((node, nodeIdx) => {
|
|
245
|
+
const isBranch = !!node.children?.length
|
|
246
|
+
const isExpanded = expanded.has(node.value)
|
|
247
|
+
const isSelected = !isBranch && selectedValues.includes(node.value)
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<li
|
|
251
|
+
key={node.value}
|
|
252
|
+
role="treeitem"
|
|
253
|
+
aria-expanded={isBranch ? isExpanded : undefined}
|
|
254
|
+
aria-selected={isBranch ? undefined : isSelected}
|
|
255
|
+
aria-level={level}
|
|
256
|
+
aria-disabled={node.disabled || undefined}
|
|
257
|
+
className="list-none"
|
|
258
|
+
>
|
|
259
|
+
<button
|
|
260
|
+
type="button"
|
|
261
|
+
data-slot="tree-select-item"
|
|
262
|
+
data-level={level}
|
|
263
|
+
data-label={node.label}
|
|
264
|
+
data-selected={isSelected || undefined}
|
|
265
|
+
data-disabled={node.disabled || undefined}
|
|
266
|
+
aria-disabled={node.disabled || undefined}
|
|
267
|
+
tabIndex={level === 1 && nodeIdx === 0 ? 0 : -1}
|
|
268
|
+
onClick={() => handleActivate(node)}
|
|
269
|
+
onKeyDown={(e) => handleItemKeyDown(e, node, level)}
|
|
270
|
+
className={cn(
|
|
271
|
+
"flex w-full items-center gap-1.5 rounded-sm py-1.5 pr-2 text-sm outline-none",
|
|
272
|
+
"transition-colors",
|
|
273
|
+
"focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
274
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
275
|
+
isSelected
|
|
276
|
+
? "bg-accent text-accent-foreground"
|
|
277
|
+
: "hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground"
|
|
278
|
+
)}
|
|
279
|
+
style={{
|
|
280
|
+
paddingLeft: `${(level - 1) * 16 + 8}px`,
|
|
281
|
+
transitionDuration: "var(--duration-fast)",
|
|
282
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
<ChevronRightIcon
|
|
286
|
+
strokeWidth={1.5}
|
|
287
|
+
aria-hidden
|
|
288
|
+
className={cn(
|
|
289
|
+
"size-4 shrink-0 text-muted-foreground transition-transform",
|
|
290
|
+
!isBranch && "pointer-events-none opacity-0",
|
|
291
|
+
isExpanded && "rotate-90"
|
|
292
|
+
)}
|
|
293
|
+
style={{
|
|
294
|
+
transitionDuration: "var(--duration-fast)",
|
|
295
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
296
|
+
}}
|
|
297
|
+
/>
|
|
298
|
+
<span className="min-w-0 flex-1 truncate text-left">{node.label}</span>
|
|
299
|
+
{isSelected && (
|
|
300
|
+
<CheckIcon strokeWidth={1.5} aria-hidden className="size-4 shrink-0" />
|
|
301
|
+
)}
|
|
302
|
+
</button>
|
|
303
|
+
{isBranch && isExpanded && renderNodes(node.children!, level + 1)}
|
|
304
|
+
</li>
|
|
305
|
+
)
|
|
306
|
+
})}
|
|
307
|
+
</ul>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<PopoverPrimitive.Root data-slot="tree-select" open={open} onOpenChange={handleOpenChange}>
|
|
313
|
+
<PopoverPrimitive.Trigger asChild>
|
|
314
|
+
<button
|
|
315
|
+
type="button"
|
|
316
|
+
data-slot="tree-select-trigger"
|
|
317
|
+
disabled={disabled}
|
|
318
|
+
aria-haspopup="tree"
|
|
319
|
+
aria-expanded={open}
|
|
320
|
+
aria-label={ariaLabel}
|
|
321
|
+
aria-labelledby={ariaLabelledBy}
|
|
322
|
+
className={cn(
|
|
323
|
+
"flex min-h-11 w-full items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm font-medium shadow-xs outline-none",
|
|
324
|
+
"transition-[color,box-shadow]",
|
|
325
|
+
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
326
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
327
|
+
"aria-expanded:border-ring aria-expanded:ring-[3px] aria-expanded:ring-ring/50",
|
|
328
|
+
className
|
|
329
|
+
)}
|
|
330
|
+
style={{
|
|
331
|
+
transitionDuration: "var(--duration-fast)",
|
|
332
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
<span
|
|
336
|
+
title={displayValue ?? undefined}
|
|
337
|
+
className={cn(
|
|
338
|
+
"min-w-0 flex-1 truncate text-left",
|
|
339
|
+
!displayValue && "font-normal text-muted-foreground"
|
|
340
|
+
)}
|
|
341
|
+
>
|
|
342
|
+
{displayValue ?? placeholder}
|
|
343
|
+
</span>
|
|
344
|
+
<ChevronDownIcon
|
|
345
|
+
strokeWidth={1.5}
|
|
346
|
+
aria-hidden
|
|
347
|
+
className={cn(
|
|
348
|
+
"size-4 shrink-0 text-muted-foreground transition-transform",
|
|
349
|
+
open && "rotate-180"
|
|
350
|
+
)}
|
|
351
|
+
style={{
|
|
352
|
+
transitionDuration: "var(--duration-fast)",
|
|
353
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
354
|
+
}}
|
|
355
|
+
/>
|
|
356
|
+
</button>
|
|
357
|
+
</PopoverPrimitive.Trigger>
|
|
358
|
+
|
|
359
|
+
<PopoverPrimitive.Portal>
|
|
360
|
+
<PopoverPrimitive.Content
|
|
361
|
+
ref={contentRef}
|
|
362
|
+
data-slot="tree-select-content"
|
|
363
|
+
align="start"
|
|
364
|
+
sideOffset={4}
|
|
365
|
+
onOpenAutoFocus={(e) => {
|
|
366
|
+
// Redirect Radix's default content focus to the selected (or
|
|
367
|
+
// first) tree item so keyboard users land inside the tree.
|
|
368
|
+
e.preventDefault()
|
|
369
|
+
focusInitialItem()
|
|
370
|
+
}}
|
|
371
|
+
className={cn(
|
|
372
|
+
"z-50 max-h-80 min-w-(--radix-popover-trigger-width) overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",
|
|
373
|
+
"origin-(--radix-popover-content-transform-origin)",
|
|
374
|
+
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
375
|
+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
376
|
+
portalThemeClass
|
|
377
|
+
)}
|
|
378
|
+
>
|
|
379
|
+
{renderNodes(data, 1)}
|
|
380
|
+
</PopoverPrimitive.Content>
|
|
381
|
+
</PopoverPrimitive.Portal>
|
|
382
|
+
</PopoverPrimitive.Root>
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export { TreeSelect }
|
|
@@ -48,8 +48,8 @@ const GAP_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const PADDING_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
|
|
51
|
-
sm: "px-2 py-1",
|
|
52
|
-
default: "px-2.5 py-
|
|
51
|
+
sm: "px-2 py-1.5",
|
|
52
|
+
default: "px-2.5 py-2",
|
|
53
53
|
lg: "px-3 py-2",
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -58,7 +58,12 @@ function WordRotate({
|
|
|
58
58
|
data-slot="word-rotate"
|
|
59
59
|
aria-live="polite"
|
|
60
60
|
aria-atomic="true"
|
|
61
|
-
|
|
61
|
+
// inline-block + overflow-hidden would drop the box's baseline to its
|
|
62
|
+
// bottom edge (a CSS quirk), floating the rotating word ABOVE the
|
|
63
|
+
// surrounding text. Keep overflow visible and pin vertical-align to the
|
|
64
|
+
// text baseline so the word sits on the same line as its neighbours. The
|
|
65
|
+
// slide is a small translateY + fade, so the brief overflow is invisible.
|
|
66
|
+
className={cn("inline-block align-baseline", className)}
|
|
62
67
|
>
|
|
63
68
|
{/* Visual word — aria-hidden because sr-only below carries the live region */}
|
|
64
69
|
<span
|