@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.
- 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.d.ts +1 -0
- package/accordion/index.mjs +549 -0
- package/accordion/src/components/index.d.ts +3 -0
- package/accordion/src/components/mp-accordion-tab.d.ts +30 -0
- package/accordion/src/components/mp-accordion.d.ts +66 -0
- package/accordion/src/index.d.ts +3 -0
- package/accordion/src/styles/index.d.ts +1 -0
- package/calendar/index.mjs +1 -1
- package/calendar/src/mp-calendar.element.d.ts +2 -0
- package/carousel/index.d.ts +1 -0
- package/carousel/index.mjs +994 -0
- package/carousel/src/components/index.d.ts +1 -0
- package/carousel/src/components/mp-carousel.d.ts +58 -0
- package/carousel/src/index.d.ts +3 -0
- package/carousel/src/styles/index.d.ts +1 -0
- package/carousel/src/types/carousel.d.ts +10 -0
- package/carousel/src/types/index.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 +21 -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/splitter/src/index.d.ts +1 -1
- package/swiper-core/index.d.ts +1 -0
- package/swiper-core/index.mjs +184 -0
- package/swiper-core/src/index-machine.d.ts +59 -0
- package/swiper-core/src/index.d.ts +4 -0
- package/swiper-core/src/keymap.d.ts +2 -0
- package/swiper-core/src/models/index.d.ts +1 -0
- package/swiper-core/src/models/types.d.ts +99 -0
- package/swiper-core/src/pointer-arbiter.d.ts +45 -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/dropdown/src/styles/dropdown.styles.d.ts +0 -2
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
|
|
1
|
+
import { unsafeCSS as a, LitElement as o, nothing as e, html as c } from "lit";
|
|
2
|
+
import { createRef as d, ref as i } from "lit/directives/ref.js";
|
|
3
|
+
import { H as l } from "./host-aria-WSGs7SPQ.mjs";
|
|
4
|
+
import { F as h, a as f, e as v } from "./form-associated-axmc5sY0.mjs";
|
|
5
|
+
import { i as g } from "./invalid-feedback.styles-he0JYrJm.mjs";
|
|
6
|
+
const u = a(`.btn {
|
|
3
7
|
--bs-btn-padding-x: 0.75rem;
|
|
4
8
|
--bs-btn-padding-y: 0.375rem;
|
|
5
9
|
--bs-btn-font-family: ;
|
|
@@ -420,14 +424,17 @@ const d = n(`.btn {
|
|
|
420
424
|
"outline-light",
|
|
421
425
|
"outline-dark"
|
|
422
426
|
]);
|
|
423
|
-
let
|
|
424
|
-
class
|
|
427
|
+
let n = 0;
|
|
428
|
+
class p extends h(o) {
|
|
425
429
|
constructor() {
|
|
426
|
-
super(...arguments), this._checked = !1, this._disabled = !1, this._name = null, this._value = null, this._color = "primary", this.
|
|
427
|
-
|
|
428
|
-
|
|
430
|
+
super(...arguments), this._checked = !1, this._disabled = !1, this._name = null, this._value = null, this._color = "primary", this._inputLabel = null, this._errorText = null, this.hostAria = new l(this, {
|
|
431
|
+
referenceTarget: () => this._inputRef.value ?? null,
|
|
432
|
+
describedByExtras: () => f(this.renderRoot)
|
|
433
|
+
}), this._inputId = `mp-toggle-button-${++n}`, this._errorId = `mp-toggle-button-${n}-error`, this._inputRef = d(), this.onInputChange = (b) => {
|
|
434
|
+
const t = b.target.checked;
|
|
435
|
+
this._checked = t, this.reflectBoolean("checked", t), this.dispatchEvent(
|
|
429
436
|
new CustomEvent("change", {
|
|
430
|
-
detail: { checked:
|
|
437
|
+
detail: { checked: t, value: this._value },
|
|
431
438
|
bubbles: !0,
|
|
432
439
|
composed: !0
|
|
433
440
|
})
|
|
@@ -435,100 +442,187 @@ class i extends r {
|
|
|
435
442
|
};
|
|
436
443
|
}
|
|
437
444
|
static {
|
|
438
|
-
this.styles = [
|
|
445
|
+
this.styles = [u, g];
|
|
439
446
|
}
|
|
440
447
|
static {
|
|
441
448
|
this.shadowRootOptions = {
|
|
442
|
-
...
|
|
449
|
+
...o.shadowRootOptions,
|
|
443
450
|
delegatesFocus: !0
|
|
444
451
|
};
|
|
445
452
|
}
|
|
446
453
|
static get observedAttributes() {
|
|
447
454
|
return [
|
|
448
455
|
...super.observedAttributes ?? [],
|
|
456
|
+
"invalid",
|
|
457
|
+
"required",
|
|
458
|
+
// Validation message rendered inside the shadow root and referenced by the
|
|
459
|
+
// inner <input>; shown only while `invalid` is also set.
|
|
460
|
+
"error-text",
|
|
449
461
|
"checked",
|
|
450
462
|
"disabled",
|
|
451
463
|
"name",
|
|
452
464
|
"value",
|
|
453
|
-
"color"
|
|
465
|
+
"color",
|
|
466
|
+
// Copied to the inner <input>; the slotted label already names the control
|
|
467
|
+
// (flat-tree label association), so these are overrides.
|
|
468
|
+
"aria-label",
|
|
469
|
+
"input-label",
|
|
470
|
+
// Resolved into element references against the host's tree — an IDREF
|
|
471
|
+
// string cannot cross the shadow boundary.
|
|
472
|
+
"aria-labelledby",
|
|
473
|
+
"aria-describedby"
|
|
454
474
|
];
|
|
455
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* Optional override for the inner <input>'s accessible name. Usually
|
|
478
|
+
* unnecessary — the slotted visible text names the control through the
|
|
479
|
+
* flat-tree label association (slotted-label spike; verdict in the plan). For an icon-only
|
|
480
|
+
* toggle, or a name that must differ from the visible text, set this.
|
|
481
|
+
*/
|
|
482
|
+
get inputLabel() {
|
|
483
|
+
return this._inputLabel;
|
|
484
|
+
}
|
|
485
|
+
set inputLabel(b) {
|
|
486
|
+
const t = b ?? null;
|
|
487
|
+
this._inputLabel !== t && (this._inputLabel = t, this.requestUpdate());
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Validation message, as `errorText` / `error-text`. Rendered as a
|
|
491
|
+
* `.invalid-feedback` node inside the shadow root and referenced from the inner
|
|
492
|
+
* `<input>` by `aria-errormessage` **and** `aria-describedby`, but only while
|
|
493
|
+
* `invalid` is set — `aria-errormessage` is meaningless on a control that is not
|
|
494
|
+
* `aria-invalid`. Text rather than a node, because a consumer's own element sits
|
|
495
|
+
* outside this shadow root where an IDREF from the input cannot reach it.
|
|
496
|
+
*/
|
|
497
|
+
get errorText() {
|
|
498
|
+
return this._errorText;
|
|
499
|
+
}
|
|
500
|
+
set errorText(b) {
|
|
501
|
+
const t = b ?? null;
|
|
502
|
+
this._errorText !== t && (this._errorText = t, this.requestUpdate());
|
|
503
|
+
}
|
|
456
504
|
get checked() {
|
|
457
505
|
return this._checked;
|
|
458
506
|
}
|
|
459
|
-
set checked(
|
|
460
|
-
const
|
|
461
|
-
this._checked !==
|
|
507
|
+
set checked(b) {
|
|
508
|
+
const t = !!b;
|
|
509
|
+
this._checked !== t && (this._checked = t, this.reflectBoolean("checked", t), this.requestUpdate());
|
|
462
510
|
}
|
|
463
511
|
get disabled() {
|
|
464
512
|
return this._disabled;
|
|
465
513
|
}
|
|
466
|
-
set disabled(
|
|
467
|
-
const
|
|
468
|
-
this._disabled !==
|
|
514
|
+
set disabled(b) {
|
|
515
|
+
const t = !!b;
|
|
516
|
+
this._disabled !== t && (this._disabled = t, this.reflectBoolean("disabled", t), this.requestUpdate());
|
|
469
517
|
}
|
|
470
518
|
get name() {
|
|
471
519
|
return this._name;
|
|
472
520
|
}
|
|
473
|
-
set name(
|
|
474
|
-
const
|
|
475
|
-
this._name !==
|
|
521
|
+
set name(b) {
|
|
522
|
+
const t = b ?? null;
|
|
523
|
+
this._name !== t && (this._name = t, this.requestUpdate());
|
|
476
524
|
}
|
|
477
525
|
get value() {
|
|
478
526
|
return this._value;
|
|
479
527
|
}
|
|
480
|
-
set value(
|
|
481
|
-
const
|
|
482
|
-
this._value !==
|
|
528
|
+
set value(b) {
|
|
529
|
+
const t = b ?? null;
|
|
530
|
+
this._value !== t && (this._value = t, this.requestUpdate());
|
|
483
531
|
}
|
|
484
532
|
get color() {
|
|
485
533
|
return this._color;
|
|
486
534
|
}
|
|
487
|
-
set color(
|
|
488
|
-
!s.has(
|
|
535
|
+
set color(b) {
|
|
536
|
+
!s.has(b) || this._color === b || (this._color = b, this.requestUpdate());
|
|
489
537
|
}
|
|
490
|
-
attributeChangedCallback(
|
|
491
|
-
switch (super.attributeChangedCallback(
|
|
538
|
+
attributeChangedCallback(b, t, r) {
|
|
539
|
+
switch (super.attributeChangedCallback(b, t, r), b) {
|
|
540
|
+
// Read from the host in render(), so a change has to ask for one — without
|
|
541
|
+
// this, aria-invalid / aria-required froze at their first-render values and
|
|
542
|
+
// an error message could never appear on a control that started out valid.
|
|
543
|
+
case "invalid":
|
|
544
|
+
case "required":
|
|
545
|
+
this.requestUpdate();
|
|
546
|
+
break;
|
|
547
|
+
case "error-text":
|
|
548
|
+
this._errorText = r, this.requestUpdate();
|
|
549
|
+
break;
|
|
492
550
|
case "checked":
|
|
493
|
-
this._checked =
|
|
551
|
+
this._checked = r !== null, this.requestUpdate();
|
|
494
552
|
break;
|
|
495
553
|
case "disabled":
|
|
496
|
-
this._disabled =
|
|
554
|
+
this._disabled = r !== null, this.requestUpdate();
|
|
497
555
|
break;
|
|
498
556
|
case "name":
|
|
499
|
-
this._name =
|
|
557
|
+
this._name = r, this.requestUpdate();
|
|
500
558
|
break;
|
|
501
559
|
case "value":
|
|
502
|
-
this._value =
|
|
560
|
+
this._value = r, this.requestUpdate();
|
|
503
561
|
break;
|
|
504
562
|
case "color":
|
|
505
|
-
|
|
563
|
+
r && s.has(r) && (this._color = r, this.requestUpdate());
|
|
564
|
+
break;
|
|
565
|
+
case "aria-label":
|
|
566
|
+
this.requestUpdate();
|
|
567
|
+
break;
|
|
568
|
+
case "input-label":
|
|
569
|
+
this._inputLabel = r, this.requestUpdate();
|
|
570
|
+
break;
|
|
571
|
+
case "aria-labelledby":
|
|
572
|
+
case "aria-describedby":
|
|
573
|
+
this.hostAria.syncReferences();
|
|
506
574
|
break;
|
|
507
575
|
}
|
|
508
576
|
}
|
|
577
|
+
// After every render — element references point at a specific node, and Lit
|
|
578
|
+
// may replace the <input> on re-render.
|
|
579
|
+
updated() {
|
|
580
|
+
this.syncFormValue(), this.hostAria.syncReferences();
|
|
581
|
+
}
|
|
509
582
|
render() {
|
|
583
|
+
const b = v(this._errorId, this._errorText, this.hasAttribute("invalid"));
|
|
510
584
|
return c`
|
|
511
585
|
<input
|
|
586
|
+
${i(this._inputRef)}
|
|
512
587
|
type="checkbox"
|
|
513
588
|
class="btn-check"
|
|
514
589
|
id=${this._inputId}
|
|
515
590
|
.checked=${this._checked}
|
|
516
591
|
?disabled=${this._disabled}
|
|
592
|
+
aria-invalid=${this.hasAttribute("invalid") ? "true" : e}
|
|
593
|
+
aria-required=${this.hasAttribute("required") ? "true" : e}
|
|
594
|
+
aria-errormessage=${b.id}
|
|
595
|
+
aria-describedby=${b.id}
|
|
517
596
|
name=${this._name ?? e}
|
|
518
597
|
value=${this._value ?? e}
|
|
598
|
+
aria-label=${this.getAttribute("aria-label") ?? this._inputLabel ?? e}
|
|
519
599
|
@change=${this.onInputChange}
|
|
520
600
|
/>
|
|
521
601
|
<label class="btn btn-${this._color}" for=${this._inputId}>
|
|
522
602
|
<slot></slot>
|
|
523
603
|
</label>
|
|
604
|
+
${b.node}
|
|
524
605
|
`;
|
|
525
606
|
}
|
|
526
|
-
reflectBoolean(
|
|
527
|
-
|
|
607
|
+
reflectBoolean(b, t) {
|
|
608
|
+
t ? this.setAttribute(b, "") : this.removeAttribute(b);
|
|
609
|
+
}
|
|
610
|
+
// ---- form association (FormAssociatedHost, Phase F) ----
|
|
611
|
+
formValue() {
|
|
612
|
+
return this._checked ? this._value ?? "on" : null;
|
|
613
|
+
}
|
|
614
|
+
formReset() {
|
|
615
|
+
this._checked = !1, this.hasAttribute("checked") && this.removeAttribute("checked"), this.requestUpdate();
|
|
616
|
+
}
|
|
617
|
+
formRestore(b) {
|
|
618
|
+
this._checked = b != null, this.requestUpdate();
|
|
619
|
+
}
|
|
620
|
+
formValidityAnchor() {
|
|
621
|
+
return this._inputRef.value ?? null;
|
|
528
622
|
}
|
|
529
623
|
}
|
|
530
|
-
typeof customElements < "u" && !customElements.get("mp-toggle-button") && customElements.define("mp-toggle-button",
|
|
624
|
+
typeof customElements < "u" && !customElements.get("mp-toggle-button") && customElements.define("mp-toggle-button", p);
|
|
531
625
|
export {
|
|
532
|
-
|
|
533
|
-
|
|
626
|
+
p as M,
|
|
627
|
+
u as t
|
|
534
628
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { unsafeCSS as I, LitElement as y,
|
|
1
|
+
import { unsafeCSS as I, LitElement as y, nothing as d, html as n } from "lit";
|
|
2
|
+
import { L as $ } from "./live-announcer-Bi0orG4n.mjs";
|
|
2
3
|
import { repeat as C } from "lit/directives/repeat.js";
|
|
3
|
-
import { unsafeHTML as
|
|
4
|
-
const
|
|
4
|
+
import { unsafeHTML as _ } from "lit/directives/unsafe-html.js";
|
|
5
|
+
const S = I(`:host {
|
|
5
6
|
display: block;
|
|
6
7
|
width: 100%;
|
|
7
8
|
--mp-treeview-indent: 20px;
|
|
@@ -153,20 +154,25 @@ ul {
|
|
|
153
154
|
.treeview-chevron {
|
|
154
155
|
transition: none !important;
|
|
155
156
|
}
|
|
156
|
-
}`),
|
|
157
|
-
let
|
|
158
|
-
class
|
|
157
|
+
}`), E = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>';
|
|
158
|
+
let R = 0;
|
|
159
|
+
class U extends y {
|
|
159
160
|
constructor() {
|
|
160
|
-
super(...arguments), this.instanceId = `mp-treeview-${++
|
|
161
|
+
super(...arguments), this.instanceId = `mp-treeview-${++R}`, this._items = [], this._expandedIds = /* @__PURE__ */ new Set(), this._selectedIds = /* @__PURE__ */ new Set(), this._selectionMode = "single", this._hideBorders = !1, this._loadingIds = /* @__PURE__ */ new Set(), this._errorIds = /* @__PURE__ */ new Map(), this.liveAnnouncer = new $(this, { omitRole: !0 }), this._focusedId = null, this._visibleOrder = [], this._byId = /* @__PURE__ */ new Map(), this._parentById = /* @__PURE__ */ new Map(), this._inputLabel = null;
|
|
161
162
|
}
|
|
162
163
|
static {
|
|
163
|
-
this.styles = [
|
|
164
|
+
this.styles = [S];
|
|
164
165
|
}
|
|
165
166
|
static get observedAttributes() {
|
|
166
167
|
return [
|
|
167
168
|
...super.observedAttributes ?? [],
|
|
168
169
|
"selection-mode",
|
|
169
|
-
"hide-borders"
|
|
170
|
+
"hide-borders",
|
|
171
|
+
// Copied onto the in-shadow role=tree node — the host is generic (the
|
|
172
|
+
// tree role CANNOT live on the host: the live-announcer region would
|
|
173
|
+
// then be an owned child of the tree, which is invalid ARIA).
|
|
174
|
+
"aria-label",
|
|
175
|
+
"input-label"
|
|
170
176
|
];
|
|
171
177
|
}
|
|
172
178
|
get items() {
|
|
@@ -247,22 +253,36 @@ class R extends y {
|
|
|
247
253
|
if (super.attributeChangedCallback(e, t, s), e === "selection-mode") {
|
|
248
254
|
const i = s ?? "single";
|
|
249
255
|
(i === "none" || i === "single" || i === "multiple") && (this.selectionMode = i);
|
|
250
|
-
} else e === "hide-borders"
|
|
256
|
+
} else e === "hide-borders" ? (this._hideBorders = s !== null, this.requestUpdate()) : e === "aria-label" ? this.requestUpdate() : e === "input-label" && (this._inputLabel = s, this.requestUpdate());
|
|
251
257
|
}
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Accessible name for the in-shadow role=tree node (tier-2 naming: the
|
|
260
|
+
* host is generic, so a consumer cannot name the tree any other way).
|
|
261
|
+
* A host `aria-label` wins over this, per the B-phase contract.
|
|
262
|
+
*/
|
|
263
|
+
get inputLabel() {
|
|
264
|
+
return this._inputLabel;
|
|
265
|
+
}
|
|
266
|
+
set inputLabel(e) {
|
|
267
|
+
const t = e ?? null;
|
|
268
|
+
this._inputLabel !== t && (this._inputLabel = t, this.requestUpdate());
|
|
254
269
|
}
|
|
255
270
|
render() {
|
|
256
|
-
return this._visibleOrder = this.computeVisibleOrder(this._items), this._focusedId === null && this._visibleOrder.length > 0 && (this._focusedId = this._visibleOrder[0].id),
|
|
271
|
+
return this._visibleOrder = this.computeVisibleOrder(this._items), this._focusedId === null && this._visibleOrder.length > 0 && (this._focusedId = this._visibleOrder[0].id), n`
|
|
257
272
|
<div class="treeview-root">
|
|
258
|
-
<ul
|
|
273
|
+
<ul
|
|
274
|
+
role=${this._items.length > 0 ? "tree" : "presentation"}
|
|
275
|
+
aria-label=${this.getAttribute("aria-label") ?? this._inputLabel ?? d}
|
|
276
|
+
aria-multiselectable=${this._selectionMode === "multiple" ? "true" : d}
|
|
277
|
+
>
|
|
259
278
|
${this.renderNodes(this._items, 1)}
|
|
260
279
|
</ul>
|
|
261
280
|
</div>
|
|
281
|
+
${this.liveAnnouncer.template()}
|
|
262
282
|
`;
|
|
263
283
|
}
|
|
264
284
|
renderNodes(e, t) {
|
|
265
|
-
return
|
|
285
|
+
return n`
|
|
266
286
|
${C(
|
|
267
287
|
e,
|
|
268
288
|
(s) => s.id,
|
|
@@ -271,47 +291,48 @@ class R extends y {
|
|
|
271
291
|
`;
|
|
272
292
|
}
|
|
273
293
|
renderNode(e, t, s, i) {
|
|
274
|
-
const r = !!(e.children && e.children.length > 0),
|
|
294
|
+
const r = !!(e.children && e.children.length > 0), u = !!e.lazy && !r, p = r || u, l = this._loadingIds.has(e.id), a = this._errorIds.get(e.id), h = this._expandedIds.has(e.id), v = this._selectedIds.has(e.id), w = this._focusedId === e.id, m = w ? 0 : -1, b = e.iconKey && this._iconResolver ? this._iconResolver(e.iconKey, e) : void 0, x = (t - 1) * 20, f = `${this.instanceId}-row-${e.id}`, g = this._nodeRenderer ? this._nodeRenderer(e, {
|
|
275
295
|
level: t,
|
|
276
|
-
expanded:
|
|
277
|
-
selected:
|
|
278
|
-
focused:
|
|
296
|
+
expanded: h,
|
|
297
|
+
selected: v,
|
|
298
|
+
focused: w,
|
|
279
299
|
hasChildren: p
|
|
280
300
|
}) : void 0;
|
|
281
|
-
return
|
|
301
|
+
return n`
|
|
282
302
|
<li role="none">
|
|
283
303
|
<div
|
|
284
|
-
id=${
|
|
304
|
+
id=${f}
|
|
285
305
|
class="treeview-row"
|
|
286
306
|
role="treeitem"
|
|
287
307
|
data-node-id=${e.id}
|
|
288
|
-
data-selected=${
|
|
308
|
+
data-selected=${v ? "true" : "false"}
|
|
289
309
|
data-loading=${l ? "true" : "false"}
|
|
290
|
-
data-error=${
|
|
310
|
+
data-error=${a ? "true" : "false"}
|
|
291
311
|
aria-level=${t}
|
|
292
312
|
aria-setsize=${i}
|
|
293
313
|
aria-posinset=${s + 1}
|
|
294
|
-
aria-expanded=${p ?
|
|
295
|
-
aria-busy=${l ? "true" :
|
|
296
|
-
aria-selected=${this._selectionMode !== "none" ?
|
|
314
|
+
aria-expanded=${p ? h ? "true" : "false" : d}
|
|
315
|
+
aria-busy=${l ? "true" : d}
|
|
316
|
+
aria-selected=${this._selectionMode !== "none" ? v ? "true" : "false" : d}
|
|
297
317
|
tabindex=${m}
|
|
298
|
-
style=${`padding-left:${
|
|
318
|
+
style=${`padding-left:${x + 12}px`}
|
|
299
319
|
@click=${(o) => this.onRowClick(e, o)}
|
|
300
320
|
@keydown=${(o) => this.onRowKeydown(e, o)}
|
|
301
|
-
|
|
321
|
+
aria-describedby=${a ? `${f}-error` : d}
|
|
302
322
|
>
|
|
323
|
+
${a ? n`<span id="${f}-error" class="treeview-load-error">${a}</span>` : d}
|
|
303
324
|
<span
|
|
304
325
|
class=${`treeview-chevron${p ? "" : " invisible"}${l ? " loading" : ""}`}
|
|
305
|
-
data-expanded=${
|
|
326
|
+
data-expanded=${h ? "true" : "false"}
|
|
306
327
|
@click=${(o) => this.onChevronClick(e, o)}
|
|
307
328
|
aria-hidden="true"
|
|
308
|
-
>${l ?
|
|
309
|
-
${g ?
|
|
310
|
-
${
|
|
329
|
+
>${l ? n`<span class="treeview-spinner" aria-hidden="true"></span>` : _(E)}</span>
|
|
330
|
+
${g ? n`<span class="treeview-body">${g}</span>` : n`
|
|
331
|
+
${b ? n`<span class="treeview-icon" aria-hidden="true">${_(b)}</span>` : d}
|
|
311
332
|
<span class="treeview-label">${e.label}</span>
|
|
312
333
|
`}
|
|
313
334
|
</div>
|
|
314
|
-
${r &&
|
|
335
|
+
${r && h ? n`<ul role="group">${this.renderNodes(e.children, t + 1)}</ul>` : d}
|
|
315
336
|
</li>
|
|
316
337
|
`;
|
|
317
338
|
}
|
|
@@ -340,6 +361,7 @@ class R extends y {
|
|
|
340
361
|
((e.children?.length ?? 0) > 0 || e.lazy) && (t.stopPropagation(), this.focusNode(e.id), this.toggleExpansion(e));
|
|
341
362
|
}
|
|
342
363
|
onRowKeydown(e, t) {
|
|
364
|
+
if (t.composedPath()[0] !== t.currentTarget) return;
|
|
343
365
|
const s = !!(e.children && e.children.length > 0), i = this._expandedIds.has(e.id);
|
|
344
366
|
switch (t.key) {
|
|
345
367
|
case "ArrowDown": {
|
|
@@ -384,14 +406,14 @@ class R extends y {
|
|
|
384
406
|
}
|
|
385
407
|
}
|
|
386
408
|
focusRelative(e, t) {
|
|
387
|
-
const s = this._visibleOrder, i = s.findIndex((
|
|
409
|
+
const s = this._visibleOrder, i = s.findIndex((u) => u.id === e.id);
|
|
388
410
|
if (i === -1) return;
|
|
389
411
|
const r = Math.max(0, Math.min(s.length - 1, i + t));
|
|
390
412
|
r !== i && this.focusNode(s[r].id);
|
|
391
413
|
}
|
|
392
414
|
focusNode(e) {
|
|
393
415
|
this._focusedId = e, this.requestUpdate(), requestAnimationFrame(() => {
|
|
394
|
-
this.shadowRoot?.querySelector(`[data-node-id="${
|
|
416
|
+
this.shadowRoot?.querySelector(`[data-node-id="${q(e)}"]`)?.focus({ preventScroll: !1 });
|
|
395
417
|
});
|
|
396
418
|
}
|
|
397
419
|
toggleSelection(e, t) {
|
|
@@ -419,9 +441,11 @@ class R extends y {
|
|
|
419
441
|
const t = !!(e.children && e.children.length > 0);
|
|
420
442
|
if (!t && !e.lazy || this._expandedIds.has(e.id)) return;
|
|
421
443
|
if (!t && e.lazy && this._loadChildren && !this._loadingIds.has(e.id)) {
|
|
422
|
-
this._loadingIds.add(e.id), this._errorIds.delete(e.id), this.requestUpdate(), this._loadChildren(e.id).then(
|
|
444
|
+
this._loadingIds.add(e.id), this._errorIds.delete(e.id), this.liveAnnouncer.announce(`Loading ${e.label}.`), this.requestUpdate(), this._loadChildren(e.id).then(
|
|
423
445
|
(i) => {
|
|
424
|
-
this._loadingIds.delete(e.id)
|
|
446
|
+
this._loadingIds.delete(e.id), this.liveAnnouncer.announce(
|
|
447
|
+
`${e.label} loaded, ${i?.length ?? 0} item${(i?.length ?? 0) === 1 ? "" : "s"}.`
|
|
448
|
+
);
|
|
425
449
|
const r = new Set(this._expandedIds);
|
|
426
450
|
r.add(e.id), this._expandedIds = r, this.requestUpdate(), this.dispatchEvent(
|
|
427
451
|
new CustomEvent("tree-node-expand", {
|
|
@@ -432,7 +456,7 @@ class R extends y {
|
|
|
432
456
|
);
|
|
433
457
|
},
|
|
434
458
|
(i) => {
|
|
435
|
-
this._loadingIds.delete(e.id), this._errorIds.set(e.id, i instanceof Error ? i.message : String(i)), this.requestUpdate(), this.dispatchEvent(
|
|
459
|
+
this._loadingIds.delete(e.id), this._errorIds.set(e.id, i instanceof Error ? i.message : String(i)), this.liveAnnouncer.announce(`Loading ${e.label} failed.`), this.requestUpdate(), this.dispatchEvent(
|
|
436
460
|
new CustomEvent("tree-node-load-error", {
|
|
437
461
|
detail: { node: e, error: i },
|
|
438
462
|
bubbles: !0,
|
|
@@ -464,11 +488,11 @@ class R extends y {
|
|
|
464
488
|
);
|
|
465
489
|
}
|
|
466
490
|
}
|
|
467
|
-
function
|
|
468
|
-
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(
|
|
491
|
+
function q(c) {
|
|
492
|
+
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(c) : c.replace(/["\\]/g, "\\$&");
|
|
469
493
|
}
|
|
470
|
-
typeof customElements < "u" && !customElements.get("mp-treeview") && customElements.define("mp-treeview",
|
|
494
|
+
typeof customElements < "u" && !customElements.get("mp-treeview") && customElements.define("mp-treeview", U);
|
|
471
495
|
export {
|
|
472
|
-
|
|
473
|
-
|
|
496
|
+
U as M,
|
|
497
|
+
S as t
|
|
474
498
|
};
|