@mintplayer/web-components 2.2.0 → 2.3.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/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 +219 -132
- package/scheduler/src/components/mp-scheduler.d.ts +3 -0
- package/scheduler/src/views/base-view.d.ts +23 -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/mp-checkbox-BokLL7BS.mjs +0 -211
package/tree-select/index.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { unsafeCSS as c, LitElement as u, html as a, nothing as o } from "lit";
|
|
2
2
|
import { repeat as p } from "lit/directives/repeat.js";
|
|
3
|
-
import {
|
|
4
|
-
import "../chunks/
|
|
5
|
-
|
|
3
|
+
import { O as b } from "../chunks/overlay-controller-DPt13i8p.mjs";
|
|
4
|
+
import { L as m } from "../chunks/live-announcer-Bi0orG4n.mjs";
|
|
5
|
+
import { d as _ } from "../chunks/focus-restore-DxuP1Oe2.mjs";
|
|
6
|
+
import { H as f } from "../chunks/host-aria-WSGs7SPQ.mjs";
|
|
7
|
+
import "../chunks/mp-treeview-tkWu28iF.mjs";
|
|
8
|
+
const v = c(`:host {
|
|
6
9
|
display: inline-block;
|
|
7
10
|
width: 100%;
|
|
8
11
|
position: relative;
|
|
@@ -248,10 +251,20 @@ button {
|
|
|
248
251
|
flex: 0 0 auto;
|
|
249
252
|
margin: 0;
|
|
250
253
|
cursor: pointer;
|
|
251
|
-
}
|
|
252
|
-
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@media (prefers-reduced-motion: reduce) {
|
|
257
|
+
* {
|
|
258
|
+
transition-duration: 0.01ms !important;
|
|
259
|
+
animation-duration: 0.01ms !important;
|
|
260
|
+
animation-iteration-count: 1 !important;
|
|
261
|
+
}
|
|
262
|
+
}`), g = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" width="100%" height="100%"><path d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg>';
|
|
263
|
+
class y extends u {
|
|
253
264
|
constructor() {
|
|
254
|
-
super(...arguments), this._mode = "single", this._variant = "textbox", this._cascadeSelect = !1, this._placeholder = "", this._showClear = !1, this._scrollHeight = "300px", this.
|
|
265
|
+
super(...arguments), this._mode = "single", this._variant = "textbox", this._cascadeSelect = !1, this._placeholder = "", this._showClear = !1, this._scrollHeight = "300px", this._inputLabel = null, this._searchLabel = null, this._clearLabel = "Clear", this.removeLabel = (e) => `Remove ${e}`, this.hostAria = new f(this, {
|
|
266
|
+
referenceTarget: () => this.renderRoot?.querySelector("input.ts-search") ?? null
|
|
267
|
+
}), this._disabled = !1, this._searchDebounceMs = 200, this._nodes = [], this._searchResults = null, this.liveAnnouncer = new m(this), this._query = "", this._loading = !1, this._rootsLoaded = !1, this._rootsHasMore = !1, this._searchHasMore = !1, this._byId = /* @__PURE__ */ new Map(), this._parentById = /* @__PURE__ */ new Map(), this._selected = /* @__PURE__ */ new Map(), this._indeterminate = /* @__PURE__ */ new Set(), this._debounceTimer = 0, this.overlay = new b(this, {
|
|
255
268
|
anchor: () => this.renderRoot.querySelector(".ts-anchor"),
|
|
256
269
|
panel: () => this.renderRoot.querySelector(".ts-panel"),
|
|
257
270
|
panelWidth: "anchor-min",
|
|
@@ -259,23 +272,23 @@ class g extends u {
|
|
|
259
272
|
onClose: () => this.onPanelClosed()
|
|
260
273
|
}), this.treeviewLoadChildren = async (e) => {
|
|
261
274
|
if (!this._provider) return [];
|
|
262
|
-
const
|
|
275
|
+
const t = new AbortController();
|
|
263
276
|
try {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
for (const
|
|
277
|
+
const s = await this._provider.loadChildren(e, { offset: 0, signal: t.signal }), r = this._byId.get(e);
|
|
278
|
+
if (r && (r.children = s.nodes, this._searchResults ? this._searchResults = [...this._searchResults] : this._nodes = [...this._nodes], this.reindexActive()), this._mode === "checkbox" && this._cascadeSelect && r && this._selected.has(e)) {
|
|
279
|
+
for (const i of s.nodes) this.applyDown(i, !0);
|
|
267
280
|
this.recomputeIndeterminate();
|
|
268
281
|
}
|
|
269
|
-
return this.requestUpdate(),
|
|
270
|
-
} catch (
|
|
282
|
+
return this.requestUpdate(), s.nodes;
|
|
283
|
+
} catch (s) {
|
|
271
284
|
return this.dispatchEvent(
|
|
272
|
-
new CustomEvent("load-error", { detail: { error:
|
|
285
|
+
new CustomEvent("load-error", { detail: { error: s }, bubbles: !0, composed: !0 })
|
|
273
286
|
), [];
|
|
274
287
|
}
|
|
275
288
|
}, this._nodeRendererKey = "";
|
|
276
289
|
}
|
|
277
290
|
static {
|
|
278
|
-
this.styles = [
|
|
291
|
+
this.styles = [v];
|
|
279
292
|
}
|
|
280
293
|
static get observedAttributes() {
|
|
281
294
|
return [
|
|
@@ -287,9 +300,26 @@ class g extends u {
|
|
|
287
300
|
"show-clear",
|
|
288
301
|
"scroll-height",
|
|
289
302
|
"disabled",
|
|
290
|
-
"search-debounce-ms"
|
|
303
|
+
"search-debounce-ms",
|
|
304
|
+
// Naming. aria-label on the host wins over input-label; both land on the
|
|
305
|
+
// main search input, which is the control a user actually operates.
|
|
306
|
+
"aria-label",
|
|
307
|
+
"input-label",
|
|
308
|
+
"search-label",
|
|
309
|
+
"clear-label",
|
|
310
|
+
// Resolved into cross-root element references, never copied as IDREFs.
|
|
311
|
+
"aria-labelledby",
|
|
312
|
+
"aria-describedby"
|
|
291
313
|
];
|
|
292
314
|
}
|
|
315
|
+
/** Accessible name for the clear-all button. */
|
|
316
|
+
get clearLabel() {
|
|
317
|
+
return this._clearLabel;
|
|
318
|
+
}
|
|
319
|
+
set clearLabel(e) {
|
|
320
|
+
const t = e || "Clear";
|
|
321
|
+
this._clearLabel !== t && (this._clearLabel = t, this.requestUpdate());
|
|
322
|
+
}
|
|
293
323
|
// ---- public reactive properties ----------------------------------------
|
|
294
324
|
get provider() {
|
|
295
325
|
return this._provider;
|
|
@@ -302,9 +332,9 @@ class g extends u {
|
|
|
302
332
|
}
|
|
303
333
|
set value(e) {
|
|
304
334
|
this._selected = /* @__PURE__ */ new Map();
|
|
305
|
-
const
|
|
306
|
-
for (const
|
|
307
|
-
|
|
335
|
+
const t = Array.isArray(e) ? e : e ? [e] : [];
|
|
336
|
+
for (const s of t)
|
|
337
|
+
s && (this._selected.set(s.id, s), this._byId.set(s.id, s));
|
|
308
338
|
this.recomputeIndeterminate(), this.syncTreeviewSelection(), this.requestUpdate();
|
|
309
339
|
}
|
|
310
340
|
get mode() {
|
|
@@ -312,8 +342,8 @@ class g extends u {
|
|
|
312
342
|
}
|
|
313
343
|
set mode(e) {
|
|
314
344
|
if (this._mode = e, e === "single" && this._selected.size > 1) {
|
|
315
|
-
const
|
|
316
|
-
this._selected = /* @__PURE__ */ new Map([[
|
|
345
|
+
const t = this._selected.values().next().value;
|
|
346
|
+
this._selected = /* @__PURE__ */ new Map([[t.id, t]]);
|
|
317
347
|
}
|
|
318
348
|
this.requestUpdate();
|
|
319
349
|
}
|
|
@@ -360,41 +390,82 @@ class g extends u {
|
|
|
360
390
|
set searchDebounceMs(e) {
|
|
361
391
|
this._searchDebounceMs = Math.max(0, Number(e) || 0);
|
|
362
392
|
}
|
|
363
|
-
attributeChangedCallback(e,
|
|
364
|
-
switch (super.attributeChangedCallback(e,
|
|
393
|
+
attributeChangedCallback(e, t, s) {
|
|
394
|
+
switch (super.attributeChangedCallback(e, t, s), e) {
|
|
365
395
|
case "mode":
|
|
366
|
-
this.mode =
|
|
396
|
+
this.mode = s ?? "single";
|
|
367
397
|
break;
|
|
368
398
|
case "variant":
|
|
369
|
-
this.variant =
|
|
399
|
+
this.variant = s ?? "textbox";
|
|
370
400
|
break;
|
|
371
401
|
case "cascade-select":
|
|
372
|
-
this.cascadeSelect =
|
|
402
|
+
this.cascadeSelect = s !== null;
|
|
373
403
|
break;
|
|
374
404
|
case "placeholder":
|
|
375
|
-
this.placeholder =
|
|
405
|
+
this.placeholder = s ?? "";
|
|
376
406
|
break;
|
|
377
407
|
case "show-clear":
|
|
378
|
-
this.showClear =
|
|
408
|
+
this.showClear = s !== null;
|
|
379
409
|
break;
|
|
380
410
|
case "scroll-height":
|
|
381
|
-
this.panelScrollHeight =
|
|
411
|
+
this.panelScrollHeight = s ?? "300px";
|
|
382
412
|
break;
|
|
383
413
|
case "disabled":
|
|
384
|
-
this.disabled =
|
|
414
|
+
this.disabled = s !== null;
|
|
385
415
|
break;
|
|
386
416
|
case "search-debounce-ms":
|
|
387
|
-
this.searchDebounceMs = Number(
|
|
417
|
+
this.searchDebounceMs = Number(s);
|
|
418
|
+
break;
|
|
419
|
+
case "aria-label":
|
|
420
|
+
this.requestUpdate();
|
|
421
|
+
break;
|
|
422
|
+
case "input-label":
|
|
423
|
+
this._inputLabel = s, this.requestUpdate();
|
|
424
|
+
break;
|
|
425
|
+
case "search-label":
|
|
426
|
+
this._searchLabel = s, this.requestUpdate();
|
|
427
|
+
break;
|
|
428
|
+
case "clear-label":
|
|
429
|
+
this.clearLabel = s ?? "Clear";
|
|
430
|
+
break;
|
|
431
|
+
case "aria-labelledby":
|
|
432
|
+
case "aria-describedby":
|
|
433
|
+
this.hostAria.syncReferences();
|
|
388
434
|
break;
|
|
389
435
|
}
|
|
390
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* Optional accessible name for the control (the main search input). Without
|
|
439
|
+
* it the name falls back to the placeholder, then 'Search' — functional, but a
|
|
440
|
+
* placeholder is a hint, not a name, so real consumers should set one of
|
|
441
|
+
* aria-label / input-label / aria-labelledby on the host.
|
|
442
|
+
*/
|
|
443
|
+
get inputLabel() {
|
|
444
|
+
return this._inputLabel;
|
|
445
|
+
}
|
|
446
|
+
set inputLabel(e) {
|
|
447
|
+
const t = e ?? null;
|
|
448
|
+
this._inputLabel !== t && (this._inputLabel = t, this.requestUpdate());
|
|
449
|
+
}
|
|
450
|
+
/** Accessible name for the button-variant panel search box. Default 'Search'. */
|
|
451
|
+
get searchLabel() {
|
|
452
|
+
return this._searchLabel;
|
|
453
|
+
}
|
|
454
|
+
set searchLabel(e) {
|
|
455
|
+
const t = e ?? null;
|
|
456
|
+
this._searchLabel !== t && (this._searchLabel = t, this.requestUpdate());
|
|
457
|
+
}
|
|
458
|
+
// After every render — the search input is re-created across variant switches.
|
|
459
|
+
updated() {
|
|
460
|
+
this.hostAria.syncReferences();
|
|
461
|
+
}
|
|
391
462
|
disconnectedCallback() {
|
|
392
463
|
super.disconnectedCallback(), this._abort?.abort(), this._debounceTimer && clearTimeout(this._debounceTimer);
|
|
393
464
|
}
|
|
394
465
|
// ---- index helpers -----------------------------------------------------
|
|
395
|
-
indexNodes(e,
|
|
396
|
-
for (const
|
|
397
|
-
this._byId.set(
|
|
466
|
+
indexNodes(e, t) {
|
|
467
|
+
for (const s of e)
|
|
468
|
+
this._byId.set(s.id, s), this._parentById.set(s.id, t), s.children?.length && this.indexNodes(s.children, s);
|
|
398
469
|
}
|
|
399
470
|
/**
|
|
400
471
|
* Rebuild the id/parent index from the *currently displayed* tree
|
|
@@ -413,25 +484,31 @@ class g extends u {
|
|
|
413
484
|
}
|
|
414
485
|
async loadRoots(e) {
|
|
415
486
|
if (!this._provider) return;
|
|
416
|
-
const
|
|
417
|
-
|
|
487
|
+
const t = e ? this._nodes.length : 0, s = await this.runRequest((r) => this._provider.loadRoots({ offset: t, signal: r }));
|
|
488
|
+
s && (this._nodes = e ? [...this._nodes, ...s.nodes] : s.nodes, this._rootsHasMore = !!s.hasMore, this._rootsLoaded = !0, this.reindexActive(), this.requestUpdate());
|
|
418
489
|
}
|
|
419
490
|
async runSearch(e) {
|
|
420
491
|
if (!this._provider) return;
|
|
421
|
-
const
|
|
422
|
-
|
|
492
|
+
const t = this._query, s = e ? this._searchResults?.length ?? 0 : 0, r = await this.runRequest((i) => this._provider.search(t, { offset: s, signal: i }));
|
|
493
|
+
if (r) {
|
|
494
|
+
if (this._searchResults = e ? [...this._searchResults ?? [], ...r.nodes] : r.nodes, !e) {
|
|
495
|
+
const i = this._searchResults.length;
|
|
496
|
+
this.liveAnnouncer.announce(i === 1 ? "1 result." : `${i} results.`);
|
|
497
|
+
}
|
|
498
|
+
this._searchHasMore = !!r.hasMore, this.reindexActive(), this.requestUpdate();
|
|
499
|
+
}
|
|
423
500
|
}
|
|
424
501
|
/** Run a provider call with abort + loading bookkeeping. Returns null on abort/error. */
|
|
425
502
|
async runRequest(e) {
|
|
426
503
|
this._abort?.abort();
|
|
427
|
-
const
|
|
428
|
-
this._abort =
|
|
504
|
+
const t = new AbortController();
|
|
505
|
+
this._abort = t, this._loading = !0, this.requestUpdate();
|
|
429
506
|
try {
|
|
430
|
-
const
|
|
431
|
-
return
|
|
432
|
-
} catch (
|
|
433
|
-
return
|
|
434
|
-
new CustomEvent("load-error", { detail: { error:
|
|
507
|
+
const s = await e(t.signal);
|
|
508
|
+
return t.signal.aborted ? null : (this._loading = !1, this.requestUpdate(), s);
|
|
509
|
+
} catch (s) {
|
|
510
|
+
return t.signal.aborted || s?.name === "AbortError" || (this._loading = !1, this.dispatchEvent(
|
|
511
|
+
new CustomEvent("load-error", { detail: { error: s }, bubbles: !0, composed: !0 })
|
|
435
512
|
), this.requestUpdate()), null;
|
|
436
513
|
}
|
|
437
514
|
}
|
|
@@ -441,12 +518,12 @@ class g extends u {
|
|
|
441
518
|
// ---- search input ------------------------------------------------------
|
|
442
519
|
onSearchInput(e) {
|
|
443
520
|
this._query = e.target.value, this.overlay.isOpen || this.open(), this._debounceTimer && clearTimeout(this._debounceTimer);
|
|
444
|
-
const
|
|
521
|
+
const t = () => {
|
|
445
522
|
this._query.trim() ? this.runSearch(!1) : (this._abort?.abort(), this._searchResults = null, this._loading = !1, this.reindexActive(), this.requestUpdate()), this.dispatchEvent(
|
|
446
523
|
new CustomEvent("search", { detail: { query: this._query }, bubbles: !0, composed: !0 })
|
|
447
524
|
);
|
|
448
525
|
};
|
|
449
|
-
this._searchDebounceMs > 0 ? this._debounceTimer = window.setTimeout(
|
|
526
|
+
this._searchDebounceMs > 0 ? this._debounceTimer = window.setTimeout(t, this._searchDebounceMs) : t();
|
|
450
527
|
}
|
|
451
528
|
// ---- open / close ------------------------------------------------------
|
|
452
529
|
async open() {
|
|
@@ -461,6 +538,27 @@ class g extends u {
|
|
|
461
538
|
onTriggerClick() {
|
|
462
539
|
this.overlay.isOpen ? this.overlay.close() : this.open();
|
|
463
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* The BsComboboxDirective contract, inside the shadow root where the
|
|
543
|
+
* directive cannot reach: ArrowDown opens the popup (and a second ArrowDown
|
|
544
|
+
* hands focus to the tree, whose own roving model takes over); Escape closes
|
|
545
|
+
* unconditionally and keeps focus in the input. aria-expanded re-renders with
|
|
546
|
+
* the overlay state, so it is live rather than a first-render snapshot.
|
|
547
|
+
*/
|
|
548
|
+
onComboboxKeydown(e) {
|
|
549
|
+
if (e.key === "ArrowDown") {
|
|
550
|
+
if (e.preventDefault(), !this.overlay.isOpen) {
|
|
551
|
+
this.open();
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
this.renderRoot?.querySelector("mp-treeview")?.focus();
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (e.key === "Escape" && this.overlay.isOpen) {
|
|
558
|
+
e.preventDefault(), e.stopPropagation(), this.overlay.close();
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
464
562
|
focusSearchAndOpen() {
|
|
465
563
|
this.open(), requestAnimationFrame(() => {
|
|
466
564
|
this.renderRoot.querySelector(".ts-search")?.focus();
|
|
@@ -469,47 +567,55 @@ class g extends u {
|
|
|
469
567
|
// ---- selection ---------------------------------------------------------
|
|
470
568
|
onTreeSelect(e) {
|
|
471
569
|
if (this._mode !== "single") return;
|
|
472
|
-
const
|
|
473
|
-
this._selected = /* @__PURE__ */ new Map([[
|
|
570
|
+
const t = e.detail;
|
|
571
|
+
this._selected = /* @__PURE__ */ new Map([[t.node.id, t.node]]), this._byId.set(t.node.id, t.node), this.emitChange(t.node, void 0), this.requestUpdate(), this.overlay.close();
|
|
474
572
|
}
|
|
475
|
-
onCheckboxToggle(e,
|
|
476
|
-
this._mode === "checkbox" && this._cascadeSelect ? (this.applyDown(e,
|
|
573
|
+
onCheckboxToggle(e, t) {
|
|
574
|
+
this._mode === "checkbox" && this._cascadeSelect ? (this.applyDown(e, t), this.applyUp(e), this.recomputeIndeterminate()) : t ? this._selected.set(e.id, e) : this._selected.delete(e.id), this.emitChange(t ? e : void 0, t ? void 0 : e), this.syncTreeviewSelection(), this.requestUpdate();
|
|
477
575
|
}
|
|
478
576
|
removeNode(e) {
|
|
479
|
-
|
|
577
|
+
const s = Array.from(
|
|
578
|
+
this.renderRoot?.querySelectorAll(".ts-chip-remove") ?? []
|
|
579
|
+
).findIndex((r) => r.closest(".ts-chip")?.contains(_()));
|
|
580
|
+
this._mode === "checkbox" && this._cascadeSelect ? (this.applyDown(e, !1), this.applyUp(e), this.recomputeIndeterminate()) : this._selected.delete(e.id), this.emitChange(void 0, e), this.syncTreeviewSelection(), this.requestUpdate(), s >= 0 && this.updateComplete.then(() => {
|
|
581
|
+
const r = Array.from(
|
|
582
|
+
this.renderRoot?.querySelectorAll(".ts-chip-remove") ?? []
|
|
583
|
+
);
|
|
584
|
+
(r[Math.min(s, r.length - 1)] ?? this.renderRoot?.querySelector("input.ts-search"))?.focus();
|
|
585
|
+
});
|
|
480
586
|
}
|
|
481
587
|
clearAll(e) {
|
|
482
588
|
e?.stopPropagation(), this._selected = /* @__PURE__ */ new Map(), this._indeterminate.clear(), this.dispatchEvent(new CustomEvent("clear", { bubbles: !0, composed: !0 })), this.emitChange(void 0, void 0), this.syncTreeviewSelection(), this.requestUpdate();
|
|
483
589
|
}
|
|
484
590
|
/** Cascade membership down over LOADED descendants only. */
|
|
485
|
-
applyDown(e,
|
|
486
|
-
|
|
487
|
-
for (const
|
|
591
|
+
applyDown(e, t) {
|
|
592
|
+
t ? this._selected.set(e.id, e) : this._selected.delete(e.id);
|
|
593
|
+
for (const s of e.children ?? []) this.applyDown(s, t);
|
|
488
594
|
}
|
|
489
595
|
/** Roll membership up: an ancestor is selected iff all its LOADED children are. */
|
|
490
596
|
applyUp(e) {
|
|
491
|
-
let
|
|
492
|
-
for (;
|
|
493
|
-
const
|
|
494
|
-
|
|
597
|
+
let t = this._parentById.get(e.id) ?? null;
|
|
598
|
+
for (; t; ) {
|
|
599
|
+
const s = t.children ?? [];
|
|
600
|
+
s.length > 0 && s.every((i) => this._selected.has(i.id)) ? this._selected.set(t.id, t) : this._selected.delete(t.id), t = this._parentById.get(t.id) ?? null;
|
|
495
601
|
}
|
|
496
602
|
}
|
|
497
603
|
/** Indeterminate = not selected, but ≥1 loaded descendant selected. */
|
|
498
604
|
recomputeIndeterminate() {
|
|
499
605
|
this._indeterminate.clear();
|
|
500
|
-
const e = (
|
|
501
|
-
let
|
|
502
|
-
for (const l of
|
|
503
|
-
e(l) && (
|
|
504
|
-
const
|
|
505
|
-
return !
|
|
506
|
-
},
|
|
507
|
-
for (const
|
|
508
|
-
}
|
|
509
|
-
emitChange(e,
|
|
510
|
-
this.dispatchEvent(
|
|
606
|
+
const e = (s) => {
|
|
607
|
+
let r = !1;
|
|
608
|
+
for (const l of s.children ?? [])
|
|
609
|
+
e(l) && (r = !0);
|
|
610
|
+
const i = this._selected.has(s.id);
|
|
611
|
+
return !i && r && this._indeterminate.add(s.id), i || r;
|
|
612
|
+
}, t = this._searchResults ?? this._nodes;
|
|
613
|
+
for (const s of t) e(s);
|
|
614
|
+
}
|
|
615
|
+
emitChange(e, t) {
|
|
616
|
+
e ? this.liveAnnouncer.announce(`${e.label} selected.`) : t ? this.liveAnnouncer.announce(`${t.label} removed.`) : this.liveAnnouncer.announce("Selection cleared."), this.dispatchEvent(
|
|
511
617
|
new CustomEvent("value-change", {
|
|
512
|
-
detail: { value: this.value, added: e, removed:
|
|
618
|
+
detail: { value: this.value, added: e, removed: t },
|
|
513
619
|
bubbles: !0,
|
|
514
620
|
composed: !0
|
|
515
621
|
})
|
|
@@ -520,24 +626,25 @@ class g extends u {
|
|
|
520
626
|
e && (e.selectedIds = [...this._selected.keys()]);
|
|
521
627
|
}
|
|
522
628
|
get nodeRenderer() {
|
|
523
|
-
const e = this._mode === "multiple" || this._mode === "checkbox",
|
|
524
|
-
return
|
|
525
|
-
const
|
|
526
|
-
if (
|
|
629
|
+
const e = this._mode === "multiple" || this._mode === "checkbox", t = `${this._mode}|${this.suggestionTemplate ? "1" : "0"}`;
|
|
630
|
+
return t === this._nodeRendererKey ? this._nodeRendererFn : (this._nodeRendererKey = t, this._nodeRendererFn = !e && !this.suggestionTemplate ? void 0 : (s) => {
|
|
631
|
+
const r = document.createElement("span");
|
|
632
|
+
if (r.className = "ts-node", e) {
|
|
527
633
|
const n = document.createElement("input");
|
|
528
|
-
n.type = "checkbox", n.className = "ts-node-check", n.checked = this._selected.has(
|
|
529
|
-
|
|
530
|
-
}),
|
|
634
|
+
n.type = "checkbox", n.className = "ts-node-check", n.checked = this._selected.has(s.id), n.indeterminate = this._indeterminate.has(s.id), n.addEventListener("click", (h) => h.stopPropagation()), n.addEventListener("change", (h) => {
|
|
635
|
+
h.stopPropagation(), this.onCheckboxToggle(s, h.target.checked);
|
|
636
|
+
}), r.appendChild(n);
|
|
531
637
|
}
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
const l = this.suggestionTemplate?.(
|
|
535
|
-
return l ?
|
|
638
|
+
const i = document.createElement("span");
|
|
639
|
+
i.className = "treeview-label";
|
|
640
|
+
const l = this.suggestionTemplate?.(s, this._query);
|
|
641
|
+
return l ? i.appendChild(l) : i.textContent = s.label, r.appendChild(i), r;
|
|
536
642
|
}, this._nodeRendererFn);
|
|
537
643
|
}
|
|
538
644
|
// ---- render ------------------------------------------------------------
|
|
539
645
|
render() {
|
|
540
|
-
return a
|
|
646
|
+
return a`
|
|
647
|
+
${this.liveAnnouncer.template()}${this.renderTrigger()}${this.renderPanel()}`;
|
|
541
648
|
}
|
|
542
649
|
get hasSelection() {
|
|
543
650
|
return this._selected.size > 0;
|
|
@@ -570,12 +677,17 @@ class g extends u {
|
|
|
570
677
|
<input
|
|
571
678
|
class="ts-search"
|
|
572
679
|
type="text"
|
|
680
|
+
role="combobox"
|
|
681
|
+
aria-haspopup="tree"
|
|
682
|
+
aria-expanded=${this.overlay.isOpen ? "true" : "false"}
|
|
683
|
+
aria-autocomplete="list"
|
|
573
684
|
.value=${this._query}
|
|
574
685
|
?disabled=${this._disabled}
|
|
575
686
|
placeholder=${this.hasSelection ? "" : this._placeholder}
|
|
576
|
-
aria-label=${this._placeholder || "Search"}
|
|
577
|
-
@input=${(
|
|
687
|
+
aria-label=${this.getAttribute("aria-label") ?? this._inputLabel ?? (this._placeholder || "Search")}
|
|
688
|
+
@input=${(t) => this.onSearchInput(t)}
|
|
578
689
|
@focus=${() => this.open()}
|
|
690
|
+
@keydown=${(t) => this.onComboboxKeydown(t)}
|
|
579
691
|
/>
|
|
580
692
|
${this.renderClear()}
|
|
581
693
|
<span class="ts-caret">${this.renderCaret()}</span>
|
|
@@ -601,9 +713,9 @@ class g extends u {
|
|
|
601
713
|
<button
|
|
602
714
|
class="ts-chip-remove"
|
|
603
715
|
type="button"
|
|
604
|
-
aria-label
|
|
605
|
-
@click=${(
|
|
606
|
-
|
|
716
|
+
aria-label=${this.removeLabel(String(e.label ?? ""))}
|
|
717
|
+
@click=${(t) => {
|
|
718
|
+
t.stopPropagation(), this.removeNode(e);
|
|
607
719
|
}}
|
|
608
720
|
>
|
|
609
721
|
×
|
|
@@ -616,7 +728,7 @@ class g extends u {
|
|
|
616
728
|
return !this._showClear || !this.hasSelection ? o : a`<button
|
|
617
729
|
class="ts-clear"
|
|
618
730
|
type="button"
|
|
619
|
-
aria-label
|
|
731
|
+
aria-label=${this._clearLabel}
|
|
620
732
|
@click=${(e) => this.clearAll(e)}
|
|
621
733
|
>
|
|
622
734
|
×
|
|
@@ -624,11 +736,11 @@ class g extends u {
|
|
|
624
736
|
}
|
|
625
737
|
renderCaret() {
|
|
626
738
|
const e = document.createElement("span");
|
|
627
|
-
return e.style.display = "inline-flex", e.style.width = "100%", e.style.height = "100%", e.innerHTML =
|
|
739
|
+
return e.style.display = "inline-flex", e.style.width = "100%", e.style.height = "100%", e.innerHTML = g, e;
|
|
628
740
|
}
|
|
629
741
|
renderPanel() {
|
|
630
742
|
return a`
|
|
631
|
-
<div class="ts-panel" role="dialog">
|
|
743
|
+
<div class="ts-panel" role="dialog" aria-busy=${this._loading ? "true" : o}>
|
|
632
744
|
${this.headerTemplate ? a`<div class="ts-panel-header">${this.headerTemplate()}</div>` : o}
|
|
633
745
|
${this._variant === "button" ? a`<div class="ts-panel-header">
|
|
634
746
|
<input
|
|
@@ -636,7 +748,7 @@ class g extends u {
|
|
|
636
748
|
type="text"
|
|
637
749
|
.value=${this._query}
|
|
638
750
|
placeholder=${this._placeholder || "Search"}
|
|
639
|
-
aria-label
|
|
751
|
+
aria-label=${this._searchLabel ?? "Search"}
|
|
640
752
|
@input=${(e) => this.onSearchInput(e)}
|
|
641
753
|
/>
|
|
642
754
|
</div>` : o}
|
|
@@ -652,16 +764,16 @@ class g extends u {
|
|
|
652
764
|
return this._loading && (e ? this._searchResults === null : !this._rootsLoaded) ? a`<div class="ts-state"><span class="ts-spinner"></span></div>` : e ? this._searchResults?.length ? this.renderTreeview(this._searchResults) : a`<div class="ts-state">${this.noResultsTemplate ? this.noResultsTemplate() : "No results"}</div>` : this._nodes.length ? this.renderTreeview(this._nodes) : a`<div class="ts-state">${this.enterSearchTermTemplate ? this.enterSearchTermTemplate() : "No items"}</div>`;
|
|
653
765
|
}
|
|
654
766
|
renderTreeview(e) {
|
|
655
|
-
const
|
|
767
|
+
const t = this._mode === "single" ? "single" : "none";
|
|
656
768
|
return a`
|
|
657
769
|
<mp-treeview
|
|
658
770
|
hide-borders
|
|
659
771
|
.items=${e}
|
|
660
|
-
.selectionMode=${
|
|
772
|
+
.selectionMode=${t}
|
|
661
773
|
.selectedIds=${[...this._selected.keys()]}
|
|
662
774
|
.loadChildren=${this.treeviewLoadChildren}
|
|
663
775
|
.nodeRenderer=${this.nodeRenderer}
|
|
664
|
-
@tree-node-select=${(
|
|
776
|
+
@tree-node-select=${(s) => this.onTreeSelect(s)}
|
|
665
777
|
></mp-treeview>
|
|
666
778
|
`;
|
|
667
779
|
}
|
|
@@ -671,47 +783,47 @@ class g extends u {
|
|
|
671
783
|
</button>` : o;
|
|
672
784
|
}
|
|
673
785
|
}
|
|
674
|
-
typeof customElements < "u" && !customElements.get("mp-tree-select") && customElements.define("mp-tree-select",
|
|
675
|
-
class
|
|
676
|
-
constructor(e,
|
|
677
|
-
this.tree = e, this.byId = /* @__PURE__ */ new Map(), this.flat = [], this.pageSize =
|
|
678
|
-
const
|
|
679
|
-
for (const
|
|
680
|
-
this.byId.set(
|
|
786
|
+
typeof customElements < "u" && !customElements.get("mp-tree-select") && customElements.define("mp-tree-select", y);
|
|
787
|
+
class k {
|
|
788
|
+
constructor(e, t = {}) {
|
|
789
|
+
this.tree = e, this.byId = /* @__PURE__ */ new Map(), this.flat = [], this.pageSize = t.pageSize ?? 50, this.delayMs = t.delayMs ?? 0;
|
|
790
|
+
const s = (r) => {
|
|
791
|
+
for (const i of r)
|
|
792
|
+
this.byId.set(i.id, i), this.flat.push(i), i.children?.length && s(i.children);
|
|
681
793
|
};
|
|
682
|
-
|
|
794
|
+
s(e);
|
|
683
795
|
}
|
|
684
796
|
loadRoots(e) {
|
|
685
797
|
return this.page(this.tree, e);
|
|
686
798
|
}
|
|
687
|
-
loadChildren(e,
|
|
688
|
-
const
|
|
689
|
-
return this.page(
|
|
799
|
+
loadChildren(e, t) {
|
|
800
|
+
const s = this.byId.get(e);
|
|
801
|
+
return this.page(s?.children ?? [], t);
|
|
690
802
|
}
|
|
691
|
-
search(e,
|
|
692
|
-
const
|
|
693
|
-
if (!
|
|
694
|
-
const
|
|
695
|
-
(
|
|
803
|
+
search(e, t) {
|
|
804
|
+
const s = e.trim().toLowerCase();
|
|
805
|
+
if (!s) return this.page([], t);
|
|
806
|
+
const r = this.flat.filter(
|
|
807
|
+
(i) => i.label.toLowerCase().includes(s) || i.id.toLowerCase().includes(s)
|
|
696
808
|
);
|
|
697
|
-
return this.page(
|
|
809
|
+
return this.page(r, t);
|
|
698
810
|
}
|
|
699
|
-
async page(e,
|
|
700
|
-
if (this.delayMs > 0 && await new Promise((
|
|
701
|
-
const
|
|
811
|
+
async page(e, t) {
|
|
812
|
+
if (this.delayMs > 0 && await new Promise((i) => setTimeout(i, this.delayMs)), t.signal.aborted) throw new DOMException("Aborted", "AbortError");
|
|
813
|
+
const s = Math.max(0, t.offset ?? 0);
|
|
702
814
|
return {
|
|
703
|
-
nodes: e.slice(
|
|
704
|
-
hasMore:
|
|
815
|
+
nodes: e.slice(s, s + this.pageSize).map((i) => this.toShallow(i)),
|
|
816
|
+
hasMore: s + this.pageSize < e.length
|
|
705
817
|
};
|
|
706
818
|
}
|
|
707
819
|
/** Strip children; flag `lazy` when the source node actually has children. */
|
|
708
820
|
toShallow(e) {
|
|
709
|
-
const
|
|
710
|
-
return { ...e, children: void 0, lazy:
|
|
821
|
+
const t = !!e.children?.length;
|
|
822
|
+
return { ...e, children: void 0, lazy: t };
|
|
711
823
|
}
|
|
712
824
|
}
|
|
713
825
|
export {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
826
|
+
k as InMemoryTreeSelectProvider,
|
|
827
|
+
y as MpTreeSelect,
|
|
828
|
+
v as treeSelectStyles
|
|
717
829
|
};
|
|
@@ -20,6 +20,21 @@ export declare class MpTreeSelect extends LitElement {
|
|
|
20
20
|
private _placeholder;
|
|
21
21
|
private _showClear;
|
|
22
22
|
private _scrollHeight;
|
|
23
|
+
private _inputLabel;
|
|
24
|
+
private _searchLabel;
|
|
25
|
+
private _clearLabel;
|
|
26
|
+
/**
|
|
27
|
+
* Accessible name for a chip's remove button. A formatter taking the node's
|
|
28
|
+
* label, because a bare "Remove" among ten chips tells the user nothing about
|
|
29
|
+
* WHICH selection the button removes — and word order differs across
|
|
30
|
+
* languages, so prefix/suffix pairs cannot express a translated middle.
|
|
31
|
+
*/
|
|
32
|
+
removeLabel: (label: string) => string;
|
|
33
|
+
/** Accessible name for the clear-all button. */
|
|
34
|
+
get clearLabel(): string;
|
|
35
|
+
set clearLabel(value: string);
|
|
36
|
+
/** Tier-2 naming: references resolve in the host's tree, land on the search input. */
|
|
37
|
+
private readonly hostAria;
|
|
23
38
|
private _disabled;
|
|
24
39
|
private _searchDebounceMs;
|
|
25
40
|
itemTemplate?: NodeTemplate;
|
|
@@ -32,6 +47,8 @@ export declare class MpTreeSelect extends LitElement {
|
|
|
32
47
|
private _provider?;
|
|
33
48
|
private _nodes;
|
|
34
49
|
private _searchResults;
|
|
50
|
+
/** Chip add/remove, clear and result counts move no visible focus; say them. */
|
|
51
|
+
private readonly liveAnnouncer;
|
|
35
52
|
private _query;
|
|
36
53
|
private _loading;
|
|
37
54
|
private _rootsLoaded;
|
|
@@ -65,6 +82,18 @@ export declare class MpTreeSelect extends LitElement {
|
|
|
65
82
|
get searchDebounceMs(): number;
|
|
66
83
|
set searchDebounceMs(value: number);
|
|
67
84
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
85
|
+
/**
|
|
86
|
+
* Optional accessible name for the control (the main search input). Without
|
|
87
|
+
* it the name falls back to the placeholder, then 'Search' — functional, but a
|
|
88
|
+
* placeholder is a hint, not a name, so real consumers should set one of
|
|
89
|
+
* aria-label / input-label / aria-labelledby on the host.
|
|
90
|
+
*/
|
|
91
|
+
get inputLabel(): string | null;
|
|
92
|
+
set inputLabel(value: string | null);
|
|
93
|
+
/** Accessible name for the button-variant panel search box. Default 'Search'. */
|
|
94
|
+
get searchLabel(): string | null;
|
|
95
|
+
set searchLabel(value: string | null);
|
|
96
|
+
protected updated(): void;
|
|
68
97
|
disconnectedCallback(): void;
|
|
69
98
|
private indexNodes;
|
|
70
99
|
/**
|
|
@@ -89,6 +118,14 @@ export declare class MpTreeSelect extends LitElement {
|
|
|
89
118
|
close(): void;
|
|
90
119
|
private onPanelClosed;
|
|
91
120
|
private onTriggerClick;
|
|
121
|
+
/**
|
|
122
|
+
* The BsComboboxDirective contract, inside the shadow root where the
|
|
123
|
+
* directive cannot reach: ArrowDown opens the popup (and a second ArrowDown
|
|
124
|
+
* hands focus to the tree, whose own roving model takes over); Escape closes
|
|
125
|
+
* unconditionally and keeps focus in the input. aria-expanded re-renders with
|
|
126
|
+
* the overlay state, so it is live rather than a first-render snapshot.
|
|
127
|
+
*/
|
|
128
|
+
private onComboboxKeydown;
|
|
92
129
|
private focusSearchAndOpen;
|
|
93
130
|
private onTreeSelect;
|
|
94
131
|
private onCheckboxToggle;
|
package/treeview/index.mjs
CHANGED