@mintplayer/web-components 2.1.1 → 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.
Files changed (128) hide show
  1. package/a11y/index.mjs +26 -2
  2. package/a11y/src/dismiss-stack.d.ts +25 -0
  3. package/a11y/src/error-text.d.ts +41 -0
  4. package/a11y/src/focus-restore.d.ts +116 -0
  5. package/a11y/src/focus-trap.d.ts +69 -0
  6. package/a11y/src/form-associated.d.ts +48 -0
  7. package/a11y/src/host-aria.d.ts +154 -0
  8. package/a11y/src/index.d.ts +16 -0
  9. package/a11y/src/inert-regions.d.ts +52 -0
  10. package/a11y/src/live-announcer.d.ts +8 -0
  11. package/a11y/src/roving-focus.d.ts +118 -0
  12. package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
  13. package/a11y/src/testing/index.d.ts +1 -0
  14. package/accordion/index.d.ts +1 -0
  15. package/accordion/index.mjs +549 -0
  16. package/accordion/src/components/index.d.ts +3 -0
  17. package/accordion/src/components/mp-accordion-tab.d.ts +30 -0
  18. package/accordion/src/components/mp-accordion.d.ts +66 -0
  19. package/accordion/src/index.d.ts +3 -0
  20. package/accordion/src/styles/index.d.ts +1 -0
  21. package/calendar/index.mjs +1 -1
  22. package/calendar/src/mp-calendar.element.d.ts +2 -0
  23. package/carousel/index.d.ts +1 -0
  24. package/carousel/index.mjs +994 -0
  25. package/carousel/src/components/index.d.ts +1 -0
  26. package/carousel/src/components/mp-carousel.d.ts +58 -0
  27. package/carousel/src/index.d.ts +3 -0
  28. package/carousel/src/styles/index.d.ts +1 -0
  29. package/carousel/src/types/carousel.d.ts +10 -0
  30. package/carousel/src/types/index.d.ts +1 -0
  31. package/checkbox/index.mjs +1 -1
  32. package/checkbox/src/components/mp-checkbox.d.ts +59 -1
  33. package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
  34. package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
  35. package/chunks/form-associated-axmc5sY0.mjs +58 -0
  36. package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
  37. package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
  38. package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
  39. package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
  40. package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
  41. package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
  42. package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
  43. package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
  44. package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
  45. package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
  46. package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
  47. package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
  48. package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
  49. package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
  50. package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
  51. package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
  52. package/chunks/roving-focus-CrL9982a.mjs +129 -0
  53. package/code-snippet/index.mjs +21 -13
  54. package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
  55. package/datatable/index.mjs +1 -1
  56. package/datatable/src/components/mp-datatable.d.ts +50 -0
  57. package/datatable/src/types/index.d.ts +2 -0
  58. package/datatable/src/types/labels.d.ts +30 -0
  59. package/datepicker/index.mjs +45 -22
  60. package/datepicker/src/mp-datepicker.element.d.ts +30 -0
  61. package/datetime-picker/index.mjs +15 -9
  62. package/dock/index.mjs +365 -209
  63. package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
  64. package/dropdown-menu/index.mjs +135 -90
  65. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
  66. package/file-manager/index.mjs +279 -214
  67. package/file-manager/src/components/mp-file-manager.d.ts +22 -0
  68. package/file-manager/src/types/messages.d.ts +9 -0
  69. package/multi-range/index.mjs +26 -10
  70. package/multi-range/src/mint-multi-range.element.d.ts +7 -0
  71. package/navbar/index.mjs +53 -39
  72. package/navbar/src/components/mp-navbar.d.ts +1 -0
  73. package/otp-input/index.mjs +82 -48
  74. package/otp-input/src/mint-otp-input.element.d.ts +31 -3
  75. package/overlay/index.mjs +2 -258
  76. package/overlay/src/overlay-controller.d.ts +64 -4
  77. package/package.json +21 -1
  78. package/pagination/index.mjs +1 -1
  79. package/query-builder/index.mjs +117 -87
  80. package/query-builder/src/model/messages.d.ts +9 -0
  81. package/radio/index.mjs +2 -160
  82. package/radio/src/components/mp-radio.d.ts +58 -3
  83. package/radio-group/index.d.ts +1 -0
  84. package/radio-group/index.mjs +145 -0
  85. package/radio-group/src/components/mp-radio-group.d.ts +52 -0
  86. package/radio-group/src/index.d.ts +1 -0
  87. package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
  88. package/ribbon/index.mjs +316 -304
  89. package/ribbon/src/mp-ribbon.element.d.ts +16 -0
  90. package/scheduler/index.mjs +219 -132
  91. package/scheduler/src/components/mp-scheduler.d.ts +3 -0
  92. package/scheduler/src/views/base-view.d.ts +23 -0
  93. package/select/index.mjs +1 -1
  94. package/select/src/components/mp-select.d.ts +60 -3
  95. package/shell/index.mjs +142 -31
  96. package/shell/src/components/mp-shell.d.ts +1 -0
  97. package/signature-pad/index.d.ts +1 -0
  98. package/signature-pad/index.mjs +230 -0
  99. package/signature-pad/src/index.d.ts +2 -0
  100. package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
  101. package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
  102. package/signature-pad/src/types/signature.d.ts +12 -0
  103. package/splitter/index.mjs +1 -1
  104. package/splitter/src/components/mp-splitter.d.ts +7 -0
  105. package/splitter/src/index.d.ts +1 -1
  106. package/swiper-core/index.d.ts +1 -0
  107. package/swiper-core/index.mjs +184 -0
  108. package/swiper-core/src/index-machine.d.ts +59 -0
  109. package/swiper-core/src/index.d.ts +4 -0
  110. package/swiper-core/src/keymap.d.ts +2 -0
  111. package/swiper-core/src/models/index.d.ts +1 -0
  112. package/swiper-core/src/models/types.d.ts +99 -0
  113. package/swiper-core/src/pointer-arbiter.d.ts +45 -0
  114. package/tab-control/index.mjs +1 -1
  115. package/tile-manager/index.mjs +110 -93
  116. package/timeline/index.mjs +138 -54
  117. package/timeline/src/components/mp-timeline.d.ts +15 -0
  118. package/timepicker/index.mjs +1 -1
  119. package/timepicker/src/mp-time-list.element.d.ts +13 -4
  120. package/timepicker/src/mp-timepicker.element.d.ts +29 -0
  121. package/toggle-button/index.mjs +1 -1
  122. package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
  123. package/tree-select/index.mjs +233 -121
  124. package/tree-select/src/components/mp-tree-select.d.ts +37 -0
  125. package/treeview/index.mjs +1 -1
  126. package/treeview/src/components/mp-treeview.d.ts +10 -1
  127. package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
  128. package/dropdown/src/styles/dropdown.styles.d.ts +0 -2
