1
- import { trans } from " i18n/design" ;
2
- import React , { ReactNode , useContext } from " react" ;
3
- import styled from " styled-components" ;
4
- import { ReactComponent as Packup } from " icons/icon-Pack-up.svg" ;
5
- import { labelCss } from " ./Label" ;
6
- import { controlItem , ControlNode } from " ./control" ;
7
-
8
- const SectionItem = styled . div < { $width ?: number } > `
1
+ import { trans } from ' i18n/design' ;
2
+ import React , { ReactNode , useContext } from ' react' ;
3
+ import styled from ' styled-components' ;
4
+ import { ReactComponent as Packup } from ' icons/icon-Pack-up.svg' ;
5
+ import { labelCss } from ' ./Label' ;
6
+ import { controlItem , ControlNode } from ' ./control' ;
7
+
8
+ const SectionItem = styled . div < { $width ?: number } > `
9
9
width: ${ ( props ) => ( props . $width ? props . $width : 312 ) } px;
10
10
border-bottom: 1px solid #e1e3eb;
11
11
@@ -63,14 +63,14 @@ const SectionLabelDiv = styled.div`
63
63
}
64
64
` ;
65
65
66
- const ShowChildren = styled . div < { $show ?: string ; $noMargin ?: boolean } > `
67
- display: ${ ( props ) => props . $show || " none" } ;
66
+ const ShowChildren = styled . div < { $show ?: string ; $noMargin ?: boolean } > `
67
+ display: ${ ( props ) => props . $show || ' none' } ;
68
68
flex-direction: column;
69
69
gap: 8px;
70
70
transition: all 3s;
71
71
margin-left: ${ ( props ) => ( props . $noMargin ? 0 : 16 ) } px;
72
72
padding-bottom: 16px;
73
- padding-right: ${ ( props ) => ( props . $noMargin ? 0 : " 16px" ) } ;
73
+ padding-right: ${ ( props ) => ( props . $noMargin ? 0 : ' 16px' ) } ;
74
74
` ;
75
75
76
76
interface ISectionConfig < T > {
@@ -95,16 +95,22 @@ export interface PropertySectionContextType {
95
95
state : PropertySectionState ;
96
96
}
97
97
98
- export const PropertySectionContext = React . createContext < PropertySectionContextType > ( {
99
- toggle : ( ) => { } ,
100
- compName : "" ,
101
- state : { } ,
102
- } ) ;
98
+ export const PropertySectionContext =
99
+ React . createContext < PropertySectionContextType > ( {
100
+ toggle : ( ) => { } ,
101
+ compName : '' ,
102
+ state : { } ,
103
+ } ) ;
103
104
104
105
export const BaseSection = ( props : ISectionConfig < ReactNode > ) => {
105
- const { name } = props ;
106
- const { compName, state, toggle } = useContext ( PropertySectionContext ) ;
107
- const open = props . open !== undefined ? props . open : name ? state [ compName ] ?. [ name ] !== false : true ;
106
+ const { name} = props ;
107
+ const { compName, state, toggle} = useContext ( PropertySectionContext ) ;
108
+ const open =
109
+ props . open !== undefined
110
+ ? props . open
111
+ : name
112
+ ? state [ compName ] ?. [ name ] !== false
113
+ : true ;
108
114
109
115
// console.log("open", open, props.open);
110
116
@@ -118,43 +124,47 @@ export const BaseSection = (props: ISectionConfig<ReactNode>) => {
118
124
return (
119
125
< SectionItem $width = { props . width } style = { props . style } >
120
126
{ props . name && (
121
- < SectionLabelDiv onClick = { handleToggle } className = { " section-header" } >
127
+ < SectionLabelDiv onClick = { handleToggle } className = { ' section-header' } >
122
128
< SectionLabel > { props . name } </ SectionLabel >
123
- < div style = { { display : " flex" } } >
129
+ < div style = { { display : ' flex' } } >
124
130
{ open && props . additionalButton }
125
- < PackupIcon deg = { open ? " rotate(0deg)" : " rotate(180deg)" } />
131
+ < PackupIcon deg = { open ? ' rotate(0deg)' : ' rotate(180deg)' } />
126
132
</ div >
127
133
</ SectionLabelDiv >
128
134
) }
129
- < ShowChildren $show = { open ? " flex" : " none" } $noMargin = { props . noMargin } >
135
+ < ShowChildren $show = { open ? ' flex' : ' none' } $noMargin = { props . noMargin } >
130
136
{ props . children }
131
137
</ ShowChildren >
132
138
</ SectionItem >
133
139
) ;
134
140
} ;
135
141
136
142
export function Section ( props : ISectionConfig < ControlNode > ) {
137
- return controlItem ( { filterText : props . name , searchChild : true } , < BaseSection { ...props } /> ) ;
143
+ return controlItem (
144
+ { filterText : props . name , searchChild : true } ,
145
+ < BaseSection { ...props } />
146
+ ) ;
138
147
}
139
148
140
149
// common section names
141
150
export const sectionNames = {
142
- basic : trans ( "prop.basic" ) ,
143
- interaction : trans ( "prop.interaction" ) ,
144
- advanced : trans ( "prop.advanced" ) ,
145
- validation : trans ( "prop.validation" ) ,
146
- layout : trans ( "prop.layout" ) ,
147
- style : trans ( "prop.style" ) ,
148
- labelStyle :trans ( "prop.labelStyle" ) ,
149
- data : trans ( "prop.data" ) ,
150
- meetings : trans ( "prop.meetings" ) , // added by Falk Wolsky
151
- field : trans ( "prop.field" ) ,
152
- inputFieldStyle :trans ( "prop.inputFieldStyle" ) ,
153
- avatarStyle :trans ( "prop.avatarStyle" ) ,
154
- captionStyle :trans ( "prop.captionStyle" ) ,
155
- startButtonStyle :trans ( "prop.startButtonStyle" ) ,
156
- resetButtonStyle :trans ( "prop.resetButtonStyle" ) ,
157
- headerStyle :trans ( "prop.headerStyle" ) ,
158
- bodyStyle :trans ( "prop.bodyStyle" ) ,
159
- badgeStyle :trans ( "prop.badgeStyle" ) ,
151
+ basic : trans ( 'prop.basic' ) ,
152
+ interaction : trans ( 'prop.interaction' ) ,
153
+ advanced : trans ( 'prop.advanced' ) ,
154
+ validation : trans ( 'prop.validation' ) ,
155
+ layout : trans ( 'prop.layout' ) ,
156
+ style : trans ( 'prop.style' ) ,
157
+ labelStyle : trans ( 'prop.labelStyle' ) ,
158
+ animationStyle : trans ( 'prop.animationStyle' ) ,
159
+ data : trans ( 'prop.data' ) ,
160
+ meetings : trans ( 'prop.meetings' ) , // added by Falk Wolsky
161
+ field : trans ( 'prop.field' ) ,
162
+ inputFieldStyle : trans ( 'prop.inputFieldStyle' ) ,
163
+ avatarStyle : trans ( 'prop.avatarStyle' ) ,
164
+ captionStyle : trans ( 'prop.captionStyle' ) ,
165
+ startButtonStyle : trans ( 'prop.startButtonStyle' ) ,
166
+ resetButtonStyle : trans ( 'prop.resetButtonStyle' ) ,
167
+ headerStyle : trans ( 'prop.headerStyle' ) ,
168
+ bodyStyle : trans ( 'prop.bodyStyle' ) ,
169
+ badgeStyle : trans ( 'prop.badgeStyle' ) ,
160
170
} ;
0 commit comments