| 136 | }; |
| 137 | |
| 138 | function CardStackHeader({ className, children, rightSlot, ...props }: CardStackHeaderProps) { |
| 139 | const { collapsible, searchable } = React.useContext(CardStackContext); |
| 140 | |
| 141 | const title = <span className="min-w-0 flex-1 truncate">{children}</span>; |
| 142 | |
| 143 | if (collapsible) { |
| 144 | return ( |
| 145 | <CollapsiblePrimitive.Trigger |
| 146 | data-slot="card-stack-header" |
| 147 | className={cn( |
| 148 | "group/card-stack-header flex w-full items-center justify-between gap-4 px-4 py-3 text-left text-sm font-medium outline-none transition-[background-color] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] hover:bg-accent/40 focus-visible:bg-accent/40", |
| 149 | className, |
| 150 | )} |
| 151 | {...props} |
| 152 | > |
| 153 | {title} |
| 154 | {searchable && <CardStackSearchInput />} |
| 155 | {rightSlot} |
| 156 | <PlusIcon |
| 157 | aria-hidden |
| 158 | className="size-4 shrink-0 text-muted-foreground transition-transform duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] group-data-[state=open]/card-stack-header:rotate-45" |
| 159 | /> |
| 160 | </CollapsiblePrimitive.Trigger> |
| 161 | ); |
| 162 | } |
| 163 | |
| 164 | return ( |
| 165 | <div |
| 166 | data-slot="card-stack-header" |
| 167 | className={cn( |
| 168 | "flex w-full items-center justify-between gap-4 px-4 py-3 text-sm font-medium", |
| 169 | className, |
| 170 | )} |
| 171 | {...props} |
| 172 | > |
| 173 | {title} |
| 174 | {searchable && <CardStackSearchInput />} |
| 175 | {rightSlot} |
| 176 | </div> |
| 177 | ); |
| 178 | } |
| 179 | |
| 180 | function CardStackHeaderAction({ className, ...props }: React.ComponentProps<"div">) { |
| 181 | return ( |