-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcosmoz-omnitable-header-row.js
75 lines (73 loc) · 1.78 KB
/
cosmoz-omnitable-header-row.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { html, component } from '@pionjs/pion';
import { repeat } from 'lit-html/directives/repeat.js';
import './lib/cosmoz-omnitable-resize-nub';
import { render } from './lib/settings/cosmoz-omnitable-sort-group';
import { when } from 'lit-html/directives/when.js';
const /* eslint-disable-next-line max-lines-per-function */
renderHeaderRow = ({
data,
columns,
groupOnColumn,
filters,
setFilterState,
}) =>
repeat(
columns,
(column) => column.name,
(column) => [
html`<div
class="cell ${column.headerCellClass} header-cell"
part="cell header-cell cell-${column.name} header-cell-${column.name}"
?hidden=${column === groupOnColumn}
title=${column.title}
name=${column.name}
>
${[
column.renderHeader(
column,
filters[column.name] ?? {},
(state) => setFilterState(column.name, state),
column.source(column, data),
),
html` <sort-and-group-consumer
style="display:contents"
.render=${({
sortOn: on,
setSortOn: setOn,
descending,
setDescending,
} = {}) =>
render({
on,
setOn,
descending,
setDescending,
column,
})}
>
</sort-and-group-consumer>`,
]}
</div>`,
html`<cosmoz-omnitable-resize-nub
.column=${column}
name=${column.name}
></cosmoz-omnitable-resize-nub>`,
],
),
HeaderRow = ({ columns, settingsConfig, hideSelectAll, ...thru }) => [
columns &&
renderHeaderRow({
columns,
...thru,
}),
when(
!hideSelectAll,
() =>
html` <cosmoz-omnitable-settings .config=${settingsConfig}>
</cosmoz-omnitable-settings>`,
),
];
customElements.define(
'cosmoz-omnitable-header-row',
component(HeaderRow, { useShadowDOM: false }),
);