33import { Sidebar , SidebarContent } from "@/components/ui/sidebar" ;
44
55import { useFormBuilderStore } from "@/stores/form-builder-store" ;
6- import { ChevronDown } from "lucide-react" ;
6+ import { ChevronDown , ChevronUp } from "lucide-react" ;
77import {
88 Collapsible ,
99 CollapsibleContent ,
1010 CollapsibleTrigger ,
1111} from "@/components/ui/collapsible" ;
1212import { getComponentViews } from "@/config/available-components" ;
13- import { ReactNode } from "react" ;
13+ import { ReactNode , useState } from "react" ;
1414
1515interface PropertySectionProps {
1616 title : string ;
1717 children : ReactNode ;
18+ isOpen : boolean ;
1819}
1920
20- function PropertySection ( { title, children } : PropertySectionProps ) {
21+ function PropertySection ( { title, children, isOpen } : PropertySectionProps ) {
22+ const [ isOpenState , setIsOpenState ] = useState ( isOpen ) ;
2123 return (
22- < Collapsible className = "border-b" defaultOpen = { true } >
23- < CollapsibleTrigger className = "flex items-center justify-between w-full p-4 cursor-pointer" >
24+ < Collapsible className = "border-b" defaultOpen = { isOpenState } >
25+ < CollapsibleTrigger
26+ className = "flex items-center justify-between w-full p-4 cursor-pointer"
27+ onClick = { ( ) => setIsOpenState ( ! isOpenState ) }
28+ >
2429 < span className = "font-normal text-sm" > { title } </ span >
25- < ChevronDown className = "h-4 w-4" />
30+ { isOpenState ? (
31+ < ChevronUp className = "h-4 w-4" />
32+ ) : (
33+ < ChevronDown className = "h-4 w-4" />
34+ ) }
2635 </ CollapsibleTrigger >
2736 < CollapsibleContent className = "p-4 pt-0 space-y-2" >
2837 { children }
@@ -32,14 +41,12 @@ function PropertySection({ title, children }: PropertySectionProps) {
3241}
3342
3443const PROPERTY_SECTIONS = [
35- { key : "options" , title : "Options" } ,
36- { key : "base" , title : "Base" } ,
37- { key : "button" , title : "Button" } ,
38- { key : "input" , title : "Input" } ,
39- { key : "label" , title : "Label" } ,
40- { key : "grid" , title : "Grid layout" } ,
41- { key : "html" , title : "HTML" } ,
42- { key : "validation" , title : "Validation" } ,
44+ { key : "options" , title : "Options" , isOpen : true } ,
45+ { key : "input" , title : "Input" , isOpen : true } ,
46+ { key : "label" , title : "Label" , isOpen : true } ,
47+ { key : "grid" , title : "Grid layout" , isOpen : false } ,
48+ { key : "html" , title : "HTML" , isOpen : false } ,
49+ { key : "validation" , title : "Validation" , isOpen : false } ,
4350] as const ;
4451
4552export function SidebarRight ( ) {
@@ -69,14 +76,12 @@ export function SidebarRight() {
6976 } else {
7077 sidebarContent = (
7178 < div >
72- < div className = "p-4 border-b" > Properties</ div >
73-
74- { PROPERTY_SECTIONS . map ( ( { key, title } ) => {
79+ { PROPERTY_SECTIONS . map ( ( { key, title, isOpen } ) => {
7580 const content = componentViews . renderDesignProperties [ key ] ;
7681 if ( ! content ) return null ;
7782
7883 return (
79- < PropertySection key = { key } title = { title } >
84+ < PropertySection key = { key } title = { title } isOpen = { isOpen } >
8085 { content }
8186 </ PropertySection >
8287 ) ;
0 commit comments