11import {
22 container ,
33 dropzone ,
4- RowLayoutProps ,
4+ rowLayout ,
55 selectable ,
66 StructurePreviewProps ,
77 text
@@ -133,6 +133,8 @@ export function getProperties(
133133}
134134
135135export const getPreview = ( values : DatagridPreviewProps , isDarkMode : boolean ) : StructurePreviewProps => {
136+ const modeColor = ( colorDark : string , colorLight : string ) => ( isDarkMode ? colorDark : colorLight ) ;
137+
136138 const hasColumns = values . columns && values . columns . length > 0 ;
137139 const columnProps : ColumnsPreviewType [ ] = hasColumns
138140 ? values . columns
@@ -156,19 +158,15 @@ export const getPreview = (values: DatagridPreviewProps, isDarkMode: boolean): S
156158 wrapText : false
157159 }
158160 ] ;
159- const columns : RowLayoutProps = {
160- type : "RowLayout" ,
161- columnSize : "fixed" ,
162- children : columnProps . map ( column =>
161+ const columns = rowLayout ( {
162+ columnSize : "fixed"
163+ } ) (
164+ ... columnProps . map ( column =>
163165 container ( {
164166 borders : true ,
165167 grow : column . width === "manual" && column . size ? column . size : 1 ,
166168 backgroundColor :
167- values . columnsHidable && column . hidable === "hidden"
168- ? isDarkMode
169- ? "#3E3E3E"
170- : "#F5F5F5"
171- : undefined
169+ values . columnsHidable && column . hidable === "hidden" ? modeColor ( "#3E3E3E" , "#F5F5F5" ) : undefined
172170 } ) (
173171 column . showContentAs === "customContent"
174172 ? dropzone ( ) ( column . content )
@@ -183,29 +181,26 @@ export const getPreview = (values: DatagridPreviewProps, isDarkMode: boolean): S
183181 )
184182 )
185183 )
186- } ;
187- const titleHeader : RowLayoutProps = {
188- type : "RowLayout" ,
189- columnSize : "fixed" ,
190- backgroundColor : isDarkMode ? "#3B5C8F" : "#DAEFFB" ,
191- borders : true ,
192- borderWidth : 1 ,
193- children : [
194- container ( {
195- padding : 4
196- } ) ( text ( { fontColor : isDarkMode ? "#6DB1FE" : "#2074C8" } ) ( "Data grid 2" ) )
197- ]
198- } ;
199- const headerFilters = {
200- type : "RowLayout" ,
184+ ) ;
185+ const titleHeader = rowLayout ( {
201186 columnSize : "fixed" ,
187+ backgroundColor : modeColor ( "#3B5C8F" , "#DAEFFB" ) ,
202188 borders : true ,
203- children : [ dropzone ( dropzone . placeholder ( "Place filter widget(s) here" ) ) ( values . filtersPlaceholder ) ]
204- } as RowLayoutProps ;
205- const headers : RowLayoutProps = {
206- type : "RowLayout" ,
189+ borderWidth : 1
190+ } ) (
191+ container ( {
192+ padding : 4
193+ } ) ( text ( { fontColor : modeColor ( "#6DB1FE" , "#2074C8" ) } ) ( "Data grid 2" ) )
194+ ) ;
195+ const headerFilters = rowLayout ( {
207196 columnSize : "fixed" ,
208- children : columnProps . map ( column => {
197+ borders : true
198+ } ) ( dropzone ( dropzone . placeholder ( "Place filter widget(s) here" ) ) ( values . filtersPlaceholder ) ) ;
199+
200+ const headers = rowLayout ( {
201+ columnSize : "fixed"
202+ } ) (
203+ ...columnProps . map ( column => {
209204 const isColumnHidden = values . columnsHidable && column . hidable === "hidden" ;
210205 const content = container ( {
211206 borders : true ,
@@ -215,13 +210,7 @@ export const getPreview = (values: DatagridPreviewProps, isDarkMode: boolean): S
215210 ? column . size
216211 : 1
217212 : undefined ,
218- backgroundColor : isColumnHidden
219- ? isDarkMode
220- ? "#4F4F4F"
221- : "#DCDCDC"
222- : isDarkMode
223- ? "#3E3E3E"
224- : "#F5F5F5"
213+ backgroundColor : isColumnHidden ? modeColor ( "#4F4F4F" , "#DCDCDC" ) : modeColor ( "#3E3E3E" , "#F5F5F5" )
225214 } ) (
226215 container ( {
227216 padding : 8
@@ -232,12 +221,8 @@ export const getPreview = (values: DatagridPreviewProps, isDarkMode: boolean): S
232221 fontColor : column . header
233222 ? undefined
234223 : isColumnHidden
235- ? isDarkMode
236- ? "#4F4F4F"
237- : "#DCDCDC"
238- : isDarkMode
239- ? "#3E3E3E"
240- : "#F5F5F5"
224+ ? modeColor ( "#4F4F4F" , "#DCDCDC" )
225+ : modeColor ( "#3E3E3E" , "#F5F5F5" )
241226 } ) ( column . header ? column . header : "Header" )
242227 ) ,
243228 ...( hasColumns && values . columnsFilterable
@@ -250,22 +235,17 @@ export const getPreview = (values: DatagridPreviewProps, isDarkMode: boolean): S
250235 )
251236 : content ;
252237 } )
253- } ;
238+ ) ;
254239 const footer =
255240 values . showEmptyPlaceholder === "custom"
256241 ? [
257- {
258- type : "RowLayout" ,
242+ rowLayout ( {
259243 columnSize : "fixed" ,
260- borders : true ,
261- children : [
262- dropzone ( dropzone . placeholder ( "Empty list message: Place widgets here" ) ) (
263- values . emptyPlaceholder
264- )
265- ]
266- } as RowLayoutProps
244+ borders : true
245+ } ) ( dropzone ( dropzone . placeholder ( "Empty list message: Place widgets here" ) ) ( values . emptyPlaceholder ) )
267246 ]
268247 : [ ] ;
248+
269249 return container ( ) (
270250 titleHeader ,
271251 ...( values . showHeaderFilters && values . filterList . length > 0 ? [ headerFilters ] : [ ] ) ,
0 commit comments