@@ -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 { OverlayController as b } from "../overlay/index.mjs";
4
- import "../chunks/mp-treeview-C48F63xb.mjs";
5
- const m = c(`:host {
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
- }`), _ = '<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>';
252
- class g extends u {
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._disabled = !1, this._searchDebounceMs = 200, this._nodes = [], this._searchResults = null, 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, {
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 s = new AbortController();
275
+ const t = new AbortController();
263
276
  try {
264
- const t = await this._provider.loadChildren(e, { offset: 0, signal: s.signal }), i = this._byId.get(e);
265
- if (i && (i.children = t.nodes, this._searchResults ? this._searchResults = [...this._searchResults] : this._nodes = [...this._nodes], this.reindexActive()), this._mode === "checkbox" && this._cascadeSelect && i && this._selected.has(e)) {
266
- for (const r of t.nodes) this.applyDown(r, !0);
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(), t.nodes;
270
- } catch (t) {
282
+ return this.requestUpdate(), s.nodes;
283
+ } catch (s) {
271
284
  return this.dispatchEvent(
272
- new CustomEvent("load-error", { detail: { error: t }, bubbles: !0, composed: !0 })
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 = [m];
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 s = Array.isArray(e) ? e : e ? [e] : [];
306
- for (const t of s)
307
- t && (this._selected.set(t.id, t), this._byId.set(t.id, t));
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 s = this._selected.values().next().value;
316
- this._selected = /* @__PURE__ */ new Map([[s.id, s]]);
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, s, t) {
364
- switch (super.attributeChangedCallback(e, s, t), e) {
393
+ attributeChangedCallback(e, t, s) {
394
+ switch (super.attributeChangedCallback(e, t, s), e) {
365
395
  case "mode":
366
- this.mode = t ?? "single";
396
+ this.mode = s ?? "single";
367
397
  break;
368
398
  case "variant":
369
- this.variant = t ?? "textbox";
399
+ this.variant = s ?? "textbox";
370
400
  break;
371
401
  case "cascade-select":
372
- this.cascadeSelect = t !== null;
402
+ this.cascadeSelect = s !== null;
373
403
  break;
374
404
  case "placeholder":
375
- this.placeholder = t ?? "";
405
+ this.placeholder = s ?? "";
376
406
  break;
377
407
  case "show-clear":
378
- this.showClear = t !== null;
408
+ this.showClear = s !== null;
379
409
  break;
380
410
  case "scroll-height":
381
- this.panelScrollHeight = t ?? "300px";
411
+ this.panelScrollHeight = s ?? "300px";
382
412
  break;
383
413
  case "disabled":
384
- this.disabled = t !== null;
414
+ this.disabled = s !== null;
385
415
  break;
386
416
  case "search-debounce-ms":
387
- this.searchDebounceMs = Number(t);
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, s) {
396
- for (const t of e)
397
- this._byId.set(t.id, t), this._parentById.set(t.id, s), t.children?.length && this.indexNodes(t.children, t);
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 s = e ? this._nodes.length : 0, t = await this.runRequest((i) => this._provider.loadRoots({ offset: s, signal: i }));
417
- t && (this._nodes = e ? [...this._nodes, ...t.nodes] : t.nodes, this._rootsHasMore = !!t.hasMore, this._rootsLoaded = !0, this.reindexActive(), this.requestUpdate());
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 s = this._query, t = e ? this._searchResults?.length ?? 0 : 0, i = await this.runRequest((r) => this._provider.search(s, { offset: t, signal: r }));
422
- i && (this._searchResults = e ? [...this._searchResults ?? [], ...i.nodes] : i.nodes, this._searchHasMore = !!i.hasMore, this.reindexActive(), this.requestUpdate());
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 s = new AbortController();
428
- this._abort = s, this._loading = !0, this.requestUpdate();
504
+ const t = new AbortController();
505
+ this._abort = t, this._loading = !0, this.requestUpdate();
429
506
  try {
430
- const t = await e(s.signal);
431
- return s.signal.aborted ? null : (this._loading = !1, this.requestUpdate(), t);
432
- } catch (t) {
433
- return s.signal.aborted || t?.name === "AbortError" || (this._loading = !1, this.dispatchEvent(
434
- new CustomEvent("load-error", { detail: { error: t }, bubbles: !0, composed: !0 })
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 s = () => {
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(s, this._searchDebounceMs) : s();
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 s = e.detail;
473
- this._selected = /* @__PURE__ */ new Map([[s.node.id, s.node]]), this._byId.set(s.node.id, s.node), this.emitChange(s.node, void 0), this.requestUpdate(), this.overlay.close();
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, s) {
476
- this._mode === "checkbox" && this._cascadeSelect ? (this.applyDown(e, s), this.applyUp(e), this.recomputeIndeterminate()) : s ? this._selected.set(e.id, e) : this._selected.delete(e.id), this.emitChange(s ? e : void 0, s ? void 0 : e), this.syncTreeviewSelection(), this.requestUpdate();
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
- 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();
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, s) {
486
- s ? this._selected.set(e.id, e) : this._selected.delete(e.id);
487
- for (const t of e.children ?? []) this.applyDown(t, s);
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 s = this._parentById.get(e.id) ?? null;
492
- for (; s; ) {
493
- const t = s.children ?? [];
494
- t.length > 0 && t.every((r) => this._selected.has(r.id)) ? this._selected.set(s.id, s) : this._selected.delete(s.id), s = this._parentById.get(s.id) ?? null;
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 = (t) => {
501
- let i = !1;
502
- for (const l of t.children ?? [])
503
- e(l) && (i = !0);
504
- const r = this._selected.has(t.id);
505
- return !r && i && this._indeterminate.add(t.id), r || i;
506
- }, s = this._searchResults ?? this._nodes;
507
- for (const t of s) e(t);
508
- }
509
- emitChange(e, s) {
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: s },
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", s = `${this._mode}|${this.suggestionTemplate ? "1" : "0"}`;
524
- return s === this._nodeRendererKey ? this._nodeRendererFn : (this._nodeRendererKey = s, this._nodeRendererFn = !e && !this.suggestionTemplate ? void 0 : (t) => {
525
- const i = document.createElement("span");
526
- if (i.className = "ts-node", e) {
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(t.id), n.indeterminate = this._indeterminate.has(t.id), n.addEventListener("click", (d) => d.stopPropagation()), n.addEventListener("change", (d) => {
529
- d.stopPropagation(), this.onCheckboxToggle(t, d.target.checked);
530
- }), i.appendChild(n);
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 r = document.createElement("span");
533
- r.className = "treeview-label";
534
- const l = this.suggestionTemplate?.(t, this._query);
535
- return l ? r.appendChild(l) : r.textContent = t.label, i.appendChild(r), i;
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`${this.renderTrigger()}${this.renderPanel()}`;
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=${(s) => this.onSearchInput(s)}
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="Remove"
605
- @click=${(s) => {
606
- s.stopPropagation(), this.removeNode(e);
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="Clear"
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 = _, e;
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="Search"
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 s = this._mode === "single" ? "single" : "none";
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=${s}
772
+ .selectionMode=${t}
661
773
  .selectedIds=${[...this._selected.keys()]}
662
774
  .loadChildren=${this.treeviewLoadChildren}
663
775
  .nodeRenderer=${this.nodeRenderer}
664
- @tree-node-select=${(t) => this.onTreeSelect(t)}
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", g);
675
- class x {
676
- constructor(e, s = {}) {
677
- this.tree = e, this.byId = /* @__PURE__ */ new Map(), this.flat = [], this.pageSize = s.pageSize ?? 50, this.delayMs = s.delayMs ?? 0;
678
- const t = (i) => {
679
- for (const r of i)
680
- this.byId.set(r.id, r), this.flat.push(r), r.children?.length && t(r.children);
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
- t(e);
794
+ s(e);
683
795
  }
684
796
  loadRoots(e) {
685
797
  return this.page(this.tree, e);
686
798
  }
687
- loadChildren(e, s) {
688
- const t = this.byId.get(e);
689
- return this.page(t?.children ?? [], s);
799
+ loadChildren(e, t) {
800
+ const s = this.byId.get(e);
801
+ return this.page(s?.children ?? [], t);
690
802
  }
691
- search(e, s) {
692
- const t = e.trim().toLowerCase();
693
- if (!t) return this.page([], s);
694
- const i = this.flat.filter(
695
- (r) => r.label.toLowerCase().includes(t) || r.id.toLowerCase().includes(t)
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(i, s);
809
+ return this.page(r, t);
698
810
  }
699
- async page(e, s) {
700
- if (this.delayMs > 0 && await new Promise((r) => setTimeout(r, this.delayMs)), s.signal.aborted) throw new DOMException("Aborted", "AbortError");
701
- const t = Math.max(0, s.offset ?? 0);
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(t, t + this.pageSize).map((r) => this.toShallow(r)),
704
- hasMore: t + this.pageSize < e.length
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 s = !!e.children?.length;
710
- return { ...e, children: void 0, lazy: s };
821
+ const t = !!e.children?.length;
822
+ return { ...e, children: void 0, lazy: t };
711
823
  }
712
824
  }
713
825
  export {
714
- x as InMemoryTreeSelectProvider,
715
- g as MpTreeSelect,
716
- m as treeSelectStyles
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;
@@ -1,4 +1,4 @@
1
- import { M as t, t as s } from "../chunks/mp-treeview-C48F63xb.mjs";
1
+ import { M as t, t as s } from "../chunks/mp-treeview-tkWu28iF.mjs";
2
2
  export {
3
3
  t as MpTreeview,
4
4
  s as treeviewStyles