@poadio/ui-elements 0.6.0 → 0.7.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 +32 -0
- package/dist/dataview.d.ts +114 -0
- package/dist/dataview.d.ts.map +1 -0
- package/dist/dataview.js +75 -0
- package/dist/dataview.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/table.d.ts +83 -5
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +134 -31
- package/dist/table.js.map +1 -1
- package/package.json +2 -2
- package/src/dataview.ts +143 -0
- package/src/index.ts +5 -3
- package/src/table.ts +170 -32
package/src/dataview.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <poad-dataview data-key="id" layout="grid" show-layout-switch paginator rows="12" sort-field="name" filter-by='["name","owner"]' grid-cols="1 sm:2 lg:3">
|
|
3
|
+
* <div slot="header">…</div>
|
|
4
|
+
* </poad-dataview>
|
|
5
|
+
* dataview.value = projets; dataview.renderList = ({ item }) => nœud; dataview.renderGrid = ({ item }) => nœud;
|
|
6
|
+
*
|
|
7
|
+
* Vue de données (le `poad-dataview` d'ui-angular) : liste ou grille de gabarits de l'application, recherche sans accents
|
|
8
|
+
* ni casse sur des champs, tri sur un champ, page, bascule liste / grille, squelettes au chargement. Modèle `dataview`
|
|
9
|
+
* de @poadio/ui-core ; même DOM et mêmes classes qu'Angular. Disposition (`layout`) et page (`first`, `rows`) tenues par
|
|
10
|
+
* l'élément. Styles : `@poadio/ui-core/dataview.css`, `paginator.css`, `skeleton.css`, `icon.css`.
|
|
11
|
+
*/
|
|
12
|
+
import {
|
|
13
|
+
dataviewBodyState, dataviewGridVars, dataviewItems, dataviewPage, dataviewRootClasses, dataviewSetLayout, dataviewSwitchItems, dataviewTrack, skeletonBars, skeletonRootClasses,
|
|
14
|
+
type DataviewLayout, type SkeletonOptions,
|
|
15
|
+
} from '@poadio/ui-core';
|
|
16
|
+
import { h, type Child } from './dom.js';
|
|
17
|
+
import { PoadElement } from './element.js';
|
|
18
|
+
import { icon } from './icon.js';
|
|
19
|
+
import { paginatorView } from './paginator.js';
|
|
20
|
+
|
|
21
|
+
type Item = Record<string, unknown>;
|
|
22
|
+
/** Contexte d'un gabarit d'élément. */
|
|
23
|
+
export interface PoadDataviewItemContext { readonly item: Item; readonly index: number }
|
|
24
|
+
const slotted = (content: readonly Node[] | null, name: string) => (content ?? []).filter((n) => n instanceof Element && n.getAttribute('slot') === name);
|
|
25
|
+
const skeleton = (o: SkeletonOptions) => h('div', { class: ['poad-skeleton', skeletonRootClasses(o)], 'aria-hidden': 'true' },
|
|
26
|
+
skeletonBars(o).map((bar) => h('span', { class: bar.className, style: { width: bar.width, height: bar.height } })));
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Vue de données : liste ou grille de gabarits (`renderList`, `renderGrid`).
|
|
30
|
+
* @fires layoutchange {DataviewLayout} L'utilisateur change de disposition.
|
|
31
|
+
* @fires pagechange {PaginatorEvent} L'utilisateur change de page ou de taille de page.
|
|
32
|
+
* @slot header Contenu de l'en-tête, à gauche de la bascule.
|
|
33
|
+
* @slot footer Contenu du pied, avant le paginateur.
|
|
34
|
+
*/
|
|
35
|
+
export class PoadDataviewElement extends PoadElement {
|
|
36
|
+
static override props = {
|
|
37
|
+
value: 'json', dataKey: 'string', layout: 'string', showLayoutSwitch: 'boolean', paginator: 'boolean', first: 'number', rows: 'number', rowsPerPageOptions: 'json',
|
|
38
|
+
alwaysShowPaginator: 'boolean', sortField: 'string', sortOrder: 'number', filterValue: 'string', filterBy: 'json', gridCols: 'string', gridMin: 'string',
|
|
39
|
+
loading: 'boolean', loadingRows: 'number', emptyMessage: 'string',
|
|
40
|
+
} as const;
|
|
41
|
+
static override functions = ['renderList', 'renderGrid'] as const;
|
|
42
|
+
/** Éléments affichés. */
|
|
43
|
+
declare value?: readonly Item[];
|
|
44
|
+
/** Champ de la clé d'un élément (suivi des éléments ; sinon leur place). */
|
|
45
|
+
declare dataKey?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Disposition `list` ou `grid`, tenue par l'élément.
|
|
48
|
+
* @default 'list'
|
|
49
|
+
*/
|
|
50
|
+
declare layout?: DataviewLayout;
|
|
51
|
+
/** Bascule liste / grille dans l'en-tête. */
|
|
52
|
+
declare showLayoutSwitch?: boolean;
|
|
53
|
+
/** Paginateur au pied et éléments découpés en pages. */
|
|
54
|
+
declare paginator?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Index du premier élément de la page, tenu par l'élément.
|
|
57
|
+
* @default 0
|
|
58
|
+
*/
|
|
59
|
+
declare first?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Taille de page, tenue par l'élément.
|
|
62
|
+
* @default 12
|
|
63
|
+
*/
|
|
64
|
+
declare rows?: number;
|
|
65
|
+
/** Tailles de page proposées. */
|
|
66
|
+
declare rowsPerPageOptions?: readonly number[];
|
|
67
|
+
/**
|
|
68
|
+
* Paginateur affiché même avec une seule page.
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
declare alwaysShowPaginator?: boolean;
|
|
72
|
+
/** Champ du tri (sinon : l'ordre de `value`). */
|
|
73
|
+
declare sortField?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Ordre du tri : `1` croissant, `-1` décroissant.
|
|
76
|
+
* @default 1
|
|
77
|
+
*/
|
|
78
|
+
declare sortOrder?: 1 | -1;
|
|
79
|
+
/** Texte recherché (sans accents ni casse) dans `filterBy`. */
|
|
80
|
+
declare filterValue?: string;
|
|
81
|
+
/** Champs de la recherche. */
|
|
82
|
+
declare filterBy?: readonly string[];
|
|
83
|
+
/**
|
|
84
|
+
* Colonnes de la grille : un nombre, ou par point de rupture (`"1 sm:2 lg:3"`).
|
|
85
|
+
* @default '1 sm:2 lg:3'
|
|
86
|
+
*/
|
|
87
|
+
declare gridCols?: string;
|
|
88
|
+
/** Largeur minimale d'une carte : la grille remplit la ligne (à la place de `gridCols`). */
|
|
89
|
+
declare gridMin?: string;
|
|
90
|
+
/** Chargement : squelettes à la place des éléments. */
|
|
91
|
+
declare loading?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Nombre de squelettes.
|
|
94
|
+
* @default 6
|
|
95
|
+
*/
|
|
96
|
+
declare loadingRows?: number;
|
|
97
|
+
/** Message du corps vide (défaut : message du catalogue). */
|
|
98
|
+
declare emptyMessage?: string;
|
|
99
|
+
/** Gabarit d'un élément en liste : ({ item, index }) → texte ou nœud ; sinon celui de la grille. */
|
|
100
|
+
declare renderList?: (ctx: PoadDataviewItemContext) => string | Node | null | undefined;
|
|
101
|
+
/** Gabarit d'un élément en grille : ({ item, index }) → texte ou nœud ; sinon celui de la liste. */
|
|
102
|
+
declare renderGrid?: (ctx: PoadDataviewItemContext) => string | Node | null | undefined;
|
|
103
|
+
|
|
104
|
+
protected render(): Child {
|
|
105
|
+
const i18n = this.i18n();
|
|
106
|
+
const { t, text, locale } = i18n;
|
|
107
|
+
const registry = this.icons();
|
|
108
|
+
const layout = this.layout ?? 'list';
|
|
109
|
+
const first = this.first ?? 0, rows = this.rows ?? 12;
|
|
110
|
+
const items = dataviewItems(this.value ?? [], { filterValue: this.filterValue, filterBy: this.filterBy, sortField: this.sortField, sortOrder: this.sortOrder, locale });
|
|
111
|
+
const page = dataviewPage(items, { paginator: this.paginator, first, rows });
|
|
112
|
+
const body = dataviewBodyState({ loading: this.loading, count: page.length });
|
|
113
|
+
const grid = layout === 'grid';
|
|
114
|
+
const tpl = grid ? this.renderGrid ?? this.renderList : this.renderList ?? this.renderGrid;
|
|
115
|
+
const at = (i: number) => (this.paginator ? first : 0) + i;
|
|
116
|
+
const skel = Array.from({ length: this.loadingRows ?? 6 }, (_, i) => i);
|
|
117
|
+
const change = (l: DataviewLayout) => {
|
|
118
|
+
const next = dataviewSetLayout(layout, l); if (!next) return;
|
|
119
|
+
this.layout = next; this.emit('layoutchange', next);
|
|
120
|
+
};
|
|
121
|
+
const footer = slotted(this.content, 'footer');
|
|
122
|
+
return h('div', { class: ['poad-dataview', dataviewRootClasses({ layout, min: this.gridMin })], style: grid ? dataviewGridVars(this.gridCols ?? '1 sm:2 lg:3', this.gridMin) : undefined }, [
|
|
123
|
+
h('div', { class: 'dv__hd' }, [
|
|
124
|
+
h('div', { class: 'dv__hd-slot' }, slotted(this.content, 'header')),
|
|
125
|
+
this.showLayoutSwitch && h('div', { class: 'dv__switch', role: 'group', 'aria-label': t('dataview.layout') }, dataviewSwitchItems(layout).map((b) =>
|
|
126
|
+
h('button', { type: 'button', class: b.className || undefined, 'aria-pressed': b['aria-pressed'], 'aria-label': t(b.labelKey), onclick: () => change(b.layout) }, icon(registry, b.icon, { size: 15 })))),
|
|
127
|
+
]),
|
|
128
|
+
body === 'skeleton' ? h('div', { class: 'dv__body' }, grid
|
|
129
|
+
? h('div', { class: 'dv__grid' }, skel.map(() => skeleton({ shape: 'rect', height: '120px' })))
|
|
130
|
+
: skel.map(() => h('div', { class: 'dv__row' }, skeleton({ lines: 2 }))))
|
|
131
|
+
: body === 'empty' ? h('div', { class: 'dv__empty' }, [icon(registry, 'inbox', { size: 24, strokeWidth: 1.5 }), h('span', {}, text(this.emptyMessage, 'dataview.empty'))])
|
|
132
|
+
: grid ? h('div', { class: 'dv__body dv__grid' }, page.map((it, i) => (tpl?.({ item: it, index: at(i) }) ?? null) as Child))
|
|
133
|
+
: h('div', { class: 'dv__body dv__list' }, page.map((it, i) => h('div', { class: 'dv__row', 'data-track': String(dataviewTrack(it, i, this.dataKey)) }, (tpl?.({ item: it, index: at(i) }) ?? null) as Child))),
|
|
134
|
+
(footer.length > 0 || this.paginator) && h('div', { class: 'dv__ft' }, [
|
|
135
|
+
footer,
|
|
136
|
+
this.paginator && paginatorView(i18n, registry, {
|
|
137
|
+
first, rows, totalRecords: items.length, rowsPerPageOptions: this.rowsPerPageOptions ?? [6, 12, 24, 48], alwaysShow: this.alwaysShowPaginator ?? true,
|
|
138
|
+
onPage: (e) => { this.first = e.first; this.rows = e.rows; this.emit('pagechange', e); }, owner: this, selectTag: this.tag('select'),
|
|
139
|
+
}),
|
|
140
|
+
]),
|
|
141
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -74,6 +74,7 @@ import { PoadTableElement } from './table.js';
|
|
|
74
74
|
import { PoadPaginatorElement } from './paginator.js';
|
|
75
75
|
import { PoadTablePanelElement } from './table-panel.js';
|
|
76
76
|
import { PoadFilterChipElement } from './filter-chip.js';
|
|
77
|
+
import { PoadDataviewElement } from './dataview.js';
|
|
77
78
|
import { noteDefinedPrefix } from './services.js';
|
|
78
79
|
|
|
79
80
|
/** Nom (sans préfixe) → classe de chaque élément. */
|
|
@@ -89,7 +90,7 @@ export const POAD_ELEMENTS = {
|
|
|
89
90
|
step: PoadStepElement, menu: PoadMenuElement, 'split-button': PoadSplitButtonElement,
|
|
90
91
|
multiselect: PoadMultiselectElement, combo: PoadComboElement, datepicker: PoadDatepickerElement,
|
|
91
92
|
dialog: PoadDialogElement, drawer: PoadDrawerElement, 'confirm-dialog': PoadConfirmDialogElement, toast: PoadToastElement,
|
|
92
|
-
table: PoadTableElement, paginator: PoadPaginatorElement, 'table-panel': PoadTablePanelElement, 'filter-chip': PoadFilterChipElement,
|
|
93
|
+
table: PoadTableElement, paginator: PoadPaginatorElement, 'table-panel': PoadTablePanelElement, 'filter-chip': PoadFilterChipElement, dataview: PoadDataviewElement,
|
|
93
94
|
breadcrumb: PoadBreadcrumbElement, timeline: PoadTimelineElement, 'scroll-top': PoadScrollTopElement, block: PoadBlockElement, image: PoadImageElement,
|
|
94
95
|
splitter: PoadSplitterElement, 'splitter-panel': PoadSplitterPanelElement, 'speed-dial': PoadSpeedDialElement, listbox: PoadListboxElement, upload: PoadUploadElement, carousel: PoadCarouselElement,
|
|
95
96
|
if: PoadIfElement, menubar: PoadMenubarElement, 'bottom-nav': PoadBottomNavElement, 'nav-drawer': PoadNavDrawerElement, 'app-shell': PoadAppShellElement, stack: PoadStackElement, cluster: PoadClusterElement, grid: PoadGridElement, split: PoadSplitElement, sidebar: PoadSidebarElement,
|
|
@@ -139,7 +140,7 @@ export {
|
|
|
139
140
|
PoadAccordionPanelElement, PoadStepperElement, PoadStepElement, PoadMenuElement, PoadSplitButtonElement,
|
|
140
141
|
PoadMultiselectElement, PoadComboElement, PoadDatepickerElement, PoadDialogElement, PoadDrawerElement,
|
|
141
142
|
PoadConfirmDialogElement, PoadToastElement, PoadTableElement, PoadPaginatorElement, PoadCardElement, PoadPanelElement, PoadFieldsetElement,
|
|
142
|
-
PoadTablePanelElement, PoadFilterChipElement,
|
|
143
|
+
PoadTablePanelElement, PoadFilterChipElement, PoadDataviewElement,
|
|
143
144
|
PoadBreadcrumbElement, PoadTimelineElement, PoadScrollTopElement, PoadBlockElement, PoadImageElement, PoadSplitterElement, PoadSplitterPanelElement, PoadSpeedDialElement, PoadListboxElement, PoadUploadElement, PoadCarouselElement,
|
|
144
145
|
PoadIfElement, PoadStackElement, PoadClusterElement, PoadGridElement, PoadSplitElement, PoadSidebarElement, PoadCenterElement, PoadContainerElement, PoadSpacerElement,
|
|
145
146
|
PoadMenubarElement, PoadBottomNavElement, PoadNavDrawerElement, PoadAppShellElement,
|
|
@@ -160,8 +161,9 @@ export type { PoadBreadcrumbItem } from './breadcrumb.js';
|
|
|
160
161
|
export type { PoadTimelineRender } from './timeline.js';
|
|
161
162
|
export type { PoadCarouselRender } from './carousel.js';
|
|
162
163
|
export type { TabData } from './tabs.js';
|
|
163
|
-
export type { PoadTableColumn, PoadTableCellContext, PoadTableSortDetail, PoadTableLazyLoadDetail, PoadTableRowDetail, PoadTableNodeDetail, PoadTableFilterDetail, PoadTableFilterContext, PoadTableGroupContext } from './table.js';
|
|
164
|
+
export type { PoadTableColumn, PoadTableCellContext, PoadTableSortDetail, PoadTableLazyLoadDetail, PoadTableRowDetail, PoadTableNodeDetail, PoadTableFilterDetail, PoadTableFilterContext, PoadTableGroupContext, PoadTableExpansionContext, PoadTableRowActionsContext, PoadTableCardContext } from './table.js';
|
|
164
165
|
export type { PoadTablePanelTab } from './table-panel.js';
|
|
166
|
+
export type { PoadDataviewItemContext } from './dataview.js';
|
|
165
167
|
/** Types de la table. */
|
|
166
168
|
export type { TableFilters, TableFilterMeta, TableFilterMatchMode, TableFilterKind, TableFilterOption } from '@poadio/ui-core';
|
|
167
169
|
/** Texte d'une valeur de filtre pour une puce, et prédicat des filtres (pour filtrer ailleurs comme la table). */
|
package/src/table.ts
CHANGED
|
@@ -50,6 +50,14 @@ import {
|
|
|
50
50
|
tableTreeNodeState, tableTreeRootVars, tableTreeRowClasses, tableTreeToggle, tableTreeToggleProps, tableTreeToggleRow, type TableSelectionPropagation,
|
|
51
51
|
type PaginatorEvent, type TableColumnDef, type TableFilters, type TableSelectionChange, type TableSelectionMode, type TableSortMeta, type TableSortMode, type TableSortOrder,
|
|
52
52
|
} from '@poadio/ui-core';
|
|
53
|
+
import {
|
|
54
|
+
TABLE_STACK_AT, tableFilterActiveCount, tableFiltersToggleProps, tableFiltersToggleShown, tableHiddenInExpansion, tableHiddenPriorities, tablePriorityColumns, tableResponsiveClasses, tableResponsivePageLinks,
|
|
55
|
+
tableStacked, type TablePriorityBreakpoints, type TableResponsiveMode,
|
|
56
|
+
} from '@poadio/ui-core';
|
|
57
|
+
import {
|
|
58
|
+
TABLE_ACTIONS_WIDTH, tableHasActionsColumn, tableHasSticky, tableScrollShadow, tableStickyClass, tableStickyKeys, tableStickyOffsets, tableStickyRootClasses, tableStickyStyle,
|
|
59
|
+
tableStickyWidths, tableStickyWidthsEqual, type TablePinnedColumns, type TableStickyKeys, type TableStickySide,
|
|
60
|
+
} from '@poadio/ui-core';
|
|
53
61
|
import { checkboxNode } from './checkbox.js';
|
|
54
62
|
import { h, type Child } from './dom.js';
|
|
55
63
|
import { PoadElement } from './element.js';
|
|
@@ -92,7 +100,17 @@ export interface PoadTableColumn extends TableColumnDef {
|
|
|
92
100
|
readonly headerCell?: (column: PoadTableColumn) => string | Node;
|
|
93
101
|
/** Rendu du filtre de la colonne (sinon `renderFilter`, puis le champ selon le type) ; `filter(valeur, mode)` pose le filtre. */
|
|
94
102
|
readonly filterCell?: (ctx: PoadTableFilterContext) => string | Node | null | undefined;
|
|
103
|
+
/** Colonne figée à gauche ou à droite pendant le défilement horizontal. */
|
|
104
|
+
readonly sticky?: TableStickySide | null;
|
|
105
|
+
/** Priorité en mode `responsive="priority"` : 5 masquée en premier, 1 (ou absente) jamais. */
|
|
106
|
+
readonly priority?: number | null;
|
|
95
107
|
}
|
|
108
|
+
/** Contexte de `renderExpansion` : la ligne, sa place, les colonnes masquées par priorité. */
|
|
109
|
+
export interface PoadTableExpansionContext { readonly row: Row; readonly rowIndex: number; readonly hiddenColumns: readonly PoadTableColumn[] }
|
|
110
|
+
/** Contexte de `renderRowActions` : la ligne, sa place, son nœud (arbre, groupes). */
|
|
111
|
+
export interface PoadTableRowActionsContext { readonly row: Row; readonly rowIndex: number; readonly node: TableNode<Row> | null }
|
|
112
|
+
/** Contexte de `renderCard` : la ligne, sa place, son nœud, si elle est choisie. */
|
|
113
|
+
export interface PoadTableCardContext extends PoadTableRowActionsContext { readonly selected: boolean }
|
|
96
114
|
export interface PoadTableSortDetail { readonly field: string | null; readonly order: TableSortOrder; readonly multiSortMeta: TableSortMeta[] }
|
|
97
115
|
export interface PoadTableLazyLoadDetail {
|
|
98
116
|
readonly first: number; readonly rows: number; readonly sortField: string | null; readonly sortOrder: TableSortOrder; readonly multiSortMeta: TableSortMeta[];
|
|
@@ -145,8 +163,10 @@ export class PoadTableElement extends PoadElement {
|
|
|
145
163
|
groupBy: 'json', aggregates: 'json', showGrandTotal: 'boolean', grandTotalLabel: 'string', groupSort: 'json', hideGroupedColumns: 'boolean', expandedGroups: 'json',
|
|
146
164
|
treeField: 'string', parentKey: 'string', treeColumn: 'string', indent: 'string', showTreeLines: 'boolean', expandedNodeKeys: 'json', keepAncestors: 'boolean',
|
|
147
165
|
selectionPropagation: 'string', lazyChildren: 'boolean',
|
|
166
|
+
rowActionsWidth: 'string', rowActionsAlwaysVisible: 'boolean', stickyFirstColumn: 'boolean', stickyActions: 'boolean', pinnedColumns: 'json',
|
|
167
|
+
responsive: 'string', stackAt: 'number', priorityBreakpoints: 'json', showHiddenInExpansion: 'boolean', filtersLabel: 'string',
|
|
148
168
|
} as const;
|
|
149
|
-
static override functions = ['renderCell', 'renderHeader', 'cellFormatter', 'rowSelectable', 'rowClass', 'renderFilter', 'renderRowCount', 'renderExpansion', 'groupLabel', 'renderGroupHeader', 'renderGroupFooter', 'treeIcon', 'hasChildren', 'loadChildren'] as const;
|
|
169
|
+
static override functions = ['renderCell', 'renderHeader', 'cellFormatter', 'rowSelectable', 'rowClass', 'renderFilter', 'renderRowCount', 'renderExpansion', 'groupLabel', 'renderGroupHeader', 'renderGroupFooter', 'treeIcon', 'hasChildren', 'loadChildren', 'renderRowActions', 'renderCard'] as const;
|
|
150
170
|
/** Lignes de la table. */
|
|
151
171
|
declare value?: readonly Row[];
|
|
152
172
|
/** Les colonnes, en données. */
|
|
@@ -277,7 +297,46 @@ export class PoadTableElement extends PoadElement {
|
|
|
277
297
|
*/
|
|
278
298
|
declare expandMode?: TableExpandMode;
|
|
279
299
|
/** Contenu de la ligne de détail d'une ligne dépliée : ({ row, rowIndex }) → texte ou nœud ; sa présence ajoute la colonne du bouton de dépliage. */
|
|
280
|
-
declare renderExpansion?: (ctx:
|
|
300
|
+
declare renderExpansion?: (ctx: PoadTableExpansionContext) => string | Node | null | undefined;
|
|
301
|
+
/** Actions d'une ligne (boutons, menu), dans la dernière colonne : ({ row, rowIndex, node }) → texte, nœud ou nœuds ; sa présence ajoute la colonne des actions. Un clic n'y choisit pas la ligne. */
|
|
302
|
+
declare renderRowActions?: (ctx: PoadTableRowActionsContext) => string | Node | readonly Node[] | null | undefined;
|
|
303
|
+
/**
|
|
304
|
+
* Largeur de la colonne des actions (valeur CSS).
|
|
305
|
+
* @default '120px'
|
|
306
|
+
*/
|
|
307
|
+
declare rowActionsWidth?: string;
|
|
308
|
+
/** Actions toujours visibles ; sinon au survol, au focus dans la ligne et sur la ligne choisie. */
|
|
309
|
+
declare rowActionsAlwaysVisible?: boolean;
|
|
310
|
+
/** Fige la première colonne (et les colonnes de sélection et de détail qui la précèdent). */
|
|
311
|
+
declare stickyFirstColumn?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Colonne des actions figée à droite.
|
|
314
|
+
* @default true
|
|
315
|
+
*/
|
|
316
|
+
declare stickyActions?: boolean;
|
|
317
|
+
/** Épinglage à l'exécution, prioritaire sur `sticky` des colonnes : `{ [id]: 'left' | 'right' | null }` (`null` : détachée). */
|
|
318
|
+
declare pinnedColumns?: TablePinnedColumns;
|
|
319
|
+
/**
|
|
320
|
+
* Largeur réduite : `scroll` (défilement horizontal), `priority` (colonnes masquées selon leur `priority`) ou `stack` (lignes en cartes).
|
|
321
|
+
* @default 'scroll'
|
|
322
|
+
*/
|
|
323
|
+
declare responsive?: TableResponsiveMode;
|
|
324
|
+
/**
|
|
325
|
+
* Largeur du conteneur (px) sous laquelle le mode `stack` passe en cartes.
|
|
326
|
+
* @default 640
|
|
327
|
+
*/
|
|
328
|
+
declare stackAt?: number;
|
|
329
|
+
/** Largeurs du conteneur (px) sous lesquelles chaque priorité (2 à 5) est masquée en mode `priority`. */
|
|
330
|
+
declare priorityBreakpoints?: TablePriorityBreakpoints;
|
|
331
|
+
/**
|
|
332
|
+
* Colonnes masquées par priorité : la ligne se déplie sur elles.
|
|
333
|
+
* @default true
|
|
334
|
+
*/
|
|
335
|
+
declare showHiddenInExpansion?: boolean;
|
|
336
|
+
/** Contenu d'une carte en mode `stack` : ({ row, rowIndex, node, selected }) → texte ou nœud, à la place des libellés et valeurs. */
|
|
337
|
+
declare renderCard?: (ctx: PoadTableCardContext) => string | Node | null | undefined;
|
|
338
|
+
/** Libellé du bouton « Filtres » de la barre en cartes (défaut : message du catalogue). */
|
|
339
|
+
declare filtersLabel?: string;
|
|
281
340
|
/** Rendu du pied des comptes : (comptes) → texte ou nœud. */
|
|
282
341
|
declare renderRowCount?: (counts: { readonly total: number; readonly filtered: number; readonly selected: number }) => string | Node;
|
|
283
342
|
|
|
@@ -461,6 +520,39 @@ export class PoadTableElement extends PoadElement {
|
|
|
461
520
|
const s = tableSortState(metas);
|
|
462
521
|
return { first, rows, sortField: s.field, sortOrder: s.order, multiSortMeta: s.multiSortMeta, filters: this.filters ?? {}, globalFilter: this.globalFilter ?? '' };
|
|
463
522
|
}
|
|
523
|
+
// colonnes figées : largeurs mesurées après chaque rendu et au redimensionnement, ombres au défilement
|
|
524
|
+
private stickyKeys: TableStickyKeys = { left: [], right: [] };
|
|
525
|
+
private stickyWidths: Record<string, number> = {};
|
|
526
|
+
private shadow = { scrolledX: false, scrolledXEnd: true };
|
|
527
|
+
private resize: ResizeObserver | null = null;
|
|
528
|
+
private resized: HTMLElement | null = null;
|
|
529
|
+
/** Largeur du conteneur `.dt` (adaptation), `null` tant qu'elle est inconnue. */
|
|
530
|
+
private width: number | null = null;
|
|
531
|
+
private filtersOpen = false;
|
|
532
|
+
/** Mesure les en-têtes figés et le défilement ; redessine si quelque chose change. */
|
|
533
|
+
private measureSticky(): void {
|
|
534
|
+
const el = this.querySelector<HTMLElement>(':scope > .poad-table > .dt > .dt-scroll'); if (!el) return;
|
|
535
|
+
// le conteneur `.dt` est observé (l'hôte, en ligne, ne signale pas ses changements de taille) : sa largeur règle
|
|
536
|
+
// l'adaptation, et son redimensionnement mesure les colonnes figées
|
|
537
|
+
const dt = el.parentElement!;
|
|
538
|
+
if (dt !== this.resized) {
|
|
539
|
+
if (this.width == null) { const w = dt.getBoundingClientRect().width || null; if (w != null) { this.width = w; queueMicrotask(() => this.update()); } }
|
|
540
|
+
if (typeof ResizeObserver === 'function') {
|
|
541
|
+
this.resize ??= new ResizeObserver((entries) => {
|
|
542
|
+
const w = entries[0]?.contentRect.width;
|
|
543
|
+
if (w != null && w !== this.width) { this.width = w; this.update(); } else this.measureSticky();
|
|
544
|
+
});
|
|
545
|
+
if (this.resized) this.resize.unobserve(this.resized);
|
|
546
|
+
this.resize.observe(dt); this.resized = dt;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const k = this.stickyKeys;
|
|
550
|
+
const next = tableHasSticky(k) ? tableStickyWidths(k, [...el.querySelectorAll<HTMLElement>('thead > tr:first-child > th[data-sk]')].map((th) => [th.dataset['sk']!, th.getBoundingClientRect().width] as const)) : {};
|
|
551
|
+
const sh = tableScrollShadow(el);
|
|
552
|
+
const changed = !tableStickyWidthsEqual(this.stickyWidths, next) || sh.scrolledX !== this.shadow.scrolledX || sh.scrolledXEnd !== this.shadow.scrolledXEnd;
|
|
553
|
+
this.stickyWidths = next; this.shadow = sh;
|
|
554
|
+
if (changed) this.update();
|
|
555
|
+
}
|
|
464
556
|
private tbody(): HTMLElement | null {
|
|
465
557
|
return this.querySelector<HTMLElement>(':scope > .poad-table > .dt > .dt-scroll > table > tbody');
|
|
466
558
|
}
|
|
@@ -470,11 +562,14 @@ export class PoadTableElement extends PoadElement {
|
|
|
470
562
|
this.timers.forEach(clearTimeout);
|
|
471
563
|
this.timers.clear();
|
|
472
564
|
this.filterRowState?.dispose();
|
|
565
|
+
this.resize?.disconnect();
|
|
566
|
+
this.resize = null; this.resized = null;
|
|
473
567
|
}
|
|
474
568
|
|
|
475
569
|
protected override updated(): void {
|
|
476
570
|
this.filterRowState?.sync();
|
|
477
571
|
tableWatchers.get(this)?.forEach((fn) => fn());
|
|
572
|
+
this.measureSticky();
|
|
478
573
|
if (!this.loadedOnce) {
|
|
479
574
|
this.loadedOnce = true;
|
|
480
575
|
if (this.lazy && this.lazyLoadOnInit !== false) this.emit('lazyload', this.lazyDetail(this.first ?? 0, this.rows ?? 25, this.metas));
|
|
@@ -508,7 +603,13 @@ export class PoadTableElement extends PoadElement {
|
|
|
508
603
|
first: this.paginator && !this.lazy ? first : 0, rows: this.paginator && !this.lazy ? rows : 0,
|
|
509
604
|
}) : null;
|
|
510
605
|
const page = shown ? shown.filter((n) => n.kind === 'row').map((n) => n.row) : this.paginator && !this.lazy ? tablePageRows(sorted, first, rows) : sorted;
|
|
511
|
-
const
|
|
606
|
+
const responsive = this.responsive ?? 'scroll';
|
|
607
|
+
const hiddenPriorities = tableHiddenPriorities({ mode: responsive, width: this.width, breakpoints: this.priorityBreakpoints });
|
|
608
|
+
const stacked = tableStacked({ mode: responsive, width: this.width, stackAt: this.stackAt ?? TABLE_STACK_AT });
|
|
609
|
+
const tools = slotted(this.content, 'toolbar');
|
|
610
|
+
// colonnes : masquées, regroupées (cachées), puis masquées par priorité (elles passent dans le détail)
|
|
611
|
+
const { visible: columns, hidden: hiddenColumns } = tablePriorityColumns(
|
|
612
|
+
tableGroupVisibleColumns(allColumns.filter((c) => !c.hidden), tableGroupFields(this.groupBy as TableGroupBy<unknown> | null), this.hideGroupedColumns ?? true), hiddenPriorities);
|
|
512
613
|
const keyOf = this.keyOf;
|
|
513
614
|
const selected = tableSelectionArray<Row>(this.selection as Row | Row[] | null);
|
|
514
615
|
const selectedKeys = tableSelectionKeys<Row>(this.selection as Row | Row[] | null, keyOf);
|
|
@@ -685,14 +786,24 @@ export class PoadTableElement extends PoadElement {
|
|
|
685
786
|
const ta = tableRootProps({ mode, hierarchical: !!grouped, busy: this.loading, rowCount: total, headerRows });
|
|
686
787
|
const counts = tableCounts({ total: this.lazy ? total : value.length, filtered: total, selected: selCount });
|
|
687
788
|
// ---- ligne de détail ----
|
|
688
|
-
const hasExp = tableHasExpandColumn({ hasTemplate: !!this.renderExpansion, rowExpandable: this.rowExpandable });
|
|
789
|
+
const hasExp = tableHasExpandColumn({ hasTemplate: !!this.renderExpansion || tableHiddenInExpansion({ showHiddenInExpansion: this.showHiddenInExpansion, hiddenCount: hiddenColumns.length }), rowExpandable: this.rowExpandable });
|
|
689
790
|
const expandedSet = tableExpandedSet(this.expandedRowKeys);
|
|
690
791
|
const toggleExpand = (row: Row, i: number) => {
|
|
691
792
|
const r = tableExpandToggle(this.expandedRowKeys, keyOf(row), this.expandMode ?? 'multiple');
|
|
692
793
|
this.expandedRowKeys = r.next;
|
|
693
794
|
this.emit(r.expanded ? 'rowexpand' : 'rowcollapse', { row, index: i } satisfies PoadTableRowDetail);
|
|
694
795
|
};
|
|
695
|
-
|
|
796
|
+
// ---- actions de ligne ----
|
|
797
|
+
const hasActs = tableHasActionsColumn({ hasTemplate: !!this.renderRowActions });
|
|
798
|
+
const colspan = tableColspan({ columns: columns.length, selection: hasSel, extra: (hasExp ? 1 : 0) + (hasActs ? 1 : 0) });
|
|
799
|
+
// ---- colonnes figées (calcul du socle) ----
|
|
800
|
+
const stickyKeys = this.stickyKeys = tableStickyKeys({
|
|
801
|
+
columns: columns.map((c) => ({ id: tableColumnId(c), sticky: c.sticky })), pinned: this.pinnedColumns, stickyFirstColumn: this.stickyFirstColumn, selection: hasSel,
|
|
802
|
+
expand: hasExp, actions: hasActs, stickyActions: this.stickyActions, responsive, stacked,
|
|
803
|
+
});
|
|
804
|
+
const offsets = tableStickyOffsets(stickyKeys, this.stickyWidths);
|
|
805
|
+
/** Classe et décalage d'une cellule (`key` : `sel`, `exp`, `acts` ou l'id d'une colonne). */
|
|
806
|
+
const stk = (key: string, base = '') => ({ class: [base, tableStickyClass(stickyKeys, key)].filter(Boolean).join(' ') || undefined, style: tableStickyStyle(offsets, key) ?? undefined });
|
|
696
807
|
const check = (id: string, checked: boolean, label: string, onToggle: () => void, indeterminate?: boolean) =>
|
|
697
808
|
checkboxNode(registry, { id: `${this.uid}-${id}`, checked, indeterminate, ariaLabel: label, onToggle });
|
|
698
809
|
// ---- groupes ----
|
|
@@ -706,9 +817,10 @@ export class PoadTableElement extends PoadElement {
|
|
|
706
817
|
const grand = !!grouped && tableShowsGrandTotal({ showGrandTotal: this.showGrandTotal, aggregates: this.aggregates, hierarchical: true });
|
|
707
818
|
/** Cellules d'agrégats (pied de groupe, total général) : libellé dans la première colonne sans agrégat. */
|
|
708
819
|
const aggregateCells = (values: Record<string, unknown>, label: Child): Child[] => [
|
|
709
|
-
hasSel && h('td',
|
|
710
|
-
hasExp && h('td',
|
|
711
|
-
columns.map((c, ci) => h('td', {
|
|
820
|
+
hasSel && h('td', stk('sel', 'col-sel')),
|
|
821
|
+
hasExp && h('td', stk('exp', 'col-exp')),
|
|
822
|
+
columns.map((c, ci) => h('td', { ...stk(tableColumnId(c), tableTdClasses(c)), 'data-l': c.header }, tableHasAggregate(c.field, this.aggregates) ? format(values[c.field!], c, undefined) : ci === 0 ? label : null)),
|
|
823
|
+
hasActs && h('td', stk('acts', 'col-acts')),
|
|
712
824
|
];
|
|
713
825
|
const groupRow = (n: TableNode<Row>, gi: number): Child => {
|
|
714
826
|
const gp = tableGroupHeaderProps(n);
|
|
@@ -732,7 +844,14 @@ export class PoadTableElement extends PoadElement {
|
|
|
732
844
|
const idx = sortMode === 'multiple' ? tableSortIndex(metas, field) : 0;
|
|
733
845
|
const hp = tableHeaderCellProps({ ariaSort: tableAriaSort(metas, field, !!c.sortable) });
|
|
734
846
|
const custom = c.headerCell?.(c) ?? this.renderHeader?.(c);
|
|
735
|
-
|
|
847
|
+
// classes : alignement, colonne figée, puis les autres (ordre d'ui-angular)
|
|
848
|
+
const id = tableColumnId(c);
|
|
849
|
+
const [al, ...others] = tableThClasses(c, order !== 0).split(' ');
|
|
850
|
+
const sticky = tableStickyStyle(offsets, id);
|
|
851
|
+
return h('th', {
|
|
852
|
+
scope: hp.scope, class: [al, tableStickyClass(stickyKeys, id), ...others].filter(Boolean).join(' '), 'aria-sort': hp['aria-sort'], 'data-sk': id,
|
|
853
|
+
style: c.width || sticky ? { width: c.width, ...sticky } : undefined,
|
|
854
|
+
}, custom != null ? custom : c.sortable
|
|
736
855
|
? h('button', { type: 'button', class: 'hd', 'aria-label': t('table.sortBy', { column: c.header ?? '' }), onclick: (e: MouseEvent) => sortBy(c, e) }, [
|
|
737
856
|
h('span', { class: 'hd-txt' }, c.header ?? ''),
|
|
738
857
|
icon(registry, tableSortIcon(order), { size: 12 }),
|
|
@@ -753,23 +872,26 @@ export class PoadTableElement extends PoadElement {
|
|
|
753
872
|
ic && h('span', { class: 'ic' }, icon(registry, ic, { size: 14 })),
|
|
754
873
|
]);
|
|
755
874
|
};
|
|
756
|
-
|
|
875
|
+
/** Contenu d'une cellule : rendu de la colonne, `renderCell`, sinon le texte mis en forme de la valeur. */
|
|
876
|
+
const content = (row: Row, i: number, c: PoadTableColumn, node: TableNode<Row> | null): Child => {
|
|
757
877
|
const v = c.field ? tableResolve(row, c.field) : undefined;
|
|
758
878
|
const ctx: PoadTableCellContext = { row, value: v, rowIndex: i, column: c, node };
|
|
759
879
|
const custom = c.cell?.(ctx) ?? this.renderCell?.(ctx);
|
|
880
|
+
return custom != null ? custom : h('span', { class: 'cell-txt' }, format(v, c, row));
|
|
881
|
+
};
|
|
882
|
+
const cell = (row: Row, i: number, c: PoadTableColumn, ci: number, node: TableNode<Row> | null) => {
|
|
760
883
|
const tree = !!node && ci === treeCol;
|
|
761
|
-
return h('td', {
|
|
762
|
-
tree
|
|
763
|
-
? h('span', { class: 'dt-tree-wrap' }, [treeToggle(node), custom != null ? custom : h('span', { class: 'cell-txt' }, format(v, c, row))])
|
|
764
|
-
: custom != null ? custom : h('span', { class: 'cell-txt' }, format(v, c, row)),
|
|
884
|
+
return h('td', { ...stk(tableColumnId(c), tableTdClasses(c) + (tree ? ' dt-tree-cell' : '') + (ci === 0 ? ' dt-first' : '')), 'data-l': c.header }, [
|
|
885
|
+
tree ? h('span', { class: 'dt-tree-wrap' }, [treeToggle(node), content(row, i, c, node)]) : content(row, i, c, node),
|
|
765
886
|
]);
|
|
766
887
|
};
|
|
767
888
|
const bodyRows = (): Child => {
|
|
768
889
|
if (body === 'skeleton') {
|
|
769
890
|
return Array.from({ length: this.loadingRows ?? 5 }, (_, r) => h('tr', { class: 'dt-row is-skeleton', 'aria-hidden': 'true' }, [
|
|
770
|
-
hasSel && h('td',
|
|
771
|
-
hasExp && h('td',
|
|
772
|
-
columns.map((c, ci) => h('td',
|
|
891
|
+
hasSel && h('td', stk('sel', 'col-sel')),
|
|
892
|
+
hasExp && h('td', stk('exp', 'col-exp')),
|
|
893
|
+
columns.map((c, ci) => h('td', stk(tableColumnId(c), tableTdClasses(c)), h('div', { class: 'skel', style: { width: tableSkeletonWidth(r, ci) + '%', marginLeft: tableColumnAlign(c) === 'right' ? 'auto' : undefined } }))),
|
|
894
|
+
hasActs && h('td', stk('acts', 'col-acts')),
|
|
773
895
|
]));
|
|
774
896
|
}
|
|
775
897
|
if (body === 'empty') {
|
|
@@ -793,8 +915,8 @@ export class PoadTableElement extends PoadElement {
|
|
|
793
915
|
const eb = tableExpandButtonProps(open);
|
|
794
916
|
const np = node ? tableNodeRowProps(node) : null;
|
|
795
917
|
const st = node && grouped && mode === 'multiple' ? tableTreeNodeState(node, grouped, { isSelected: isSel, canSelect, propagation: isTree ? propagation : 'none' }) : sel ? 'on' : 'off';
|
|
796
|
-
const
|
|
797
|
-
|
|
918
|
+
const rowClass = tableRowClasses({ selectable: hasSel && canSelect(row), hasSelectionColumn: hasSel, selected: sel, extra: [open ? 'is-expanded' : '', node ? tableTreeRowClasses(node) : '', this.rowClass?.(row, i) ?? ''].filter(Boolean).join(' ') || null });
|
|
919
|
+
const trProps = {
|
|
798
920
|
'data-key': this.dataKey ? String(track) : undefined, tabindex: node ? (i === activeAt ? 0 : -1) : rp.tabindex, 'aria-selected': rp['aria-selected'], 'aria-rowindex': node ? undefined : rp['aria-rowindex'],
|
|
799
921
|
style: node ? { '--_lvl': String(node.level) } : undefined, role: np ? 'row' : undefined, 'aria-level': np?.['aria-level'], 'aria-expanded': np?.['aria-expanded'] ?? undefined, 'aria-posinset': np?.['aria-posinset'], 'aria-setsize': np?.['aria-setsize'],
|
|
800
922
|
onclick: (e: MouseEvent) => onRowClick(row, i, e), ondblclick: () => this.emit('rowdblclick', { row, index: i } satisfies PoadTableRowDetail),
|
|
@@ -806,20 +928,27 @@ export class PoadTableElement extends PoadElement {
|
|
|
806
928
|
this.activeKey = track;
|
|
807
929
|
this.tbody()?.querySelectorAll(':scope > tr.dt-row').forEach((tr) => { if (tr.hasAttribute('tabindex')) tr.setAttribute('tabindex', tr === e.currentTarget ? '0' : '-1'); });
|
|
808
930
|
},
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
|
|
931
|
+
};
|
|
932
|
+
// carte de l'application (mode `stack`) : toute la ligne
|
|
933
|
+
if (stacked && this.renderCard) return h('tr', { class: rowClass + ' dt-card', ...trProps }, h('td', { colspan }, this.renderCard({ row, rowIndex: i, node, selected: sel }) ?? null));
|
|
934
|
+
const tr = h('tr', { class: rowClass, ...trProps }, [
|
|
935
|
+
hasSel && h('td', stk('sel', 'col-sel'), canSelect(row) && check(`r${i}`, st === 'on', t('table.selectRow', { index: i + 1 }), () => (mode === 'multiple' ? toggleRow(row, i) : selectSingle(row, i)), st === 'some')),
|
|
936
|
+
hasExp && h('td', stk('exp', 'col-exp'), tableCanExpand(row, this.rowExpandable) && h('button', {
|
|
812
937
|
type: 'button', class: 'exp', 'aria-expanded': eb['aria-expanded'], 'aria-label': t(eb.labelKey), onclick: () => toggleExpand(row, i),
|
|
813
938
|
}, icon(registry, 'chevron-right', { size: 13 }))),
|
|
814
939
|
columns.map((c, ci) => cell(row, i, c, ci, node)),
|
|
940
|
+
hasActs && h('td', stk('acts', 'col-acts'), h('span', { class: 'acts', onclick: (e: MouseEvent) => e.stopPropagation() }, (this.renderRowActions!({ row, rowIndex: i, node }) ?? null) as Child)),
|
|
815
941
|
]);
|
|
816
|
-
|
|
942
|
+
if (!open) return tr;
|
|
943
|
+
const detail = this.renderExpansion ? this.renderExpansion({ row, rowIndex: i, hiddenColumns }) ?? null
|
|
944
|
+
: h('div', { class: 'kv' }, hiddenColumns.map((c) => h('div', {}, [h('b', {}, c.header || c.field), content(row, i, c, node)])));
|
|
945
|
+
return [tr, h('tr', { class: 'dt-detail', style: node ? { '--_lvl': String(node.level) } : undefined }, h('td', { colspan }, detail))];
|
|
817
946
|
});
|
|
818
947
|
};
|
|
819
948
|
|
|
820
949
|
const caption = slotted(this.content, 'caption');
|
|
821
950
|
return h('div', {
|
|
822
|
-
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 }), { 'is-grouped': !!this.groupBy && !(Array.isArray(this.groupBy) && !this.groupBy.length), 'is-tree': isTree, 'has-tree-lines': !!this.showTreeLines }],
|
|
951
|
+
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 }), { 'is-grouped': !!this.groupBy && !(Array.isArray(this.groupBy) && !this.groupBy.length), 'is-tree': isTree, 'has-tree-lines': !!this.showTreeLines, ...tableStickyRootClasses({ ...this.shadow, sticky: tableHasSticky(stickyKeys), actionsAlwaysVisible: this.rowActionsAlwaysVisible }), ...tableResponsiveClasses({ stacked, hidden: hiddenPriorities }) }],
|
|
823
952
|
style: this.bodyMaxHeight || hasExp || (isTree && this.indent) ? {
|
|
824
953
|
'--_scroll-h': this.bodyMaxHeight, '--_detail-pl': hasExp ? tableDetailPaddingLeft({ selection: hasSel, expand: true }) : undefined, ...(isTree ? tableTreeRootVars(this.indent) : {}),
|
|
825
954
|
} : undefined,
|
|
@@ -833,12 +962,18 @@ export class PoadTableElement extends PoadElement {
|
|
|
833
962
|
]) : (this.showToolbar ?? true) && h('div', { class: 'dt-bar' }, [
|
|
834
963
|
this.heading && h('span', { class: 'dt-bar__title' }, this.heading),
|
|
835
964
|
(this.showCount ?? true) && h('span', { class: 'dt-bar__count' }, String(this.count ?? total)),
|
|
836
|
-
|
|
965
|
+
tableFiltersToggleShown({ stacked, hasTools: tools.length > 0 }) && (() => {
|
|
966
|
+
const ft = tableFiltersToggleProps(this.filtersOpen); const active = tableFilterActiveCount(filters);
|
|
967
|
+
return h('button', { type: 'button', class: ft.className, 'aria-expanded': ft['aria-expanded'], onclick: () => { this.filtersOpen = !this.filtersOpen; this.update(); } }, [
|
|
968
|
+
icon(registry, 'filter', { size: 13 }), text(this.filtersLabel, ft.labelKey), active > 0 && h('span', { class: 'dt-bar__count' }, String(active)),
|
|
969
|
+
]);
|
|
970
|
+
})(),
|
|
971
|
+
h('span', { class: ['dt-bar__tools', { 'is-open': this.filtersOpen }] }, tools),
|
|
837
972
|
h('span', { class: 'dt-bar__grow' }),
|
|
838
973
|
this.showSearch && tableSearch(i18n, registry, { text: this.searchText ?? this.globalFilter ?? '', placeholder: this.searchPlaceholder, onSearch }),
|
|
839
974
|
h('span', { class: 'dt-bar__tools-end' }, slotted(this.content, 'toolbar-end')),
|
|
840
975
|
]),
|
|
841
|
-
h('div', { class: 'dt-scroll' }, [
|
|
976
|
+
h('div', { class: 'dt-scroll', onscroll: () => this.measureSticky() }, [
|
|
842
977
|
tableShowsOverlay({ loading: this.loading, hasData: value.length > 0 }) && h('div', { class: 'dt-loading' }, icon(registry, 'loader', { size: 22, spin: true })),
|
|
843
978
|
h('table', {
|
|
844
979
|
class: this.tableClass ? 'tbl ' + this.tableClass : 'tbl', role: ta.role, 'aria-rowcount': ta['aria-rowcount'], 'aria-busy': ta['aria-busy'],
|
|
@@ -849,17 +984,20 @@ export class PoadTableElement extends PoadElement {
|
|
|
849
984
|
hasSel && h('col', { style: { width: '36px' } }),
|
|
850
985
|
hasExp && h('col', { style: { width: '30px' } }),
|
|
851
986
|
columns.map((c) => h('col', { style: { width: c.width, minWidth: c.minWidth, maxWidth: c.maxWidth } })),
|
|
987
|
+
hasActs && h('col', { style: { width: this.rowActionsWidth ?? TABLE_ACTIONS_WIDTH } }),
|
|
852
988
|
]),
|
|
853
989
|
h('thead', {}, [
|
|
854
990
|
h('tr', { 'aria-rowindex': tableHeaderRowProps(0)['aria-rowindex'] }, [
|
|
855
|
-
hasSel && h('th', {
|
|
856
|
-
hasExp && h('th', {
|
|
991
|
+
hasSel && h('th', { ...stk('sel', 'col-sel'), scope: 'col', 'data-sk': 'sel' }, mode === 'multiple' && (this.selectAll ?? true) && check('all', allState === 'all', t('table.selectAll'), toggleAll, allState === 'some')),
|
|
992
|
+
hasExp && h('th', { ...stk('exp', 'col-exp'), scope: 'col', 'data-sk': 'exp' }, h('span', { hidden: true }, t('table.detail'))),
|
|
857
993
|
columns.map(header),
|
|
994
|
+
hasActs && h('th', { ...stk('acts', 'col-acts'), scope: 'col', 'data-sk': 'acts' }, h('span', { hidden: true }, t('table.actions'))),
|
|
858
995
|
]),
|
|
859
996
|
hasFilterRow && h('tr', { class: 'flt', 'aria-rowindex': tableHeaderRowProps(1)['aria-rowindex'] }, [
|
|
860
|
-
hasSel && h('th',
|
|
861
|
-
hasExp && h('th',
|
|
862
|
-
columns.map((c) => h('th',
|
|
997
|
+
hasSel && h('th', stk('sel')),
|
|
998
|
+
hasExp && h('th', stk('exp')),
|
|
999
|
+
columns.map((c) => h('th', stk(tableColumnId(c)), this.filterRow.cell(i18n, registry, filters, c, actions, c.filterCell ?? this.renderFilter))),
|
|
1000
|
+
hasActs && h('th', stk('acts')),
|
|
863
1001
|
]),
|
|
864
1002
|
]),
|
|
865
1003
|
h('tbody', {}, bodyRows()),
|
|
@@ -869,7 +1007,7 @@ export class PoadTableElement extends PoadElement {
|
|
|
869
1007
|
((this.paginator && (total > 0 || this.lazy)) || this.showRowCount) && h('div', { class: ['dt-foot', { 'has-count': !!this.showRowCount }] }, [
|
|
870
1008
|
this.showRowCount && h('span', { class: 'dt-foot__count' }, this.renderRowCount ? this.renderRowCount(counts) : tableRowCountParts(counts, (k, p) => t(k, p), this.rowCountLabel).join(' · ')),
|
|
871
1009
|
this.paginator && (total > 0 || this.lazy) && paginatorView(i18n, registry, {
|
|
872
|
-
first, rows, totalRecords: pageTotal, rowsPerPageOptions: this.rowsPerPageOptions, pageLinks: this.pageLinks, showCurrentPageReport: this.showCurrentPageReport,
|
|
1010
|
+
first, rows, totalRecords: pageTotal, rowsPerPageOptions: this.rowsPerPageOptions, pageLinks: tableResponsivePageLinks(stacked, this.pageLinks ?? 5), showCurrentPageReport: this.showCurrentPageReport,
|
|
873
1011
|
currentPageReportTemplate: this.currentPageReportTemplate, showFirstLastIcon: this.showFirstLastIcon, alwaysShow: this.alwaysShowPaginator, onPage: changePage,
|
|
874
1012
|
owner: this, selectTag: this.tag('select'),
|
|
875
1013
|
}),
|