@@ -74,6 +74,10 @@ export default class ControlledTable extends Component<ControlledTableProps> {
74
74
this . props . setProps ( { active_cell : this . props . selected_cell [ 0 ] } ) ;
75
75
}
76
76
77
+ this . handleResize ( ) ;
78
+ }
79
+
80
+ componentWillMount ( ) {
77
81
// Fallback method for paste handling in Chrome
78
82
// when no input element has focused inside the table
79
83
window . addEventListener ( 'resize' , this . handleResize ) ;
@@ -87,14 +91,6 @@ export default class ControlledTable extends Component<ControlledTableProps> {
87
91
document . removeEventListener ( 'paste' , this . handlePaste ) ;
88
92
}
89
93
90
- componentWillUpdate ( ) {
91
- const { table_style } = this . props ;
92
-
93
- R . forEach ( ( { selector, rule } ) => {
94
- this . stylesheet . setRule ( selector , rule ) ;
95
- } , table_style ) ;
96
- }
97
-
98
94
componentDidUpdate ( ) {
99
95
this . handleResize ( ) ;
100
96
this . handleDropdown ( ) ;
@@ -128,6 +124,12 @@ export default class ControlledTable extends Component<ControlledTableProps> {
128
124
handleResize = ( ) => {
129
125
const { r0c0, r0c1, r1c0, r1c1 } = this . refs as { [ key : string ] : HTMLElement } ;
130
126
127
+ const { n_fixed_columns, n_fixed_rows, table_style } = this . props ;
128
+
129
+ R . forEach ( ( { selector, rule } ) => {
130
+ this . stylesheet . setRule ( selector , rule ) ;
131
+ } , table_style ) ;
132
+
131
133
// Adjust [fixed columns/fixed rows combo] to fixed rows height
132
134
let trs = r0c1 . querySelectorAll ( 'tr' ) ;
133
135
r0c0 . querySelectorAll ( 'tr' ) . forEach ( ( tr , index ) => {
@@ -152,6 +154,28 @@ export default class ControlledTable extends Component<ControlledTableProps> {
152
154
153
155
this . stylesheet . setRule ( '.cell-1-0 tr' , `height: ${ getComputedStyle ( contentTr ) . height } ` ) ;
154
156
}
157
+
158
+ // Adjust the width of the fixed row header
159
+ if ( n_fixed_rows ) {
160
+ r1c1 . querySelectorAll ( 'tr:first-of-type td' ) . forEach ( ( td , index ) => {
161
+ const width : any = getComputedStyle ( td ) . width ;
162
+ this . stylesheet . setRule (
163
+ `.dash-fixed-row:not(.dash-fixed-column) th:nth-of-type(${ index + 1 } )` ,
164
+ `width: ${ width } ; min-width: ${ width } ; max-width: ${ width } ;`
165
+ ) ;
166
+ } ) ;
167
+ }
168
+
169
+ // Adjust the width of the fixed row / fixed columns header
170
+ if ( n_fixed_columns && n_fixed_rows ) {
171
+ r1c0 . querySelectorAll ( 'tr:first-of-type td' ) . forEach ( ( td , index ) => {
172
+ const width : any = getComputedStyle ( td ) . width ;
173
+ this . stylesheet . setRule (
174
+ `.dash-fixed-column.dash-fixed-row th:nth-of-type(${ index + 1 } )` ,
175
+ `width: ${ width } ; min-width: ${ width } ; max-width: ${ width } ;`
176
+ ) ;
177
+ } ) ;
178
+ }
155
179
}
156
180
157
181
get $el ( ) {
@@ -594,10 +618,6 @@ export default class ControlledTable extends Component<ControlledTableProps> {
594
618
`.dash-spreadsheet-inner td.column-${ typeIndex } ` ,
595
619
`width: 30px; max-width: 30px; min-width: 30px;`
596
620
) ;
597
- this . stylesheet . setRule (
598
- `.dash-spreadsheet-inner th.column-${ typeIndex } ` ,
599
- `width: 30px; max-width: 30px; min-width: 30px;`
600
- ) ;
601
621
602
622
++ typeIndex ;
603
623
}
@@ -607,10 +627,6 @@ export default class ControlledTable extends Component<ControlledTableProps> {
607
627
`.dash-spreadsheet-inner td.column-${ typeIndex } ` ,
608
628
`width: 30px; max-width: 30px; min-width: 30px;`
609
629
) ;
610
- this . stylesheet . setRule (
611
- `.dash-spreadsheet-inner th.column-${ typeIndex } ` ,
612
- `width: 30px; max-width: 30px; min-width: 30px;`
613
- ) ;
614
630
615
631
++ typeIndex ;
616
632
}
@@ -624,6 +640,7 @@ export default class ControlledTable extends Component<ControlledTableProps> {
624
640
`.dash-spreadsheet-inner td.column-${ typeIndex } ` ,
625
641
`width: ${ width } ; max-width: ${ maxWidth } ; min-width: ${ minWidth } ;`
626
642
) ;
643
+
627
644
this . stylesheet . setRule (
628
645
`.dash-spreadsheet-inner th.column-${ typeIndex } ` ,
629
646
`width: ${ width } ; max-width: ${ maxWidth } ; min-width: ${ minWidth } ;`
@@ -707,6 +724,7 @@ export default class ControlledTable extends Component<ControlledTableProps> {
707
724
const {
708
725
id,
709
726
columns,
727
+ content_style,
710
728
n_fixed_columns,
711
729
n_fixed_rows,
712
730
row_deletable,
@@ -719,14 +737,27 @@ export default class ControlledTable extends Component<ControlledTableProps> {
719
737
'dash-spreadsheet-inner' ,
720
738
'dash-spreadsheet' ,
721
739
...( n_fixed_rows ? [ 'freeze-top' ] : [ ] ) ,
722
- ...( n_fixed_columns ? [ 'freeze-left' ] : [ ] )
740
+ ...( n_fixed_columns ? [ 'freeze-left' ] : [ ] ) ,
741
+ [ `dash-${ content_style } ` ]
723
742
] ;
724
743
725
744
const containerClasses = [
726
745
'dash-spreadsheet' ,
727
746
'dash-spreadsheet-container' ,
728
747
...( n_fixed_rows ? [ 'freeze-top' ] : [ ] ) ,
729
- ...( n_fixed_columns ? [ 'freeze-left' ] : [ ] )
748
+ ...( n_fixed_columns ? [ 'freeze-left' ] : [ ] ) ,
749
+ [ `dash-${ content_style } ` ]
750
+ ] ;
751
+
752
+ const fragmentClasses = [
753
+ [
754
+ n_fixed_rows && n_fixed_columns ? 'dash-fixed-row dash-fixed-column' : '' ,
755
+ n_fixed_rows ? 'dash-fixed-row' : ''
756
+ ] ,
757
+ [
758
+ n_fixed_columns ? 'dash-fixed-column' : '' ,
759
+ 'dash-fixed-content'
760
+ ]
730
761
] ;
731
762
732
763
const cells = this . getCells ( ) ;
@@ -748,7 +779,7 @@ export default class ControlledTable extends Component<ControlledTableProps> {
748
779
> { row . map ( ( cell , columnIndex ) => ( < div
749
780
key = { columnIndex }
750
781
ref = { `r${ rowIndex } c${ columnIndex } ` }
751
- className = { `cell cell-${ rowIndex } -${ columnIndex } ` }
782
+ className = { `cell cell-${ rowIndex } -${ columnIndex } ${ fragmentClasses [ rowIndex ] [ columnIndex ] } ` }
752
783
> { cell } </ div > ) )
753
784
} </ div > ) ) }
754
785
</ div >
0 commit comments