1111 * or submit itself to any jurisdiction.
1212 */
1313
14- import { h } from '/js/src/index.js' ;
14+ import { h , info } from '/js/src/index.js' ;
1515import { iconCaretTop , iconCaretBottom , iconX } from '/js/src/icons.js' ;
16+ import { tooltip } from '../popover/tooltip.js' ;
1617
1718/**
1819 * @typedef TableModels the list of models that handle an eventual table state
@@ -36,11 +37,13 @@ export const headers = (columns, models) => {
3637 const classes = [ size || null , column . classes || null ] ;
3738
3839 // Name needs to be empty for a popover, otherwise the name when hovering will be blocking the popover.
39- const attributes = {
40- scope : 'col' ,
41- title : information || undefined ,
42- } ;
40+ const attributes = { scope : 'col' } ;
4341 let content = [ name ] ;
42+
43+ if ( information ) {
44+ content . push ( tooltip ( info ( ) , information ) ) ;
45+ }
46+
4447 if ( sortModel && sortable ) {
4548 attributes . onmouseenter = ( ) => {
4649 sortModel . previewOn = key ;
@@ -67,31 +70,37 @@ export const headers = (columns, models) => {
6770 classes . push ( 'clickable' ) ;
6871
6972 const sortIndicator = h (
70- `.ml2 ${ preview ? '.gray-dark' : '' } ` ,
73+ preview ? '.gray-dark' : '' ,
7174 { id : `${ key } -sort${ preview ? '-preview' : '' } ` } ,
7275 icon ,
7376 ) ;
7477 content . push ( sortIndicator ) ;
78+ }
7579
80+ if ( content . length > 1 ) {
7681 // Wrap content in a row container
77- content = h ( '.flex-row.items-center' , content ) ;
78- } else if ( inlineFilter ) {
82+ content = h ( '.flex-row.items-center.g1' , content ) ;
83+ }
84+
85+ if ( inlineFilter ) {
7986 const {
8087 getValue = null ,
8188 onChange = ( ) => {
8289 // Simple default which does nothing
8390 } ,
8491 placeholder = '' ,
8592 } = inlineFilter ;
86- content . push ( h ( 'input.form-control' , {
87- type : 'text' ,
88- placeholder,
89- oninput : ( e ) => onChange ( e . target . value , filterModel ) ,
90- ...getValue ? { value : getValue ( filterModel ) } : { } ,
91- } ) ) ;
9293
9394 // Wrap content in a column container
94- content = h ( '.flex-column.justify-between.gr2' , content ) ;
95+ content = h ( '.flex-column.justify-between.gr2' , [
96+ content ,
97+ h ( 'input.form-control' , {
98+ type : 'text' ,
99+ placeholder,
100+ oninput : ( e ) => onChange ( e . target . value , filterModel ) ,
101+ ...getValue ? { value : getValue ( filterModel ) } : { } ,
102+ } ) ,
103+ ] ) ;
95104 }
96105
97106 return h ( `th#${ key } .${ classes . filter ( ( item ) => Boolean ( item ) ) . join ( ' ' ) } ` , attributes , content ) ;
0 commit comments