@mintplayer/web-components 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/index.mjs +26 -2
- package/a11y/src/dismiss-stack.d.ts +25 -0
- package/a11y/src/error-text.d.ts +41 -0
- package/a11y/src/focus-restore.d.ts +116 -0
- package/a11y/src/focus-trap.d.ts +69 -0
- package/a11y/src/form-associated.d.ts +48 -0
- package/a11y/src/host-aria.d.ts +154 -0
- package/a11y/src/index.d.ts +16 -0
- package/a11y/src/inert-regions.d.ts +52 -0
- package/a11y/src/live-announcer.d.ts +8 -0
- package/a11y/src/roving-focus.d.ts +118 -0
- package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
- package/a11y/src/testing/index.d.ts +1 -0
- package/accordion/index.mjs +180 -174
- package/accordion/src/components/mp-accordion.d.ts +18 -13
- package/calendar/index.mjs +1 -1
- package/calendar/src/mp-calendar.element.d.ts +2 -0
- package/carousel/index.mjs +211 -164
- package/carousel/src/components/mp-carousel.d.ts +1 -0
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +59 -1
- package/chunks/color-CpFtrIoX.mjs +899 -0
- package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
- package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
- package/chunks/form-associated-axmc5sY0.mjs +58 -0
- package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
- package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
- package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
- package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
- package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
- package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
- package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
- package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
- package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
- package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
- package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
- package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
- package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
- package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
- package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
- package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
- package/chunks/roving-focus-CrL9982a.mjs +129 -0
- package/code-snippet/index.mjs +21 -13
- package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
- package/datatable/index.mjs +1 -1
- package/datatable/src/components/mp-datatable.d.ts +50 -0
- package/datatable/src/types/index.d.ts +2 -0
- package/datatable/src/types/labels.d.ts +30 -0
- package/datepicker/index.mjs +45 -22
- package/datepicker/src/mp-datepicker.element.d.ts +30 -0
- package/datetime-picker/index.mjs +15 -9
- package/dock/index.mjs +365 -209
- package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
- package/dropdown-menu/index.mjs +135 -90
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
- package/file-manager/index.mjs +279 -214
- package/file-manager/src/components/mp-file-manager.d.ts +22 -0
- package/file-manager/src/types/messages.d.ts +9 -0
- package/multi-range/index.mjs +26 -10
- package/multi-range/src/mint-multi-range.element.d.ts +7 -0
- package/navbar/index.mjs +53 -39
- package/navbar/src/components/mp-navbar.d.ts +1 -0
- package/otp-input/index.mjs +82 -48
- package/otp-input/src/mint-otp-input.element.d.ts +31 -3
- package/overlay/index.mjs +2 -258
- package/overlay/src/overlay-controller.d.ts +64 -4
- package/package.json +9 -1
- package/pagination/index.mjs +1 -1
- package/query-builder/index.mjs +117 -87
- package/query-builder/src/model/messages.d.ts +9 -0
- package/radio/index.mjs +2 -160
- package/radio/src/components/mp-radio.d.ts +58 -3
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.mjs +145 -0
- package/radio-group/src/components/mp-radio-group.d.ts +52 -0
- package/radio-group/src/index.d.ts +1 -0
- package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
- package/ribbon/index.mjs +316 -304
- package/ribbon/src/mp-ribbon.element.d.ts +16 -0
- package/scheduler/index.mjs +892 -493
- package/scheduler/src/components/mp-scheduler.d.ts +30 -0
- package/scheduler/src/input/input-handler.d.ts +2 -0
- package/scheduler/src/views/base-view.d.ts +43 -6
- package/scheduler/src/views/timeline-view.d.ts +6 -0
- package/scheduler-core/index.mjs +73 -70
- package/scheduler-core/src/models/index.d.ts +1 -0
- package/scheduler-core/src/models/messages.d.ts +69 -0
- package/scheduler-core/src/models/options.d.ts +4 -0
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +60 -3
- package/shell/index.mjs +142 -31
- package/shell/src/components/mp-shell.d.ts +1 -0
- package/signature-pad/index.d.ts +1 -0
- package/signature-pad/index.mjs +230 -0
- package/signature-pad/src/index.d.ts +2 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
- package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
- package/signature-pad/src/types/signature.d.ts +12 -0
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +7 -0
- package/tab-control/index.mjs +1 -1
- package/tile-manager/index.mjs +110 -93
- package/timeline/index.mjs +138 -54
- package/timeline/src/components/mp-timeline.d.ts +15 -0
- package/timepicker/index.mjs +1 -1
- package/timepicker/src/mp-time-list.element.d.ts +13 -4
- package/timepicker/src/mp-timepicker.element.d.ts +29 -0
- package/toggle-button/index.mjs +1 -1
- package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
- package/tree-select/index.mjs +233 -121
- package/tree-select/src/components/mp-tree-select.d.ts +37 -0
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +10 -1
- package/chunks/color-CyamnJnn.mjs +0 -847
- package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import "lit";
|
|
2
|
+
import "lit/directives/ref.js";
|
|
3
|
+
import { d as v } from "./focus-restore-DxuP1Oe2.mjs";
|
|
4
|
+
import { F as k, d, c as g } from "./focus-trap-DTOLJ5bb.mjs";
|
|
5
|
+
const b = [
|
|
6
|
+
{ originX: "start", originY: "bottom", overlayX: "start", overlayY: "top" },
|
|
7
|
+
{ originX: "start", originY: "top", overlayX: "start", overlayY: "bottom" }
|
|
8
|
+
];
|
|
9
|
+
class c {
|
|
10
|
+
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 = () => {
|
|
12
|
+
if (!this._open) return;
|
|
13
|
+
const o = this.currentStrategy();
|
|
14
|
+
if (o === "close") {
|
|
15
|
+
this.close(!1);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
o === "reposition" && this.schedulePosition();
|
|
19
|
+
}, this.onResize = () => {
|
|
20
|
+
this._open && this.schedulePosition();
|
|
21
|
+
}, this.onKeyDown = (o) => {
|
|
22
|
+
o.key === "Escape" && this._open && this.isTopOfStack() && (this.close(), o.preventDefault());
|
|
23
|
+
}, this.onMouseDown = (o) => {
|
|
24
|
+
this._open && (o.composedPath().includes(this.host) || this.close(!1));
|
|
25
|
+
}, this.host = t, this.options = e, this.focusTrap = new k(() => this.options.panel(), {
|
|
26
|
+
initialFocus: "none",
|
|
27
|
+
// open() handles initial focus; the trap only contains Tab
|
|
28
|
+
returnFocus: !1,
|
|
29
|
+
// close() owns focus return, so the two cannot fight
|
|
30
|
+
// Gate on being the top frame so an inner overlay's trap does not fight
|
|
31
|
+
// its parent's while both are open.
|
|
32
|
+
enabled: () => this.isTopOfStack()
|
|
33
|
+
}), t.addController(this);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Allocate a frame on the document's dismiss stack. Use this from code paths
|
|
37
|
+
* that don't own a full `OverlayController` instance. Pair every
|
|
38
|
+
* `pushFrame()` with a `releaseFrame(token)`.
|
|
39
|
+
*
|
|
40
|
+
* These delegate to the shared stack in `@mintplayer/web-components/a11y`
|
|
41
|
+
* rather than owning a private static, so web-component overlays and Angular
|
|
42
|
+
* overlays (via `BsOverlayStackService`, now a facade over the same array)
|
|
43
|
+
* cannot each believe they are top-most and both consume one Escape.
|
|
44
|
+
*/
|
|
45
|
+
static pushFrame() {
|
|
46
|
+
return d.push("overlay-frame-external");
|
|
47
|
+
}
|
|
48
|
+
static releaseFrame(t) {
|
|
49
|
+
d.release(t);
|
|
50
|
+
}
|
|
51
|
+
static isFrameTop(t) {
|
|
52
|
+
return d.isTop(t);
|
|
53
|
+
}
|
|
54
|
+
hostConnected() {
|
|
55
|
+
document.addEventListener("keydown", this.onKeyDown);
|
|
56
|
+
}
|
|
57
|
+
hostDisconnected() {
|
|
58
|
+
document.removeEventListener("keydown", this.onKeyDown), this.detachMouseDown(), this.stackToken && this.releaseStackToken();
|
|
59
|
+
}
|
|
60
|
+
get isOpen() {
|
|
61
|
+
return this._open;
|
|
62
|
+
}
|
|
63
|
+
async open() {
|
|
64
|
+
if (this._open) return;
|
|
65
|
+
this._open = !0;
|
|
66
|
+
const t = v();
|
|
67
|
+
this.restoreTo = t instanceof HTMLElement && t !== t.ownerDocument.body ? t : null, this.stackToken = c.pushFrame(), 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?.();
|
|
68
|
+
}
|
|
69
|
+
close(t = !0) {
|
|
70
|
+
if (!this._open) return;
|
|
71
|
+
this._open = !1, this.releaseStackToken(), this.focusTrap.isActive && this.focusTrap.deactivate();
|
|
72
|
+
const e = this.resolveReturnTarget();
|
|
73
|
+
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?.();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Focus-return target, in order of preference: whatever had focus when this
|
|
77
|
+
* overlay opened, then the explicitly configured trigger, then the
|
|
78
|
+
* positioning anchor.
|
|
79
|
+
*
|
|
80
|
+
* The captured element wins because it is right in the cases a configured
|
|
81
|
+
* trigger gets wrong (nested overlays, programmatic opens), and it degrades
|
|
82
|
+
* to the same answer in the common case — the user activated the trigger, so
|
|
83
|
+
* the trigger is what had focus. It is skipped when it has since been
|
|
84
|
+
* detached, or when it is inside the panel that is about to be hidden.
|
|
85
|
+
*/
|
|
86
|
+
resolveReturnTarget() {
|
|
87
|
+
const t = this.restoreTo;
|
|
88
|
+
return t?.isConnected && !this.isInsidePanel(t) ? t : this.options.trigger?.() ?? this.activeAnchor;
|
|
89
|
+
}
|
|
90
|
+
isInsidePanel(t) {
|
|
91
|
+
const e = this.options.panel();
|
|
92
|
+
return e !== null && (e === t || e.contains(t));
|
|
93
|
+
}
|
|
94
|
+
/** Move focus into the panel per `initialFocus`. Default is to leave it alone. */
|
|
95
|
+
moveFocusIn() {
|
|
96
|
+
let t = this.options.initialFocus ?? "none";
|
|
97
|
+
if (typeof t == "function" && (t = t() ?? "first"), t === "none") return;
|
|
98
|
+
const e = this.options.panel();
|
|
99
|
+
if (!e) return;
|
|
100
|
+
if (t instanceof HTMLElement) {
|
|
101
|
+
t.focus({ preventScroll: !0 });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (t === "self") {
|
|
105
|
+
e.hasAttribute("tabindex") || e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const o = g(e)[0];
|
|
109
|
+
o ? o.focus({ preventScroll: !0 }) : (e.hasAttribute("tabindex") || e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 }));
|
|
110
|
+
}
|
|
111
|
+
async toggle() {
|
|
112
|
+
this._open ? this.close() : await this.open();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Resolve the list of candidate anchors from `anchor()`. Single-element
|
|
116
|
+
* returns become a one-item array; null returns become an empty array.
|
|
117
|
+
* Nulls inside arrays are filtered out.
|
|
118
|
+
*/
|
|
119
|
+
resolveAnchors() {
|
|
120
|
+
const t = this.options.anchor();
|
|
121
|
+
if (t === null) return [];
|
|
122
|
+
if (Array.isArray(t)) {
|
|
123
|
+
const e = t.filter((o) => o != null);
|
|
124
|
+
return e.length === 0 && t.length > 0 && console.warn("[OverlayController] anchor() returned an array of all-null elements."), e;
|
|
125
|
+
}
|
|
126
|
+
return [t];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Resolve the *active* anchor — the one used in the most recent positioning
|
|
130
|
+
* pass, or the first available one if none has been picked yet.
|
|
131
|
+
*/
|
|
132
|
+
resolveAnchor() {
|
|
133
|
+
return this.activeAnchor ? this.activeAnchor : this.resolveAnchors()[0] ?? null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Walk the configured `positions` and pick the first candidate whose panel
|
|
137
|
+
* rect fully fits inside the viewport (minus `viewportMargin`). If none fit,
|
|
138
|
+
* the last candidate is applied and clamped to viewport edges (push behaviour).
|
|
139
|
+
*
|
|
140
|
+
* `start`/`end` are direction-aware: in RTL contexts they swap to match
|
|
141
|
+
* visual layout.
|
|
142
|
+
*
|
|
143
|
+
* Sticky-offscreen behaviour: when `stickyOnAnchorOffscreen` is true and the
|
|
144
|
+
* anchor's bounding rect is entirely outside the viewport, the panel is
|
|
145
|
+
* pinned to its last in-viewport position (clamped to viewport edges) rather
|
|
146
|
+
* than disappearing with the anchor. Normal positioning resumes when the
|
|
147
|
+
* anchor re-enters the viewport.
|
|
148
|
+
*/
|
|
149
|
+
position() {
|
|
150
|
+
const t = this.resolveAnchors(), e = this.options.panel();
|
|
151
|
+
if (t.length === 0 || !e) return;
|
|
152
|
+
this.applyPanelWidth(e, t[0]);
|
|
153
|
+
const o = this.options.viewportMargin ?? 8, i = e.getBoundingClientRect(), s = window.innerWidth, n = window.innerHeight, r = t[0].getBoundingClientRect();
|
|
154
|
+
if (this.options.stickyOnAnchorOffscreen && this.isAnchorOffscreen(r, s, n)) {
|
|
155
|
+
const l = parseFloat(e.style.left) || i.left, f = parseFloat(e.style.top) || i.top, h = this.clampToViewport({ left: l, top: f }, i, s, n, o);
|
|
156
|
+
e.style.left = `${h.left}px`, e.style.top = `${h.top}px`;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const a = this.options.positions ?? b, w = this.isRtl();
|
|
160
|
+
let u = null, p = null;
|
|
161
|
+
t: for (const l of t) {
|
|
162
|
+
const f = l.getBoundingClientRect();
|
|
163
|
+
for (const h of a) {
|
|
164
|
+
const y = this.placeFor(h, f, i, w);
|
|
165
|
+
if (u = l, p = y, this.fitsInViewport(y, i, s, n, o)) break t;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (!p || !u) return;
|
|
169
|
+
this.activeAnchor = u;
|
|
170
|
+
const m = this.clampToViewport(p, i, s, n, o);
|
|
171
|
+
e.style.left = `${m.left}px`, e.style.top = `${m.top}px`;
|
|
172
|
+
}
|
|
173
|
+
/** True when the anchor's bounding rect lies entirely outside the viewport. */
|
|
174
|
+
isAnchorOffscreen(t, e, o) {
|
|
175
|
+
return t.right < 0 || t.bottom < 0 || t.left > e || t.top > o;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Apply the configured `panelWidth` strategy to the panel element. Called
|
|
179
|
+
* from `position()` before measurement so the position-pair fit check
|
|
180
|
+
* sees the post-resize panel dimensions.
|
|
181
|
+
*
|
|
182
|
+
* For `'anchor'` and `'anchor-min'` the anchor's `offsetWidth` is used
|
|
183
|
+
* (not `getBoundingClientRect().width`) so transforms / zoom on ancestors
|
|
184
|
+
* don't skew the result.
|
|
185
|
+
*/
|
|
186
|
+
applyPanelWidth(t, e) {
|
|
187
|
+
const o = this.options.panelWidth;
|
|
188
|
+
if (o != null) {
|
|
189
|
+
if (o === "anchor") {
|
|
190
|
+
t.style.width = `${e.offsetWidth}px`, t.style.minWidth = "";
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (o === "anchor-min") {
|
|
194
|
+
t.style.minWidth = `${e.offsetWidth}px`, t.style.width = "";
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (typeof o == "number") {
|
|
198
|
+
t.style.width = `${o}px`, t.style.minWidth = "";
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
t.style.width = o, t.style.minWidth = "";
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
isRtl() {
|
|
205
|
+
return getComputedStyle(this.host).direction === "rtl";
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Compute the (left, top) at which `panel` should be placed for a single
|
|
209
|
+
* position candidate. The candidate identifies which corner of the anchor
|
|
210
|
+
* to align which corner of the panel to, plus optional pixel offsets.
|
|
211
|
+
*/
|
|
212
|
+
placeFor(t, e, o, i) {
|
|
213
|
+
const s = this.anchorXFor(t.originX, e, i), n = this.anchorYFor(t.originY, e), r = this.panelXOffsetFor(t.overlayX, o.width, i), a = this.panelYOffsetFor(t.overlayY, o.height);
|
|
214
|
+
return {
|
|
215
|
+
left: s + r + (t.offsetX ?? 0),
|
|
216
|
+
top: n + a + (t.offsetY ?? 0)
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
anchorXFor(t, e, o) {
|
|
220
|
+
const i = o ? e.right : e.left, s = o ? e.left : e.right;
|
|
221
|
+
return t === "start" ? i : t === "end" ? s : e.left + e.width / 2;
|
|
222
|
+
}
|
|
223
|
+
anchorYFor(t, e) {
|
|
224
|
+
return t === "top" ? e.top : t === "bottom" ? e.bottom : e.top + e.height / 2;
|
|
225
|
+
}
|
|
226
|
+
panelXOffsetFor(t, e, o) {
|
|
227
|
+
return t === "start" ? o ? -e : 0 : t === "end" ? o ? 0 : -e : -e / 2;
|
|
228
|
+
}
|
|
229
|
+
panelYOffsetFor(t, e) {
|
|
230
|
+
return t === "top" ? 0 : t === "bottom" ? -e : -e / 2;
|
|
231
|
+
}
|
|
232
|
+
fitsInViewport(t, e, o, i, s) {
|
|
233
|
+
return t.left >= s && t.top >= s && t.left + e.width <= o - s && t.top + e.height <= i - s;
|
|
234
|
+
}
|
|
235
|
+
clampToViewport(t, e, o, i, s) {
|
|
236
|
+
let { left: n, top: r } = t;
|
|
237
|
+
return n + e.width > o - s && (n = o - e.width - s), n < s && (n = s), r + e.height > i - s && (r = i - e.height - s), r < s && (r = s), { left: n, top: r };
|
|
238
|
+
}
|
|
239
|
+
/* ---- Scroll + resize tracking ---- */
|
|
240
|
+
currentStrategy() {
|
|
241
|
+
return this.options.scrollStrategy ?? "reposition";
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Wire scroll + resize listeners according to the active strategy. Called
|
|
245
|
+
* from open(); paired with detachScrollListeners() in close().
|
|
246
|
+
*
|
|
247
|
+
* The capture-phase listener on document catches scroll events from any
|
|
248
|
+
* scrollable ancestor without us having to walk the DOM — scroll events
|
|
249
|
+
* don't bubble, but capture-phase listeners receive every dispatch.
|
|
250
|
+
*/
|
|
251
|
+
attachScrollListeners() {
|
|
252
|
+
if (this.scrollListenersAttached) return;
|
|
253
|
+
this.scrollListenersAttached = !0;
|
|
254
|
+
const t = this.currentStrategy();
|
|
255
|
+
if (t !== "noop") {
|
|
256
|
+
if (window.addEventListener("resize", this.onResize, { passive: !0 }), t === "block") {
|
|
257
|
+
this.applyBlockScroll();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
document.addEventListener("scroll", this.onScroll, {
|
|
261
|
+
passive: !0,
|
|
262
|
+
capture: !0
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
detachScrollListeners() {
|
|
267
|
+
this.scrollListenersAttached && (this.scrollListenersAttached = !1, window.removeEventListener("resize", this.onResize), document.removeEventListener("scroll", this.onScroll, !0), this.releaseBlockScroll());
|
|
268
|
+
}
|
|
269
|
+
schedulePosition() {
|
|
270
|
+
this.positionFrame || (this.positionFrame = requestAnimationFrame(() => {
|
|
271
|
+
this.positionFrame = 0, this.position();
|
|
272
|
+
}));
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 'block' strategy: lock the document scroll position while the overlay is
|
|
276
|
+
* open. Mirrors CDK's BlockScrollStrategy — sets position: fixed on the html
|
|
277
|
+
* element with the saved offset, then restores on close. Cheap; no event
|
|
278
|
+
* preventDefault dance required.
|
|
279
|
+
*/
|
|
280
|
+
applyBlockScroll() {
|
|
281
|
+
if (this.blockedScroll) return;
|
|
282
|
+
const t = document.documentElement, e = t.scrollTop || window.scrollY, o = t.scrollLeft || window.scrollX, i = Math.max(0, window.innerWidth - t.clientWidth);
|
|
283
|
+
if (this.blockedScroll = { top: e, left: o }, i > 0) {
|
|
284
|
+
const s = document.body;
|
|
285
|
+
this.blockedBodyPaddingRight = s.style.paddingRight;
|
|
286
|
+
const n = parseFloat(getComputedStyle(s).paddingRight) || 0;
|
|
287
|
+
s.style.paddingRight = `${n + i}px`;
|
|
288
|
+
}
|
|
289
|
+
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%";
|
|
290
|
+
}
|
|
291
|
+
releaseBlockScroll() {
|
|
292
|
+
if (!this.blockedScroll) return;
|
|
293
|
+
const { top: t, left: e } = this.blockedScroll;
|
|
294
|
+
this.blockedScroll = null;
|
|
295
|
+
const o = document.documentElement;
|
|
296
|
+
o.style.position = "", o.style.top = "", o.style.left = "", o.style.width = "", o.style.removeProperty("--overlay-blocked-top"), o.style.removeProperty("--overlay-blocked-left"), this.blockedBodyPaddingRight !== null && (document.body.style.paddingRight = this.blockedBodyPaddingRight, this.blockedBodyPaddingRight = null), window.scrollTo(e, t);
|
|
297
|
+
}
|
|
298
|
+
/* ---- Esc-stack ---- */
|
|
299
|
+
releaseStackToken() {
|
|
300
|
+
this.stackToken && (c.releaseFrame(this.stackToken), this.stackToken = null);
|
|
301
|
+
}
|
|
302
|
+
isTopOfStack() {
|
|
303
|
+
return this.stackToken !== null && c.isFrameTop(this.stackToken);
|
|
304
|
+
}
|
|
305
|
+
attachMouseDown() {
|
|
306
|
+
this.mouseDownAttached || (document.addEventListener("mousedown", this.onMouseDown, !0), this.mouseDownAttached = !0);
|
|
307
|
+
}
|
|
308
|
+
detachMouseDown() {
|
|
309
|
+
this.mouseDownAttached && (document.removeEventListener("mousedown", this.onMouseDown, !0), this.mouseDownAttached = !1);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
export {
|
|
313
|
+
c as O
|
|
314
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
function h(r, t, e, s, n) {
|
|
2
|
+
if (r === 0) return -1;
|
|
3
|
+
let i = t;
|
|
4
|
+
for (let o = 0; o < r; o++) {
|
|
5
|
+
if (i += e, i < 0) {
|
|
6
|
+
if (!s) return -1;
|
|
7
|
+
i = r - 1;
|
|
8
|
+
} else if (i >= r) {
|
|
9
|
+
if (!s) return -1;
|
|
10
|
+
i = 0;
|
|
11
|
+
}
|
|
12
|
+
if (!n(i)) return i;
|
|
13
|
+
}
|
|
14
|
+
return -1;
|
|
15
|
+
}
|
|
16
|
+
function f(r, t) {
|
|
17
|
+
for (let e = 0; e < r; e++)
|
|
18
|
+
if (!t(e)) return e;
|
|
19
|
+
return -1;
|
|
20
|
+
}
|
|
21
|
+
function c(r, t) {
|
|
22
|
+
for (let e = r - 1; e >= 0; e--)
|
|
23
|
+
if (!t(e)) return e;
|
|
24
|
+
return -1;
|
|
25
|
+
}
|
|
26
|
+
class d {
|
|
27
|
+
constructor(t) {
|
|
28
|
+
this.options = t, this.activeIndex = 0;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Apply `tabindex` across the items so exactly one is tabbable.
|
|
32
|
+
*
|
|
33
|
+
* Call from the host's `updated()`. Vital for a rebuilt DOM: if the active
|
|
34
|
+
* item disappears, something must still be tabbable or the whole widget drops
|
|
35
|
+
* out of the tab order and can never be entered again — the failure the audit
|
|
36
|
+
* found in `mp-treeview` (collapse the focused node's ancestor and the tree
|
|
37
|
+
* becomes unreachable) and in `bs-rating` (no value set, so no star is
|
|
38
|
+
* tabbable).
|
|
39
|
+
*/
|
|
40
|
+
sync() {
|
|
41
|
+
const t = this.options.items();
|
|
42
|
+
t.length !== 0 && ((this.activeIndex >= t.length || this.isDisabled(t[this.activeIndex])) && (this.activeIndex = this.firstEnabledIndex(t)), t.forEach((e, s) => {
|
|
43
|
+
e.tabIndex = s === this.activeIndex ? 0 : -1;
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
/** Index of the current tab stop. */
|
|
47
|
+
get index() {
|
|
48
|
+
return this.activeIndex;
|
|
49
|
+
}
|
|
50
|
+
get activeItem() {
|
|
51
|
+
return this.options.items()[this.activeIndex] ?? null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Handle a keydown. Returns true when the key was consumed, so the caller can
|
|
55
|
+
* `preventDefault()` and stop there.
|
|
56
|
+
*
|
|
57
|
+
* Only acts when the event originated on one of the items — a key typed into
|
|
58
|
+
* an input nested inside an item must reach the input, not be reinterpreted
|
|
59
|
+
* as navigation. That guard is the bug the audit found in `mp-treeview`,
|
|
60
|
+
* where a consumer's node template could not be typed into at all.
|
|
61
|
+
*/
|
|
62
|
+
onKeydown(t) {
|
|
63
|
+
if (t.altKey || t.ctrlKey || t.metaKey) return !1;
|
|
64
|
+
const e = this.options.items();
|
|
65
|
+
if (e.length === 0) return !1;
|
|
66
|
+
const s = t.composedPath(), n = s.length > 0 ? s[0] : t.target;
|
|
67
|
+
if (!(n instanceof HTMLElement) || !e.includes(n)) return !1;
|
|
68
|
+
const i = this.options.orientation !== "vertical", o = this.options.orientation !== "horizontal", a = this.rtl(n) ? "ArrowLeft" : "ArrowRight", l = this.rtl(n) ? "ArrowRight" : "ArrowLeft";
|
|
69
|
+
switch (t.key) {
|
|
70
|
+
case "ArrowDown":
|
|
71
|
+
return o ? this.step(1) : !1;
|
|
72
|
+
case "ArrowUp":
|
|
73
|
+
return o ? this.step(-1) : !1;
|
|
74
|
+
case a:
|
|
75
|
+
return i ? this.step(1) : !1;
|
|
76
|
+
case l:
|
|
77
|
+
return i ? this.step(-1) : !1;
|
|
78
|
+
case "Home":
|
|
79
|
+
return this.moveTo(this.firstEnabledIndex(e));
|
|
80
|
+
case "End":
|
|
81
|
+
return this.moveTo(this.lastEnabledIndex(e));
|
|
82
|
+
default:
|
|
83
|
+
return !1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Move the tab stop to `index` and focus it. Returns false if it could not move. */
|
|
87
|
+
moveTo(t) {
|
|
88
|
+
const e = this.options.items(), s = e[t];
|
|
89
|
+
return !s || this.isDisabled(s) ? !1 : (this.activeIndex = t, e.forEach((n, i) => {
|
|
90
|
+
n.tabIndex = i === t ? 0 : -1;
|
|
91
|
+
}), s.focus({ preventScroll: !1 }), this.options.onActiveChange?.(s, t), !0);
|
|
92
|
+
}
|
|
93
|
+
/** Point the tab stop at a specific element, without focusing it. */
|
|
94
|
+
setActiveItem(t) {
|
|
95
|
+
const e = this.options.items().indexOf(t);
|
|
96
|
+
e < 0 || (this.activeIndex = e, this.sync());
|
|
97
|
+
}
|
|
98
|
+
step(t) {
|
|
99
|
+
const e = this.options.items(), s = h(
|
|
100
|
+
e.length,
|
|
101
|
+
this.activeIndex,
|
|
102
|
+
t,
|
|
103
|
+
this.options.wrap ?? !1,
|
|
104
|
+
(n) => this.isDisabled(e[n])
|
|
105
|
+
);
|
|
106
|
+
return s < 0 ? !1 : this.moveTo(s);
|
|
107
|
+
}
|
|
108
|
+
/** First enabled index, falling back to 0 so a fully-disabled set still has a tab stop. */
|
|
109
|
+
firstEnabledIndex(t) {
|
|
110
|
+
const e = f(t.length, (s) => this.isDisabled(t[s]));
|
|
111
|
+
return e < 0 ? 0 : e;
|
|
112
|
+
}
|
|
113
|
+
lastEnabledIndex(t) {
|
|
114
|
+
const e = c(t.length, (s) => this.isDisabled(t[s]));
|
|
115
|
+
return e < 0 ? 0 : e;
|
|
116
|
+
}
|
|
117
|
+
isDisabled(t) {
|
|
118
|
+
return this.options.isDisabled ? this.options.isDisabled(t) : t.getAttribute("aria-disabled") === "true" || t.matches(":disabled");
|
|
119
|
+
}
|
|
120
|
+
rtl(t) {
|
|
121
|
+
return this.options.rtlAware === !1 || typeof getComputedStyle != "function" ? !1 : getComputedStyle(t).direction === "rtl";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
d as R,
|
|
126
|
+
f,
|
|
127
|
+
c as l,
|
|
128
|
+
h as n
|
|
129
|
+
};
|
package/code-snippet/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { LitElement as g, css as u, html as m } from "lit";
|
|
2
|
-
import { property as
|
|
2
|
+
import { property as h, state as c } from "lit/decorators.js";
|
|
3
3
|
import { unsafeHTML as b } from "lit/directives/unsafe-html.js";
|
|
4
4
|
import n from "highlight.js/lib/common";
|
|
5
5
|
var f = Object.defineProperty, a = (r, t, e, s) => {
|
|
6
|
-
for (var o = void 0, l = r.length - 1,
|
|
7
|
-
(
|
|
6
|
+
for (var o = void 0, l = r.length - 1, d; l >= 0; l--)
|
|
7
|
+
(d = r[l]) && (o = d(t, e, o) || o);
|
|
8
8
|
return o && f(t, e, o), o;
|
|
9
9
|
};
|
|
10
|
-
const
|
|
10
|
+
const p = "mp-code-snippet";
|
|
11
11
|
class i extends g {
|
|
12
12
|
constructor() {
|
|
13
|
-
super(...arguments), this.language = "", this.code = "", this.detectedLanguage = "code", this.highlighted = "", this.toastVisible = !1, this.toastTimer = null;
|
|
13
|
+
super(...arguments), this.language = "", this.copyLabel = "Copy ${language} code to clipboard", this.code = "", this.detectedLanguage = "code", this.highlighted = "", this.toastVisible = !1, this.toastTimer = null;
|
|
14
14
|
}
|
|
15
15
|
static {
|
|
16
16
|
this.styles = u`
|
|
@@ -187,9 +187,14 @@ class i extends g {
|
|
|
187
187
|
class="copy"
|
|
188
188
|
part="copy-button"
|
|
189
189
|
@click=${this.handleCopy}
|
|
190
|
-
aria-label="
|
|
190
|
+
aria-label="${this.copyLabel.replace("${language}", this.detectedLanguage)}"
|
|
191
191
|
>Copy ${this.detectedLanguage}</button>
|
|
192
|
-
<pre
|
|
192
|
+
<pre
|
|
193
|
+
part="pre"
|
|
194
|
+
tabindex="0"
|
|
195
|
+
role="region"
|
|
196
|
+
aria-label="${this.detectedLanguage} code sample"
|
|
197
|
+
><code part="code" class="hljs">${b(this.highlighted)}</code></pre>
|
|
193
198
|
<div class="toast ${this.toastVisible ? "visible" : ""}" part="toast" aria-hidden="${!this.toastVisible}">Copied!</div>
|
|
194
199
|
<div class="sr-only" role="status" aria-live="polite">${this.toastVisible ? "Copied to clipboard" : ""}</div>
|
|
195
200
|
`;
|
|
@@ -201,21 +206,24 @@ class i extends g {
|
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
208
|
a([
|
|
204
|
-
|
|
209
|
+
h({ type: String })
|
|
205
210
|
], i.prototype, "language");
|
|
206
211
|
a([
|
|
207
|
-
|
|
212
|
+
h({ type: String, attribute: "copy-label" })
|
|
213
|
+
], i.prototype, "copyLabel");
|
|
214
|
+
a([
|
|
215
|
+
h({ type: String })
|
|
208
216
|
], i.prototype, "code");
|
|
209
217
|
a([
|
|
210
|
-
|
|
218
|
+
c()
|
|
211
219
|
], i.prototype, "detectedLanguage");
|
|
212
220
|
a([
|
|
213
|
-
|
|
221
|
+
c()
|
|
214
222
|
], i.prototype, "highlighted");
|
|
215
223
|
a([
|
|
216
|
-
|
|
224
|
+
c()
|
|
217
225
|
], i.prototype, "toastVisible");
|
|
218
|
-
typeof customElements < "u" && !customElements.get(
|
|
226
|
+
typeof customElements < "u" && !customElements.get(p) && customElements.define(p, i);
|
|
219
227
|
export {
|
|
220
228
|
i as MpCodeSnippet
|
|
221
229
|
};
|
|
@@ -26,6 +26,12 @@ import { LitElement, TemplateResult, PropertyValues } from 'lit';
|
|
|
26
26
|
export declare class MpCodeSnippet extends LitElement {
|
|
27
27
|
static styles: import('lit').CSSResult;
|
|
28
28
|
language: string;
|
|
29
|
+
/**
|
|
30
|
+
* Accessible name for the copy button. Category-2 default derived from the
|
|
31
|
+
* detected language; override for localisation. The ${language} placeholder
|
|
32
|
+
* is substituted, so a translated pattern keeps the dynamic part.
|
|
33
|
+
*/
|
|
34
|
+
copyLabel: string;
|
|
29
35
|
code: string;
|
|
30
36
|
private detectedLanguage;
|
|
31
37
|
private highlighted;
|
package/datatable/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { DatatableLabels } from '../types/labels';
|
|
2
3
|
import { SortColumn } from '../sort';
|
|
3
4
|
import { DatatableColumnDef, RowKey, RowRenderer, DatatableFetch, TreeIdKey, TreeSelectionStrategy } from '../types';
|
|
4
5
|
export type DatatableSelectionMode = 'none' | 'single' | 'multiple';
|
|
@@ -39,6 +40,28 @@ export declare class MpDatatable extends LitElement {
|
|
|
39
40
|
static styles: import('lit').CSSResult[];
|
|
40
41
|
static get observedAttributes(): string[];
|
|
41
42
|
private readonly instanceId;
|
|
43
|
+
private _caption;
|
|
44
|
+
private _inputLabel;
|
|
45
|
+
/** Tier-2 naming: references resolve in the host's tree, land on the <table>. */
|
|
46
|
+
private readonly hostAria;
|
|
47
|
+
/**
|
|
48
|
+
* Visible table caption, rendered as a real <caption> — the native way to name
|
|
49
|
+
* a table, and the only one sighted users benefit from too. For an invisible
|
|
50
|
+
* name use aria-label / input-label instead (they win over the caption in the
|
|
51
|
+
* accessible-name computation when both are set).
|
|
52
|
+
*/
|
|
53
|
+
get caption(): string | null;
|
|
54
|
+
set caption(value: string | null);
|
|
55
|
+
/**
|
|
56
|
+
* User-visible strings, overridable per key for localisation
|
|
57
|
+
* (see DatatableLabels). Property-only: it holds functions.
|
|
58
|
+
*/
|
|
59
|
+
labels: Partial<DatatableLabels> | undefined;
|
|
60
|
+
/** Merged view of labels — consumer keys over the English defaults. */
|
|
61
|
+
private get mergedLabels();
|
|
62
|
+
/** Optional invisible accessible name for the <table>. Host aria-label wins. */
|
|
63
|
+
get inputLabel(): string | null;
|
|
64
|
+
set inputLabel(value: string | null);
|
|
42
65
|
private _columns;
|
|
43
66
|
private _data;
|
|
44
67
|
private _sortColumns;
|
|
@@ -46,6 +69,18 @@ export declare class MpDatatable extends LitElement {
|
|
|
46
69
|
private _selectedIds;
|
|
47
70
|
private _cutIds;
|
|
48
71
|
private _focusedRowKey;
|
|
72
|
+
/** Polite announcements for async/derived state changes (sort, page,
|
|
73
|
+
* selection count, loaded rows) — attribute-level changes alone are
|
|
74
|
+
* inaudible mid-table. */
|
|
75
|
+
private readonly liveAnnouncer;
|
|
76
|
+
/**
|
|
77
|
+
* Focus continuity across data swaps: replacing the dataset (file-manager
|
|
78
|
+
* folder navigation, external paging) destroys the focused <tr> and would
|
|
79
|
+
* strand keyboard focus on <body>. Same-key row wins; else the row at the
|
|
80
|
+
* same index; else the table itself. Capture is scoped, so updates while
|
|
81
|
+
* focus is elsewhere never steal it.
|
|
82
|
+
*/
|
|
83
|
+
private readonly rowFocusRestore;
|
|
49
84
|
private _rowKey;
|
|
50
85
|
private _columnWidths;
|
|
51
86
|
/** Becomes `true` after the first measure-once pass locks column widths. Drives the `.measured` class on the table (→ `table-layout: fixed`). */
|
|
@@ -310,6 +345,15 @@ export declare class MpDatatable extends LitElement {
|
|
|
310
345
|
* therefore one-way: visible → deselect-all → hidden again.
|
|
311
346
|
*/
|
|
312
347
|
private onDeselectAll;
|
|
348
|
+
/**
|
|
349
|
+
* Range selections anchor here, NOT on `_focusedRowKey`. The focused-row
|
|
350
|
+
* marker is deliberately volatile — every click and keyboard focus move
|
|
351
|
+
* updates it, and both used to update it *before* this method ran, so the
|
|
352
|
+
* shift-range check compared the clicked key against itself and ranges never
|
|
353
|
+
* fired. The anchor only moves on a NON-shift selection, which is the
|
|
354
|
+
* convention every desktop file/table UI follows.
|
|
355
|
+
*/
|
|
356
|
+
private _selectionAnchorKey;
|
|
313
357
|
private handleSelectionOnClick;
|
|
314
358
|
private emitSelectionChange;
|
|
315
359
|
/**
|
|
@@ -320,6 +364,12 @@ export declare class MpDatatable extends LitElement {
|
|
|
320
364
|
private resolveRows;
|
|
321
365
|
private gotoPage;
|
|
322
366
|
private resizeState;
|
|
367
|
+
/**
|
|
368
|
+
* Keyboard column resize — the same ±px model as the pointer path, same 40px
|
|
369
|
+
* floor. The handle is a focusable role="separator"; without this it was the
|
|
370
|
+
* audit's pointer-only finding for the datatable.
|
|
371
|
+
*/
|
|
372
|
+
private onResizeHandleKeydown;
|
|
323
373
|
private startColumnResize;
|
|
324
374
|
private onColumnResizeMove;
|
|
325
375
|
private onColumnResizeEnd;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export type { DatatableColumnDef, CellContent, CellRenderer, HeaderRenderer, RowKey, RowRenderer, RowRenderContext, } from './column-def';
|
|
2
2
|
export type { DatatableFetchRequest, DatatableFetchResponse, DatatableFetch, TreeRowExpandDetail, TreeExpandedIdsChangeDetail, TreeIdKey, TreeSelectionStrategy, } from './tree';
|
|
3
|
+
export { DEFAULT_DATATABLE_LABELS } from './labels';
|
|
4
|
+
export type { DatatableLabels } from './labels';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-visible strings rendered by `<mp-datatable>`. Consumers override via the
|
|
3
|
+
* `labels` property; merge semantics are partial — any key the consumer omits
|
|
4
|
+
* falls back to the English default.
|
|
5
|
+
*
|
|
6
|
+
* Patterned after `FileManagerMessages` / `QueryBuilderMessages`. Interpolated
|
|
7
|
+
* strings are **formatter functions**, never prefix/suffix pairs: word order
|
|
8
|
+
* differs across languages, so a translated middle cannot be expressed any
|
|
9
|
+
* other way.
|
|
10
|
+
*/
|
|
11
|
+
export interface DatatableLabels {
|
|
12
|
+
/** Column header over the tree expand/collapse chevron column. */
|
|
13
|
+
treeChevronColumn: string;
|
|
14
|
+
/** The header checkbox when everything is selected. */
|
|
15
|
+
deselectAll: string;
|
|
16
|
+
/** The header checkbox when not everything is selected. */
|
|
17
|
+
selectAll: string;
|
|
18
|
+
expandRow: string;
|
|
19
|
+
collapseRow: string;
|
|
20
|
+
loading: string;
|
|
21
|
+
rowsPerPage: string;
|
|
22
|
+
resizeColumn: (column: string) => string;
|
|
23
|
+
selectRow: (rowNumber: number) => string;
|
|
24
|
+
/** Live-region announcements (Phase E). */
|
|
25
|
+
announceSorted: (column: string, direction: 'ascending' | 'descending' | 'none') => string;
|
|
26
|
+
announcePage: (page: number, totalPages: number) => string;
|
|
27
|
+
announceSelection: (count: number) => string;
|
|
28
|
+
announceLoaded: (rows: number) => string;
|
|
29
|
+
}
|
|
30
|
+
export declare const DEFAULT_DATATABLE_LABELS: DatatableLabels;
|