File tree Expand file tree Collapse file tree
packages/pluggableWidgets/repeater-native Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { StructurePreviewProps , topBar } from "@mendix/piw-utils-internal" ;
1+ import { StructurePreviewProps } from "@mendix/piw-utils-internal" ;
22
33import { RepeaterPreviewProps } from "../typings/RepeaterProps" ;
44
55export function getPreview ( values : RepeaterPreviewProps , isDarkMode : boolean ) : StructurePreviewProps {
6- return topBar (
7- "Repeater" ,
8- {
9- type : "DropZone" ,
10- placeholder : "Content" ,
11- property : values . content
12- } ,
13- isDarkMode
14- ) ;
6+ return {
7+ type : "Container" ,
8+ borders : true ,
9+ children : [
10+ {
11+ type : "Container" ,
12+ backgroundColor : isDarkMode ? "#454545" : "#F5F5F5" ,
13+ children : [
14+ {
15+ type : "Container" ,
16+ padding : 4 ,
17+ children : [
18+ {
19+ type : "Text" ,
20+ fontColor : isDarkMode ? "#DEDEDE" : "#6B707B" ,
21+ content : "Repeater"
22+ }
23+ ]
24+ }
25+ ]
26+ } ,
27+ {
28+ type : "DropZone" ,
29+ placeholder : "Content" ,
30+ property : values . content
31+ } ,
32+ {
33+ type : "Container" ,
34+ borders : true ,
35+ children : [
36+ {
37+ type : "DropZone" ,
38+ placeholder : "Content when Empty" ,
39+ property : values . contentEmpty
40+ }
41+ ]
42+ }
43+ ]
44+ } ;
1545}
Original file line number Diff line number Diff line change @@ -7,19 +7,16 @@ import { mergeNativeStyles } from "@mendix/pluggable-widgets-tools";
77
88export function Repeater ( props : RepeaterProps < RepeaterStyle > ) : ReactElement {
99 const styles = mergeNativeStyles ( defaultRepeaterStyle , props . style ) ;
10- if (
11- props . datasource . status === ValueStatus . Loading ||
12- ! props . datasource . items ||
13- props . datasource . items . length === 0
14- ) {
10+ if ( props . datasource . status === ValueStatus . Loading || ! props . datasource . items ) {
1511 return < View /> ;
1612 }
17-
13+ const contentEmpty = props . datasource . items . length === 0 ? props . contentEmpty : null ;
1814 return (
1915 < View style = { styles . container } >
20- { props . datasource . items ? .map ( ( item , index ) => (
16+ { props . datasource . items . map ( ( item , index ) => (
2117 < Fragment key = { `item_${ index } ` } > { props . content . get ( item ) } </ Fragment >
2218 ) ) }
19+ { contentEmpty }
2320 </ View >
2421 ) ;
2522}
Original file line number Diff line number Diff line change 1414 <property key =" content" type =" widgets" dataSource =" datasource" >
1515 <caption >Content</caption >
1616 <description />
17+ </property >
18+ <property key =" contentEmpty" type =" widgets" required =" false" >
19+ <caption >Content empty</caption >
20+ <description />
1721 </property >
1822 </propertyGroup >
1923 <propertyGroup caption =" Common" >
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export interface RepeaterProps<Style> {
1111 style : Style [ ] ;
1212 datasource : ListValue ;
1313 content : ListWidgetValue ;
14+ contentEmpty ?: ReactNode ;
1415}
1516
1617export interface RepeaterPreviewProps {
@@ -26,4 +27,5 @@ export interface RepeaterPreviewProps {
2627 translate : ( text : string ) => string ;
2728 datasource : { } | { caption : string } | { type : string } | null ;
2829 content : { widgetCount : number ; renderer : ComponentType < { children : ReactNode ; caption ?: string } > } ;
30+ contentEmpty : { widgetCount : number ; renderer : ComponentType < { caption ?: string } > } ;
2931}
You can’t perform that action at this time.
0 commit comments