1
- import { html } from '@pionjs/pion' ;
2
1
import { layout } from './layout' ;
3
2
4
- const
5
- _toCss = ( layout , config ) =>
6
- config
7
- . map ( ( item , index ) => {
8
- const width = layout [ index ] ;
9
- return width == null || width === 0
10
- ? `cosmoz-omnitable-resize-nub[name="${ item . name } "], .cell[name="${ item . name } "]{display:none}`
11
- : `.cell[name="${ item . name } "]{width: ${ width } px;padding: 0 min(3px, ${ width / 2 } px)}` ;
12
- } )
13
- . join ( '\n' ) ;
3
+ const _toCss = ( layout , config ) =>
4
+ config
5
+ . map ( ( item , index ) => {
6
+ const width = layout [ index ] ;
7
+ return width == null || width === 0
8
+ ? `cosmoz-omnitable-resize-nub[name="${ item . name } "], .cell[name="${ item . name } "]{display:none}`
9
+ : `.cell[name="${ item . name } "]{width: ${ Math . floor (
10
+ width ,
11
+ ) } px;padding: 0 min(3px, ${ width / 2 } px)}`;
12
+ } )
13
+ . join ( '\n' ) ;
14
14
15
- export const
16
- computeLayout = ( _columnConfigs , canvasWidth , numColumns ) => {
17
- const columnConfigs = _columnConfigs . filter ( c => ! c . hidden ) ,
15
+ export const computeLayout = ( _columnConfigs , canvasWidth , numColumns ) => {
16
+ const columnConfigs = _columnConfigs . filter ( ( c ) => ! c . hidden ) ,
18
17
totalWidths = columnConfigs . reduce ( ( sum , { width } ) => sum + width , 0 ) ;
19
18
20
19
if ( columnConfigs . length > 1 && totalWidths > canvasWidth ) {
@@ -26,8 +25,11 @@ export const
26
25
// as the column configs might now be in a different order than displayed
27
26
// due to priority settings
28
27
const lastColumnIndex = columnConfigs . reduce (
29
- ( [ max , maxIndex ] , column , index ) => [ Math . max ( max , column . index ) , column . index > max ? index : maxIndex ] ,
30
- [ - 1 , - 1 ]
28
+ ( [ max , maxIndex ] , column , index ) => [
29
+ Math . max ( max , column . index ) ,
30
+ column . index > max ? index : maxIndex ,
31
+ ] ,
32
+ [ - 1 , - 1 ] ,
31
33
) [ 1 ] ;
32
34
33
35
// force the last visible column to flex
@@ -43,6 +45,4 @@ export const
43
45
} , new Array ( numColumns ) . fill ( undefined ) ) ;
44
46
} ,
45
47
toCss = ( layout , config ) =>
46
- layout . length === 0
47
- ? html `< style > .cell {display : none;}</ style > `
48
- : html `< style > ${ _toCss ( layout , config ) } </ style > ` ;
48
+ layout . length === 0 ? '.cell {display: none;}' : _toCss ( layout , config ) ;
0 commit comments