@mintplayer/web-components 2.17.0 → 2.19.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/chunks/mp-datatable-BeKunRfd.mjs +2884 -0
- package/custom-elements.json +7678 -6749
- package/datatable/index.mjs +1 -1
- package/datatable/src/components/column-resize.d.ts +22 -0
- package/datatable/src/components/index.d.ts +1 -1
- package/datatable/src/components/mp-datatable.d.ts +403 -24
- package/datatable/src/index.d.ts +1 -1
- package/datatable/src/types/column-def.d.ts +13 -1
- package/datatable/src/types/labels.d.ts +28 -0
- package/file-manager/index.mjs +1 -1
- package/package.json +1 -1
- package/chunks/mp-datatable-eRpl7-2V.mjs +0 -2238
package/datatable/index.mjs
CHANGED
|
@@ -9,3 +9,25 @@ export declare const KEYBOARD_RESIZE_STEP = 10;
|
|
|
9
9
|
* floor.
|
|
10
10
|
*/
|
|
11
11
|
export declare function resizedColumnWidth(startWidth: number, delta: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* The furthest measured columns are scaled down to keep fitting a narrowing
|
|
14
|
+
* scroller. Past it they keep this share and the table scrolls: crushing them
|
|
15
|
+
* to the floor would overflow anyway (measured: a desktop table narrowed to
|
|
16
|
+
* 254px clamps to 40px columns and still overflows), with every cell an
|
|
17
|
+
* ellipsis on the way there.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MIN_REFIT_SCALE = 0.75;
|
|
20
|
+
/**
|
|
21
|
+
* Movement, in px, below which a press on a resize handle is a TAP: it opens
|
|
22
|
+
* the resize options instead of resizing. Without it a finger, which never
|
|
23
|
+
* lands perfectly still, would nudge the column on every tap.
|
|
24
|
+
*/
|
|
25
|
+
export declare const RESIZE_TAP_SLOP = 4;
|
|
26
|
+
/**
|
|
27
|
+
* The width that shows the widest of `contentWidths` (each already including
|
|
28
|
+
* its cell's padding) without an ellipsis. Rounded UP, unlike the initial
|
|
29
|
+
* measurement: here a sub-pixel short would clip the very content the user
|
|
30
|
+
* asked to see, and the column was explicitly sized, so overflowing the
|
|
31
|
+
* scroller is the requested outcome rather than a phantom scrollbar.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fittedColumnWidth(contentWidths: readonly number[]): number | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { MpDatatable } from './mp-datatable';
|
|
2
|
-
export type { DatatableSelectionMode, RowEventDetail, SortChangeEventDetail, SelectionChangeEventDetail, } from './mp-datatable';
|
|
2
|
+
export type { DatatableSelectionMode, RowEventDetail, SortChangeEventDetail, SelectionChangeEventDetail, DatatableFetchState, DatatableReloadOptions, } from './mp-datatable';
|
|
@@ -2,26 +2,58 @@ import { LitElement, TemplateResult } from 'lit';
|
|
|
2
2
|
import { DatatableLabels } from '../types/labels';
|
|
3
3
|
import { SortColumn } from '../sort';
|
|
4
4
|
import { DatatableColumnDef, RowKey, RowRenderer, DatatableFetch, DatatableDistincts, TreeIdKey, TreeSelectionStrategy } from '../types';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* - `'none'`: rows are not selectable.
|
|
7
|
+
* - `'single'`: a row click or Enter/Space selects that one row.
|
|
8
|
+
* - `'multiple'`: a row click selects (Ctrl/Cmd toggles, Shift selects a range),
|
|
9
|
+
* and a checkbox column toggles rows individually.
|
|
10
|
+
* - `'checkbox'`: multi-select through the checkbox column ONLY. A row click and
|
|
11
|
+
* Enter emit `mp-datatable-row-click` without selecting, so a row can open
|
|
12
|
+
* something; Space toggles the focused row's checkbox.
|
|
13
|
+
*/
|
|
14
|
+
export type DatatableSelectionMode = 'none' | 'single' | 'multiple' | 'checkbox';
|
|
6
15
|
export interface RowEventDetail<T = unknown> {
|
|
7
16
|
row: T;
|
|
8
17
|
rowIndex: number;
|
|
9
18
|
rowKey: string;
|
|
10
19
|
originalEvent: Event;
|
|
11
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The fetch-driving state `applyFetchState` applies as one change. Every field
|
|
23
|
+
* is optional; see that method for the absent-field rules.
|
|
24
|
+
*/
|
|
25
|
+
export interface DatatableFetchState {
|
|
26
|
+
fetch?: DatatableFetch | null;
|
|
27
|
+
sortColumns?: SortColumn[];
|
|
28
|
+
page?: number;
|
|
29
|
+
perPage?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Options for `reload()`. */
|
|
32
|
+
export interface DatatableReloadOptions {
|
|
33
|
+
/** Return to page 1 before re-fetching. Default `false`. */
|
|
34
|
+
resetPage?: boolean;
|
|
35
|
+
}
|
|
12
36
|
export interface SortChangeEventDetail {
|
|
13
37
|
sortColumns: SortColumn[];
|
|
14
38
|
}
|
|
15
39
|
export interface SelectionChangeEventDetail<T = unknown> {
|
|
16
|
-
selectedIds: string[];
|
|
17
40
|
/**
|
|
18
|
-
* The
|
|
19
|
-
*
|
|
20
|
-
* consumers can't resolve ids → rows themselves — this is how a consumer gets
|
|
21
|
-
* the actual selected records. An id whose row isn't currently loaded is
|
|
22
|
-
* omitted (shouldn't happen: you can only select a row you can see).
|
|
41
|
+
* The selection, authoritative. Act on this: it holds every selected key,
|
|
42
|
+
* including keys whose rows are on another page or were never loaded.
|
|
23
43
|
*/
|
|
24
|
-
|
|
44
|
+
selectedIds: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Index-aligned with `selectedIds`: `selectedRows[i]` is the row of
|
|
47
|
+
* `selectedIds[i]`. Render from this.
|
|
48
|
+
*
|
|
49
|
+
* A row is resolved from the loaded data first (page 1, fetched windows,
|
|
50
|
+
* tree children), so a re-fetched row object wins; otherwise from the rows
|
|
51
|
+
* the element remembered when they were selected, which is what keeps a row
|
|
52
|
+
* that has paged, sorted or re-fetched out of view. `undefined` marks a key
|
|
53
|
+
* whose row the element has never seen (a host seeded the key without its
|
|
54
|
+
* row). Nothing is dropped, so the two arrays always pair positionally.
|
|
55
|
+
*/
|
|
56
|
+
selectedRows: (T | undefined)[];
|
|
25
57
|
}
|
|
26
58
|
/**
|
|
27
59
|
* `<mp-datatable>` — property-driven data grid.
|
|
@@ -29,12 +61,15 @@ export interface SelectionChangeEventDetail<T = unknown> {
|
|
|
29
61
|
* - Columns are declared programmatically via `DatatableColumnDef[]`.
|
|
30
62
|
* Each column supplies a name (sort key) + optional `cellRenderer`.
|
|
31
63
|
* - Sort algorithm extracted into the pure `computeNextSort` helper.
|
|
32
|
-
* - Selection model: `'none' | 'single' | 'multiple'` with checkbox column
|
|
33
|
-
*
|
|
64
|
+
* - Selection model: `'none' | 'single' | 'multiple' | 'checkbox'` with a checkbox column
|
|
65
|
+
* in the multi-select modes (see `DatatableSelectionMode`).
|
|
34
66
|
* - Row events: `mp-datatable-row-click`, `mp-datatable-row-dblclick`,
|
|
35
67
|
* `mp-datatable-row-contextmenu` — all carry `RowEventDetail`.
|
|
36
68
|
* - Pagination footer when `pagination` enabled.
|
|
37
|
-
* - Column resize via a
|
|
69
|
+
* - Column resize via a handle at the right edge of each header (24px hit
|
|
70
|
+
* area, 40px on coarse pointers): drag, Left/Right arrows, or tap / Enter
|
|
71
|
+
* for an options dialog (narrower, wider, fit, reset). Per column via
|
|
72
|
+
* `DatatableColumnDef.resizable`, table-wide via `resizable-columns`.
|
|
38
73
|
*/
|
|
39
74
|
export declare class MpDatatable extends LitElement {
|
|
40
75
|
/**
|
|
@@ -62,9 +97,14 @@ export declare class MpDatatable extends LitElement {
|
|
|
62
97
|
set caption(value: string | null);
|
|
63
98
|
/**
|
|
64
99
|
* User-visible strings, overridable per key for localisation
|
|
65
|
-
* (see DatatableLabels). Property-only: it holds functions.
|
|
66
|
-
|
|
67
|
-
|
|
100
|
+
* (see DatatableLabels). Property-only: it holds functions. Re-renders on
|
|
101
|
+
* assignment, so switching language on a mounted table renames every
|
|
102
|
+
* control (row-checkbox names included) without waiting for an unrelated
|
|
103
|
+
* update.
|
|
104
|
+
*/
|
|
105
|
+
get labels(): Partial<DatatableLabels> | undefined;
|
|
106
|
+
set labels(value: Partial<DatatableLabels> | undefined);
|
|
107
|
+
private _labels;
|
|
68
108
|
/** Merged view of labels — consumer keys over the English defaults. */
|
|
69
109
|
private get mergedLabels();
|
|
70
110
|
/** Optional invisible accessible name for the <table>. Host aria-label wins. */
|
|
@@ -75,6 +115,14 @@ export declare class MpDatatable extends LitElement {
|
|
|
75
115
|
private _sortColumns;
|
|
76
116
|
private _selectionMode;
|
|
77
117
|
private _selectedIds;
|
|
118
|
+
/**
|
|
119
|
+
* The row of each selected key, remembered when it was selected (or seeded
|
|
120
|
+
* via `selectedRows`). Loaded data is replaced on every page change, sort and
|
|
121
|
+
* re-fetch, so without this a selected row that leaves the loaded set could
|
|
122
|
+
* no longer be reported. Keys ⊆ `_selectedIds`: every path that deselects
|
|
123
|
+
* prunes it, so it holds the selection's own rows and never mirrors the data.
|
|
124
|
+
*/
|
|
125
|
+
private _selectedRowCache;
|
|
78
126
|
private _cutIds;
|
|
79
127
|
private _focusedRowKey;
|
|
80
128
|
/** Polite announcements for async/derived state changes (sort, page,
|
|
@@ -89,10 +137,41 @@ export declare class MpDatatable extends LitElement {
|
|
|
89
137
|
* focus is elsewhere never steal it.
|
|
90
138
|
*/
|
|
91
139
|
private readonly rowFocusRestore;
|
|
140
|
+
/**
|
|
141
|
+
* The default key: the row's `id`, else its position. A positional key names
|
|
142
|
+
* a different row after every re-fetch, sort or tree expansion, so it cannot
|
|
143
|
+
* carry a selection across them — hence the one-time warning below.
|
|
144
|
+
*
|
|
145
|
+
* Worse, a row that is NOT loaded (an off-page selected row, a child of a
|
|
146
|
+
* collapsed parent) has no index at all and is keyed `rowKey(row, -1)`, so
|
|
147
|
+
* every id-less off-page row collapses onto the one key `row--1` and the
|
|
148
|
+
* selection can no longer tell them apart. A stable, id-based `rowKey` is
|
|
149
|
+
* therefore required for selection with `fetch` or pagination.
|
|
150
|
+
*/
|
|
92
151
|
private _rowKey;
|
|
152
|
+
private _warnedPositionalKey;
|
|
153
|
+
/**
|
|
154
|
+
* Warn rather than throw: a static table without ids keeps working, and only
|
|
155
|
+
* a fetched or selectable one is actually harmed by a positional key.
|
|
156
|
+
*/
|
|
157
|
+
private warnPositionalKeyOnce;
|
|
93
158
|
private _columnWidths;
|
|
159
|
+
/** Widths the measure pass chose, kept so Reset can return to them. */
|
|
160
|
+
private _measuredWidths;
|
|
161
|
+
/** Columns the user sized (drag, keys, the options dialog): never re-fitted. */
|
|
162
|
+
private _userWidths;
|
|
163
|
+
/**
|
|
164
|
+
* Text each column's header actually renders, read from a Node a
|
|
165
|
+
* headerRenderer returned. It names the column in generated strings when the
|
|
166
|
+
* consumer set no label, so a header template that says Artist is not
|
|
167
|
+
* announced by its internal key. See columnLabel().
|
|
168
|
+
*/
|
|
169
|
+
private _derivedLabels;
|
|
94
170
|
/** Becomes `true` after the first measure-once pass locks column widths. Drives the `.measured` class on the table (→ `table-layout: fixed`). */
|
|
95
171
|
private _hasMeasuredInitial;
|
|
172
|
+
/** Whether the natural column widths fitted the scroller at measurement; see refitMeasuredWidths. */
|
|
173
|
+
private _measuredFit;
|
|
174
|
+
private _refitFrame;
|
|
96
175
|
private _loading;
|
|
97
176
|
private _emptyMessage;
|
|
98
177
|
private _pagination;
|
|
@@ -109,6 +188,15 @@ export declare class MpDatatable extends LitElement {
|
|
|
109
188
|
private _virtualRange;
|
|
110
189
|
private _scrollElement;
|
|
111
190
|
private _resizeObserver;
|
|
191
|
+
/**
|
|
192
|
+
* Re-renders when a header's TEXT changes in place. A wrapper's header view
|
|
193
|
+
* (Angular's EmbeddedViewRef) updates its own nodes — a language switch, say
|
|
194
|
+
* — without any property of this element changing, so without this the
|
|
195
|
+
* names derived from header text would go stale until some unrelated render.
|
|
196
|
+
* A render that changes nothing mutates nothing, so it cannot loop.
|
|
197
|
+
*/
|
|
198
|
+
private _headerObserver;
|
|
199
|
+
private _observedThead;
|
|
112
200
|
private _scrollListener;
|
|
113
201
|
private _viewportHeight;
|
|
114
202
|
/** Name of the column whose filter panel is open, or null. Only ever one. */
|
|
@@ -143,7 +231,7 @@ export declare class MpDatatable extends LitElement {
|
|
|
143
231
|
private _fetch;
|
|
144
232
|
/** Bumped on invalidation; in-flight responses from an older generation are dropped. */
|
|
145
233
|
private _fetchGeneration;
|
|
146
|
-
/** Guards the one-time initial page-1 load. Reset
|
|
234
|
+
/** Guards the one-time initial page-1 load. Reset when the callback changes. */
|
|
147
235
|
private _initialFetchDone;
|
|
148
236
|
/** Coalesces multiple setter calls in one flush into a single reload. */
|
|
149
237
|
private _reloadScheduled;
|
|
@@ -193,9 +281,19 @@ export declare class MpDatatable extends LitElement {
|
|
|
193
281
|
* loop and the consumer provides nothing else — no page-1 seeding via `data`,
|
|
194
282
|
* no separate `totalRecords`, no event bridge. Works with any framework or
|
|
195
283
|
* none (`el.fetch = fn`). Setting it kicks off the initial page-1 load.
|
|
284
|
+
*
|
|
285
|
+
* Pass a STABLE function. Assigning the same function again is a no-op, but
|
|
286
|
+
* a new closure on every render is a new callback, and each one reloads. To
|
|
287
|
+
* re-query with an unchanged callback, call `reload()`.
|
|
196
288
|
*/
|
|
197
289
|
get fetch(): DatatableFetch | null;
|
|
198
290
|
set fetch(value: DatatableFetch | null);
|
|
291
|
+
/**
|
|
292
|
+
* Assigns the callback without scheduling a load; true when a load is due.
|
|
293
|
+
* Shared by the setter and `applyFetchState`, which schedules once for all
|
|
294
|
+
* of its fields.
|
|
295
|
+
*/
|
|
296
|
+
private assignFetch;
|
|
199
297
|
/**
|
|
200
298
|
* Consumer-supplied source of distinct values for the filter panels.
|
|
201
299
|
* Property-only (it holds a function), mirroring `fetch` and `labels`.
|
|
@@ -207,14 +305,85 @@ export declare class MpDatatable extends LitElement {
|
|
|
207
305
|
set distincts(value: DatatableDistincts | null);
|
|
208
306
|
get sortColumns(): SortColumn[];
|
|
209
307
|
set sortColumns(value: SortColumn[]);
|
|
308
|
+
/**
|
|
309
|
+
* Assigns without scheduling; false when the value is structurally equal. A
|
|
310
|
+
* wrapper echoing back the array it was just given is not a sort change, and
|
|
311
|
+
* must not cost a re-render or a request (#407).
|
|
312
|
+
*/
|
|
313
|
+
private assignSortColumns;
|
|
314
|
+
/**
|
|
315
|
+
* Re-queries the `fetch` callback for the current sort, page and page size,
|
|
316
|
+
* even though none of them changed (the server data did). One request,
|
|
317
|
+
* coalesced with any change already pending in the same task.
|
|
318
|
+
*
|
|
319
|
+
* The loaded windows and tree children are dropped, because they may be
|
|
320
|
+
* stale. The selection is NOT: every selected key and its remembered row
|
|
321
|
+
* survive, so a re-fetched row simply replaces the remembered one.
|
|
322
|
+
*
|
|
323
|
+
* `resetPage: true` also returns to page 1 (and emits
|
|
324
|
+
* `mp-datatable-page-change` when that moves the page). A no-op without a
|
|
325
|
+
* `fetch` callback, apart from the page reset.
|
|
326
|
+
*/
|
|
327
|
+
reload({ resetPage }?: DatatableReloadOptions): void;
|
|
328
|
+
/**
|
|
329
|
+
* Applies any of `fetch`, `sortColumns`, `page` and `perPage` as ONE change:
|
|
330
|
+
* every provided field is assigned first, then exactly one reload is
|
|
331
|
+
* scheduled. Assigning them one by one through the setters can split across
|
|
332
|
+
* ticks and cost two requests; this cannot (#407). Framework wrappers that
|
|
333
|
+
* forward several of these inputs should call this rather than the setters.
|
|
334
|
+
*
|
|
335
|
+
* A field that is absent (or `undefined`) is left alone, except `fetch`: a
|
|
336
|
+
* present `fetch` key is always assigned, so `{ fetch: null }` removes the
|
|
337
|
+
* callback. `perPage` returns to page 1 unless `page` is also given.
|
|
338
|
+
* Unchanged values cost nothing, as with the setters.
|
|
339
|
+
*
|
|
340
|
+
* When `perPage` changes and the given `page` would lie past the last page
|
|
341
|
+
* of the known row count (20 → 50 per page while on page 5 of 100 rows), the
|
|
342
|
+
* page is clamped to the last page and `mp-datatable-page-change` reports
|
|
343
|
+
* it, so a wrapper's page state follows. With no known count (a fetch table
|
|
344
|
+
* before its first response, or a new `fetch` in the same call) the page is
|
|
345
|
+
* kept as given.
|
|
346
|
+
*/
|
|
347
|
+
applyFetchState(state: DatatableFetchState): void;
|
|
210
348
|
get selectionMode(): DatatableSelectionMode;
|
|
211
349
|
set selectionMode(value: DatatableSelectionMode);
|
|
350
|
+
/** Modes that select many rows and render the checkbox column. */
|
|
351
|
+
private get isMulti();
|
|
212
352
|
get selectedIds(): string[];
|
|
213
353
|
set selectedIds(value: string[] | ReadonlyArray<string>);
|
|
354
|
+
/**
|
|
355
|
+
* The selected rows, index-aligned with `selectedIds` (`undefined` for a key
|
|
356
|
+
* whose row the element has never seen). See `SelectionChangeEventDetail`.
|
|
357
|
+
*
|
|
358
|
+
* Setting it REPLACES the selection: the keys are derived through `rowKey`,
|
|
359
|
+
* and the rows are remembered, so a host that owns row objects (the Angular
|
|
360
|
+
* wrapper's `selection` model) can seed rows that are not loaded here — they
|
|
361
|
+
* are reported back in `selectedRows` even while off-page.
|
|
362
|
+
*/
|
|
363
|
+
get selectedRows(): unknown[];
|
|
364
|
+
set selectedRows(value: unknown[] | ReadonlyArray<unknown>);
|
|
214
365
|
get cutIds(): string[];
|
|
215
366
|
set cutIds(value: string[] | ReadonlyArray<string>);
|
|
216
367
|
get focusedRowKey(): string | null;
|
|
217
368
|
set focusedRowKey(value: string | null);
|
|
369
|
+
private _rowLabel;
|
|
370
|
+
/**
|
|
371
|
+
* Names a row for its selection checkbox ("Select {label}"). Property-only (it
|
|
372
|
+
* holds a function). When unset, or when it returns an empty string, the
|
|
373
|
+
* trimmed text of the row's first data cell is used, and when that is empty
|
|
374
|
+
* too, the row number ("Select row N").
|
|
375
|
+
*
|
|
376
|
+
* The name is a string handed to the checkbox: an `aria-labelledby` pointing
|
|
377
|
+
* at the cell could not cross the checkbox's shadow boundary.
|
|
378
|
+
*/
|
|
379
|
+
get rowLabel(): ((row: unknown) => string) | null;
|
|
380
|
+
set rowLabel(value: ((row: unknown) => string) | null);
|
|
381
|
+
/**
|
|
382
|
+
* Row identity: selection, focus and row-view reuse are keyed by it. It must
|
|
383
|
+
* be stable, and derived from the row rather than its index: a row that is
|
|
384
|
+
* not loaded is keyed `rowKey(row, -1)`, so an index-based key maps every
|
|
385
|
+
* off-page row onto `row--1`. Required with `fetch`.
|
|
386
|
+
*/
|
|
218
387
|
get rowKey(): RowKey;
|
|
219
388
|
set rowKey(value: RowKey);
|
|
220
389
|
/** Enable tree mode (chevron column, nested expansion, lazy children). */
|
|
@@ -250,8 +419,18 @@ export declare class MpDatatable extends LitElement {
|
|
|
250
419
|
set pagination(value: boolean);
|
|
251
420
|
get page(): number;
|
|
252
421
|
set page(value: number);
|
|
422
|
+
/** Assigns without scheduling; true when the page changed. */
|
|
423
|
+
private assignPage;
|
|
253
424
|
get perPage(): number;
|
|
254
425
|
set perPage(value: number);
|
|
426
|
+
/**
|
|
427
|
+
* Moves a page past the end back to the last page, when the row count is
|
|
428
|
+
* known: the server's `totalRecords` with `fetch`, the data length without.
|
|
429
|
+
* Reported through `mp-datatable-page-change` when it moves the page.
|
|
430
|
+
*/
|
|
431
|
+
private clampPageToKnownTotal;
|
|
432
|
+
/** Assigns without scheduling (and returns to page 1); true when it changed. */
|
|
433
|
+
private assignPerPage;
|
|
255
434
|
get perPageOptions(): number[];
|
|
256
435
|
set perPageOptions(value: number[]);
|
|
257
436
|
/**
|
|
@@ -295,6 +474,24 @@ export declare class MpDatatable extends LitElement {
|
|
|
295
474
|
* authoritative and overflowing content clips with ellipsis.
|
|
296
475
|
*/
|
|
297
476
|
private maybeMeasureInitialColumnWidths;
|
|
477
|
+
private scheduleRefit;
|
|
478
|
+
/**
|
|
479
|
+
* Keeps columns that fitted fitting when the scroller narrows: when it is
|
|
480
|
+
* resized, or when a classic vertical scrollbar appears after the
|
|
481
|
+
* measurement (13-15px, measured on Windows Chromium and Firefox), which
|
|
482
|
+
* otherwise brings back the very horizontal scrollbar #426 removed.
|
|
483
|
+
*
|
|
484
|
+
* Only MEASURED widths move. A user-set width, an explicit `col.width` and
|
|
485
|
+
* the fixed checkbox/chevron cells keep theirs, and their total is taken off
|
|
486
|
+
* the room first. Scaling is always from the measured base, never from the
|
|
487
|
+
* previous result, which would ratchet down a pixel per pass through the
|
|
488
|
+
* floor; that also restores the exact widths when the scroller widens again.
|
|
489
|
+
*
|
|
490
|
+
* It only ever shrinks (fixed layout spreads any surplus by itself), and
|
|
491
|
+
* never below MIN_REFIT_SCALE: past that the columns would crush into
|
|
492
|
+
* ellipses, and content that no longer fits is meant to scroll instead.
|
|
493
|
+
*/
|
|
494
|
+
private refitMeasuredWidths;
|
|
298
495
|
private measureColumnWidth;
|
|
299
496
|
disconnectedCallback(): void;
|
|
300
497
|
private refreshVirtualRange;
|
|
@@ -473,8 +670,45 @@ export declare class MpDatatable extends LitElement {
|
|
|
473
670
|
*/
|
|
474
671
|
private renderFilterRow;
|
|
475
672
|
private renderFilterCell;
|
|
673
|
+
/**
|
|
674
|
+
* The column's name in every generated string: the consumer's label, else the
|
|
675
|
+
* text its header renders, else its key. The header-text step is what makes a
|
|
676
|
+
* wrapper that only passes a header template (Angular) correct with no extra
|
|
677
|
+
* input, and that text is already localized because the consumer rendered it.
|
|
678
|
+
*/
|
|
679
|
+
private columnLabel;
|
|
680
|
+
/**
|
|
681
|
+
* Caches the text of a Node header. Read during render, before lit moves a
|
|
682
|
+
* fragment's children into the cell, and only a non-empty text replaces the
|
|
683
|
+
* cache: a renderer that hands back the same, already-emptied fragment on a
|
|
684
|
+
* later render must not erase the name it had.
|
|
685
|
+
*/
|
|
686
|
+
private deriveHeaderLabel;
|
|
687
|
+
/** Idempotent; re-attaches if the thead was replaced or the element reconnected. */
|
|
688
|
+
private observeHeaderText;
|
|
689
|
+
/**
|
|
690
|
+
* Whether a header now shows different text than the name derived from it.
|
|
691
|
+
* The gate that keeps the observer from looping: a renderer that returns
|
|
692
|
+
* fresh nodes on every call (a new fragment each time, the React/Vue
|
|
693
|
+
* render-prop shape) mutates the header on EVERY render, but its text stays
|
|
694
|
+
* the same, so only a real change re-renders.
|
|
695
|
+
*/
|
|
696
|
+
private headerTextChanged;
|
|
697
|
+
/** The column's own flag wins in either direction; absent, the table-wide one. */
|
|
698
|
+
private isColumnResizable;
|
|
476
699
|
private renderHeader;
|
|
477
700
|
private renderRow;
|
|
701
|
+
/**
|
|
702
|
+
* Names every rendered row checkbox (D14): `rowLabel(row)`, else the trimmed
|
|
703
|
+
* text of the row's first data cell, else the row number.
|
|
704
|
+
*
|
|
705
|
+
* Runs after each render rather than in the template because the cell text
|
|
706
|
+
* only exists once the cell is rendered — and it may be consumer DOM from a
|
|
707
|
+
* `cellRenderer` or `rowRenderer` — so a re-rendered cell renames its
|
|
708
|
+
* checkbox on the same update. The attribute is written only when it
|
|
709
|
+
* changes, so an unchanged name costs no mutation.
|
|
710
|
+
*/
|
|
711
|
+
private nameRowCheckboxes;
|
|
478
712
|
private renderRowFromRenderer;
|
|
479
713
|
private renderCell;
|
|
480
714
|
private renderFooter;
|
|
@@ -490,11 +724,40 @@ export declare class MpDatatable extends LitElement {
|
|
|
490
724
|
* `getVirtualSpacerHeights`, aria-rowcount) share one computation.
|
|
491
725
|
*/
|
|
492
726
|
private getFlatList;
|
|
727
|
+
/** `_data` in display order: client-sorted when the WC owns sorting. */
|
|
728
|
+
private localSortedRows;
|
|
729
|
+
/**
|
|
730
|
+
* Drops the flat-list memo. It is otherwise reset only in `willUpdate`, so a
|
|
731
|
+
* path that runs between a data change and the next render (a programmatic
|
|
732
|
+
* setter, an event fired before the re-render) would read the old rows.
|
|
733
|
+
*/
|
|
734
|
+
private freshFlatList;
|
|
735
|
+
/**
|
|
736
|
+
* Every loaded row that has a renderer-assigned key, as `[key, row]`. The keys
|
|
737
|
+
* are the ones the renderer uses (K1): a positional fallback key only means
|
|
738
|
+
* anything at the row's rendered index. With local pagination every page is
|
|
739
|
+
* loaded, so rows of the other pages are keyed by their global index too.
|
|
740
|
+
*/
|
|
741
|
+
private liveRowEntries;
|
|
742
|
+
private _keyByRowMemo;
|
|
743
|
+
/**
|
|
744
|
+
* The key the renderer gives a row object. A row outside the live entries (a
|
|
745
|
+
* child of a collapsed parent, a row only the host knows) has no rendered
|
|
746
|
+
* index, so it falls back to an index-free `rowKey` call — exact for any
|
|
747
|
+
* id-based key, and a positional key is already warned about.
|
|
748
|
+
*/
|
|
749
|
+
private keyOfRow;
|
|
750
|
+
/** `keyOfRow` against the current data, for paths that may run before a re-render. */
|
|
751
|
+
private rowKeyLookup;
|
|
493
752
|
private computeVisibleRows;
|
|
494
753
|
private extractId;
|
|
495
754
|
private extractChildCount;
|
|
496
|
-
/**
|
|
497
|
-
|
|
755
|
+
/**
|
|
756
|
+
* Walks the loaded subtree of `row` and returns `[key, row]` for every
|
|
757
|
+
* descendant — the row too, because a cascade selects it and the selection
|
|
758
|
+
* remembers the rows it selected.
|
|
759
|
+
*/
|
|
760
|
+
private collectDescendants;
|
|
498
761
|
/** Some-but-not-all loaded descendants selected → indeterminate parent checkbox. */
|
|
499
762
|
private isParentIndeterminate;
|
|
500
763
|
/**
|
|
@@ -537,7 +800,13 @@ export declare class MpDatatable extends LitElement {
|
|
|
537
800
|
* change anything.
|
|
538
801
|
*/
|
|
539
802
|
private scheduleFetchReload;
|
|
540
|
-
/**
|
|
803
|
+
/**
|
|
804
|
+
* Row keymap, the same in every mode: ArrowUp/Down move, ArrowRight/Left
|
|
805
|
+
* expand/collapse a tree row, Enter opens (row-click), Space selects.
|
|
806
|
+
* 'single'/'multiple': Enter and Space both select with the click modifiers
|
|
807
|
+
* and emit row-click. 'checkbox': Enter only emits row-click, Space only
|
|
808
|
+
* toggles the row's checkbox.
|
|
809
|
+
*/
|
|
541
810
|
private onRowKeydown;
|
|
542
811
|
private hasRowClickListeners;
|
|
543
812
|
/**
|
|
@@ -548,7 +817,22 @@ export declare class MpDatatable extends LitElement {
|
|
|
548
817
|
private onRowClick;
|
|
549
818
|
private onRowDblClick;
|
|
550
819
|
private onRowContextMenu;
|
|
551
|
-
/**
|
|
820
|
+
/**
|
|
821
|
+
* A click anywhere in the checkbox cell, in every mode. The cell is
|
|
822
|
+
* selection-only, so neither its click nor its double-click reaches the row
|
|
823
|
+
* (D12: a double-click on a checkbox used to open the row).
|
|
824
|
+
*
|
|
825
|
+
* In 'checkbox' mode the whole cell is the hit target, not just the 20px box.
|
|
826
|
+
* A click that went through the checkbox's own shadow root is the checkbox
|
|
827
|
+
* operating itself (its change handler toggles), so it is left alone; every
|
|
828
|
+
* other click toggles here. `closest('mp-checkbox')` cannot tell the two
|
|
829
|
+
* apart: a click on the checkbox host's padding is retargeted to the host yet
|
|
830
|
+
* fires no change, so it would be swallowed (spike S1). No focus() and no
|
|
831
|
+
* preventDefault(): the browser focuses the row natively, which keeps Enter,
|
|
832
|
+
* Space and the arrow keys working from there (spike S4).
|
|
833
|
+
*/
|
|
834
|
+
private onCheckboxCellClick;
|
|
835
|
+
/** Row checkboxes render only in the multi-select modes, so this is multi-select toggling. */
|
|
552
836
|
private onRowCheckboxToggle;
|
|
553
837
|
/**
|
|
554
838
|
* Clears the entire selection. The header checkbox is only rendered when
|
|
@@ -568,22 +852,117 @@ export declare class MpDatatable extends LitElement {
|
|
|
568
852
|
*/
|
|
569
853
|
private _selectionAnchorKey;
|
|
570
854
|
private handleSelectionOnClick;
|
|
855
|
+
/**
|
|
856
|
+
* The one write path for a user-driven selection change. `rows` supplies the
|
|
857
|
+
* row of each key being selected; the remembered rows are then pruned to the
|
|
858
|
+
* new keys, so a deselected row is forgotten in the same step.
|
|
859
|
+
*/
|
|
860
|
+
private commitSelection;
|
|
861
|
+
/**
|
|
862
|
+
* Every row the element holds right now, by key: the loaded rows (keyed as
|
|
863
|
+
* the renderer keys them, K1) plus the fetched children of collapsed parents
|
|
864
|
+
* (through `keyOfRow`'s index-free fallback).
|
|
865
|
+
*/
|
|
866
|
+
private liveRowMap;
|
|
867
|
+
/** Remembers the loaded row of every selected key (a loaded row always wins, D2). */
|
|
868
|
+
private rememberLiveSelectedRows;
|
|
869
|
+
/**
|
|
870
|
+
* True when `pairs` is exactly the current selection: the same keys in the
|
|
871
|
+
* same order, each with the row object the element would report for it.
|
|
872
|
+
*/
|
|
873
|
+
private isSameSelectedRows;
|
|
874
|
+
/** Forgets the rows of keys that left the selection. One pass, deletes in place. */
|
|
875
|
+
private pruneSelectedRowCache;
|
|
571
876
|
private emitSelectionChange;
|
|
572
877
|
/**
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
878
|
+
* Resolves keys to rows, index-aligned with `ids` (D3): the loaded row if
|
|
879
|
+
* there is one, else the row remembered at selection time, else `undefined`.
|
|
880
|
+
*
|
|
881
|
+
* A loaded row also refreshes the remembered one, so a re-fetched row object
|
|
882
|
+
* always wins over a stale copy. Loaded rows are keyed exactly as the
|
|
883
|
+
* renderer keys them (K1); children of collapsed parents have no rendered
|
|
884
|
+
* index and go through `keyOfRow`'s index-free fallback.
|
|
576
885
|
*/
|
|
577
886
|
private resolveRows;
|
|
578
887
|
private gotoPage;
|
|
579
888
|
private resizeState;
|
|
889
|
+
/** The column whose resize options dialog is open, or null. */
|
|
890
|
+
private _openResizeColumn;
|
|
891
|
+
private _resizeHintAnnounced;
|
|
892
|
+
/**
|
|
893
|
+
* Every resize path ends here. A user-set width is never re-fitted when the
|
|
894
|
+
* scroller resizes (see `refitMeasuredWidths`): the user chose it.
|
|
895
|
+
*/
|
|
896
|
+
private setUserColumnWidth;
|
|
897
|
+
private currentColumnWidth;
|
|
898
|
+
/**
|
|
899
|
+
* Width of the cells no column owns (selection checkbox, tree chevron) while
|
|
900
|
+
* the widths are frozen; null while the table fills its container.
|
|
901
|
+
*/
|
|
902
|
+
private _frozenExtraWidth;
|
|
903
|
+
/**
|
|
904
|
+
* Before the first user resize, pins every column at the width it RENDERS
|
|
905
|
+
* and gives the table that total as an explicit width.
|
|
906
|
+
*
|
|
907
|
+
* Without this the resized edge does not follow the pointer. The table is
|
|
908
|
+
* 100% wide with fixed layout, so whenever the pins add up to less than the
|
|
909
|
+
* container the slack is shared out over every column, the one being
|
|
910
|
+
* resized included: widening it shrinks its share (it grows slower than the
|
|
911
|
+
* pointer), narrowing it grows its share (it hardly moves). With an explicit
|
|
912
|
+
* width equal to the sum there is no slack to share, so a column is exactly
|
|
913
|
+
* as wide as its pin and the edge tracks the pointer 1:1. Narrowing then
|
|
914
|
+
* leaves room on the right, as in a spreadsheet, instead of refusing to move.
|
|
915
|
+
*
|
|
916
|
+
* Idempotent. Unfrozen again when the last user width is reset.
|
|
917
|
+
*/
|
|
918
|
+
private freezeColumnWidths;
|
|
919
|
+
/** Widths at the moment of freezing: what Reset returns a column to while frozen. */
|
|
920
|
+
private _frozenWidths;
|
|
921
|
+
private frozenTableWidth;
|
|
922
|
+
private headerCell;
|
|
923
|
+
private resizeHandle;
|
|
580
924
|
/**
|
|
581
925
|
* Keyboard column resize — the same ±px model as the pointer path, same 40px
|
|
582
|
-
* floor.
|
|
583
|
-
*
|
|
926
|
+
* floor. Enter opens the same options dialog a tap does, so every pointer
|
|
927
|
+
* path has a keyboard twin and the other way round.
|
|
584
928
|
*/
|
|
585
929
|
private onResizeHandleKeydown;
|
|
930
|
+
private stepColumnWidth;
|
|
931
|
+
/** The keymap, spoken once per element: a separator gives no hint of Enter on its own. */
|
|
932
|
+
private onResizeHandleFocus;
|
|
933
|
+
/**
|
|
934
|
+
* A press on a handle is a drag only once it moves past `RESIZE_TAP_SLOP`;
|
|
935
|
+
* released before that it is a tap, and a tap opens the options dialog. That
|
|
936
|
+
* dialog is the single-pointer alternative WCAG 2.5.7 requires for the drag,
|
|
937
|
+
* and the arrow keys do not count as one.
|
|
938
|
+
*
|
|
939
|
+
* The gesture itself is protected by `touch-action: none` on the handle, not
|
|
940
|
+
* by anything here: `preventDefault()` on pointerdown does not stop a touch
|
|
941
|
+
* pan, and a pan the browser claims ends in `pointercancel`.
|
|
942
|
+
*/
|
|
586
943
|
private startColumnResize;
|
|
587
944
|
private onColumnResizeMove;
|
|
588
945
|
private onColumnResizeEnd;
|
|
946
|
+
private readonly resizeOverlay;
|
|
947
|
+
private openResizePanel;
|
|
948
|
+
/**
|
|
949
|
+
* The resize options dialog: step narrower, step wider, fit, reset. Rendered
|
|
950
|
+
* into the overlay pane with a render() of its own, like the filter panel,
|
|
951
|
+
* and for the same reasons — including being a NON-modal dialog in ARIA
|
|
952
|
+
* terms (#416): it is anchored, dismissible and does not own the page.
|
|
953
|
+
*
|
|
954
|
+
* The readout is an `output`, whose implicit status role announces each new
|
|
955
|
+
* width: the only feedback a screen reader gets for a step, because the
|
|
956
|
+
* buttons keep focus and the separator's valuenow is not where focus is.
|
|
957
|
+
*/
|
|
958
|
+
private renderResizePanel;
|
|
959
|
+
/**
|
|
960
|
+
* Sizes the column to its widest RENDERED content: header plus the body rows
|
|
961
|
+
* currently in the DOM (one window, in virtual mode). Read with a Range,
|
|
962
|
+
* because a clipped cell's own box reports the column width, not its
|
|
963
|
+
* content's, while a range over its contents measures the text itself.
|
|
964
|
+
*/
|
|
965
|
+
private fitColumnWidth;
|
|
966
|
+
/** Back to the width the table chose: the measured one, else the column's own. */
|
|
967
|
+
private resetColumnWidth;
|
|
589
968
|
}
|
package/datatable/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MpDatatable } from './components';
|
|
2
|
-
export type { DatatableSelectionMode, RowEventDetail, SortChangeEventDetail, SelectionChangeEventDetail, } from './components';
|
|
2
|
+
export type { DatatableSelectionMode, RowEventDetail, SortChangeEventDetail, SelectionChangeEventDetail, DatatableFetchState, DatatableReloadOptions, } from './components';
|
|
3
3
|
export type { DatatableColumnDef, CellContent, CellRenderer, HeaderRenderer, FilterRenderer, RowKey, RowRenderer, RowRenderContext, TreeIdKey, TreeSelectionStrategy, DatatableFetchRequest, DatatableFetchResponse, DatatableFetch, TreeRowExpandDetail, TreeExpandedIdsChangeDetail, DistinctValue, DistinctValues, DistinctsRequest, DatatableDistincts, FilterSelection, FilterContext, FilterChangeDetail, ValuesFilterChangeDetail, ComparisonFilterChangeDetail, FilterMode, FilterOperator, FilterInputType, } from './types';
|
|
4
4
|
export type { DatatableLabels } from './types';
|
|
5
5
|
export { DEFAULT_DATATABLE_LABELS } from './types';
|
|
@@ -41,10 +41,22 @@ export type FilterRenderer<T = unknown> = (column: DatatableColumnDef<T>, contex
|
|
|
41
41
|
export interface DatatableColumnDef<T = unknown> {
|
|
42
42
|
/** Data property name + sort key. */
|
|
43
43
|
name: string;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Header label (rendered when no `headerRenderer` is provided) and the
|
|
46
|
+
* column's name in every generated accessible string: resize handle, filter
|
|
47
|
+
* trigger and panel, sort and filter announcements. When absent, those
|
|
48
|
+
* strings use the text a `headerRenderer` node renders, and only then
|
|
49
|
+
* `name`. Set it when the header is icon-only or should be spoken differently.
|
|
50
|
+
*/
|
|
45
51
|
label?: string;
|
|
46
52
|
/** Whether the header is clickable to toggle sort. Default `true`. */
|
|
47
53
|
sortable?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether this column offers a resize handle. Absent follows the table-wide
|
|
56
|
+
* `resizableColumns`; a set value wins over it in either direction, so one
|
|
57
|
+
* column can be resizable in a table that is not, and vice versa.
|
|
58
|
+
*/
|
|
59
|
+
resizable?: boolean;
|
|
48
60
|
/** Initial pinned width in px. Resizable columns can override at runtime. */
|
|
49
61
|
width?: number;
|
|
50
62
|
/** Cell renderer; defaults to `String(row[column.name])`. */
|