@poadio/ui-elements 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +18 -1
- package/dist/card.d.ts +23 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +34 -0
- package/dist/card.js.map +1 -0
- package/dist/checkbox.d.ts +15 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +18 -0
- package/dist/checkbox.js.map +1 -1
- package/dist/fieldset.d.ts +15 -0
- package/dist/fieldset.d.ts.map +1 -0
- package/dist/fieldset.js +45 -0
- package/dist/fieldset.js.map +1 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/paginator.d.ts +65 -0
- package/dist/paginator.d.ts.map +1 -0
- package/dist/paginator.js +110 -0
- package/dist/paginator.js.map +1 -0
- package/dist/panel.d.ts +19 -0
- package/dist/panel.d.ts.map +1 -0
- package/dist/panel.js +50 -0
- package/dist/panel.js.map +1 -0
- package/dist/table.d.ts +176 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +293 -0
- package/dist/table.js.map +1 -0
- package/package.json +2 -2
- package/src/card.ts +43 -0
- package/src/checkbox.ts +21 -1
- package/src/fieldset.ts +49 -0
- package/src/index.ts +9 -2
- package/src/paginator.ts +151 -0
- package/src/panel.ts +56 -0
- package/src/table.ts +364 -0
package/src/paginator.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <poad-paginator total-records="137" rows="10" first="40" show-first-last-icon></poad-paginator>
|
|
3
|
+
* pager.addEventListener('pagechange', (e) => load(e.detail.first, e.detail.rows));
|
|
4
|
+
*
|
|
5
|
+
* Paginateur : machine `paginator` de @poadio/ui-core (nombre de pages, liens avec ellipses, rapport du catalogue
|
|
6
|
+
* `paginator.report`, changement de taille de page qui garde la page). La position (`first`, `rows`) est tenue par
|
|
7
|
+
* l'élément, comme la valeur d'un champ natif : un geste la change et émet `pagechange` (detail : `{ first, rows, page,
|
|
8
|
+
* pageCount }`) ; une valeur posée par la page est rendue sans évènement. Même DOM, mêmes classes, même ARIA que
|
|
9
|
+
* `poad-paginator` d'ui-angular. Taille de page : `<poad-select>` de la même définition (jamais de `<select>` natif).
|
|
10
|
+
* Style : `@poadio/ui-core/paginator.css` (et `icon.css`, `select.css`, `option-list.css`, `floating.css`).
|
|
11
|
+
*/
|
|
12
|
+
import {
|
|
13
|
+
paginatorChangeRows, paginatorEvent, paginatorGoTo, paginatorLinks, paginatorNavProps, paginatorPage, paginatorPageCount, paginatorReport, paginatorVisible,
|
|
14
|
+
type IconRegistry, type PaginatorEvent, type UiMessageKey,
|
|
15
|
+
} from '@poadio/ui-core';
|
|
16
|
+
import { h, type VNode } from './dom.js';
|
|
17
|
+
import { PoadElement } from './element.js';
|
|
18
|
+
import type { UiI18nValue } from './i18n.js';
|
|
19
|
+
import { icon } from './icon.js';
|
|
20
|
+
|
|
21
|
+
export interface PaginatorView {
|
|
22
|
+
readonly first: number;
|
|
23
|
+
readonly rows: number;
|
|
24
|
+
readonly totalRecords: number;
|
|
25
|
+
readonly rowsPerPageOptions?: readonly number[];
|
|
26
|
+
readonly rowsPerPageLabel?: string;
|
|
27
|
+
readonly pageLinks?: number;
|
|
28
|
+
readonly showCurrentPageReport?: boolean;
|
|
29
|
+
readonly currentPageReportTemplate?: string;
|
|
30
|
+
readonly showFirstLastIcon?: boolean;
|
|
31
|
+
readonly showPageLinks?: boolean;
|
|
32
|
+
readonly alwaysShow?: boolean;
|
|
33
|
+
/** Un geste a changé la position. */
|
|
34
|
+
readonly onPage: (e: PaginatorEvent) => void;
|
|
35
|
+
/** Élément qui rend le paginateur (il garde sa liste de taille de page) et balise de la liste (`poad-select`). */
|
|
36
|
+
readonly owner: Element;
|
|
37
|
+
readonly selectTag: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface SizeSelect extends HTMLElement {
|
|
41
|
+
options?: readonly unknown[];
|
|
42
|
+
value?: unknown;
|
|
43
|
+
size?: string;
|
|
44
|
+
ariaLabel: string | null;
|
|
45
|
+
}
|
|
46
|
+
const sizeSelects = new WeakMap<Element, { readonly el: SizeSelect; key: string; pick: (rows: number) => void }>();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Liste de taille de page : un `<poad-select>` créé une fois par hôte et posé tel quel dans le rendu (`patch` ne
|
|
50
|
+
* touche pas à un nœud donné, donc ni à son contenu ni à son focus). Ses évènements (`input`, `change`, `openchange`)
|
|
51
|
+
* s'arrêtent à lui : seul `pagechange` sort du paginateur ou de la table.
|
|
52
|
+
*/
|
|
53
|
+
function pageSizeSelect(o: PaginatorView, options: readonly number[], rows: number, label: string, pick: (rows: number) => void): Node {
|
|
54
|
+
let held = sizeSelects.get(o.owner);
|
|
55
|
+
if (!held || held.el.localName !== o.selectTag) {
|
|
56
|
+
const el = document.createElement(o.selectTag) as SizeSelect;
|
|
57
|
+
el.className = 'poad-paginator__sel';
|
|
58
|
+
el.size = 'sm';
|
|
59
|
+
held = { el, key: '', pick };
|
|
60
|
+
const box = held;
|
|
61
|
+
for (const type of ['input', 'openchange']) el.addEventListener(type, (e) => e.stopPropagation());
|
|
62
|
+
el.addEventListener('change', (e) => {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
const v = (e as CustomEvent).detail;
|
|
65
|
+
if (v != null) box.pick(+v);
|
|
66
|
+
});
|
|
67
|
+
sizeSelects.set(o.owner, held);
|
|
68
|
+
}
|
|
69
|
+
held.pick = pick;
|
|
70
|
+
const key = options.join(',');
|
|
71
|
+
if (held.key !== key) {
|
|
72
|
+
held.key = key;
|
|
73
|
+
held.el.options = options.map((n) => ({ label: String(n), value: n }));
|
|
74
|
+
}
|
|
75
|
+
if (held.el.value !== rows) held.el.value = rows;
|
|
76
|
+
if (held.el.ariaLabel !== label) held.el.ariaLabel = label;
|
|
77
|
+
return held.el;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Le paginateur en nœud de rendu (seul, ou au pied de `<poad-table>`). Interne au paquet. */
|
|
81
|
+
export function paginatorView(i18n: UiI18nValue, registry: IconRegistry, o: PaginatorView): VNode {
|
|
82
|
+
const { t, text } = i18n;
|
|
83
|
+
const { first, rows, totalRecords: total } = o;
|
|
84
|
+
const options = o.rowsPerPageOptions ?? [10, 25, 50, 100];
|
|
85
|
+
const pageCount = paginatorPageCount(total, rows);
|
|
86
|
+
const page = paginatorPage(first, rows, pageCount);
|
|
87
|
+
const visible = paginatorVisible(o.alwaysShow ?? true, pageCount);
|
|
88
|
+
const nav = paginatorNavProps(page, pageCount);
|
|
89
|
+
const rppText = text(o.rowsPerPageLabel, 'paginator.rowsPerPage');
|
|
90
|
+
const goTo = (p: number) => {
|
|
91
|
+
const next = paginatorGoTo(p, { first, rows, pageCount });
|
|
92
|
+
if (next !== null) o.onPage(paginatorEvent(next, rows, total));
|
|
93
|
+
};
|
|
94
|
+
const changeRows = (r: number) => {
|
|
95
|
+
const next = paginatorChangeRows(r, { first, rows, total });
|
|
96
|
+
if (next) o.onPage(paginatorEvent(next.first, next.rows, total));
|
|
97
|
+
};
|
|
98
|
+
const navButton = (b: { readonly labelKey: UiMessageKey; readonly disabled: boolean; readonly to: number }, name: string) =>
|
|
99
|
+
h('button', { type: 'button', 'aria-label': t(b.labelKey), disabled: b.disabled, onclick: () => goTo(b.to) }, icon(registry, name, { size: 13 }));
|
|
100
|
+
return h('nav', { class: ['poad-paginator', { 'is-hidden': !visible }], role: 'navigation', 'aria-label': t('paginator.label') }, visible && [
|
|
101
|
+
options.length > 0 && h('span', { class: 'poad-paginator__rpp' }, [
|
|
102
|
+
h('span', {}, rppText),
|
|
103
|
+
pageSizeSelect(o, options, rows, rppText, changeRows),
|
|
104
|
+
]),
|
|
105
|
+
h('span', { class: 'poad-paginator__grow' }),
|
|
106
|
+
(o.showCurrentPageReport ?? true) && h('span', { class: 'poad-paginator__report' }, paginatorReport(o.currentPageReportTemplate ?? t('paginator.report'), { first, rows, total })),
|
|
107
|
+
h('span', { class: 'poad-paginator__pages' }, [
|
|
108
|
+
o.showFirstLastIcon && navButton(nav.first, 'chevrons-left'),
|
|
109
|
+
navButton(nav.previous, 'chevron-left'),
|
|
110
|
+
(o.showPageLinks ?? true) && paginatorLinks(pageCount, page, o.pageLinks ?? 5).map((p) => (p < 0
|
|
111
|
+
? h('span', { class: 'poad-paginator__dots', 'aria-hidden': 'true' }, '…')
|
|
112
|
+
: h('button', { type: 'button', class: p === page ? 'is-on' : undefined, 'aria-current': p === page ? 'page' : undefined, 'aria-label': t('paginator.page', { page: p + 1 }), onclick: () => goTo(p) }, String(p + 1)))),
|
|
113
|
+
navButton(nav.next, 'chevron-right'),
|
|
114
|
+
o.showFirstLastIcon && navButton(nav.last, 'chevrons-right'),
|
|
115
|
+
]),
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class PoadPaginatorElement extends PoadElement {
|
|
120
|
+
static override props = {
|
|
121
|
+
first: 'number', rows: 'number', totalRecords: 'number', rowsPerPageOptions: 'json', rowsPerPageLabel: 'string', pageLinks: 'number',
|
|
122
|
+
showCurrentPageReport: 'boolean', currentPageReportTemplate: 'string', showFirstLastIcon: 'boolean', showPageLinks: 'boolean', alwaysShow: 'boolean',
|
|
123
|
+
} as const;
|
|
124
|
+
/** Index du premier élément de la page (à partir de 0). */
|
|
125
|
+
declare first?: number;
|
|
126
|
+
/** Taille de page (défaut 25). */
|
|
127
|
+
declare rows?: number;
|
|
128
|
+
declare totalRecords?: number;
|
|
129
|
+
declare rowsPerPageOptions?: readonly number[];
|
|
130
|
+
declare rowsPerPageLabel?: string;
|
|
131
|
+
declare pageLinks?: number;
|
|
132
|
+
declare showCurrentPageReport?: boolean;
|
|
133
|
+
declare currentPageReportTemplate?: string;
|
|
134
|
+
declare showFirstLastIcon?: boolean;
|
|
135
|
+
declare showPageLinks?: boolean;
|
|
136
|
+
declare alwaysShow?: boolean;
|
|
137
|
+
|
|
138
|
+
protected render() {
|
|
139
|
+
return paginatorView(this.i18n(), this.icons(), {
|
|
140
|
+
first: this.first ?? 0, rows: this.rows ?? 25, totalRecords: this.totalRecords ?? 0, rowsPerPageOptions: this.rowsPerPageOptions,
|
|
141
|
+
rowsPerPageLabel: this.rowsPerPageLabel, pageLinks: this.pageLinks, showCurrentPageReport: this.showCurrentPageReport,
|
|
142
|
+
currentPageReportTemplate: this.currentPageReportTemplate, showFirstLastIcon: this.showFirstLastIcon, showPageLinks: this.showPageLinks, alwaysShow: this.alwaysShow,
|
|
143
|
+
owner: this, selectTag: this.tag('select'),
|
|
144
|
+
onPage: (e) => {
|
|
145
|
+
this.propValues['first'] = e.first;
|
|
146
|
+
this.rows = e.rows;
|
|
147
|
+
this.emit('pagechange', e);
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
package/src/panel.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <poad-panel header="Resources" toggleable collapsed>…<poad-button slot="actions" icon="refresh-cw"></poad-button></poad-panel>
|
|
3
|
+
* <poad-panel header="Logs" variant="outline" flat>…<span slot="footer">…</span></poad-panel>
|
|
4
|
+
*
|
|
5
|
+
* Panneau : classes et attributs de @poadio/ui-core (`panelClasses`, `collapsible*`) — même DOM que `poad-panel`
|
|
6
|
+
* d'ui-angular. Repliable avec `toggleable` (motif « disclosure ») : un bouton `aria-expanded` / `aria-controls`, nommé
|
|
7
|
+
* par le titre, bascule la zone repliable (`inert` repliée, hauteur animée sauf mouvement réduit). Propriété
|
|
8
|
+
* `collapsed` ; évènement `collapsedchange` (detail : la nouvelle valeur) au geste de l'utilisateur ; méthode
|
|
9
|
+
* `toggle()`. Contenu de la page : `slot="header"` (remplace le titre), `slot="actions"`, `slot="footer"`, le reste
|
|
10
|
+
* dans le corps. Style : `@poadio/ui-core/panel.css` (et `icon.css`).
|
|
11
|
+
*/
|
|
12
|
+
import { collapsibleButtonProps, collapsibleRegionProps, collapsibleToggle, panelClasses, panelHeadless, panelIds } from '@poadio/ui-core';
|
|
13
|
+
import { slotted, unslotted } from './card.js';
|
|
14
|
+
import { h } from './dom.js';
|
|
15
|
+
import { PoadElement } from './element.js';
|
|
16
|
+
import { icon } from './icon.js';
|
|
17
|
+
|
|
18
|
+
export class PoadPanelElement extends PoadElement {
|
|
19
|
+
static override props = { header: 'string', toggleable: 'boolean', collapsed: 'boolean', variant: 'string', flat: 'boolean' } as const;
|
|
20
|
+
declare header?: string;
|
|
21
|
+
declare toggleable?: boolean;
|
|
22
|
+
declare collapsed?: boolean;
|
|
23
|
+
declare variant?: 'filled' | 'outline';
|
|
24
|
+
declare flat?: boolean;
|
|
25
|
+
|
|
26
|
+
/** Replie ou déplie (si `toggleable`), comme le bouton : signalé par `collapsedchange`. */
|
|
27
|
+
toggle(): void {
|
|
28
|
+
const next = collapsibleToggle(!!this.collapsed, !!this.toggleable);
|
|
29
|
+
if (next === null) return;
|
|
30
|
+
this.collapsed = next;
|
|
31
|
+
this.emit('collapsedchange', next);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected render() {
|
|
35
|
+
const ids = panelIds(this.uid);
|
|
36
|
+
const collapsed = !!this.collapsed;
|
|
37
|
+
const custom = slotted(this.content, 'header');
|
|
38
|
+
const btn = collapsibleButtonProps(ids.region, collapsed);
|
|
39
|
+
const region = collapsibleRegionProps(ids.region, collapsed);
|
|
40
|
+
const headless = panelHeadless({ header: this.header, toggleable: this.toggleable, customHeader: custom.length > 0 });
|
|
41
|
+
return h('div', { class: panelClasses({ collapsed, flat: this.flat, variant: this.variant, headless }) }, [
|
|
42
|
+
h('div', { class: 'poad-panel__head' }, [
|
|
43
|
+
this.toggleable && h('button', {
|
|
44
|
+
class: 'poad-panel__toggle', type: btn.type, 'aria-expanded': btn['aria-expanded'], 'aria-controls': btn['aria-controls'], 'aria-labelledby': ids.title,
|
|
45
|
+
onclick: () => this.toggle(),
|
|
46
|
+
}, icon(this.icons(), 'chevron-right', { size: 14, class: 'poad-panel__chev' })),
|
|
47
|
+
h('div', { class: 'poad-panel__title', id: ids.title }, custom.length ? custom : this.header ?? ''),
|
|
48
|
+
h('div', { class: 'poad-panel__actions' }, slotted(this.content, 'actions')),
|
|
49
|
+
]),
|
|
50
|
+
h('div', { class: 'poad-panel__wrap', id: region.id, inert: region.inert }, h('div', { class: 'poad-panel__body' }, [
|
|
51
|
+
h('div', { class: 'poad-panel__content' }, unslotted(this.content)),
|
|
52
|
+
h('div', { class: 'poad-panel__foot' }, slotted(this.content, 'footer')),
|
|
53
|
+
])),
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/table.ts
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <poad-table data-key="id" selection-mode="multiple" paginator rows="10"
|
|
3
|
+
* columns='[{"field":"name","header":"Project","sortable":true},{"field":"pods","header":"Pods","dataType":"number"}]'>
|
|
4
|
+
* <button slot="toolbar">Export</button>
|
|
5
|
+
* </poad-table>
|
|
6
|
+
* table.value = rows;
|
|
7
|
+
* table.renderCell = ({ row, column }) => column.field === 'name' ? Object.assign(document.createElement('b'), { textContent: row.name }) : undefined;
|
|
8
|
+
* table.addEventListener('selectionchange', (e) => e.detail);
|
|
9
|
+
*
|
|
10
|
+
* Table de données, tranche 1 : modèle `table` et machine `paginator` de @poadio/ui-core — colonnes en données
|
|
11
|
+
* (`columns`, propriété ou attribut JSON ; une colonne posée en propriété peut porter `cell` / `headerCell`), rendu de
|
|
12
|
+
* cellule par une fonction (`renderCell(ctx)` → texte, nœud, ou `undefined` pour le texte par défaut) et d'en-tête
|
|
13
|
+
* (`renderHeader(column)`), tri simple / multiple (`Intl.Collator` de la langue de l'élément), pagination, données
|
|
14
|
+
* serveur (`lazy`, évènement `lazyload`), sélection simple / multiple / cases avec plage à la Maj, états vide et
|
|
15
|
+
* chargement, grille WAI-ARIA dont la ligne a le focus. Tri (`sort`), page (`first`, `rows`) et sélection
|
|
16
|
+
* (`selection`) sont tenus par l'élément, comme la valeur d'un champ natif : un geste les change et émet
|
|
17
|
+
* `sortchange`, `pagechange`, `selectionchange` ; une valeur posée par la page est rendue sans évènement. Contenu de la
|
|
18
|
+
* page placé par `slot="toolbar"`, `"toolbar-end"`, `"selection-bar"`, `"empty"`, `"caption"`. Même DOM, mêmes classes,
|
|
19
|
+
* même ARIA que `poad-table` d'ui-angular. Styles : `@poadio/ui-core/table.css`, `paginator.css`, `checkbox.css`,
|
|
20
|
+
* `icon.css`.
|
|
21
|
+
*/
|
|
22
|
+
import {
|
|
23
|
+
TABLE_ROW_CLICK_IGNORE, paginatorClampFirst, tableActiveIndex, tableAllState, tableAriaSort, tableBodyState, tableClearSelection, tableCollator, tableColumnAlign,
|
|
24
|
+
tableColumnId, tableColumnSortField, tableColspan, tableFormatCell, tableGridKey, tableHeaderCellProps, tableHeaderRowProps, tablePageRows, tableResolve,
|
|
25
|
+
tableRootClasses, tableRootProps, tableRowClasses, tableRowClickAction, tableRowKey, tableRowProps, tableSelectOnly, tableSelectRange, tableSelectSingle,
|
|
26
|
+
tableSelectionArray, tableSelectionKeys, tableSelectionValue, tableShowsOverlay, tableSkeletonWidth, tableSortIcon, tableSortIndex, tableSortOrderOf, tableSortState,
|
|
27
|
+
tableSortToggle, tableTdClasses, tableThClasses, tableToggleAll, tableToggleRow, tableView,
|
|
28
|
+
type PaginatorEvent, type TableColumnDef, type TableSelectionChange, type TableSelectionMode, type TableSortMeta, type TableSortMode, type TableSortOrder,
|
|
29
|
+
} from '@poadio/ui-core';
|
|
30
|
+
import { checkboxNode } from './checkbox.js';
|
|
31
|
+
import { h, type Child } from './dom.js';
|
|
32
|
+
import { PoadElement } from './element.js';
|
|
33
|
+
import { icon } from './icon.js';
|
|
34
|
+
import { paginatorView } from './paginator.js';
|
|
35
|
+
|
|
36
|
+
type Row = unknown;
|
|
37
|
+
/** Ce que reçoit `renderCell`. */
|
|
38
|
+
export interface PoadTableCellContext {
|
|
39
|
+
readonly row: Row;
|
|
40
|
+
readonly value: unknown;
|
|
41
|
+
/** Position de la ligne dans la page. */
|
|
42
|
+
readonly rowIndex: number;
|
|
43
|
+
readonly column: PoadTableColumn;
|
|
44
|
+
}
|
|
45
|
+
/** Une colonne en données. `cell` / `headerCell` : seulement quand `columns` est posé en propriété. */
|
|
46
|
+
export interface PoadTableColumn extends TableColumnDef {
|
|
47
|
+
readonly width?: string;
|
|
48
|
+
readonly minWidth?: string;
|
|
49
|
+
readonly maxWidth?: string;
|
|
50
|
+
readonly hidden?: boolean;
|
|
51
|
+
readonly cell?: (ctx: PoadTableCellContext) => string | Node | null | undefined;
|
|
52
|
+
readonly headerCell?: (column: PoadTableColumn) => string | Node;
|
|
53
|
+
}
|
|
54
|
+
export interface PoadTableSortDetail { readonly field: string | null; readonly order: TableSortOrder; readonly multiSortMeta: TableSortMeta[] }
|
|
55
|
+
export interface PoadTableLazyLoadDetail { readonly first: number; readonly rows: number; readonly sortField: string | null; readonly sortOrder: TableSortOrder; readonly multiSortMeta: TableSortMeta[] }
|
|
56
|
+
export interface PoadTableRowDetail { readonly row: Row; readonly index: number }
|
|
57
|
+
|
|
58
|
+
const slotted = (content: readonly Node[] | null, name: string) => (content ?? []).filter((n) => n instanceof Element && n.getAttribute('slot') === name);
|
|
59
|
+
|
|
60
|
+
export class PoadTableElement extends PoadElement {
|
|
61
|
+
static override props = {
|
|
62
|
+
value: 'json', columns: 'json', dataKey: 'string', sortMode: 'string', sort: 'json', defaultSortOrder: 'number', customSort: 'boolean',
|
|
63
|
+
paginator: 'boolean', first: 'number', rows: 'number', rowsPerPageOptions: 'json', totalRecords: 'number', showCurrentPageReport: 'boolean',
|
|
64
|
+
currentPageReportTemplate: 'string', pageLinks: 'number', showFirstLastIcon: 'boolean', alwaysShowPaginator: 'boolean', lazy: 'boolean', lazyLoadOnInit: 'boolean',
|
|
65
|
+
selectionMode: 'string', selection: 'json', selectAll: 'boolean', selectAllScope: 'string', metaKeySelection: 'boolean', showSelectionBar: 'boolean',
|
|
66
|
+
loading: 'boolean', loadingRows: 'number', emptyMessage: 'string', emptyHint: 'string', emptyIcon: 'string', dense: 'boolean', striped: 'boolean',
|
|
67
|
+
hoverable: 'boolean', bordered: 'boolean', borderless: 'boolean', stickyHeader: 'boolean', bodyMaxHeight: 'string', tableClass: 'string', showToolbar: 'boolean',
|
|
68
|
+
heading: 'string', count: 'number', showCount: 'boolean',
|
|
69
|
+
} as const;
|
|
70
|
+
static override functions = ['renderCell', 'renderHeader', 'cellFormatter', 'rowSelectable', 'rowClass'] as const;
|
|
71
|
+
declare value?: readonly Row[];
|
|
72
|
+
declare columns?: readonly PoadTableColumn[];
|
|
73
|
+
/** Chemin de la clé d'une ligne (sinon : la ligne elle-même). */
|
|
74
|
+
declare dataKey?: string;
|
|
75
|
+
declare sortMode?: TableSortMode;
|
|
76
|
+
/** Tri courant (critères dans l'ordre). */
|
|
77
|
+
declare sort?: readonly TableSortMeta[];
|
|
78
|
+
declare defaultSortOrder?: 1 | -1;
|
|
79
|
+
/** La page trie elle-même (reçoit `sortchange`, pose `value` trié). */
|
|
80
|
+
declare customSort?: boolean;
|
|
81
|
+
declare paginator?: boolean;
|
|
82
|
+
declare first?: number;
|
|
83
|
+
/** Taille de page (défaut 25). */
|
|
84
|
+
declare rows?: number;
|
|
85
|
+
declare rowsPerPageOptions?: readonly number[];
|
|
86
|
+
/** Nombre total de lignes (données serveur). */
|
|
87
|
+
declare totalRecords?: number;
|
|
88
|
+
declare showCurrentPageReport?: boolean;
|
|
89
|
+
declare currentPageReportTemplate?: string;
|
|
90
|
+
declare pageLinks?: number;
|
|
91
|
+
declare showFirstLastIcon?: boolean;
|
|
92
|
+
declare alwaysShowPaginator?: boolean;
|
|
93
|
+
declare lazy?: boolean;
|
|
94
|
+
declare lazyLoadOnInit?: boolean;
|
|
95
|
+
declare selectionMode?: TableSelectionMode;
|
|
96
|
+
/** Ligne (simple) ou lignes (multiple) choisies. */
|
|
97
|
+
declare selection?: Row | readonly Row[] | null;
|
|
98
|
+
declare selectAll?: boolean;
|
|
99
|
+
declare selectAllScope?: 'page' | 'all';
|
|
100
|
+
declare metaKeySelection?: boolean;
|
|
101
|
+
declare showSelectionBar?: boolean;
|
|
102
|
+
declare loading?: boolean;
|
|
103
|
+
declare loadingRows?: number;
|
|
104
|
+
declare emptyMessage?: string;
|
|
105
|
+
declare emptyHint?: string;
|
|
106
|
+
declare emptyIcon?: string;
|
|
107
|
+
declare dense?: boolean;
|
|
108
|
+
declare striped?: boolean;
|
|
109
|
+
declare hoverable?: boolean;
|
|
110
|
+
declare bordered?: boolean;
|
|
111
|
+
declare borderless?: boolean;
|
|
112
|
+
declare stickyHeader?: boolean;
|
|
113
|
+
/** Hauteur maximale de la zone qui défile (`scrollHeight` d'Angular et React ; ici `bodyMaxHeight`, `scrollHeight` étant la hauteur mesurée de tout élément). */
|
|
114
|
+
declare bodyMaxHeight?: string;
|
|
115
|
+
declare tableClass?: string;
|
|
116
|
+
declare showToolbar?: boolean;
|
|
117
|
+
/** Titre de la barre (`title` d'Angular et React ; ici `heading`, pour ne pas donner une info-bulle à toute la table). */
|
|
118
|
+
declare heading?: string;
|
|
119
|
+
declare count?: number;
|
|
120
|
+
declare showCount?: boolean;
|
|
121
|
+
/** Rendu d'une cellule : texte, nœud, ou `undefined` pour le texte mis en forme de la valeur. */
|
|
122
|
+
declare renderCell?: (ctx: PoadTableCellContext) => string | Node | null | undefined;
|
|
123
|
+
/** Rendu d'un en-tête (remplace le libellé et le bouton de tri) ; `undefined` : celui par défaut. */
|
|
124
|
+
declare renderHeader?: (column: PoadTableColumn) => string | Node | null | undefined;
|
|
125
|
+
declare cellFormatter?: (value: unknown, column: PoadTableColumn, row: Row) => string;
|
|
126
|
+
declare rowSelectable?: (row: Row) => boolean;
|
|
127
|
+
declare rowClass?: (row: Row, index: number) => string;
|
|
128
|
+
|
|
129
|
+
private activeKey: unknown = undefined;
|
|
130
|
+
private anchor: number | null = null;
|
|
131
|
+
private loadedOnce = false;
|
|
132
|
+
/** Tri mémorisé : rien ne se retrie si ni les lignes, ni le tri, ni la langue ne changent (10 000 lignes : quelques dizaines de ms). */
|
|
133
|
+
private memo: { readonly value: unknown; readonly sort: string; readonly locale: string; readonly flags: string; readonly sorted: readonly Row[] } | null = null;
|
|
134
|
+
|
|
135
|
+
private get metas(): TableSortMeta[] {
|
|
136
|
+
const sort = this.sort ?? [];
|
|
137
|
+
return (this.sortMode ?? 'single') === 'single' ? sort.slice(0, 1) : [...sort];
|
|
138
|
+
}
|
|
139
|
+
private keyOf = (r: Row) => tableRowKey(r, this.dataKey);
|
|
140
|
+
private sorted(locale: string): readonly Row[] {
|
|
141
|
+
const value = this.value ?? [];
|
|
142
|
+
const metas = this.metas;
|
|
143
|
+
const key = JSON.stringify(metas), flags = `${!!this.lazy}${!!this.customSort}`;
|
|
144
|
+
const m = this.memo;
|
|
145
|
+
if (m && m.value === value && m.sort === key && m.locale === locale && m.flags === flags) return m.sorted;
|
|
146
|
+
const sorted = tableView(value, { metas, collator: tableCollator(locale), lazy: this.lazy, customSort: this.customSort }).sorted;
|
|
147
|
+
this.memo = { value, sort: key, locale, flags, sorted };
|
|
148
|
+
return sorted;
|
|
149
|
+
}
|
|
150
|
+
private lazyDetail(first: number, rows: number, metas: readonly TableSortMeta[]): PoadTableLazyLoadDetail {
|
|
151
|
+
const s = tableSortState(metas);
|
|
152
|
+
return { first, rows, sortField: s.field, sortOrder: s.order, multiSortMeta: s.multiSortMeta };
|
|
153
|
+
}
|
|
154
|
+
private tbody(): HTMLElement | null {
|
|
155
|
+
return this.querySelector<HTMLElement>(':scope > .poad-table > .dt > .dt-scroll > table > tbody');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
protected override updated(): void {
|
|
159
|
+
if (!this.loadedOnce) {
|
|
160
|
+
this.loadedOnce = true;
|
|
161
|
+
if (this.lazy && this.lazyLoadOnInit !== false) this.emit('lazyload', this.lazyDetail(this.first ?? 0, this.rows ?? 25, this.metas));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
protected render(): Child {
|
|
166
|
+
const i18n = this.i18n();
|
|
167
|
+
const { t, text, locale } = i18n;
|
|
168
|
+
const registry = this.icons();
|
|
169
|
+
const value = this.value ?? [];
|
|
170
|
+
const mode = this.selectionMode ?? null;
|
|
171
|
+
const sortMode = this.sortMode ?? 'single';
|
|
172
|
+
const metas = this.metas;
|
|
173
|
+
const rows = this.rows ?? 25;
|
|
174
|
+
const sorted = this.sorted(locale);
|
|
175
|
+
const total = this.lazy ? (this.totalRecords ?? value.length) : sorted.length;
|
|
176
|
+
// retour sur la dernière page quand `first` dépasse (filtre, suppression) : corrigé sans évènement, comme React
|
|
177
|
+
const back = !this.lazy && this.paginator ? paginatorClampFirst(this.first ?? 0, total, rows) : null;
|
|
178
|
+
if (back !== null) this.propValues['first'] = back;
|
|
179
|
+
const first = this.first ?? 0;
|
|
180
|
+
const page = this.paginator && !this.lazy ? tablePageRows(sorted, first, rows) : sorted;
|
|
181
|
+
const columns = (this.columns ?? []).filter((c) => !c.hidden);
|
|
182
|
+
const keyOf = this.keyOf;
|
|
183
|
+
const selected = tableSelectionArray<Row>(this.selection as Row | Row[] | null);
|
|
184
|
+
const selectedKeys = tableSelectionKeys<Row>(this.selection as Row | Row[] | null, keyOf);
|
|
185
|
+
const canSelect = (r: Row) => this.rowSelectable?.(r) ?? true;
|
|
186
|
+
const scope = (this.selectAllScope === 'all' ? sorted : page).filter(canSelect);
|
|
187
|
+
const allState = tableAllState(scope, selectedKeys, keyOf);
|
|
188
|
+
const body = tableBodyState({ loading: this.loading, hasData: value.length > 0, rowCount: page.length });
|
|
189
|
+
const trackOf = (r: Row, i: number) => (this.dataKey ? keyOf(r) : i);
|
|
190
|
+
const activeAt = tableActiveIndex(Math.max(0, page.findIndex((r, i) => trackOf(r, i) === this.activeKey)), page.length);
|
|
191
|
+
const hasSel = !!mode;
|
|
192
|
+
const rowOffset = this.paginator || this.lazy ? first : 0;
|
|
193
|
+
|
|
194
|
+
// ---- tri ----
|
|
195
|
+
const sortBy = (c: PoadTableColumn, e: MouseEvent) => {
|
|
196
|
+
const field = tableColumnSortField(c);
|
|
197
|
+
if (!field) return;
|
|
198
|
+
const next = tableSortToggle(metas, field, { mode: sortMode, additive: e.ctrlKey || e.metaKey || e.shiftKey, defaultOrder: this.defaultSortOrder ?? 1 });
|
|
199
|
+
this.sort = next;
|
|
200
|
+
this.emit('sortchange', tableSortState(next) satisfies PoadTableSortDetail);
|
|
201
|
+
if (this.lazy) this.emit('lazyload', this.lazyDetail(first, rows, next));
|
|
202
|
+
};
|
|
203
|
+
// ---- pagination ----
|
|
204
|
+
const changePage = (e: PaginatorEvent) => {
|
|
205
|
+
this.propValues['first'] = e.first;
|
|
206
|
+
this.rows = e.rows;
|
|
207
|
+
this.emit('pagechange', e);
|
|
208
|
+
if (this.lazy) this.emit('lazyload', this.lazyDetail(e.first, e.rows, metas));
|
|
209
|
+
const scroller = this.querySelector<HTMLElement>(':scope > .poad-table > .dt > .dt-scroll');
|
|
210
|
+
if (scroller) scroller.scrollTop = 0;
|
|
211
|
+
};
|
|
212
|
+
// ---- sélection ----
|
|
213
|
+
const apply = (ch: TableSelectionChange<Row> | null, index: number | null) => {
|
|
214
|
+
if (!ch) return;
|
|
215
|
+
this.selection = tableSelectionValue(ch.next, mode);
|
|
216
|
+
this.emit('selectionchange', this.selection);
|
|
217
|
+
ch.added.forEach((row) => this.emit('rowselect', { row, index: index ?? -1 } satisfies PoadTableRowDetail));
|
|
218
|
+
ch.removed.forEach((row) => this.emit('rowunselect', { row, index: index ?? -1 } satisfies PoadTableRowDetail));
|
|
219
|
+
};
|
|
220
|
+
const toggleRow = (row: Row, i: number) => { if (!canSelect(row)) return; this.anchor = i; apply(tableToggleRow(selected, row, keyOf), i); };
|
|
221
|
+
const selectSingle = (row: Row, i: number) => { if (!canSelect(row)) return; this.anchor = i; apply(tableSelectSingle(selected, row, keyOf), i); };
|
|
222
|
+
const selectRange = (from: number, to: number) => apply(tableSelectRange(selected, page, from, to, keyOf, canSelect), to);
|
|
223
|
+
const toggleAll = () => apply(tableToggleAll(selected, scope, keyOf), null);
|
|
224
|
+
|
|
225
|
+
const onRowClick = (row: Row, i: number, e: MouseEvent) => {
|
|
226
|
+
if ((e.target as Element).closest(TABLE_ROW_CLICK_IGNORE)) return;
|
|
227
|
+
this.activeKey = trackOf(row, i);
|
|
228
|
+
this.emit('rowclick', { row, index: i } satisfies PoadTableRowDetail);
|
|
229
|
+
const action = tableRowClickAction({ mode, selectable: canSelect(row), shiftKey: e.shiftKey, ctrlKey: e.ctrlKey, metaKey: e.metaKey, metaKeySelection: this.metaKeySelection, hasAnchor: this.anchor != null });
|
|
230
|
+
if (action === 'single') selectSingle(row, i);
|
|
231
|
+
else if (action === 'range') selectRange(this.anchor!, i);
|
|
232
|
+
else if (action === 'only') { this.anchor = i; apply(tableSelectOnly(selected, row, keyOf), i); }
|
|
233
|
+
else if (action === 'toggle') toggleRow(row, i);
|
|
234
|
+
this.update(); // ligne active (focus itinérant), même sans changement de sélection
|
|
235
|
+
};
|
|
236
|
+
const onRowKeydown = (i: number, e: KeyboardEvent) => {
|
|
237
|
+
if (e.target !== e.currentTarget && (e.target as Element).closest('input, select, textarea, button, a')) return;
|
|
238
|
+
const eff = tableGridKey(e, { index: i, count: page.length, mode, selectAll: this.selectAll });
|
|
239
|
+
if (!eff) return;
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
const to = eff.move ?? i;
|
|
242
|
+
if (eff.move !== undefined && eff.move !== i) {
|
|
243
|
+
this.activeKey = trackOf(page[eff.move], eff.move);
|
|
244
|
+
this.tbody()?.querySelectorAll<HTMLElement>(':scope > tr.dt-row')[eff.move]?.focus();
|
|
245
|
+
}
|
|
246
|
+
const row = page[to];
|
|
247
|
+
if (eff.select === 'all') { if (allState !== 'all') toggleAll(); }
|
|
248
|
+
else if (to < page.length && eff.select === 'single') selectSingle(row, to);
|
|
249
|
+
else if (to < page.length && eff.select === 'toggle') toggleRow(row, to);
|
|
250
|
+
else if (to < page.length && eff.select === 'range' && canSelect(row)) selectRange(this.anchor ?? i, to);
|
|
251
|
+
this.update(); // ligne active (focus itinérant)
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// ---- rendu ----
|
|
255
|
+
const format = (v: unknown, c: PoadTableColumn, row: Row) =>
|
|
256
|
+
this.cellFormatter ? this.cellFormatter(v, c, row) : tableFormatCell(v, c.dataType, { locale, booleanText: (b) => t(b ? 'common.yes' : 'common.no') });
|
|
257
|
+
const selCount = selectedKeys.size;
|
|
258
|
+
const ta = tableRootProps({ mode, busy: this.loading, rowCount: total, headerRows: 1 });
|
|
259
|
+
const colspan = tableColspan({ columns: columns.length, selection: hasSel });
|
|
260
|
+
const check = (id: string, checked: boolean, label: string, onToggle: () => void, indeterminate?: boolean) =>
|
|
261
|
+
checkboxNode(registry, { id: `${this.uid}-${id}`, checked, indeterminate, ariaLabel: label, onToggle });
|
|
262
|
+
|
|
263
|
+
const header = (c: PoadTableColumn) => {
|
|
264
|
+
const field = tableColumnSortField(c);
|
|
265
|
+
const order = tableSortOrderOf(metas, field);
|
|
266
|
+
const idx = sortMode === 'multiple' ? tableSortIndex(metas, field) : 0;
|
|
267
|
+
const hp = tableHeaderCellProps({ ariaSort: tableAriaSort(metas, field, !!c.sortable) });
|
|
268
|
+
const custom = c.headerCell?.(c) ?? this.renderHeader?.(c);
|
|
269
|
+
return h('th', { scope: hp.scope, class: tableThClasses(c, order !== 0), 'aria-sort': hp['aria-sort'], style: c.width ? { width: c.width } : undefined }, custom != null ? custom : c.sortable
|
|
270
|
+
? h('button', { type: 'button', class: 'hd', 'aria-label': t('table.sortBy', { column: c.header ?? '' }), onclick: (e: MouseEvent) => sortBy(c, e) }, [
|
|
271
|
+
h('span', { class: 'hd-txt' }, c.header ?? ''),
|
|
272
|
+
icon(registry, tableSortIcon(order), { size: 12 }),
|
|
273
|
+
idx > 0 && h('span', { class: 'hd-idx' }, String(idx)),
|
|
274
|
+
])
|
|
275
|
+
: h('span', { class: 'hd' }, h('span', { class: 'hd-txt' }, c.header ?? '')));
|
|
276
|
+
};
|
|
277
|
+
const cell = (row: Row, i: number, c: PoadTableColumn, ci: number) => {
|
|
278
|
+
const v = c.field ? tableResolve(row, c.field) : undefined;
|
|
279
|
+
const ctx: PoadTableCellContext = { row, value: v, rowIndex: i, column: c };
|
|
280
|
+
const custom = c.cell?.(ctx) ?? this.renderCell?.(ctx);
|
|
281
|
+
return h('td', { class: tableTdClasses(c) + (ci === 0 ? ' dt-first' : ''), 'data-l': c.header }, custom != null ? custom : h('span', { class: 'cell-txt' }, format(v, c, row)));
|
|
282
|
+
};
|
|
283
|
+
const bodyRows = (): Child => {
|
|
284
|
+
if (body === 'skeleton') {
|
|
285
|
+
return Array.from({ length: this.loadingRows ?? 5 }, (_, r) => h('tr', { class: 'dt-row is-skeleton', 'aria-hidden': 'true' }, [
|
|
286
|
+
hasSel && h('td', { class: 'col-sel' }),
|
|
287
|
+
columns.map((c, ci) => h('td', { class: tableTdClasses(c) }, h('div', { class: 'skel', style: { width: tableSkeletonWidth(r, ci) + '%', marginLeft: tableColumnAlign(c) === 'right' ? 'auto' : undefined } }))),
|
|
288
|
+
]));
|
|
289
|
+
}
|
|
290
|
+
if (body === 'empty') {
|
|
291
|
+
const empty = slotted(this.content, 'empty');
|
|
292
|
+
return h('tr', { class: 'dt-empty' }, h('td', { colspan }, empty.length ? empty : h('div', { class: 'empty' }, [
|
|
293
|
+
(this.emptyIcon ?? 'inbox') && icon(registry, this.emptyIcon ?? 'inbox', { size: 26, strokeWidth: 1.5 }),
|
|
294
|
+
h('b', {}, text(this.emptyMessage, 'table.empty')),
|
|
295
|
+
this.emptyHint && h('span', {}, this.emptyHint),
|
|
296
|
+
])));
|
|
297
|
+
}
|
|
298
|
+
return page.map((row, i) => {
|
|
299
|
+
const sel = selectedKeys.has(keyOf(row));
|
|
300
|
+
const rp = tableRowProps({ position: rowOffset + i, mode, selected: sel, active: i === activeAt });
|
|
301
|
+
const track = trackOf(row, i);
|
|
302
|
+
return h('tr', {
|
|
303
|
+
class: tableRowClasses({ selectable: hasSel && canSelect(row), hasSelectionColumn: hasSel, selected: sel, extra: this.rowClass?.(row, i) }),
|
|
304
|
+
'data-key': this.dataKey ? String(track) : undefined, tabindex: rp.tabindex, 'aria-selected': rp['aria-selected'], 'aria-rowindex': rp['aria-rowindex'],
|
|
305
|
+
onclick: (e: MouseEvent) => onRowClick(row, i, e), ondblclick: () => this.emit('rowdblclick', { row, index: i } satisfies PoadTableRowDetail),
|
|
306
|
+
onkeydown: (e: KeyboardEvent) => onRowKeydown(i, e),
|
|
307
|
+
// focus itinérant posé sans redessiner : un nouveau rendu remplacerait les nœuds de `renderCell` sous le pointeur
|
|
308
|
+
// (le clic qui suit l'appui n'arriverait pas) ; le prochain rendu trouve les mêmes valeurs
|
|
309
|
+
onfocus: (e: FocusEvent) => {
|
|
310
|
+
if (e.target !== e.currentTarget || this.activeKey === track) return;
|
|
311
|
+
this.activeKey = track;
|
|
312
|
+
this.tbody()?.querySelectorAll(':scope > tr.dt-row').forEach((tr) => { if (tr.hasAttribute('tabindex')) tr.setAttribute('tabindex', tr === e.currentTarget ? '0' : '-1'); });
|
|
313
|
+
},
|
|
314
|
+
}, [
|
|
315
|
+
hasSel && h('td', { class: 'col-sel' }, canSelect(row) && check(`r${i}`, sel, t('table.selectRow', { index: i + 1 }), () => (mode === 'multiple' ? toggleRow(row, i) : selectSingle(row, i)))),
|
|
316
|
+
columns.map((c, ci) => cell(row, i, c, ci)),
|
|
317
|
+
]);
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const caption = slotted(this.content, 'caption');
|
|
322
|
+
return h('div', {
|
|
323
|
+
class: ['poad-table', tableRootClasses({ dense: this.dense, striped: this.striped, hoverable: this.hoverable, bordered: this.bordered, borderless: this.borderless, stickyHeader: this.stickyHeader, scrollHeight: this.bodyMaxHeight, loading: this.loading })],
|
|
324
|
+
style: this.bodyMaxHeight ? { '--_scroll-h': this.bodyMaxHeight } : undefined,
|
|
325
|
+
}, h('div', { class: 'dt' }, [
|
|
326
|
+
selCount > 0 && (this.showSelectionBar ?? true) ? h('div', { class: 'dt-sel', role: 'region', 'aria-live': 'polite' }, [
|
|
327
|
+
check('bar-all', allState === 'all', t('table.selectAll'), toggleAll, allState === 'some'),
|
|
328
|
+
h('span', {}, t('table.selectedCount', { n: selCount })),
|
|
329
|
+
h('span', { class: 'dt-sel__grow' }),
|
|
330
|
+
slotted(this.content, 'selection-bar'),
|
|
331
|
+
h('button', { type: 'button', class: 'dt-sel__clear', 'aria-label': t('table.clearSelection'), onclick: () => apply(tableClearSelection(selected), null) }, icon(registry, 'x', { size: 14 })),
|
|
332
|
+
]) : (this.showToolbar ?? true) && h('div', { class: 'dt-bar' }, [
|
|
333
|
+
this.heading && h('span', { class: 'dt-bar__title' }, this.heading),
|
|
334
|
+
(this.showCount ?? true) && h('span', { class: 'dt-bar__count' }, String(this.count ?? total)),
|
|
335
|
+
h('span', { class: 'dt-bar__tools' }, slotted(this.content, 'toolbar')),
|
|
336
|
+
h('span', { class: 'dt-bar__grow' }),
|
|
337
|
+
h('span', { class: 'dt-bar__tools-end' }, slotted(this.content, 'toolbar-end')),
|
|
338
|
+
]),
|
|
339
|
+
h('div', { class: 'dt-scroll' }, [
|
|
340
|
+
tableShowsOverlay({ loading: this.loading, hasData: value.length > 0 }) && h('div', { class: 'dt-loading' }, icon(registry, 'loader', { size: 22, spin: true })),
|
|
341
|
+
h('table', {
|
|
342
|
+
class: this.tableClass ? 'tbl ' + this.tableClass : 'tbl', role: ta.role, 'aria-rowcount': ta['aria-rowcount'], 'aria-busy': ta['aria-busy'],
|
|
343
|
+
'aria-multiselectable': ta['aria-multiselectable'],
|
|
344
|
+
}, [
|
|
345
|
+
caption.length > 0 && h('caption', {}, caption),
|
|
346
|
+
h('colgroup', {}, [
|
|
347
|
+
hasSel && h('col', { style: { width: '36px' } }),
|
|
348
|
+
columns.map((c) => h('col', { style: { width: c.width, minWidth: c.minWidth, maxWidth: c.maxWidth } })),
|
|
349
|
+
]),
|
|
350
|
+
h('thead', {}, h('tr', { 'aria-rowindex': tableHeaderRowProps(0)['aria-rowindex'] }, [
|
|
351
|
+
hasSel && h('th', { class: 'col-sel', scope: 'col' }, mode === 'multiple' && (this.selectAll ?? true) && check('all', allState === 'all', t('table.selectAll'), toggleAll, allState === 'some')),
|
|
352
|
+
columns.map(header),
|
|
353
|
+
])),
|
|
354
|
+
h('tbody', {}, bodyRows()),
|
|
355
|
+
]),
|
|
356
|
+
]),
|
|
357
|
+
this.paginator && (total > 0 || this.lazy) && h('div', { class: 'dt-foot' }, paginatorView(i18n, registry, {
|
|
358
|
+
first, rows, totalRecords: total, rowsPerPageOptions: this.rowsPerPageOptions, pageLinks: this.pageLinks, showCurrentPageReport: this.showCurrentPageReport,
|
|
359
|
+
currentPageReportTemplate: this.currentPageReportTemplate, showFirstLastIcon: this.showFirstLastIcon, alwaysShow: this.alwaysShowPaginator, onPage: changePage,
|
|
360
|
+
owner: this, selectTag: this.tag('select'),
|
|
361
|
+
})),
|
|
362
|
+
]));
|
|
363
|
+
}
|
|
364
|
+
}
|