scb-wc 0.1.91 → 0.1.93
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/mvc/components/scb-list/scb-list-item.js +7 -7
- package/mvc/components/scb-list/scb-list.js +2 -2
- package/package.json +2 -2
- package/scb-components/scb-list/scb-list-item.d.ts +4 -0
- package/scb-components/scb-list/scb-list.d.ts +1 -0
- package/scb-list/scb-list-item.js +16 -6
- package/scb-list/scb-list.js +9 -5
- package/scb-wc.bundle.js +4 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../../vendor/lazy-focus-ring.js","../../vendor/rolldown-runtime.js","../../vendor/preload-helper.js","../../vendor/lazy-ripple.js","../scb-checkbox/scb-checkbox.js","../../vendor/assertClassBrand.js","../../vendor/classPrivateFieldGet2.js","../../vendor/decorate.js","../../vendor/vendor.js","../../vendor/md-focus-ring.js","../../vendor/attachable-controller.js","../../vendor/vendor-lit.js","../../vendor/delegate.js","../../vendor/form-associated.js","../../vendor/redispatch-event.js","../../vendor/ripple.js","../../vendor/validator.js","../../vendor/checkbox-validator.js","../scb-checkbox/scb-checkbox-group.js","../scb-switch/scb-switch.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{g as n,h as
|
|
2
|
+
import{g as n,h as y,m as w,p as a,v as o,y as k}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as u}from"../../vendor/preload-helper.js";import{t as e}from"../../vendor/decorate.js";(function(){try{var p=typeof globalThis<"u"?globalThis:window;if(!p.__scb_ce_guard_installed__){p.__scb_ce_guard_installed__=!0;var s=customElements.define.bind(customElements);customElements.define=function(t,r,l){try{customElements.get(t)||s(t,r,l)}catch(c){var d=String(c||"");if(d.indexOf("already been used")===-1&&d.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var g,_;function f(){return g??(g=u(()=>import("../../vendor/lazy-focus-ring.js").then(p=>p.i),__vite__mapDeps([0,1,2]),import.meta.url)),g}function b(){return _??(_=u(()=>import("../../vendor/lazy-ripple.js"),__vite__mapDeps([3,2]),import.meta.url)),_}var i=class extends y{constructor(...s){super(...s),this.type="text",this.href="",this.itemHref="",this.target="",this.disabled=!1,this.label="",this.supportingText="",this.overline="",this.leading=!1,this.leadingVariant="",this.leadingIcon="",this.avatarLabel="",this.avatarAlt="",this.avatarVariant="icon",this.avatarSrc="",this.imgHrefImage="",this.trailing=!1,this.trailingVariant="",this.trailingIcon="",this.trailingSwitchLabel="",this.trailingSwitchWidth="",this.trailingSwitchSelected=!1,this.density=0,this.noDivider=!1,this.__scbCheckboxLoaded=!1,this.__scbSwitchLoaded=!1,this.__focusRingRequested=!1,this.__focusRingLoaded=!1,this.__focusVisibleRaf=null,this.__rippleRequested=!1,this.__rippleLoaded=!1,this.__pendingRippleClick=!1,this.__syncRipple=async()=>{const t=this.renderRoot.querySelector("md-ripple"),r=this.renderRoot.querySelector(".row"),l=this.__pendingRippleEvent,d=this.__pendingRippleClick;this.__pendingRippleEvent=void 0,this.__pendingRippleClick=!1;const{syncRippleToControl:c}=await b();await c(t,r,l,d)},this.__onPointerInteraction=t=>{this.__ensureRipple(t)},this.__onFocusIn=()=>{this.__scheduleFocusVisibleSync()},this.__onFocusOut=()=>{this.__scheduleFocusVisibleSync()},this.__onPointerDown=()=>{this.toggleAttribute("data-focus-visible",!1)},this.__onLazyFocusRingKeydown=t=>{t.key==="Tab"&&f().then(({ensureFocusRingOnTab:r})=>r(t))},this.onRowClick=()=>{if(this.type==="link"&&!this.disabled&&(!this.__rippleLoaded||this.__pendingRippleEvent)&&(this.__pendingRippleClick=!0,this.__ensureRipple()),this.type==="link"&&(this.href||this.itemHref))return;const t=this.shadowRoot?.querySelector("scb-checkbox"),r=this.shadowRoot?.querySelector("scb-switch");if(t&&(t.checked=!t.checked),r){const l=!this.trailingSwitchSelected;r.selected=l,this.__setTrailingSwitchSelected(l,!0)}},this.__onTrailingSwitchChange=t=>{const r=t.detail?.selected,l=typeof r=="boolean"?r:t.currentTarget?.selected??!1;this.__setTrailingSwitchSelected(l,!0)},this.__onKeydown=t=>{if(!t.defaultPrevented&&(t.key==="Enter"||t.key===" ")){if(this.type==="link"){const r=this.shadowRoot?.querySelector("a[href]");if(r){t.preventDefault(),r.click();return}}t.preventDefault(),this.onRowClick()}}}static get styles(){return k`:host{display:block;border-bottom:var(--stroke-border, 1px) solid var(--md-sys-color-outline-variant);margin-bottom:calc(var(--stroke-border, 1px)*-1);outline:0;position:relative;color:var(--md-sys-color-on-surface);font-family:var(--brand-font)}:host([hidden]){display:none}:host([no-divider]){--stroke-border:0px}md-focus-ring{position:absolute;inset:0;pointer-events:none;display:none;border-radius:var(--scb-list-item-focus-ring-radius, var(--md-sys-shape-corner-small, 8px))}:host([data-focus-visible]) md-focus-ring{display:block}.row{display:flex;align-items:center;gap:var(--spacing-5, 16px);padding-block:var(--spacing-7, 24px);padding-inline:var(--spacing-5, 16px);border-radius:var(--radius-none, 0px);-webkit-tap-highlight-color:transparent;position:relative;overflow:hidden;cursor:default}:host([type="link"]) .row{cursor:pointer}:host([density="-2"]) .row,:host-context([data-density="-2"]) .row{padding-block:var(--spacing-5, 16px)}:host([density="-4"]) .row,:host-context([data-density="-4"]) .row{padding-block:var(--spacing-4, 12px)}md-ripple{border-radius:inherit;inset:0;position:absolute;pointer-events:none}.material-icon{display:inline-block;inline-size:var(--icon-size-medium, 24px);block-size:var(--icon-size-medium, 24px);overflow:hidden;font-family:"Material Symbols Outlined";font-size:var(--icon-size-medium, 24px);line-height:1;text-align:center;white-space:nowrap;text-transform:none;word-wrap:normal;direction:ltr;font-feature-settings:"liga"1;font-variation-settings:"FILL"0,"wght"400,"GRAD"0,"opsz"24;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.material-icon.scb-svg-icon{fill:currentColor;font:inherit}.leading{align-self:center;display:grid;place-items:center}.img{width:calc(var(--icon-size-extra-large, 36px) + var(--spacing-5, 16px));height:calc(var(--icon-size-extra-large, 36px) + var(--spacing-5, 16px));object-fit:contain;border-radius:var(--radius-s, 8px);filter:var(--scb-list-leading-image-filter, none)}.texts{display:grid;gap:var(--spacing-1, 2px);min-inline-size:0}.label,.overline,.supporting-text{font-family:var(--brand-font);font-size:var(--md-sys-typescale-label-medium-size);line-height:var(--md-sys-typescale-label-medium-line-height);font-weight:var(--weight-regular);letter-spacing:var(--md-sys-typescale-label-medium-tracking);color:var(--md-sys-color-on-surface-variant)}.label,.supporting-text{font-size:var(--md-sys-typescale-title-large-size);line-height:var(--md-sys-typescale-title-large-line-height);font-weight:var(--weight-semibold);letter-spacing:var(--md-sys-typescale-title-large-tracking);color:var(--md-sys-color-on-surface)}.supporting-text{font-size:var(--md-sys-typescale-body-medium-size);line-height:var(--md-sys-typescale-body-medium-line-height);font-weight:var(--weight-regular);letter-spacing:var(--md-sys-typescale-body-medium-tracking);color:var(--md-sys-color-on-surface-variant)}.trailing{margin-left:auto;align-self:center;display:flex}.trailing.trailing-switch{justify-content:flex-end}.trailing scb-checkbox{margin-inline-end:var(--scb-list-trailing-checkbox-nudge)}:host([trailing-variant="checkbox"]) .row,:host([trailing-variant="switch"]) .row{cursor:pointer}:host([disabled]) .row{cursor:default}.link{text-decoration:none;color:inherit;display:flex;width:100%;gap:12px}`}async firstUpdated(){await this.__ensureDepsLoaded(),this.addEventListener("focusin",this.__onFocusIn),this.addEventListener("focusout",this.__onFocusOut),this.addEventListener("pointerdown",this.__onPointerDown,!0),this.addEventListener("keydown",this.__onLazyFocusRingKeydown),this.addEventListener("keydown",this.__onKeydown)}disconnectedCallback(){this.removeEventListener("focusin",this.__onFocusIn),this.removeEventListener("focusout",this.__onFocusOut),this.removeEventListener("pointerdown",this.__onPointerDown,!0),this.removeEventListener("keydown",this.__onLazyFocusRingKeydown),this.removeEventListener("keydown",this.__onKeydown),this.__focusVisibleRaf!==null&&(cancelAnimationFrame(this.__focusVisibleRaf),this.__focusVisibleRaf=null),super.disconnectedCallback()}updated(s){super.updated(s),(s.has("leading")||s.has("leadingVariant")||s.has("trailing")||s.has("trailingVariant")||s.has("type")||s.has("target"))&&this.__ensureDepsLoaded()}async __ensureDepsLoaded(){this.trailing&&this.trailingVariant==="checkbox"&&!this.__scbCheckboxLoaded&&(await u(()=>import("../scb-checkbox/scb-checkbox.js"),__vite__mapDeps([4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18]),import.meta.url),this.__scbCheckboxLoaded=!0),this.trailing&&this.trailingVariant==="switch"&&!this.__scbSwitchLoaded&&(await u(()=>import("../scb-switch/scb-switch.js"),__vite__mapDeps([19,5,7,8,9,1,10,11,12,13,14,15,16,17]),import.meta.url),this.__scbSwitchLoaded=!0)}__ensureRipple(s){if(!(this.type!=="link"||this.disabled)){if(s&&(this.__pendingRippleEvent=s),this.__rippleLoaded){this.__syncRipple();return}this.__rippleRequested||(this.__rippleRequested=!0,b().then(({ensureRippleReady:t})=>t()).then(()=>{this.disabled||(this.__rippleLoaded=!0,this.requestUpdate(),this.updateComplete.then(()=>this.__syncRipple()))}))}}__scheduleFocusVisibleSync(){this.__focusVisibleRaf!==null&&cancelAnimationFrame(this.__focusVisibleRaf),this.__focusVisibleRaf=requestAnimationFrame(()=>{this.__focusVisibleRaf=null;const s=this.renderRoot instanceof ShadowRoot?this.renderRoot.activeElement:null,t=this.matches(":focus-visible")||s instanceof HTMLElement&&s.matches(":focus-visible");this.toggleAttribute("data-focus-visible",t),t&&this.__ensureFocusRing()})}__ensureFocusRing(){this.__focusRingLoaded||this.__focusRingRequested||(this.__focusRingRequested=!0,f().then(({ensureFocusRingReady:s})=>s()).then(()=>{this.__focusRingLoaded=!0,this.requestUpdate()}))}__setTrailingSwitchSelected(s,t){this.trailingSwitchSelected=s,t&&this.dispatchEvent(new CustomEvent("trailing-switch-change",{detail:{selected:s},bubbles:!0,composed:!0}))}render(){const s=this.leading?(()=>{switch(this.leadingVariant){case"icon":return this.leadingIcon?o`<div class="leading"><span class="material-icon" aria-hidden="true">${this.leadingIcon}</span></div>`:n;case"avatar":return o`
|
|
3
3
|
<div class="leading">
|
|
4
4
|
<scb-avatar
|
|
5
5
|
label=${this.avatarLabel}
|
|
@@ -10,11 +10,11 @@ import{g as n,h as b,m as w,p as a,v as o,y as k}from"../../vendor/vendor.js";im
|
|
|
10
10
|
variant=${this.avatarVariant}
|
|
11
11
|
></scb-avatar>
|
|
12
12
|
</div>
|
|
13
|
-
`;case"image":return this.imgHrefImage?o`<div class="leading"><img class="img" part="leading-image" src="${this.imgHrefImage}" alt="" /></div>`:n;default:return n}})():n,t=this.href||this.itemHref||"",
|
|
13
|
+
`;case"image":return this.imgHrefImage?o`<div class="leading"><img class="img" part="leading-image" src="${this.imgHrefImage}" alt="" /></div>`:n;default:return n}})():n,t=this.href||this.itemHref||"",r=this.target==="_blank"?"open_in_new":"chevron_right",l=this.label?`Välj ${this.label}`:"Välj",d=this.label?`Växla ${this.label}`:"Växla";let c=n;if(this.trailing)if(this.trailingVariant==="icon"){const h=this.trailingIcon||(this.type==="link"?r:"");c=h?o`<div class="trailing"><span class="material-icon" aria-hidden="true">${h}</span></div>`:n}else this.trailingVariant==="checkbox"?c=o`
|
|
14
14
|
<div class="trailing">
|
|
15
15
|
<scb-checkbox
|
|
16
16
|
aria-label=${l}
|
|
17
|
-
@click=${
|
|
17
|
+
@click=${h=>h.stopPropagation()}
|
|
18
18
|
></scb-checkbox>
|
|
19
19
|
</div>`:this.trailingVariant==="switch"&&(c=o`
|
|
20
20
|
<div class="trailing trailing-switch" style=${this.trailingSwitchWidth?`inline-size: ${this.trailingSwitchWidth}; min-inline-size: ${this.trailingSwitchWidth};`:n}>
|
|
@@ -22,11 +22,11 @@ import{g as n,h as b,m as w,p as a,v as o,y as k}from"../../vendor/vendor.js";im
|
|
|
22
22
|
.selected=${this.trailingSwitchSelected}
|
|
23
23
|
label=${this.trailingSwitchLabel||n}
|
|
24
24
|
aria-label=${d}
|
|
25
|
-
@click=${
|
|
25
|
+
@click=${h=>h.stopPropagation()}
|
|
26
26
|
@change=${this.__onTrailingSwitchChange}
|
|
27
27
|
></scb-switch>
|
|
28
|
-
</div>`);else this.type==="link"&&(c=o`<div class="trailing"><span class="material-icon" aria-hidden="true">${
|
|
29
|
-
${
|
|
28
|
+
</div>`);else this.type==="link"&&(c=o`<div class="trailing"><span class="material-icon" aria-hidden="true">${r}</span></div>`);const m=this.type==="link"&&this.target==="_blank"?"noopener noreferrer":n,v=o`
|
|
29
|
+
${s}
|
|
30
30
|
<div class="texts">
|
|
31
31
|
${this.overline?o`<div class="overline">${this.overline}</div>`:n}
|
|
32
32
|
<div class="label"><slot name="label">${this.label}</slot></div>
|
|
@@ -42,7 +42,7 @@ import{g as n,h as b,m as w,p as a,v as o,y as k}from"../../vendor/vendor.js";im
|
|
|
42
42
|
?inert=${this.disabled}
|
|
43
43
|
aria-disabled=${this.disabled?"true":"false"}
|
|
44
44
|
>
|
|
45
|
-
${this.type==="link"&&t?o`<a class="link" href=${t} target=${this.target||n} rel=${m}>${
|
|
45
|
+
${this.type==="link"&&t?o`<a class="link" href=${t} target=${this.target||n} rel=${m}>${v}</a>`:v}
|
|
46
46
|
${this.type==="link"&&this.__rippleLoaded?o`<md-ripple></md-ripple>`:n}
|
|
47
47
|
</div>
|
|
48
48
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{d as h,h as u,m,p as a,v as
|
|
1
|
+
import{d as h,h as u,m as b,p as a,v as m,y as f}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as o}from"../../vendor/decorate.js";import"./scb-list-item.js";(function(){try{var c=typeof globalThis<"u"?globalThis:window;if(!c.__scb_ce_guard_installed__){c.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,r,s){try{customElements.get(e)||t(e,r,s)}catch(p){var i=String(p||"");if(i.indexOf("already been used")===-1&&i.indexOf("NotSupportedError")===-1)throw p}}}}catch{}})();var l,n=(l=class extends u{constructor(...t){super(...t),this.noDivider=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._onSlotChange=()=>this._setupItems()}firstUpdated(){this._setupItems(),this._applySpacing()}updated(t){super.updated(t),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this._applySpacing()}_getItems(){return(this._slotEl?.assignedElements({flatten:!0})??[]).filter(t=>t instanceof HTMLElement)}_isItemDisabled(t){return t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"}_setupItems(){const t=this._getItems(),e=t.filter(i=>!this._isItemDisabled(i)),r=e.find(i=>i.getAttribute("tabindex")==="0")??e[0]??null;t.forEach(i=>{i.hasAttribute("role")||i.setAttribute("role","listitem"),i.setAttribute("tabindex",i===r?"0":"-1")});const s=this.renderRoot?.querySelector(".list");s&&!s.hasAttribute("data-kbd")&&(s.setAttribute("data-kbd","true"),s.addEventListener("keydown",i=>this._onKeyDown(i)))}_onKeyDown(t){const e=this._getItems().filter(i=>!this._isItemDisabled(i));if(!e.length)return;const r=e.findIndex(i=>i.getAttribute("tabindex")==="0"),s=i=>{const p=(i%e.length+e.length)%e.length;e.forEach(g=>g.setAttribute("tabindex","-1"));const d=e[p];d.setAttribute("tabindex","0"),d.focus()};switch(t.key){case"ArrowDown":case"ArrowRight":t.preventDefault(),s(r<0?0:r+1);break;case"ArrowUp":case"ArrowLeft":t.preventDefault(),s(r<0?0:r-1);break;case"Home":t.preventDefault(),s(0);break;case"End":t.preventDefault(),s(e.length-1);break;default:break}}_mapSpacingToken(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}_applySpacing(){const t=this._mapSpacingToken(this.spacing),e=this._mapSpacingToken(this.spacingTop)??t,r=this._mapSpacingToken(this.spacingBottom)??t,s=this._mapSpacingToken(this.spacingLeft),i=this._mapSpacingToken(this.spacingRight);e?this.style.marginBlockStart=e:this.style.removeProperty("margin-block-start"),r?this.style.marginBlockEnd=r:this.style.removeProperty("margin-block-end"),s?this.style.marginInlineStart=s:this.style.removeProperty("margin-inline-start"),i?this.style.marginInlineEnd=i:this.style.removeProperty("margin-inline-end")}render(){return m`
|
|
2
2
|
<div class="list" role="list">
|
|
3
3
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
4
4
|
</div>
|
|
5
|
-
`}},l.styles=[
|
|
5
|
+
`}},l.styles=[f`:host{display:block;--scb-list-bg:transparent}.list{background:var(--scb-list-bg);padding-block:var(--scb-list-container-padding-block, 8px)}:host(:not([no-divider])) ::slotted(scb-list-item:first-of-type:not([no-divider])){border-top:1px solid var(--md-sys-color-outline-variant)}:host([no-divider]) ::slotted(scb-list-item){--stroke-border:0px}`],l);o([a({type:Boolean,attribute:"no-divider",reflect:!0})],n.prototype,"noDivider",void 0);o([a({type:String,reflect:!0})],n.prototype,"spacing",void 0);o([a({type:String,reflect:!0,attribute:"spacing-top"})],n.prototype,"spacingTop",void 0);o([a({type:String,reflect:!0,attribute:"spacing-bottom"})],n.prototype,"spacingBottom",void 0);o([a({type:String,reflect:!0,attribute:"spacing-left"})],n.prototype,"spacingLeft",void 0);o([a({type:String,reflect:!0,attribute:"spacing-right"})],n.prototype,"spacingRight",void 0);o([h("slot")],n.prototype,"_slotEl",void 0);n=o([b("scb-list")],n);export{n as ScbList};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.93",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -460,5 +460,5 @@
|
|
|
460
460
|
},
|
|
461
461
|
"./mvc/*": "./mvc/*"
|
|
462
462
|
},
|
|
463
|
-
"buildHash": "
|
|
463
|
+
"buildHash": "8DE79553359A23978EB8639B4E65BDBFA049A83764A37F3E6687182E2FB26967"
|
|
464
464
|
}
|
|
@@ -28,6 +28,7 @@ export declare class ScbListItem extends LitElement {
|
|
|
28
28
|
private __scbSwitchLoaded;
|
|
29
29
|
private __focusRingRequested;
|
|
30
30
|
private __focusRingLoaded;
|
|
31
|
+
private __focusVisibleRaf;
|
|
31
32
|
private __rippleRequested;
|
|
32
33
|
private __rippleLoaded;
|
|
33
34
|
private __pendingRippleEvent?;
|
|
@@ -41,6 +42,9 @@ export declare class ScbListItem extends LitElement {
|
|
|
41
42
|
private __syncRipple;
|
|
42
43
|
private __onPointerInteraction;
|
|
43
44
|
private __onFocusIn;
|
|
45
|
+
private __onFocusOut;
|
|
46
|
+
private __onPointerDown;
|
|
47
|
+
private __scheduleFocusVisibleSync;
|
|
44
48
|
private __onLazyFocusRingKeydown;
|
|
45
49
|
private __ensureFocusRing;
|
|
46
50
|
private onRowClick;
|
|
@@ -11,7 +11,7 @@ function u() {
|
|
|
11
11
|
}
|
|
12
12
|
var d = class extends t {
|
|
13
13
|
constructor(...e) {
|
|
14
|
-
super(...e), this.type = "text", this.href = "", this.itemHref = "", this.target = "", this.disabled = !1, this.label = "", this.supportingText = "", this.overline = "", this.leading = !1, this.leadingVariant = "", this.leadingIcon = "", this.avatarLabel = "", this.avatarAlt = "", this.avatarVariant = "icon", this.avatarSrc = "", this.imgHrefImage = "", this.trailing = !1, this.trailingVariant = "", this.trailingIcon = "", this.trailingSwitchLabel = "", this.trailingSwitchWidth = "", this.trailingSwitchSelected = !1, this.density = 0, this.noDivider = !1, this.__scbCheckboxLoaded = !1, this.__scbSwitchLoaded = !1, this.__focusRingRequested = !1, this.__focusRingLoaded = !1, this.__rippleRequested = !1, this.__rippleLoaded = !1, this.__pendingRippleClick = !1, this.__syncRipple = async () => {
|
|
14
|
+
super(...e), this.type = "text", this.href = "", this.itemHref = "", this.target = "", this.disabled = !1, this.label = "", this.supportingText = "", this.overline = "", this.leading = !1, this.leadingVariant = "", this.leadingIcon = "", this.avatarLabel = "", this.avatarAlt = "", this.avatarVariant = "icon", this.avatarSrc = "", this.imgHrefImage = "", this.trailing = !1, this.trailingVariant = "", this.trailingIcon = "", this.trailingSwitchLabel = "", this.trailingSwitchWidth = "", this.trailingSwitchSelected = !1, this.density = 0, this.noDivider = !1, this.__scbCheckboxLoaded = !1, this.__scbSwitchLoaded = !1, this.__focusRingRequested = !1, this.__focusRingLoaded = !1, this.__focusVisibleRaf = null, this.__rippleRequested = !1, this.__rippleLoaded = !1, this.__pendingRippleClick = !1, this.__syncRipple = async () => {
|
|
15
15
|
let e = this.renderRoot.querySelector("md-ripple"), t = this.renderRoot.querySelector(".row"), n = this.__pendingRippleEvent, r = this.__pendingRippleClick;
|
|
16
16
|
this.__pendingRippleEvent = void 0, this.__pendingRippleClick = !1;
|
|
17
17
|
let { syncRippleToControl: i } = await u();
|
|
@@ -19,7 +19,11 @@ var d = class extends t {
|
|
|
19
19
|
}, this.__onPointerInteraction = (e) => {
|
|
20
20
|
this.__ensureRipple(e);
|
|
21
21
|
}, this.__onFocusIn = () => {
|
|
22
|
-
this.
|
|
22
|
+
this.__scheduleFocusVisibleSync();
|
|
23
|
+
}, this.__onFocusOut = () => {
|
|
24
|
+
this.__scheduleFocusVisibleSync();
|
|
25
|
+
}, this.__onPointerDown = () => {
|
|
26
|
+
this.toggleAttribute("data-focus-visible", !1);
|
|
23
27
|
}, this.__onLazyFocusRingKeydown = (e) => {
|
|
24
28
|
e.key === "Tab" && l().then(({ ensureFocusRingOnTab: t }) => t(e));
|
|
25
29
|
}, this.onRowClick = () => {
|
|
@@ -70,8 +74,7 @@ var d = class extends t {
|
|
|
70
74
|
display: none;
|
|
71
75
|
border-radius: var(--scb-list-item-focus-ring-radius, var(--md-sys-shape-corner-small, 8px));
|
|
72
76
|
}
|
|
73
|
-
:host(
|
|
74
|
-
:host(:focus-within) md-focus-ring { display: block; }
|
|
77
|
+
:host([data-focus-visible]) md-focus-ring { display: block; }
|
|
75
78
|
|
|
76
79
|
.row {
|
|
77
80
|
display: flex;
|
|
@@ -188,10 +191,10 @@ var d = class extends t {
|
|
|
188
191
|
`;
|
|
189
192
|
}
|
|
190
193
|
async firstUpdated() {
|
|
191
|
-
await this.__ensureDepsLoaded(), this.addEventListener("focusin", this.__onFocusIn), this.addEventListener("keydown", this.__onLazyFocusRingKeydown), this.addEventListener("keydown", this.__onKeydown);
|
|
194
|
+
await this.__ensureDepsLoaded(), this.addEventListener("focusin", this.__onFocusIn), this.addEventListener("focusout", this.__onFocusOut), this.addEventListener("pointerdown", this.__onPointerDown, !0), this.addEventListener("keydown", this.__onLazyFocusRingKeydown), this.addEventListener("keydown", this.__onKeydown);
|
|
192
195
|
}
|
|
193
196
|
disconnectedCallback() {
|
|
194
|
-
this.removeEventListener("focusin", this.__onFocusIn), this.removeEventListener("keydown", this.__onLazyFocusRingKeydown), this.removeEventListener("keydown", this.__onKeydown), super.disconnectedCallback();
|
|
197
|
+
this.removeEventListener("focusin", this.__onFocusIn), this.removeEventListener("focusout", this.__onFocusOut), this.removeEventListener("pointerdown", this.__onPointerDown, !0), this.removeEventListener("keydown", this.__onLazyFocusRingKeydown), this.removeEventListener("keydown", this.__onKeydown), this.__focusVisibleRaf !== null && (cancelAnimationFrame(this.__focusVisibleRaf), this.__focusVisibleRaf = null), super.disconnectedCallback();
|
|
195
198
|
}
|
|
196
199
|
updated(e) {
|
|
197
200
|
super.updated(e), (e.has("leading") || e.has("leadingVariant") || e.has("trailing") || e.has("trailingVariant") || e.has("type") || e.has("target")) && this.__ensureDepsLoaded();
|
|
@@ -210,6 +213,13 @@ var d = class extends t {
|
|
|
210
213
|
}));
|
|
211
214
|
}
|
|
212
215
|
}
|
|
216
|
+
__scheduleFocusVisibleSync() {
|
|
217
|
+
this.__focusVisibleRaf !== null && cancelAnimationFrame(this.__focusVisibleRaf), this.__focusVisibleRaf = requestAnimationFrame(() => {
|
|
218
|
+
this.__focusVisibleRaf = null;
|
|
219
|
+
let e = this.renderRoot instanceof ShadowRoot ? this.renderRoot.activeElement : null, t = this.matches(":focus-visible") || e instanceof HTMLElement && e.matches(":focus-visible");
|
|
220
|
+
this.toggleAttribute("data-focus-visible", t), t && this.__ensureFocusRing();
|
|
221
|
+
});
|
|
222
|
+
}
|
|
213
223
|
__ensureFocusRing() {
|
|
214
224
|
this.__focusRingLoaded || this.__focusRingRequested || (this.__focusRingRequested = !0, l().then(({ ensureFocusRingReady: e }) => e()).then(() => {
|
|
215
225
|
this.__focusRingLoaded = !0, this.requestUpdate();
|
package/scb-list/scb-list.js
CHANGED
|
@@ -16,15 +16,19 @@ var s = class extends t {
|
|
|
16
16
|
_getItems() {
|
|
17
17
|
return (this._slotEl?.assignedElements({ flatten: !0 }) ?? []).filter((e) => e instanceof HTMLElement);
|
|
18
18
|
}
|
|
19
|
+
_isItemDisabled(e) {
|
|
20
|
+
return e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true";
|
|
21
|
+
}
|
|
19
22
|
_setupItems() {
|
|
20
|
-
this._getItems().
|
|
21
|
-
|
|
23
|
+
let e = this._getItems(), t = e.filter((e) => !this._isItemDisabled(e)), n = t.find((e) => e.getAttribute("tabindex") === "0") ?? t[0] ?? null;
|
|
24
|
+
e.forEach((e) => {
|
|
25
|
+
e.hasAttribute("role") || e.setAttribute("role", "listitem"), e.setAttribute("tabindex", e === n ? "0" : "-1");
|
|
22
26
|
});
|
|
23
|
-
let
|
|
24
|
-
|
|
27
|
+
let r = this.renderRoot?.querySelector(".list");
|
|
28
|
+
r && !r.hasAttribute("data-kbd") && (r.setAttribute("data-kbd", "true"), r.addEventListener("keydown", (e) => this._onKeyDown(e)));
|
|
25
29
|
}
|
|
26
30
|
_onKeyDown(e) {
|
|
27
|
-
let t = this._getItems();
|
|
31
|
+
let t = this._getItems().filter((e) => !this._isItemDisabled(e));
|
|
28
32
|
if (!t.length) return;
|
|
29
33
|
let n = t.findIndex((e) => e.getAttribute("tabindex") === "0"), r = (e) => {
|
|
30
34
|
let n = (e % t.length + t.length) % t.length;
|
package/scb-wc.bundle.js
CHANGED
|
@@ -1652,7 +1652,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
1652
1652
|
<span class="switch-label">${this.label}</span>
|
|
1653
1653
|
${n}
|
|
1654
1654
|
</label>
|
|
1655
|
-
`:n}},P([_({type:String})],Fc.prototype,`label`,void 0),P([_({type:String,reflect:!0,attribute:`aria-label`})],Fc.prototype,`ariaLabel`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`icons`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`selected`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`required`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`disabled`,void 0),P([_({type:Boolean,reflect:!0,attribute:`full-width`})],Fc.prototype,`fullWidth`,void 0),P([_({type:String,reflect:!0})],Fc.prototype,`spacing`,void 0),P([_({type:String,attribute:`spacing-top`,reflect:!0})],Fc.prototype,`spacingTop`,void 0),P([_({type:String,attribute:`spacing-bottom`,reflect:!0})],Fc.prototype,`spacingBottom`,void 0),P([_({type:String,attribute:`spacing-left`,reflect:!0})],Fc.prototype,`spacingLeft`,void 0),P([_({type:String,attribute:`spacing-right`,reflect:!0})],Fc.prototype,`spacingRight`,void 0),P([_({type:String})],Fc.prototype,`name`,void 0),P([_({type:String})],Fc.prototype,`value`,void 0),Fc=P([o(`scb-switch`)],Fc)}));function Lc(){return zc??=Promise.resolve().then(()=>(N(),tc)),zc}function Rc(){return Bc??=Promise.resolve().then(()=>(hc(),dc)),Bc}var zc,Bc,L,Vc=n((()=>{w(),b(),F(),L=class extends C{constructor(...e){super(...e),this.type=`text`,this.href=``,this.itemHref=``,this.target=``,this.disabled=!1,this.label=``,this.supportingText=``,this.overline=``,this.leading=!1,this.leadingVariant=``,this.leadingIcon=``,this.avatarLabel=``,this.avatarAlt=``,this.avatarVariant=`icon`,this.avatarSrc=``,this.imgHrefImage=``,this.trailing=!1,this.trailingVariant=``,this.trailingIcon=``,this.trailingSwitchLabel=``,this.trailingSwitchWidth=``,this.trailingSwitchSelected=!1,this.density=0,this.noDivider=!1,this.__scbCheckboxLoaded=!1,this.__scbSwitchLoaded=!1,this.__focusRingRequested=!1,this.__focusRingLoaded=!1,this.__rippleRequested=!1,this.__rippleLoaded=!1,this.__pendingRippleClick=!1,this.__syncRipple=async()=>{let e=this.renderRoot.querySelector(`md-ripple`),t=this.renderRoot.querySelector(`.row`),n=this.__pendingRippleEvent,r=this.__pendingRippleClick;this.__pendingRippleEvent=void 0,this.__pendingRippleClick=!1;let{syncRippleToControl:i}=await Rc();await i(e,t,n,r)},this.__onPointerInteraction=e=>{this.__ensureRipple(e)},this.__onFocusIn=()=>{this.
|
|
1655
|
+
`:n}},P([_({type:String})],Fc.prototype,`label`,void 0),P([_({type:String,reflect:!0,attribute:`aria-label`})],Fc.prototype,`ariaLabel`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`icons`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`selected`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`required`,void 0),P([_({type:Boolean,reflect:!0})],Fc.prototype,`disabled`,void 0),P([_({type:Boolean,reflect:!0,attribute:`full-width`})],Fc.prototype,`fullWidth`,void 0),P([_({type:String,reflect:!0})],Fc.prototype,`spacing`,void 0),P([_({type:String,attribute:`spacing-top`,reflect:!0})],Fc.prototype,`spacingTop`,void 0),P([_({type:String,attribute:`spacing-bottom`,reflect:!0})],Fc.prototype,`spacingBottom`,void 0),P([_({type:String,attribute:`spacing-left`,reflect:!0})],Fc.prototype,`spacingLeft`,void 0),P([_({type:String,attribute:`spacing-right`,reflect:!0})],Fc.prototype,`spacingRight`,void 0),P([_({type:String})],Fc.prototype,`name`,void 0),P([_({type:String})],Fc.prototype,`value`,void 0),Fc=P([o(`scb-switch`)],Fc)}));function Lc(){return zc??=Promise.resolve().then(()=>(N(),tc)),zc}function Rc(){return Bc??=Promise.resolve().then(()=>(hc(),dc)),Bc}var zc,Bc,L,Vc=n((()=>{w(),b(),F(),L=class extends C{constructor(...e){super(...e),this.type=`text`,this.href=``,this.itemHref=``,this.target=``,this.disabled=!1,this.label=``,this.supportingText=``,this.overline=``,this.leading=!1,this.leadingVariant=``,this.leadingIcon=``,this.avatarLabel=``,this.avatarAlt=``,this.avatarVariant=`icon`,this.avatarSrc=``,this.imgHrefImage=``,this.trailing=!1,this.trailingVariant=``,this.trailingIcon=``,this.trailingSwitchLabel=``,this.trailingSwitchWidth=``,this.trailingSwitchSelected=!1,this.density=0,this.noDivider=!1,this.__scbCheckboxLoaded=!1,this.__scbSwitchLoaded=!1,this.__focusRingRequested=!1,this.__focusRingLoaded=!1,this.__focusVisibleRaf=null,this.__rippleRequested=!1,this.__rippleLoaded=!1,this.__pendingRippleClick=!1,this.__syncRipple=async()=>{let e=this.renderRoot.querySelector(`md-ripple`),t=this.renderRoot.querySelector(`.row`),n=this.__pendingRippleEvent,r=this.__pendingRippleClick;this.__pendingRippleEvent=void 0,this.__pendingRippleClick=!1;let{syncRippleToControl:i}=await Rc();await i(e,t,n,r)},this.__onPointerInteraction=e=>{this.__ensureRipple(e)},this.__onFocusIn=()=>{this.__scheduleFocusVisibleSync()},this.__onFocusOut=()=>{this.__scheduleFocusVisibleSync()},this.__onPointerDown=()=>{this.toggleAttribute(`data-focus-visible`,!1)},this.__onLazyFocusRingKeydown=e=>{e.key===`Tab`&&Lc().then(({ensureFocusRingOnTab:t})=>t(e))},this.onRowClick=()=>{if(this.type===`link`&&!this.disabled&&(!this.__rippleLoaded||this.__pendingRippleEvent)&&(this.__pendingRippleClick=!0,this.__ensureRipple()),this.type===`link`&&(this.href||this.itemHref))return;let e=this.shadowRoot?.querySelector(`scb-checkbox`),t=this.shadowRoot?.querySelector(`scb-switch`);if(e&&(e.checked=!e.checked),t){let e=!this.trailingSwitchSelected;t.selected=e,this.__setTrailingSwitchSelected(e,!0)}},this.__onTrailingSwitchChange=e=>{let t=e.detail?.selected,n=typeof t==`boolean`?t:e.currentTarget?.selected??!1;this.__setTrailingSwitchSelected(n,!0)},this.__onKeydown=e=>{if(!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)){if(this.type===`link`){let t=this.shadowRoot?.querySelector(`a[href]`);if(t){e.preventDefault(),t.click();return}}e.preventDefault(),this.onRowClick()}}}static get styles(){return m`
|
|
1656
1656
|
:host {
|
|
1657
1657
|
display: block;
|
|
1658
1658
|
border-bottom: var(--stroke-border, 1px) solid var(--md-sys-color-outline-variant);
|
|
@@ -1676,8 +1676,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
1676
1676
|
display: none;
|
|
1677
1677
|
border-radius: var(--scb-list-item-focus-ring-radius, var(--md-sys-shape-corner-small, 8px));
|
|
1678
1678
|
}
|
|
1679
|
-
:host(
|
|
1680
|
-
:host(:focus-within) md-focus-ring { display: block; }
|
|
1679
|
+
:host([data-focus-visible]) md-focus-ring { display: block; }
|
|
1681
1680
|
|
|
1682
1681
|
.row {
|
|
1683
1682
|
display: flex;
|
|
@@ -1791,7 +1790,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
1791
1790
|
width: 100%;
|
|
1792
1791
|
gap: 12px;
|
|
1793
1792
|
}
|
|
1794
|
-
`}async firstUpdated(){await this.__ensureDepsLoaded(),this.addEventListener(`focusin`,this.__onFocusIn),this.addEventListener(`keydown`,this.__onLazyFocusRingKeydown),this.addEventListener(`keydown`,this.__onKeydown)}disconnectedCallback(){this.removeEventListener(`focusin`,this.__onFocusIn),this.removeEventListener(`keydown`,this.__onLazyFocusRingKeydown),this.removeEventListener(`keydown`,this.__onKeydown),super.disconnectedCallback()}updated(e){super.updated(e),(e.has(`leading`)||e.has(`leadingVariant`)||e.has(`trailing`)||e.has(`trailingVariant`)||e.has(`type`)||e.has(`target`))&&this.__ensureDepsLoaded()}async __ensureDepsLoaded(){this.trailing&&this.trailingVariant===`checkbox`&&!this.__scbCheckboxLoaded&&(await Promise.resolve().then(()=>(Nc(),Tc)),this.__scbCheckboxLoaded=!0),this.trailing&&this.trailingVariant===`switch`&&!this.__scbSwitchLoaded&&(await Promise.resolve().then(()=>(Ic(),Pc)),this.__scbSwitchLoaded=!0)}__ensureRipple(e){if(!(this.type!==`link`||this.disabled)){if(e&&(this.__pendingRippleEvent=e),this.__rippleLoaded){this.__syncRipple();return}this.__rippleRequested||(this.__rippleRequested=!0,Rc().then(({ensureRippleReady:e})=>e()).then(()=>{this.disabled||(this.__rippleLoaded=!0,this.requestUpdate(),this.updateComplete.then(()=>this.__syncRipple()))}))}}__ensureFocusRing(){this.__focusRingLoaded||this.__focusRingRequested||(this.__focusRingRequested=!0,Lc().then(({ensureFocusRingReady:e})=>e()).then(()=>{this.__focusRingLoaded=!0,this.requestUpdate()}))}__setTrailingSwitchSelected(e,t){this.trailingSwitchSelected=e,t&&this.dispatchEvent(new CustomEvent(`trailing-switch-change`,{detail:{selected:e},bubbles:!0,composed:!0}))}render(){let e=this.leading?(()=>{switch(this.leadingVariant){case`icon`:return this.leadingIcon?x`<div class="leading"><span class="material-icon" aria-hidden="true">${this.leadingIcon}</span></div>`:S;case`avatar`:return x`
|
|
1793
|
+
`}async firstUpdated(){await this.__ensureDepsLoaded(),this.addEventListener(`focusin`,this.__onFocusIn),this.addEventListener(`focusout`,this.__onFocusOut),this.addEventListener(`pointerdown`,this.__onPointerDown,!0),this.addEventListener(`keydown`,this.__onLazyFocusRingKeydown),this.addEventListener(`keydown`,this.__onKeydown)}disconnectedCallback(){this.removeEventListener(`focusin`,this.__onFocusIn),this.removeEventListener(`focusout`,this.__onFocusOut),this.removeEventListener(`pointerdown`,this.__onPointerDown,!0),this.removeEventListener(`keydown`,this.__onLazyFocusRingKeydown),this.removeEventListener(`keydown`,this.__onKeydown),this.__focusVisibleRaf!==null&&(cancelAnimationFrame(this.__focusVisibleRaf),this.__focusVisibleRaf=null),super.disconnectedCallback()}updated(e){super.updated(e),(e.has(`leading`)||e.has(`leadingVariant`)||e.has(`trailing`)||e.has(`trailingVariant`)||e.has(`type`)||e.has(`target`))&&this.__ensureDepsLoaded()}async __ensureDepsLoaded(){this.trailing&&this.trailingVariant===`checkbox`&&!this.__scbCheckboxLoaded&&(await Promise.resolve().then(()=>(Nc(),Tc)),this.__scbCheckboxLoaded=!0),this.trailing&&this.trailingVariant===`switch`&&!this.__scbSwitchLoaded&&(await Promise.resolve().then(()=>(Ic(),Pc)),this.__scbSwitchLoaded=!0)}__ensureRipple(e){if(!(this.type!==`link`||this.disabled)){if(e&&(this.__pendingRippleEvent=e),this.__rippleLoaded){this.__syncRipple();return}this.__rippleRequested||(this.__rippleRequested=!0,Rc().then(({ensureRippleReady:e})=>e()).then(()=>{this.disabled||(this.__rippleLoaded=!0,this.requestUpdate(),this.updateComplete.then(()=>this.__syncRipple()))}))}}__scheduleFocusVisibleSync(){this.__focusVisibleRaf!==null&&cancelAnimationFrame(this.__focusVisibleRaf),this.__focusVisibleRaf=requestAnimationFrame(()=>{this.__focusVisibleRaf=null;let e=this.renderRoot instanceof ShadowRoot?this.renderRoot.activeElement:null,t=this.matches(`:focus-visible`)||e instanceof HTMLElement&&e.matches(`:focus-visible`);this.toggleAttribute(`data-focus-visible`,t),t&&this.__ensureFocusRing()})}__ensureFocusRing(){this.__focusRingLoaded||this.__focusRingRequested||(this.__focusRingRequested=!0,Lc().then(({ensureFocusRingReady:e})=>e()).then(()=>{this.__focusRingLoaded=!0,this.requestUpdate()}))}__setTrailingSwitchSelected(e,t){this.trailingSwitchSelected=e,t&&this.dispatchEvent(new CustomEvent(`trailing-switch-change`,{detail:{selected:e},bubbles:!0,composed:!0}))}render(){let e=this.leading?(()=>{switch(this.leadingVariant){case`icon`:return this.leadingIcon?x`<div class="leading"><span class="material-icon" aria-hidden="true">${this.leadingIcon}</span></div>`:S;case`avatar`:return x`
|
|
1795
1794
|
<div class="leading">
|
|
1796
1795
|
<scb-avatar
|
|
1797
1796
|
label=${this.avatarLabel}
|
|
@@ -1839,7 +1838,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
1839
1838
|
</div>
|
|
1840
1839
|
|
|
1841
1840
|
${this.__focusRingLoaded?x`<md-focus-ring></md-focus-ring>`:S}
|
|
1842
|
-
`}},P([_({type:String,reflect:!0,attribute:`type`})],L.prototype,`type`,void 0),P([_({type:String})],L.prototype,`href`,void 0),P([_({type:String,attribute:`item-href`})],L.prototype,`itemHref`,void 0),P([_({type:String,attribute:`target`})],L.prototype,`target`,void 0),P([_({type:Boolean,attribute:`disabled`})],L.prototype,`disabled`,void 0),P([_({type:String,reflect:!0})],L.prototype,`label`,void 0),P([_({type:String,attribute:`supporting-text`})],L.prototype,`supportingText`,void 0),P([_({type:String,attribute:`overline`})],L.prototype,`overline`,void 0),P([_({type:Boolean})],L.prototype,`leading`,void 0),P([_({type:String,attribute:`leading-variant`,reflect:!0})],L.prototype,`leadingVariant`,void 0),P([_({type:String,attribute:`leading-icon`})],L.prototype,`leadingIcon`,void 0),P([_({type:String,attribute:`avatar-label`})],L.prototype,`avatarLabel`,void 0),P([_({type:String,attribute:`avatar-alt`})],L.prototype,`avatarAlt`,void 0),P([_({type:String,attribute:`avatar-variant`})],L.prototype,`avatarVariant`,void 0),P([_({type:String,attribute:`avatar-src`})],L.prototype,`avatarSrc`,void 0),P([_({type:String,reflect:!0,attribute:`img-href-image`})],L.prototype,`imgHrefImage`,void 0),P([_({type:Boolean})],L.prototype,`trailing`,void 0),P([_({type:String,attribute:`trailing-variant`,reflect:!0})],L.prototype,`trailingVariant`,void 0),P([_({type:String,attribute:`trailing-icon`})],L.prototype,`trailingIcon`,void 0),P([_({type:String,attribute:`trailing-switch-label`})],L.prototype,`trailingSwitchLabel`,void 0),P([_({type:String,attribute:`trailing-switch-width`})],L.prototype,`trailingSwitchWidth`,void 0),P([_({type:Boolean,attribute:`trailing-switch-selected`,reflect:!0})],L.prototype,`trailingSwitchSelected`,void 0),P([_({type:Number,reflect:!0})],L.prototype,`density`,void 0),P([_({type:Boolean,attribute:`no-divider`,reflect:!0})],L.prototype,`noDivider`,void 0),L=P([o(`scb-list-item`)],L)})),Hc=r({ScbList:()=>Uc}),Uc,Wc=n((()=>{w(),b(),Vc(),F(),Uc=class extends C{constructor(...e){super(...e),this.noDivider=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._onSlotChange=()=>this._setupItems()}firstUpdated(){this._setupItems(),this._applySpacing()}updated(e){super.updated(e),(e.has(`spacing`)||e.has(`spacingTop`)||e.has(`spacingBottom`)||e.has(`spacingLeft`)||e.has(`spacingRight`))&&this._applySpacing()}_getItems(){return(this._slotEl?.assignedElements({flatten:!0})??[]).filter(e=>e instanceof HTMLElement)}_setupItems(){this._getItems().
|
|
1841
|
+
`}},P([_({type:String,reflect:!0,attribute:`type`})],L.prototype,`type`,void 0),P([_({type:String})],L.prototype,`href`,void 0),P([_({type:String,attribute:`item-href`})],L.prototype,`itemHref`,void 0),P([_({type:String,attribute:`target`})],L.prototype,`target`,void 0),P([_({type:Boolean,attribute:`disabled`})],L.prototype,`disabled`,void 0),P([_({type:String,reflect:!0})],L.prototype,`label`,void 0),P([_({type:String,attribute:`supporting-text`})],L.prototype,`supportingText`,void 0),P([_({type:String,attribute:`overline`})],L.prototype,`overline`,void 0),P([_({type:Boolean})],L.prototype,`leading`,void 0),P([_({type:String,attribute:`leading-variant`,reflect:!0})],L.prototype,`leadingVariant`,void 0),P([_({type:String,attribute:`leading-icon`})],L.prototype,`leadingIcon`,void 0),P([_({type:String,attribute:`avatar-label`})],L.prototype,`avatarLabel`,void 0),P([_({type:String,attribute:`avatar-alt`})],L.prototype,`avatarAlt`,void 0),P([_({type:String,attribute:`avatar-variant`})],L.prototype,`avatarVariant`,void 0),P([_({type:String,attribute:`avatar-src`})],L.prototype,`avatarSrc`,void 0),P([_({type:String,reflect:!0,attribute:`img-href-image`})],L.prototype,`imgHrefImage`,void 0),P([_({type:Boolean})],L.prototype,`trailing`,void 0),P([_({type:String,attribute:`trailing-variant`,reflect:!0})],L.prototype,`trailingVariant`,void 0),P([_({type:String,attribute:`trailing-icon`})],L.prototype,`trailingIcon`,void 0),P([_({type:String,attribute:`trailing-switch-label`})],L.prototype,`trailingSwitchLabel`,void 0),P([_({type:String,attribute:`trailing-switch-width`})],L.prototype,`trailingSwitchWidth`,void 0),P([_({type:Boolean,attribute:`trailing-switch-selected`,reflect:!0})],L.prototype,`trailingSwitchSelected`,void 0),P([_({type:Number,reflect:!0})],L.prototype,`density`,void 0),P([_({type:Boolean,attribute:`no-divider`,reflect:!0})],L.prototype,`noDivider`,void 0),L=P([o(`scb-list-item`)],L)})),Hc=r({ScbList:()=>Uc}),Uc,Wc=n((()=>{w(),b(),Vc(),F(),Uc=class extends C{constructor(...e){super(...e),this.noDivider=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._onSlotChange=()=>this._setupItems()}firstUpdated(){this._setupItems(),this._applySpacing()}updated(e){super.updated(e),(e.has(`spacing`)||e.has(`spacingTop`)||e.has(`spacingBottom`)||e.has(`spacingLeft`)||e.has(`spacingRight`))&&this._applySpacing()}_getItems(){return(this._slotEl?.assignedElements({flatten:!0})??[]).filter(e=>e instanceof HTMLElement)}_isItemDisabled(e){return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}_setupItems(){let e=this._getItems(),t=e.filter(e=>!this._isItemDisabled(e)),n=t.find(e=>e.getAttribute(`tabindex`)===`0`)??t[0]??null;e.forEach(e=>{e.hasAttribute(`role`)||e.setAttribute(`role`,`listitem`),e.setAttribute(`tabindex`,e===n?`0`:`-1`)});let r=this.renderRoot?.querySelector(`.list`);r&&!r.hasAttribute(`data-kbd`)&&(r.setAttribute(`data-kbd`,`true`),r.addEventListener(`keydown`,e=>this._onKeyDown(e)))}_onKeyDown(e){let t=this._getItems().filter(e=>!this._isItemDisabled(e));if(!t.length)return;let n=t.findIndex(e=>e.getAttribute(`tabindex`)===`0`),r=e=>{let n=(e%t.length+t.length)%t.length;t.forEach(e=>e.setAttribute(`tabindex`,`-1`));let r=t[n];r.setAttribute(`tabindex`,`0`),r.focus()};switch(e.key){case`ArrowDown`:case`ArrowRight`:e.preventDefault(),r(n<0?0:n+1);break;case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),r(n<0?0:n-1);break;case`Home`:e.preventDefault(),r(0);break;case`End`:e.preventDefault(),r(t.length-1);break;default:break}}_mapSpacingToken(e){if(!e)return;let t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_applySpacing(){let e=this._mapSpacingToken(this.spacing),t=this._mapSpacingToken(this.spacingTop)??e,n=this._mapSpacingToken(this.spacingBottom)??e,r=this._mapSpacingToken(this.spacingLeft),i=this._mapSpacingToken(this.spacingRight);t?this.style.marginBlockStart=t:this.style.removeProperty(`margin-block-start`),n?this.style.marginBlockEnd=n:this.style.removeProperty(`margin-block-end`),r?this.style.marginInlineStart=r:this.style.removeProperty(`margin-inline-start`),i?this.style.marginInlineEnd=i:this.style.removeProperty(`margin-inline-end`)}static{this.styles=[m`
|
|
1843
1842
|
:host {
|
|
1844
1843
|
display: block;
|
|
1845
1844
|
--scb-list-bg: transparent;
|