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,22 +95,16 @@ export interface PropertySectionContextType {
95
95
state : PropertySectionState ;
96
96
}
97
97
98
- export const PropertySectionContext =
99
- React . createContext < PropertySectionContextType > ( {
100
- toggle : ( ) => { } ,
101
- compName : '' ,
102
- state : { } ,
103
- } ) ;
98
+ export const PropertySectionContext = React . createContext < PropertySectionContextType > ( {
99
+ toggle : ( ) => { } ,
100
+ compName : "" ,
101
+ state : { } ,
102
+ } ) ;
104
103
105
104
export const BaseSection = ( props : ISectionConfig < ReactNode > ) => {
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 ;
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 ;
114
108
115
109
// console.log("open", open, props.open);
116
110
@@ -124,47 +118,44 @@ export const BaseSection = (props: ISectionConfig<ReactNode>) => {
124
118
return (
125
119
< SectionItem $width = { props . width } style = { props . style } >
126
120
{ props . name && (
127
- < SectionLabelDiv onClick = { handleToggle } className = { ' section-header' } >
121
+ < SectionLabelDiv onClick = { handleToggle } className = { " section-header" } >
128
122
< SectionLabel > { props . name } </ SectionLabel >
129
- < div style = { { display : ' flex' } } >
123
+ < div style = { { display : " flex" } } >
130
124
{ open && props . additionalButton }
131
- < PackupIcon deg = { open ? ' rotate(0deg)' : ' rotate(180deg)' } />
125
+ < PackupIcon deg = { open ? " rotate(0deg)" : " rotate(180deg)" } />
132
126
</ div >
133
127
</ SectionLabelDiv >
134
128
) }
135
- < ShowChildren $show = { open ? ' flex' : ' none' } $noMargin = { props . noMargin } >
129
+ < ShowChildren $show = { open ? " flex" : " none" } $noMargin = { props . noMargin } >
136
130
{ props . children }
137
131
</ ShowChildren >
138
132
</ SectionItem >
139
133
) ;
140
134
} ;
141
135
142
136
export function Section ( props : ISectionConfig < ControlNode > ) {
143
- return controlItem (
144
- { filterText : props . name , searchChild : true } ,
145
- < BaseSection { ...props } />
146
- ) ;
137
+ return controlItem ( { filterText : props . name , searchChild : true } , < BaseSection { ...props } /> ) ;
147
138
}
148
139
149
140
// common section names
150
141
export const sectionNames = {
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' ) ,
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
+ animationStyle :trans ( " prop.animationStyle" ) ,
150
+ data : trans ( " prop.data" ) ,
151
+ meetings : trans ( " prop.meetings" ) , // added by Falk Wolsky
152
+ field : trans ( " prop.field" ) ,
153
+ inputFieldStyle :trans ( " prop.inputFieldStyle" ) ,
154
+ avatarStyle :trans ( " prop.avatarStyle" ) ,
155
+ captionStyle :trans ( " prop.captionStyle" ) ,
156
+ startButtonStyle :trans ( " prop.startButtonStyle" ) ,
157
+ resetButtonStyle :trans ( " prop.resetButtonStyle" ) ,
158
+ headerStyle :trans ( " prop.headerStyle" ) ,
159
+ bodyStyle :trans ( " prop.bodyStyle" ) ,
160
+ badgeStyle :trans ( " prop.badgeStyle" ) ,
170
161
} ;
0 commit comments