@@ -16,23 +16,25 @@ import {compCheckbox, logger} from './figma-main';
1616import { FigmaCheckbox } from './figma-checkbox' ;
1717import { FigmaValue } from './figma-value' ;
1818
19+ const supportedStatuses = [ "Open" , "Unpaid" , "Paid" , "New" , "In Process" , "Info Requested" , "On Hold" ] as const ;
20+
1921export class FigmaRow extends FigmaNode {
2022
2123 static rowTypes = new Map < QPFieldElementType , string > ( [
2224 [ QPFieldElementType . Currency , 'Currency' ] ,
2325 [ QPFieldElementType . CheckBox , 'Checkbox' ] ,
2426 [ QPFieldElementType . DateTimeEdit , 'Date' ] ,
25- [ QPFieldElementType . DropDown , 'Label + Field' ] ,
26- [ QPFieldElementType . TextEditor , 'Label + Field' ] ,
27- [ QPFieldElementType . Selector , 'Label + Field' ] ,
28- [ QPFieldElementType . NumberEditor , 'Label + Number Field' ] ,
29- [ QPFieldElementType . Status , 'Label + Field' ] ,
30- [ QPFieldElementType . Button , 'Button' ] ,
31- [ QPFieldElementType . RadioButton , 'Radio Button ' ] ,
32- [ QPFieldElementType . MultilineTextEditor , 'Label + Text Area' ] ,
33- [ QPFieldElementType . HorizontalContainer , 'Label + Field' ] ,
34- [ QPFieldElementType . LabelFieldCheckbox , 'Label + Field + Checkbox' ] ,
35- [ QPFieldElementType . LabelFieldButton , 'Label + Field + Button' ]
27+ [ QPFieldElementType . DropDown , 'Field' ] ,
28+ [ QPFieldElementType . TextEditor , 'Field' ] ,
29+ [ QPFieldElementType . Selector , 'Field' ] ,
30+ [ QPFieldElementType . NumberEditor , 'Number Field' ] ,
31+ [ QPFieldElementType . Status , 'Field' ] ,
32+ [ QPFieldElementType . Button , 'Button Left ' ] ,
33+ [ QPFieldElementType . RadioButton , 'Radiobutton ' ] ,
34+ [ QPFieldElementType . MultilineTextEditor , 'Text Area' ] ,
35+ [ QPFieldElementType . HorizontalContainer , 'Field' ] ,
36+ [ QPFieldElementType . LabelFieldCheckbox , 'Field + Checkbox' ] ,
37+ [ QPFieldElementType . LabelFieldButton , 'Field + Button' ]
3638 ] ) ;
3739
3840 constructor ( field : QPField , name : string , parent : FigmaNode | null = null ) {
@@ -61,7 +63,13 @@ export class FigmaRow extends FigmaNode {
6163 logger . Warn ( `${ field . ElementType } row type is not supported` , this . acuElement . Id , field ) ;
6264 elementType = QPFieldElementType . TextEditor ;
6365 }
64- this . componentProperties [ 'Type' ] = FigmaRow . rowTypes . get ( elementType ) ! ;
66+
67+ if ( elementType != QPFieldElementType . HorizontalContainer ) {
68+ //this.componentProperties['Type'] = FigmaRow.rowTypes.get(elementType)!;
69+ let rightContentField = new FigmaNode ( '👉 RIGHT_CONTENT' ) ;
70+ rightContentField . componentProperties [ 'Property' ] = FigmaRow . rowTypes . get ( elementType ) ! ;
71+ this . children . push ( rightContentField ) ;
72+ }
6573
6674 let labelField ;
6775 let valueField ;
@@ -73,12 +81,14 @@ export class FigmaRow extends FigmaNode {
7381 typedField = field as QPFieldCheckbox ;
7482 valueField = new FigmaCheckbox ( typedField , 'Checkbox' ) ;
7583 this . children . push ( valueField ) ;
84+ labelField = new FigmaNode ( '👉 LEFT_CONTENT' ) ;
85+ labelField . componentProperties [ 'Show Value#9992:0' ] = false ;
86+ this . children . push ( labelField ) ;
7687 break ;
7788 case QPFieldElementType . RadioButton :
78- this . componentProperties [ 'Label Position' ] = 'Top' ;
79- this . componentProperties [ 'Label Length' ] = 's' ;
89+ this . componentProperties [ 'Show LeftContent#9784:31' ] = false ;
8090 typedField = field as QPFieldRadioButton ;
81- valueField = new FigmaNode ( 'Radiobuttons ' ) ;
91+ valueField = new FigmaNode ( 'Radio Button ' ) ;
8292 valueField . componentProperties [ 'Name#8227:0' ] = typedField . RadioName ?? '' ;
8393 valueField . componentProperties [ 'Checked' ] = typedField . Checked ? 'True' : 'False' ;
8494 this . children . push ( valueField ) ;
@@ -89,6 +99,9 @@ export class FigmaRow extends FigmaNode {
8999 valueField . componentProperties [ 'Type' ] = 'Secondary' ;
90100 valueField . componentProperties [ 'Value ▶#3133:332' ] = typedField . Value ?? '' ;
91101 this . children . push ( valueField ) ;
102+ labelField = new FigmaNode ( '👉 LEFT_CONTENT' ) ;
103+ labelField . componentProperties [ 'Show Value#9992:0' ] = false ;
104+ this . children . push ( labelField ) ;
92105 break ;
93106 case QPFieldElementType . MultilineTextEditor :
94107 typedField = field as QPFieldMultilineTextEditor ;
@@ -112,14 +125,17 @@ export class FigmaRow extends FigmaNode {
112125 this . children . push ( valueField ) ;
113126
114127 const status = new FigmaNode ( 'Status' ) ;
115- status . componentProperties [ 'Status' ] = typedField . Value ?? '' ;
128+ const value = typedField . Value ?? supportedStatuses [ 0 ] ;
129+ status . componentProperties [ 'Status' ] = supportedStatuses . includes ( value as typeof supportedStatuses [ number ] )
130+ ? value
131+ : supportedStatuses [ 0 ] ;
116132 this . children . push ( status ) ;
117133 }
118134 break ;
119135 case QPFieldElementType . HorizontalContainer : {
120136 let width = 0 ;
121137 const itemSpacing = 8 ;
122- const labelWisth = 200 ;
138+ const labelWidth = 200 ;
123139 if ( parent ) {
124140 parent . detach = true ;
125141 width = parent . width ;
@@ -139,7 +155,7 @@ export class FigmaRow extends FigmaNode {
139155 labelField . componentProperties [ 'Label Value ▶#3141:62' ] = '' ;
140156 this . children . push ( labelField ) ;
141157 if ( width > 0 )
142- width = ( width - labelWisth ) / typedField . Children . length - itemSpacing ;
158+ width = ( width - labelWidth ) / typedField . Children . length - itemSpacing ;
143159
144160 this . children . push ( container ) ;
145161 let childNumber = 1 ;
0 commit comments