@mintplayer/web-components 2.15.0 → 2.16.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-B7st6G-I.mjs +2238 -0
- package/chunks/{mp-datetime-picker.element-D1CiLbHm.mjs → mp-datetime-picker.element-DsWA1AFs.mjs} +2 -2
- package/chunks/{mp-timepicker.element-COZEUIoE.mjs → mp-timepicker.element-CwaAAOcm.mjs} +1 -1
- package/chunks/{overlay-controller-D6agzzOI.mjs → overlay-controller-DifgO6jT.mjs} +103 -47
- package/datatable/index.mjs +6 -5
- package/datatable/src/components/mp-datatable.d.ts +201 -1
- package/datatable/src/index.d.ts +3 -1
- package/datatable/src/types/column-def.d.ts +61 -0
- package/datatable/src/types/filter.d.ts +138 -0
- package/datatable/src/types/index.d.ts +3 -2
- package/datatable/src/types/labels.d.ts +58 -0
- package/datepicker/index.mjs +1 -1
- package/datetime-picker/index.mjs +1 -1
- package/file-manager/index.mjs +1 -1
- package/navbar/index.mjs +1 -1
- package/overlay/index.mjs +5 -2
- package/overlay/src/index.d.ts +2 -0
- package/overlay/src/overlay-controller.d.ts +27 -0
- package/overlay/src/overlay-portal.d.ts +53 -0
- package/package.json +1 -1
- package/ribbon/index.mjs +1 -1
- package/scheduler/index.mjs +2 -2
- package/timepicker/index.mjs +1 -1
- package/tree-select/index.mjs +1 -1
- package/chunks/mp-datatable-UJI8E73X.mjs +0 -1400
- package/datatable/src/styles/datatable.styles.d.ts +0 -2
package/chunks/{mp-datetime-picker.element-D1CiLbHm.mjs → mp-datetime-picker.element-DsWA1AFs.mjs}
RENAMED
|
@@ -2,9 +2,9 @@ import { html as c, unsafeCSS as v, LitElement as y, nothing as b } from "lit";
|
|
|
2
2
|
import { query as n } from "lit/decorators.js";
|
|
3
3
|
import { L as w } from "./live-announcer-Bi0orG4n.mjs";
|
|
4
4
|
import { e as D } from "./error-text-B45eDAt1.mjs";
|
|
5
|
-
import { O as g } from "./overlay-controller-
|
|
5
|
+
import { O as g } from "./overlay-controller-DifgO6jT.mjs";
|
|
6
6
|
import "./mp-calendar.element-CJ8-t-Zn.mjs";
|
|
7
|
-
import { m as p } from "./mp-timepicker.element-
|
|
7
|
+
import { m as p } from "./mp-timepicker.element-CwaAAOcm.mjs";
|
|
8
8
|
import { i as $ } from "./invalid-feedback.styles-he0JYrJm.mjs";
|
|
9
9
|
c`<!-- Rendered dynamically by render(). Codegen-wc emits styles from the
|
|
10
10
|
sibling .scss; the template export is intentionally unused. -->`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { html as l, unsafeCSS as p, LitElement as m, nothing as c } from "lit";
|
|
2
2
|
import { query as u } from "lit/decorators.js";
|
|
3
|
-
import { O as f } from "./overlay-controller-
|
|
3
|
+
import { O as f } from "./overlay-controller-DifgO6jT.mjs";
|
|
4
4
|
import "lit/directives/ref.js";
|
|
5
5
|
import { H as g } from "./host-aria-WSGs7SPQ.mjs";
|
|
6
6
|
import { R as y } from "./roving-focus-CrL9982a.mjs";
|
|
@@ -1,14 +1,52 @@
|
|
|
1
1
|
import "lit";
|
|
2
2
|
import "lit/directives/ref.js";
|
|
3
|
-
import { d as
|
|
4
|
-
import { F as
|
|
5
|
-
const
|
|
3
|
+
import { d as b } from "./focus-restore-DxuP1Oe2.mjs";
|
|
4
|
+
import { F as A, d as v, c as S } from "./focus-trap-DTOLJ5bb.mjs";
|
|
5
|
+
const w = "mp-overlay-container", F = "mp-overlay-pane", E = 2e3, x = [
|
|
6
|
+
"position: fixed",
|
|
7
|
+
"inset: 0",
|
|
8
|
+
// The container spans the viewport, so it must not intercept anything. Panes
|
|
9
|
+
// opt back in individually.
|
|
10
|
+
"pointer-events: none",
|
|
11
|
+
`z-index: var(--mp-overlay-container-z-index, ${E})`,
|
|
12
|
+
"display: block"
|
|
13
|
+
].join("; "), L = ["position: fixed", "pointer-events: auto"].join("; ");
|
|
14
|
+
let l = null, a = 0;
|
|
15
|
+
function P() {
|
|
16
|
+
typeof customElements > "u" || customElements.get(w) || customElements.define(w, class extends HTMLElement {
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function C() {
|
|
20
|
+
if (l?.isConnected) return l;
|
|
21
|
+
P();
|
|
22
|
+
const c = document.createElement(w);
|
|
23
|
+
return c.setAttribute("style", x), document.body.appendChild(c), l = c, c;
|
|
24
|
+
}
|
|
25
|
+
function O() {
|
|
26
|
+
if (typeof document > "u" || !document.body) return null;
|
|
27
|
+
const c = C(), t = document.createElement("div");
|
|
28
|
+
t.className = F, t.setAttribute("style", L), c.appendChild(t), a++;
|
|
29
|
+
let e = !1;
|
|
30
|
+
return {
|
|
31
|
+
container: t,
|
|
32
|
+
release() {
|
|
33
|
+
e || (e = !0, t.remove(), a = Math.max(0, a - 1), a === 0 && l && (l.remove(), l = null));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function W() {
|
|
38
|
+
return l?.isConnected ? l : null;
|
|
39
|
+
}
|
|
40
|
+
function $() {
|
|
41
|
+
return a;
|
|
42
|
+
}
|
|
43
|
+
const D = [
|
|
6
44
|
{ originX: "start", originY: "bottom", overlayX: "start", overlayY: "top" },
|
|
7
45
|
{ originX: "start", originY: "top", overlayX: "start", overlayY: "bottom" }
|
|
8
46
|
];
|
|
9
|
-
class
|
|
47
|
+
class p {
|
|
10
48
|
constructor(t, e) {
|
|
11
|
-
this._open = !1, this.mouseDownAttached = !1, this.stackToken = null, this.activeAnchor = null, this.restoreTo = null, this.positionFrame = 0, this.scrollListenersAttached = !1, this.blockedScroll = null, this.blockedBodyPaddingRight = null, this.onScroll = () => {
|
|
49
|
+
this._open = !1, this.mouseDownAttached = !1, this.stackToken = null, this.activeAnchor = null, this.restoreTo = null, this.positionFrame = 0, this.scrollListenersAttached = !1, this.blockedScroll = null, this.blockedBodyPaddingRight = null, this.portalHandle = null, this.onScroll = () => {
|
|
12
50
|
if (!this._open) return;
|
|
13
51
|
const o = this.currentStrategy();
|
|
14
52
|
if (o === "close") {
|
|
@@ -21,8 +59,12 @@ class c {
|
|
|
21
59
|
}, this.onKeyDown = (o) => {
|
|
22
60
|
o.key === "Escape" && this._open && this.isTopOfStack() && (this.close(), o.preventDefault());
|
|
23
61
|
}, this.onMouseDown = (o) => {
|
|
24
|
-
|
|
25
|
-
|
|
62
|
+
if (!this._open) return;
|
|
63
|
+
const n = o.composedPath();
|
|
64
|
+
if (n.includes(this.host)) return;
|
|
65
|
+
const s = this.options.panel();
|
|
66
|
+
s && n.includes(s) || this.close(!1);
|
|
67
|
+
}, this.host = t, this.options = e, this.focusTrap = new A(() => this.options.panel(), {
|
|
26
68
|
initialFocus: "none",
|
|
27
69
|
// open() handles initial focus; the trap only contains Tab
|
|
28
70
|
returnFocus: !1,
|
|
@@ -43,23 +85,34 @@ class c {
|
|
|
43
85
|
* cannot each believe they are top-most and both consume one Escape.
|
|
44
86
|
*/
|
|
45
87
|
static pushFrame() {
|
|
46
|
-
return
|
|
88
|
+
return v.push("overlay-frame-external");
|
|
47
89
|
}
|
|
48
90
|
static releaseFrame(t) {
|
|
49
|
-
|
|
91
|
+
v.release(t);
|
|
50
92
|
}
|
|
51
93
|
static isFrameTop(t) {
|
|
52
|
-
return
|
|
94
|
+
return v.isTop(t);
|
|
53
95
|
}
|
|
54
96
|
hostConnected() {
|
|
55
97
|
document.addEventListener("keydown", this.onKeyDown);
|
|
56
98
|
}
|
|
57
99
|
hostDisconnected() {
|
|
58
|
-
document.removeEventListener("keydown", this.onKeyDown), this.detachMouseDown(), this.stackToken && this.releaseStackToken();
|
|
100
|
+
document.removeEventListener("keydown", this.onKeyDown), this.detachMouseDown(), this.stackToken && this.releaseStackToken(), this.releasePortal();
|
|
59
101
|
}
|
|
60
102
|
get isOpen() {
|
|
61
103
|
return this._open;
|
|
62
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* The document-root pane to render the panel into, or `null` when this
|
|
107
|
+
* overlay is closed or not portalled. Read it from the host's update so the
|
|
108
|
+
* panel exists by the time the controller positions it.
|
|
109
|
+
*/
|
|
110
|
+
get portalContainer() {
|
|
111
|
+
return this.portalHandle?.container ?? null;
|
|
112
|
+
}
|
|
113
|
+
releasePortal() {
|
|
114
|
+
this.portalHandle?.release(), this.portalHandle = null;
|
|
115
|
+
}
|
|
63
116
|
/**
|
|
64
117
|
* Whether this overlay is the top-most dismissible layer — i.e. whether an
|
|
65
118
|
* Escape belongs to IT rather than to something opened on top of it.
|
|
@@ -78,14 +131,14 @@ class c {
|
|
|
78
131
|
async open() {
|
|
79
132
|
if (this._open) return;
|
|
80
133
|
this._open = !0;
|
|
81
|
-
const t =
|
|
82
|
-
this.restoreTo = t instanceof HTMLElement && t !== t.ownerDocument.body ? t : null, this.stackToken =
|
|
134
|
+
const t = b();
|
|
135
|
+
this.restoreTo = t instanceof HTMLElement && t !== t.ownerDocument.body ? t : null, this.stackToken = p.pushFrame(), this.options.portal && (this.portalHandle = O()), this.host.setAttribute("data-menu-open", ""), this.host.requestUpdate(), await this.host.updateComplete, this.position(), this.attachScrollListeners(), this.moveFocusIn(), this.options.modal && this.focusTrap.activate(), setTimeout(() => this.attachMouseDown(), 0), this.options.onOpen?.();
|
|
83
136
|
}
|
|
84
137
|
close(t = !0) {
|
|
85
138
|
if (!this._open) return;
|
|
86
139
|
this._open = !1, this.releaseStackToken(), this.focusTrap.isActive && this.focusTrap.deactivate();
|
|
87
140
|
const e = this.resolveReturnTarget();
|
|
88
|
-
this.host.removeAttribute("data-menu-open"), this.host.requestUpdate(), this.detachMouseDown(), this.detachScrollListeners(), this.positionFrame && (cancelAnimationFrame(this.positionFrame), this.positionFrame = 0), t && e?.focus({ preventScroll: !0 }), this.restoreTo = null, this.activeAnchor = null, this.options.onClose?.();
|
|
141
|
+
this.host.removeAttribute("data-menu-open"), this.host.requestUpdate(), this.detachMouseDown(), this.detachScrollListeners(), this.positionFrame && (cancelAnimationFrame(this.positionFrame), this.positionFrame = 0), t && e?.focus({ preventScroll: !0 }), this.releasePortal(), this.restoreTo = null, this.activeAnchor = null, this.options.onClose?.();
|
|
89
142
|
}
|
|
90
143
|
/**
|
|
91
144
|
* Focus-return target, in order of preference: whatever had focus when this
|
|
@@ -120,7 +173,7 @@ class c {
|
|
|
120
173
|
e.hasAttribute("tabindex") || e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 });
|
|
121
174
|
return;
|
|
122
175
|
}
|
|
123
|
-
const o =
|
|
176
|
+
const o = S(e)[0];
|
|
124
177
|
o ? o.focus({ preventScroll: !0 }) : (e.hasAttribute("tabindex") || e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 }));
|
|
125
178
|
}
|
|
126
179
|
async toggle() {
|
|
@@ -165,25 +218,25 @@ class c {
|
|
|
165
218
|
const t = this.resolveAnchors(), e = this.options.panel();
|
|
166
219
|
if (t.length === 0 || !e) return;
|
|
167
220
|
this.applyPanelWidth(e, t[0]);
|
|
168
|
-
const o = this.options.viewportMargin ?? 8,
|
|
169
|
-
if (this.options.stickyOnAnchorOffscreen && this.isAnchorOffscreen(r, s,
|
|
170
|
-
const
|
|
171
|
-
e.style.left = `${
|
|
221
|
+
const o = this.options.viewportMargin ?? 8, n = e.getBoundingClientRect(), s = window.innerWidth, i = window.innerHeight, r = t[0].getBoundingClientRect();
|
|
222
|
+
if (this.options.stickyOnAnchorOffscreen && this.isAnchorOffscreen(r, s, i)) {
|
|
223
|
+
const h = parseFloat(e.style.left) || n.left, y = parseFloat(e.style.top) || n.top, u = this.clampToViewport({ left: h, top: y }, n, s, i, o);
|
|
224
|
+
e.style.left = `${u.left}px`, e.style.top = `${u.top}px`;
|
|
172
225
|
return;
|
|
173
226
|
}
|
|
174
|
-
const
|
|
175
|
-
let
|
|
176
|
-
t: for (const
|
|
177
|
-
const
|
|
178
|
-
for (const
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
227
|
+
const d = this.options.positions ?? D, T = this.isRtl();
|
|
228
|
+
let f = null, m = null;
|
|
229
|
+
t: for (const h of t) {
|
|
230
|
+
const y = h.getBoundingClientRect();
|
|
231
|
+
for (const u of d) {
|
|
232
|
+
const g = this.placeFor(u, y, n, T);
|
|
233
|
+
if (f = h, m = g, this.fitsInViewport(g, n, s, i, o)) break t;
|
|
181
234
|
}
|
|
182
235
|
}
|
|
183
|
-
if (!
|
|
184
|
-
this.activeAnchor =
|
|
185
|
-
const
|
|
186
|
-
e.style.left = `${
|
|
236
|
+
if (!m || !f) return;
|
|
237
|
+
this.activeAnchor = f;
|
|
238
|
+
const k = this.clampToViewport(m, n, s, i, o);
|
|
239
|
+
e.style.left = `${k.left}px`, e.style.top = `${k.top}px`;
|
|
187
240
|
}
|
|
188
241
|
/** True when the anchor's bounding rect lies entirely outside the viewport. */
|
|
189
242
|
isAnchorOffscreen(t, e, o) {
|
|
@@ -224,16 +277,16 @@ class c {
|
|
|
224
277
|
* position candidate. The candidate identifies which corner of the anchor
|
|
225
278
|
* to align which corner of the panel to, plus optional pixel offsets.
|
|
226
279
|
*/
|
|
227
|
-
placeFor(t, e, o,
|
|
228
|
-
const s = this.anchorXFor(t.originX, e,
|
|
280
|
+
placeFor(t, e, o, n) {
|
|
281
|
+
const s = this.anchorXFor(t.originX, e, n), i = this.anchorYFor(t.originY, e), r = this.panelXOffsetFor(t.overlayX, o.width, n), d = this.panelYOffsetFor(t.overlayY, o.height);
|
|
229
282
|
return {
|
|
230
283
|
left: s + r + (t.offsetX ?? 0),
|
|
231
|
-
top:
|
|
284
|
+
top: i + d + (t.offsetY ?? 0)
|
|
232
285
|
};
|
|
233
286
|
}
|
|
234
287
|
anchorXFor(t, e, o) {
|
|
235
|
-
const
|
|
236
|
-
return t === "start" ?
|
|
288
|
+
const n = o ? e.right : e.left, s = o ? e.left : e.right;
|
|
289
|
+
return t === "start" ? n : t === "end" ? s : e.left + e.width / 2;
|
|
237
290
|
}
|
|
238
291
|
anchorYFor(t, e) {
|
|
239
292
|
return t === "top" ? e.top : t === "bottom" ? e.bottom : e.top + e.height / 2;
|
|
@@ -244,12 +297,12 @@ class c {
|
|
|
244
297
|
panelYOffsetFor(t, e) {
|
|
245
298
|
return t === "top" ? 0 : t === "bottom" ? -e : -e / 2;
|
|
246
299
|
}
|
|
247
|
-
fitsInViewport(t, e, o,
|
|
248
|
-
return t.left >= s && t.top >= s && t.left + e.width <= o - s && t.top + e.height <=
|
|
300
|
+
fitsInViewport(t, e, o, n, s) {
|
|
301
|
+
return t.left >= s && t.top >= s && t.left + e.width <= o - s && t.top + e.height <= n - s;
|
|
249
302
|
}
|
|
250
|
-
clampToViewport(t, e, o,
|
|
251
|
-
let { left:
|
|
252
|
-
return
|
|
303
|
+
clampToViewport(t, e, o, n, s) {
|
|
304
|
+
let { left: i, top: r } = t;
|
|
305
|
+
return i + e.width > o - s && (i = o - e.width - s), i < s && (i = s), r + e.height > n - s && (r = n - e.height - s), r < s && (r = s), { left: i, top: r };
|
|
253
306
|
}
|
|
254
307
|
/* ---- Scroll + resize tracking ---- */
|
|
255
308
|
currentStrategy() {
|
|
@@ -294,12 +347,12 @@ class c {
|
|
|
294
347
|
*/
|
|
295
348
|
applyBlockScroll() {
|
|
296
349
|
if (this.blockedScroll) return;
|
|
297
|
-
const t = document.documentElement, e = t.scrollTop || window.scrollY, o = t.scrollLeft || window.scrollX,
|
|
298
|
-
if (this.blockedScroll = { top: e, left: o },
|
|
350
|
+
const t = document.documentElement, e = t.scrollTop || window.scrollY, o = t.scrollLeft || window.scrollX, n = Math.max(0, window.innerWidth - t.clientWidth);
|
|
351
|
+
if (this.blockedScroll = { top: e, left: o }, n > 0) {
|
|
299
352
|
const s = document.body;
|
|
300
353
|
this.blockedBodyPaddingRight = s.style.paddingRight;
|
|
301
|
-
const
|
|
302
|
-
s.style.paddingRight = `${
|
|
354
|
+
const i = parseFloat(getComputedStyle(s).paddingRight) || 0;
|
|
355
|
+
s.style.paddingRight = `${i + n}px`;
|
|
303
356
|
}
|
|
304
357
|
t.style.setProperty("--overlay-blocked-top", `-${e}px`), t.style.setProperty("--overlay-blocked-left", `-${o}px`), t.style.position = "fixed", t.style.top = `-${e}px`, t.style.left = `-${o}px`, t.style.width = "100%";
|
|
305
358
|
}
|
|
@@ -312,10 +365,10 @@ class c {
|
|
|
312
365
|
}
|
|
313
366
|
/* ---- Esc-stack ---- */
|
|
314
367
|
releaseStackToken() {
|
|
315
|
-
this.stackToken && (
|
|
368
|
+
this.stackToken && (p.releaseFrame(this.stackToken), this.stackToken = null);
|
|
316
369
|
}
|
|
317
370
|
isTopOfStack() {
|
|
318
|
-
return this.stackToken !== null &&
|
|
371
|
+
return this.stackToken !== null && p.isFrameTop(this.stackToken);
|
|
319
372
|
}
|
|
320
373
|
attachMouseDown() {
|
|
321
374
|
this.mouseDownAttached || (document.addEventListener("mousedown", this.onMouseDown, !0), this.mouseDownAttached = !0);
|
|
@@ -325,5 +378,8 @@ class c {
|
|
|
325
378
|
}
|
|
326
379
|
}
|
|
327
380
|
export {
|
|
328
|
-
|
|
381
|
+
p as O,
|
|
382
|
+
O as a,
|
|
383
|
+
W as c,
|
|
384
|
+
$ as o
|
|
329
385
|
};
|
package/datatable/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as s, M as e, c as o, d as A, s as L } from "../chunks/mp-datatable-B7st6G-I.mjs";
|
|
2
2
|
export {
|
|
3
|
-
s as
|
|
4
|
-
e as
|
|
5
|
-
o as
|
|
6
|
-
|
|
3
|
+
s as DEFAULT_DATATABLE_LABELS,
|
|
4
|
+
e as MpDatatable,
|
|
5
|
+
o as computeNextSort,
|
|
6
|
+
A as datatableLightStyles,
|
|
7
|
+
L as sortRows
|
|
7
8
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement, TemplateResult } from 'lit';
|
|
2
2
|
import { DatatableLabels } from '../types/labels';
|
|
3
3
|
import { SortColumn } from '../sort';
|
|
4
|
-
import { DatatableColumnDef, RowKey, RowRenderer, DatatableFetch, TreeIdKey, TreeSelectionStrategy } from '../types';
|
|
4
|
+
import { DatatableColumnDef, RowKey, RowRenderer, DatatableFetch, DatatableDistincts, TreeIdKey, TreeSelectionStrategy } from '../types';
|
|
5
5
|
export type DatatableSelectionMode = 'none' | 'single' | 'multiple';
|
|
6
6
|
export interface RowEventDetail<T = unknown> {
|
|
7
7
|
row: T;
|
|
@@ -111,6 +111,19 @@ export declare class MpDatatable extends LitElement {
|
|
|
111
111
|
private _resizeObserver;
|
|
112
112
|
private _scrollListener;
|
|
113
113
|
private _viewportHeight;
|
|
114
|
+
/** Name of the column whose filter panel is open, or null. Only ever one. */
|
|
115
|
+
private _openFilterColumn;
|
|
116
|
+
/** Column whose consumer content is currently mounted in the panel. Guards
|
|
117
|
+
* against re-mounting on every render, which would destroy focus. */
|
|
118
|
+
private _mountedFilterColumn;
|
|
119
|
+
/** Whether the mounted panel is the consumer's node rather than the built-in one. */
|
|
120
|
+
private _consumerMountedFilter;
|
|
121
|
+
/** Unique per instance so several datatables on a page cannot collide on IDREFs. */
|
|
122
|
+
private readonly _filterUid;
|
|
123
|
+
/** Consumer-supplied distinct-value source; null = compute locally when possible. */
|
|
124
|
+
private _distincts;
|
|
125
|
+
/** Per-column filter panel state, keyed by `DatatableColumnDef.name`. */
|
|
126
|
+
private readonly _filterStates;
|
|
114
127
|
private _tree;
|
|
115
128
|
private _idKey;
|
|
116
129
|
private _childCountKey;
|
|
@@ -161,6 +174,18 @@ export declare class MpDatatable extends LitElement {
|
|
|
161
174
|
set virtualBuffer(value: number);
|
|
162
175
|
get columns(): DatatableColumnDef[];
|
|
163
176
|
set columns(value: DatatableColumnDef[]);
|
|
177
|
+
/**
|
|
178
|
+
* Drops state for columns that are gone and seeds state for new ones from
|
|
179
|
+
* `filterSelection`.
|
|
180
|
+
*
|
|
181
|
+
* An existing column keeps its state: the Angular wrapper rebuilds the whole
|
|
182
|
+
* column array on every change detection, so treating a re-assignment as
|
|
183
|
+
* "new columns" would wipe the user's selection on any unrelated input change.
|
|
184
|
+
* A column whose `filterSelection` reference actually changed is re-seeded —
|
|
185
|
+
* that is the consumer restoring a filter, and it is why the input is a
|
|
186
|
+
* reference and not a value.
|
|
187
|
+
*/
|
|
188
|
+
private syncFilterStates;
|
|
164
189
|
get data(): unknown[];
|
|
165
190
|
set data(value: unknown[]);
|
|
166
191
|
/**
|
|
@@ -171,6 +196,15 @@ export declare class MpDatatable extends LitElement {
|
|
|
171
196
|
*/
|
|
172
197
|
get fetch(): DatatableFetch | null;
|
|
173
198
|
set fetch(value: DatatableFetch | null);
|
|
199
|
+
/**
|
|
200
|
+
* Consumer-supplied source of distinct values for the filter panels.
|
|
201
|
+
* Property-only (it holds a function), mirroring `fetch` and `labels`.
|
|
202
|
+
*
|
|
203
|
+
* A source that resolves `null` for a column means "compute that column
|
|
204
|
+
* locally", so one table can mix server-backed and local filter columns.
|
|
205
|
+
*/
|
|
206
|
+
get distincts(): DatatableDistincts | null;
|
|
207
|
+
set distincts(value: DatatableDistincts | null);
|
|
174
208
|
get sortColumns(): SortColumn[];
|
|
175
209
|
set sortColumns(value: SortColumn[]);
|
|
176
210
|
get selectionMode(): DatatableSelectionMode;
|
|
@@ -245,6 +279,12 @@ export declare class MpDatatable extends LitElement {
|
|
|
245
279
|
protected firstUpdated(): void;
|
|
246
280
|
protected willUpdate(changedProperties: Map<string, unknown>): void;
|
|
247
281
|
protected updated(changedProperties: Map<string, unknown>): void;
|
|
282
|
+
/**
|
|
283
|
+
* Publish header row 1's height as `--mp-datatable-header-height` for the
|
|
284
|
+
* filter row's sticky offset. Cheap and idempotent: it writes only on change,
|
|
285
|
+
* so it cannot feed back into the render loop.
|
|
286
|
+
*/
|
|
287
|
+
private publishHeaderHeight;
|
|
248
288
|
/**
|
|
249
289
|
* Run the auto-size-once pass after the first batch of rows lands in the
|
|
250
290
|
* DOM. Columns with an explicit `col.width` are pinned to that value
|
|
@@ -273,6 +313,166 @@ export declare class MpDatatable extends LitElement {
|
|
|
273
313
|
private maybeFetchPagesInViewport;
|
|
274
314
|
render(): TemplateResult;
|
|
275
315
|
private getVirtualSpacerHeights;
|
|
316
|
+
/** True when any column opted in. No column opts in, no second row, no cost. */
|
|
317
|
+
private get hasFilterRow();
|
|
318
|
+
private get filterPanelId();
|
|
319
|
+
private filterTriggerId;
|
|
320
|
+
private createFilterState;
|
|
321
|
+
/** State for a filterable column, created on demand. */
|
|
322
|
+
private filterState;
|
|
323
|
+
private notifyFilterListeners;
|
|
324
|
+
private abortFilterRequest;
|
|
325
|
+
/**
|
|
326
|
+
* Replaces a column's selection and emits the one event the component owns.
|
|
327
|
+
*
|
|
328
|
+
* The component never filters `_data` itself — what a selection means, and
|
|
329
|
+
* whether it is applied here or on a server, belongs to the consumer. All it
|
|
330
|
+
* does locally is snapshot the value list the first time a selection becomes
|
|
331
|
+
* non-empty, so the list cannot collapse to the selection.
|
|
332
|
+
*/
|
|
333
|
+
private applyFilter;
|
|
334
|
+
/** The column's mode, defaulting to a checkbox list of distinct values. */
|
|
335
|
+
private filterModeOf;
|
|
336
|
+
private clearFilter;
|
|
337
|
+
/**
|
|
338
|
+
* Comparison mode's counterpart to `applyFilter`.
|
|
339
|
+
*
|
|
340
|
+
* It keeps the same contract: the component records what the user asked for
|
|
341
|
+
* and emits it, and never filters `_data`. An empty operand is a cleared
|
|
342
|
+
* filter, not a comparison against the empty string — otherwise every column
|
|
343
|
+
* would filter everything away the moment its panel opened.
|
|
344
|
+
*/
|
|
345
|
+
private applyComparison;
|
|
346
|
+
/**
|
|
347
|
+
* An empty input, and a `'number'` input holding something unparseable, both
|
|
348
|
+
* mean "no filter" rather than a comparison against `NaN` — which would be
|
|
349
|
+
* false for every row and silently empty the table.
|
|
350
|
+
*/
|
|
351
|
+
private parseOperand;
|
|
352
|
+
private setFilterSearch;
|
|
353
|
+
/**
|
|
354
|
+
* Loads (or recomputes) one column's value list.
|
|
355
|
+
*
|
|
356
|
+
* Called on every panel open — there is no cross-open cache, because the data
|
|
357
|
+
* behind a list can change while the panel is closed and a stale list is worse
|
|
358
|
+
* than a re-query. The source is asked first; a source resolving `null` means
|
|
359
|
+
* it cannot answer for this column, and the local path takes over.
|
|
360
|
+
*/
|
|
361
|
+
private loadDistincts;
|
|
362
|
+
/**
|
|
363
|
+
* Recomputes the OPEN column's list when it is locally derived and the rows
|
|
364
|
+
* changed under it.
|
|
365
|
+
*
|
|
366
|
+
* This is what makes the `remaining` bucket work at all. A consumer applies a
|
|
367
|
+
* filter by rebinding `data` to the subset; if the list were not recomputed,
|
|
368
|
+
* `loaded` would still describe the pre-filter rows, every snapshot value
|
|
369
|
+
* would still look present, and nothing would ever be marked as having left
|
|
370
|
+
* the data.
|
|
371
|
+
*
|
|
372
|
+
* Only the open column, and only the local path: a closed panel reloads when
|
|
373
|
+
* it opens, and a consumer-supplied source owns its own freshness — re-asking
|
|
374
|
+
* it on every `data` assignment would be a request per keystroke of whatever
|
|
375
|
+
* the consumer's own filtering does.
|
|
376
|
+
*/
|
|
377
|
+
private refreshLocalDistincts;
|
|
378
|
+
/**
|
|
379
|
+
* The value list computed from the rows this element holds — but only when it
|
|
380
|
+
* holds all of them.
|
|
381
|
+
*
|
|
382
|
+
* With a `fetch` callback, external paging, or loaded tree children, `_data`
|
|
383
|
+
* is a window onto a larger set, and a list built from a window silently omits
|
|
384
|
+
* values. There is no partial answer worth giving there: the column reports
|
|
385
|
+
* that it has no values and the consumer is expected to supply `distincts`.
|
|
386
|
+
*/
|
|
387
|
+
private localDistincts;
|
|
388
|
+
/**
|
|
389
|
+
* Re-derives `matching` / `remaining` from the snapshot and the search term.
|
|
390
|
+
*
|
|
391
|
+
* `remaining` holds snapshot values the current list no longer contains: they
|
|
392
|
+
* stay listed (dimmed) so a selection can be widened. Search is applied to
|
|
393
|
+
* both buckets client-side — the debounced re-query above is the exception,
|
|
394
|
+
* not the rule.
|
|
395
|
+
*/
|
|
396
|
+
private rebucket;
|
|
397
|
+
/** The open column's trigger button, or null. Re-queried on every call. */
|
|
398
|
+
private openFilterTrigger;
|
|
399
|
+
/**
|
|
400
|
+
* The filter panel is portalled to the document root, because an in-flow
|
|
401
|
+
* panel opened from a header cell is clipped by `.datatable-scroll` — on the
|
|
402
|
+
* right in paged mode, and on both axes in virtual mode, measured in three
|
|
403
|
+
* engines. Positioning stays the controller's job; only DOM ownership moves.
|
|
404
|
+
*
|
|
405
|
+
* No local scroll listener is needed. `scroll` does not compose, so a
|
|
406
|
+
* component whose scroller lives in a shadow root must re-dispatch it (see
|
|
407
|
+
* `mp-scheduler`) — but `.datatable-scroll` is in the LIGHT DOM, so the
|
|
408
|
+
* controller's document-level capture listener already sees it and
|
|
409
|
+
* `scrollStrategy: 'reposition'` works as-is. Do not copy the scheduler's
|
|
410
|
+
* workaround here; it would be redundant.
|
|
411
|
+
*/
|
|
412
|
+
private readonly filterOverlay;
|
|
413
|
+
private onFilterTriggerClick;
|
|
414
|
+
/**
|
|
415
|
+
* Renders the open panel into the overlay pane, with a render root of its
|
|
416
|
+
* own. The panel is NOT part of this element's template: relocating a node
|
|
417
|
+
* lit rendered is unsupported, so the pane gets its own `render()` call
|
|
418
|
+
* whose container happens to live in `document.body`.
|
|
419
|
+
*
|
|
420
|
+
* The consumer's node is appended AFTER the template has been stamped —
|
|
421
|
+
* `stampScope` recurses, so stamping a subtree that already holds consumer
|
|
422
|
+
* DOM would brand it with our scope and let our rules match their content.
|
|
423
|
+
*
|
|
424
|
+
* ### Why this dialog is deliberately NOT `aria-modal` (#416)
|
|
425
|
+
*
|
|
426
|
+
* Tab is contained and Escape closes, but the rest of the page stays
|
|
427
|
+
* available to assistive tech — and it must. A column filter is anchored to
|
|
428
|
+
* its trigger, dismissible, and does not own the page.
|
|
429
|
+
*
|
|
430
|
+
* `aria-modal="true"` would tell a screen reader that everything outside the
|
|
431
|
+
* panel is unavailable while a virtual cursor could still walk into the table
|
|
432
|
+
* behind it. The honest way to keep that promise — marking the table `inert`
|
|
433
|
+
* while the panel is open — would hide the very rows whose values the user is
|
|
434
|
+
* picking from, which is worse than the inconsistency it fixes.
|
|
435
|
+
*
|
|
436
|
+
* So it is a non-modal dialog: the wrong claim removed rather than an
|
|
437
|
+
* unfinished one completed. `OverlayController` is right to refuse to guess
|
|
438
|
+
* whether its host is a dialog or a menu; the call belongs here, where the
|
|
439
|
+
* component knows what it is.
|
|
440
|
+
*/
|
|
441
|
+
private renderFilterPanel;
|
|
442
|
+
/**
|
|
443
|
+
* The built-in panel: clear, search, invert, checkbox list.
|
|
444
|
+
*
|
|
445
|
+
* Rendered with a `render()` of its own into the panel body, for the same
|
|
446
|
+
* reason the panel itself is: this is not part of the element's template, and
|
|
447
|
+
* lit must own the container it diffs. The checkbox list is keyed on `value`
|
|
448
|
+
* so a repaint after a re-query moves rows instead of rebuilding them — an
|
|
449
|
+
* unkeyed list would rebuild the input the user is interacting with.
|
|
450
|
+
*/
|
|
451
|
+
private renderDefaultFilterPanel;
|
|
452
|
+
/**
|
|
453
|
+
* The `'comparison'` panel: an operator and one operand.
|
|
454
|
+
*
|
|
455
|
+
* It deliberately does NOT load distinct values — the whole point of this mode
|
|
456
|
+
* is that the column's values are a quantity rather than a set worth listing,
|
|
457
|
+
* so asking the source for them would be a round trip whose answer is never
|
|
458
|
+
* displayed.
|
|
459
|
+
*/
|
|
460
|
+
private renderComparisonFilterPanel;
|
|
461
|
+
private onFilterToggle;
|
|
462
|
+
private onFilterClear;
|
|
463
|
+
/**
|
|
464
|
+
* The second `<thead>` row. One cell per column in the SAME order as row 1,
|
|
465
|
+
* gutters included — alignment is structural, not a CSS problem, and the
|
|
466
|
+
* empty cells for non-filterable columns are what keeps it that way.
|
|
467
|
+
*
|
|
468
|
+
* The cells deliberately carry no width. Widths live on row 1's `<th>`, and
|
|
469
|
+
* `table-layout: fixed` resolves columns from the first row only, so this row
|
|
470
|
+
* cannot perturb geometry once the measure pass has run. Before it runs the
|
|
471
|
+
* table is `auto`, where the row is only harmless because `.filter-trigger`
|
|
472
|
+
* is width-neutral — see the note on that rule in `datatable.light.scss`.
|
|
473
|
+
*/
|
|
474
|
+
private renderFilterRow;
|
|
475
|
+
private renderFilterCell;
|
|
276
476
|
private renderHeader;
|
|
277
477
|
private renderRow;
|
|
278
478
|
private renderRowFromRenderer;
|
package/datatable/src/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { MpDatatable } from './components';
|
|
2
2
|
export type { DatatableSelectionMode, RowEventDetail, SortChangeEventDetail, SelectionChangeEventDetail, } from './components';
|
|
3
|
-
export type { DatatableColumnDef, CellContent, CellRenderer, HeaderRenderer, RowKey, RowRenderer, RowRenderContext, TreeIdKey, TreeSelectionStrategy, DatatableFetchRequest, DatatableFetchResponse, DatatableFetch, TreeRowExpandDetail, TreeExpandedIdsChangeDetail, } from './types';
|
|
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
|
+
export type { DatatableLabels } from './types';
|
|
5
|
+
export { DEFAULT_DATATABLE_LABELS } from './types';
|
|
4
6
|
export type { SortColumn, SortDirection } from './sort';
|
|
5
7
|
export { computeNextSort, sortRows } from './sort';
|
|
6
8
|
export { datatableLightStyles } from './styles';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TemplateResult } from 'lit';
|
|
2
|
+
import { FilterContext, FilterInputType, FilterMode, FilterOperator, FilterSelection } from './filter';
|
|
2
3
|
export type CellContent = string | number | boolean | null | undefined | TemplateResult | Node;
|
|
3
4
|
export type CellRenderer<T = unknown> = (row: T, column: DatatableColumnDef<T>, rowIndex: number) => CellContent;
|
|
4
5
|
export type HeaderRenderer<T = unknown> = (column: DatatableColumnDef<T>) => CellContent;
|
|
@@ -23,6 +24,20 @@ export interface RowRenderContext {
|
|
|
23
24
|
* into the WC's shadow DOM via EmbeddedViewRef-managed nodes.
|
|
24
25
|
*/
|
|
25
26
|
export type RowRenderer<T = unknown> = (row: T | undefined, rowIndex: number, context?: RowRenderContext) => ReadonlyArray<Node> | Node | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Contents of a column's filter panel. Like every other renderer here, it is a
|
|
29
|
+
* plain function returning a DOM `Node` — the component appends it and never
|
|
30
|
+
* asks where it came from, so React/Vue pass one directly and the Angular
|
|
31
|
+
* wrapper bridges an `ng-template` through an `EmbeddedViewRef`.
|
|
32
|
+
*
|
|
33
|
+
* Returning `null` means "use the built-in panel" — that is what a wrapper
|
|
34
|
+
* returns when the consumer declared no override, and it is why a wrapper can
|
|
35
|
+
* install this unconditionally instead of deciding up front.
|
|
36
|
+
*
|
|
37
|
+
* The returned node is the CONSUMER's DOM: it is never stamped with this
|
|
38
|
+
* component's style scope, and none of its rules reach inside.
|
|
39
|
+
*/
|
|
40
|
+
export type FilterRenderer<T = unknown> = (column: DatatableColumnDef<T>, context: FilterContext) => Node | null;
|
|
26
41
|
export interface DatatableColumnDef<T = unknown> {
|
|
27
42
|
/** Data property name + sort key. */
|
|
28
43
|
name: string;
|
|
@@ -38,4 +53,50 @@ export interface DatatableColumnDef<T = unknown> {
|
|
|
38
53
|
headerRenderer?: HeaderRenderer<T>;
|
|
39
54
|
/** Forwarded to the cell as `class` attribute. */
|
|
40
55
|
cellClass?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Opt this column into the filter row. Default `false` — deliberately the
|
|
58
|
+
* opposite of `sortable`, because adding the row is a visible change to the
|
|
59
|
+
* table. The row itself is emitted only when at least one column sets this.
|
|
60
|
+
*/
|
|
61
|
+
filterable?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Contents of this column's filter panel. Ignored unless `filterable`.
|
|
64
|
+
* Absent — or present and returning `null` — renders the built-in panel.
|
|
65
|
+
*/
|
|
66
|
+
filterRenderer?: FilterRenderer<T>;
|
|
67
|
+
/**
|
|
68
|
+
* Purely visual: marks the trigger as "this column has an active filter".
|
|
69
|
+
* The component attaches no meaning to it — what counts as active, and when,
|
|
70
|
+
* belongs to the consumer.
|
|
71
|
+
*/
|
|
72
|
+
filterActive?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Short description of the active filter, rendered on the trigger and folded
|
|
75
|
+
* into its accessible name. Also consumer-owned: the component never derives
|
|
76
|
+
* it from a selection, because only the consumer knows what it filtered on.
|
|
77
|
+
*/
|
|
78
|
+
filterSummary?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Initial (or externally restored) selection for this column's panel. Read
|
|
81
|
+
* when `columns` is set; the component then owns the selection until the next
|
|
82
|
+
* `columns` assignment, so this is a seed, not a binding.
|
|
83
|
+
*/
|
|
84
|
+
filterSelection?: FilterSelection;
|
|
85
|
+
/**
|
|
86
|
+
* Which question the built-in panel asks: a checkbox list of distinct values
|
|
87
|
+
* (default) or an operator plus one operand. Ignored when `filterRenderer`
|
|
88
|
+
* returns a node, which replaces the panel entirely.
|
|
89
|
+
*/
|
|
90
|
+
filterMode?: FilterMode;
|
|
91
|
+
/**
|
|
92
|
+
* `type` of the operand input in `'comparison'` mode. Default `'number'`,
|
|
93
|
+
* and it also decides how the operand is parsed back out. There is no text
|
|
94
|
+
* option -- a free-text filter is a nest-your-own case, see FilterInputType.
|
|
95
|
+
*/
|
|
96
|
+
filterInputType?: FilterInputType;
|
|
97
|
+
/**
|
|
98
|
+
* Operators offered in `'comparison'` mode, in the order shown. Defaults to
|
|
99
|
+
* all six; narrow it when only some make sense (equality alone for an id).
|
|
100
|
+
*/
|
|
101
|
+
filterOperators?: FilterOperator[];
|
|
41
102
|
}
|