@@ -4,6 +4,7 @@ import type * as React from 'react'
44import { cn } from '../../lib/cn'
55import { handleKeyboardActivation } from '../../lib/keyboard'
66import { Expandable , ExpandableContent } from '../expandable/expandable'
7+ import { FieldCardContent , FieldCardFrame } from '../field-card/field-card'
78import { OverflowText , overflowTextClipClass } from '../overflow-text/overflow-text'
89
910export interface CollapsibleCardProps
@@ -28,6 +29,7 @@ export interface CollapsibleCardProps
2829 * A collapsible field card: a `--surface-4` header (click / keyboard to toggle)
2930 * with a fade-clipped title + optional badge, over a `--surface-2` body. Shared by
3031 * the workflow input-mapping rows and the enrichment output-column config.
32+ * Its frame and body are also used by the always-open FieldCard.
3133 *
3234 * @example
3335 * <CollapsibleCard title='Condition' collapsed={collapsed} onToggleCollapse={toggle}
@@ -47,74 +49,62 @@ export function CollapsibleCard({
4749 className,
4850 ...props
4951} : CollapsibleCardProps ) {
50- const content = (
51- < div
52- { ...contentProps }
53- className = { cn (
54- 'flex flex-col gap-2 rounded-b-[4px] border-[var(--border-1)] border-t bg-[var(--surface-2)] px-2.5 pt-1.5 pb-2.5' ,
55- contentProps ?. className
56- ) }
57- >
58- { children }
59- </ div >
60- )
52+ const content = < FieldCardContent { ...contentProps } > { children } </ FieldCardContent >
6153 return (
62- < div
54+ < FieldCardFrame
6355 { ...props }
64- className = { cn (
65- 'rounded-sm border border-[var(--border-1)]' ,
66- collapsed ? 'overflow-hidden' : 'overflow-visible' ,
67- className
68- ) }
69- >
70- < div className = 'flex items-center justify-between rounded-t-[4px] bg-[var(--surface-4)]' >
71- < div
72- role = 'button'
73- tabIndex = { 0 }
74- aria-expanded = { ! collapsed }
75- aria-controls = { contentProps ?. id }
76- className = { cn (
77- 'flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-2.5 py-[5px]' ,
78- actions && 'pr-2'
79- ) }
80- onClick = { onToggleCollapse }
81- onKeyDown = { ( event ) => {
82- if ( event . target !== event . currentTarget ) return
83- handleKeyboardActivation ( event , onToggleCollapse )
84- } }
85- >
86- { typeof title === 'string' || typeof title === 'number' ? (
87- < OverflowText
88- label = { String ( title ) }
89- className = 'flex-1 text-[var(--text-tertiary)] text-sm'
90- focusTarget = 'nearest-interactive'
91- />
92- ) : (
93- < span
94- className = { cn ( overflowTextClipClass , 'flex-1 text-[var(--text-tertiary)] text-sm' ) }
95- >
96- { title }
97- </ span >
98- ) }
99- { badge }
100- </ div >
101- { actions && (
56+ className = { cn ( collapsed ? 'overflow-hidden' : 'overflow-visible' , className ) }
57+ header = {
58+ < >
10259 < div
103- role = 'presentation'
104- className = 'flex shrink-0 items-center gap-2 py-[5px] pr-2.5'
105- onClick = { ( event ) => event . stopPropagation ( ) }
60+ role = 'button'
61+ tabIndex = { 0 }
62+ aria-expanded = { ! collapsed }
63+ aria-controls = { contentProps ?. id }
64+ className = { cn (
65+ 'flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-2.5 py-[5px]' ,
66+ actions && 'pr-2'
67+ ) }
68+ onClick = { onToggleCollapse }
69+ onKeyDown = { ( event ) => {
70+ if ( event . target !== event . currentTarget ) return
71+ handleKeyboardActivation ( event , onToggleCollapse )
72+ } }
10673 >
107- { actions }
74+ { typeof title === 'string' || typeof title === 'number' ? (
75+ < OverflowText
76+ label = { String ( title ) }
77+ className = 'flex-1 text-[var(--text-tertiary)] text-sm'
78+ focusTarget = 'nearest-interactive'
79+ />
80+ ) : (
81+ < span
82+ className = { cn ( overflowTextClipClass , 'flex-1 text-[var(--text-tertiary)] text-sm' ) }
83+ >
84+ { title }
85+ </ span >
86+ ) }
87+ { badge }
10888 </ div >
109- ) }
110- </ div >
89+ { actions && (
90+ < div
91+ role = 'presentation'
92+ className = 'flex shrink-0 items-center gap-2 py-[5px] pr-2.5'
93+ onClick = { ( event ) => event . stopPropagation ( ) }
94+ >
95+ { actions }
96+ </ div >
97+ ) }
98+ </ >
99+ }
100+ >
111101 { animated ? (
112102 < Expandable expanded = { ! collapsed } >
113103 < ExpandableContent > { content } </ ExpandableContent >
114104 </ Expandable >
115105 ) : (
116106 ! collapsed && content
117107 ) }
118- </ div >
108+ </ FieldCardFrame >
119109 )
120110}
0 commit comments