@@ -40,6 +40,7 @@ import { ControlItemCompBuilder } from "comps/generators/controlCompBuilder";
40
40
import { ColorControl } from "./colorControl" ;
41
41
import { StringStateControl } from "./codeStateControl" ;
42
42
import { reduceInContext } from "../utils/reduceContext" ;
43
+ import React from "react" ;
43
44
44
45
const OptionTypes = [
45
46
{
@@ -65,10 +66,13 @@ type OptionControlParam = {
65
66
title ?: string ;
66
67
// The new option's label name
67
68
newOptionLabel ?: string ;
69
+ // Whether to use flex layout (for column options)
70
+ useFlexLayout ?: boolean ;
68
71
} ;
69
72
70
73
type OptionPropertyParam = {
71
74
autoMap ?: boolean ;
75
+ useFlexLayout ?: boolean ;
72
76
} ;
73
77
74
78
interface OptionCompProperty {
@@ -176,7 +180,7 @@ export function manualOptionsControl<T extends OptionsControlType>(
176
180
itemTitle = { ( comp ) => comp . children . label . getView ( ) }
177
181
popoverTitle = { ( ) => trans ( "edit" ) }
178
182
content = { ( comp ) => {
179
- return hasPropertyView ( comp ) ? comp . propertyView ( { } ) : comp . getPropertyView ( ) ;
183
+ return hasPropertyView ( comp ) ? comp . propertyView ( { useFlexLayout : param . useFlexLayout } ) : comp . getPropertyView ( ) ;
180
184
} }
181
185
items = { manualComp . getView ( ) }
182
186
onAdd = { ( ) => {
@@ -576,7 +580,7 @@ const StyledContent = styled.div`
576
580
}
577
581
` ;
578
582
579
- const ColumnOption = new MultiCompBuilder (
583
+ let ColumnOption = new MultiCompBuilder (
580
584
{
581
585
id : valueComp < number > ( - 1 ) ,
582
586
label : StringControl ,
@@ -591,48 +595,55 @@ const ColumnOption = new MultiCompBuilder(
591
595
padding : withDefault ( StringControl , "" ) ,
592
596
} ,
593
597
( props ) => props
594
- )
595
- . setPropertyViewFn ( ( children ) => (
596
- < StyledContent >
597
- { children . minWidth . propertyView ( {
598
- label : trans ( 'responsiveLayout.minWidth' ) ,
599
- preInputNode : < StyledIcon as = { WidthIcon } title = "" /> ,
600
- placeholder : '3px' ,
601
- } ) }
602
- { children . width . propertyView ( {
603
- label : trans ( 'responsiveLayout.width' ) ,
604
- preInputNode : < StyledIcon as = { WidthIcon } title = "" /> ,
605
- placeholder : '50%' ,
606
- } ) }
607
- { children . background . propertyView ( {
608
- label : trans ( 'style.background' ) ,
609
- } ) }
610
- { children . backgroundImage . propertyView ( {
611
- label : `Background Image` ,
612
- // preInputNode: <StyledIcon as={ImageCompIcon} title="" />,
613
- placeholder : 'https://temp.im/350x400' ,
614
- } ) }
615
- { children . border . propertyView ( {
616
- label : trans ( 'style.border' )
617
- } ) }
618
- { children . radius . propertyView ( {
619
- label : trans ( 'style.borderRadius' ) ,
620
- preInputNode : < StyledIcon as = { IconRadius } title = "" /> ,
621
- placeholder : '3px' ,
622
- } ) }
623
- { children . margin . propertyView ( {
624
- label : trans ( 'style.margin' ) ,
625
- preInputNode : < StyledIcon as = { ExpandIcon } title = "" /> ,
626
- placeholder : '3px' ,
627
- } ) }
628
- { children . padding . propertyView ( {
629
- label : trans ( 'style.padding' ) ,
630
- preInputNode : < StyledIcon as = { CompressIcon } title = "" /> ,
631
- placeholder : '3px' ,
632
- } ) }
633
- </ StyledContent >
634
- ) )
635
- . build ( ) ;
598
+ ) . build ( ) ;
599
+
600
+ // Add propertyView method through class extension
601
+ ColumnOption = class extends ColumnOption implements OptionCompProperty {
602
+ propertyView ( param : OptionPropertyParam ) {
603
+ const useFlexLayout = param ?. useFlexLayout !== undefined ? param . useFlexLayout : true ;
604
+
605
+ return (
606
+ < StyledContent >
607
+ { useFlexLayout && this . children . minWidth . propertyView ( {
608
+ label : trans ( 'responsiveLayout.minWidth' ) ,
609
+ preInputNode : < StyledIcon as = { WidthIcon } title = "" /> ,
610
+ placeholder : '3px' ,
611
+ } ) }
612
+ { useFlexLayout && this . children . width . propertyView ( {
613
+ label : trans ( 'responsiveLayout.width' ) ,
614
+ preInputNode : < StyledIcon as = { WidthIcon } title = "" /> ,
615
+ placeholder : '50%' ,
616
+ } ) }
617
+ { this . children . background . propertyView ( {
618
+ label : trans ( 'style.background' ) ,
619
+ } ) }
620
+ { this . children . backgroundImage . propertyView ( {
621
+ label : `Background Image` ,
622
+ // preInputNode: <StyledIcon as={ImageCompIcon} title="" />,
623
+ placeholder : 'https://temp.im/350x400' ,
624
+ } ) }
625
+ { this . children . border . propertyView ( {
626
+ label : trans ( 'style.border' )
627
+ } ) }
628
+ { this . children . radius . propertyView ( {
629
+ label : trans ( 'style.borderRadius' ) ,
630
+ preInputNode : < StyledIcon as = { IconRadius } title = "" /> ,
631
+ placeholder : '3px' ,
632
+ } ) }
633
+ { this . children . margin . propertyView ( {
634
+ label : trans ( 'style.margin' ) ,
635
+ preInputNode : < StyledIcon as = { ExpandIcon } title = "" /> ,
636
+ placeholder : '3px' ,
637
+ } ) }
638
+ { this . children . padding . propertyView ( {
639
+ label : trans ( 'style.padding' ) ,
640
+ preInputNode : < StyledIcon as = { CompressIcon } title = "" /> ,
641
+ placeholder : '3px' ,
642
+ } ) }
643
+ </ StyledContent >
644
+ ) ;
645
+ }
646
+ } ;
636
647
637
648
export const ColumnOptionControl = manualOptionsControl ( ColumnOption , {
638
649
initOptions : [
0 commit comments