scb-wc-test 0.1.149 → 0.1.150
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as m,n as d,e as h,i as f,x as b,t as _}from"../../vendor/vendor.js";import"../scb-button/scb-button.js";import"../scb-menu/scb-menu.js";import"../../vendor/vendor-material.js";import"../scb-menu/scb-menu-item.js";import"../scb-divider/scb-divider.js";import"../scb-menu/scb-sub-menu.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(n,s,i){try{customElements.get(n)||t(n,s,i)}catch(p){var l=String(p||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw p}}}}catch{}})();var y=Object.defineProperty,g=Object.getOwnPropertyDescriptor,a=(e,t,n,s)=>{for(var i=s>1?void 0:s?g(t,n):t,l=e.length-1,p;l>=0;l--)(p=e[l])&&(i=(s?p(t,n,i):p(i))||i);return s&&i&&y(t,n,i),i};let r=class extends f{constructor(){super(...arguments),this.label="Dropdown",this.variant="filled",this.open=!1,this.disabled=!1,this.menuGap="3",this.width=null,this.maxWidth=null,this._slottedMenuEl=null,this._openSettledTimer=null,this._menuCloseTimer=null,this._panelResizeObserver=null,this._panelHeightSyncRaf=null,this._onDocumentClickBound=e=>{!this.open
|
|
1
|
+
import{a as m,n as d,e as h,i as f,x as b,t as _}from"../../vendor/vendor.js";import"../scb-button/scb-button.js";import"../scb-menu/scb-menu.js";import"../../vendor/vendor-material.js";import"../scb-menu/scb-menu-item.js";import"../scb-divider/scb-divider.js";import"../scb-menu/scb-sub-menu.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(n,s,i){try{customElements.get(n)||t(n,s,i)}catch(p){var l=String(p||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw p}}}}catch{}})();var y=Object.defineProperty,g=Object.getOwnPropertyDescriptor,a=(e,t,n,s)=>{for(var i=s>1?void 0:s?g(t,n):t,l=e.length-1,p;l>=0;l--)(p=e[l])&&(i=(s?p(t,n,i):p(i))||i);return s&&i&&y(t,n,i),i};let r=class extends f{constructor(){super(...arguments),this.label="Dropdown",this.variant="filled",this.open=!1,this.disabled=!1,this.menuGap="3",this.width=null,this.maxWidth=null,this._slottedMenuEl=null,this._openSettledTimer=null,this._menuCloseTimer=null,this._panelResizeObserver=null,this._panelHeightSyncRaf=null,this._onDocumentClickBound=e=>{if(!this.open)return;const t=e.composedPath(),n=t.find(s=>s instanceof HTMLElement&&s.tagName.toLowerCase()==="scb-dropdown");if(n&&n!==this){this.open=!1;return}t.includes(this)||(this.open=!1)},this._onDocumentKeydownBound=e=>{this.open&&e.key==="Escape"&&(this.open=!1)},this._onSlottedMenuOpen=()=>{this.open||(this.open=!0)},this._onSlottedMenuClose=()=>{this.open&&(this.open=!1)},this._onSlotChange=()=>{this._syncSlottedMenu(),this._applyPanelSizing(),this._applyInertByOpen(),this.requestUpdate()},this._onTriggerClick=e=>{e.stopPropagation(),!this.disabled&&(this.open=!this.open)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._onDocumentClickBound,!0),document.addEventListener("keydown",this._onDocumentKeydownBound)}disconnectedCallback(){document.removeEventListener("click",this._onDocumentClickBound,!0),document.removeEventListener("keydown",this._onDocumentKeydownBound),this._detachSlottedMenuListeners(),this._panelResizeObserver&&(this._panelResizeObserver.disconnect(),this._panelResizeObserver=null),this._panelHeightSyncRaf!==null&&(window.cancelAnimationFrame(this._panelHeightSyncRaf),this._panelHeightSyncRaf=null),this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),super.disconnectedCallback()}firstUpdated(e){super.firstUpdated(e),this._syncSlottedMenu(),this._applyPanelVars(),this._applyPanelSizing(),this._applyChevronState(),this._applyInertByOpen(),this._setupPanelResizeObserver(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen()}updated(e){super.updated(e),e.has("menuGap")&&this._applyPanelVars(),(e.has("width")||e.has("maxWidth"))&&this._applyPanelSizing(),e.has("open")&&(this.open||this._closeAllSubMenus(),this._syncSlottedMenuOpen(),this._applyChevronState(),this._applyInertByOpen(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen())}_applyPanelVars(){if(this.menuGap==null||String(this.menuGap).trim()===""){this.style.removeProperty("--scb-dropdown-panel-gap");return}this.style.setProperty("--scb-dropdown-panel-gap",this._mapSpacingToken(this.menuGap))}_applyPanelSizing(){const e=this.renderRoot.querySelector(".panel-surface");e&&(this.width&&String(this.width).trim()!==""?e.style.inlineSize=this.width:e.style.removeProperty("inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?e.style.maxInlineSize=this.maxWidth:e.style.removeProperty("max-inline-size")),this._slottedMenuEl&&(this.width&&String(this.width).trim()!==""?this._slottedMenuEl.style.inlineSize=this.width:this._slottedMenuEl.style.removeProperty("inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?this._slottedMenuEl.style.maxInlineSize=this.maxWidth:this._slottedMenuEl.style.removeProperty("max-inline-size")),this._schedulePanelHeightSync()}_setupPanelResizeObserver(){if(this._panelResizeObserver||typeof ResizeObserver>"u")return;const e=this._panelInnerEl;e&&(this._panelResizeObserver=new ResizeObserver(()=>{this._schedulePanelHeightSync()}),this._panelResizeObserver.observe(e))}_schedulePanelHeightSync(){this._panelHeightSyncRaf===null&&(this._panelHeightSyncRaf=window.requestAnimationFrame(()=>{this._panelHeightSyncRaf=null,this._syncPanelMaxHeightByOpen()}))}_syncPanelMaxHeightByOpen(){const e=this._panelSurfaceEl;if(!e)return;if(this._slottedMenuEl){e.style.removeProperty("--scb-dropdown-panel-current-max-height");return}if(!this.open){e.style.setProperty("--scb-dropdown-panel-current-max-height","0px");return}const t=this._panelInnerEl;if(!t)return;const n=`${Math.ceil(t.scrollHeight)}px`;e.style.getPropertyValue("--scb-dropdown-panel-current-max-height").trim()!==n&&e.style.setProperty("--scb-dropdown-panel-current-max-height",n)}_mapSpacingToken(e){const t=String(e).trim();return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_syncSlottedMenu(){const t=(this._slotEl?.assignedElements({flatten:!0})??[]).find(n=>n.tagName.toLowerCase()==="scb-menu");if(t===this._slottedMenuEl){this._syncSlottedMenuOpen();return}this._detachSlottedMenuListeners(),this._slottedMenuEl=t??null,this._slottedMenuEl&&(this._slottedMenuEl.addEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.addEventListener("close",this._onSlottedMenuClose),this._syncSlottedMenuOpen())}_detachSlottedMenuListeners(){this._slottedMenuEl&&(this._slottedMenuEl.removeEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.removeEventListener("close",this._onSlottedMenuClose))}_syncSlottedMenuOpen(){if(!this._slottedMenuEl)return;if(this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),this.open){this._slottedMenuEl.open=!0;return}const e=this._getPanelTransitionMs();if(e<=0){this._slottedMenuEl.open=!1;return}this._menuCloseTimer=window.setTimeout(()=>{this._menuCloseTimer=null,!this.open&&this._slottedMenuEl&&(this._slottedMenuEl.open=!1)},e)}_syncOverflowVisibilityByOpen(){if(this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this.removeAttribute("data-open-settled"),!this.open)return;const e=this.renderRoot.querySelector(".panel-surface");if(!e){this.setAttribute("data-open-settled","");return}const t=this._getTransitionMs(e);if(t<=0){this.setAttribute("data-open-settled","");return}this._openSettledTimer=window.setTimeout(()=>{this._openSettledTimer=null,this.open&&this.setAttribute("data-open-settled","")},t)}_getPanelTransitionMs(){const e=this.renderRoot.querySelector(".panel-surface");return e?this._getTransitionMs(e):0}_getTransitionMs(e){const t=getComputedStyle(e),n=t.transitionDuration.split(",").map(o=>o.trim()),s=t.transitionDelay.split(",").map(o=>o.trim()),i=o=>{const u=parseFloat(o);return Number.isFinite(u)?o.endsWith("ms")?u:o.endsWith("s")?u*1e3:u:0},l=Math.max(n.length,s.length);let p=0;for(let o=0;o<l;o+=1){const u=i(n[o]??n[n.length-1]??"0s"),c=i(s[o]??s[s.length-1]??"0s");p=Math.max(p,u+c)}return Math.ceil(p)}_applyInertByOpen(){const e=this.renderRoot.querySelector(".panel");e&&(this.open?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false"),this._restoreTabIndexesIfNeeded()):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true"),this._removeTabIndexesIfNeeded()))}_supportsInert(){return"inert"in HTMLElement.prototype}_collectFocusableFromSlot(){const e=this._slotEl;if(!e)return[];const t=e.assignedElements({flatten:!0}),n=[],s=i=>{i instanceof HTMLElement&&i.matches("a,button,input,select,textarea,[tabindex]")&&n.push(i)};return t.forEach(i=>{s(i),i.querySelectorAll?.("a,button,input,select,textarea,[tabindex]").forEach(l=>s(l))}),n}_removeTabIndexesIfNeeded(){if(this._supportsInert())return;this._collectFocusableFromSlot().forEach(t=>{const n=t.getAttribute("tabindex");n!==null&&t.setAttribute("data-scb-prev-tabindex",n),t.setAttribute("tabindex","-1")})}_restoreTabIndexesIfNeeded(){if(this._supportsInert())return;this._collectFocusableFromSlot().forEach(t=>{const n=t.getAttribute("data-scb-prev-tabindex");n!==null?(t.setAttribute("tabindex",n),t.removeAttribute("data-scb-prev-tabindex")):t.removeAttribute("tabindex")})}_closeAllSubMenus(){const e=this.querySelectorAll("scb-sub-menu");for(const t of e)t.removeAttribute("open")}_applyChevronState(){const e=this._getChevronIconEl();e&&(e.style.transition="transform var(--motion-duration-medium, 200ms) var(--motion-easing-standard, ease)",e.style.transformOrigin="center",e.style.transform=this.open?"rotate(180deg)":"rotate(0deg)")}_getChevronIconEl(){const t=this._triggerEl?.shadowRoot;return t?t.querySelector('md-icon[slot="icon"]')??t.querySelector("md-icon"):null}render(){const e=!!this._slottedMenuEl;return b`
|
|
2
2
|
<scb-button
|
|
3
3
|
label=${this.label}
|
|
4
4
|
variant=${this.variant}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.150",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -369,5 +369,5 @@
|
|
|
369
369
|
},
|
|
370
370
|
"./mvc/*": "./mvc/*"
|
|
371
371
|
},
|
|
372
|
-
"buildHash": "
|
|
372
|
+
"buildHash": "32803C4C6AFAA080C8E943ECDC22CD4D01D1891A71EADEE759E596F6A04ECDDC"
|
|
373
373
|
}
|
|
@@ -2,15 +2,23 @@ import { css as m, LitElement as f, html as b } from "lit";
|
|
|
2
2
|
import { property as d, query as u, customElement as y } from "lit/decorators.js";
|
|
3
3
|
import "../scb-button/scb-button.js";
|
|
4
4
|
import "../scb-menu/scb-menu.js";
|
|
5
|
-
var _ = Object.defineProperty, v = Object.getOwnPropertyDescriptor, a = (e, t, n,
|
|
6
|
-
for (var
|
|
7
|
-
(l = e[p]) && (
|
|
8
|
-
return
|
|
5
|
+
var _ = Object.defineProperty, v = Object.getOwnPropertyDescriptor, a = (e, t, n, i) => {
|
|
6
|
+
for (var s = i > 1 ? void 0 : i ? v(t, n) : t, p = e.length - 1, l; p >= 0; p--)
|
|
7
|
+
(l = e[p]) && (s = (i ? l(t, n, s) : l(s)) || s);
|
|
8
|
+
return i && s && _(t, n, s), s;
|
|
9
9
|
};
|
|
10
10
|
let r = class extends f {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments), this.label = "Dropdown", this.variant = "filled", this.open = !1, this.disabled = !1, this.menuGap = "3", this.width = null, this.maxWidth = null, this._slottedMenuEl = null, this._openSettledTimer = null, this._menuCloseTimer = null, this._panelResizeObserver = null, this._panelHeightSyncRaf = null, this._onDocumentClickBound = (e) => {
|
|
13
|
-
!this.open
|
|
13
|
+
if (!this.open) return;
|
|
14
|
+
const t = e.composedPath(), n = t.find(
|
|
15
|
+
(i) => i instanceof HTMLElement && i.tagName.toLowerCase() === "scb-dropdown"
|
|
16
|
+
);
|
|
17
|
+
if (n && n !== this) {
|
|
18
|
+
this.open = !1;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
t.includes(this) || (this.open = !1);
|
|
14
22
|
}, this._onDocumentKeydownBound = (e) => {
|
|
15
23
|
this.open && e.key === "Escape" && (this.open = !1);
|
|
16
24
|
}, this._onSlottedMenuOpen = () => {
|
|
@@ -24,10 +32,10 @@ let r = class extends f {
|
|
|
24
32
|
};
|
|
25
33
|
}
|
|
26
34
|
connectedCallback() {
|
|
27
|
-
super.connectedCallback(), document.addEventListener("click", this._onDocumentClickBound), document.addEventListener("keydown", this._onDocumentKeydownBound);
|
|
35
|
+
super.connectedCallback(), document.addEventListener("click", this._onDocumentClickBound, !0), document.addEventListener("keydown", this._onDocumentKeydownBound);
|
|
28
36
|
}
|
|
29
37
|
disconnectedCallback() {
|
|
30
|
-
document.removeEventListener("click", this._onDocumentClickBound), document.removeEventListener("keydown", this._onDocumentKeydownBound), this._detachSlottedMenuListeners(), this._panelResizeObserver && (this._panelResizeObserver.disconnect(), this._panelResizeObserver = null), this._panelHeightSyncRaf !== null && (window.cancelAnimationFrame(this._panelHeightSyncRaf), this._panelHeightSyncRaf = null), this._openSettledTimer !== null && (window.clearTimeout(this._openSettledTimer), this._openSettledTimer = null), this._menuCloseTimer !== null && (window.clearTimeout(this._menuCloseTimer), this._menuCloseTimer = null), super.disconnectedCallback();
|
|
38
|
+
document.removeEventListener("click", this._onDocumentClickBound, !0), document.removeEventListener("keydown", this._onDocumentKeydownBound), this._detachSlottedMenuListeners(), this._panelResizeObserver && (this._panelResizeObserver.disconnect(), this._panelResizeObserver = null), this._panelHeightSyncRaf !== null && (window.cancelAnimationFrame(this._panelHeightSyncRaf), this._panelHeightSyncRaf = null), this._openSettledTimer !== null && (window.clearTimeout(this._openSettledTimer), this._openSettledTimer = null), this._menuCloseTimer !== null && (window.clearTimeout(this._menuCloseTimer), this._menuCloseTimer = null), super.disconnectedCallback();
|
|
31
39
|
}
|
|
32
40
|
firstUpdated(e) {
|
|
33
41
|
super.firstUpdated(e), this._syncSlottedMenu(), this._applyPanelVars(), this._applyPanelSizing(), this._applyChevronState(), this._applyInertByOpen(), this._setupPanelResizeObserver(), this._syncPanelMaxHeightByOpen(), this._syncOverflowVisibilityByOpen();
|
|
@@ -80,7 +88,7 @@ let r = class extends f {
|
|
|
80
88
|
}
|
|
81
89
|
_syncSlottedMenu() {
|
|
82
90
|
var n;
|
|
83
|
-
const t = (((n = this._slotEl) == null ? void 0 : n.assignedElements({ flatten: !0 })) ?? []).find((
|
|
91
|
+
const t = (((n = this._slotEl) == null ? void 0 : n.assignedElements({ flatten: !0 })) ?? []).find((i) => i.tagName.toLowerCase() === "scb-menu");
|
|
84
92
|
if (t === this._slottedMenuEl) {
|
|
85
93
|
this._syncSlottedMenuOpen();
|
|
86
94
|
return;
|
|
@@ -126,13 +134,13 @@ let r = class extends f {
|
|
|
126
134
|
return e ? this._getTransitionMs(e) : 0;
|
|
127
135
|
}
|
|
128
136
|
_getTransitionMs(e) {
|
|
129
|
-
const t = getComputedStyle(e), n = t.transitionDuration.split(",").map((o) => o.trim()),
|
|
137
|
+
const t = getComputedStyle(e), n = t.transitionDuration.split(",").map((o) => o.trim()), i = t.transitionDelay.split(",").map((o) => o.trim()), s = (o) => {
|
|
130
138
|
const h = parseFloat(o);
|
|
131
139
|
return Number.isFinite(h) ? o.endsWith("ms") ? h : o.endsWith("s") ? h * 1e3 : h : 0;
|
|
132
|
-
}, p = Math.max(n.length,
|
|
140
|
+
}, p = Math.max(n.length, i.length);
|
|
133
141
|
let l = 0;
|
|
134
142
|
for (let o = 0; o < p; o += 1) {
|
|
135
|
-
const h =
|
|
143
|
+
const h = s(n[o] ?? n[n.length - 1] ?? "0s"), c = s(i[o] ?? i[i.length - 1] ?? "0s");
|
|
136
144
|
l = Math.max(l, h + c);
|
|
137
145
|
}
|
|
138
146
|
return Math.ceil(l);
|
|
@@ -147,12 +155,12 @@ let r = class extends f {
|
|
|
147
155
|
_collectFocusableFromSlot() {
|
|
148
156
|
const e = this._slotEl;
|
|
149
157
|
if (!e) return [];
|
|
150
|
-
const t = e.assignedElements({ flatten: !0 }), n = [],
|
|
151
|
-
|
|
158
|
+
const t = e.assignedElements({ flatten: !0 }), n = [], i = (s) => {
|
|
159
|
+
s instanceof HTMLElement && s.matches("a,button,input,select,textarea,[tabindex]") && n.push(s);
|
|
152
160
|
};
|
|
153
|
-
return t.forEach((
|
|
161
|
+
return t.forEach((s) => {
|
|
154
162
|
var p;
|
|
155
|
-
s
|
|
163
|
+
i(s), (p = s.querySelectorAll) == null || p.call(s, "a,button,input,select,textarea,[tabindex]").forEach((l) => i(l));
|
|
156
164
|
}), n;
|
|
157
165
|
}
|
|
158
166
|
_removeTabIndexesIfNeeded() {
|
package/scb-wc-test.bundle.js
CHANGED
|
@@ -5915,7 +5915,7 @@ ${this.value}</textarea
|
|
|
5915
5915
|
opacity 0.25s cubic-bezier(0.23, 1, 0.32, 1),
|
|
5916
5916
|
transform 0.32s cubic-bezier(0.23, 1, 0.32, 1);
|
|
5917
5917
|
}
|
|
5918
|
-
`,is([l({type:Boolean,reflect:!0})],a.ScbMenu.prototype,"open",2),is([l({type:Boolean,attribute:!1})],a.ScbMenu.prototype,"inSb",2),a.ScbMenu=is([_("scb-menu")],a.ScbMenu);var Tu=Object.defineProperty,Au=Object.getOwnPropertyDescriptor,$e=(o,e,t,i)=>{for(var r=i>1?void 0:i?Au(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(i?n(e,t,r):n(r))||r);return i&&r&&Tu(e,t,r),r};a.ScbDropdown=class extends x{constructor(){super(...arguments),this.label="Dropdown",this.variant="filled",this.open=!1,this.disabled=!1,this.menuGap="3",this.width=null,this.maxWidth=null,this._slottedMenuEl=null,this._openSettledTimer=null,this._menuCloseTimer=null,this._panelResizeObserver=null,this._panelHeightSyncRaf=null,this._onDocumentClickBound=e=>{!this.open
|
|
5918
|
+
`,is([l({type:Boolean,reflect:!0})],a.ScbMenu.prototype,"open",2),is([l({type:Boolean,attribute:!1})],a.ScbMenu.prototype,"inSb",2),a.ScbMenu=is([_("scb-menu")],a.ScbMenu);var Tu=Object.defineProperty,Au=Object.getOwnPropertyDescriptor,$e=(o,e,t,i)=>{for(var r=i>1?void 0:i?Au(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(i?n(e,t,r):n(r))||r);return i&&r&&Tu(e,t,r),r};a.ScbDropdown=class extends x{constructor(){super(...arguments),this.label="Dropdown",this.variant="filled",this.open=!1,this.disabled=!1,this.menuGap="3",this.width=null,this.maxWidth=null,this._slottedMenuEl=null,this._openSettledTimer=null,this._menuCloseTimer=null,this._panelResizeObserver=null,this._panelHeightSyncRaf=null,this._onDocumentClickBound=e=>{if(!this.open)return;const t=e.composedPath(),i=t.find(r=>r instanceof HTMLElement&&r.tagName.toLowerCase()==="scb-dropdown");if(i&&i!==this){this.open=!1;return}t.includes(this)||(this.open=!1)},this._onDocumentKeydownBound=e=>{this.open&&e.key==="Escape"&&(this.open=!1)},this._onSlottedMenuOpen=()=>{this.open||(this.open=!0)},this._onSlottedMenuClose=()=>{this.open&&(this.open=!1)},this._onSlotChange=()=>{this._syncSlottedMenu(),this._applyPanelSizing(),this._applyInertByOpen(),this.requestUpdate()},this._onTriggerClick=e=>{e.stopPropagation(),!this.disabled&&(this.open=!this.open)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._onDocumentClickBound,!0),document.addEventListener("keydown",this._onDocumentKeydownBound)}disconnectedCallback(){document.removeEventListener("click",this._onDocumentClickBound,!0),document.removeEventListener("keydown",this._onDocumentKeydownBound),this._detachSlottedMenuListeners(),this._panelResizeObserver&&(this._panelResizeObserver.disconnect(),this._panelResizeObserver=null),this._panelHeightSyncRaf!==null&&(window.cancelAnimationFrame(this._panelHeightSyncRaf),this._panelHeightSyncRaf=null),this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),super.disconnectedCallback()}firstUpdated(e){super.firstUpdated(e),this._syncSlottedMenu(),this._applyPanelVars(),this._applyPanelSizing(),this._applyChevronState(),this._applyInertByOpen(),this._setupPanelResizeObserver(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen()}updated(e){super.updated(e),e.has("menuGap")&&this._applyPanelVars(),(e.has("width")||e.has("maxWidth"))&&this._applyPanelSizing(),e.has("open")&&(this.open||this._closeAllSubMenus(),this._syncSlottedMenuOpen(),this._applyChevronState(),this._applyInertByOpen(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen())}_applyPanelVars(){if(this.menuGap==null||String(this.menuGap).trim()===""){this.style.removeProperty("--scb-dropdown-panel-gap");return}this.style.setProperty("--scb-dropdown-panel-gap",this._mapSpacingToken(this.menuGap))}_applyPanelSizing(){const e=this.renderRoot.querySelector(".panel-surface");e&&(this.width&&String(this.width).trim()!==""?e.style.inlineSize=this.width:e.style.removeProperty("inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?e.style.maxInlineSize=this.maxWidth:e.style.removeProperty("max-inline-size")),this._slottedMenuEl&&(this.width&&String(this.width).trim()!==""?this._slottedMenuEl.style.inlineSize=this.width:this._slottedMenuEl.style.removeProperty("inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?this._slottedMenuEl.style.maxInlineSize=this.maxWidth:this._slottedMenuEl.style.removeProperty("max-inline-size")),this._schedulePanelHeightSync()}_setupPanelResizeObserver(){if(this._panelResizeObserver||typeof ResizeObserver>"u")return;const e=this._panelInnerEl;e&&(this._panelResizeObserver=new ResizeObserver(()=>{this._schedulePanelHeightSync()}),this._panelResizeObserver.observe(e))}_schedulePanelHeightSync(){this._panelHeightSyncRaf===null&&(this._panelHeightSyncRaf=window.requestAnimationFrame(()=>{this._panelHeightSyncRaf=null,this._syncPanelMaxHeightByOpen()}))}_syncPanelMaxHeightByOpen(){const e=this._panelSurfaceEl;if(!e)return;if(this._slottedMenuEl){e.style.removeProperty("--scb-dropdown-panel-current-max-height");return}if(!this.open){e.style.setProperty("--scb-dropdown-panel-current-max-height","0px");return}const t=this._panelInnerEl;if(!t)return;const i=`${Math.ceil(t.scrollHeight)}px`;e.style.getPropertyValue("--scb-dropdown-panel-current-max-height").trim()!==i&&e.style.setProperty("--scb-dropdown-panel-current-max-height",i)}_mapSpacingToken(e){const t=String(e).trim();return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_syncSlottedMenu(){var i;const t=(((i=this._slotEl)==null?void 0:i.assignedElements({flatten:!0}))??[]).find(r=>r.tagName.toLowerCase()==="scb-menu");if(t===this._slottedMenuEl){this._syncSlottedMenuOpen();return}this._detachSlottedMenuListeners(),this._slottedMenuEl=t??null,this._slottedMenuEl&&(this._slottedMenuEl.addEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.addEventListener("close",this._onSlottedMenuClose),this._syncSlottedMenuOpen())}_detachSlottedMenuListeners(){this._slottedMenuEl&&(this._slottedMenuEl.removeEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.removeEventListener("close",this._onSlottedMenuClose))}_syncSlottedMenuOpen(){if(!this._slottedMenuEl)return;if(this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),this.open){this._slottedMenuEl.open=!0;return}const e=this._getPanelTransitionMs();if(e<=0){this._slottedMenuEl.open=!1;return}this._menuCloseTimer=window.setTimeout(()=>{this._menuCloseTimer=null,!this.open&&this._slottedMenuEl&&(this._slottedMenuEl.open=!1)},e)}_syncOverflowVisibilityByOpen(){if(this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this.removeAttribute("data-open-settled"),!this.open)return;const e=this.renderRoot.querySelector(".panel-surface");if(!e){this.setAttribute("data-open-settled","");return}const t=this._getTransitionMs(e);if(t<=0){this.setAttribute("data-open-settled","");return}this._openSettledTimer=window.setTimeout(()=>{this._openSettledTimer=null,this.open&&this.setAttribute("data-open-settled","")},t)}_getPanelTransitionMs(){const e=this.renderRoot.querySelector(".panel-surface");return e?this._getTransitionMs(e):0}_getTransitionMs(e){const t=getComputedStyle(e),i=t.transitionDuration.split(",").map(d=>d.trim()),r=t.transitionDelay.split(",").map(d=>d.trim()),s=d=>{const u=parseFloat(d);return Number.isFinite(u)?d.endsWith("ms")?u:d.endsWith("s")?u*1e3:u:0},n=Math.max(i.length,r.length);let h=0;for(let d=0;d<n;d+=1){const u=s(i[d]??i[i.length-1]??"0s"),m=s(r[d]??r[r.length-1]??"0s");h=Math.max(h,u+m)}return Math.ceil(h)}_applyInertByOpen(){const e=this.renderRoot.querySelector(".panel");e&&(this.open?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false"),this._restoreTabIndexesIfNeeded()):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true"),this._removeTabIndexesIfNeeded()))}_supportsInert(){return"inert"in HTMLElement.prototype}_collectFocusableFromSlot(){const e=this._slotEl;if(!e)return[];const t=e.assignedElements({flatten:!0}),i=[],r=s=>{s instanceof HTMLElement&&s.matches("a,button,input,select,textarea,[tabindex]")&&i.push(s)};return t.forEach(s=>{var n;r(s),(n=s.querySelectorAll)==null||n.call(s,"a,button,input,select,textarea,[tabindex]").forEach(h=>r(h))}),i}_removeTabIndexesIfNeeded(){if(this._supportsInert())return;this._collectFocusableFromSlot().forEach(t=>{const i=t.getAttribute("tabindex");i!==null&&t.setAttribute("data-scb-prev-tabindex",i),t.setAttribute("tabindex","-1")})}_restoreTabIndexesIfNeeded(){if(this._supportsInert())return;this._collectFocusableFromSlot().forEach(t=>{const i=t.getAttribute("data-scb-prev-tabindex");i!==null?(t.setAttribute("tabindex",i),t.removeAttribute("data-scb-prev-tabindex")):t.removeAttribute("tabindex")})}_closeAllSubMenus(){const e=this.querySelectorAll("scb-sub-menu");for(const t of e)t.removeAttribute("open")}_applyChevronState(){const e=this._getChevronIconEl();e&&(e.style.transition="transform var(--motion-duration-medium, 200ms) var(--motion-easing-standard, ease)",e.style.transformOrigin="center",e.style.transform=this.open?"rotate(180deg)":"rotate(0deg)")}_getChevronIconEl(){const e=this._triggerEl,t=e==null?void 0:e.shadowRoot;return t?t.querySelector('md-icon[slot="icon"]')??t.querySelector("md-icon"):null}render(){const e=!!this._slottedMenuEl;return c`
|
|
5919
5919
|
<scb-button
|
|
5920
5920
|
label=${this.label}
|
|
5921
5921
|
variant=${this.variant}
|