287 lines
9.0 KiB
JavaScript
287 lines
9.0 KiB
JavaScript
import { _ as p, n as C, r as S, x as z, a as L, b as P } from "./class-map-CwiboTfb.mjs";
|
|
import { e as k } from "./animation-DjClVFum.mjs";
|
|
/**
|
|
* @license
|
|
* Copyright 2017 Google LLC
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
let $;
|
|
function K(s) {
|
|
return (e, t) => k(e, t, { get() {
|
|
return (this.renderRoot ?? $ ?? ($ = document.createDocumentFragment())).querySelectorAll(s);
|
|
} });
|
|
}
|
|
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
function x(s, e = c) {
|
|
const t = A(s, e);
|
|
return t && (t.tabIndex = 0, t.focus()), t;
|
|
}
|
|
function w(s, e = c) {
|
|
const t = _(s, e);
|
|
return t && (t.tabIndex = 0, t.focus()), t;
|
|
}
|
|
function W(s, e = c) {
|
|
const t = h(s, e);
|
|
return t && (t.item.tabIndex = -1), t;
|
|
}
|
|
function h(s, e = c) {
|
|
for (let t = 0; t < s.length; t++) {
|
|
const i = s[t];
|
|
if (i.tabIndex === 0 && e(i))
|
|
return {
|
|
item: i,
|
|
index: t
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
function A(s, e = c) {
|
|
for (const t of s)
|
|
if (e(t))
|
|
return t;
|
|
return null;
|
|
}
|
|
function _(s, e = c) {
|
|
for (let t = s.length - 1; t >= 0; t--) {
|
|
const i = s[t];
|
|
if (e(i))
|
|
return i;
|
|
}
|
|
return null;
|
|
}
|
|
function q(s, e, t = c, i = !0) {
|
|
for (let a = 1; a < s.length; a++) {
|
|
const n = (a + e) % s.length;
|
|
if (n < e && !i)
|
|
return null;
|
|
const d = s[n];
|
|
if (t(d))
|
|
return d;
|
|
}
|
|
return s[e] ? s[e] : null;
|
|
}
|
|
function H(s, e, t = c, i = !0) {
|
|
for (let a = 1; a < s.length; a++) {
|
|
const n = (e - a + s.length) % s.length;
|
|
if (n > e && !i)
|
|
return null;
|
|
const d = s[n];
|
|
if (t(d))
|
|
return d;
|
|
}
|
|
return s[e] ? s[e] : null;
|
|
}
|
|
function y(s, e, t = c, i = !0) {
|
|
if (e) {
|
|
const a = q(s, e.index, t, i);
|
|
return a && (a.tabIndex = 0, a.focus()), a;
|
|
} else
|
|
return x(s, t);
|
|
}
|
|
function I(s, e, t = c, i = !0) {
|
|
if (e) {
|
|
const a = H(s, e.index, t, i);
|
|
return a && (a.tabIndex = 0, a.focus()), a;
|
|
} else
|
|
return w(s, t);
|
|
}
|
|
function B() {
|
|
return new Event("deactivate-items", { bubbles: !0, composed: !0 });
|
|
}
|
|
function X() {
|
|
return new Event("request-activation", { bubbles: !0, composed: !0 });
|
|
}
|
|
function c(s) {
|
|
return !s.disabled;
|
|
}
|
|
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
const f = {
|
|
ArrowDown: "ArrowDown",
|
|
ArrowLeft: "ArrowLeft",
|
|
ArrowUp: "ArrowUp",
|
|
ArrowRight: "ArrowRight",
|
|
Home: "Home",
|
|
End: "End"
|
|
};
|
|
class j {
|
|
constructor(e) {
|
|
this.handleKeydown = (r) => {
|
|
const o = r.key;
|
|
if (r.defaultPrevented || !this.isNavigableKey(o))
|
|
return;
|
|
const m = this.items;
|
|
if (!m.length)
|
|
return;
|
|
const l = h(m, this.isActivatable);
|
|
r.preventDefault();
|
|
const v = this.isRtl(), D = v ? f.ArrowRight : f.ArrowLeft, T = v ? f.ArrowLeft : f.ArrowRight;
|
|
let u = null;
|
|
switch (o) {
|
|
case f.ArrowDown:
|
|
case T:
|
|
u = y(m, l, this.isActivatable, this.wrapNavigation());
|
|
break;
|
|
case f.ArrowUp:
|
|
case D:
|
|
u = I(m, l, this.isActivatable, this.wrapNavigation());
|
|
break;
|
|
case f.Home:
|
|
u = x(m, this.isActivatable);
|
|
break;
|
|
case f.End:
|
|
u = w(m, this.isActivatable);
|
|
break;
|
|
}
|
|
u && l && l.item !== u && (l.item.tabIndex = -1);
|
|
}, this.onDeactivateItems = () => {
|
|
const r = this.items;
|
|
for (const o of r)
|
|
this.deactivateItem(o);
|
|
}, this.onRequestActivation = (r) => {
|
|
this.onDeactivateItems();
|
|
const o = r.target;
|
|
this.activateItem(o), o.focus();
|
|
}, this.onSlotchange = () => {
|
|
const r = this.items;
|
|
let o = !1;
|
|
for (const l of r) {
|
|
if (!l.disabled && l.tabIndex > -1 && !o) {
|
|
o = !0, l.tabIndex = 0;
|
|
continue;
|
|
}
|
|
l.tabIndex = -1;
|
|
}
|
|
if (o)
|
|
return;
|
|
const m = A(r, this.isActivatable);
|
|
m && (m.tabIndex = 0);
|
|
};
|
|
const { isItem: t, getPossibleItems: i, isRtl: a, deactivateItem: n, activateItem: d, isNavigableKey: N, isActivatable: R, wrapNavigation: E } = e;
|
|
this.isItem = t, this.getPossibleItems = i, this.isRtl = a, this.deactivateItem = n, this.activateItem = d, this.isNavigableKey = N, this.isActivatable = R, this.wrapNavigation = E ?? (() => !0);
|
|
}
|
|
/**
|
|
* The items being managed by the list. Additionally, attempts to see if the
|
|
* object has a sub-item in the `.item` property.
|
|
*/
|
|
get items() {
|
|
const e = this.getPossibleItems(), t = [];
|
|
for (const i of e) {
|
|
if (this.isItem(i)) {
|
|
t.push(i);
|
|
continue;
|
|
}
|
|
const n = i.item;
|
|
n && this.isItem(n) && t.push(n);
|
|
}
|
|
return t;
|
|
}
|
|
/**
|
|
* Activates the next item in the list. If at the end of the list, the first
|
|
* item will be activated.
|
|
*
|
|
* @return The activated list item or `null` if there are no items.
|
|
*/
|
|
activateNextItem() {
|
|
const e = this.items, t = h(e, this.isActivatable);
|
|
return t && (t.item.tabIndex = -1), y(e, t, this.isActivatable, this.wrapNavigation());
|
|
}
|
|
/**
|
|
* Activates the previous item in the list. If at the start of the list, the
|
|
* last item will be activated.
|
|
*
|
|
* @return The activated list item or `null` if there are no items.
|
|
*/
|
|
activatePreviousItem() {
|
|
const e = this.items, t = h(e, this.isActivatable);
|
|
return t && (t.item.tabIndex = -1), I(e, t, this.isActivatable, this.wrapNavigation());
|
|
}
|
|
}
|
|
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
class b extends S {
|
|
constructor() {
|
|
super(...arguments), this.multiline = !1;
|
|
}
|
|
render() {
|
|
return z`
|
|
<slot name="container"></slot>
|
|
<slot class="non-text" name="start"></slot>
|
|
<div class="text">
|
|
<slot name="overline" @slotchange=${this.handleTextSlotChange}></slot>
|
|
<slot
|
|
class="default-slot"
|
|
@slotchange=${this.handleTextSlotChange}></slot>
|
|
<slot name="headline" @slotchange=${this.handleTextSlotChange}></slot>
|
|
<slot
|
|
name="supporting-text"
|
|
@slotchange=${this.handleTextSlotChange}></slot>
|
|
</div>
|
|
<slot class="non-text" name="trailing-supporting-text"></slot>
|
|
<slot class="non-text" name="end"></slot>
|
|
`;
|
|
}
|
|
handleTextSlotChange() {
|
|
let e = !1, t = 0;
|
|
for (const i of this.textSlots)
|
|
if (M(i) && (t += 1), t > 1) {
|
|
e = !0;
|
|
break;
|
|
}
|
|
this.multiline = e;
|
|
}
|
|
}
|
|
p([
|
|
C({ type: Boolean, reflect: !0 })
|
|
], b.prototype, "multiline", void 0);
|
|
p([
|
|
K(".text slot")
|
|
], b.prototype, "textSlots", void 0);
|
|
function M(s) {
|
|
var e;
|
|
for (const t of s.assignedNodes({ flatten: !0 })) {
|
|
const i = t.nodeType === Node.ELEMENT_NODE, a = t.nodeType === Node.TEXT_NODE && ((e = t.textContent) == null ? void 0 : e.match(/\S/));
|
|
if (i || a)
|
|
return !0;
|
|
}
|
|
return !1;
|
|
}
|
|
/**
|
|
* @license
|
|
* Copyright 2024 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
const F = L`:host{color:var(--md-sys-color-on-surface, #1d1b20);font-family:var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-body-large-size, 1rem);font-weight:var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400));line-height:var(--md-sys-typescale-body-large-line-height, 1.5rem);align-items:center;box-sizing:border-box;display:flex;gap:16px;min-height:56px;overflow:hidden;padding:12px 16px;position:relative;text-overflow:ellipsis}:host([multiline]){min-height:72px}[name=overline]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-label-small-size, 0.6875rem);font-weight:var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500));line-height:var(--md-sys-typescale-label-small-line-height, 1rem)}[name=supporting-text]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-body-medium-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-body-medium-size, 0.875rem);font-weight:var(--md-sys-typescale-body-medium-weight, var(--md-ref-typeface-weight-regular, 400));line-height:var(--md-sys-typescale-body-medium-line-height, 1.25rem)}[name=trailing-supporting-text]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-label-small-size, 0.6875rem);font-weight:var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500));line-height:var(--md-sys-typescale-label-small-line-height, 1rem)}[name=container]::slotted(*){inset:0;position:absolute}.default-slot{display:inline}.default-slot,.text ::slotted(*){overflow:hidden;text-overflow:ellipsis}.text{display:flex;flex:1;flex-direction:column;overflow:hidden}
|
|
`;
|
|
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
let g = class extends b {
|
|
};
|
|
g.styles = [F];
|
|
g = p([
|
|
P("md-item")
|
|
], g);
|
|
export {
|
|
j as L,
|
|
f as N,
|
|
X as a,
|
|
h as b,
|
|
B as c,
|
|
W as d,
|
|
_ as e,
|
|
A as g
|
|
};
|